From 94ff39539114bc58ced7c433dc4976cebea6b1ae Mon Sep 17 00:00:00 2001 From: John Mitsch Date: Tue, 19 Mar 2024 10:38:06 -0300 Subject: [PATCH] small update --- packages/libs/sdk/src/solana/solana.ts | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/libs/sdk/src/solana/solana.ts b/packages/libs/sdk/src/solana/solana.ts index d5f830e7..d1313d5f 100644 --- a/packages/libs/sdk/src/solana/solana.ts +++ b/packages/libs/sdk/src/solana/solana.ts @@ -87,18 +87,8 @@ export class Solana { return transaction; } - private async createDynamicPriorityFeeInstruction( - feeType: PriorityFeeLevels = 'medium' - ) { - const { result } = await this.fetchEstimatePriorityFees({}); - const priorityFee = result.per_compute_unit[feeType]; - const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({ - microLamports: priorityFee, - }); - return priorityFeeInstruction; - } - - private async fetchEstimatePriorityFees({ + // Get the priority fee averages based on fee data from the latest blocks + async fetchEstimatePriorityFees({ last_n_blocks = 100, account = undefined, }: EstimatePriorityFeesParams): Promise { @@ -138,6 +128,17 @@ export class Solana { return data; } + private async createDynamicPriorityFeeInstruction( + feeType: PriorityFeeLevels = 'medium' + ) { + const { result } = await this.fetchEstimatePriorityFees({}); + const priorityFee = result.per_compute_unit[feeType]; + const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: priorityFee, + }); + return priorityFeeInstruction; + } + private async getSimulationUnits( connection: Connection, instructions: TransactionInstruction[],