Skip to main content

view-policy

View the current Drift protocol policy.
glam drift view-policy

allowlist-market

Add a market to the allowlist.
glam drift allowlist-market <market_type> <market_index> [options]
market_type
string
required
Market type: “spot” or “perp”
market_index
number
required
Spot or perp market index
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
# Allowlist spot market
glam drift allowlist-market spot 0

# Allowlist perp market
glam drift allowlist-market perp 1 -y

remove-market

Remove a market from the allowlist.
glam drift remove-market <market_type> <market_index> [options]
market_type
string
required
Market type: “spot” or “perp”
market_index
number
required
Spot or perp market index
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
# Remove spot market
glam drift remove-market spot 0

# Remove perp market
glam drift remove-market perp 1 -y

set-order-price-tolerance

Set max allowed deviation from oracle price for limit orders.
glam drift set-order-price-tolerance <tolerance_bps> [options]
tolerance_bps
number
required
Tolerance in basis points (0 to disable, e.g., 500 = 5%)
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
# Set 5% tolerance
glam drift set-order-price-tolerance 500

# Disable tolerance check
glam drift set-order-price-tolerance 0 -y

allowlist-borrowable-asset

Add a borrowable asset to the allowlist.
glam drift allowlist-borrowable-asset <token_mint> [options]
token_mint
string
required
Token mint public key
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
glam drift allowlist-borrowable-asset EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v

remove-borrowable-asset

Remove a borrowable asset from the allowlist.
glam drift remove-borrowable-asset <token_mint> [options]
token_mint
string
required
Token mint public key
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
glam drift remove-borrowable-asset EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v -y

init-user

Initialize a Drift user account (sub-account).
glam drift init-user [options]
-s, --sub-account-id
number
default:"0"
Sub-account ID
-p, --pool-id
number
default:"0"
Isolated pool ID
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
# Initialize default sub-account
glam drift init-user

# Initialize sub-account 1
glam drift init-user -s 1 -y

list-users

List Drift users (sub-accounts).
glam drift list-users
Example output:
2 Drift users found
[0]: Main Account (Pool ID: 0)
[1]: Sub Account 1 (Pool ID: 0)

list-positions

List Drift positions for a sub-account.
glam drift list-positions [options]
-s, --sub-account-id
number
default:"0"
Sub-account ID
Examples:
# List positions for default sub-account
glam drift list-positions

# List positions for sub-account 1
glam drift list-positions -s 1

deposit

Deposit assets to Drift.
glam drift deposit <market_index> <amount> [options]
market_index
number
required
Spot market index
amount
number
required
Amount to deposit
-s, --sub-account-id
number
default:"0"
Sub-account ID
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
# Deposit 100 USDC (market index 0)
glam drift deposit 0 100

# Deposit to sub-account 1
glam drift deposit 0 100 -s 1 -y

withdraw

Withdraw assets from Drift.
glam drift withdraw <market_index> <amount> [options]
market_index
number
required
Spot market index
amount
number
required
Amount to withdraw
-s, --sub-account-id
number
default:"0"
Sub-account ID
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
# Withdraw 50 USDC
glam drift withdraw 0 50

# Withdraw from sub-account 1
glam drift withdraw 0 50 -s 1 -y

spot

Place a limit spot order.
glam drift spot <direction> <market_index> <amount> <price_limit> [options]
direction
string
required
Order direction: “long” or “short”
market_index
number
required
Spot market index
amount
number
required
Order amount
price_limit
number
required
Price limit in USD
-s, --sub-account-id
number
default:"0"
Sub-account ID
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
# Place long order for 100 USDC at $1.00
glam drift spot long 0 100 1.00

# Place short order
glam drift spot short 0 100 1.00 -y

perp

Place a limit perpetual order.
glam drift perp <direction> <market_index> <amount> <price_limit> [options]
direction
string
required
Order direction: “long” or “short”
market_index
number
required
Perpetual market index
amount
number
required
Order amount
price_limit
number
required
Price limit in USD
-s, --sub-account-id
number
default:"0"
Sub-account ID
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
# Place long perp order
glam drift perp long 0 1 50000

# Place short perp order
glam drift perp short 0 1 45000 -y

list-orders

List open orders.
glam drift list-orders [options]
-s, --sub-account-id
number
default:"0"
Sub-account ID
Examples:
# List orders for default sub-account
glam drift list-orders

# List orders for sub-account 1
glam drift list-orders -s 1

cancel

Cancel one or more orders.
glam drift cancel <order_ids...> [options]
order_ids
number[]
required
Space-separated list of order IDs
-s, --sub-account-id
number
default:"0"
Sub-account ID
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
# Cancel single order
glam drift cancel 123

# Cancel multiple orders
glam drift cancel 123 124 125 -y

margin

Enable or disable margin trading.
glam drift margin <enabled> [options]
enabled
boolean
required
Enable (true) or disable (false) margin trading
-s, --sub-account-id
number
default:"0"
Sub-account ID
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
# Enable margin trading
glam drift margin true

# Disable margin trading
glam drift margin false -y

settle

Settle PnL for a perpetual market.
glam drift settle <market_index> [options]
market_index
number
required
Perpetual market index
-s, --sub-account-id
number
default:"0"
Sub-account ID
Examples:
# Settle PnL for perp market 0
glam drift settle 0

# Settle for sub-account 1
glam drift settle 0 -s 1

delete-user

Delete a Drift user (sub-account).
glam drift delete-user <sub_account_id> [options]
sub_account_id
number
required
Sub-account ID to delete
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
# Delete sub-account 1
glam drift delete-user 1

# Delete without confirmation
glam drift delete-user 1 -y

update-user-pool-id

Update a Drift user’s pool ID.
glam drift update-user-pool-id <sub_account_id> <pool_id> [options]
sub_account_id
number
required
Sub-account ID
pool_id
number
required
New isolated pool ID
-y, --yes
boolean
default:"false"
Skip confirmation prompt
Examples:
# Update sub-account 1 to pool 2
glam drift update-user-pool-id 1 2

# Update without confirmation
glam drift update-user-pool-id 1 2 -y

Build docs developers (and LLMs) love