Updated 2025-03-16
    with

    pricet as (
    select
    hour::date as date,
    avg(price) as token_price_usd
    from
    avalanche.price.ez_prices_hourly
    where
    token_address = '0x6e84a6216ea6dacc71ee8e6b0a5b7322eebc0fdd'
    group by 1
    ),

    txns as (
    select
    tx_hash,
    block_timestamp,
    origin_from_address as user,
    decoded_log:value / 1e18 as amount,
    iff(decoded_log:from = user, 'Stake', 'Unstake') as event_name,
    'Avalanche' as chain
    from
    avalanche.core.ez_decoded_event_logs
    where
    event_name = 'Transfer'
    and origin_to_address = '0x1a731b2299e22fbac282e7094eda41046343cb51'
    and tx_status = 'SUCCESS'
    and user in (decoded_log:from, decoded_log:to)
    and contract_address = '0x6e84a6216ea6dacc71ee8e6b0a5b7322eebc0fdd'
    and amount > 0

    union all

    select
    tx_hash,
    block_timestamp,