Class PriorityFeeCalculator

This class determines whether a priority fee needs to be included in a transaction based on a recent history of timed out transactions.

Hierarchy

  • PriorityFeeCalculator

Constructors

  • Constructor for the PriorityFeeCalculator class.

    Parameters

    • currentTimeMs: number

      The current time in milliseconds.

    • priorityFeeLatchDurationMs: number = ...

      The duration for how long to stay in triggered state before resetting. Default value is 10 seconds.

    Returns PriorityFeeCalculator

Properties

lastTxTimeoutCount: number
lastTxTimeoutCountTriggered: number
priorityFeeLatchDurationMs: number
priorityFeeTriggered: boolean

Methods

  • Calculates the compute unit price to use based on the desired additional fee to pay and the compute unit limit.

    Returns

    the compute unit price to use, in micro lamports

    Parameters

    • computeUnitLimit: number

      desired CU to use

    • additionalFeeMicroLamports: number

      desired additional fee to pay, in micro lamports

    Returns number

  • This method returns a transaction instruction list that sets the compute limit on the ComputeBudget program.

    Returns

    An array of transaction instructions.

    Parameters

    • computeUnitLimit: number

      The maximum number of compute units that can be used by the transaction.

    Returns TransactionInstruction[]

  • This method generates a list of transaction instructions for the ComputeBudget program, and includes a priority fee if it's required

    Returns

    An array of transaction instructions.

    Parameters

    • computeUnitLimit: number

      The maximum number of compute units that can be used by the transaction.

    • usePriorityFee: boolean

      A boolean indicating whether to include a priority fee in the transaction, this should be from this.updatePriorityFee() or this.priorityFeeTriggered.

    • additionalFeeMicroLamports: number

      The additional fee to be paid, in micro lamports, the actual price will be calculated.

    Returns TransactionInstruction[]

  • Update the priority fee state based on the current time and the current timeout count.

    Returns

    true if priority fee should be included in the next transaction

    Parameters

    • currentTimeMs: number

      current time in milliseconds

    • txTimeoutCount: number

    Returns boolean

Generated using TypeDoc