Query editor
with price as (selectdate_trunc('day',minute) as day,contract_address,blockchain,decimals,symbol,avg(price) as pricefrom prices.usdgroup by 1,2,3,4,5),ethereum_tvl as (select day, contract_address, sum(sum(coalesce(value,0))) over (partition by contract_address order by day) as value from (select date_trunc('day', evt_block_time) as day, contract_address, sum(cast(value as double)) as valuefrom erc20_ethereum.evt_Transferwhere cast(value as double)>0 andto in (select distinct pair as poolfrom uniswap_v2_ethereum.Factory_evt_PairCreatedunionselect distinct poolfrom uniswap_v3_ethereum.Factory_evt_PoolCreatedunionselect distinct exchange as poolfrom uniswap_ethereum.Factory_evt_NewExchange)and date(evt_block_time) not in (date('2022-07-13'), date('2022-11-07'), date('2022-11-06')) -- wrong pricing datagroup by 1,2UNION ALLselect date_trunc('day', evt_block_time) as day, contract_address, sum(cast(value as double)*-1) as valuefrom erc20_ethereum.evt_Transferwhere cast(value as double)>0 and"from" in (select distinct pair as poolfrom uniswap_v2_ethereum.Factory_evt_PairCreatedunionselect distinct poolfrom uniswap_v3_ethereum.Factory_evt_PoolCreatedunionselect distinct exchange as poolfrom uniswap_ethereum.Factory_evt_NewExchange)and date(evt_block_time) not in (date('2022-07-13'), date('2022-11-07'), date('2022-11-06')) -- wrong pricing datagroup by 1,2) agroup by 1,2),v1_eth as (select a.day, null as contract_address, sum(sum(coalesce(value,0) /1e18*price)) over (order by a.day) as value from (select date_trunc('day',block_time) as day, sum(cast(value as double)) as valuefrom ethereum.traceswhere to in (select distinct exchange as poolfrom uniswap_ethereum.Factory_evt_NewExchange)and date(block_time) not in (date('2022-07-13'), date('2022-11-07'), date('2022-11-06')) -- wrong pricing dataAND (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') or call_type is null)AND success = true