Overview
TheSpotMarket struct represents a Drift spot market account. It contains all configuration parameters, balance information, and state for a spot market including oracle data, interest rates, fees, and collateral weights.
Account Structure
Core Fields
The public key address of this spot market account
The oracle account address providing price data for this market
The SPL token mint address for this market’s asset
The token account holding deposited assets for this market
Human-readable name of the market (32-byte array)
Unique identifier index for this spot market
Oracle and Price Data
Historical oracle price information and statistics
The type of oracle being used (e.g., Pyth, Switchboard)
Historical interest rate index data
Balance Information
Total deposited balance in the market (in token’s base units)
Total borrowed balance in the market (in token’s base units)
Cumulative interest earned by depositors since market inception
Cumulative interest paid by borrowers since market inception
Maximum allowed deposit amount for this market
TWAP (Time-Weighted Average Price) Data
Time-weighted average of total deposits
Time-weighted average of total borrows
Time-weighted average utilization rate
Unix timestamp of last TWAP update
Interest Rate Parameters
Target utilization rate for optimal interest rates (in basis points)
Interest rate at optimal utilization (in basis points per year)
Maximum borrow interest rate (in basis points per year)
Minimum borrow interest rate
Unix timestamp of last interest rate update
Risk Parameters
Initial collateral weight for deposits (in basis points, e.g., 8000 = 80%)
Maintenance collateral weight for deposits (in basis points)
Initial weight for borrows when calculating collateral requirements
Maintenance weight for borrows when calculating collateral requirements
Initial margin fraction factor for position size scaling
Fee paid to liquidators (in basis points)
Insurance fund liquidation fee (in basis points)
Deposit size at which initial asset weight scaling begins
Order Configuration
Minimum order quantity increment (order sizes must be multiples of this)
Minimum price increment (prices must be multiples of this)
Minimum allowed order size
Maximum position size allowed
Whether trading is enabled for this market
Fee Pools
Protocol revenue pool balance
Spot trading fee pool balance
Total spot fees collected
Total swap fees collected
Insurance Fund
Insurance fund configuration and balance
Social Loss
Total socialized loss in base asset
Total socialized loss in quote asset
Market Status
Current operational status of the market (Active, ReduceOnly, etc.)
Risk classification of the asset (Collateral, Protected, Cross, Isolated)
Bitfield of paused operations
Bitfield of insurance fund paused operations
Flash Loans
Current outstanding flash loan amount
Initial token amount for flash loan tracking
Token Program
Flags indicating token program type (SPL Token vs Token-2022)
Number of decimal places for the token
Record IDs
Next fill record identifier
Next deposit record identifier
Miscellaneous
Threshold for withdrawal guards
Unix timestamp when market expires (0 if no expiry)
Fee adjustment factor
Maximum fraction of deposits that can be borrowed
Associated pool identifier
Fuel boost multiplier for deposits
Fuel boost multiplier for borrows
Fuel boost multiplier for taker fees
Fuel boost multiplier for maker fees
Fuel boost multiplier for insurance fund contributions
Methods
TheSpotMarket struct implements the Market trait from marketmap.rs:
market_index()
oracle_info()
MarketId- The spot market IDPubkey- The oracle account addressOracleSource- The oracle source type
token_program()
token_program_flag.
is_token_2022_program()
true if using Token-2022, false otherwise.
has_transfer_hook()
true if transfer hook is enabled.
Usage Example
See Also
- PerpMarket - Perpetual futures market structure
- MarketMap - Market subscription and management