with maintable as (
select 'Optimism' as blockchain,
origin_from_address,
count (distinct tx_hash) as Swaps_Count,
sum (amount_in_usd) as Total_Swap_Volume
from optimism.sushi.ez_swaps
group by 1,2
union ALL
select 'Arbitrum' as blockchain,
origin_from_address,
count (distinct tx_hash) as Swaps_Count,
sum (amount_in_usd) as Total_Swap_Volume
from arbitrum.sushi.ez_swaps
group by 1,2
union ALL
select 'Polygon' as blockchain,
origin_from_address,
count (distinct tx_hash) as Swaps_Count,
sum (amount_in_usd) as Total_Swap_Volume
from polygon.sushi.ez_swaps
group by 1,2)
select blockchain,
avg (swaps_count) as Average_Swaps_Count,
avg (total_Swap_Volume) as Average_Swap_Volume
from maintable
group by 1