cypherstETH - HODL or Sell - n stakers above and below current price
Updated 2022-06-14
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
›
⌄
-- identify accounts that have staked their ETH by swapping to stETH.
-- Find the price of eth when they staked by looking at the time of the swap and getting corresponding eth price
-- Identify accounts that have sold a part or all of their steth by using the erc20_balance table.
with data as (select
date(date_trunc('day', block_timestamp)) as date,
tx_hash,
origin_from_address as address,
event_inputs:value/1e18 as amount_staked
from ethereum.core.fact_event_logs
where
event_inputs:from = lower('0x0000000000000000000000000000000000000000')
and contract_address = lower('0xae7ab96520de3a18e5e111b5eaab095312d7fe84')),
eth_price as (select
date_trunc('day', hour) as date,
avg(price) as eth_price
from ethereum.core.fact_hourly_token_prices
where token_address is null
group by date),
total_daily_staked as (select date, address, sum(amount_staked) as total_staked
from data
group by date, address),
joined as (
select * from total_daily_staked
left join eth_price using (date)
),
unique_addreseses as (
select count(distinct(address)) as n_unique_addresses
from joined
),
below_current as (
select count(distinct(address)) as n_address
from joined
Run a query to Download Data