with buy as (
select
count(distinct tx_id) as buy_tx,
count(distinct trader) as buyer,
sum(TO_AMOUNT/pow(10,6)) as buy_volume
from terra.core.ez_swaps
where block_timestamp::date = '2023-01-09'
and TO_CURRENCY = 'uluna'
and TX_SUCCEEDED = 'TRUE'),
sell as (
select
count(distinct tx_id) as swap_tx,
count(distinct trader) as seller,
sum(from_AMOUNT/pow(10,6)) as sales_volume
from terra.core.ez_swaps
where block_timestamp::date = '2023-01-09'
and from_CURRENCY = 'uluna'
and TX_SUCCEEDED = 'TRUE'
)
select * , 'buy' as type from buy
union
select * , 'sell' as type from sell