Eman-Raz2024-08-02 01:54 AM
    Updated 2024-08-01
    with staked as (
    SELECT
    date_trunc('{{granularity}}', block_timestamp) as date,
    count(DISTINCT tx_id) as n_stake_action,
    sum(event_data:flowAmountIn) as flow_staked,
    sum(event_data:stFlowAmountOut) as stFlowAmountOut
    FROM flow.core.fact_events
    WHERE event_contract = 'A.d6f80565193ad727.LiquidStaking'
    AND event_type = 'Stake'
    AND TX_SUCCEEDED
    AND block_timestamp::date >= '2022-10-10'
    GROUP BY date
    )
    ,
    unstaked as (
    SELECT
    date_trunc('{{granularity}}', block_timestamp) as date,
    count(DISTINCT tx_id) as n_unstake_action,
    sum(event_data:lockedFlowAmount) as flow_unstaked,
    sum(event_data:stFlowAmountIn) as stFlowAmountIn
    FROM flow.core.fact_events
    WHERE event_contract = 'A.d6f80565193ad727.LiquidStaking'
    AND event_type = 'Unstake'
    AND TX_SUCCEEDED
    AND block_timestamp::date >= '2022-10-10'
    GROUP BY date
    )
    ,
    flow_price as (
    SELECT
    date_trunc('{{granularity}}',timestamp) as date,
    median(price_usd) as flow_price
    FROM flow.price.fact_prices
    WHERE symbol ilike 'flow'
    GROUP BY 1
    ORDER BY 1 DESC
    QueryRunArchived: QueryRun has been archived