Summary
In the closePot function of the Pot contract, the calculation of claimantCut incorrectly uses the length of the i_players array instead of the claimants array. This miscalculation can lead to incorrect distribution of remaining rewards.
Vulnerability Details
The closePot function calculates claimantCut using i_players.length.
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
Rewards may be distributed incorrectly, with claimants receiving less than their fair share. Claimants may be dissatisfied with the reward distribution, leading to potential disputes.
Tools Used
Manual Review
Recommendation
Modify the calculation to use claimants.length instead of i_players.length.
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);
}
}
}