Query editor
/* ============================================================================Q5a · Growth-push attribution — daily protocol revenue before / after start----------------------------------------------------------------------------Parameters (shared with the dashboard):{{campaign_start}} date the push starts (no on-chain marker: the push isdate-based, so attribution is before/after only){{lookback_days}} how many days before the start to showRevenue = accrual-basis protocol revenue from the reconciliation query(Tsunami fees net of creator share + Calamari v4 protocol fee).`series` = protocol x period, so a bar chart grouped by it colours the push.========================================================================== */WITH daily AS (SELECT day, protocol,sum(computed_revenue_usd) AS revenue_usd,sum(computed_revenue_eth) AS revenue_ethFROM query_9105610WHERE protocol IN ('Tsunami', 'Calamari')GROUP BY 1, 2),labelled AS (SELECT d.*,CASE WHEN d.day >= date_trunc('day', TIMESTAMP '{{campaign_start}}') THEN 'after push start' ELSE 'before push' END AS periodFROM daily dWHERE d.day >= date_trunc('day', TIMESTAMP '{{campaign_start}}') - INTERVAL '{{lookback_days}}' DAY)SELECT day, protocol, period,protocol || ' · ' || period AS series,round(revenue_usd, 2) AS protocol_revenue_usd,round(revenue_eth, 6) AS protocol_revenue_eth,round(avg(revenue_usd) OVER (PARTITION BY protocol ORDER BY day ROWS BETWEEN 6 PRECEDING AND CURRENT ROW), 2) AS revenue_usd_7d_avg,round(avg(revenue_usd) OVER (PARTITION BY protocol, period), 2) AS period_avg_daily_revenue_usdFROM labelledORDER BY day DESC, protocol