-- forked from Ario / Vertex - Weekly Perp Trading @ https://flipsidecrypto.xyz/Ario/q/nwpWoDMfgoQE/vertex---weekly-perp-trading
select
date_trunc(week, block_timestamp) as date,
split(TRADE_TYPE, '/')[1] as TYPE,
count(distinct TX_HASH) as "# Trades",
count(DISTINCT trader) as "# Traders",
sum(case when IS_TAKER = 'TRUE' then AMOUNT_USD end) as Perp_Volume
from arbitrum.vertex.ez_perp_trades
where block_timestamp > '2023-04-01'
group by 1,2