fix(staker): replace wrapping Mul with MulDiv in reward scaling#1233
fix(staker): replace wrapping Mul with MulDiv in reward scaling#1233
Mul with MulDiv in reward scaling#1233Conversation
WalkthroughRefactored reward scaling computation in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 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 |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
contract/r/gnoswap/staker/v1/reward_calculation_pool_test.gno (1)
952-962: Exercise the production helper here.Lines 952-962 re-derive the formula instead of calling
RewardState.scaleRewardorrewardPerWarmup, so this test can stay green even if the implementation under review regresses or starts reading the wrong liquidity source.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f80fe1ed-4ddc-481e-a051-788c596f025d
📒 Files selected for processing (2)
contract/r/gnoswap/staker/v1/reward_calculation_pool.gnocontract/r/gnoswap/staker/v1/reward_calculation_pool_test.gno



Description
Mul(rewardAcc, liquidity)withMulDiv(rewardAcc, liquidity * rewardPerSecond, q128)to use a 512 bit intermediate instead of a 256-bit wrapping multiplicationSummary by CodeRabbit
Bug Fixes
Tests