fix: remove artificial BigInt overflow guard in liquidation PnL (H7)#89
fix: remove artificial BigInt overflow guard in liquidation PnL (H7)#890x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
Conversation
…(H7) The overflow check clamped PnL at Number.MAX_SAFE_INTEGER (9e15) which is meaningless for BigInt (arbitrary precision, no overflow). Large positions with diff*posSize > 9e15 were clamped to a positive value, potentially making deeply underwater accounts appear healthy and preventing valid liquidations. The re-verification path (line 435) never had this guard and worked correctly. Remove it from the scan path to match. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe liquidation service was simplified by removing BigInt overflow protection logic that compared position sizes against a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Number.MAX_SAFE_INTEGER(9e15), which is meaningless for BigInt (arbitrary precision)diff * positionSize > 9e15were clamped to a positive valueFix
Remove the
MAX_SAFE_BIGINToverflow guard. BigInt arithmetic in JavaScript has arbitrary precision — no overflow is possible. The PnL calculation now matches the re-verification path.Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit