TSwapPool::sellPoolTokens mistakenly calls the incorrect swap function.
The sellPoolTokens function is intended to allow users to easily sell pool tokens and receive WETH in exchange. In the poolTokenAmount parameter, users indicate how many pool token they intend to sell. However, the function mistakenly calls swapExactOutput instead of swapExactInput to perform the swap, and therein assignes the value of poolTokenAmount to function input argument outputAmount, effectively mixing up the input and output tokens / amounts.
Consider the following scenario:
A user has 100 pool tokens, and wants to sell 5 by calling the sellPoolTokens function.
Instead of the swapExactInput function, sellPoolTokens calls swapExactOutput.
In swapExactOutput, poolTokenAmount is used as outputAmount while it is really the input amount.
As a result, user will swap more output tokens than originally intended.
Apart from this, the user will be overtaxed due to a bug in getInputAmountBasedOnOutput() called by swapExactOutput.
For a proof of code, add this piece of code to TSwapPool.t.sol:
Users will swap the incorrects amount of tokens, which severely discrupts the functionality of the protocol.
Manual review, Foundry.
Change the implementation to use swapExactInput instead of the swapExactOutput function. Note that this would require the sellPoolTokens function to accept an additional parameter (i.e. minOutputAmount to be passed to swapExactInput).
Additionally, it might be wise to add a deadline to the function, as currently there is no deadline.
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.