with withdraw as (
select
currency,
sum(amount/pow(10, decimal)) as amount
from osmosis.core.fact_liquidity_provider_actions
where action = 'pool_exited'
and block_id >= '4707300'
and block_id < '4713063'
group by currency
),
token as (
select
labels.project_name as name,
withdraw.amount as amount
from osmosis.core.dim_labels as labels
inner join withdraw on labels.address = withdraw.currency
),
price as (
select
token.name as token,
(token.amount * prices.price) as amount_usd
from osmosis.core.dim_prices as prices
inner join token on prices.symbol = token.name
where prices.recorded_at = '2022-06-10 04:56:00.000'
)
select *
from price