with price as (
select
date_trunc('day', recorded_hour) as date,
(avg(open) + avg(close)) / 2 as price
from crosschain.core.fact_hourly_prices
where id = 'terra-luna-2'
group by 1
),
tx as (
select
count(distinct tx_id) as "tx count"--,
-- count(distinct tx_from) as "Active users"
from terra.core.fact_transactions
where tx_succeeded = TRUE
),
fee as (
select
sum(fee * price) as "fee"
from terra.core.fact_transactions join price on date = block_timestamp::date
where
tx_succeeded = TRUE and fee_denom = 'uluna'
)
select *
from tx, fee