Query editor
with date_series as (selectdayfrom unnest(sequence((timestamp '2024-09-01 00:00:00'),(current_date),interval '1' day)) as t(day)),cl_pools as (select distinct *,row_number() over (partition by pool_symbol order by 1 = 1) as rnfrom (select distinctpool,token0,coalesce(concat(tokens0.symbol, '-', tokens1.symbol), concat(tokens0.symbol, ' Pool'), concat(tokens1.symbol, ' Pool')) as pool_symbol,tokens0.decimals as token_0_decimals,token1,tokens1.decimals as token_1_decimals,case when token0 in (select distinct pToken from rumpel_ethereum.pointtokenvault_evt_ptokendeployed) then token0 else token1 end as ptokenfrom uniswap_ethereum.pools t0left join tokens.erc20 tokens0on t0.token0 = tokens0.contract_addressand tokens0.blockchain = 'ethereum'left join tokens.erc20 tokens1on t0.token1 = tokens1.contract_addressand tokens1.blockchain = 'ethereum'where token0 in (select distinct pToken from rumpel_ethereum.pointtokenvault_evt_ptokendeployed)or token1 in (select distinct pToken from rumpel_ethereum.pointtokenvault_evt_ptokendeployed))),index as (select distinctd.day,cl.pool,case when cl.pool_symbol like '%-%' then cl.pool_symbol else concat(cl.pool_symbol, ' ', cast(rn as varchar)) end as pool_symbol,cl.token0,cl.token_0_decimals,cl.token1,cl.token_1_decimals,cl.ptoken,rnfrom date_series dcross join cl_pools clleft join (select distinctcontract_address,symbolfrom dune.rumpel_protocol.result_rumpel_protocol_index) pon 1 = 1),swaps as (selectindex.day,index.pool,index.pool_symbol,index.token0,index.token1,index.ptoken,sum(swaps.amount0) as token0_amount,sum(swaps.amount1) as token1_amount,sum(case when index.token0 in (select distinct pToken from rumpel_ethereum.pointtokenvault_evt_ptokendeployed) then swaps.amount1 else swaps.amount0 end) /sum(case when index.token0 in (select distinct pToken from rumpel_ethereum.pointtokenvault_evt_ptokendeployed) then swaps.amount0 else swaps.amount1 end) as quote_asset_price-- sum(sum(swaps.amount0)) over (partition by index.pool, index.token0 order by index.day) as token0_amount_cumulative,-- sum(sum(swaps.amount1)) over (partition by index.pool, index.token1 order by index.day) as token1_amount_cumulativefrom indexleft join (select