Eman-RazTotal Stats: Unstaking volume
    Updated 2024-08-02
    with tab1 as (select date_trunc('hour', block_timestamp) as date, sum(event_data:lockedFlowAmount) as volume
    from flow.core.fact_events
    where event_type='Unstake' and event_contract='A.d6f80565193ad727.LiquidStaking'
    and tx_succeeded='TRUE'
    group by 1),

    tab2 as (select hour, avg(price) as avg_price
    from flow.price.ez_prices_hourly
    where symbol='FLOW'
    group by 1)

    select -sum(volume) as "Volume ($FLOW)", -sum(volume*avg_price) as "Volume ($USD)"
    from tab1 left join tab2 on tab1.date=tab2.hour
    where date::date between '{{Start_Date}}' and '{{End_Date}}'

    QueryRunArchived: QueryRun has been archived