-- forked from Alex_Dyan / DEX Monthly Metrics @ https://flipsidecrypto.xyz/Alex_Dyan/q/phxVMZKu8aVT/dex-monthly-metrics
select
date_trunc('MONTH', BLOCK_TIMESTAMP) as month,
sum(abs(AMOUNT_IN_USD)) as Monthly_dex_volume,
count(distinct ORIGIN_FROM_ADDRESS) as Monthly_dex_users,
count(distinct TX_HASH) as Monthly_dex_txns
from
polygon.defi.ez_dex_swaps
where
BLOCK_TIMESTAMP is not null
group by
month
order by
1 desc