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:
mindesbunister
2025-07-16 11:36:58 +02:00
parent cd1273b612
commit 77eb727f8d
4 changed files with 134 additions and 31 deletions

View File

@@ -43,6 +43,21 @@ export default function TradesHistoryPanel() {
}
}
const getTradeTypeInfo = (trade) => {
switch (trade.type) {
case 'SPOT_SWAP':
return { label: 'SPOT SWAP', color: 'bg-purple-600', icon: '⚡' }
case 'market':
return { label: 'MARKET', color: 'bg-blue-600', icon: '📈' }
case 'limit':
return { label: 'LIMIT', color: 'bg-orange-600', icon: '🎯' }
case 'stop':
return { label: 'STOP', color: 'bg-red-600', icon: '🛑' }
default:
return { label: trade.type?.toUpperCase() || 'TRADE', color: 'bg-gray-600', icon: '💱' }
}
}
const getSideColor = (side) => {
return side === 'BUY' ? 'text-green-400' : 'text-red-400'
}
@@ -122,7 +137,15 @@ export default function TradesHistoryPanel() {
}`}>
{trade.side}
</span>
<span className="px-2 py-1 rounded text-xs bg-blue-600 text-white">
{(() => {
const typeInfo = getTradeTypeInfo(trade)
return (
<span className={`px-2 py-1 rounded text-xs font-medium text-white ${typeInfo.color}`}>
{typeInfo.icon} {typeInfo.label}
</span>
)
})()}
<span className="px-2 py-1 rounded text-xs bg-gray-700 text-gray-300">
{trade.dex}
</span>
</div>