Query editor
-- 1) Your uploaded listWITH tokens AS (SELECTaddress AS token_address, -- VARBINARYcoalesce(nullif(trim(symbol), ''), name) AS name,'bnb' AS chain -- change label if you prefer 'bsc'FROM dune.vlad_bnbchain.dataset_alpha_tokensWHERE address IS NOT NULL),-- 2) Last 35 days of BNB Chain DEX tradestrades AS (SELECTdate_trunc('day', block_time) AS dt,token_bought_address AS token_bought, -- VARBINARYtoken_sold_address AS token_sold, -- VARBINARYcoalesce(amount_usd, 0) AS amount_usd,tx_hash,tx_fromFROM dex.tradesWHERE blockchain = 'bnb' -- use 'bnb' if that's how Dune labels BSC in your envAND block_time >= now() - interval '35' day),-- 3) Match your tokens on either side of the swapmatches AS (SELECT dt, tok.name, tok.chain, t.amount_usd AS vol_usd, t.tx_hash, t.tx_fromFROM trades tJOIN tokens tok ON t.token_bought = tok.token_addressUNION ALLSELECT dt, tok.name, tok.chain, t.amount_usd AS vol_usd, t.tx_hash, t.tx_fromFROM trades tJOIN tokens tok ON t.token_sold = tok.token_address),-- 4) Daily per-token totals (for vol/txns)daily AS (SELECTdt,name,chain,SUM(vol_usd) AS total_vol,COUNT(DISTINCT tx_hash) AS txnsFROM matchesGROUP BY 1,2,3),-- 5) Per-token unique wallets over the windowstraders AS (SELECTname,chain,COUNT(DISTINCT CASE WHEN dt >= now() - interval '30' day THEN tx_from END) AS monthly_active_wallets,COUNT(DISTINCT CASE WHEN dt >= now() - interval '7' day THEN tx_from END) AS weekly_active_walletsFROM matchesGROUP BY 1,2),-- 6) Rollups for volume/txns (avoid the reserved word "rollup")agg AS (