Fun Tiger Horse
Medium
Slippage in sellVotes() should be calculated based on proceedsAfterFees instead of proceedsBeforeFees
The slippage in sellVotes()
is calculated based on proceedsBeforeFees
:
@--> uint256 pricePerVote = votesToSell > 0 ? proceedsBeforeFees / votesToSell : 0;
if (pricePerVote < minimumVotePrice) {
revert SellSlippageLimitExceeded(minimumVotePrice, pricePerVote);
}
The seller is going to ultimately receive proceedsAfterFees
and hence would base his expectations on that. Here's a simple example:
proceedsBeforeFees
is 6 etherprotocolFee
is 2 etherproceedsAfterFees = 6 - 2 = 4 ether
- Seller sold 1 vote and specified
minimumVotePrice
as5 ether
, which he expects to receive in his account - Protocol compared :
Is 6 < 5? No; so it's safe to continue
. - Seller gets
4 ether
in his account even though he had specifiedminimumVotePrice
as5 ether
.
- uint256 pricePerVote = votesToSell > 0 ? proceedsBeforeFees / votesToSell : 0;
+ uint256 pricePerVote = votesToSell > 0 ? proceedsAfterFees/ votesToSell : 0;
if (pricePerVote < minimumVotePrice) {
revert SellSlippageLimitExceeded(minimumVotePrice, pricePerVote);
}