> ## Documentation Index
> Fetch the complete documentation index at: https://pessoal-86816071.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Drift

> How Drift is integrated, which paths are supported, and how to validate it safely.

# Drift

`drift-reserve` is the liquid reserve sleeve.

The implementation lives in [services/adapters/src/drift.ts](/Users/giovanna-britto/Documents/PROJETOS/vault-solana/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

| Variable               | Purpose                                      |
| ---------------------- | -------------------------------------------- |
| `DRIFT_RPC_URL`        | Solana RPC used by the Drift adapter         |
| `DRIFT_OWNER_ADDRESS`  | Drift authority expected by the SDK          |
| `DRIFT_ENV`            | Cluster config, usually `mainnet-beta`       |
| `DRIFT_MARKET_INDEX`   | Spot market index, default `0` for `USDC`    |
| `DRIFT_MARKET_SYMBOL`  | Market symbol, usually `USDC`                |
| `DRIFT_SUB_ACCOUNT_ID` | Subaccount used for deposits and withdrawals |
| `DRIFT_USER_NAME`      | Name 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.
