usePriorityFeeSubscriber
Subscribes to priority fee updates from the Solana network. This hook creates and manages aPriorityFeeSubscriber that monitors recent transaction fees to help determine appropriate priority fees for transactions.
Signature
Parameters
The strategy to use for calculating priority fees. This determines how fees are computed from recent transaction data.
Optional array of addresses to monitor for priority fee data. Defaults to
PRIORITY_FEE_SUBSCRIPTION_ADDRESSES constant.Returns
A React ref containing thePriorityFeeSubscriber instance, or null if not yet initialized.
Example
Implementation Details
- Uses
usePriorityFeesPollingRate()to determine the update frequency - Monitors the last
FEE_SUBSCRIPTION_SLOT_LOOKBACKslots for fee data - Automatically subscribes on mount and unsubscribes on unmount
- Re-initializes when connection, polling rate, or strategy changes
Source
source/react/src/hooks/priorityFees/usePriorityFeeSubscriber.ts:29
usePriorityFeeUserSettings
Manages user preferences for priority fees, persisting settings to local storage. This is a singleton hook, meaning all instances share the same state.Signature
Returns
An object containing:The current user priority fee settings:
userPriorityFeeType:'dynamic' | 'custom'- The fee type selected by the useruserCustomMaxPriorityFeeCap:number- Maximum priority fee cap in SOL (default: 0.01)userCustomPriorityFee:number | null- Custom priority fee value in SOL, ornullfor dynamic
Function to update the priority fee settings. Changes are automatically persisted to local storage.
Default Settings
Example
Notes
This is a singleton hook using
react-singleton-hook. All components using this hook will share the same state and see the same values.Source
source/react/src/hooks/priorityFees/usePriorityFeeUserSettings.ts:17
usePriorityFeesPollingRate
Calculates the appropriate polling rate for priority fee updates based on the base polling rate and various multipliers.Signature
Returns
number - The polling frequency in milliseconds.
Behavior
- Before priority fee store is ready: Returns
1000ms (polls every second for faster initial load) - After store is ready: Returns
basePollingRateMs * max(pollingMultiplier, priorityFeePollingMultiplier)
Example
Implementation Details
The polling rate is calculated from three store values:basePollingRateMs- Base polling rate from environment configpollingMultiplier- Global polling multiplier (e.g., increases when app is idle)priorityFeePollingMultiplier- Priority fee specific multiplier from environment
Source
source/react/src/hooks/priorityFees/usePriorityFeesPollingRate.ts:3