import type { MidnightMarketConfig } from '@1delta/data-sdk';
/** One aggregated price level of a Midnight book side (raw bigints, loan-token units). */
export interface MidnightBookLevel {
    /** Midnight tick (price point). */
    tick: bigint;
    /** Total credit/debt units available at this level. */
    units: bigint;
    /** Total loan-token assets implied at this level. */
    assets: bigint;
}
/**
 * Top-of-book snapshot for a single Midnight market, already reduced to the
 * best executable rate per side plus the aggregate depth.
 *
 * Side semantics (Midnight): `bids` are maker BUY offers (makers lending) — a
 * taker consumes them to BORROW. `asks` are maker SELL offers (makers
 * borrowing) — a taker consumes them to LEND. So:
 *   - best BORROW rate  = min period-rate over bids (cheapest to borrow)
 *   - best SUPPLY yield  = max period-rate over asks (highest to lend)
 * Selection is order-agnostic (we scan every level), so it does not depend on
 * the API returning levels best-first.
 */
export interface MidnightBookTop {
    /** Tick of the best (lowest-rate) borrow offer, or undefined if the bid side is empty. */
    bestBorrowTick?: bigint;
    /** Tick of the best (highest-yield) supply offer, or undefined if the ask side is empty. */
    bestSupplyTick?: bigint;
    /** Aggregate borrowable units/assets (bid side). */
    borrowDepthUnits: bigint;
    borrowDepthAssets: bigint;
    /** Aggregate lendable units/assets (ask side). */
    supplyDepthUnits: bigint;
    supplyDepthAssets: bigint;
}
/**
 * Full order-book ladder for a market — every executable price level per side,
 * pre-sorted BEST-FIRST (unlike {@link MidnightBookTop}, which collapses to the
 * single best level + aggregate depth). Empty levels are dropped.
 */
export interface MidnightBook {
    /** Bid levels — maker BUYs / lends, a taker consumes them to BORROW. Best borrow first (tick ↓). */
    bids: MidnightBookLevel[];
    /** Ask levels — maker SELLs / borrows, a taker consumes them to LEND. Best supply first (tick ↑). */
    asks: MidnightBookLevel[];
}
/** Pluggable Midnight order-book source — hosted API today, self-indexed mempool later. */
export interface MidnightBookSource {
    /** Best-rate + depth snapshot for a market, or null when unavailable. */
    getBookTop(marketId: string): Promise<MidnightBookTop | null>;
    /**
     * Full best-first ladder for a market, or null when unavailable. Optional so
     * lightweight stubs need only implement `getBookTop`; the hosted API source
     * provides it for the live "all offers" endpoint.
     */
    getBook?(marketId: string): Promise<MidnightBook | null>;
    /**
     * ONE fetch: the full-depth aggregate {@link MidnightBookTop} PLUS a bounded
     * best-first ladder slice (top `maxLevels` per side). Same `/books/{id}` call
     * as `getBookTop`/`getBook` — the public batch uses this so it gets the top
     * AND a chunk of the book without a second request. Optional (stubs may omit).
     */
    getTopAndBook?(marketId: string, maxLevels?: number): Promise<{
        top: MidnightBookTop;
        book: MidnightBook;
    } | null>;
}
/** A Midnight market paired with its current top-of-book (null when the book fetch failed). */
export interface MidnightMarketRaw {
    config: MidnightMarketConfig;
    top: MidnightBookTop | null;
    /** Bounded best-first ladder slice (top-N levels/side); null/absent when unavailable. */
    book?: MidnightBook | null;
}
//# sourceMappingURL=types.d.ts.map