From c1e4040921f3a4e981e2d5fe0224fe1666c31a78 Mon Sep 17 00:00:00 2001 From: "amilz.sol" <85324096+amilz@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:27:19 -0800 Subject: [PATCH] feat: add recommended priority fee - update types to have a recommended level and response - if user passes 'recommended' utilize the recommended value --- packages/libs/sdk/src/solana/solana.ts | 5 ++++- packages/libs/sdk/src/solana/types.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/libs/sdk/src/solana/solana.ts b/packages/libs/sdk/src/solana/solana.ts index 50f3d4ae..c098f372 100644 --- a/packages/libs/sdk/src/solana/solana.ts +++ b/packages/libs/sdk/src/solana/solana.ts @@ -128,7 +128,10 @@ export class Solana { feeType: PriorityFeeLevels = 'medium' ) { const { result } = await this.fetchEstimatePriorityFees({}); - const priorityFee = result.per_compute_unit[feeType]; + const priorityFee = feeType === 'recommended' + ? result.recommended + : result.per_compute_unit[feeType]; + const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: priorityFee, }); diff --git a/packages/libs/sdk/src/solana/types.ts b/packages/libs/sdk/src/solana/types.ts index c1c004f5..629ad90e 100644 --- a/packages/libs/sdk/src/solana/types.ts +++ b/packages/libs/sdk/src/solana/types.ts @@ -23,7 +23,7 @@ type PercentileRangeUnion = | '95' | '100'; -export type PriorityFeeLevels = 'low' | 'medium' | 'high' | 'extreme'; +export type PriorityFeeLevels = 'low' | 'medium' | 'high' | 'extreme' | 'recommended'; export interface PriorityFeeRequestPayload { method: string; @@ -53,6 +53,7 @@ export interface PriorityFeeResponseData { }; per_compute_unit: PriorityFeeEstimates; per_transaction: PriorityFeeEstimates; + recommended: number; }; id: number; }