Slow Tan Swallow
Medium
Unlike buyVotes
it's opposite sellVotes
lacks slippage protection.
function buyVotes(
uint256 profileId,
bool isPositive,
uint256 expectedVotes,
uint256 slippageBasisPoints
) public payable whenNotPaused activeMarket(profileId) nonReentrant {
// ...
_checkSlippageLimit(votesBought, expectedVotes, slippageBasisPoints);
// ...
}
function sellVotes(
uint256 profileId,
bool isPositive,
uint256 amount
//@audit no slippage protection
) public whenNotPaused activeMarket(profileId) nonReentrant {
This will put users in danger as selling votes decreases their price, and such if a user sells too many votes he can decrease his vote price bellow the one he is willing to get for selling, resulting in him selling, but receiving little to nothing. Same can be done if a TX of another sells happens before ours, where our user would sell at a starting lower price and further decrease his profit.
sellVotes
lacking slippage protection, while buyVotes
has it
No response
No response
- Bob make a TX to sell 50 votes
- Alice also makes a TX to sell 500 votes
- Alice TX gets executed first, meaning Bob sells at a much lower price
If Bob knew his actual sell price he wouldn't sell.
Users lose funds when selling.
No response
Add slippage protection, requiring the profit to be above a given amount (can be calculated off chain or in the front end).