select
date_trunc('WEEK', BLOCK_TIMESTAMP) as week,
sum(abs(AMOUNT_IN_USD)) as Weekly_dex_volume,
count(distinct ORIGIN_FROM_ADDRESS) as Weekly_dex_users,
count(distinct TX_HASH) as Weekly_dex_txns
from
polygon.defi.ez_dex_swaps
where
BLOCK_TIMESTAMP is not null
group by
week
order by
1 desc