Query editor
-- Define the zero address for Mint/Burn logic-- Using the standard EVM zero address-- NOTE: In Trino/DuneSQL, sometimes the hex string must be unquoted, or prefixed with 0x.-- We use the 0x prefix without quotes, which usually works for address comparison.WITH daily_net_supply_change AS (SELECTDATE_TRUNC('day', evt_block_date) AS day,-- 1. Calculate Daily Mint Amount (Tokens transferred FROM the zero address)SUM(CASEWHEN "from" = 0x0000000000000000000000000000000000000000THEN value / 1e6ELSE 0END) AS daily_mint_amount,-- 2. Calculate Daily Burn Amount (Tokens transferred TO the zero address)- SUM(CASEWHEN "to" = 0x0000000000000000000000000000000000000000THEN value / 1e6ELSE 0END) AS daily_burn_amountFROMerc20_plasma.evt_transferWHERE-- Filter for the specific stablecoin contractcontract_address = 0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebbAND (-- Only include Mint and Burn events"from" = 0x0000000000000000000000000000000000000000OR "to" = 0x0000000000000000000000000000000000000000)GROUP BY1)-- Calculate the Cumulative Supply (Running Total)SELECTdns.day,dns.daily_mint_amount,dns.daily_burn_amount,-- Daily Net Change (Mint - Burn)(dns.daily_mint_amount - (-dns.daily_burn_amount)) AS daily_net_change,-- Cumulative Supply (The stablecoin supply calculation)SUM(dns.daily_mint_amount - (-dns.daily_burn_amount)) OVER (ORDER BY dns.dayROWS UNBOUNDED PRECEDING -- Calculate sum from the start to the current day) AS cumulative_supplyFROMdaily_net_supply_change dns