Query editor
WITH period_config AS (SELECT '30d' AS period, CURRENT_DATE - INTERVAL '30' DAY AS start_dateUNION ALLSELECT '90d' AS period, CURRENT_DATE - INTERVAL '90' DAY AS start_date),trades AS (SELECTp.period,t.block_date,t.tx_hash,t.tx_from AS address,t.amount_usdFROM period_config pJOIN dex.trades tON t.block_date >= p.start_dateWHERE t.blockchain = 'hyperevm'AND t.project = 'hyperswap'AND t.block_month >= CAST(date_trunc('month', CURRENT_DATE - INTERVAL '90' DAY) AS date)AND t.amount_usd > 0AND t.tx_from IS NOT NULL),daily AS (SELECTperiod,block_date,address,SUM(amount_usd) AS daily_volume_usd,COUNT(DISTINCT tx_hash) AS transactions,COUNT(*) AS swap_legsFROM tradesGROUP BY 1, 2, 3),market AS (SELECTperiod,COUNT(DISTINCT block_date) AS market_days,COUNT(DISTINCT CAST(date_trunc('week', block_date) AS date)) AS market_weeksFROM tradesGROUP BY 1),wallets AS (SELECTperiod,address,SUM(daily_volume_usd) AS total_volume_usd,SUM(transactions) AS transactions,SUM(swap_legs) AS swap_legs,COUNT(*) AS active_days,COUNT(DISTINCT CAST(date_trunc('week', block_date) AS date)) AS active_weeks,AVG(daily_volume_usd) AS avg_active_day_volume_usd,approx_percentile(daily_volume_usd, 0.5) AS median_active_day_volume_usdFROM dailyGROUP BY 1, 2),classified_wallets AS (SELECTw.period,w.address,w.total_volume_usd,w.transactions,