MahrooUntitled Query
Updated 2022-11-08Copy 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
26
27
28
29
30
31
32
33
34
35
36
›
⌄
with DelegateTable as (
select date_trunc (week,block_timestamp) as date,
validator_address,
sum (amount/pow(10,decimal)) as delegate_amount
from osmosis.core.fact_staking
where action in ('delegate')
and tx_status = 'SUCCEEDED'
group by 1,2),
UndelegateTable as (
select date_trunc (week,block_timestamp) as date,
validator_address,
sum (amount/pow(10,decimal)) as undelegate_amount
from osmosis.core.fact_staking
where action in ('undelegate')
and tx_status = 'SUCCEEDED'
group by 1,2),
RedelegateTable as (
select date_trunc (week,block_timestamp) as date,
redelegate_source_validator_address,
sum (amount/pow(10,decimal)) as redelegate_amount
from osmosis.core.fact_staking
where action in ('redelegate')
and tx_status = 'SUCCEEDED'
group by 1,2),
topvalidators as (
select t1.validator_address,
sum ((delegate_amount + redelegate_amount) - undelegate_amount)::numeric as Net_Delegate_Amount
from DelegateTable t1 join UndelegateTable t2 on t1.validator_address = t2.validator_address
join RedelegateTable t3 on t1.validator_address = t3.redelegate_source_validator_address
group by 1
order by 2 DESC
limit 150),
Run a query to Download Data