Query editor
-- USDT blocklist activity by month, last 12 months, Ethereum + Tron-- Counts newly blocklisted addresses per month/chain and sums their current frozen balanceWITH added AS (SELECT chain, _user AS address, evt_block_time AS added_timeFROM tether_multichain.tether_usd_evt_addedblacklistWHERE chain IN ('ethereum', 'tron')),removed AS (SELECT chain, _user AS address, evt_block_time AS removed_timeFROM tether_multichain.tether_usd_evt_removedblacklistWHERE chain IN ('ethereum', 'tron')),-- most recent add/remove event per chain+address, so we know current statuslatest_added AS (SELECT chain, address, MAX(added_time) AS last_added_timeFROM addedGROUP BY chain, address),latest_removed AS (SELECT chain, address, MAX(removed_time) AS last_removed_timeFROM removedGROUP BY chain, address),-- addresses that are still blocklisted right now (no later removal)currently_blocklisted AS (SELECT la.chain, la.address, la.last_added_timeFROM latest_added laLEFT JOIN latest_removed lrON la.chain = lr.chain AND 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 (SELECTchain,address,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 on its own chain (in minus out)inflows AS (SELECT t.chain, t."to" AS address, SUM(t.value) AS in_valueFROM tether_multichain.tether_usd_evt_transfer tJOIN in_window w ON t.chain = w.chain AND t."to" = w.addressWHERE t.chain IN ('ethereum', 'tron')GROUP BY t.chain, t."to"),outflows AS (SELECT t.chain, t."from" AS address, SUM(t.value) AS out_valueFROM tether_multichain.tether_usd_evt_transfer tJOIN in_window w ON t.chain = w.chain AND t."from" = w.addressWHERE t.chain IN ('ethereum', 'tron')GROUP BY t.chain, t."from"),balances AS (SELECTw.chain,w.address,