Flipside TeamAverage daily requests count by stakers participants
    Updated 2024-08-05
    -- forked from Average daily requests count by all participants @ https://flipsidecrypto.xyz/studio/queries/f9ee5ef5-1e09-4c67-87f3-f8c9c047134f

    --- staking part
    with tb1 as (select
    BLOCK_TIMESTAMP,
    tx_hash,
    MULTISIG_ADDRESS as multisig,
    OWNER_ADDRESS as owner,
    SERVICE_ID as serviceId,
    row_number() OVER (partition BY serviceId order by BLOCK_TIMESTAMP desc) as r_no
    from crosschain.olas.ez_service_staking
    where PROGRAM_NAME = 'Alpha'
    and EVENT_NAME = 'ServiceStaked'
    ),

    tb2 as (select
    *
    from tb1
    where r_no = 1),

    ---------------------------------------------------------------------------
    --- unstaking part
    tb3 as (select
    BLOCK_TIMESTAMP,
    tx_hash,
    MULTISIG_ADDRESS as multisig,
    OWNER_ADDRESS as owner,
    SERVICE_ID as serviceId,
    row_number() OVER (partition BY serviceId order by BLOCK_TIMESTAMP desc) as r_no
    from crosschain.olas.ez_service_staking
    where PROGRAM_NAME = 'Alpha'
    and EVENT_NAME = 'ServiceUnstaked'
    ),

    tb4 as (select
    *
    QueryRunArchived: QueryRun has been archived