Query editor
WITH targets(chain,vault) AS (VALUES ('base',0xbeef0e0834849acc03f0089f01f4f1eeb06873c9),('robinhood',0xbeeff033f34c046626b8d0a041844c5d1a5409dd)),flows AS (SELECT 'base' AS chain,evt_tx_hash AS tx,sum(cast(value AS double))/1e6 AS incoming,cast(0 as double) AS explainedFROM erc20_base.evt_transfer WHERE evt_block_date>=date '2025-11-15' AND evt_block_date<date '2026-11-15' AND contract_address=0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 AND "to"=0xbeef0e0834849acc03f0089f01f4f1eeb06873c9 AND "from"!="to" GROUP BY 1,2UNION ALLSELECT 'robinhood',evt_tx_hash,sum(cast(value AS double))/1e6,cast(0 as double)FROM erc20_robinhood.evt_transfer WHERE evt_block_date>=date '2025-11-15' AND evt_block_date<date '2026-11-15' AND contract_address=0x5fc5360d0400a0fd4f2af552add042d716f1d168 AND "to"=0xbeeff033f34c046626b8d0a041844c5d1a5409dd AND "from"!="to" GROUP BY 1,2UNION ALLSELECT a.chain,a.evt_tx_hash,cast(0 as double),sum(cast(assets AS double))/1e6 FROM morpho_v2_multichain.vaultv2_evt_deposit a JOIN targets t ON a.chain=t.chain AND a.contract_address=t.vault WHERE evt_block_date>=date '2025-11-15' AND evt_block_date<date '2026-11-15' GROUP BY 1,2UNION ALLSELECT a.chain,a.evt_tx_hash,cast(0 as double),sum(cast(assets AS double))/1e6 FROM morpho_v2_multichain.vaultv2_evt_deallocate a JOIN targets t ON a.chain=t.chain AND a.contract_address=t.vault WHERE evt_block_date>=date '2025-11-15' AND evt_block_date<date '2026-11-15' GROUP BY 1,2), per_tx AS (SELECT chain,tx,sum(incoming) incoming,sum(explained) explained,sum(incoming)-sum(explained) residual FROM flows GROUP BY 1,2)SELECT chain,count(*) AS txs,sum(incoming) AS incoming,sum(explained) AS deposits_plus_deallocations,count_if(residual>0.00001) AS positive_residual_txs,sum(if(residual>0.00001,residual,0)) AS positive_residual_assets,count_if(residual< -0.00001) AS negative_residual_txs,sum(if(residual< -0.00001,residual,0)) AS negative_residual_assets,max(residual) AS largest_positive_residual FROM per_tx GROUP BY 1