near-toll-audit / pipeline/sql/09b_intents_flows_recent.sql · raw
-- Rolling 28 days of 09_intents_flows_weekly.sql, so the on-chain volume check stays current.-- 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_rawFROM `bigquery-public-data.crypto_near_mainnet_us.ft_events`WHERE block_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 28 DAY)  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, 4ORDER BY 1, 2, 3, 4