Query editor
-- Rolling APY and MEY per tAsset, from the same rate series that drives TVL.-- MEY = tAsset APY - benchmark LST APY (the premium over just holding the LST).-- INTRINSIC ONLY: excludes token incentives (e.g. TREE via Merkl), so this reads-- lower than the app's headline APR wherever a campaign is running.WITH r AS (SELECT day, tasset,MAX(underlying_per_share) AS rate,MAX(benchmark_per_share) AS benchFROM dune.treehouseprotocol.result_treehouse_tasset_daily_navWHERE underlying_per_share IS NOT NULLAND benchmark_per_share IS NOT NULLAND counts_toward_protocol_totalGROUP BY 1, 2),lagged AS (SELECT day, tasset, rate, bench,LAG(rate, 30) OVER (PARTITION BY tasset ORDER BY day) AS r30,LAG(bench, 30) OVER (PARTITION BY tasset ORDER BY day) AS b30,LAG(rate, 7) OVER (PARTITION BY tasset ORDER BY day) AS r7,LAG(bench, 7) OVER (PARTITION BY tasset ORDER BY day) AS b7FROM r)SELECTday,tasset,(POWER(rate / NULLIF(r7, 0), 365.0 / 7) - 1) * 100 AS apy_7d_pct,(POWER(rate / NULLIF(r30, 0), 365.0 / 30) - 1) * 100 AS apy_30d_pct,(POWER(bench / NULLIF(b30, 0), 365.0 / 30) - 1) * 100 AS benchmark_apy_30d_pct,( (POWER(rate / NULLIF(r30, 0), 365.0 / 30) - 1)- (POWER(bench / NULLIF(b30, 0), 365.0 / 30) - 1) ) * 10000 AS mey_30d_bpsFROM laggedWHERE r30 IS NOT NULL AND b30 IS NOT NULLAND day >= DATE '2024-11-15'ORDER BY day, tasset