UNPKG

@drift-labs/common

Version:

Common functions for Drift

25 lines (24 loc) 1.48 kB
export declare const DRIFT_TX_COMPUTE_UNIT_ESTIMATE = 600000; export declare const SANITY_CHECK_ABS_MAX_FEE_IN_SOL = 1; export declare const SANITY_CHECK_ABS_MAX_CU_PRICE: number; /** * The goal of this class is to encapsulate all logic around "priority fee calculation". The majority of the complexity is in calculating the dynamic priority fees, because the other settings are very simple. * * Priority Fees are determined by a "compute unit price". The compute unit price is denominated in "micro-lamports per compute unit". The end fee for the transactions is calculated as: * FEE_LAMPORTS = COMPUTE_UNIT_PRICE_MICRO_LAMPORTS * COMPUTE_UNITS / 10^6 */ export declare class PriorityFeeCalculator { constructor(); /** * The baseline dynamic compute units price is the "target" price to use. It is based on the latest * results on the priority fee subscriber, and some other contextual information. */ static calculateDynamicCUPriceToUse({ latestFeeSample, boostMultiplier, extraMultiplier, }: { latestFeeSample: number; boostMultiplier?: number; extraMultiplier?: number; }): number; static getPriorityFeeInSolForComputeUnitPrice(computeUnitPrice: number, txComputeUnits?: number): number; static calculatePriorityFeeInUsd(computeUnitPrice: number, solPrice: number, txComputeUnits?: number): number; static calculateCUPriceForTargetSolValue(targetSolValue: number, txComputeUnits?: number): number; }