-- Token flows through intents.near and the revenue wallets, weekly per token. -- ft_mint into intents.near = deposit from another chain. ft_burn out of it = withdrawal to another chain. -- The token list (sql/intents_tokens.txt) uses the table's clustering, which cuts the scan about tenfold. SELECT DATE_TRUNC(block_date, WEEK(MONDAY)) AS wk, affected_account_id AS account, contract_account_id AS token, cause, COUNT(*) AS events, SUM(SAFE_CAST(delta_amount AS FLOAT64)) AS delta_raw, SUM(ABS(SAFE_CAST(delta_amount AS FLOAT64))) AS gross_raw FROM `bigquery-public-data.crypto_near_mainnet_us.ft_events` WHERE block_date >= '2025-07-01' AND contract_account_id IN ({{INTENTS_TOKENS}}) AND affected_account_id IN ('intents.near', 'buybacks.multisignature.near', 'fefundsadmin.sputnik-dao.near', '1csfundsadmin.sputnik-dao.near', '7066024d3f20f94de601c003163367873cca78507eeca4df66d9be645f197f05') GROUP BY 1, 2, 3, 4 ORDER BY 1, 2, 3, 4