in-solana by Supanode

Drift Protocol — Program ID & Overview

dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH

Drift Protocol is a decentralized perpetual futures exchange and lending platform on Solana. It uses a virtual AMM (vAMM) combined with a decentralized orderbook for price discovery and trade execution.

Program ID

dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH

Market types

TypeDescription
PerpetualLeveraged futures with no expiry, funding rate mechanism
SpotSpot trading and lending/borrowing

Key concepts

vAMM (Virtual AMM): Drift’s vAMM provides guaranteed liquidity. It does not hold actual tokens but uses a virtual reserve model to calculate prices. Real liquidity comes from the decentralized orderbook and JIT (Just-in-Time) liquidity providers.

JIT liquidity: Market makers provide just-in-time liquidity by filling orders within a 5-second auction window. This reduces slippage compared to pure vAMM execution.

Insurance fund: Each market has an insurance fund that covers socialized losses (when a position is liquidated at a loss greater than its collateral).

Key instructions

InstructionDescription
InitializeUserCreates a user account with sub-accounts
DepositDeposits collateral
PlacePerpOrderPlaces a perpetual futures order
PlaceSpotOrderPlaces a spot order
CancelOrderCancels an open order
FillPerpOrderFills a pending order (keeper)
LiquidateLiquidates an undercollateralized position
WithdrawWithdraws available collateral

Drift SDK

import { DriftClient, Wallet } from "@drift-labs/sdk";

const driftClient = new DriftClient({
  connection,
  wallet: new Wallet(keypair),
  env: "mainnet-beta",
});

await driftClient.subscribe();

const user = driftClient.getUser();
console.log("Free collateral:", user.getFreeCollateral().toString());
console.log("Leverage:", user.getLeverage().toString());

Perpetual funding rate

Perpetual markets use a funding rate to keep the contract price aligned with the oracle (spot) price:

  • If perp price > oracle price: longs pay shorts (positive funding).
  • If perp price < oracle price: shorts pay longs (negative funding).
  • Funding is settled continuously.

FAQ

What leverage is available on Drift? Maximum leverage depends on the market. SOL-PERP supports up to 20× leverage. Other markets may have different limits based on liquidity and risk parameters.

How are liquidations handled? When a user’s margin ratio falls below the maintenance margin, their position can be partially liquidated by keeper bots. The keeper receives a liquidation fee as incentive.

Can I use Drift for lending/borrowing? Yes. Drift’s spot markets support lending and borrowing. Deposited collateral automatically earns lending yield. Borrowers pay interest based on utilization rates.

Updated: