-
Notifications
You must be signed in to change notification settings - Fork 316
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
contracts: Sushiswap OHM/LQTY rewards #704
base: main
Are you sure you want to change the base?
Conversation
For London hardfork. See this issue: sc-forks/solidity-coverage#652
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.
Great, thanks - just worth commenting the decimal issue mentioned below, and ensuring that deployment uses the right multiplier values.
|
||
function onSushiReward (uint256, address, address to, uint256 sushiAmount, uint256) onlyMCV2 override external { | ||
// OHM rewards | ||
uint256 ohmPendingReward = sushiAmount.mul(ohmRewardMultiplier) / REWARD_TOKEN_DIVISOR; |
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.
I noticed the OHM token uses 9-digit decimal precision:
https://etherscan.io/address/0x383518188c0c6d7730d91b2c03a03c837814a899#readContract
and SUSHI and LQTY use 18.
It seems here that ohmRewardMultiplier
and lqtyRewardMultiplier
variables are 18-digit decimal precision, and that's why they're divided by REWARD_TOKEN_DIVISOR
.
Perhaps we can add comments to note that:
- These multiplier variables are 18-digit precision
- The value of
ohmRewardMultiplier
should take into account the different decimal precision of SUSHI and OHM when it is set at construction.
e.g. if we wanted to reward 2 OHM per SUSHI, the raw value of ohmRewardMultiplier
should be 2e9
. Then when calculating the OHM pending reward, we'd get:
ohmPendingReward = sushiAmount * 2e9 / 1e18
= sushiAmount * 2 / 1e9
Which is equivalent to 2 OHM per SUSHI, given OHM's 9-digit precision.
Basically at deployment we just need to remember to pass an _ohmRewardMultiplier
on the order of 1e9
, and _lqtyRewardMultiplier
should be on the order of 1e18
.
I think tests don't catch this because the OZ ERC20.sol hardcodes decimals = 18
.
- Use real sushi per block amount - Use 9 decimals for OHM
To remember to set up correct multipliers at deployment.
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.
Looks good!
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.
Makes sense!
No description provided.