Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blunt Ebony Copperhead - Precision loss while calculating pricePerVote in ReputationMarket::sellVotes #134

Open
sherlock-admin3 opened this issue Dec 30, 2024 · 0 comments

Comments

@sherlock-admin3
Copy link
Contributor

Blunt Ebony Copperhead

Medium

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.

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 the sellVotes function, line where pricePerVote 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

  1. User calls the sellVotes function.

Impact

  • Rejection of valid transactions where the actual price per vote should meet the minimumVotePrice.
  • Potential underestimation of the per-vote price in edge cases.

PoC

No response

Mitigation

Introduce a scaling factor (e.g., 10**18) to preserve precision during division.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant