satsihNEAR Staking Distributions
    Updated 2022-11-25
    with
    near_staking_actions as (
    SELECT
    b.block_timestamp,
    b.method_name,
    b.deposit/pow(10,24) as deposit,
    a.tx_receiver as validator,
    a.tx_signer as stakers
    FROM
    near.core.fact_transactions a
    INNER JOIN
    (SELECT
    *
    FROM
    near.core.fact_actions_events_function_call
    WHERE method_name = 'deposit_and_stake') b
    ON a.tx_hash = b.tx_hash
    WHERE deposit > 0
    ),
    validators as (
    SELECT
    validator,
    sum(deposit) as deposit
    FROM
    near_staking_actions
    GROUP BY 1
    ORDER BY 2 DESC
    )

    SELECT
    CASE
    WHEN cume_dist_val <= 0.25 THEN '75%-100%'
    WHEN cume_dist_val > 0.25 AND cume_dist_val <= 0.5 THEN '50%-75%'
    WHEN cume_dist_val > 0.5 AND cume_dist_val <= 0.67 THEN '33%-50%'
    ELSE '0-33%'
    END AS Distribution,
    Run a query to Download Data