MadiValidators count
Updated 2023-03-14Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
›
⌄
WITH deposit_and_stake_events as (select tx_hash from near.core.fact_actions_events_function_call
where method_name in ('deposit_and_stake')),
df as (
SELECT
date_trunc('day', block_timestamp) as date,
tx_receiver as validator,
regexp_substr(tx:receipt[0]:outcome:logs, 'Contract total staked balance is\\W+\\w+') as stake_balance,
try_to_numeric(trim(REGEXP_REPLACE(stake_balance, '[a-z/-/A-z/./#/*"]', ''))) as amount
FROM near.core.fact_transactions join deposit_and_stake_events on deposit_and_stake_events.tx_hash=near.core.fact_transactions.tx_hash)
select count (DISTINCT validator), round(sum (stake),2),
min(stake) as min_pool,
avg(stake) as AVG_pool,
max(stake) as max_pool,
median(stake) as median_pool
from (
SELECT
replace(validator, '.near') as validator,
avg(amount)/pow(10,24) as Stake
FROM df
WHERE date >= CURRENT_DATE - {{Period}} and amount is not null
group by 1
order by 2 desc )
Run a query to Download Data