MyCut

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

Incorrect calculation of claimantCut in the Pot::closePot function

Relevant GitHub Links

https://github.com/Cyfrin/2024-08-MyCut/blob/main/src/Pot.sol#L57

Summary

The project description states that the remaining rewards should be distributed equally among those who claimed them in time. However, in the Pot::closePot function, the formula for claimantCut is (remainingRewards - managerCut) / i_players.length. If not all players claim their rewards (i.e., claimants.length < i_players.length), the claimants will receive a smaller cut, and tokens will remain in the Pot contract after the pot is closed.

Impact

If not all players claim their rewards, they will receive a smaller cut when the pot is closed.

Recommendation

To fix this, the denominator in the formula should be changed to claimants.length:

- uint256 claimantCut = (remainingRewards - managerCut) / i_players.length;
+ uint256 claimantCut = (remainingRewards - managerCut) / claimants.length;
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.