Files
trading_bot_v4/lib/drift/orders.ts
mindesbunister b4bcde942a critical: Fix entry AND exit prices to use actual Drift fills (Bug #89)
- Extended getActualFillPriceFromTx() to also extract entry fill prices
- openPosition() now uses actual fill from tx logs (was using oracle price)
- closePosition() already fixed to use actual exit fills
- Both prices now extracted via Drift SDK LogParser OrderActionRecord events
- Eliminates ~0.08% entry and exit price discrepancies vs Drift UI
- P&L calculations now 100% accurate to actual execution prices

Files changed:
- lib/drift/orders.ts (entry extraction in openPosition)
- docs/COMMON_PITFALLS.md (updated Pitfall #89)

Expected impact: Entry AND exit prices match Drift exactly on all future trades
2026-01-12 08:32:48 +01:00

48 KiB