Division before Multiplication could incur unnecessary precision loss #232
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-194
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/nounsDAO/nouns-monorepo/blob/718211e063d511eeda1084710f6a682955e80dcb/packages/nouns-contracts/contracts/governance/NounsDAOV3DynamicQuorum.sol#L64
Vulnerability details
Impact
Division before multiplication could incur unnecessary precision loss causing loss of funds.
Proof of Concept
In the
dynamicQuorumVotes()
function ofNounsDAOV3DynamicQuorum.sol
contract the value ofagainstVotesBPS
is first calculated by dividing a value bytotalSupply
before doing another multiplication withagainstVotesBPS
in the next line.Tools Used
Manual Review
Recommended Mitigation Steps
When implementing mathematical operations involving multiplication and division, always ensure all division come last after all multiplications have been implemented to avoid incurring precision loss and subsequent loss of value.
Assessed type
Math
The text was updated successfully, but these errors were encountered: