Key Features: - ✅ Drift SDK v2.126.0-beta.14 integration with Helius RPC - ✅ User account initialization and balance reading - ✅ Leverage trading API with real trades executed - ✅ Support for SOL, BTC, ETH, APT, AVAX, BNB, MATIC, ARB, DOGE, OP - ✅ Transaction confirmed: gNmaWVqcE4qNK31ksoUsK6pcHqdDTaUtJXY52ZoXRF API Endpoints: - POST /api/drift/trade - Main trading endpoint - Actions: get_balance, place_order - Successfully tested with 0.01 SOL buy order at 2x leverage Technical Fixes: - Fixed RPC endpoint blocking with Helius API key - Resolved wallet signing compatibility issues - Implemented proper BigNumber handling for amounts - Added comprehensive error handling and logging Trading Bot Status: 🚀 FULLY OPERATIONAL with leverage trading!
58 lines
2.0 KiB
JavaScript
58 lines
2.0 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Minimal Drift test to identify what's being blocked
|
|
import { Connection, Keypair } from '@solana/web3.js'
|
|
|
|
async function testMinimalDrift() {
|
|
try {
|
|
console.log('🧪 Testing minimal Drift functionality...')
|
|
|
|
// Test different RPC endpoints
|
|
const rpcEndpoints = [
|
|
'https://mainnet.helius-rpc.com/?api-key=demo',
|
|
'https://rpc.ankr.com/solana',
|
|
'https://api.mainnet-beta.solana.com'
|
|
]
|
|
|
|
for (const rpcUrl of rpcEndpoints) {
|
|
try {
|
|
console.log(`\n🔗 Testing RPC: ${rpcUrl}`)
|
|
const connection = new Connection(rpcUrl, 'confirmed')
|
|
|
|
// Test basic operations
|
|
console.log(' Testing getVersion...')
|
|
const version = await connection.getVersion()
|
|
console.log(' ✅ Version:', version['solana-core'])
|
|
|
|
console.log(' Testing getLatestBlockhash...')
|
|
const blockHash = await connection.getLatestBlockhash()
|
|
console.log(' ✅ Block hash:', blockHash.blockhash.slice(0, 10) + '...')
|
|
|
|
// Test program account access (this might be what's blocked)
|
|
console.log(' Testing program account access...')
|
|
const { initialize } = await import('@drift-labs/sdk')
|
|
const sdkConfig = initialize({ env: 'mainnet-beta' })
|
|
|
|
console.log(' Testing getAccountInfo for Drift program...')
|
|
const programInfo = await connection.getAccountInfo(sdkConfig.DRIFT_PROGRAM_ID)
|
|
console.log(' ✅ Program info:', programInfo ? 'Found' : 'Not found')
|
|
|
|
// If we get here, this RPC works
|
|
console.log(` ✅ RPC ${rpcUrl} works for all tests!`)
|
|
break
|
|
|
|
} catch (error) {
|
|
console.log(` ❌ RPC ${rpcUrl} failed:`, error.message)
|
|
if (error.message.includes('410') || error.message.includes('disabled')) {
|
|
console.log(' This RPC has disabled certain calls')
|
|
}
|
|
}
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ Minimal test failed:', error)
|
|
}
|
|
}
|
|
|
|
testMinimalDrift()
|