Ali3NVote-Switching Behavior of Validator Vote-Changers on Proposals (Terra Recent 5)
Updated 2023-01-21
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 terravalidators as (
select REPLACE(ATTRIBUTE_VALUE, 'valoper', '') as validator_address1,
left(validator_address1, 38) as Account_address
from terra.core.fact_msg_attributes
where ATTRIBUTE_KEY= 'source_validator'
and tx_succeeded = 'TRUE'),
table1 as (
select voter,
block_timestamp,
tx_id,
vote_option_text,
proposal_id,
row_number () over (partition by voter order by block_timestamp asc) as rn
from terra.core.fact_governance_votes t1
where proposal_id in ('3796','3795','3794','3665','3619')
and tx_succeeded = 'TRUE'
and left(t1.voter, 38) in (select Account_address from terravalidators)),
table2 as (
select t1.voter,
t1.block_timestamp,
t1.tx_id,
t1.vote_option_text,
t1.proposal_id
from table1 t1 join table1 t2 on t1.voter = t2.voter and t1.vote_option_text != t2.vote_option_text and t2.rn > t1.rn and t1.proposal_id = t2.proposal_id and t1.block_timestamp < t2.block_timestamp
where t2.rn > 1
and left(t1.voter, 38) in (select Account_address from terravalidators))
select 'Proposal #' || t1.proposal_id as proposalid,
'From ' || t1.vote_option_text || ' To ' || t2.vote_option_text as vote_change,
count (distinct t1.voter) as Voters_Count
from table1 t1 join table2 t2 on t1.voter = t2.voter and t1.vote_option_text != t2.vote_option_text
where left(t1.voter, 38) in (select Account_address from terravalidators)
group by 1,2
order by 3 desc
Run a query to Download Data