Query editor
-- USDT (Ethereum) blocklist activity by month, last 12 months-- Counts newly blocklisted addresses per month and sums their current frozen balanceWITH added AS (SELECT _user AS address, evt_block_time AS added_timeFROM tether_ethereum.tether_usd_evt_addedblacklist),removed AS (SELECT _user AS address, evt_block_time AS removed_timeFROM tether_ethereum.tether_usd_evt_removedblacklist),-- most recent add/remove event per address, so we know current statuslatest_added AS (SELECT address, MAX(added_time) AS last_added_timeFROM addedGROUP BY address),latest_removed AS (SELECT address, MAX(removed_time) AS last_removed_timeFROM removedGROUP BY address),-- addresses that are still blocklisted right now (no later removal)currently_blocklisted AS (SELECT la.address, la.last_added_timeFROM latest_added laLEFT JOIN latest_removed lr ON la.address = lr.addressWHERE lr.address IS NULL OR la.last_added_time > lr.last_removed_time),-- restrict to addresses blocklisted in the last 12 monthsin_window AS (SELECTaddress,date_trunc('month', last_added_time) AS freeze_monthFROM currently_blocklistedWHERE last_added_time >= date_trunc('month', now() - interval '12' month)),-- rebuild each address's balance from all USDT transfers (in minus out)inflows AS (SELECT "to" AS address, SUM(value) AS in_valueFROM tether_ethereum.tether_usd_evt_transferWHERE "to" IN (SELECT address FROM in_window)GROUP BY "to"),outflows AS (SELECT "from" AS address, SUM(value) AS out_valueFROM tether_ethereum.tether_usd_evt_transferWHERE "from" IN (SELECT address FROM in_window)GROUP BY "from"),balances AS (SELECTw.address,w.freeze_month,(COALESCE(i.in_value, 0) - COALESCE(o.out_value, 0)) / 1e6 AS balance_usdtFROM in_window wLEFT JOIN inflows i ON w.address = i.addressLEFT JOIN outflows o ON w.address = o.address)SELECT