Calculations in _distributeRewards() use totalVotes to calculate how many pieces the reward should be divided to. This is incorrect way to do that because it divides the reward into more pieces, than it should be.
Here we calculate portion of the reward by dividing totalRewards by totalVotes instead of totalVotesFor .
Consider this situation:
There are 5 eligible voters.
First voter votes for (true), second voter votes against (false) and the third voter votes for (true).
This situation looks as follows:
Reward: 1ETH
The quorum has been reached.
Total votes: 3
Votes for: 2
Votes againt: 1
Reward for "for" voter is = reward / totalVotes. (1 ETH / 3) = 1/3 of the reward
When there are two for voters the reward is 2 * 1/3 = 2/3 which means that 1/3 of the reward is stuck in contract.
Due to the current design the reward will be divided into three pieces but only two will be sent meaning some portion will be stuck in contract because the function includes the against votes in calculations.
Please add this test to test/VotingBoothTest.t.sol and run forge test
Funds are stuck in contract.
VScode, Manual Review
To calcuate correct amount that has to be sent to "for" voter divide the reward by totalVotesFor not totalVotes to ensure corrent reward calculation and distribution.
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.