MyCut

First Flight #23
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

`Pot::clostPot()` incorrectly calculates how much to reward each claimant

Summary

Claimants will always receive less tokens than they should when there's still rewards left in the pot and Pot::clostPot() is called once the claim period is over.

Vulnerability Details

The clostPot() function inside the Pot contract calculates how many tokens each claimant should receive by subtracting the managers cut from the remaining cut and the dividing it by the total number of players, as opposed to the total number of claimants, this means that the lower the number of people that have claimed are, aka claimants, the more tokens that'll be left in the contract instead of being sent to the claimants.

function closePot() external onlyOwner {
if (block.timestamp - i_deployedAt < 90 days) {
revert Pot__StillOpenForClaim();
}
if (remainingRewards > 0) {
uint256 managerCut = remainingRewards / managerCutPercent;
i_token.transfer(msg.sender, managerCut);
@> uint256 claimantCut = (remainingRewards - managerCut) / i_players.length;
for (uint256 i = 0; i < claimants.length; i++) {
_transferReward(claimants[i], claimantCut);
}
}
}

Impact

Users will receive less tokens than they should if the pot closes with rewards remaining.

Tools Used

Manual Review

Recommendation

Divide the remaining rewards by the total number of claimants instead of the total number of players

function closePot() external onlyOwner {
if (block.timestamp - i_deployedAt < 90 days) {
revert Pot__StillOpenForClaim();
}
if (remainingRewards > 0) {
uint256 managerCut = remainingRewards / managerCutPercent;
i_token.transfer(msg.sender, managerCut);
- uint256 claimantCut = (remainingRewards - managerCut) / i_players.length;
+ uint256 claimantCut = (remainingRewards - managerCut) / claimants.length;
for (uint256 i = 0; i < claimants.length; i++) {
_transferReward(claimants[i], claimantCut);
}
}
}
Updates

Lead Judging Commences

equious Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Incorrect distribution in closePot()

Support

FAQs

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