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

Incorrect parsing of transaction input in trade_simulator #1

Open
Godxia opened this issue Nov 5, 2023 · 1 comment
Open

Incorrect parsing of transaction input in trade_simulator #1

Godxia opened this issue Nov 5, 2023 · 1 comment

Comments

@Godxia
Copy link

Godxia commented Nov 5, 2023

I've added a test case in trade_simulator to verify the transaction input data parsing:
#[test] fn test_wrangle_tx() { let mut trade_simulator = TradeSimulator::new(); let buf = hex!("ac9650d8...[truncated for brevity]...0000000000000042"); let tx = TransactionInfo{ to: e_Address::from_str("0xE592427A0AEce92De3Edee1F18E0157C05861564").unwrap(), value: U256::zero(), input: &buf }; trade_simulator.wrangle_transaction(&tx); }
Upon running this test, I'm trying to match and decode data corresponding to the UNISWAP_V3_V2_EXACT_OUTPUT selector:
} else if selector == UNISWAP_V3_V2_EXACT_OUTPUT { println!("🦄2 exact output"); let swap = UniswapV3ExactOutputParamsV2::decode(buf).unwrap(); println!("{:?}",swap.path); println!("{:?}",TradeSimulator::bytes_zcp_to_hex_string(&swap.path)); }
The output I received was:
🦄2 exact output BytesZcp([0, 0, 0, 0,...,0, 0, 66]) "00000000000000000000000022e798f9440f563b92aae24e94c75dfa499e3d3e00000000000000000000000000000000000000000000009110f5cdf1c1500000000000000000000000000000000000000000000000000000000000007741d7a10000000000000000000000000000000000000000000000000000000000000042"
This is incorrect, yielding a length of 128 bytes for the parsed result. The expected correct result should be of 66 bytes:
0c880f6761f1af8d9aa9c466984b80dab9a8c9e8000bb882af49447d8a07e3bd95bd0d56f35241523fbab10001f4ff970a61a04b1ca14834a43f5de4533ebddb5cc8

@Godxia
Copy link
Author

Godxia commented Nov 5, 2023

Sorry! The parsed content is wrong, the correct one is:
fn test_wrangle_tx() { let mut trade_simulator = TradeSimulator::new(); let buf = hex!("09b813460000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000022e798f9440f563b92aae24e94c75dfa499e3d3e00000000000000000000000000000000000000000000009110f5cdf1c1500000000000000000000000000000000000000000000000000000000000007741d7a100000000000000000000000000000000000000000000000000000000000000420c880f6761f1af8d9aa9c466984b80dab9a8c9e8000bb882af49447d8a07e3bd95bd0d56f35241523fbab10001f4ff970a61a04b1ca14834a43f5de4533ebddb5cc8000000000000000000000000000000000000000000000000000000000000"); let tx = TransactionInfo{ to: e_Address::from_str("0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45").unwrap(), value: U256::zero(), input: &buf }; trade_simulator.wrangle_transaction(&tx); }
In addition, the definition of e_Address comes from use ethers::types::Address as e_Address;

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