KuramaAtom Redelegations
Updated 2023-03-03
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
›
⌄
-- all delegation txs
with table_0 as (
select distinct tx_id from cosmos.core.fact_msg_attributes
where tx_succeeded = 'TRUE'
and msg_type = 'message'
and attribute_key = 'action'
and attribute_value = '/cosmos.staking.v1beta1.MsgBeginRedelegate'
),
-- all delegation txs + address
table_1 as (select distinct date_trunc('day',block_timestamp) as date, tx_id, attribute_value as address from cosmos.core.fact_msg_attributes
where tx_succeeded = 'TRUE'
and msg_type = 'transfer'
and attribute_key = 'sender'
and msg_index = '2'
and tx_id in (select * from table_0)),
-- all delegation txs + source validator
table_2_1 as (select distinct tx_id,msg_index, attribute_value as source_validator from cosmos.core.fact_msg_attributes
where tx_succeeded = 'TRUE'
and msg_type = 'redelegate'
and attribute_key = 'source_validator'
and tx_id in (select * from table_0)),
table_2_2 as (select distinct tx_id,msg_index, attribute_value as destination_validator from cosmos.core.fact_msg_attributes
where tx_succeeded = 'TRUE'
and msg_type = 'redelegate'
and attribute_key = 'destination_validator'
and tx_id in (select * from table_0)),
-- all delegation txs + amount
table_3 as (select distinct tx_id, msg_index,
case when attribute_value like '%ibc/%'
then left(right(attribute_value, charindex(',', reverse(attribute_value)) - 1), charindex('uatom', right(attribute_value, charindex(',', reverse(attribute_value)) - 1)) - 1)
else left(attribute_value, charindex('uatom', attribute_value) - 1) end as shares
from cosmos.core.fact_msg_attributes
Run a query to Download Data