Skip to content

Commit

Permalink
chore: add recommended field to prio fee api
Browse files Browse the repository at this point in the history
  • Loading branch information
amilz committed Dec 17, 2024
1 parent 7f5fb5c commit 7241adf
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion solana/priority-fees-addon/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const params: EstimatePriorityFeesParams = {
async function createDynamicPriorityFeeInstruction() {
const { result } = await fetchEstimatePriorityFees(params);
console.table(result);
const priorityFee = result.per_compute_unit.high; // 👈 Replace depending on your transaction requirements (e.g., low, medium, high, or specific percentile)
const priorityFee = result.recommended; // 👈 Replace depending on your transaction requirements (e.g., low, medium, high, or specific percentile)
const priorityFeeInstruction = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: priorityFee });
return priorityFeeInstruction;
}
Expand Down
1 change: 1 addition & 0 deletions solana/priority-fees-addon/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface ResponseData {
};
per_compute_unit: FeeEstimates;
per_transaction: FeeEstimates;
recommended: number;
};
id: number;
}
Expand Down
4 changes: 3 additions & 1 deletion solana/web3.js-2.0/optimized-tx/src/QuickNodeSolana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ export class QuickNodeSolana {
last_n_blocks: priorityFeeQuery.last_n_blocks,
api_version: priorityFeeQuery.api_version
}).send();
return priorityFees.per_compute_unit[priorityFeeQuery.level];
return priorityFeeQuery.level === "recommended"
? priorityFees.recommended
: priorityFees.per_compute_unit[priorityFeeQuery.level];
}

async prepareSmartTransactionMessage({
Expand Down
3 changes: 2 additions & 1 deletion solana/web3.js-2.0/optimized-tx/src/types/priority-fees.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type PriorityFeeLevel = { level: "low" | "medium" | "high" | "extreme" };
type PriorityFeeLevel = { level: "low" | "medium" | "high" | "extreme" | "recommended" };

interface FeeEstimates {
extreme: number;
Expand All @@ -16,6 +16,7 @@ interface EstimatePriorityFeesResponse {
};
per_compute_unit: FeeEstimates;
per_transaction: FeeEstimates;
recommended: number;
};

interface EstimatePriorityFeesParams {
Expand Down
1 change: 1 addition & 0 deletions solana/web3.js-2.0/quicknode-addons/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface EstimatePriorityFeesResponse {
};
per_compute_unit: FeeEstimates;
per_transaction: FeeEstimates;
recommended: number;
};

interface EstimatePriorityFeesParams {
Expand Down

0 comments on commit 7241adf

Please sign in to comment.