Skip to main content
The UserStats account tracks aggregate statistics and settings across all sub-accounts for a given authority. It includes trading volume, referral information, and fuel rewards.

Account Structure

authority
Pubkey
The wallet address that owns these stats
referrer
Pubkey
The referrer’s wallet address (if this user was referred)
fees
UserFees
Detailed fee statistics for the user
next_epoch_ts
i64
Timestamp when the next fee epoch begins
maker_volume30d
u64
Rolling 30-day maker volume
taker_volume30d
u64
Rolling 30-day taker volume
filler_volume30d
u64
Rolling 30-day filler volume
last_maker_volume30d_ts
i64
Timestamp of last maker volume update
last_taker_volume30d_ts
i64
Timestamp of last taker volume update
last_filler_volume30d_ts
i64
Timestamp of last filler volume update
if_staked_quote_asset_amount
u64
Amount of quote asset staked in the insurance fund
number_of_sub_accounts
u16
Current number of active sub-accounts
number_of_sub_accounts_created
u16
Total number of sub-accounts ever created
referrer_status
u8
Status flags for referrer/referral relationships
disable_update_perp_bid_ask_twap
bool
Whether to disable updating perp bid/ask TWAP
paused_operations
u8
Bitmap of paused operations for this user
fuel_overflow_status
u8
Status of fuel overflow mechanism
fuel_insurance
u32
Fuel points earned from insurance fund staking
fuel_deposits
u32
Fuel points earned from deposits
fuel_borrows
u32
Fuel points earned from borrows
fuel_positions
u32
Fuel points earned from positions
fuel_taker
u32
Fuel points earned from taker trades
fuel_maker
u32
Fuel points earned from maker trades
if_staked_gov_token_amount
u64
Amount of governance token staked in the insurance fund
last_fuel_if_bonus_update_ts
u32
Timestamp of the last fuel insurance fund bonus update

Usage

use drift_rs::types::UserStats;

// Get user stats account data
let user_stats: UserStats = drift_client.get_user_stats(&authority).await?;

// Access statistics
println!("30d Maker Volume: {}", user_stats.maker_volume30d);
println!("30d Taker Volume: {}", user_stats.taker_volume30d);
println!("Sub-accounts: {}", user_stats.number_of_sub_accounts);

// Check referrer status
if user_stats.is_referrer() {
    println!("User is a referrer");
}
if user_stats.is_referred() {
    println!("User was referred by: {}", user_stats.referrer);
}

Helper Methods

The UserStats struct implements helper methods:
  • is_referrer() - Returns true if the user is a referrer
  • is_referred() - Returns true if the user was referred by someone

Build docs developers (and LLMs) love