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 first/last transfer heuristic:

  • Uses first transfer as tokenIn (what user sent)
  • Uses last transfer as tokenOut (what user received)

Changes

  • src/index.ts: Added fallback logic using first/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
});
});

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.

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