lack of slippage protection in the withdraw function would lead to frontrunning or MEV losses for users.
In the provided withdraw function, there's no mechanism to guarantee a minimum amount of tokens the user will receive. The user specifies _amountToWithdraw, but there's no guarantee about how many tokens they'll actually receive. The function processes the withdrawal and transfers whatever amount is left after the operations.
If the value of the token changes between the time the user initiates the transaction and when it's executed, they might receive fewer tokens than expected. In blockchain networks, miners or validators can reorder transactions. A malicious actor could potentially front-run the withdrawal, affecting the price and causing the user to receive less than expected.
What could happen without slippage protection:
User initiates a withdrawal of 100 pool tokens.
Due to market fluctuations or MEV, the value of the pool tokens drops by 5% before the transaction is processed.
The user ends up receiving only 95 tokens of the underlying asset.
The transaction succeeds, but the user receives less than they expected.
By not including slippage protection, the original withdraw function exposes users to potential losses due to market volatility or malicious actors. Implementing slippage protection allows users to specify their risk tolerance and ensures they receive at least a minimum amount of tokens they're willing to accept.
Manual Review
Add slippage protection. The user specifies both _amountToWithdraw and _minAmountToReceive.
If the amount received falls below _minAmountToReceive, the transaction reverts.
This allows the user to set a threshold for the minimum acceptable amount, protecting them from unexpected losses.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.