Skip to main content

Drift

drift-reserve is the liquid reserve sleeve. The implementation lives in services/adapters/src/drift.ts.

Supported paths

Fixture mode

Used when no live RPC is provided. Good for:
  • offline tests
  • deterministic demos
  • no-network development

SDK mode

Used when DRIFT_RPC_URL is set. Current supported operations:
  • deposit
  • request_withdraw
  • finalize_withdraw via the same withdraw path

Important behavior

  • deposit can initialize the Drift user account automatically
  • withdraw requires an existing user account with collateral
  • the adapter emits instructionLabels and instructionEnvelopes for Ranger

Main environment variables

VariablePurpose
DRIFT_RPC_URLSolana RPC used by the Drift adapter
DRIFT_OWNER_ADDRESSDrift authority expected by the SDK
DRIFT_ENVCluster config, usually mainnet-beta
DRIFT_MARKET_INDEXSpot market index, default 0 for USDC
DRIFT_MARKET_SYMBOLMarket symbol, usually USDC
DRIFT_SUB_ACCOUNT_IDSubaccount used for deposits and withdrawals
DRIFT_USER_NAMEName used when initializing a Drift user

Validation order

  1. node --experimental-strip-types services/ranger/src/drift-smoke.ts
  2. set DRIFT_SMOKE_MODE=deposit first
  3. use drift-live-send.ts only after bundle construction is working
  4. use withdraw only after a real deposit exists for that signer

Common failure mode

If you run withdraw too early, you should expect an error that the Drift user account does not exist yet.