You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Precision loss while calculating pricePerVote in ReputationMarket::sellVotes
Summary
The sellVotes function in the ReputationMarket contract calculates the price per vote by dividing proceedsBeforeFees by votesToSell. This calculation may lead to precision loss due to integer division in Solidity, potentially resulting in unexpected behavior or failed transactions when the calculated price does not meet the minimumVotePrice requirement.
Blunt Ebony Copperhead
Medium
Precision loss while calculating
pricePerVote
in ReputationMarket::sellVotesSummary
The
sellVotes
function in theReputationMarket
contract calculates the price per vote by dividingproceedsBeforeFees
byvotesToSell
. This calculation may lead to precision loss due to integer division in Solidity, potentially resulting in unexpected behavior or failed transactions when the calculated price does not meet theminimumVotePrice
requirement.Root Cause
Solidity uses integer arithmetic, truncating any fractional part during division. As a result,
proceedsBeforeFees / votesToSell
may not accurately represent the true price per vote. The issue lies in thesellVotes
function, line wherepricePerVote
is calculated.https://github.com/sherlock-audit/2024-12-ethos-update/blob/main/ethos/packages/contracts/contracts/ReputationMarket.sol#L553
Internal Pre-conditions
No response
External Pre-conditions
No response
Attack Path
sellVotes
function.Impact
minimumVotePrice
.PoC
No response
Mitigation
Introduce a scaling factor (e.g., 10**18) to preserve precision during division.
The text was updated successfully, but these errors were encountered: