Query editor
WITH sol_t AS (SELECT block_time, from_owner, to_owner, CAST(amount AS double)/1e6 AS usdcFROM tokens_solana.transfersWHERE token_mint_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'AND outer_executing_account = '5bCJcdWdKLJ7arrMVMFh3z99rQDxV785fnD9XGcr3xwc'AND from_owner IS NOT NULL AND to_owner IS NOT NULL),c AS (SELECT block_time, usdc,from_owner IN ('HqT251JKWz6gDb9DVeorJLwxLjytmwQqPGpdenDjMDMW','GAnhVQnVcPSp7zgaEsvPiY4peDpokmTqr2RXmTLSYtxx','6Sy8NzYc9NByCSnnDEcBtLc6Tw1zvahAhW4seaBobtv8') AS from_pool,to_owner IN ('HqT251JKWz6gDb9DVeorJLwxLjytmwQqPGpdenDjMDMW','GAnhVQnVcPSp7zgaEsvPiY4peDpokmTqr2RXmTLSYtxx','6Sy8NzYc9NByCSnnDEcBtLc6Tw1zvahAhW4seaBobtv8') AS to_pool,to_owner = 'BYgYr8UdLvnCWJEkKZSFuy1GpmQwWX6onKPzc6U1sjmx' AS to_treasury,from_owner = 'JB7rp9wMerZbP3yQLL8ZJx5kxRxvhkcfEzaAhuG5uThL' AS from_funderFROM sol_t),d AS (SELECT date_trunc('day', block_time) AS day,SUM(CASE WHEN (to_pool AND NOT from_pool AND NOT from_funder) OR (from_pool AND NOT to_pool AND NOT to_treasury) THEN usdc ELSE 0 END) AS settlement_usdc,COUNT(CASE WHEN to_pool AND NOT from_pool AND NOT from_funder THEN 1 END) AS callsFROM c GROUP BY 1)SELECT day, settlement_usdc, calls,SUM(settlement_usdc) OVER (ORDER BY day) AS cumulative_settlement_usdc,SUM(calls) OVER (ORDER BY day) AS cumulative_callsFROM d ORDER BY day