Fix spot trade logic: remove incorrect positions and enhance trade history display
- Remove incorrect open positions for spot swaps (instant settlements) - Add DELETE API route for position removal (/api/trading/positions/[positionId]) - Update existing SOL/USDC trade to clearly mark as SPOT_SWAP - Enhance TradesHistoryPanel with visual trade type indicators: * SPOT_SWAP: Purple badge with ⚡ icon * MARKET: Blue badge with 📈 icon * LIMIT: Orange badge with 🎯 icon * STOP: Red badge with 🛑 icon - Add trade history update functionality for modifying existing trades - Fix container communication URLs in execute-dex route Result: Spot trades no longer create open positions, trade history clearly shows trade types
This commit is contained in:
@@ -98,6 +98,31 @@ export async function POST(request) {
|
||||
message: `Trade added to history: ${newTrade.side} ${newTrade.amount} ${newTrade.symbol}`
|
||||
})
|
||||
|
||||
} else if (action === 'update') {
|
||||
// Load existing trades
|
||||
const tradesHistory = loadTrades()
|
||||
const { tradeId, updates } = tradeData
|
||||
|
||||
// Find and update the trade
|
||||
const tradeIndex = tradesHistory.findIndex(trade => trade.id === tradeId)
|
||||
|
||||
if (tradeIndex === -1) {
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
error: 'Trade not found'
|
||||
}, { status: 404 })
|
||||
}
|
||||
|
||||
// Update the trade with new data
|
||||
tradesHistory[tradeIndex] = { ...tradesHistory[tradeIndex], ...updates }
|
||||
saveTrades(tradesHistory)
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
trade: tradesHistory[tradeIndex],
|
||||
message: `Trade updated: ${tradeId}`
|
||||
})
|
||||
|
||||
} else if (action === 'clear') {
|
||||
// Clear trade history
|
||||
saveTrades([])
|
||||
|
||||
Reference in New Issue
Block a user