select label,
date_trunc('day', block_timestamp) as days,
count(distinct tx_id) as trxs,
count(distinct instruction:accounts[0]) as users,
case when block_timestamp::date <'2022-10-12' then 'before hack'
else 'after hack'
end as period
from solana.core.fact_events inner join solana.core.dim_labels
on program_id = address
where SUCCEEDED='TRUE'
and label_type in( 'dex', 'defi')
and block_timestamp::date >='2022-10-08'
group by 1, 2, 5