Query editor
-- TREE monthly transfers from 0x0bE4...3c87 treasury + balance-- Token: TREE 0x77146784315Ba81904d654466968e3a7c196d1f3 (18 decimals)-- Treasury: 0x0bE45e75797155078417d1a0c32c8B8926403c87-- Excluded recipient (broken out separately): 0x1d8F99CB035785D858cceDE70Aba970b335B2731WITH transfers AS (SELECTdate_trunc('month', evt_block_time) AS month,"from","to",CAST(value AS DOUBLE) / 1e18 AS amountFROM erc20_ethereum.evt_transferWHERE contract_address = 0x77146784315Ba81904d654466968e3a7c196d1f3AND ("from" = 0x0bE45e75797155078417d1a0c32c8B8926403c87OR "to" = 0x0bE45e75797155078417d1a0c32c8B8926403c87)),-- Outflows from the treasury, split by destinationoutflows AS (SELECTmonth,SUM(CASE WHEN "to" = 0x1d8F99CB035785D858cceDE70Aba970b335B2731 THEN amount ELSE 0 END) AS out_to_1d8f,SUM(CASE WHEN "to" <> 0x1d8F99CB035785D858cceDE70Aba970b335B2731 THEN amount ELSE 0 END) AS out_to_others,SUM(amount) AS total_outflowFROM transfersWHERE "from" = 0x0bE45e75797155078417d1a0c32c8B8926403c87AND "to" <> 0x0bE45e75797155078417d1a0c32c8B8926403c87 -- ignore self-transfersGROUP BY 1),-- Inflows into the treasury (needed for balance reconstruction)inflows AS (SELECTmonth,SUM(amount) AS total_inflowFROM transfersWHERE "to" = 0x0bE45e75797155078417d1a0c32c8B8926403c87AND "from" <> 0x0bE45e75797155078417d1a0c32c8B8926403c87GROUP BY 1),-- Union of months that had any activitymonths AS (SELECT month FROM outflowsUNIONSELECT month FROM inflows),combined AS (SELECTm.month,COALESCE(o.out_to_others, 0) AS monthly_out_to_other_wallets,COALESCE(o.out_to_1d8f, 0) AS monthly_out_to_1d8f,COALESCE(o.total_outflow, 0) AS monthly_total_outflow,COALESCE(i.total_inflow, 0) AS monthly_inflow,COALESCE(i.total_inflow, 0) - COALESCE(o.total_outflow, 0) AS monthly_net_flowFROM months mLEFT JOIN outflows o ON m.month = o.month