Skip to main content
The User account is the primary account structure for a Drift trading account. It contains all spot and perp positions, active orders, and user-specific settings.

Account Structure

authority
Pubkey
The wallet address that owns and controls this user account
delegate
Pubkey
Optional delegate address that can execute trades on behalf of the user
name
[u8; 32]
Human-readable name for the sub-account (32-byte array)
spot_positions
[SpotPosition; 8]
Array of up to 8 spot market positions
perp_positions
[PerpPosition; 8]
Array of up to 8 perpetual market positions
orders
[Order; 32]
Array of up to 32 active orders
last_add_perp_lp_shares_ts
i64
Timestamp of the last time perp LP shares were added
total_deposits
u64
Cumulative lifetime deposits into this account
total_withdraws
u64
Cumulative lifetime withdrawals from this account
total_social_loss
u64
Cumulative social loss absorbed by this account
settled_perp_pnl
i64
Total settled perpetual PnL
cumulative_spot_fees
i64
Cumulative fees paid on spot trades
cumulative_perp_funding
i64
Cumulative funding payments (positive = received, negative = paid)
liquidation_margin_freed
u64
Amount of margin freed through liquidations
last_active_slot
u64
Slot number when the account was last active
next_order_id
u32
The next order ID to be assigned
max_margin_ratio
u32
Maximum custom margin ratio for this account
next_liquidation_id
u16
The next liquidation ID to be assigned
sub_account_id
u16
Sub-account identifier (allows multiple accounts per authority)
status
u8
Current account status (active, liquidating, etc.)
is_margin_trading_enabled
bool
Whether margin trading is enabled for this account
idle
bool
Whether the account is currently idle (no open positions or orders)
open_orders
u8
Number of currently open orders
has_open_order
bool
Quick flag indicating if there are any open orders
open_auctions
u8
Number of currently open auctions
has_open_auction
bool
Quick flag indicating if there are any open auctions
margin_mode
MarginMode
The margin mode for this account (Cross or Isolated)
pool_id
u8
Associated liquidity pool ID
last_fuel_bonus_update_ts
u32
Timestamp of the last fuel bonus update

Usage

use drift_rs::types::User;

// Get user account data
let user: User = drift_client.get_user_account(&user_pubkey).await?;

// Access user properties
println!("Authority: {}", user.authority);
println!("Sub-account ID: {}", user.sub_account_id);
println!("Total deposits: {}", user.total_deposits);

Build docs developers (and LLMs) love