Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aamirusmani1552 - The protocol does not account for dual fee on fee on transfer token both stable fee currency and stable origin tokens are equal. #229

Open
sherlock-admin4 opened this issue Nov 13, 2024 · 0 comments

Comments

@sherlock-admin4
Copy link

sherlock-admin4 commented Nov 13, 2024

Aamirusmani1552

Medium

The protocol does not account for dual fee on fee on transfer token both stable fee currency and stable origin tokens are equal.

Summary

When user want to do the defiSwap first and then stable swap, there might be situation where the stable origin token and stable fee tokens are the same tokens. And if that token is a fee on transfer token then it will cause issue:

    function _stablecoinSwap(address wallet, StablecoinSwap memory ss) internal {
        if (ss.stablecoinFeeCurrency != address(0) && ss.stablecoinFeeSafe != address(0)) {
            ERC20PermitUpgradeable(ss.stablecoinFeeCurrency).safeTransferFrom(
                wallet, ss.stablecoinFeeSafe, ss.feeAmount
            );
        }

        // Handle the transfer or burning of the origin currency:
        // If the origin is a recognized stablecoin (XYZ), burn the specified amount from the wallet.
        if (isXYZ(ss.origin)) {
            Stablecoin(ss.origin).burnFrom(wallet, ss.oAmount);
        } else {
            ERC20PermitUpgradeable(ss.origin).safeTransferFrom(wallet, ss.liquiditySafe, ss.oAmount);
        }

        // Handle the minting or transferring of the target currency:
        // If the target is a recognized stablecoin (XYZ), mint the required amount to the destination address.
        if (isXYZ(ss.target)) {
            Stablecoin(ss.target).mintTo(ss.destination, ss.tAmount);
        } else {
            // @audit so the liquidity safe is going to give approval every time?
            ERC20PermitUpgradeable(ss.target).safeTransferFrom(ss.liquiditySafe, ss.destination, ss.tAmount);
        }
    }
    ```
    
    Github: [link](https://github.com/sherlock-audit/2024-11-telcoin/blob/main/telcoin-audit/contracts/stablecoin/StablecoinHandler.sol#L148C1-L165C1)
    
    For example if user wants to perform the defi to stable swap, the balance of origin token from the defi swap will not account for fee on the transfers double time. first when fee is transferred and second when the actual tokens is transferred. So it migh cause dos.  

### Root Cause

_No response_

### Internal pre-conditions

_No response_

### External pre-conditions

_No response_

### Attack Path

_No response_

### Impact

_No response_

### PoC

I am submitting this on last minute. that is why there is no POC. will provide later if necessary.

### Mitigation

Perform the neccessary check to make it work
@sherlock-admin3 sherlock-admin3 changed the title Passive Mango Rabbit - The protocol does not account for dual fee on fee on transfer token both stable fee currency and stable origin tokens are equal. Aamirusmani1552 - The protocol does not account for dual fee on fee on transfer token both stable fee currency and stable origin tokens are equal. Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant