Query editor
/*@title: Steakhouse HY USDC V2 — Basket Levels + Cross-chain & Credit Spreads (6m, cleaned)@description: HY basket levels, basket & cbBTC cross-chain spreads, and same-chain credit spreads (basket − cbBTC), 7d MA@author: Romana@notes: Extends query_8567821. Credit spread = HY basket APY minus cbBTC/USDC borrow rate on the SAME chain,i.e. the pickup of the curated high-yield book over the vanilla blue-chip collateral market — 7d MA.Exclusion windows (Resolv 2026-03-22..25, KelpDAO 2026-04-18..21) removed from ALL series before smoothing.@version: 1.0*/with holders (blockchain, holder, vault_label, valid_from, valid_to) as (values('base', 0xbeefa7b88064feef0cee02aaebbd95d30df3878f, 'base', date '2000-01-01', date '2026-04-13'), ('base', 0xfaaf20a032aefada97278c165345b6be1afc18c2, 'base', date '2026-04-14', date '2100-01-01'), ('ethereum', 0xbeefff209270748ddd194831b3fa287a5386f5bc, 'ethereum', date '2000-01-01', date '2026-04-22'), ('ethereum', 0xbfe734baab130048e20a64e800c4c2ec25756284, 'ethereum', date '2026-04-23', date '2100-01-01')), excluded_windows (excl_from, excl_to, reason) as (values(date '2026-03-22', date '2026-03-25', 'Resolv exploit'), (date '2026-04-18', date '2026-04-21', 'KelpDAO exploit'), (date '2026-04-01', date '2026-04-01', 'Drift exploit / whale deleveraging'), (date '2026-06-11', date '2026-06-13', 'Coinbase High Yield Edition launch')), cbbtc_markets (blockchain, market_id) as (values('base', 0x9103c3b4e834476c9a62ea009ba2c884ee42e94e6e314a26f04d312434191836), ('ethereum', 0x64d65c9a2d91c36d56fbc42d69e979335320169b3df63bf92789e2c8883fcc64)), markets as (selectblockchain, market_id, loan_decimalsfrom dune.steakhouse.result_morpho_markets), flows as (selectdate(evt_block_time) as dt, holder, blockchain, market_id, sum(shares) as shares_deltafrom (select s.evt_block_time, h.holder, s.chain as blockchain, s.id as market_id, s.shares as sharesfrom morpho_blue_multichain.morphoblue_evt_supply as sjoin holders as h on s.onBehalf = h.holder and s.chain = h.blockchainunion allselect w.evt_block_time, h.holder, w.chain as blockchain, w.id as market_id, -w.shares as sharesfrom morpho_blue_multichain.morphoblue_evt_withdraw as wjoin holders as h on w.onBehalf = h.holder and w.chain = h.blockchain) as fjoin markets using (market_id, blockchain)group by 1, 2, 3, 4), first_alloc as (select holder, blockchain, market_id, min(dt) as start_dtfrom flowsgroup by 1, 2, 3), calendar as (