cypherCurve steth/eth pool composition
Updated 2022-06-13Copy Reference Fork
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 data as (select
balance_date as date,
iff(symbol is null, 'stETH', symbol) as symbol,
non_adjusted_balance/1e18 as adj_balance,
adj_balance * price as adj_amount_usd
from flipside_prod_db.ethereum.erc20_balances
where balance_date >= current_date() - 90
and user_address = '0xdc24316b9ae028f1497c275eb9192a3ea0f67022'
and (contract_address = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84' or contract_address = 'ETH')),
total_balance as (
select
date,
symbol,
adj_balance,
adj_amount_usd,
sum(adj_balance) over (partition by date) as total_balance,
sum(adj_amount_usd) over (partition by date) as total_balance_usd,
(adj_balance/total_balance)*100 as balance_percentage,
(adj_amount_usd/total_balance_usd)*100 as balance_usd_percentage
from data
),
steth_price as (select
date_trunc('day', hour) as date,
avg(price) as steth_price
from ethereum.core.fact_hourly_token_prices
where hour >= current_date() - 90
and token_address = lower('0xae7ab96520de3a18e5e111b5eaab095312d7fe84')
group by date),
eth_price as (select
date_trunc('day', hour) as date,
avg(price) as eth_price
from ethereum.core.fact_hourly_token_prices
where hour >= current_date() - 90
Run a query to Download Data