select
platform,
count(distinct tx_hash) as tx_count,
count(distinct sender) as senders_count,
sum(amount_in_usd) as volume_usd,
avg(amount_in_usd) as avg_volume_usd,
median(amount_in_usd) as median_volume_usd,
sum(tx_fee) as total_fee,
avg(tx_fee) as avg_fee,
median(tx_fee) as median_fee,
sum(gas_used) as total_gas_usd,
avg(gas_used) as avg_gas_usd,
median(gas_used) as median_gas_usd
from ethereum.core.fact_transactions
join ethereum.core.ez_dex_swaps
using(tx_hash)
where 1 = 1
and block_timestamp >= '2022-01-01'
and event_name = 'Swap'
group by platform
order by tx_count desc