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

Very weird [FAIL. Reason: EvmError: Revert], only when test with USDT ERC20. #6459

Closed
2 tasks done
KuangyeChen opened this issue Nov 29, 2023 · 4 comments
Closed
2 tasks done
Labels
T-bug Type: bug

Comments

@KuangyeChen
Copy link

KuangyeChen commented Nov 29, 2023

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (d7d2901 2023-11-29T00:16:36.235049762Z)

What command(s) is the bug in?

forge test --rpc-url ${MAINNET_URL}

Operating System

macOS (Intel)

Describe the bug

Here is the code I have tested. If the token address is USDT, the test will fail with: [FAIL. Reason: EvmError: Revert]. I have tested with DAI and WETH, it will pass. It's the same on Linux and on Intel Mac. I don't know if there are other ERC20 contracts that will trigger the revert.

But since USDT is kinda important, I issue this here.

function testFoo() public {
    ERC20 token = ERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7);
    token.approve(
        uniswapV2AddressBook.uniswapV2Router02,
        2 ** 256 - 1 - 100
    );
}

The error:

  [32142] TestUniswapToleranceCheck::testFoo()
    ├─ [26953] 0xdAC17F958D2ee523a2206206994597C13D831ec7::approve(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 115792089237316195423570985008687907853269984665640564039457584007913129639835 [1.157e77])
    │   ├─ emit Approval(owner: TestUniswapToleranceCheck: [0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496], spender: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, value: 115792089237316195423570985008687907853269984665640564039457584007913129639835 [1.157e77])
    │   └─ ← ()
    └─ ← EvmError: Revert
@KuangyeChen KuangyeChen added the T-bug Type: bug label Nov 29, 2023
@jubeira
Copy link

jubeira commented Nov 29, 2023

@KuangyeChen use safeApprove ser: https://forum.openzeppelin.com/t/can-not-call-the-function-approve-of-the-usdt-contract/2130/2

@KuangyeChen
Copy link
Author

@KuangyeChen
Copy link
Author

safeApprove is deprecated according to this issue. Use safeIncreaseAllowance instead.

@jubeira
Copy link

jubeira commented Nov 30, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

2 participants