Defi Integrations
Drift Protocol Integration
Manage Drift user accounts, vaults, and trading on Solana
Integrate with Drift Protocol for managing user accounts, vaults, perpetual trading, and deposits/withdrawals. This implementation provides comprehensive functionality for interacting with Drift’s spot and perpetual markets.
Core Features
-
Account Management
- User account creation
- Vault management
- Deposits and withdrawals
- Account information
-
Trading Features
- Perpetual trading
- Market/limit orders
- Position management
- Vault delegation
Account Creation
Account Parameters
Parameter | Type | Required | Description |
---|---|---|---|
amount | number | Yes | Initial deposit amount |
symbol | string | Yes | Token symbol (e.g., “USDC”) |
Vault Parameters
Parameter | Type | Required | Description |
---|---|---|---|
name | string | Yes | Unique vault name |
marketName | string | Yes | Market in TOKEN-SPOT format |
redeemPeriod | number | Yes | Days until redemption |
maxTokens | number | Yes | Maximum vault capacity |
minDepositAmount | number | Yes | Minimum deposit |
managementFee | number | Yes | Management fee percentage |
profitShare | number | Yes | Profit share percentage |
hurdleRate | number | No | Optional hurdle rate |
permissioned | boolean | No | Whether vault uses whitelist |
Trading Operations
Trading Parameters
Parameter | Type | Required | Description |
---|---|---|---|
amount | number | Yes | Trade amount in USD |
symbol | string | Yes | Token symbol |
action | string | Yes | ”long” or “short” |
type | string | Yes | ”market” or “limit” |
price | number | No | Required for limit orders |
Deposits and Withdrawals
Deposit Parameters
Parameter | Type | Required | Description |
---|---|---|---|
amount | number | Yes | Amount to deposit |
symbol | string | Yes | Token symbol |
isRepay | boolean | No | Whether deposit is loan repayment |
Example Prompts
Natural Language Prompts
LangChain Tool Prompts
Create Account
Trade Perpetuals
Implementation Details
Market Structure
Vault Structure
Error Handling
Best Practices
-
Account Management
- Monitor collateral levels
- Track positions regularly
- Keep sufficient margin
- Use appropriate leverage
-
Trading Operations
- Set reasonable limits
- Monitor price impact
- Handle slippage
- Track positions
-
Vault Management
- Plan redemption periods
- Monitor fund utilization
- Track performance
- Manage delegations
Common Issues
-
Trading Issues
- Insufficient collateral
- Price impact too high
- Oracle price issues
- Network congestion
-
Account Issues
- Account not initialized
- Insufficient funds
- Position limits
- Margin requirements
-
Vault Issues
- Redemption period
- Insufficient liquidity
- Delegation errors
- Permission issues
Response Format
Success Response
Error Response
Related Functions
createDriftUserAccount
: Create new user accountdepositToDriftUserAccount
: Deposit to accountwithdrawFromDriftAccount
: Withdraw from accounttradeUsingDriftPerpAccount
: Execute tradesgetDriftVaultInfo
: Get vault informationcreateDriftVault
: Create new vaultdepositIntoDriftVault
: Deposit to vaultwithdrawFromDriftVault
: Withdraw from vault
Resources
Was this page helpful?