@hawksightco/hawk-sdk
Advanced tools
Comparing version 0.0.38 to 0.0.39
@@ -160,6 +160,11 @@ "use strict"; | ||
const estimate = yield (0, functions_1.getFeeEstimate)(this.generalUtility, priorityLevel, this.txMetadataResponse); | ||
const priorityFeeEstimate = maxPriorityFee !== undefined && maxPriorityFee > 0 | ||
? Math.round(Math.min(estimate, maxPriorityFee)) | ||
: Math.round(estimate); | ||
// Create priority fee ixs for transaction | ||
// Calculate the total fee in lamports | ||
let totalPriorityFeeLamports = (new bn_js_1.BN(estimate).mul(new bn_js_1.BN(computeUnitLimit)).div(new bn_js_1.BN(1000000))).toNumber(); | ||
// If maxPriorityFee is defined and it is less than the total calculated fee, cap it | ||
if (maxPriorityFee !== undefined && maxPriorityFee > 0 && totalPriorityFeeLamports > maxPriorityFee) { | ||
totalPriorityFeeLamports = maxPriorityFee; | ||
} | ||
// Convert the total priority fee back to microLamports per compute unit | ||
const priorityFeePerUnitMicroLamports = (new bn_js_1.BN(totalPriorityFeeLamports).mul(new bn_js_1.BN(1000000)).div(new bn_js_1.BN(computeUnitLimit))).toNumber(); | ||
// Create priority fee instructions for transaction | ||
const priorityFeeIxs = [ | ||
@@ -171,10 +176,7 @@ web3.ComputeBudgetProgram.setComputeUnitLimit({ | ||
// CU * CU PRICE -> 1400000 * feeEstimate.priorityFeeEstimate | ||
microLamports: priorityFeeEstimate, | ||
microLamports: priorityFeePerUnitMicroLamports, | ||
}), | ||
]; | ||
this._priorityFeeEstimate = (new bn_js_1.BN(priorityFeeEstimate) | ||
.mul(new bn_js_1.BN(computeUnitLimit)) | ||
.div(new bn_js_1.BN(1000000)) | ||
.add(new bn_js_1.BN(5000)) | ||
.toNumber() / 1000000000).toString(); | ||
// Store the total priority fee in lamports | ||
this._priorityFeeEstimate = totalPriorityFeeLamports.toString(); | ||
// Append priority fee instruction at the beginning | ||
@@ -181,0 +183,0 @@ this._instructions.unshift(...priorityFeeIxs); |
{ | ||
"name": "@hawksightco/hawk-sdk", | ||
"version": "0.0.38", | ||
"version": "0.0.39", | ||
"description": "Hawksight v2 SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
132361
2399