Skip to content

Commit

Permalink
Fix audit #GAS-01
Browse files Browse the repository at this point in the history
Multiply before division
  • Loading branch information
cwsnt committed Nov 18, 2021
1 parent c45cadb commit d18a2b0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions contracts/governance/GovernorAlpha.sol
Expand Up @@ -526,12 +526,9 @@ contract GovernorAlpha is SafeMath96 {
}
uint96 totalVotes = add96(proposal.forVotes, proposal.againstVotes, "GovernorAlpha:: state: forVotes + againstVotes > uint96");
uint96 totalVotesMajorityPercentage = div96(totalVotes, 100, "GovernorAlpha:: state: division error");
totalVotesMajorityPercentage = mul96(
totalVotesMajorityPercentage,
majorityPercentageVotes,
"GovernorAlpha:: state: totalVotes * majorityPercentage > uint96"
);
uint96 totalVotesMajorityPercentage =
mul96(totalVotes, majorityPercentageVotes, "GovernorAlpha:: state: totalVotes * majorityPercentage > uint96");
totalVotesMajorityPercentage = div96(totalVotesMajorityPercentage, 100, "GovernorAlpha:: state: division error");
if (proposal.forVotes <= totalVotesMajorityPercentage || totalVotes < proposal.quorum) {
return ProposalState.Defeated;
}
Expand Down

0 comments on commit d18a2b0

Please sign in to comment.