When a pot is created, the totalRewards
is set, this parameter doesn't have any requirement, therefor it can be less than the actual total rewards amount in rewards[]
or even 0, and in order to claim their prizes, the players use Pot::claimCut
which substract the amount claimed to remainingRewards
that in on itself is set as equal to totalRewards when the pot is created, If the said variable is less than the amount claimed, the function will revert beacuse of underflow, and thus the player will not be able to claim his cut.
First in ContestManager::createContest
the total rewards is set with no check for zero amount in place, nor check if the said value is equivalent to the actual total rewards (as shown in th code snipet below), as such, it is possible to make a mistake by accident or on purpuse by malicious contest manager.
When the pot is created, remainingRewards
is set to total rewards in Pot::constructor
.
The issue becomes evident when a player tries to claim his cut, as shown below, the amount the player is claimming, is subtracted from the remainingRewards variable, as susch, if reward > remainingRewards the function will revert due to arithmetic underflow, making it imposible for a player to get his reward.
You may corroborate the problem by adding the following codes in TestMyCut.sol
, in this codes, we test two posible sitations, the first one where totalRewards = 0
making every claim imposible; an a second one, where totalRewards != 0
but is still less than the actual total amount to be claimed, meaning the first claim will succeed but the following ones will not.
Player would be unable to claim their prizes if it is greater than the totalRewards if t was set incorrectly.
Foundry and Manual review
The simplest solution would be that the totalRewards variable is set as the addition of all values within the rewards array using a for loop as follows:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.