Updated 2024-09-03
    with

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

    main as (
    select
    tx_id,
    block_timestamp,
    iff(event_type = 'Stake', event_data:flowAmountIn, event_data:lockedFlowAmount)::float as amount,
    amount * price_usd as amount_usd,
    event_type as action,
    authorizers[0] as staker
    from
    flow.core.fact_events events
    join
    flow.core.fact_transactions using(tx_id)
    left join
    pricet on block_timestamp::date = date
    where
    event_contract = 'A.d6f80565193ad727.LiquidStaking'
    and event_type in ( 'Stake', 'Unstake')
    and tx_succeeded = 1

    )

    select
    count(distinct tx_id) as transactions,
    QueryRunArchived: QueryRun has been archived