protocol: Drift
version: v2
account_type: Multiple
idl_file_path: idl.json

tags:
  - perpetuals
  - spot-trading
  - amm
  - liquidation
  - defi

templates:
  - id: drift-perp-market
    name: Override Perp Market State
    description: Override core AMM and oracle parameters of a perpetual market
    idl_account_name: PerpMarket
    properties:
      [
        "amm.base_asset_reserve",
        "amm.quote_asset_reserve",
        "amm.peg_multiplier",
        "amm.last_funding_rate",
        "amm.base_spread",
        "amm.historical_oracle_data.last_oracle_price",
      ]
    address:
      type: pubkey

  - id: drift-spot-market
    name: Override Spot Market State
    description: Override balances and interest parameters for spot market simulation
    idl_account_name: SpotMarket
    properties:
      [
        "deposit_balance",
        "borrow_balance",
        "cumulative_deposit_interest",
        "cumulative_borrow_interest",
        "optimal_utilization",
        "max_borrow_rate",
      ]
    address:
      type: pubkey

  - id: drift-user-state
    name: Override User State
    description: Override user's perp & spot positions and margin parameters
    idl_account_name: User
    properties:
      [
        "perp_positions",
        "spot_positions",
        "settled_perp_pnl",
        "total_deposits",
        "max_margin_ratio",
      ]
    address:
      type: pubkey

  - id: drift-global-state
    name: Override Global State
    description: Override global parameters controlling pricing, fees, and safety checks
    idl_account_name: State
    properties:
      [
        "perp_fee_structure",
        "spot_fee_structure",
        "oracle_guard_rails",
        "liquidation_margin_buffer_ratio",
        "exchange_status",
      ]
    address:
      type: pubkey
