freemartianvote power test
Updated 2022-11-22
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 delegations as (
select
date_trunc('hour', block_timestamp) as TIME,
delegator_address,
sum(amount)/pow(10,6) as delegation_amount
from osmosis.core.fact_staking
where action = 'delegate'
and TX_STATUS = 'SUCCEEDED'
group by TIME, delegator_address),
undelegations as (
select
date_trunc('hour', block_timestamp) as TIME,
delegator_address,
sum(amount)/pow(10,6) as undelegation_amount
from osmosis.core.fact_staking
where action = 'undelegate'
and TX_STATUS = 'SUCCEEDED'
group by TIME, delegator_address
)
select
d.TIME,
d.delegator_address as delegator,
delegation_amount,
case
when undelegation_amount is null then 0
when undelegation_amount is not null then undelegation_amount
end as undelegation_amount,
case when delegation_amount - undelegation_amount is null then delegation_amount
when delegation_amount - undelegation_amount is not null then delegation_amount - undelegation_amount
end as staked_amount
from delegations d left join undelegations u on d.delegator_address = u.delegator_address
-- final as (
-- select
-- max(block_timestamp),
Run a query to Download Data