Query editor
WITHparams AS (SELECT *FROM (VALUES-- ('Junior Collateralized Lending Pool', 0x1f88c069a1f6daad251dda3b921358274368b96b),('Junior Secure BG RE Pool 02', 0x82f5839362cd07cc9d9653d70f033bd2866882cc),-- ('Senior Collateralized Lending Pool', 0xa4725b4ba562205e7267635bbfc6677c59f4f22f),('Senior Secure BG RE Pool 01', 0x0d56f741c6d9b09c823e46b701505dcb93f518e4)-- ('Senior Agri Loan Pool', 0xf4dd3d7307472f5c0a7d94e7b4d120666363614c)) AS t(name, pool)),deposite_credit_pools as (SELECTevt_block_time as time,to as pool,"from" as depositor,sum(value)/1e6 as depositFROM erc20_arbitrum.evt_transferWHERE to IN (select pool from params)GROUP BY 1,2,3),widr_credit_pools as (SELECTevt_block_time as time,"from" as pool,"to" as depositor,sum(value)/1e6 as withdrawFROM erc20_arbitrum.evt_transferWHERE "from" IN (select pool from params)GROUP BY 1,2,3),add_all as (SELECTd.time,d.pool,d.depositor,d.deposit,COALESCE(w.withdraw,0) as withdraw,d.deposit - COALESCE(w.withdraw,0) as remainderFROM deposite_credit_pools dLEFT JOIN widr_credit_pools wON d.depositor = w.depositor),add_name as (SELECTp.name,d.*FROM add_all dLEFT JOIN params pON d.pool = p.pool)SELECTname,time,pool,depositor as address,'USDC' as symbol,deposit,