- Added order cancellation to Position Manager's external closure handler - When on-chain SL/TP orders close position, remaining orders now cancelled automatically - Prevents ghost orders from triggering unintended positions - Real incident: Nov 20 SHORT stop-out left 32 ghost orders on Drift - Risk: Ghost TP1 at $140.66 could fill later, creating unwanted LONG position - Fix: Import cancelAllOrders() and call after trade removed from monitoring - Non-blocking: Logs errors but doesn't fail trade closure if cancellation fails - Files: lib/trading/position-manager.ts (external closure handler ~line 920) - Documented as Common Pitfall #56
71 KiB
71 KiB