Skip to content

feat(hindsight): decode on-chain aggregator swaps#253

Draft
tamaralipows wants to merge 2 commits into
mainfrom
tnl/decode-swaps
Draft

feat(hindsight): decode on-chain aggregator swaps#253
tamaralipows wants to merge 2 commits into
mainfrom
tnl/decode-swaps

Conversation

@tamaralipows

@tamaralipows tamaralipows commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

JIRA Task

(base) [23:12:44] [~/Code/fynd] >>> cargo run -p hindsight --release -- --rpc-url $RPC_URL --block 24978566

    Finished `release` profile [optimized] target(s) in 0.83s
     Running `target/release/hindsight --rpc-url 'https://nd-548-927-918.p2pify.com/e0bc212db3ddc9957521c2f73081d3ee' --block 24978566`
2026-06-18T03:13:14.721381Z  INFO decoding aggregator trades block=24978566
2026-06-18T03:13:17.602287Z  WARN no token or native ETH flow found for sender or entry point tx=0xf9c78b13f3d86c7d896d54fd6340b8e311f0974b4fa859c9f63a87e078372175 client=1inch
2026-06-18T03:13:17.602405Z  INFO decoded trades block=24978566 count=2 elapsed_ms=2880

2 aggregator trade(s) found:

  tx:         0x4e086bf50fe40561e11404fab0fd71dc79934ef9e71eadfe995950bc659912f8
  block:      24978566
  client:     1inch
  aggregator: 1inch
  sender:     0xf43c76170EAc81fC56c59D36f2f247e64930D6F9
  token_in:   0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84
  amount_in:  1000000000000000000
  token_out:  0x0000000000000000000000000000000000000000
  amount_out: 994866672008638709

  tx:         0x8b461c79220fe1b8b0bd469d160987c732442deb6c0d66143fe43a7b65f445d8
  block:      24978566
  client:     relay
  aggregator: tycho
  sender:     0xf70da97812CB96acDF810712Aa562db8dfA3dbEF
  token_in:   0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
  amount_in:  990416385871
  token_out:  0xdAC17F958D2ee523a2206206994597C13D831ec7
  amount_out: 989315162329

@github-actions

Copy link
Copy Markdown

No API Breaking Changes Detected

The PR title signals breaking changes, but cargo-semver-checks found none.
If the breaking change is behavioral, CLI, or config-level (not public Rust API), this is expected.
Otherwise, consider using fix: instead of feat: in the PR title.

@tamaralipows tamaralipows marked this pull request as draft June 18, 2026 03:28
@tamaralipows tamaralipows force-pushed the tnl/decode-swaps branch 4 times, most recently from 6b31171 to 709394f Compare June 25, 2026 22:57
tamaralipows and others added 2 commits June 25, 2026 19:19
Decode settled aggregator swaps for a block and report what each trade
put in and took out, with client and aggregator attribution.

- Fetch receipts per block with eth_getBlockReceipts and trace matched
  transactions concurrently (bounded), keeping each block within its
  block time
- Recover native ETH legs from the callTracer trace, since token->ETH
  and ETH->token swaps deliver ETH without emitting a log
- Attribute client vs aggregator: direct swaps settle at the entry
  point; client-routed swaps (e.g. Relay) resolve the aggregator from
  the trace, falling back to the contract address when unknown

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a `hindsight verify` subcommand that decodes a block locally and diffs
each transaction against Allium's aggregator_trades table as ground truth
(allium.rs async Explorer client, verify.rs comparison by token, amount in
bps, and aggregator). Split the CLI into `decode` and `verify` subcommands.

Extend the decoder to catch filler-initiated intent fills (UniswapX, 1inch
limit orders) by matching a known aggregator log signature and resolving the
order maker by net flow. Add 1inch v5, the UniswapX reactor, and the Tycho
router addresses.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant