-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from mtitus6/main
Add ezeth
- Loading branch information
Showing
12 changed files
with
425 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* Dune query number - 3742207 */ | ||
/* Technically this should work but the results are too volatile to present with other LSTs */ | ||
with hours as ( | ||
select | ||
timestamp as hr, | ||
date_trunc('day', timestamp) as d | ||
from | ||
unnest( | ||
sequence( | ||
date_trunc('hour', cast(current_timestamp as timestamp) - interval '1' year), | ||
cast(current_timestamp as timestamp), | ||
interval '60' minute | ||
) | ||
) as tbl (timestamp) | ||
) | ||
, | ||
--only when the peg changes | ||
oracle_change as ( | ||
select | ||
t, | ||
d, | ||
block, | ||
token_peg_eth, | ||
token_contract_address, | ||
token_name, | ||
lag(token_peg_eth) over (order by t desc) as prev_peg | ||
from | ||
query_3742160 | ||
) | ||
, | ||
--one per hour | ||
oracle_hr as ( | ||
select | ||
t, | ||
d, | ||
block, | ||
token_peg_eth, | ||
token_contract_address, | ||
token_name, | ||
rank() over (partition by date_trunc('hour', t) order by t desc) as hr_rank | ||
from | ||
oracle_change | ||
where token_peg_eth != prev_peg | ||
) | ||
, | ||
pre_apy as ( | ||
select | ||
t, | ||
date_trunc('hour', t) as hr, | ||
d, | ||
lag(t) over (order by t) as prev_t, | ||
t - lag(t) over (order by t) as t_elapsed, | ||
block, | ||
lag(block) over (order by block) as prev_block, | ||
token_peg_eth, | ||
lag(token_peg_eth) over (order by t) as prev_token_peg_eth, | ||
100 * (token_peg_eth / lag(token_peg_eth) over (order by t) - 1) as peg_chg, | ||
token_contract_address, | ||
token_name, | ||
lead(date_trunc('hour', t)) over (order by date_trunc('hour', t)) as next_hr | ||
from | ||
oracle_hr | ||
where | ||
t >= cast(current_timestamp as timestamp) - interval '1' year | ||
and hr_rank = 1 | ||
) | ||
, | ||
|
||
apy as ( | ||
select | ||
hours.hr, | ||
hours.d, | ||
pre_apy.prev_t, | ||
pre_apy.block, | ||
pre_apy.prev_block, | ||
pre_apy.token_peg_eth, | ||
pre_apy.prev_token_peg_eth, | ||
pre_apy.peg_chg, | ||
day(pre_apy.t_elapsed) * 86400 + hour(pre_apy.t_elapsed) * 3600 | ||
+ minute(pre_apy.t_elapsed) * 60 + second(pre_apy.t_elapsed) as t_elapsed, | ||
31536000 / nullif(coalesce(( | ||
day(pre_apy.t_elapsed) * 86400 + hour(pre_apy.t_elapsed) * 3600 | ||
+ minute(pre_apy.t_elapsed) * 60 + second(pre_apy.t_elapsed) | ||
), 0 | ||
), 0) * pre_apy.peg_chg as apy, | ||
pre_apy.token_contract_address, | ||
pre_apy.token_name | ||
from hours | ||
left join pre_apy on | ||
hours.hr >= pre_apy.hr | ||
and hours.hr < pre_apy.next_hr | ||
) | ||
|
||
select | ||
hr, | ||
d, | ||
block, | ||
token_peg_eth, | ||
apy, | ||
avg(apy) over (order by hr asc rows between 24 preceding and current row) as apy_1d, | ||
avg(apy) over (order by hr asc rows between 168 preceding and current row) as apy_7d, | ||
avg(apy) over (order by hr asc rows between 720 preceding and current row) as apy_30d, | ||
avg(apy) over (order by hr asc rows between 2160 preceding and current row) as apy_90d, | ||
avg(apy) over (order by hr asc rows between 2880 preceding and current row) as apy_120d, | ||
date_trunc('hour', prev_t) as prev_hr, | ||
prev_block, | ||
prev_token_peg_eth, | ||
t_elapsed, | ||
peg_chg, | ||
token_contract_address, | ||
token_name | ||
from | ||
apy | ||
where token_peg_eth > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* Dune query number - 3738613 */ | ||
select | ||
date_trunc('day', evt_block_time) as d, | ||
0xbf5495efe5db9ce00f80364c8b423567e58d2110 as token_contract_address, | ||
'ezETH' as token_name, | ||
sum(ezethburned) as token_burn_amount | ||
from renzo_ethereum.restakemanager_evt_userwithdrawcompleted | ||
group by 1, 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* Dune query number - 3738564 */ | ||
select | ||
date_trunc('day', evt_block_time) as d, | ||
0xbf5495efe5db9ce00f80364c8b423567e58d2110 as token_contract_address, | ||
'ezETH' as token_name, | ||
sum(cast(ezethminted as double)) / 1e18 as token_mint_amount | ||
from | ||
renzo_ethereum.restakemanager_evt_deposit | ||
group by | ||
1, 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* Dune query number - 3742160 */ | ||
select | ||
max(cast(evt_block_number as bigint)) as block, | ||
date_trunc('hour', evt_block_time) as t, | ||
date_trunc('day', evt_block_time) as d, | ||
sum(ezethminted) / cast(sum(amount) as double) as token_peg_eth, | ||
0xbf5495efe5db9ce00f80364c8b423567e58d2110 as token_contract_address, | ||
'ezETH' as token_name | ||
from | ||
renzo_ethereum.restakemanager_evt_deposit | ||
group by | ||
2, 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* Dune query number - 3742163 */ | ||
with weth as ( | ||
select | ||
date_trunc('hour', minute) as hr, | ||
avg(price) as price | ||
from | ||
prices.usd | ||
where | ||
contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 | ||
and minute >= cast(current_timestamp - interval '1' year as timestamp) | ||
group by | ||
date_trunc('hour', minute) | ||
) | ||
, | ||
token as ( | ||
select | ||
date_trunc('hour', minute) as hr, | ||
contract_address, | ||
avg(price) as price | ||
from | ||
prices.usd | ||
where | ||
contract_address = 0xbf5495efe5db9ce00f80364c8b423567e58d2110 | ||
and minute >= cast(current_timestamp - interval '1' year as timestamp) | ||
group by | ||
date_trunc('hour', minute), | ||
contract_address | ||
) | ||
|
||
select | ||
token.hr, | ||
token.contract_address as token_contract_address, | ||
'ezETH' as token_name, | ||
token.price as token_price_usd, | ||
weth.price as weth_price_usd, | ||
token.price / weth.price as token_price_eth | ||
from | ||
token | ||
inner join weth on | ||
token.hr = weth.hr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* Dune query number - 3742173 */ | ||
with hours as ( | ||
select | ||
timestamp as hr, | ||
date_trunc('day', timestamp) as d | ||
from | ||
unnest( | ||
sequence( | ||
date_trunc('hour', cast(current_timestamp as timestamp) - interval '1' year), | ||
cast(current_timestamp as timestamp), | ||
interval '60' minute | ||
) | ||
) as tbl (timestamp) | ||
), | ||
|
||
peg as ( | ||
select | ||
hours.hr, | ||
peg.token_peg_eth | ||
from hours | ||
left join | ||
(select | ||
date_trunc('hour', t) as hr, | ||
token_peg_eth, | ||
lead(date_trunc('hour', t)) over (order by date_trunc('hour', t)) as next_hr | ||
from query_3742160) as peg on | ||
hours.hr >= peg.hr | ||
and hours.hr < peg.next_hr | ||
), | ||
|
||
prices as ( | ||
select | ||
hours.hr, | ||
prices.token_price_eth | ||
from hours | ||
left join | ||
(select | ||
hr, | ||
token_price_eth, | ||
lead(hr) over (order by hr) as next_hr | ||
from query_3742163) as prices on | ||
hours.hr >= prices.hr | ||
and hours.hr < prices.next_hr | ||
) | ||
|
||
select | ||
hours.hr, | ||
'ezETH' as token_name, | ||
prices.token_price_eth, | ||
avg(prices.token_price_eth) | ||
over (order by hours.hr rows between 5 preceding and current row) | ||
as token_price_eth_6hr_ma, | ||
peg.token_peg_eth, | ||
prices.token_price_eth / peg.token_peg_eth as token_price_peg_ratio, | ||
avg(prices.token_price_eth) over (order by hours.hr rows between 5 preceding and current row) | ||
/ peg.token_peg_eth as token_price_peg_ratio_6hr_ma, | ||
(prices.token_price_eth / peg.token_peg_eth) - 1 as token_peg_pct_divergence, | ||
avg(prices.token_price_eth) over (order by hours.hr rows between 5 preceding and current row) / peg.token_peg_eth | ||
- 1 as token_peg_pct_divergence_6hr_ma | ||
from hours | ||
left join peg on hours.hr = peg.hr | ||
left join prices on hours.hr = prices.hr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* Dune query number - 3738624 */ | ||
with days as (select tbl.d from unnest(sequence(date('2023-12-06'), current_date, interval '1' day)) as tbl (d) | ||
), | ||
|
||
totals as ( | ||
select | ||
days.d, | ||
cast(coalesce(sum(mint.token_mint_amount), 0) as double) as token_mint_amount, | ||
cast(coalesce(sum(burn.token_burn_amount), 0) as double) as token_burn_amount, | ||
cast(coalesce(sum(mint.token_mint_amount), 0) as double) | ||
- cast(coalesce(sum(burn.token_burn_amount), 0) as double) as token_supply_change_amount | ||
from days | ||
left join | ||
query_3738564 as mint | ||
on days.d = mint.d | ||
left join | ||
query_3738613 as burn | ||
on days.d = burn.d | ||
group by 1 | ||
) | ||
|
||
select | ||
d, | ||
token_mint_amount, | ||
token_burn_amount, | ||
token_supply_change_amount, | ||
sum(token_mint_amount) over (order by d asc) as token_total_mint, | ||
sum(token_burn_amount) over (order by d asc) as token_total_burn, | ||
sum(token_supply_change_amount) over (order by d asc) as token_total_supply, | ||
'ezETH' as token_name | ||
from totals | ||
order by 1 asc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* Dune query number - 3738627 */ | ||
with | ||
trades as ( | ||
select | ||
block_time as t, | ||
0xbf5495efe5db9ce00f80364c8b423567e58d2110 as token_contract_address, | ||
case | ||
when token_bought_address = 0xbf5495efe5db9ce00f80364c8b423567e58d2110 then token_bought_amount | ||
else token_sold_amount | ||
end as token_trade_amount, | ||
amount_usd as token_trade_amount_usd | ||
from | ||
dex.trades | ||
where | ||
blockchain = 'ethereum' | ||
and ( | ||
token_bought_address = 0xbf5495efe5db9ce00f80364c8b423567e58d2110 | ||
or token_sold_address = 0xbf5495efe5db9ce00f80364c8b423567e58d2110 | ||
) | ||
and block_time >= cast('2023-12-06' as timestamp) | ||
and amount_usd > 10 | ||
) | ||
|
||
select | ||
trades.t, | ||
date_trunc('day', trades.t) as d, | ||
trades.token_trade_amount, | ||
trades.token_trade_amount_usd, | ||
trades.token_trade_amount_usd / cast(prices.price as double) as token_trade_amount_eth, | ||
/* Trade size in USD divided by USD/ETH is amount of USD. */ | ||
'ezETH' as token_name, | ||
trades.token_contract_address | ||
from | ||
trades | ||
inner join | ||
prices.usd | ||
as prices | ||
on prices.minute = date_trunc('minute', trades.t) | ||
and prices.symbol = 'WETH' | ||
and not trades.token_trade_amount_usd is null /* We need to drop trades if the ETH amount will be unknown. */ | ||
and not prices.price is null | ||
and prices.price > 0 | ||
where | ||
prices.blockchain = 'ethereum' |
Oops, something went wrong.