Commit 7409abb
* feat(dex): add 0x Settler RFQ fills to dex.trades (robust echo-ported decoder, 16 chains)
Promotes 0x Settler plain-RFQ (action selector 0xd92aadfb) maker fills into dex.trades
as a new PMM venue (project '0x API', version 'settler') across 16 chains. They were
previously absent from dex.trades (which only carried the legacy ExchangeProxy decodes).
Method, ported from Dune's echo indexer (zero_ex_settler.rs):
- Token identities (maker, makerAsset, takerToken) come from the signed RFQ action's
calldata static head; amounts come from the real ERC20 Transfer logs pivoted on the
maker, with an exactly-one-per-leg validity gate (drops ambiguous / native-ETH legs).
- Identity-grouped maker pivot so distinct fills sharing a byte offset across multiple
settler traces in one tx are not collapsed (the naive (tx_hash,p) grouping silently
dropped/aliased such fills via arbitrary()).
Files:
- new macro zeroex_settler_rfq + per-chain zeroex_settler_<chain>_base_trades (16 chains),
registered in dex_<chain>_base_trades; dex_info + ethereum seed test added.
- settler-txs staging extended to emit tx_from + rfq_input (RFQ-bearing rows only).
Verified on-chain (Ethereum + sampled chains): decoder reproduces real fills exactly;
0 overlap with the legacy native 0x venue (no double counting); AMM-routed settler
trades correctly excluded (their underlying pool venues already represent them).
mode excluded (no dex pipeline). dex_aggregator path unchanged in this PR.
CUR2-2843
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* perf(dex): bound dex_base_trades CI full-refresh to 7d to avoid OOM/timeout
CI slim-builds full-refresh dex_<chain>_base_trades (the duplicates_rank window over
a chain's entire history), exceeding the per-node memory limit on large chains
(bnb: 331GB TopN vs 348GB ceiling) and the CI job timeout. Bound the union to the
last 7 days in CI only (target=ci); prod (dunesql) is unchanged and keeps the
incremental_predicate. Verified no CI test depends on full-history dex_base_trades:
aggregate models carry no history-dependent tests (only dex_story's
check_dex_info_relationship, which passes on a subset), seed tests query venue models
(not the aggregate), and dex_<chain>_trades is out of CI scope.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(dex): dedup 0x Settler RFQ rows on (tx_hash, evt_index)
The 0xd92aadfb selector can recur inside an RFQ action's ABI body, so the
all-occurrences scan decodes the SAME action twice (identical maker/asset/token)
at two byte offsets, both matching the one maker-leg transfer -> duplicate
(tx_hash, evt_index). Keep one row per (tx_hash, maker_evt_index) via row_number;
genuine distinct fills always have distinct maker-leg logs, so only the spurious
re-decode is dropped (verified: the lone ethereum 14d collision was an
identical-tuple recurrence at offsets 1093/1125 of tx 0x49da06f1...). Uses a
subquery rather than QUALIFY (no precedent for QUALIFY in this codebase).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat(dex): deterministic 0x Settler aggregator volume — supersede PR #9795 (CUR2-2844)
Replaces the heuristic maker/taker leg-matching (and the PR #9795 5x-divergence band-aid)
for 0x Settler trades in dex_aggregator.trades with a deterministic decode. Per settler call,
emits one 0x-API aggregator row = the user's net swap:
- token_bought = AllowedSlippage.buyToken (from calldata, deterministic).
- amount = the unique Transfer(buyToken, to=receiver) when resolvable, else the minAmountOut
floor (verified tight, ~1% under actual). receiver = tx-level sender (execute) / msgSender
(executeMetaTxn) — verified to be the true buyToken recipient, NOT the calldata recipient
(an intermediate routing hop). Anchoring on a single calldata-named token to the verified
user means it cannot mis-bind to internal routing hops the way the heuristic did.
- token_sold = best-effort (unique Transfer out of the user, token != buyToken).
- volume_usd priced via either leg (add_amount_usd), so an unpriced buyToken still values off
the sell leg (cuts the unpriced-NULL bucket ~20% -> ~5%).
New macro zeroex_settler_agg; settler-txs staging extended with the AllowedSlippage fields
(buy_token, min_amount_out, settler_msgsender); all 17 settler chains' zeroex_v2_<chain>_trades
rewired to it.
Verified on-chain (example 0xf61374… : current $0.75 -> deterministic ~$490). NOTE: requires a
coordinated full-refresh of zeroex_v2_<chain>_trades + dex_aggregator_trades (merge cannot delete
the old mis-bound rows). Old-vs-new regression to be validated on CI-built tables before merge.
Stacked on CUR2-2843 (Phase 1). CUR2-2844
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: tomfutago <tomfutago@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 26df65a commit 7409abb
19 files changed
Lines changed: 301 additions & 783 deletions
File tree
- dbt_subprojects/dex
- macros/models/_project/zeroex
- models/_projects/zeroex
- arbitrum
- avalanche_c
- base
- berachain
- blast
- bnb
- ethereum
- ink
- linea
- mantle
- mode
- monad
- optimism
- polygon
- scroll
- unichain
- worldchain
Lines changed: 202 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
| |||
110 | 115 | | |
111 | 116 | | |
112 | 117 | | |
113 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
114 | 125 | | |
115 | 126 | | |
116 | 127 | | |
| |||
Lines changed: 5 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 5 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 5 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
0 commit comments