Skip to content

Commit 2eb41eb

Browse files
authored
perf(seaport_v4): bound OrdersMatched scan to incremental window (#9781)
* perf(seaport_v4): bound OrdersMatched scan to incremental window * perf(seaport_v4): use standard incremental_predicate lookback Replace all hardcoded is_incremental() bounds (interval '7' day) with incremental_predicate() macro on all 4 sites: block_time in source_ethereum_transactions, and evt_block_time in both OrderFulfilled scans and the OrdersMatched scan. On hourly_spellbook the macro resolves to a 3-day window, shrinking the per-run lookback from 7d to 3d as requested by 0xRobin. OrderFulfilled and OrdersMatched are kept on the same window so joined pairs are never split across the boundary.
1 parent 85e2cac commit 2eb41eb

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

dbt_subprojects/hourly_spellbook/macros/_sector/nft/platforms/seaport_v4_trades.sql

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ with source_ethereum_transactions as (
2222
where block_time >= TIMESTAMP '{{start_date}}' -- seaport first txn
2323
{% endif %}
2424
{% if is_incremental() %}
25-
where block_time >= date_trunc('day', now() - interval '7' day)
25+
where {{ incremental_predicate('block_time') }}
2626
{% endif %}
2727
)
2828
,iv_orders_matched AS (
@@ -42,6 +42,12 @@ with source_ethereum_transactions as (
4242
where contract_address in ({% for order_contract in Seaport_order_contracts %}
4343
{{order_contract}}{%- if not loop.last -%},{%- endif -%}
4444
{% endfor %})
45+
{% if not is_incremental() %}
46+
and evt_block_time >= TIMESTAMP '{{start_date}}' -- seaport first txn
47+
{% endif %}
48+
{% if is_incremental() %}
49+
and {{ incremental_predicate('evt_block_time') }}
50+
{% endif %}
4551
) group by 1,2,3,4 -- deduplicate order hash re-use in advanced matching
4652
)
4753
,fee_wallet_list as (
@@ -113,7 +119,7 @@ with source_ethereum_transactions as (
113119
and evt_block_time >= TIMESTAMP '{{start_date}}' -- seaport first txn
114120
{% endif %}
115121
{% if is_incremental() %}
116-
and evt_block_time >= date_trunc('day', now() - interval '7' day)
122+
and {{ incremental_predicate('evt_block_time') }}
117123
{% endif %}
118124
)
119125
union all
@@ -181,7 +187,7 @@ with source_ethereum_transactions as (
181187
and evt_block_time >= TIMESTAMP '{{start_date}}' -- seaport first txn
182188
{% endif %}
183189
{% if is_incremental() %}
184-
and evt_block_time >= date_trunc('day', now() - interval '7' day)
190+
and {{ incremental_predicate('evt_block_time') }}
185191
{% endif %}
186192
)
187193
)

0 commit comments

Comments
 (0)