Query editor
-- Bitcoin Quantum Risk Tracker — unspent totals by script type (materialized weekly)-- 21Shares Research---- unspent = created - spent, per script type. bitcoin.inputs carries the type and value-- of the output it spends, so netting by type equals the UTXO-set total for that type.-- Coinbase inputs spend nothing and are excluded.-- Snapshot: block_date < CURRENT_DATE (00:00 UTC on the run date).WITH flows AS (SELECTCOALESCE(type, 'unknown') AS type,CAST(ROUND(value * 1e8) AS bigint) AS sats,1 AS n,IF(value >= 0.001, 1, 0) AS n_geFROM bitcoin.outputsWHERE block_date < CURRENT_DATEUNION ALLSELECTCOALESCE(type, 'unknown'),-CAST(ROUND(value * 1e8) AS bigint),-1,-IF(value >= 0.001, 1, 0)FROM bitcoin.inputsWHERE block_date < CURRENT_DATEAND NOT COALESCE(is_coinbase, false))SELECTtype,SUM(sats) AS unspent_sats,SUM(n) AS unspent_utxos,SUM(n_ge) AS unspent_utxos_ge_001FROM flowsGROUP BY type