Query editor
with eth_tvl as (select a.day, sum(mint) as mint, sum(redemption) as redemption, sum(coalesce(mint,0)+coalesce(redemption,0)) as amountfrom (select date_trunc('day',block_time) as day, sum(cast(value as double)/1e18) as mintfrom base.traces bwhere (LOWER(call_type) NOT IN ('delegatecall', 'callcode', 'staticcall') or call_type is null)AND success = trueAND to = 0xcf205808ed36593aa40a44f10c7f7c2f67d4a4d4group by 1)aleft join (select date_trunc('day',block_time) as day, sum(cast(value as double)/1e18*-1) as redemptionfrom base.traceswhere (LOWER(call_type) NOT IN ('delegatecall', 'callcode', 'staticcall') or call_type is null)AND success = trueAND "from" = 0xcf205808ed36593aa40a44f10c7f7c2f67d4a4d4group by 1)bon a.day=b.daygroup by 1),idle_tvl as (select a.day,sum(mint) as new_deposit,sum(take_profit) as profit_taking,sum(redemption) as withdrawal,sum(minting) as re_invest,sum(coalesce(mint,0)+coalesce(redemption,0)+coalesce(take_profit,0)+coalesce(minting,0)) as idle_capitalfrom (select date_trunc('day',block_time) as day,sum(case when "from" <> 0xcf205808ed36593aa40a44f10c7f7c2f67d4a4d4 then cast(value as double)/1e18 else 0 end) as mint,sum(case when "from" = 0xcf205808ed36593aa40a44f10c7f7c2f67d4a4d4 then cast(value as double)/1e18 else 0 end) as take_profitfrom base.traces bwhere (LOWER(call_type) NOT IN ('delegatecall', 'callcode', 'staticcall') or call_type is null)AND success = trueAND to in (select distinct subject from friendtech_base.FriendtechSharesV1_evt_Trade)group by 1)aleft join (select date_trunc('day',block_time) as day,sum(case when "to" <> 0xcf205808ed36593aa40a44f10c7f7c2f67d4a4d4 then cast(value as double)/1e18*-1 else 0 end) as redemption,sum(case when "to" = 0xcf205808ed36593aa40a44f10c7f7c2f67d4a4d4 then cast(value as double)/1e18*-1 else 0 end) as mintingfrom base.traceswhere (LOWER(call_type) NOT IN ('delegatecall', 'callcode', 'staticcall') or call_type is null)AND success = trueAND "from" in (select distinct subject from friendtech_base.FriendtechSharesV1_evt_Trade)group by 1)bon a.day=b.daygroup by 1),treasury as (select day, sum(amount) as treasury from (select date_trunc('day',block_time) as day, sum(cast(value as double)/1e18) as amountfrom base.traces bwhere (LOWER(call_type) NOT IN ('delegatecall', 'callcode', 'staticcall') or call_type is null)AND success = trueAND to in (0xdd9176ea3e7559d6b68b537ef555d3e89403f742,0x831Be9e08185Eba7D88aAb1Efc059336baBef430)group by 1union allselect date_trunc('day',block_time) as day, sum(cast(value as double)/1e18*-1) as amountfrom base.traces bwhere (LOWER(call_type) NOT IN ('delegatecall', 'callcode', 'staticcall') or call_type is null)AND success = trueAND "from" in ( 0xdd9176ea3e7559d6b68b537ef555d3e89403f742,0x831Be9e08185Eba7D88aAb1Efc059336baBef430)group by 1)agroup by 1),