with
tab1 as (
SELECT
date_trunc('day',block_timestamp) as time
,
'PERP' as type
,
symbol
,
sum(case when is_taker= 'true' then amount_usd end) as amount_vol
,
sum(amount_vol) over (order by time) as total_amount
,
count(distinct trader) as users
,
count(distinct digest) as orders
,
sum(orders) over (order by time) as total_orders
,
count(distinct EZ_PERP_TRADES_ID) as trades
,
sum(trades) over (order by time) as total_trades
from arbitrum.vertex.ez_perp_trades
group by 1,2,3
UNION
SELECT
date_trunc('day',block_timestamp) as time
,
'SPOT' as type
,
symbol
,
sum(case when is_taker= 'true' then amount_usd end) as amount_vol
,