with temp as (
select
block_timestamp::date as date,
case
when rune_amount > 0 and asset_amount > 0 then 'rune-asset'
when rune_amount > 0 and asset_amount = 0 then 'rune'
when asset_amount > 0 and rune_amount = 0 then 'asset'
end as category,
sum(rune_amount_usd + asset_amount_usd) as usd_amount,
sum(1) as count,
avg(rune_amount_usd + asset_amount_usd) as average
from flipside_prod_db.thorchain.liquidity_actions
where lp_action='add_liquidity'
and (rune_amount > 0 or asset_amount > 0)
and block_timestamp::date >='2022-01-01'
group by 1,2
)
select
*,
sum(usd_amount) over (order by date) as cumulative_usd_amount,
sum(count) over (order by date) as cumulative_count
from temp