Skip to content

Fork not working as expected #20

Open
@elyase

Description

@elyase

Problem:

This tx simulates on tenderly or cast without issue but fails with pyrevm (see below for tx details). There are no other txs for that pool in the block.

Code

from pyrevm import EVM

# Swap 0.031485012992133186 ETH for 1,110.686711078457978839 CSWAP on Uniswap v2
block_number = 19726294
caller = "0xc0170e050355408e53800d093f3f13c3a53b29c8"
router = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
value = 31485012992133186
tx_input = bytes.fromhex(
    "b6f9de950000000000000000000000000000000000000000000000343cc08b07804e00000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000c0170e050355408e53800d093f3f13c3a53b29c80000000000000000000000000000000000000000000000000000000066292d4e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000ae41b275aaaf484b541a5881a2dded9515184cca"
)

fork_url = "https://eth.merkle.io"
evm = EVM(
    fork_url=fork_url,
    fork_block=str(block_number - 1),
)

evm.set_balance(caller, value)
evm.message_call(
    caller=caller,
    to=router,
    calldata=tx_input,
    value=value,
    is_static=False,
)

Error

it fails with:

evm.message_call(
RuntimeError: Revert { gas_used: 221178, output: 0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002b556e69737761705632526f757465723a20494e53554646494349454e545f4f55545055545f414d4f554e54000000000000000000000000000000000000000080 }

Error can be decoded to UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT

Transaction details

cast tx --rpc-url "https://eth.merkle.io" 0x652bae3b1c11fbcf64309c2dfec5537b9bd1d3f2b521176f71ba1115a313ecbd --json | jq .
{
  "hash": "0x652bae3b1c11fbcf64309c2dfec5537b9bd1d3f2b521176f71ba1115a313ecbd",
  "nonce": "0xf4",
  "blockHash": "0x46f9451a299c23b82ce71b0d4c510ebddad5a7b6830237ed4e08440ff8985715",
  "blockNumber": "0x12cffd6",
  "transactionIndex": "0xf",
  "from": "0xc0170e050355408e53800d093f3f13c3a53b29c8",
  "to": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d",
  "value": "0x6fdb73d7250842",
  "gasPrice": "0x4902e7d7f",
  "gas": "0x300d8",
  "input": "0xb6f9de950000000000000000000000000000000000000000000000343cc08b07804e00000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000c0170e050355408e53800d093f3f13c3a53b29c80000000000000000000000000000000000000000000000000000000066292d4e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000ae41b275aaaf484b541a5881a2dded9515184cca",
  "v": "0x0",
  "r": "0xe4b274dbd9d9412fa10821d6234dc40212d95022a71ad6986cd84030aeda1e8a",
  "s": "0x44a3d544bb513107be06c1da4f39820dc72cc49a1cf076d42abb27ee5ee4e401",
  "sourceHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "isSystemTx": false,
  "type": "0x2",
  "accessList": [],
  "maxPriorityFeePerGas": "0x3b9aca00",
  "maxFeePerGas": "0x8a5215ece",
  "chainId": "0x1",
  "yParity": "0x0"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions