Query editor
WITH r AS (SELECT token, asset_class FROM query_9226938 WHERE blockchain = 'ethereum'),bluechip(token, is_stable) AS (VALUES(0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, false), (0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, true),(0xdac17f958d2ee523a2206206994597c13d831ec7, true), (0x6b175474e89094c44da98b954eedeac495271d0f, true),(0x2260fac5e5542a773aa44fbcfedf7c193bc2c599, false), (0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf, false),(0x4c9edd5852cd905f086c759e8383e09bff1e68b3, true), (0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0, false)),t AS (SELECT date_trunc('week', t.block_time) AS week,coalesce(rb.asset_class, rs.asset_class) AS asset_class,(bb.token IS NOT NULL OR bs.token IS NOT NULL) AND NOT coalesce(bb.is_stable AND bs.is_stable, false) AS in_denominator,t.amount_usdFROM dex.trades tLEFT JOIN r rb ON rb.token = t.token_bought_addressLEFT JOIN r rs ON rs.token = t.token_sold_addressLEFT JOIN bluechip bb ON bb.token = t.token_bought_addressLEFT JOIN bluechip bs ON bs.token = t.token_sold_addressWHERE t.blockchain = 'ethereum'AND t.block_month >= DATE '2025-01-01'AND t.block_time >= TIMESTAMP '2025-01-06'AND t.amount_usd < 1e8AND NOT (t.project = 'balancer' AND t.version = '1')),tot AS (SELECT week, sum(amount_usd) AS eth_dex_volume_usdFROM t WHERE in_denominator OR asset_class IS NOT NULLGROUP BY 1)SELECT t.week, t.asset_class,sum(t.amount_usd) AS volume_usd,count(*) AS trades,max(tot.eth_dex_volume_usd) AS eth_dex_volume_usd,sum(t.amount_usd) / max(tot.eth_dex_volume_usd) AS share_of_eth_dex_volumeFROM tJOIN tot ON tot.week = t.weekWHERE t.asset_class IS NOT NULLGROUP BY 1, 2ORDER BY 1, 2