After closePot() distributes the manager cut and claimant surplus, the remainingRewards state variable is never set to 0. The remainingRewards > 0 guard on line 53 passes on every subsequent call, causing the function to re-execute its distribution logic against an already-drained token balance.
After the first closePot() call distributes tokens, remainingRewards still holds its original value. On a second call:
With standard ERC20 tokens (which revert on insufficient balance): the second i_token.transfer() reverts because the Pot's token balance is now 0 or near 0. The transaction fails harmlessly but wastes the admin's gas.
With non-reverting tokens (if ever used despite the scope restriction): transfer() returns false silently. The function completes without error, but no tokens move. The stale remainingRewards value persists indefinitely, allowing infinite no-op calls.
In either case, the contract's remainingRewards getter permanently reports a non-zero value even after the pot is fully distributed, which is misleading for any off-chain systems reading this state.
Likelihood:
Requires the trusted admin to call closeContest() twice for the same pot. This is unlikely in normal operation but possible if the admin misunderstands the contract's state or if an automated system retries a transaction.
Impact:
With in-scope standard ERC20 tokens, the second call simply reverts — no fund loss, just wasted gas. The main concern is the permanently stale remainingRewards value misleading off-chain integrations.
The test shows that after closing a pot, remainingRewards still returns a non-zero value, and a second close attempt reverts because the token balance is already drained.
Set remainingRewards = 0 after the distribution block to make the function idempotent and ensure the state accurately reflects that the pot has been closed.
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.