Skip to content

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

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

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.

…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.
@github-actions github-actions Bot added WIP work in progress dbt: dex covers the DEX dbt subproject labels Jun 12, 2026
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 WIP work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant