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!
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
// Test minimal Drift connection
|
|
require('dotenv').config() // Load environment variables
|
|
const { Connection, Keypair } = require('@solana/web3.js')
|
|
|
|
async function testMinimalDrift() {
|
|
try {
|
|
console.log('🧪 Testing minimal Drift setup...')
|
|
|
|
// Check if we have the private key
|
|
if (!process.env.SOLANA_PRIVATE_KEY) {
|
|
console.log('❌ No SOLANA_PRIVATE_KEY found')
|
|
return
|
|
}
|
|
|
|
console.log('✅ Environment variable found')
|
|
|
|
// Test connection
|
|
const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed')
|
|
console.log('✅ Connection created')
|
|
|
|
// Test keypair
|
|
const privateKeyArray = JSON.parse(process.env.SOLANA_PRIVATE_KEY)
|
|
const keypair = Keypair.fromSecretKey(new Uint8Array(privateKeyArray))
|
|
console.log('✅ Keypair created:', keypair.publicKey.toString())
|
|
|
|
// Test Anchor Wallet
|
|
const { Wallet } = await import('@coral-xyz/anchor')
|
|
const wallet = new Wallet(keypair)
|
|
console.log('✅ Wallet created')
|
|
|
|
// Test Drift imports
|
|
const { DriftClient, initialize } = await import('@drift-labs/sdk')
|
|
console.log('✅ Drift SDK imported')
|
|
|
|
// Test initialize
|
|
const sdkConfig = initialize({ env: 'mainnet-beta' })
|
|
console.log('✅ Drift initialized', sdkConfig.DRIFT_PROGRAM_ID.toString())
|
|
|
|
console.log('🎉 All tests passed!')
|
|
|
|
} catch (error) {
|
|
console.error('❌ Error:', error.message)
|
|
console.error('Stack:', error.stack)
|
|
}
|
|
}
|
|
|
|
testMinimalDrift()
|