Afonso_DiazVolume Distribution Based on Number of Transactions (stake)
    Updated 2025-02-22
    with user_txn_counts as (
    select
    origin_from_address as user,
    count(*) as txn_count,
    sum(decoded_log:value::bigint / 1e18) as total_staked
    from
    kaia.core.ez_decoded_event_logs
    where
    contract_address = '0x999999999939ba65abb254339eec0b2a0dac80e9'
    and event_name = 'Transfer'
    and tx_succeeded
    and origin_from_address = decoded_log:to
    and origin_to_address = '0xf50782a24afcb26acb85d086cf892bfffb5731b5'
    and tx_hash in (
    select distinct tx_hash
    from kaia.core.ez_decoded_event_logs
    where event_name = 'StakeKlay'
    and decoded_log:from = '0x999999999939ba65abb254339eec0b2a0dac80e9'
    )
    group by user
    ),

    categorized_users as (
    select
    user,
    total_staked,
    txn_count,
    case
    when txn_count = 1 then 'One-time Stakers'
    when txn_count between 2 and 5 then 'Occasional Stakers'
    when txn_count between 6 and 15 then 'Frequent Stakers'
    else 'High Activity Stakers'
    end as category
    from user_txn_counts
    ),

    QueryRunArchived: QueryRun has been archived