with mintable as (
select tx_from,
min (block_timestamp) as mindate
from osmosis.core.fact_transactions
group by 1),
pricet as (
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)
select date_trunc(week,mindate) as date,
project_name,
count (*) as Countt,
sum (to_amount*usdprice/pow(10,to_decimal)) as Volume
from osmosis.core.fact_swaps t1 join mintable t2 on t1.trader = t2.tx_from and t1.block_timestamp = t2.mindate
join osmosis.core.dim_tokens on to_currency = address
join pricet t3 on t1.to_currency = t3.address and t1.block_timestamp::date = t3.day
where project_name not in ('IOV')
group by 1,2
order by 1