Moestake all in one
Updated 2023-06-15
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
›
⌄
(with prices as (
select
date_trunc(day , RECORDED_AT) as days ,
CURRENCY as symbol ,
avg(PRICE) as price
from
osmosis.core.dim_prices
group by 1 , 2
)
select
date_trunc(week , BLOCK_TIMESTAMP) :: date as date ,
'Osmosis' as chain ,
count(distinct TX_ID) as actions ,
count(distinct DELEGATOR_ADDRESS) as stakers ,
sum(stakers) over (order by date) as cum_stakers ,
round(sum (AMOUNT/pow(10,decimal)),2) as staked_native,
round(sum (staked_native)over(order by date),2) as cum_staked_native,
sum(amount/pow(10,decimal)*price) as staked_usd,
round(sum (staked_usd)over(order by date),2) as cum_staked_usd,
avg(amount/pow(10,decimal)*price) as avg_staked_usd,
staked_usd/stakers as usd_per_user
from
osmosis.core.fact_staking , prices
where
BLOCK_TIMESTAMP::date = days and CURRENCY = symbol
and
action like 'delegate'
and BLOCK_TIMESTAMP >= current_date - interval '{{months_back}} months'
group by 1
)
union all
(
Run a query to Download Data