Query editor
-- Rolling frozen fee-recipient history. The matview keeps its 20260924 name so-- the daily graph, its pins and TY03 are unchanged; its boundary now rolls.-- Each refresh copies every row of the fee live fact, including its derived-- revenue split columns, strictly before the same boundary as the router-- history (59): LEAST(current UTC date - 3 days, start of the day the seven-- supported chains are indexed through). TY15/TY23 take tail rows only from-- the day after this history's last block_date. Only tycho-history-roll.yml-- refreshes this matview. roll_guard divides by zero, aborting the refresh and-- keeping the previous snapshot, unless the latest passing daily hot receipt-- (TYHOT) still describes the current router and fee lives exactly.WITHrouter_state AS (SELECTCOUNT(*) AS router_call_row_count,MAX(block_time) AS router_call_max_block_timeFROM dune.propeller_heads.result_tycho_router_call_fact_v3_live),fee_state AS (SELECTCOUNT(*) AS fee_recipient_row_count,MAX(block_time) AS fee_recipient_max_block_timeFROM dune.propeller_heads.result_tycho_fee_recipient_fact_v3_live),coverage AS (SELECTCAST(MAX(r.supported_chain_indexed_through) AS TIMESTAMP)AS indexed_throughFROM dune.propeller_heads.result_tycho_router_fee_daily_hot_v1_live rCROSS JOIN router_stateCROSS JOIN fee_stateWHERE r.receipt_status = 'pass'AND r.pipeline_revision = 'tycho_router_fee_daily_hot_v1'AND CURRENT_TIMESTAMP <= r.checkpoint_expires_atAND r.router_call_row_count = router_state.router_call_row_countAND r.router_call_max_block_timeIS NOT DISTINCT FROM router_state.router_call_max_block_timeAND r.fee_recipient_row_count = fee_state.fee_recipient_row_countAND r.fee_recipient_max_block_timeIS NOT DISTINCT FROM fee_state.fee_recipient_max_block_time),-- A refused roll still selects rows (the boundary falls back to the date-- limit), so roll_guard is evaluated and aborts the refresh.roll AS (SELECTLEAST(CAST(date_add('day', -3, CURRENT_DATE) AS TIMESTAMP),COALESCE(date_trunc('day', indexed_through),CAST(date_add('day', -3, CURRENT_DATE) AS TIMESTAMP))) AS boundary,CASE WHEN indexed_through IS NOT NULL THEN 1 ELSE 0 END AS admittedFROM coverage)SELECTl.*,1 / roll.admitted AS roll_guardFROM dune.propeller_heads.result_tycho_fee_recipient_fact_v3_live lCROSS JOIN roll