elovianoonative stakes 2a
    Updated 2025-01-25
    with native_stakes as (


    select *
    from (
    select stake_account
    , case when validator_name like 'validator:%' then SPLIT_PART(validator_name, ':', -1) else validator_name end AS validator_name
    , vote_account
    , stake_active
    , post_tx_staked_balance
    , post_tx_staked_balance_usd
    -- , max_by(stake_active , (block_timestamp , index , inner_index)) , max_by(POST_TX_STAKED_BALANCE , block_timestamp)
    , row_number() over (partition by stake_account order by block_timestamp desc , index desc , inner_index desc) as recency
    from solana.marinade.ez_native_staking_actions
    ) s
    where s.recency = 1
    -- group by 1
    )
    /*
    -- QA
    select stake_Account , count(*)
    from native_stakes
    group by 1
    having count(*) > 1
    */
    -- select *
    -- from native_stakes
    -- where stake_active = 'false' and post_tx_staked_balance < 1
    -- where validator_name = '6m4ZwGp8zCuqjBoAn11pYAQun2FwSMe86RwPbqpf34YC'

    select
    case
    when stake_active = 'true' then 'active'
    when stake_active = 'false' or post_tx_staked_balance = 0 then 'inactive'
    when stake_active is null then 'activating'
    Last run: 3 months ago
    STAKE_STATUS
    STAKE_ACCOUNTS
    STAKED_SOL
    STAKES_USD
    1
    inactive196762187241.1132349922435567.68
    2
    activating28181.33966381943116.78
    3
    active4730673035235.75014689628305522.63
    3
    138B
    2s