Core Contracts

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

Wrong calculation of rewards in `FeeCollector::_calculatePendingReward` function.

Summary

FeeCollector::_calculatePendingReward function is used in claimRewards function which is used to calculate the amount of reward tokens for the user. But the formula used is incorrect which is going to give 0 or very less rewards to the users.

Vulnerability Details

In function FeeCollector::_calculatePendingReward(),

function _calculatePendingRewards(address user) internal view returns (uint256) {
uint256 userVotingPower = veRAACToken.getVotingPower(user);
if (userVotingPower == 0) return 0;
uint256 totalVotingPower = veRAACToken.getTotalVotingPower();
if (totalVotingPower == 0) return 0;
uint256 share = (totalDistributed * userVotingPower) / totalVotingPower;
return share > userRewards[user] ? share - userRewards[user] : 0;
}

It gets the user voting power and the total voting power, the it calculates the share amount , and then return the share amount as given. Which is incorrect and it is going to return wrong reward shares amount,
The correct way to calculate share amount is

uint256 share = ((totalDistributed - userRewards[user] )* userVotingPower)/ totalVotingPower;

Impact

Less or 0 amount of reward tokens will be distributed loss for the users.

Tools Used

Manual review

Recommendations

Calculate share amount as

uint256 share = ((totalDistributed - userRewards[user] )* userVotingPower)/ totalVotingPower;
Updates

Lead Judging Commences

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!