datavortexvalidator and stakes
Updated 2024-12-04
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 delegate AS (
SELECT
tx_id,
ATTRIBUTE_VALUE as validator
FROM sei.core.fact_msg_attributes
WHERE ATTRIBUTE_KEY = 'validator' AND msg_type = 'delegate'
)
, delegate_amount AS (
SELECT
validator,
sum((split(ATTRIBUTE_VALUE, 'usei')[0])/1e6) as stake_amount
FROM sei.core.fact_msg_attributes a
INNER JOIN delegate b USING(tx_id)
WHERE msg_type = 'delegate' AND ATTRIBUTE_KEY = 'amount'
GROUP BY validator
)
-- You can add similar CTEs for redelegate, undelegate, etc.
, main AS (
SELECT
a.validator,
CASE a.validator
WHEN 'seivaloper1hnkkqnzwmyw652muh6wfea7xlfgplnyj0ku4w4' THEN 'Cosmostation'
WHEN 'seivaloper1zv9z2wqt348dhxqn38xv8dvsu78cle4xs2cdf4' THEN 'Enigma'
-- Add other mappings here...
ELSE a.validator
END AS "Validator Name",
-- Other aggregated columns (stake_amount, redelegate_amount, etc.)
FROM delegate_amount a
-- JOIN operations for other data (redelegate_amount, undelegate_amount, etc.)
GROUP BY a.validator
)
SELECT * FROM main;
*/
/*
WITH delegate AS (
QueryRunArchived: QueryRun has been archived