TSwapPool::getInputAmountBasedOnOutput
overtaxes users with a 90.3% swap fee.
The getInputAmountBasedOnOutput
function is intended to calculate the amount of tokens the users should deposit given the amount of output tokens. However, the function currently miscalculates the resulting amount. When calculating the fee, it scales the amount by 10_000 instead of 1_000, resulting in a 90.3% fee.
Consider the following scenario:
The user calls TSwapPool::swapExactOutput
to buy a predefined amount of output tokens in exchange for an undefined amount of input tokens.
TSwapPool::swapExactOutput
calls the getInputAmountBasedOnOutput
function that is supposed to calculate the amount of input tokens required to result in the predefined amount of output tokens. However, the fee calculation in this function in incorrect.
The user gets overtaxed with a 90.4% fee.
Also consider the following test as proof of code:
The protocol takes way more fees than expected by the users.
Manual review, Foundry.
Perform the following corrections in TSwapPool::getInputAmountBasedOnOutput
:
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.