Query editor
-- sUSDe / PYUSD market on Morpho: how far the book was from liquidation on seven dates. Public Dune query: https://dune.com/queries/9186430-- Measured from events, in aggregate. No address is in the output.-- Per address: collateral = SupplyCollateral - WithdrawCollateral - seized in Liquidate. Debt = its borrow-- shares x market borrow assets / market borrow shares, where market borrow assets include AccrueInterest.-- Collateral value = sUSDe x contract rate x USDe / USD feed / PYUSD / USD feed, as the market's oracle does.-- The book is the one at the end of the day. The feeds are the worst of that day for a borrower (lowest USDe-- answer, highest PYUSD answer), or the latest earlier answer when a feed did not update that day.-- "Liquidatable after a fall of x" = debt of positions whose loan-to-value would reach 91.5% if the oracle-- price fell by x more. That part is a counterfactual on a measured book. 0.598% is the largest drawdown of-- the feed ratio since December 2025 (query 21).-- Limits: positions under 10,000 PYUSD of debt are left out. The sUSDe rate is read from the latest large-- unstake request within two days, so it can lag by up to two days of yield.WITH dates(d) AS (VALUES (DATE '2026-03-15'), (DATE '2026-04-15'), (DATE '2026-04-18'), (DATE '2026-04-21'),(DATE '2026-08-15'), (DATE '2026-10-30'), (DATE '2026-11-22')),-- signed events per address: sUSDe collateral, borrow shares, and market totals of borrow assets and sharesev AS (SELECT onBehalf AS addr, evt_block_time AS t, CAST(assets AS double) / 1e18 AS coll, 0e0 AS sh, 0e0 AS aFROM morpho_blue_ethereum.morphoblue_evt_supplycollateralWHERE evt_block_date >= DATE '2025-12-01' AND id = 0x90ef0c5a0dc7c4de4ad4585002d44e9d411d212d2f6258e94948beecf8b4c0d5UNION ALLSELECT onBehalf, evt_block_time, -CAST(assets AS double) / 1e18, 0e0, 0e0FROM morpho_blue_ethereum.morphoblue_evt_withdrawcollateralWHERE evt_block_date >= DATE '2025-12-01' AND id = 0x90ef0c5a0dc7c4de4ad4585002d44e9d411d212d2f6258e94948beecf8b4c0d5UNION ALLSELECT onBehalf, evt_block_time, 0e0, CAST(shares AS double), CAST(assets AS double) / 1e6FROM morpho_blue_ethereum.morphoblue_evt_borrowWHERE evt_block_date >= DATE '2025-12-01' AND id = 0x90ef0c5a0dc7c4de4ad4585002d44e9d411d212d2f6258e94948beecf8b4c0d5UNION ALLSELECT onBehalf, evt_block_time, 0e0, -CAST(shares AS double), -CAST(assets AS double) / 1e6FROM morpho_blue_ethereum.morphoblue_evt_repayWHERE evt_block_date >= DATE '2025-12-01' AND id = 0x90ef0c5a0dc7c4de4ad4585002d44e9d411d212d2f6258e94948beecf8b4c0d5UNION ALLSELECT borrower, evt_block_time, -CAST(seizedAssets AS double) / 1e18,-CAST(repaidShares AS double) - CAST(badDebtShares AS double), -CAST(repaidAssets AS double) / 1e6 - CAST(badDebtAssets AS double) / 1e6FROM morpho_blue_ethereum.morphoblue_evt_liquidateWHERE id = 0x90ef0c5a0dc7c4de4ad4585002d44e9d411d212d2f6258e94948beecf8b4c0d5UNION ALL-- interest raises the market's borrow assets, not the sharesSELECT 0x0000000000000000000000000000000000000000, evt_block_time, 0e0, 0e0, CAST(interest AS double) / 1e6FROM morpho_blue_ethereum.morphoblue_evt_accrueinterestWHERE evt_block_date >= DATE '2025-12-01' AND id = 0x90ef0c5a0dc7c4de4ad4585002d44e9d411d212d2f6258e94948beecf8b4c0d5),tot AS (SELECT dt.d, sum(ev.a) AS assets, sum(ev.sh) AS sharesFROM dates dt JOIN ev ON ev.t < CAST(dt.d AS timestamp) + INTERVAL '1' day GROUP BY 1),pos AS (SELECT dt.d, ev.addr, sum(ev.coll) AS coll, sum(ev.sh) AS shFROM dates dt JOIN ev ON ev.t < CAST(dt.d AS timestamp) + INTERVAL '1' dayWHERE ev.addr <> 0x0000000000000000000000000000000000000000GROUP BY 1, 2),-- sUSDe contract rate from the latest unstake request of the day or the two days before (assets per share)rate AS (SELECT dt.d, max_by(CAST(e.assets AS double) / CAST(e.shares AS double), e.evt_block_time) AS rateFROM dates dt JOIN ethena_labs_ethereum.stakedusdev2_evt_withdraw eON e.evt_block_date BETWEEN dt.d - INTERVAL '2' day AND dt.d AND CAST(e.shares AS double) > 1e21WHERE e.evt_block_date >= DATE '2026-03-01'GROUP BY 1),