Query editor
WITH bronze AS (SELECT * FROM (WITH relevant_tokens AS (SELECT token_addressFROM dune.blockworks_research.ethereum_tokens__gold_erc20WHERE token_category IN ('blockchains', 'stablecoins', 'tokenized-assets', 'projects', 'liquid-staking', 'composites')), events AS (SELECT l.block_date, l.block_time, l.tx_hash, l.index AS evt_index, l.contract_address AS token_address, varbinary_substring(l.topic1, 13, 20) AS holder, IF(l.topic0 = 0x0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885, 'mint', 'burn') AS event_type, TRY_CAST(varbinary_to_uint256(varbinary_substring(l.data, 1, 32)) AS decimal(38, 0)) AS amount_rawFROM delta_prod.ethereum.logs lWHERE l.block_date <= DATE '2026-10-27'AND l.topic0 IN (0x0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885, 0xcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5)AND l.topic1 IS NOT NULL AND l.topic2 IS NULL AND bytearray_length(l.data) = 32AND l.contract_address IN (SELECT token_address FROM relevant_tokens)), zero_transfers AS (SELECT l.tx_hash, l.contract_address AS token_address, IF(l.topic1 = 0x0000000000000000000000000000000000000000000000000000000000000000, 'mint', 'burn') AS event_type, varbinary_substring(IF(l.topic1 = 0x0000000000000000000000000000000000000000000000000000000000000000, l.topic2, l.topic1), 13, 20) AS holder, TRY_CAST(varbinary_to_uint256(varbinary_substring(l.data, 1, 32)) AS decimal(38, 0)) AS amount_rawFROM delta_prod.ethereum.logs lWHERE l.block_date <= DATE '2026-10-27'AND l.topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efAND (l.topic1 = 0x0000000000000000000000000000000000000000000000000000000000000000 OR l.topic2 = 0x0000000000000000000000000000000000000000000000000000000000000000)AND bytearray_length(l.data) = 32AND l.contract_address IN (SELECT DISTINCT token_address FROM events))SELECT e.* FROM events eWHERE e.amount_raw IS NOT NULLAND NOT EXISTS (SELECT 1 FROM zero_transfers z WHERE z.tx_hash = e.tx_hash AND z.token_address = e.token_address AND z.event_type = e.event_type AND z.holder = e.holder AND z.amount_raw = e.amount_raw))), silver AS (WITH events AS (SELECT e.block_date, e.token_address, SUM(IF(e.event_type = 'mint', e.amount_raw, 0)) / POW(10, ARBITRARY(COALESCE(t.decimals, 18))) AS mint_amount, -SUM(IF(e.event_type = 'burn', e.amount_raw, 0)) / POW(10, ARBITRARY(COALESCE(t.decimals, 18))) AS burn_amount, COUNT_IF(e.event_type = 'mint') AS mint_cnt, COUNT_IF(e.event_type = 'burn') AS burn_cntFROM bronze e LEFT JOIN dune.blockworks_research.ethereum_tokens__gold_erc20 t ON t.token_address = e.token_addressGROUP BY 1, 2), tokens AS (SELECT token_address, MIN(block_date) AS first_event_date, SUM(mint_cnt) > 0 AS has_silent_mints FROM events GROUP BY 1), opening AS (SELECT t.token_address, MAX_BY(h.total_supply, h.block_date) AS opening_supplyFROM tokens t INNER JOIN dune.blockworks_research.ethereum_tokens__gold_holders h ON h.token_address = t.token_address AND h.block_date < t.first_event_dateWHERE NOT t.has_silent_mints GROUP BY 1), running AS (SELECT token_address, block_date, LEAD(block_date) OVER (PARTITION BY token_address ORDER BY block_date) AS next_date, SUM(COALESCE(mint_amount, 0) + COALESCE(burn_amount, 0)) OVER (PARTITION BY token_address ORDER BY block_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS net_to_dateFROM events), days AS (SELECT h.block_date, h.token_address FROM dune.blockworks_research.ethereum_tokens__gold_holders hINNER JOIN tokens t ON t.token_address = h.token_address AND (t.has_silent_mints OR h.block_date >= t.first_event_date))SELECT d.block_date, d.token_address, IF(t.has_silent_mints, 0, o.opening_supply) + r.net_to_date AS supply_total, e.mint_amount, e.burn_amountFROM days d INNER JOIN tokens t ON t.token_address = d.token_addressLEFT JOIN opening o ON o.token_address = d.token_addressINNER JOIN running r ON r.token_address = d.token_address AND r.block_date <= d.block_date AND (r.next_date IS NULL OR d.block_date < r.next_date)