with tab1 as (
select TRADER,TOKEN_OUT_CONTRACT as swap_for,sum(TOKEN_OUT_AMOUNT)as swap_for_amount
from flow.core.fact_swaps
where BLOCK_TIMESTAMP>=current_date-1
group by 1,2),
tab2 as (
select EVENT_CONTRACT,CONTRACT_NAME
from flow.core.dim_contract_labels)
select tab1.*,tab2.CONTRACT_NAME
from tab1
left join tab2
on tab1.swap_for=tab2.EVENT_CONTRACT