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

Pubkey
Wallet public key that controls this account
u16
Sub-account ID (0-9999)
PerpPosition[8]
Array of up to 8 perpetual positions
SpotPosition[8]
Array of up to 8 spot positions (collateral)
Order[32]
Array of up to 32 active orders
i64
Settled perpetual PnL
i64
Cumulative funding payments
u32
Next order ID to assign
u32
Custom maximum margin ratio
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