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

PNS - MorphoLeverageModule._executeTrade may not work with some tokens such as USDT #46

Open
sherlock-admin3 opened this issue Oct 21, 2024 · 0 comments

Comments

@sherlock-admin3
Copy link
Contributor

sherlock-admin3 commented Oct 21, 2024

PNS

Medium

MorphoLeverageModule._executeTrade may not work with some tokens such as USDT

Summary

The USDT token requires first resetting to 0 when changing the allowance, which is not done with _executeTrade.

Root Cause

When changing the allowance for the next trade, the allowance should first be set to 0 for USDT.

Internal pre-conditions

No response

External pre-conditions

After the previous exchange using exchange Adapter the allowance was not fully used, which is why its value is different from 0.

Attack Path

The lever / delever function can be called with various adapters to perform a token exchange, depending on the implementation, they may not fully utilize the granted allowance for the token being exchanged. This will result in tokens such as USDT not being able to perform another trade, because changing from a non-zero allowance to another one is not possible.

MorphoLeverageModule._executeTrade

Impact

Attempting to call the lever / delever function and similar ones using the internal function _executeTrade will cause the transaction to revert. This will make the position unable to be balanced, which may lead to liquidation and financial loss.

Additionally, the main functions of the module will not work correctly.

PoC

No response

Mitigation

As in modules already implemented, e.g. AaveV3LeverageModule, you should first change the allowance to 0 and only then set a new non-zero value.

AaveV3LeverageModule.sol

@sherlock-admin2 sherlock-admin2 changed the title Harsh Sand Barbel - MorphoLeverageModule._executeTrade may not work with some tokens such as USDT PNS - MorphoLeverageModule._executeTrade may not work with some tokens such as USDT Oct 28, 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