Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: high
Invalid

BaseGauge.sol :: wrong Order of operations Leads to exponentiation of rewardPerTokenStored in getRewardPerToken()

Summary

The order of operation in getRewardPerToken() for calculating rewardPerTokenStored can make it grow exponentially, severly overstating each individuals rewards

Vulnerability Details

/**
* @notice Calculates current reward per token
* @return Current reward per token value
*/
function getRewardPerToken() public view returns (uint256) {
.... other codes....
return rewardPerTokenStored + (
(lastTimeRewardApplicable() - lastUpdateTime) * rewardRate * 1e18 / totalSupply()
);
}

should be changed to

return (
rewardPerTokenStored +
lastTimeRewardApplicable() - lastUpdateTime) * rewardRate * 1e18 / totalSupply()
);

The order of operation in the current logic can make rewardPerTokenStored grow exponentially, severly overstating each individuals rewards. Individuals will therefore either be able to withdraw more funds than should be allocated to them or they will not be able to withdraw thier funds at all as the contract will have insufficient amount of tokens

Impact

High

individuals rewards can be severly overstated

Tools Used

Manual analysis, also reported in unipool's audit report

Recommendations

The order of operation should be changed

/**
* @notice Calculates current reward per token
* @return Current reward per token value
*/
function getRewardPerToken() public view returns (uint256) {
.... other codes....
return rewardPerTokenStored + (
(lastTimeRewardApplicable() - lastUpdateTime) * rewardRate * 1e18 / totalSupply()
);
}

should be changed to

return (rewardPerTokenStored +
lastTimeRewardApplicable() - lastUpdateTime) \* rewardRate \* 1e18 / totalSupply()
);
Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!