drift-sdk
Original:🇺🇸 English
Translated
1 scriptsChecked / no sensitive code detected
Drift Protocol perpetual futures trading on Solana (direct SDK)
4installs
Sourcealsk1992/cloddsbot
Added on
NPX Install
npx skill4agent add alsk1992/cloddsbot drift-sdkTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Drift Protocol SDK
Direct SDK-based trading on Drift Protocol, Solana's leading perpetual futures DEX. Bypass the gateway requirement with native SDK integration.
Quick Start
bash
# Set credentials
export DRIFT_PRIVATE_KEY="your-solana-private-key"
export SOLANA_RPC_URL="https://api.mainnet-beta.solana.com"
# Check balance
/drift balance
# Open a position
/drift long BTC 0.1
/drift short ETH 1 2500
# Close position
/drift close BTCCommands
Trading
| Command | Description |
|---|---|
| Open long position |
| Open short position |
| Close position at market |
| Close all positions |
| Set leverage |
Examples:
bash
/drift long BTC 0.1 # Market buy 0.1 BTC
/drift short ETH 1 2500 # Limit sell 1 ETH at $2500
/drift leverage SOL 5 # Set SOL leverage to 5xOrders
| Command | Description |
|---|---|
| List open orders |
| Cancel order by ID |
| Cancel all orders for coin |
| Cancel all orders |
| Modify order |
Account
| Command | Description |
|---|---|
| Collateral, margin, health factor |
| Open positions with PnL |
Configuration
bash
# Required
export DRIFT_PRIVATE_KEY="base58_or_json_array"
# Optional
export SOLANA_RPC_URL="https://api.mainnet-beta.solana.com"
export DRY_RUN=true # Test modeFeatures
- Direct SDK - No gateway server required
- Perp & Spot - Trade both market types
- Order Types - Market, limit, post-only, IOC, FOK
- Position Management - Track unrealized PnL, entry prices
- Risk Metrics - Health factor, margin usage, liquidation prices
- Leverage Control - Set per-market leverage (1-20x)
Markets
| Market | Index | Max Leverage |
|---|---|---|
| BTC-PERP | 0 | 20x |
| ETH-PERP | 1 | 20x |
| SOL-PERP | 2 | 20x |
| ... | ... | ... |