Division calculations rounding down leads to users receiving fewer rewards
Summary
Certain division calculations will lead to the user receiving fewer rewards, or funds getting stuck in the contracts.
Vulnerability Detail
For example, when calculating emissionsPerSecond with an odd duration parameter, the final value will be rounded down, which means the user will receive a little less rewards than supposed.
Elegant Vanilla Crane
Low/Info
Division calculations rounding down leads to users receiving fewer rewards
Summary
Certain division calculations will lead to the user receiving fewer rewards, or funds getting stuck in the contracts.
Vulnerability Detail
For example, when calculating
emissionsPerSecond
with an odd duration parameter, the final value will be rounded down, which means the user will receive a little less rewards than supposed.Solidity:
10e18 / 19 == 526315789473684210
Python:10e18 / 19 == 526315789473684224
Impact
User will receive fewer rewards than supposed.
Code Snippet
https://github.com/sherlock-audit/2024-06-magicsea/blob/main/magicsea-staking/src/rewarders/BribeRewarder.sol#L308
Tool used
Manual Review, Foundry
Recommendation
Use the SafeMath library by OpenZeppelin