theericstoneDeposits to Pickle
Updated 2022-02-08
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 unstakes as (
select
date_trunc('hour',block_timestamp) as hour,
sum(amount) * -1 as farm_withdrawals
from ethereum.udm_events
where from_address = LOWER('0xAB8e74017a8Cc7c15FFcCd726603790d26d7DeCa') -- alcx/eth farm
and contract_address = LOWER('0xc3f279090a47e80990fe3a9c30d24cb117ef91a8') -- alcx/weth slp
and block_timestamp > '2021-04-26'
group by 1
),
pickles as (
select
date_trunc('hour',block_timestamp) as hour,
sum(amount) as pickle_deposits
from ethereum.udm_events
where to_address = LOWER('0x9eb0aAd5Bb943D3b2F7603Deb772faa35f60aDF9') -- alcx/eth pickle jar
and contract_address = LOWER('0xc3f279090a47e80990fe3a9c30d24cb117ef91a8') -- alcx/weth slp
and block_timestamp > '2021-04-26'
group by 1
),
slpprice AS (
SELECT
etb.balance_date as hour,
avg(tvlhist.tvl) / sum(etb.balance) AS price
FROM
ethereum.erc20_balances etb
JOIN (
SELECT tvld.balance_date, sum(tvl_usd) as tvl FROM (
SELECT detb.balance_date,
detb.contract_address,
detb.symbol,
sum(detb.balance) as tvl,
avg(cmcprices.price) as pricey,
tvl * pricey as tvl_usd