Query editor
with portal_eth as (select date_trunc('day', block_time) as txn_date, sum(case when "to" = 0x25ab3efd52e6470681ce037cd546dc60726948d3 then cast("value" as double) / 1e18 else 0 end) as deposited_eth --- native deposited ETH and formatted vaules, sum(case when "from" = 0x25ab3efd52e6470681ce037cd546dc60726948d3 then cast("value" as double) / 1e18 else 0 end) * -1 as withdrawn_eth --- native withdrawm ETH and formatted vaulesfrom arbitrum.traceswhere ("to" = 0x25ab3efd52e6470681ce037cd546dc60726948d3or "from" = 0x25ab3efd52e6470681ce037cd546dc60726948d3)and block_time < current_date --- exclude the current dateand block_number >= 27054305 --- only include block from the given number and aboveand success = true --- only transactions that successedand (call_type not in ('delegatecall', 'callcode', 'staticcall') or call_type is null)group by 1), eth_mkt as (select date_trunc('day', "minute") as mkt_date, symbol, avg(price) as mkt_pricefrom prices.usdwhere blockchain is nulland symbol = 'ETH'group by 1, 2), cumulative_eth as (select e.txn_date, p.symbol, p.mkt_price, sum(e.net_eth) over (order by e.txn_date asc) as cumulative_eth, sum(e.net_eth) over (order by e.txn_date asc) * p.mkt_price as tvs_eth_usdfrom (select txn_date, (deposited_eth + withdrawn_eth) as net_ethfrom portal_eth) e --- daily average market price on native ETHjoin eth_mkt pon e.txn_date = p.mkt_date), portal_erc20 as (select date_trunc('day', evt_block_time) as txn_date, contract_address, sum(casewhen "to" = 0x25ab3efd52e6470681ce037cd546dc60726948d3 then cast("value" as double)else 0end) as deposited_erc20, sum(casewhen "from" = 0x25ab3efd52e6470681ce037cd546dc60726948d3 then cast("value" as double)else 0end) * -1 as withdrawn_erc20from erc20_arbitrum.evt_transferwhere ("to" = 0x25ab3efd52e6470681ce037cd546dc60726948d3or "from" = 0x25ab3efd52e6470681ce037cd546dc60726948d3)and evt_block_time < current_dateand contract_address in (0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f --- wbtc, 0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9 --- usdt, 0xaf88d065e77c8cc2239327c5edb3a432268e5831 --- usdc)and evt_block_number >= 27054305group by 1, 2), daily_net_erc20 as (