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

Best Carbon Eagle - in sellVotes, participants who sold all their shares are not removed from the array #727

Open
sherlock-admin2 opened this issue Dec 5, 2024 · 0 comments

Comments

@sherlock-admin2
Copy link
Contributor

Best Carbon Eagle

Medium

in sellVotes, participants who sold all their shares are not removed from the array

Summary

When participant's shares reach zero in sellVotes, they are not removed from the participants array.

function sellVotes(
  uint256 profileId,
  bool isPositive,
  uint256 amount
) public whenNotPaused activeMarket(profileId) nonReentrant {
  _checkMarketExists(profileId);

  // calculate the amount of votes to sell and the funds received
  (
    uint256 votesSold,
    uint256 fundsReceived,
    ,
    uint256 protocolFee,
    uint256 minVotePrice,
    uint256 maxVotePrice
  ) = _calculateSell(markets[profileId], profileId, isPositive, amount);

  // update the market state
  markets[profileId].votes[isPositive ? TRUST : DISTRUST] -= votesSold;
  votesOwned[msg.sender][profileId].votes[isPositive ? TRUST : DISTRUST] -= votesSold;

  // apply protocol fees
  applyFees(protocolFee, 0, profileId);

  // send the proceeds to the seller
  _sendEth(fundsReceived);
  // tally market funds
  marketFunds[profileId] -= fundsReceived;
  emit VotesSold(
    profileId,
    msg.sender,
    isPositive,
    votesSold,
    fundsReceived,
    block.timestamp,
    minVotePrice,
    maxVotePrice
  );
  _emitMarketUpdate(profileId);
}

Impact

They are still regarded as a participant even though they no longer hold shares.

Code snippet

https://github.com/sherlock-audit/2024-11-ethos-network-ii/blob/57c02df7c56f0b18c681a89ebccc28c86c72d8d8/ethos/packages/contracts/contracts/ReputationMarket.sol#L495-L534

Recommendation

Remove them from the array when share balance hits 0.

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