import Dec from 'decimal.js'; /** * Safety margin every Midnight position is held at. On Midnight the lltv is *both* the borrow cap and the * liquidation threshold (`liquidationLimitUsd === borrowLimitUsd` in the aggregate), so a position borrowed * to its full limit opens at a health ratio of exactly 1 — immediately liquidatable. This is what holds it * off that line, and what absorbs swap price impact on a boost. */ export declare const MIDNIGHT_MIN_HEALTH_RATIO = 1.025; export interface MidnightBorrowHeadroomParams { borrowLimitUsd: Dec.Value; borrowedUsd: Dec.Value; /** Principal a unit of borrow power is worth (loan-per-unit price, ≤ 1), off a book rate. */ principalPerUnit?: Dec.Value; /** Depth the book can fill, in loan tokens, from the same quote. Omitted leaves the answer uncapped. */ availableAssets?: Dec.Value; loanTokenPrice?: Dec.Value; /** Loan token decimals. Omitted skips the quantisation, which only a caller ignoring `leftToBorrow` wants. */ loanTokenDecimals?: number; isMatured?: boolean; minHealthRatio?: Dec.Value; } export interface MidnightBorrowHeadroom { /** Face-value headroom, before the order-book discount. What a *boost* solve scales itself. */ headroomUsd: string; /** The borrowable amount in loan tokens — the Borrow action's Max, quantised exactly as it is typed in. */ leftToBorrow: string; /** `leftToBorrow · price`. Derived FROM the token amount, never computed alongside it — see below. */ leftToBorrowUsd: string; borrowPowerUsed: string; } /** * The one answer to "how much more can this position borrow". Every surface that sizes a Midnight borrow * derives from here — the max-borrow getter, the position overview's headroom rows, and the max-boost * solve, which scales `headroomUsd` by its own leverage factors — so a max and the figure shown next to it * cannot drift into two different formulas. They did: the overview used to price * the whole headroom off the top-of-book offer (often dust) with no rate pad and no depth cap, while the * max walked the book for its real size, which is what put the two 1–2% apart. * * Three corrections separate this from a plain `limit − debt`, and dropping any one overstates the answer: * `minHealthRatio` reserves the margin, `principalPerUnit` turns face-value headroom into the principal a * borrow actually receives (a correction that grows with the term, past 7% on a one-year market), and * `availableAssets` caps it at what the book can currently fill. * * `leftToBorrowUsd` is deliberately `leftToBorrow · price` rather than the USD figure the token amount was * derived from: the two differ by the round-down to token decimals, and a UI showing one next to an input * holding the other would be reporting a difference the user cannot spend. Everything quantises once, here. */ export declare const getMorphoMidnightBorrowHeadroom: ({ borrowLimitUsd, borrowedUsd, principalPerUnit, availableAssets, loanTokenPrice, loanTokenDecimals, isMatured, minHealthRatio, }: MidnightBorrowHeadroomParams) => MidnightBorrowHeadroom;