Skip to content

Conversation

@barskhianfannie
Copy link
Member

@barskhianfannie barskhianfannie commented Nov 26, 2025

Problem

The existing parser fails in two example swaps:

  • Example: 0x7eea91c5c715ef4bb1e39ddf4c7832113693e87c18392740353d5ae669406a46 Etherscan
  • Example: 0xdee6f4fea0250f297ed9663c4ca4479e8a253c62e16faa60759e25832cd1f34f OpScan

Resolves Issue #94

Solution

Adds fallback logic when primary parsing fails using a last transfer heuristic:

  • Uses last transfer as tokenOut (what user received)

Changes

  • src/index.ts: Added fallback logic using last transfer
  • src/tests/index.test.ts: Added tests for the failing txns

Testing

Ensure all tests are passing locally.

Additional Changes

  • Updated README.md to ensure table display has a consistent number of columns in every row.
  • Added more context to the .env.example regarding the various enviornment variables needed to successfully run all tests.

@barskhianfannie barskhianfannie marked this pull request as draft November 26, 2025 06:10
@barskhianfannie barskhianfannie force-pushed the main branch 2 times, most recently from 85599bb to 502eade Compare November 26, 2025 22:49
@barskhianfannie barskhianfannie self-assigned this Nov 26, 2025
@barskhianfannie barskhianfannie marked this pull request as ready for review November 26, 2025 23:08
@barskhianfannie barskhianfannie changed the title feat: add fallback parsing for complex multi-hop transactions feat: add first in/out heuristic for transactions which fail to parse Nov 26, 2025
@barskhianfannie barskhianfannie changed the title feat: add first in/out heuristic for transactions which fail to parse feat: add first/last transfer heuristic for transactions which fail to parse Nov 26, 2025
@hzhu hzhu self-requested a review November 29, 2025 09:46
address: "0x4200000000000000000000000000000000000006",
},
});
});
Copy link
Member

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? 🙏

Suggested change
});
});

hzhu
hzhu previously approved these changes Nov 30, 2025
.env.example Outdated
ALCHEMY_API_KEY="your-alchemy-api-key-here"


# Required: QuickNode API keys for specific chain tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: proper casing for Quicknode.

Suggested change
# Required: QuickNode API keys for specific chain tests
# Required: Quicknode API keys for specific chain tests

@hzhu
Copy link
Member

hzhu commented Nov 30, 2025

Thanks for the PR! Appreciate the description, and tying the PR to an issue.

@barskhianfannie barskhianfannie changed the title feat: add first/last transfer heuristic for transactions which fail to parse feat: add last transfer heuristic for transactions which fail to parse Dec 2, 2025
Comment on lines +67 to +73
// The Issue: FOR SETTLERINTENT TXNS only - The taker address passed into calculateNativeTransfer is not the actual takers address, causing nativeAmountToTaker to be 0 when it shouldn't be
// Potential Solution: we need to determine if the txn is a settlerIntent txn, if so we
// can determine the taker from the to address in the last trace call.
const actualTaker = trace.calls[trace.calls.length-1].to;
//Scans the execution trace for any internal ETH transfers to the taker's address
const nativeAmountToTaker = calculateNativeTransfer(trace, {
recipient: taker,
recipient: taker, // for Settler Intent txns we should use actualTaker
Copy link
Member Author

@barskhianfannie barskhianfannie Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@duncancmt In order to solve the failing parse for this Optimism txn, I am thinking of using the solution outlined in the comments of this codeblock. Any feedback before I begin implementation on if this is a valid approach or not?

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

Successfully merging this pull request may close these issues.

2 participants