Query editor
-- B20 DEX trading volume by token type (Asset/Stablecoin), hourly + cumulative, from dex.trades on Base since 2026-06-24.WITH p AS (SELECT from_hex(substr('{{token_prefix}}', 3)) AS pfx),trades AS (SELECTdate_trunc('day', block_time) AS bucket,amount_usd,CASEWHEN bytearray_substring(token_bought_address, 1, bytearray_length(p.pfx)) = p.pfxTHEN CASE bytearray_substring(token_bought_address, bytearray_length(p.pfx) + 1, 1)WHEN 0x00 THEN 'Asset' WHEN 0x01 THEN 'Stablecoin' ELSE 'Other' ENDWHEN bytearray_substring(token_sold_address, 1, bytearray_length(p.pfx)) = p.pfxTHEN CASE bytearray_substring(token_sold_address, bytearray_length(p.pfx) + 1, 1)WHEN 0x00 THEN 'Asset' WHEN 0x01 THEN 'Stablecoin' ELSE 'Other' ENDEND AS token_typeFROM dex.trades, pWHERE blockchain = 'base'AND block_date >= DATE '2026-06-24'AND amount_usd IS NOT NULLAND (bytearray_substring(token_bought_address, 1, bytearray_length(p.pfx)) = p.pfxOR bytearray_substring(token_sold_address, 1, bytearray_length(p.pfx)) = p.pfx))SELECTbucket AS day,token_type,sum(amount_usd) AS dex_volume_usd,sum(sum(amount_usd)) OVER (PARTITION BY token_type ORDER BY bucket) AS cumulative_volume_usdFROM tradesGROUP BY 1, 2ORDER BY 1, 2