with cextable as (
select * from near.core.dim_address_labels
where label_type ilike 'cex'),
outflows as (
select distinct project_name,
tx_receiver as Outflow_User
from near.core.fact_transfers t1 join cextable t2 on t1.tx_signer = t2.address
where status ilike 'true')
select initcap(project_name) as CEX_Name,
count (Distinct tx_hash) as TX_Count,
sum (transaction_fee/1e24) as Paid_Fees,
count (distinct block_timestamp::date) as Active_Days,
TX_Count + Paid_Fees + Active_Days as Total_Activity_Score
from near.core.fact_transactions t1 join outflows t2 on t1.tx_signer = t2.outflow_user
where tx_status ilike 'success'
group by 1
order by 2 desc