Wrong formula to calculate rewardPerVoter
when proposal passed. Certain amount of ETH can remain in the contract forever
In VotingBooth::_distributeRewards()
function, in case the proposal passed, the eth reward should be distributed to all "For" voters equally. Hence the formula for calculating the rewardPerVoter
should be as follows:
Instead it is as follows:
In case when:
the proposal passed (there are more voters for than against) and
there is at least one voter against
not all of the reward will be distributed to the "For" voters, and totalRewards/totalVotes * (totalVotes - totalVotesFor)
of eth will remain in the contract after distribution is finished.
Changing the existing test function testVotePassesAndMoneyIsSent()
so that address(0x3)
votes against will cause the test to fail.
I additionally added console2.log
to see the balances
The result will be:
Consider changing the following lines in the function _distributeRewards()
:
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.