with from_ as (
select block_timestamp::date as date ,
sum (swap_from_amount) as volume
from algorand.swaps
where swap_from_asset_id = 571576867
and swap_from_amount > 0
group by 1
),
to_ as (
select block_timestamp::date as date ,
sum (swap_from_amount) as volume
from algorand.swaps
where swap_to_asset_id = 571576867
and swap_from_amount > 0
group by 1
),
all_ as (
select 'swap_from' as type,
* from from_
UNION all
select 'swap_to' as type,
* from to_
)
select type , date ,
sum (volume ) as volume
from all_
group by 1,2