_distributeRewards()
serves the purpose of transferring Ether within the contract to the owner if the proposal fails, or to the For voters if the proposal succeeds. However, there's an issue in the calculation of rewardPerVoter, resulting in an incorrect distribution. This miscalculation leads to a situation where users who vote For receive fewer rewards.
distributeRewards()
calculates the rewardPerVoter using a formula that involves totalVotes when a proposal passes.
While this approach works seamlessly when all votes are in favor, it introduces a problem when there's even a single vote against. In such cases, for each against vote, the users who voted For will receive less rewards.
For better comprehension, let's illustrate with an example:
---------------------------Example---------------------------
totalVotesFor = 3
totalVotesAgainst = 1
totalVotes = 3 + 1 = 4
totalRewards = 4 ETH
rewardPerVoter = 4 / 4 = 1 ETH
Each user will receive 1 ETH provocating a 1 ETH becomes trapped within the contract. The accurate totalRewards should be:
rewardPerVoter = 4 / 3 = 1.3 ETH
Users who vote For will receive less rewards, and the remaining difference will become trapped within the contract.
Manual review.
Change rewardPerVoter for the following formula rewardPerVoter = totalRewards / totalVotesFor
.
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.