Skip to main content
The User account stores all trading data for a user including positions, orders, and collateral.

Account Structure

The UserAccount is defined in programs/drift/src/state/user.rs.

Key Fields

authority
Pubkey
Wallet public key that controls this account
subAccountId
u16
Sub-account ID (0-9999)
perpPositions
PerpPosition[8]
Array of up to 8 perpetual positions
spotPositions
SpotPosition[8]
Array of up to 8 spot positions (collateral)
orders
Order[32]
Array of up to 32 active orders
settledPerpPnl
i64
Settled perpetual PnL
cumulativePerpFunding
i64
Cumulative funding payments
nextOrderId
u32
Next order ID to assign
maxMarginRatio
u32
Custom maximum margin ratio
isMarginTradingEnabled
bool
Whether margin trading is enabled

TypeScript Types

For TypeScript SDK usage, see:

UserAccount Type

Full TypeScript interface

User API

User class methods

Account Management

Create and manage accounts

Position Management

Work with positions

Build docs developers (and LLMs) love