The function swapExactOutput
lacks slippage protection, which means that once the user initiates a transaction, it will be completed even if the price fluctuates beyond the user's acceptable range during this period. This can lead to financial losses for the user and a poor user experience.
The implementation of swapExactOutput
lacks verification of the final transaction price range, resulting in unpredictable transaction prices that are likely to deviate significantly from the user's expectations.
First, we need to fix the price calculation bug that existed in the original swapExactOutput
function. Here we replace the call to the getInputAmountBasedOnOutput
function with the correct calculation.
Place the following into TSwapPool.sol
, we will use this function in the test:
The above function is provided for testing convenience only. Please delete it after confirming the correction.
To simulate a scenario where a large transaction causes significant price fluctuations, and the user, being unaware of this, expects the previous price but ends up paying much more tokens than anticipated.
Place the following into TSwapPool.t.sol
:
In the event of severe market price fluctuations, it is highly likely that transactions will be executed at extremely unfavorable prices, which are unacceptable for users.
The function needs to include a maxInputAmount
variable to ensure that the transaction occurs within a specified range acceptable to the user.
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.