Query editor
-- B20 payments volume by token type (Asset/Stablecoin), hourly + cumulative. Wallet-to-wallet proxy:-- exclude mint/burn/self and any transfer touching a centralized-exchange or bridge address (public onchain labels).-- USD is a LIQUIDITY-GATED DEX-VWAP: each token is priced by its own daily volume-weighted DEX price (struck off the-- paired side of real trades), applied only to tokens with >= $100k cumulative DEX volume. Illiquid tokens are left-- unpriced because a thin market price applied to large nominal transfer volume produces absurd USD. Counts always populate.WITH p AS (SELECT from_hex(substr('{{token_prefix}}', 3)) AS pfx),excluded AS (SELECT DISTINCT oa.address AS addrFROM labels.owner_addresses oaJOIN labels.owner_details od ON oa.owner_key = od.owner_keyWHERE oa.blockchain = 'base'AND od.primary_category IN ('Centralized Exchange', 'Bridge')AND oa.address IS NOT NULL),dex_leg AS ( -- one row per side of every priced B20 DEX tradeSELECT token_bought_address AS ca, block_date AS d, token_bought_amount AS amt, amount_usd AS usdFROM dex.tradesWHERE blockchain = 'base' AND block_date >= DATE '2026-06-24' AND amount_usd > 0 AND token_bought_amount > 0UNION ALLSELECT token_sold_address AS ca, block_date AS d, token_sold_amount AS amt, amount_usd AS usdFROM dex.tradesWHERE blockchain = 'base' AND block_date >= DATE '2026-06-24' AND amount_usd > 0 AND token_sold_amount > 0),legb AS (SELECT dl.* FROM dex_leg dl, pWHERE bytearray_substring(dl.ca, 1, bytearray_length(p.pfx)) = p.pfx),px AS ( -- per-token daily volume-weighted DEX price (USD per whole token)SELECT ca, d, sum(usd) / sum(amt) AS price_dayFROM legb GROUP BY ca, d),liq AS ( -- liquidity gate: token must clear >= $100k cumulative DEX volume to be pricedSELECT ca FROM legb GROUP BY ca HAVING sum(usd) >= 100000),x AS (SELECTdate_trunc('hour', tr.block_time) AS bucket,tr.block_date AS d,tr."from" AS f,tr."to" AS t,tr.contract_address AS ca,tr.amount AS tok_amt,CASE bytearray_substring(tr.contract_address, bytearray_length(p.pfx) + 1, 1)WHEN 0x00 THEN 'Asset' WHEN 0x01 THEN 'Stablecoin' ELSE 'Other' END AS token_typeFROM tokens.transfers tr, pWHERE tr.blockchain = 'base'AND tr.block_date >= DATE '2026-06-24'AND tr.contract_address <> 0x0000000000000000000000000000000000000000AND bytearray_substring(tr.contract_address, 1, bytearray_length(p.pfx)) = p.pfx),pay AS (SELECTx.bucket,x.token_type,CASE WHEN liq.ca IS NOT NULL THEN x.tok_amt * px.price_day END AS amount_usdFROM xLEFT JOIN liq ON liq.ca = x.caLEFT JOIN px ON px.ca = x.ca AND px.d = x.dWHERE x.f <> 0x0000000000000000000000000000000000000000AND x.t <> 0x0000000000000000000000000000000000000000