The function TSwapPool::sellPoolTokens
is used by user to sell the pool token in exchange of weth. User inputs the amount of pool token he intends to sell and the function will calculate the weth that he will get in return. However, TSwapPool::sellPoolTokens
wrongly implement the return function swapExactOutput
resulting incorrect amount of weth paid to user and incorrect amount of pool token being deducted from user account after the sell transaction
According to the natspec, TSwapPool::sellPoolTokens
is used to facilitate users selling pool tokens in exchange of weth. However, TSwapPool::sellPoolTokens
implements wrong function swapExactOutput
to calculate the weth amount user should get after the user inputs the amount of pool token he intends to sell. The correct return value should be calculated through function swapExactInput
instead
Place the following test case in test/unit/TSwapPool.t.sol
:
** Prerequisite:
In contract TswapPool
, correct back another audit finding ( change 10000 to 1000) on getInputAmountBasedOnOutput
under the swapExactOutput
, so that we only test swapExactOutput
validity in the sellPoolToken
function and not influenced by the error caused by other factor.
The test above will fail indicating that the currect implementation of swapExactOutput
in TSwapPool::sellPoolTokens
is wrong. However if we change the return function from swapExactOutput
to swapExactInput
with the correct corresponding input parameters and return variable, the test above will pass.
User will receive an incorrect amount of weth and also will have incorrect amount of pool token being deducted as the result of the execution of TSwapPool::sellPoolTokens
with wrong return function implemented
Manual review and test case
Make correction to the return function used in TSwapPool::sellPoolTokens
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.