select
iff(block_timestamp::date >= '2022-11-08', 'FTX Crisis: After', 'FTX Crisis: Before') as timespan,
count(distinct (tx_id)) as txn_count,
count(distinct (instruction:accounts[1])) as users_count,
(txn_count / users_count) as avg_txn_per_user
from solana.core.dim_labels
join solana.core.fact_events on address = program_id
where (
label_type = 'dex' or label_type = 'defi'
)
and block_timestamp::date between date('2022-11-08') - interval '2 weeks' and date('2022-11-08')
and succeeded = 1
group by timespan
order by txn_count desc