The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: medium
Invalid

swap function will fail for fee-on-transfer tokens

Summary

The swap function will fail for fee-on-transfer input tokens. This is because the parameter amountIn will decrease when a transaction will be done on the input token.
For example, say the user has USDT or STA token (fee-on-transfer tokens) as input token for swap. The user has specified the swap amount as X. Due to which, the amountIn parameter is calculated as (X-Y) amount, where Y is the swap fee. Now, before performing the actual swap, the swap fee Y is transferred. As these tokens incur fee, when transfer functions are called, so this leads to a decrease in the amount of remaining tokens, which is less than the calculated amountIn amount.

As a result of this the safeApprove function fails, because the amount that it was trying to approve was amountIn , but in reality the amount that was remaining is less than amountIn.

Hence when such fee-on-transfer tokens are used, the swap function will always revert.

Vulnerability Details

The protocol doesn't support fee on transfer tokens like USDT or STA

Impact

Swap function will always fail for fee-on-transfer tokens

Tools Used

Manual review

Recommendations

Before approving the calculated amount, check the current balance, and accordingly approve the current amount.

Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

fee-on-transfer

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Out of scope
Assigned finding tags:

fee-on-transfer

Support

FAQs

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