First Flight #18: T-Swap

First Flight #18
Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

Wrong Calculation of fee to be deducted in TSwapPool::getInputAmountBasedOnOutput, causing protocol to deduct more fees than it should

Summary

Wrong Calculation of fee to be deducted in TSwapPool::getInputAmountBasedOnOutput, causing protocol to deduct more fees than it should

Vulnerability Details

In TSwapPool::getInputAmountBasedOnOutput function it calculates inputAmount based on outputAmount,inputReserves, outputReserves and then when computing the fee it multiplies by a factor of 10000 instead 1000

Impact

The user gets more fees deducted from them than expected

Tools Used

Manual Review

Recommendations

function getInputAmountBasedOnOutput(
uint256 outputAmount,
uint256 inputReserves,
uint256 outputReserves
)
public
pure
revertIfZero(outputAmount)
revertIfZero(outputReserves)
returns (uint256 inputAmount)
{
- return ((inputReserves * outputAmount) * 10_000) / ((outputReserves - outputAmount) * 997);
+ return ((inputReserves * outputAmount) * 1_000) / ((outputReserves - outputAmount) * 997);
}
Updates

Appeal created

inallhonesty Lead Judge 11 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Incorrect fee calculation in TSwapPool::getInputAmountBasedOnOutput causes protocol to take too many tokens from users, resulting in lost fees

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.