UNPKG

@drift-labs/sdk-browser

Version:
45 lines (44 loc) 2.7 kB
import { TransactionInstruction } from '@solana/web3.js'; /** * This class determines whether a priority fee needs to be included in a transaction based on * a recent history of timed out transactions. */ export declare class PriorityFeeCalculator { lastTxTimeoutCount: number; priorityFeeTriggered: boolean; lastTxTimeoutCountTriggered: number; priorityFeeLatchDurationMs: number; /** * Constructor for the PriorityFeeCalculator class. * @param currentTimeMs - The current time in milliseconds. * @param priorityFeeLatchDurationMs - The duration for how long to stay in triggered state before resetting. Default value is 10 seconds. */ constructor(currentTimeMs: number, priorityFeeLatchDurationMs?: number); /** * Update the priority fee state based on the current time and the current timeout count. * @param currentTimeMs current time in milliseconds * @returns true if priority fee should be included in the next transaction */ updatePriorityFee(currentTimeMs: number, txTimeoutCount: number): boolean; /** * This method returns a transaction instruction list that sets the compute limit on the ComputeBudget program. * @param computeUnitLimit - The maximum number of compute units that can be used by the transaction. * @returns An array of transaction instructions. */ generateComputeBudgetIxs(computeUnitLimit: number): Array<TransactionInstruction>; /** * Calculates the compute unit price to use based on the desired additional fee to pay and the compute unit limit. * @param computeUnitLimit desired CU to use * @param additionalFeeMicroLamports desired additional fee to pay, in micro lamports * @returns the compute unit price to use, in micro lamports */ calculateComputeUnitPrice(computeUnitLimit: number, additionalFeeMicroLamports: number): number; /** * This method generates a list of transaction instructions for the ComputeBudget program, and includes a priority fee if it's required * @param computeUnitLimit - The maximum number of compute units that can be used by the transaction. * @param usePriorityFee - A boolean indicating whether to include a priority fee in the transaction, this should be from `this.updatePriorityFee()` or `this.priorityFeeTriggered`. * @param additionalFeeMicroLamports - The additional fee to be paid, in micro lamports, the actual price will be calculated. * @returns An array of transaction instructions. */ generateComputeBudgetWithPriorityFeeIx(computeUnitLimit: number, usePriorityFee: boolean, additionalFeeMicroLamports: number): Array<TransactionInstruction>; }