with price_list as (
select
date_trunc('day', timestamp) as date,
symbol,
avg(price_usd) as price
from near.core.fact_prices
group by 1, 2
)
select
date_trunc('day', b.date) "Date",
count(distinct(tx_hash)) "Transactions Count",
count(distinct (trader)) "Traders Count",
sum (price * amount_in) "Volume IN (USD)",
sum ("Transactions Count") over (order by "Date") "Comulative Transactions Count",
sum ("Traders Count") over (order by "Date") "Comulative Traders Count",
sum ("Volume IN (USD)") over (order by "Date") "Comulative Volume IN (USD)"
from near.core.ez_dex_swaps a
join price_list b
on a.block_timestamp::date = b.date
where token_in = symbol
group by 1
order by 1, 2 desc