mmdrezaWeekly top5 Validator stakers
    Updated 2022-10-19
    with
    stake as (
    select tx_hash
    from near.core.fact_actions_events_function_call
    where method_name in ('deposit_and_stake','stake','stake_all')
    ),
    top_validator as (
    select
    tx_receiver as validator,
    count(distinct tx_signer) as stakers,
    sum(tx:actions[0]:FunctionCall:deposit/pow(10,24)) as near_staked
    from near.core.fact_transactions
    where tx_hash in (select * from stake)
    and block_timestamp >= current_date-90
    group by 1
    order by 2 desc
    limit 5)

    select
    date_trunc('week',block_timestamp) as date,
    tx_receiver as t_validator,
    count(distinct tx_signer) as stakers,
    sum(tx:actions[0]:FunctionCall:deposit/pow(10,24)) as near_staked
    from near.core.fact_transactions
    where tx_hash in (select * from stake)
    and tx_receiver in (select validator from top_validator)
    and block_timestamp >= current_date-90
    group by 1,2


    Run a query to Download Data