@orca-so/common-sdk
Advanced tools
Comparing version 0.6.3 to 0.6.4-alpha-1
@@ -125,2 +125,15 @@ import { AddressLookupTableAccount, Commitment, Connection, PublicKey, RecentPrioritizationFees, SendOptions, Signer, Transaction, VersionedTransaction } from "@solana/web3.js"; | ||
/** | ||
* Estimates the fee for this transaction | ||
* @param getPriorityFeePerUnit - A function to get the priority fee per unit | ||
* @param computeLimitMargin - The margin for the compute budget limit | ||
* @param selectionPercentile - The percentile to use when calculating the priority fee | ||
* @param lookupTableAccounts - The lookup table accounts that will be used in the transaction | ||
* @returns An object containing the estimated values for consumed compute units, priority fee per unit in lamports, and the total priority fee in lamports | ||
*/ | ||
estimateFee(getPriorityFeePerUnit?: (lockedWritableAccounts: PublicKey[]) => Promise<RecentPrioritizationFees[]>, computeLimitMargin?: number, selectionPercentile?: number, lookupTableAccounts?: AddressLookupTableAccount[]): Promise<{ | ||
estConsumedComputeUnits: number; | ||
estPriorityFeePerUnitInLamports: RecentPrioritizationFees[]; | ||
estPriorityFeeInLamports: number; | ||
}>; | ||
/** | ||
* Constructs a transaction payload with the gathered instructions | ||
@@ -127,0 +140,0 @@ * @param userOptions - Options to override the default build options |
@@ -193,2 +193,25 @@ "use strict"; | ||
/** | ||
* Estimates the fee for this transaction | ||
* @param getPriorityFeePerUnit - A function to get the priority fee per unit | ||
* @param computeLimitMargin - The margin for the compute budget limit | ||
* @param selectionPercentile - The percentile to use when calculating the priority fee | ||
* @param lookupTableAccounts - The lookup table accounts that will be used in the transaction | ||
* @returns An object containing the estimated values for consumed compute units, priority fee per unit in lamports, and the total priority fee in lamports | ||
*/ | ||
async estimateFee(getPriorityFeePerUnit, computeLimitMargin, selectionPercentile, lookupTableAccounts) { | ||
const estConsumedComputeUnits = await (0, compute_budget_1.estimateComputeBudgetLimit)(this.connection, this.instructions, lookupTableAccounts, this.wallet.publicKey, computeLimitMargin ?? 0.1); | ||
const lockedWritableAccounts = (0, compute_budget_1.getLockWritableAccounts)(this.instructions); | ||
const estPriorityFeePerUnitInLamports = await (getPriorityFeePerUnit | ||
? getPriorityFeePerUnit(lockedWritableAccounts) | ||
: this.connection.getRecentPrioritizationFees({ | ||
lockedWritableAccounts, | ||
})); | ||
const estPriorityFeeInLamports = await (0, compute_budget_1.getPriorityFeeInLamports)(this.connection, estConsumedComputeUnits, lockedWritableAccounts, selectionPercentile ?? compute_budget_1.DEFAULT_PRIORITY_FEE_PERCENTILE, getPriorityFeePerUnit); | ||
return { | ||
estConsumedComputeUnits, | ||
estPriorityFeePerUnitInLamports, | ||
estPriorityFeeInLamports, | ||
}; | ||
} | ||
/** | ||
* Constructs a transaction payload with the gathered instructions | ||
@@ -195,0 +218,0 @@ * @param userOptions - Options to override the default build options |
{ | ||
"name": "@orca-so/common-sdk", | ||
"version": "0.6.3", | ||
"version": "0.6.4-alpha-1", | ||
"description": "Common Typescript components across Orca", | ||
@@ -38,2 +38,2 @@ "repository": "https://github.com/orca-so/orca-sdks", | ||
] | ||
} | ||
} |
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
2009
163453