-
Notifications
You must be signed in to change notification settings - Fork 16
feat: add last transfer heuristic for transactions which fail to parse #93
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
base: main
Are you sure you want to change the base?
Conversation
85599bb to
502eade
Compare
502eade to
20439b5
Compare
src/tests/index.test.ts
Outdated
| address: "0x4200000000000000000000000000000000000006", | ||
| }, | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a new line here? 🙏
| }); | |
| }); | |
|
Thanks for the PR! Appreciate the description, and tying the PR to an issue. |
| if (to?.toLowerCase() === FORWARDING_MULTICALL_ADDRESS.toLowerCase()) { | ||
| const { args: multicallArgs } = decodeFunctionData({ | ||
| abi: FORWARDING_MULTICALL_ABI, | ||
| data: transaction.input, | ||
| }); | ||
|
|
||
| if (multicallArgs && Array.isArray(multicallArgs) && multicallArgs[0] && Array.isArray(multicallArgs[0])) { | ||
| const { args: settlerArgs } = decodeFunctionData({ | ||
| abi: SETTLER_META_TXN_ABI, | ||
| data: multicallArgs[0][1]?.data, | ||
| }); | ||
|
|
||
| const recipient = | ||
| settlerArgs[0].recipient.toLowerCase() as Address; | ||
|
|
||
| const msgSender = settlerArgs[3]; | ||
|
|
||
| const nativeAmountToTaker = calculateNativeTransfer(trace, { | ||
| recipient, | ||
| }); | ||
|
|
||
| if (nativeAmountToTaker === "0") { | ||
| [output] = logs.filter( | ||
| (log) => log.to.toLowerCase() === msgSender.toLowerCase() | ||
| ); | ||
| } else { | ||
| output = { | ||
| symbol: NATIVE_SYMBOL_BY_CHAIN_ID[chainId], | ||
| amount: nativeAmountToTaker, | ||
| address: NATIVE_TOKEN_ADDRESS, | ||
| }; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MultiCall3 will no longer be used and we can instead rely on the forwarding multi call address and abi @ this step of txn parsing. I decided to leave the previous logic related to Multicall3 to maintain backwards compatibility.
cc: @duncancmt
Problem
The existing parser fails in two example swaps:
0x7eea91c5c715ef4bb1e39ddf4c7832113693e87c18392740353d5ae669406a46Etherscan0xdee6f4fea0250f297ed9663c4ca4479e8a253c62e16faa60759e25832cd1f34fOpScanThis is occurring because we are relying on
MultiCall3to parse txns when we should instead rely on Forwarding Multi Call.Resolves Issue #94
Solution
Apply the necessary logic for Forward Multi Call support.
Changes
src/index.ts: Added logic for txn decoding when thetoaddress equals the Forwarding Multi Call address (0x00000000000000CF9E3c5A26621af382fA17f24f),src/tests/index.test.ts: Added tests for the failing txnssrc/tests/constants.tsx: AddedFORWARDING_MULTICALL_ADDRESSandFORWARDING_MULTICALL_ABITesting
Ensure all tests are passing locally.
Additional Changes
.env.exampleregarding the various environment variables needed to successfully run all tests.