Query editor
-- ============================================================================-- Query: icETH Yield-- Dune ID: 547552-- URL: https://dune.com/queries/547552-- Description: Calculates icETH yield metrics, APY, and parity value vs ETH/stETH-- Parameters: none---- Columns: Hour, Leverage Ratio, Aave APY, Lido stETH APY, 7d/30d/60d/90d APY,-- Net Yield vs ETH/stETH, Parity Value ETH/USD, Net Asset Value-- Depends on: query_2511613 (wstETH APR Updates), query_2620080 (Aave V2 wETH Hourly Borrow Rates),-- query_1581818 (icETH Composition Hourly), query_2621012 (Fee Structure)---- Optimizations applied (logic preserved):-- 1. ethereum.blocks -> utils.hours (for time series generation)-- 2. prices.usd -> prices.hour (LEGACY table)-- 3. cast('...' as timestamp) -> timestamp '...' (DuneSQL syntax)---- Note: Depends on queries that may need materialized views:-- query_2511613, query_2620080, query_1581818, query_2621012---- ============================================================================-- Define hours in the specified time rangewithhours as (select timestamp as hourfrom utils.hourswhere timestamp >= timestamp '2022-04-01 16:00')-- wstETH Hourly APR, lido_rates as (selecthour, pd_apr as aprfrom (selecth.hour, a.pd_apr, row_number() over (partition by h.hour order by a.pd_start desc) as rnfrom hours hleft join query_2511613 a -- wstETH APR Updateson a.pd_start <= h.hourand a.pd_apr is not null)where rn = 1)-- Calculate rates for each hour, rates as (selecta.hour, a.rate as eth_borrow_rate, l.apr as steth_yield, power((a.rate + 1), 0.00011415525) as aave_rate, 1 + (l.apr / 365 / 24) as lido_ratefrom query_2620080 as a -- Aave V2 wETH Average Hourly Borrow Ratesleft join lido_rates lon a.hour = l.hour