Ali3NBenqi Users By #Stakes (Avalanche's Benqi vs Aptos's Amnis)
    Updated 2025-02-22
    with StakeTable as (
    select decoded_log:user as User,
    count (distinct tx_hash) as TX_Count
    from avalanche.core.ez_decoded_event_logs
    where contract_name = 'Staked AVAX'
    and event_name ilike 'Submitted'
    and tx_status ilike 'Success'
    group by 1),

    amnistable1 as (
    select sender,
    count (Distinct t1.tx_hash) as TX_Count
    from aptos.core.fact_events t1 join aptos.core.fact_transactions t2 on t1.tx_hash = t2.tx_hash
    where t1.event_resource = 'MintEvent' -- Stake
    and t1.event_module = 'stapt_token' -- LSAPT
    and t1.payload_function like '0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a%'-- LS
    group by 1)


    select 'Benqi' as platform,
    case when TX_Count = 1 then 'One-Time Staker'
    when TX_Count > 1 and TX_Count <= 5 then '2 - 5 Times'
    when TX_Count > 5 and TX_Count <= 10 then '6 - 10 Times'
    else '> 10 Times' end as type,
    count (Distinct user) as Users_Count
    from StakeTable
    group by 1,2

    /*union all


    select 'Amnis' as platform,
    case when TX_Count = 1 then 'One-Time Staker'
    when TX_Count > 1 and TX_Count <= 5 then '2 - 5 Times'
    when TX_Count > 5 and TX_Count <= 10 then '6 - 10 Times'
    else '> 10 Times' end as type,
    Auto-refreshes every 24 hours
    QueryRunArchived: QueryRun has been archived