This calculation can lead to a loss of precision due to integer division. If _weights[i] is small compared to _totalVoteWeight, the result of the multiplication might be less than _totalVoteWeight, causing the division to result in zero. This can lead to votes being lost or skewed.
To fix this, we should rearrange the calculation to minimize the loss of precision:
Atomic Tortilla Falcon
Low/Info
loss of precision when
_weights[i]
is small compared to_totalVoteWeight
Vulnerability Detail
The bug is in the calculation of
_poolWeight
:This calculation can lead to a loss of precision due to integer division. If
_weights[i]
is small compared to_totalVoteWeight
, the result of the multiplication might be less than_totalVoteWeight
, causing the division to result in zero. This can lead to votes being lost or skewed.To fix this, we should rearrange the calculation to minimize the loss of precision:
Code Snippet
https://github.com/sherlock-audit/2024-06-velocimeter/blob/main/v4-contracts/contracts/Voter.sol#L267
Tool used
Manual Review