- Added 5-minute validation interval to Position Manager - Validates tracked positions against actual Drift state - Auto-cleanup ghost positions (DB shows open but Drift shows closed) - Prevents rate limit storms from accumulated ghost positions - Logs detailed ghost detection: DB state vs Drift state - Self-healing system requires no manual intervention Implementation: - scheduleValidation(): Sets 5-minute timer after monitoring starts - validatePositions(): Queries each tracked position on Drift - handleExternalClosure(): Reusable method for ghost cleanup - Clears interval when monitoring stops Benefits: - Prevents ghost position accumulation - Eliminates need for manual container restarts - Minimal RPC overhead (1 check per 5 min per position) - Addresses root cause (state management) not symptom (rate limits) Fixes: - Ghost positions from failed DB updates during external closures - Container restart state sync issues - Rate limit exhaustion from managing non-existent positions
50 KiB
50 KiB