Implement pure Drift Protocol automation system
- Remove Jupiter DEX completely from automation system - Implement exclusive Drift Protocol integration with up to 100x leverage - Update executeLiveTrade method to use only Drift API endpoints - Change default DEX provider from Jupiter to Drift - Create minimal professional UI without promotional banners - Add comprehensive leverage options (1x-100x) with risk indicators - Update automation service to route all trades through /api/automation/trade - Fix type definitions to support Drift-only configuration - Add multiple trading pairs support (SOL, BTC, ETH, APT, AVAX, DOGE) - Implement clean configuration interface with essential controls - Remove excessive marketing text and promotional elements - Maintain full automation functionality while simplifying UX
This commit is contained in:
50
drift_executeLiveTrade.txt
Normal file
50
drift_executeLiveTrade.txt
Normal file
@@ -0,0 +1,50 @@
|
||||
private async executeLiveTrade(decision: any): Promise<any> {
|
||||
try {
|
||||
console.log(`🚀 Executing DRIFT trade: ${decision.direction} ${decision.positionSize} ${this.config!.symbol} with ${this.config!.maxLeverage}x leverage`)
|
||||
|
||||
const response = await fetch('http://localhost:3000/api/automation/trade', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
dexProvider: 'DRIFT',
|
||||
action: decision.direction.toLowerCase() === 'buy' ? 'open_long' : 'open_short',
|
||||
symbol: this.config!.symbol.replace('USD', ''), // Convert SOLUSD to SOL
|
||||
amount: this.config!.tradingAmount,
|
||||
side: decision.direction,
|
||||
leverage: this.config!.maxLeverage,
|
||||
stopLoss: decision.stopLoss,
|
||||
takeProfit: decision.takeProfit,
|
||||
mode: 'LIVE'
|
||||
})
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Drift trade request failed: ${response.statusText}`)
|
||||
}
|
||||
|
||||
const result = await response.json()
|
||||
|
||||
if (result.success) {
|
||||
return {
|
||||
transactionId: result.result?.transactionId || result.txId,
|
||||
executionPrice: result.result?.executionPrice || decision.currentPrice,
|
||||
amount: result.result?.amount || decision.positionSize,
|
||||
direction: decision.direction,
|
||||
status: 'COMPLETED',
|
||||
timestamp: new Date(),
|
||||
fees: result.result?.fees || 0,
|
||||
slippage: result.result?.slippage || 0,
|
||||
leverage: this.config!.maxLeverage,
|
||||
dexProvider: 'DRIFT',
|
||||
tradingAmount: this.config!.tradingAmount
|
||||
}
|
||||
} else {
|
||||
throw new Error(result.error || 'Drift trade execution failed')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Live trade execution error:', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user