Skip to main content
Drift Protocol is built using the Anchor framework on Solana. The program implements a cross-margined derivatives exchange with perpetual futures and spot markets.

Program ID

Mainnet & Devnet: dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH

Core Components

State Accounts

  • State: Global protocol configuration and parameters
  • PerpMarket: Individual perpetual market configuration and AMM state
  • SpotMarket: Spot market configuration for collateral assets
  • User: User trading account with positions and orders
  • UserStats: User statistics and fee tiers

Controllers

  • Position Controller: Manages perpetual and spot positions
  • Order Controller: Handles order placement and matching
  • AMM Controller: Controls automated market maker operations
  • Liquidation Controller: Executes liquidations
  • Funding Controller: Calculates and applies funding rates

Instructions

All instructions are implemented in the instructions/ module:
  • User instructions: Account management, deposits, withdrawals
  • Trading instructions: Place, modify, cancel orders
  • Admin instructions: Market management, parameter updates
  • Keeper instructions: Fill orders, liquidate accounts, update funding

Program Features

Cross-Margin

Single collateral pool supports all positions

vAMM

Virtual automated market maker for liquidity

DLOB

Decentralized limit order book

Oracle Integration

Pyth and Switchboard price feeds

Architecture Overview

The Drift program is structured with:
  1. Entry Point: Anchor program entrypoint with custom discriminator handling
  2. State Management: Accounts stored on-chain with versioned upgrades
  3. Math Library: Precision-based calculations for positions, margins, and PnL
  4. Validation: Guard rails for oracle data, margin requirements, and risk limits

Security

  • Audited by multiple firms (see AUDIT.md)
  • Bug bounty program active
  • Program upgrades require governance
  • All critical operations use oracle guard rails

Next Steps

Instructions

Program instruction reference

State

Account structures

Security

Security considerations

SDK

Use the TypeScript SDK

Build docs developers (and LLMs) love