Afonso_Diazgrouping users
    Updated 2025-02-28
    with

    pricet as (
    select
    hour::date as date,
    avg(price) as price_usd
    from near.price.ez_prices_hourly
    where token_address = 'wrap.near'
    group by 1
    ),

    main as (
    select
    tx_hash,
    block_timestamp,
    signer_id as user,
    'Stake' as action,
    deposit/1e24 as amount
    from near.core.fact_actions_events_function_call
    where receipt_succeeded = 1
    and method_name = 'deposit_and_stake'
    and receiver_id = 'meteor.poolv1.near'
    ),

    final as (
    select
    main.*,
    amount * price_usd as amount_usd,
    price_usd as token_price_usd,
    from main
    left join pricet on date = block_timestamp::date
    ),

    users as (
    select
    user,
    QueryRunArchived: QueryRun has been archived