with price as (
select hour::date as datee,
avg(price) as usdprice
from avalanche.price.ez_hourly_token_prices
where symbol = 'WAVAX'
group by 1
)
select DISTINCT decoded_log:user as "User",
count(DISTINCT tx_hash) as "Stakes",
sum(decoded_log:avaxAmount/pow(10,18)) as "Staked $AVAX",
sum(decoded_log:avaxAmount/pow(10,18)*usdprice) as "Staked USD"
from avalanche.core.ez_decoded_event_logs
join price on block_timestamp::date=datee
where contract_name = 'Staked AVAX'
and event_name = 'Submitted'
and block_timestamp::date >= '2023-08-01'
and tx_status = 'SUCCESS'
group by 1
order by 4 DESC
limit 100