Query editor
with data as ((selectdate_trunc('week', cast(deposit_dt as date)) as week,count(*)*32 as amount,0 as amount_exited,sum(points) as points,platform_type, staking_typefromdune.p2p_org.dataset_eigenlayer_data as depositsgroup bydate_trunc('week', cast(deposit_dt as date)),platform_type, staking_type)UNION(selectdate_trunc('week', CAST(exit_dt as Date)) as week,0 as amount,count(*) * 32 * -1 as amount_exited,0 as points,platform_type, staking_typefromdune.p2p_org.dataset_eigenlayer_data as exitswhereexits.exit_dt is not nullgroup bydate_trunc('week', CAST(exits.exit_dt as Date)),platform_type, staking_type)),agg_data as (selectweek,sum(amount) as amount,sum(amount_exited) as amount_exited,sum(points) as pointsfromdatagroup byweek)selectweek,amount,amount_exited,amount_exited * -1 as abs_amount_exited,amount + amount_exited as net_value,points,sum(amount + amount_exited) over (order byweek rows between unbounded precedingand current row) as cumsum,sum((amount + amount_exited) * (SELECT price FROM prices.usd WHERE symbol = 'WETH' ORDER BY minute DESC LIMIT 1) )over (order byweek rows between unbounded precedingand current row) as net_value_usd,sum(points) over (order byweek rows between unbounded precedingand current row