with table_1 as (select date_trunc('hour', block_timestamp) as hour,
swapper as active_wallet,
count(distinct(tx_id)) as swap_count
from solana.core.fact_swaps
group by 1,2
having swap_count < 600)
select date_trunc('week', block_timestamp) as week,
'To CEX',
count(distinct(tx_id)) as tx_count
from solana.core.dim_labels a
join solana.core.fact_transfers b on a.address = b.tx_to
join table_1 c on b.tx_from = c.active_wallet
where label_type = 'cex'
group by 1
union
select date_trunc('week', block_timestamp) as week,
'From CEX',
count(distinct(tx_id)) as tx_count
from solana.core.dim_labels a
join solana.core.fact_transfers b on a.address = b.tx_from
join table_1 c on b.tx_to = c.active_wallet
where label_type = 'cex'
group by 1
order by 1