Query editor
-- ===========================================-- Production_Supply_Query-- ===========================================WITH daily_dates AS (-- 1) Use query_4534898 to get a continuous daily range-- from 2022-11-07 up to the current date (truncated to day).SELECTCAST(time AS date) AS dayFROM query_4534898WHERE time >= DATE '2022-11-07'AND time <= CURRENT_DATE),-- 2) Aggregate daily minted amounts for the specified ERC-20 on Ethereumethereum_mints AS (SELECTDATE_TRUNC('day', evt_block_time) AS day,SUM(value / POWER(10, 6)) AS mintedFROM erc20_ethereum.evt_TransferWHERE contract_address = 0x6C3EA9036406852006290770BEDFCABA0E23A0E8-- Mint occurs when tokens come from the zero addressAND "from" = 0x0000000000000000000000000000000000000000GROUP BY 1),-- 3) Aggregate daily burned amounts (tokens sent to zero address)ethereum_burns AS (SELECTDATE_TRUNC('day', evt_block_time) AS day,SUM(value / POWER(10, 6)) AS burnedFROM erc20_ethereum.evt_TransferWHERE contract_address = 0x6C3EA9036406852006290770BEDFCABA0E23A0E8-- Burn occurs when tokens go to the zero addressAND "to" = 0x0000000000000000000000000000000000000000GROUP BY 1),-- 4) Combine daily mints and burns, filling missing days with 0ethereum_daily_changes AS (SELECTCOALESCE(m.day, b.day) AS day,COALESCE(m.minted, 0) AS minted,COALESCE(b.burned, 0) AS burnedFROM ethereum_mints mFULL OUTER JOIN ethereum_burns bON m.day = b.day),-- 5) Join to our daily date range, compute net issuance & running total supplyethereum_supply AS (SELECTdd.day,COALESCE(dc.minted, 0) AS daily_mints,COALESCE(dc.burned, 0) AS daily_burns,-- net new tokens = minted - burned( COALESCE(dc.minted, 0) - COALESCE(dc.burned, 0) ) AS net_mints,-- running total supply from 2022-11-07 onwardSUM(COALESCE(dc.minted, 0) - COALESCE(dc.burned, 0)) OVER (ORDER BY dd.day) AS cumulative_supply