TSwapPool::swapExactOutput
does not include proper slippage protection.
The function swapExactOutput
does not include any kind of slippage protection. This function is similar to what is done in TSwapPool::swapExactInput
, where the function specifies the minOutputAmount
. Similarly, swapExactOutput
should specify a maxInputAmount
.
If the market conditions change before the transaction process, the user could get a much worse swap then expected.
Foundry, manual review.
The price of WETH is 1_000 USDC.
User calls swapExactOutput
, looking for 1 WETH with the following parameters:
inputToken: USDC
outputToken: WETH
outputAmount: 1
deadline: whatever
The function does not allow a maxInputAmount
.
As the transaction is pending in the mempool, the market changes, and the price movement is huge: 1 WETH now costs 10_000 USDC, 10x more than the user expected!
The transaction completes, but the user got charged 10_000 USDC for 1 WETH.
Include a maxInputAmount
input parameter in the function declaration, so that the user could specify the maximum amount of tokens he would like to spend and, hence, could predict their spending when using this function of the protocol.
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.