Slippage check is unnecessarily strict when executes swaps in CurveAdapter
.
CurveAdapter
provides executeSwapExactInput() for executing swaps. User can specify a custom path to swap input token for the desired output token.
CurveAdapter::executeSwapExactInput():
The problem is that it performs slippage checking for every intermediate swap, this is a bit strict and the whole swap may revert unnecessarily.
Assuming:
Swap path is [tokenA, tokenB, tokenC]
Slippage tolerance is 2%
For tokenA : tokenB
, the expected swap rate is 100 : 1
, and the actual swap rate is 103 : 1
For tokenB : tokenC
, the expected swap rate is 1 : 50
, and the actual swap rate is 1 : 53
Therefore, for tokenA : tokenC
, the expected swap rate for is 2 : 1
, and the actual swap rate is 1.83 : 1
.
By providing 100
tokenA, user is expected to receive 50
tokenC, but they can actually receive 51
tokenC, which is better, however, the transaction will revert when swaps tokenA for tokenB, as user is expected to receive 1
tokenB but they actually receive 0.97
, the slippage is more than 2%.
The swap unnecessarily revert.
Manual Review
It is recommended to calculate the expected swap rate for input token and output token, use this rate to perform slippage checking against the actual received token amount.
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.