John_Galt1 yLuna in Reg Staking by Address
Updated 2022-07-07
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
›
⌄
with table1 as (select -------------------------------looks like there might be a few innacuracies here. need to investigate further.
event_attributes:staker_addr::string as staking_address,
sum(event_attributes:"1_amount") / pow(10, 6) as in_regular_staking -- into regular staking
from terra.msg_events
where event_attributes:"1_contract_address" = 'terra1p7jp8vlt57cf8qwazjg58qngwvarmszsamzaru'
and event_attributes:"1_action" = 'bond'
and event_index = 3
group by 1
),
table2 as (select
event_attributes:staker_addr::string as unstaking_address,
sum(event_attributes:"0_amount") / pow(10, 6) as out_regular_staking --gone out of regular staking
from terra.msg_events
where event_attributes:"0_contract_address" = 'terra1p7jp8vlt57cf8qwazjg58qngwvarmszsamzaru'
and event_attributes:"0_action" = 'unbond'
and event_index = 3
group by 1
)
select table1.staking_address, table1.in_regular_staking, table2.out_regular_staking,
table1.in_regular_staking - COALESCE(table2.out_regular_staking, 0) as remaining_yluna
from table1
left outer join table2 on table1.staking_address = table2.unstaking_address
where remaining_yluna > 5 -----for the sake of the pie graph
order by remaining_yluna