with transfer as
(
select date_trunc('day', block_timestamp) as date
, transfer_type
, amount / pow(10, coalesce(decimal, 0)) as amount_raw
, currency
from osmosis.core.fact_transfers
where tx_status = 'SUCCEEDED'
and block_timestamp::date > current_date - {{PastDays}}
), price as
(
select date_trunc('day', recorded_at) as date
, symbol
, avg(price) as price
from osmosis.core.dim_prices
where recorded_at::date > current_date - {{PastDays}}
group by 1, 2
)
select trn.date as "Date"
, sum(amount_raw * price) as "Total Amount ($)"
from transfer trn
join price prc on trn.date = prc.date
and trn.currency = prc.symbol
group by 1
order by 1