Query editor
-- Stabletide A1: current supply + trailing net mint/burn per token-chain-- current_supply = cumulative(mint - burn) = on-chain totalSupply() (includes issuer treasury)-- *_bn columns are the same values scaled to billions of tokens for counter widgets.WITH ev AS (SELECT 'USDT-Ethereum' AS token_chain, evt_block_date AS day, CAST(amount AS decimal(38,0)) AS amt FROM tether_ethereum.tether_usd_evt_issueUNION ALL SELECT 'USDT-Ethereum', evt_block_date, -CAST(amount AS decimal(38,0)) FROM tether_ethereum.tether_usd_evt_redeemUNION ALL SELECT 'USDT-Ethereum', evt_block_date, -CAST(_balance AS decimal(38,0)) FROM tether_ethereum.tether_usd_evt_destroyedblackfundsUNION ALL SELECT 'USDC-Ethereum', evt_block_date, CAST(amount AS decimal(38,0)) FROM circle_ethereum.usdc_evt_mintUNION ALL SELECT 'USDC-Ethereum', evt_block_date, -CAST(amount AS decimal(38,0)) FROM circle_ethereum.usdc_evt_burnUNION ALL SELECT 'USDT-Tron', evt_block_date, CAST(amount AS decimal(38,0)) FROM tether_tron.tether_usd_evt_issueUNION ALL SELECT 'USDT-Tron', evt_block_date, -CAST(amount AS decimal(38,0)) FROM tether_tron.tether_usd_evt_redeemUNION ALL SELECT 'USDT-Tron', evt_block_date, -CAST(_balance AS decimal(38,0)) FROM tether_tron.tether_usd_evt_destroyedblackfunds)SELECTtoken_chain,CAST(SUM(amt) / 1e6 AS double) AS current_supply,CAST(SUM(CASE WHEN day >= current_date - interval '7' day THEN amt ELSE 0 END) / 1e6 AS double) AS net_7d,CAST(SUM(CASE WHEN day >= current_date - interval '30' day THEN amt ELSE 0 END) / 1e6 AS double) AS net_30d,CAST(SUM(amt) / 1e15 AS double) AS current_supply_bn,CAST(SUM(CASE WHEN day >= current_date - interval '7' day THEN amt ELSE 0 END) / 1e15 AS double) AS net_7d_bn,MAX(day) AS as_of_dateFROM evGROUP BY token_chainORDER BY token_chain