Query editor
-- tETH MEY: day-by-day positive-day count-- MEY = APY of (convertToAssets output_0/shares), which is the tETH/wstETH ratio-- This is already wstETH-denominated — Lido yield cancels in the denominator,-- so this rate appreciates purely from MEY accrual.WITH calendar AS (SELECT dayFROM unnest(sequence(date '2024-09-25', current_date, interval '1' day)) AS t(day)),teth_daily AS (SELECTcall_block_date AS day,COUNT(*) AS n_calls,MAX_BY(CAST(output_0 AS DOUBLE) / NULLIF(CAST(shares AS DOUBLE), 0), call_block_time) AS rateFROM treehouse_asset_ethereum.teth_call_converttoassetsWHERE call_successAND shares > UINT256 '0'AND output_0 > UINT256 '0'AND call_block_date >= date '2024-09-25'GROUP BY 1),teth_merged AS (SELECT c.day, t.rate, t.n_calls,SUM(CASE WHEN t.rate IS NOT NULL THEN 1 ELSE 0 END) OVER (ORDER BY c.day) AS grpFROM calendar c LEFT JOIN teth_daily t ON c.day = t.day),teth_filled AS (SELECT day,MAX(rate) OVER (PARTITION BY grp) AS teth_rate,n_callsFROM teth_merged),rates AS (SELECTday,teth_rate,n_calls,LAG(teth_rate, 1) OVER (ORDER BY day) AS teth_rate_lagFROM teth_filled),mey_daily AS (SELECTday,n_calls,POWER(teth_rate / teth_rate_lag, 365.0) - 1 AS mey_apy,teth_rate / teth_rate_lag - 1 AS mey_dod -- raw day-over-day returnFROM ratesWHERE teth_rate_lag IS NOT NULLAND teth_rate_lag > 0AND day >= date '2024-10-01'AND day < current_date),monthly AS (SELECT 'monthly' AS period_type,date_format(date_trunc('month', day), '%Y-%m') AS period_label,