Incorrect calculation for rewardPerVoter leads to lose of funds
VotingBooth:_distributeRewards is a function called when totalCurrentVotes * 100 / s_totalAllowedVoters >= MIN_QUORUM, basically, when the quorum is met. If totalVotesAgainst < totalVotesFor then it calculates the rewardPerVoter by dividing totalRewards by totalVotes. Calculation is incorrect, as it should be totalVotesFor instead of totalVotes, as the contract will be trying to distribute all rewards among the total amount of voters, but it will only iterate through the s_votersFor array. Also, in VotingBooth.sol#L207, the denominator should also be totalVotesFor instead of totalVotes.
This means there will be ether left in the contract, not distributed, and the ether is lost.
High impact, high likelihood. Funds remaining in contract is lost.
Manual Review
Foundry
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.