Afonso_DiazOvertime
    Updated 2024-10-13
    with

    pricet as (
    select
    hour::date as date,
    avg(price) as price_usd
    from aptos.price.ez_prices_hourly
    where symbol = 'APT'
    group by 1
    ),

    pricet2 as (
    select
    date_trunc('{{ period }}', hour) as dt,
    avg(price) as price_usd
    from aptos.price.ez_prices_hourly
    where symbol = 'APT'
    group by 1
    ),

    main as (
    select
    tx_hash,
    block_timestamp,
    sender as user,
    event_data:staked_APT/1e8 as amount_apt,
    amount_apt * price_usd as amount_usd
    from aptos.core.fact_events
    join aptos.core.fact_transactions
    using (tx_hash)
    left join pricet on block_timestamp::date = date
    where success = 1
    and payload_function = '0xfaf4e633ae9eb31366c9ca24214231760926576c7b625313b3688b5e900731f6::scripts::stake_APT_and_thAPT'
    and event_resource = 'StakeAPTEvent'
    and success = 1
    )
    QueryRunArchived: QueryRun has been archived