-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(RewardsStreamerMP): use Math.mulDiv
to reduce likelyhood of
#92
Conversation
6fa11e3
to
b621485
Compare
src/RewardsStreamerMP.sol
Outdated
return amount * lockMultiplier / SCALE_FACTOR; | ||
return Math.mulDiv( | ||
Math.mulDiv(amount * lockPeriod, MAX_MULTIPLIER * SCALE_FACTOR, MAX_LOCKUP_PERIOD), 1, SCALE_FACTOR | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be changed to
uint256 intermediate = Math.mulDiv(amount * lockPeriod, MAX_MULTIPLIER * SCALE_FACTOR, MAX_LOCKUP_PERIOD);
return intermediate / SCALE_FACTOR;
@@ -444,7 +447,7 @@ contract RewardsStreamerMP is | |||
return 0; | |||
} | |||
|
|||
uint256 accruedMP = (timeDiff * account.stakedBalance * MP_RATE_PER_YEAR) / (365 days * SCALE_FACTOR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to remove scale factor if using math.muldiv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
b621485
to
2dee933
Compare
precision loss Closes #85
bfa5879
to
7aefe4c
Compare
@3esmit this is now green on CI. I'm dismissing your "change requested" as all the requested changes have landed and it keeps us blocked from merging this. |
We agreed on merging this once green on CI
precision loss
Closes #85
Checklist
Ensure you completed all of the steps below before submitting your pull request:
pnpm adorno
?pnpm verify
?