fix(math): use pure BigInt arithmetic in warmup to avoid BigInt(float) crash#188
fix(math): use pure BigInt arithmetic in warmup to avoid BigInt(float) crash#1880x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
Conversation
…) crash Re-applies PR dcccrypto#154 which was overwritten by upstream SBF offset corrections. computeWarmupLeverageCap and computeWarmupMaxPositionSize called BigInt() on computeMaxLeverage() return value which is a float (e.g., 3.003 for 3333 bps). BigInt(3.003) throws TypeError. Replaced with pure BigInt arithmetic: - leverageCap: (10000n * unlocked) / (initialMarginBps * totalCapital) - maxPositionSize: (unlocked * 10000n) / initialMarginBps Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 45 minutes and 35 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ 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
computeWarmupLeverageCap(line 93) andcomputeWarmupMaxPositionSize(line 136) calledBigInt()oncomputeMaxLeverage()which returns a float (e.g.,3.003for 3333 bps)BigInt(3.003)throwsTypeError— crashes for anyinitialMarginBpsthat doesn't evenly divide 10000(10000n * unlocked) / (initialMarginBps * totalCapital)and(unlocked * 10000n) / initialMarginBpsTest plan
initialMarginBps=3333nproduces correct results instead of crashing🤖 Generated with Claude Code