KaskoazulTop 12 Validators
    Updated 2022-08-04
    WITH al AS (
    SELECT c.*, t.*
    FROM flipside_prod_db.mdao_near.actions_events_function_call c
    JOIN flipside_prod_db.mdao_near.transactions t
    ON c.txn_hash = t.txn_hash
    WHERE method_name IN ('deposit_and_stake', 'stake', 'stake_all', 'unstake', 'unstake_all', 'epoch_stake', 'epoch_unstake')
    ),

    ordered as (
    select tx_receiver as governor,
    sum (deposit/ pow(10,24)) as stake_NEAR,
    count (distinct tx_signer) as delegators,
    rank () over (order by stake_NEAR desc) as rank
    from al
    where method_name IN ('deposit_and_stake','stake', 'stake_all')
    group by 1
    order by 2 desc
    ),

    total_stake as (
    select sum (stake_NEAR) as total_stake
    from ordered
    )

    select rank,
    governor,
    stake_NEAR,
    sum (stake_NEAR) over (order by rank) / total_stake * 100 as perc_stake
    from ordered
    join total_stake
    order by rank
    limit 12


    Run a query to Download Data