Query editor
WITH yield_agents AS (SELECTagent_address AS created_contractFROM query_5890197),contract_addresses AS (SELECTaddress AS contract_addressFROM base.creation_tracesWHERE address NOT IN (0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae,0xee7ae85f2fe2239e27d9c1e23fffe168d63b4055,0x5c9bdc801a600c006c388fc032dcb27355154cc9,0x1111111254eeb25477b68fb85ed929f73a960582,0xc38e4e6a15593f908255214653d3d947ca1c2338)),usdc_transfers AS (SELECT"from" AS from_address,"to" AS to_address,value / 1e6 AS amount,DATE_TRUNC('day', evt_block_time) AS date,evt_tx_hashFROM erc20_base.evt_TransferWHEREcontract_address = 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913),deposits AS (SELECTdate,SUM(amount) AS daily_depositsFROM usdc_transfers tJOIN yield_agents f ON t.to_address = f.created_contractLEFT JOIN contract_addresses kc ON t.from_address = kc.contract_addressWHERE kc.contract_address IS NULLGROUP BY date),withdrawals AS (SELECTdate,SUM(amount) AS daily_withdrawalsFROM usdc_transfers tJOIN yield_agents f ON t.from_address = f.created_contractLEFT JOIN contract_addresses kc ON t.to_address = kc.contract_addressWHERE kc.contract_address IS NULLGROUP BY date),daily_combined AS (SELECTCOALESCE(d.date, w.date) AS date,COALESCE(d.daily_deposits, 0) AS daily_deposits,COALESCE(w.daily_withdrawals, 0) AS daily_withdrawals,COALESCE(d.daily_deposits, 0) - COALESCE(w.daily_withdrawals, 0) AS daily_net_flowFROM deposits d