synthquestDebtLock Release
Updated 2024-09-04
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 snxStaker as (
select row_number() over (partition by user_address order by block_number DESC) as acctIndex, * from ethereum.synthetix.ez_snx_staking
)
, snaxPrice as (
SELECT decoded_log:current *1e-8 AS snx_price
FROM ethereum.core.ez_decoded_event_logs
WHERE contract_address = '0x06ce8be8729b6ba18dd3416e3c223a5d4db5e755'
AND event_name = 'AnswerUpdated'
ORDER BY block_timestamp desc
limit 1
)
, sdsPrice as (
SELECT decoded_log:current *1e-27 AS sds_price
FROM ethereum.core.ez_decoded_event_logs
WHERE contract_address = '0xc7bb32a4951600fbac701589c73e219b26ca2dfc'
AND event_name = 'AnswerUpdated'
ORDER BY block_timestamp DESC
limit 1
)
, release_base as (
select
ss.snx_balance as current_SNX
, case when sds_balance = 0 or snx_balance + escrowed_snx_balance = 0 then 0 else SP.snx_price * 500 / ((snx_balance + escrowed_snx_balance) * SP.snx_price / (sds_balance * sds.sds_price) * 100) end as release_price
, case when sds_balance = 0 then 0 else (snx_balance + escrowed_snx_balance) * SP.snx_price / (sds_balance * sds.sds_price) * 100 end as current_cratio
, ss.user_address as address
, SP.snx_price as current_SNXprice
, sds.sds_price as current_SDSPrice
, ss.*
from snxStaker ss
, snaxPrice SP
, sdsPrice sds
QueryRunArchived: QueryRun has been archived