Files
trading_bot_v3/app/api/zeta/test/route.js
mindesbunister fb194f1b12 Implement working Drift leverage trading
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!
2025-07-22 12:23:51 +02:00

53 lines
1.5 KiB
JavaScript

import { NextResponse } from 'next/server'
export async function GET() {
try {
console.log('🔍 Testing Zeta Markets SDK imports...')
// Test imports
const zeta = await import('@zetamarkets/sdk')
console.log('Zeta SDK exports:', Object.keys(zeta))
// Test Solana imports
const { Connection, Keypair } = await import('@solana/web3.js')
const { Wallet } = await import('@coral-xyz/anchor')
if (!process.env.SOLANA_PRIVATE_KEY) {
return NextResponse.json({
success: false,
error: 'SOLANA_PRIVATE_KEY not configured',
zetaExports: Object.keys(zeta),
message: 'Zeta SDK imports working but wallet not configured'
})
}
// Test wallet creation
const privateKeyArray = JSON.parse(process.env.SOLANA_PRIVATE_KEY)
const keypair = Keypair.fromSecretKey(new Uint8Array(privateKeyArray))
const wallet = new Wallet(keypair)
return NextResponse.json({
success: true,
message: 'Zeta Markets SDK imports successful',
zetaExports: Object.keys(zeta),
walletPublicKey: keypair.publicKey.toString(),
timestamp: Date.now()
})
} catch (error) {
console.error('❌ Zeta test error:', error)
return NextResponse.json({
success: false,
error: error.message,
stack: error.stack
}, { status: 500 })
}
}
export async function POST() {
return NextResponse.json({
message: 'Use GET method to test Zeta imports'
}, { status: 405 })
}