Vulnerability Details
BaseGauge::getRewardPerToken#L574 has wrong value in the calculation.
* @notice Calculates current reward per token
* @return Current reward per token value
*/
function getRewardPerToken() public view returns (uint256) {
if (totalSupply() == 0) {
return rewardPerTokenStored;
}
return rewardPerTokenStored + ( 👇👇
(lastTimeRewardApplicable() - lastUpdateTime) * rewardRate * 1e18 / totalSupply()
);
}
Impact
It should use BIPS for calculation.
BIPS 10000
and 1e18
is not the same.
Tools Used
Manual
Recommendations
Use BIPS
for calculation. Like 10000
/**
* @notice Calculates current reward per token
* @return Current reward per token value
*/
function getRewardPerToken() public view returns (uint256) {
if (totalSupply() == 0) {
return rewardPerTokenStored;
}
return rewardPerTokenStored + (
- (lastTimeRewardApplicable() - lastUpdateTime) * rewardRate * 1e18 / totalSupply()
+ (lastTimeRewardApplicable() - lastUpdateTime) * rewardRate * 10000 / totalSupply()
);
}