select date_trunc(month, mindate) as date,
project_name,
count (*),
sum (from_amount*usdprice/pow(10,from_decimal)) as Volume
from osmosis.core.fact_swaps t1 join (select tx_from,
min (block_timestamp) as mindate
from osmosis.core.fact_transactions
group by 1
) t2 on t1.trader = t2.tx_from and t1.block_timestamp = t2.mindate
join osmosis.core.dim_tokens on to_currency = address
join (select recorded_at::date as day,
address,
symbol,
avg (price) as USDPrice
from osmosis.core.dim_prices t1 join osmosis.core.dim_labels t2 on t1.symbol = t2.project_name
group by 1,2,3) t3 on t1.from_currency = t3.address and t1.block_timestamp::date = t3.day
where project_name not in ('IOV')
group by 1,2
order by 1