carlesmontalanakamoto osmosis2
Updated 2022-11-03
999
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
›
⌄
--credits to adriaparcerisas
WITH
stakes1 as (
SELECT
block_timestamp,
tx_id,
REDELEGATE_SOURCE_VALIDATOR_ADDRESS as validator,
(amount / power(10,6))*(-1) as staked
FROM osmosis.core.fact_staking
where currency LIKE 'uosmo'
AND REDELEGATE_SOURCE_VALIDATOR_ADDRESS is not null
),
stakes2 as (
SELECT
block_timestamp,
tx_id,
validator_address as validator,
CASE WHEN action = 'undelegate' then (amount / power(10,6))*(-1)
else amount/power(10,6) end as staked
FROM osmosis.core.fact_staking
where currency LIKE 'uosmo'
AND REDELEGATE_SOURCE_VALIDATOR_ADDRESS is NULL
),
stakes3 as (
SELECT * FROM stakes1 UNION SELECT * FROM stakes2
),
monthly as (
SELECT
trunc(block_timestamp,'day') as days,
tx_id,
validator,
sum(staked) as osmo_staked
FROM stakes3 WHERE staked is not null group by 1,2,3
),
totals as (
Run a query to Download Data