Skip to content

fix(oneinch): resolve AR v6 trace-decoded token details via calldata fallback#9769

Open
bh2smith wants to merge 1 commit into
mainfrom
bh2smith/sim-6142-oneinch-ar-v6-token-details
Open

fix(oneinch): resolve AR v6 trace-decoded token details via calldata fallback#9769
bh2smith wants to merge 1 commit into
mainfrom
bh2smith/sim-6142-oneinch-ar-v6-token-details

Conversation

@bh2smith

Copy link
Copy Markdown
Member

Description:

Fix: 1inch AR v6 trace-decoded trades ship with empty-string symbols and NULL amounts (~10%/day)

Problem. dex_aggregator.trades rows for project = '1inch', version = 'AR v6' that come from the trace-decoding path (evt_index = -2) systematically ship with '' (empty-string) token symbols and NULL token amounts: 22,816 rows June 1–12 2026 (8–13% of AR v6 rows per day, 98% on bnb), carrying ~$4.6M/week of measured amount_usd on rows with no token detail. Because the symbols are '' rather than NULL, IS NULL-based quality checks report these rows as 0% incomplete.

Root cause. The AR executions macro resolves token metadata and amounts from the transfer graph around the router call. When the router is invoked internally (e.g. wallet-proxy → AR v6 0x111111125421ca6dc452d289314280a0f8842a65, selector 0x07ed2379) and/or the fill settles through PancakeSwap-Infinity / v4-style flash-accounting vaults, the transfer-matching filters find no rows, so src/dst amounts and symbols resolve to nothing — even though the swap's token addresses and amounts are present in the decoded call parameters. The trades model then coalesced unresolved symbols to ''.

Fix (two files, no restructuring):

  1. oneinch_ar_executions_macro.sql — add calldata-decoded amounts as the final fallback in the existing coalesce chains, and a LEFT JOIN to the tokens lookup on the calldata token address (native sentinels 0x0…0/0xeee…e mapped via blockchain.wrapped_native_token_address / native_token_symbol) so symbol/decimals resolve when transfer-based resolution is empty. Transfer-derived values still take precedence — event-decoded AR v4/v5 output is unchanged.
  2. oneinch_ar_trades.sql — stop coalescing unresolved symbols to ''; they now stay NULL so gaps are detectable, and token_pair correspondingly stays NULL (matching enrich_dex_aggregator_trades behavior).

Behavior change note for reviewers: previously-'' symbols become NULL. Anyone filtering token_sold_symbol != '' on 1inch rows sees a difference; this aligns 1inch with how every other dex_aggregator project represents unknown symbols.

Validation: bnb model compiled locally and rendered SQL inspected (fallback chains and tokens join render correctly); relying on CI for the full per-chain compile and tests. Post-merge check: re-run https://dune.com/queries/7709025 — the AR v6 daily blank rate should drop from ~10% to ~0, and the anchor tx's spell row should carry full token details.

@github-actions github-actions Bot added WIP work in progress dbt: dex covers the DEX dbt subproject labels Jun 12, 2026
…fallback

Trace-decoded AR rows (evt_index = -2) shipped with '' token symbols and
NULL amounts when the transfer-graph resolution found no matches - typical
for internally-called router swaps (wallet proxies) and PancakeSwap
Infinity / v4-style vault fills, ~10% of AR v6 rows/day, 98% on bnb.

- executions macro: fall back to the calldata-decoded token address,
  symbol, decimals (via tokens lookup, native sentinels mapped to the
  chain's wrapped native) and amounts when transfer-derived values are
  absent; transfer-derived values still take precedence.
- ar trades model: stop coalescing unresolved symbols to '' - they stay
  NULL so gaps are detectable and token_pair stays NULL, consistent with
  enrich_dex_aggregator_trades.
@bh2smith
bh2smith marked this pull request as ready for review July 23, 2026 07:38
@bh2smith bh2smith removed the WIP work in progress label Jul 23, 2026
@bh2smith
bh2smith force-pushed the bh2smith/sim-6142-oneinch-ar-v6-token-details branch from a54247c to 7cd9791 Compare July 23, 2026 07:57
@cursor

cursor Bot commented Jul 23, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes how 1inch AR trade token fields are populated downstream in dex aggregator data; transfer precedence is preserved but NULL vs empty-string semantics shift for consumers.

Overview
Fixes 1inch AR v6 trace-decoded trades (evt_index = -2) that showed empty symbols and NULL amounts when transfer matching failed (e.g. internal router calls from wallet proxies or v4-style vault settlements).

oneinch_ar_executions_macro.sql extends the existing coalesce chains so calldata-decoded token addresses, amounts, and ERC20 metadata are used only after transfer-based resolution. Native sentinels (0x0…0 / 0xeee…e) map to wrapped native + chain symbol via a new tokens lookup join.

oneinch_ar_trades.sql stops forcing unresolved symbols to ''; they stay NULL so quality checks and token_pair behave like other dex_aggregator enrich paths (NULL pair when symbols are unknown).

Reviewer note: rows that previously had '' symbols now have NULL—filters like token_sold_symbol != '' on 1inch AR rows will differ.

Reviewed by Cursor Bugbot for commit 7cd9791. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dbt: dex covers the DEX dbt subproject

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant