Query editor
with raw_values as (selectdate,pool_name,casewhen symbol1 = 'USDC' then current_pricewhen symbol0 = 'USDC' then 1/nullif(current_price, 0)else 0end as derived_price,amount0,amount1,symbol0,symbol1from dune.alphagrowth.saga_yieldfi_oku_positions),calc as (selectdate,pool_name,(case when symbol0 != 'USDC' then amount0 * derived_price else amount0 end) +(case when symbol1 != 'USDC' then amount1 * derived_price else amount1 end) as usd_valuefrom raw_values)selectdate,pool_name,sum(usd_value) as tvl_usd,sum(sum(usd_value)) over (partition by date) as cumulative_tvlfrom calcgroup by 1, 2order by date desc, tvl_usd desc