import type { TermMarketConfig } from '@1delta/data-sdk';
/**
 * Top-of-book snapshot for a single Term repo, already reduced to best
 * executable APR per side + aggregate depth. Unlike Midnight (tick math), the
 * Term subgraph is expected to return APRs directly (secondary-listing discount
 * rates and auction-clearing rates), so these are plain percents.
 *
 * Side semantics: SUPPLY = lend (buy repo tokens on the secondary book / submit
 * auction offers); BORROW = auction bids.
 */
export interface TermBookTop {
    /** Best lend APR in percent (secondary listings / auction offers), if any. */
    supplyAprPct?: number;
    /** Best borrow APR in percent (auction bids), if any. */
    borrowAprPct?: number;
    /** Lendable depth in loan-token units (human, already decimal-scaled). */
    supplyLiquidity: number;
    /** Borrowable depth in loan-token units (human, already decimal-scaled). */
    borrowLiquidity: number;
}
/** One aggregated book level (already rate+size normalized). */
export interface TermBookLevel {
    /** annualised rate at this level, percent. */
    apr: number;
    /** aggregate size, loan-token base units (raw string). */
    units: string;
    /** aggregate size, loan-token assets (human number). */
    assets: number;
}
/**
 * Bounded book slice. `asks` = the secondary repo-token orders (RepoTokenLinkedList,
 * the continuous LEND book, analogous to Midnight asks); `bids` = the BORROW
 * side (typically empty — Term borrow origination is sealed-bid auction, not a
 * continuous book).
 */
export interface TermBook {
    bids: TermBookLevel[];
    asks: TermBookLevel[];
}
/** One secondary-market repo-token listing (RepoTokenLinkedList), from the subgraph. */
export interface TermListing {
    listingId: string;
    seller: string;
    repoToken: string;
    /** Listed amount in repo-token units (raw string). */
    amount: string;
    /** Effective discount rate in percent, if the source provides it. */
    discountRatePct?: number;
}
/**
 * One PRIMARY-auction submission by a user (the sealed-bid book that has no
 * instant-settle counterpart): `offer` = a lend commitment, `bid` = a borrow
 * commitment. Only surfaces AFTER the on-chain entity exists (i.e. locked) —
 * the pre-image price stays sealed (`revealed=false`) until the reveal window.
 * The `active` flag marks submissions whose auction is still running (awaiting
 * reveal/clearing, so still cancellable/actionable); once the auction clears,
 * `assignedAmount` is how much was filled into a position.
 */
export interface TermAuctionOrder {
    /** Subgraph entity id (the offer/bid id). */
    id: string;
    side: 'offer' | 'bid';
    /** Auction (offer/bid locker round) this submission belongs to. */
    auctionId: string;
    /** Submitter address (offeror for offers, bidder for bids). */
    account: string;
    /** Submitted amount, purchase(loan)-token base units (raw string). */
    amount: string;
    /** Same amount decimal-scaled to loan-token assets (human number). */
    assets: number;
    /** Amount assigned when the auction cleared, base units (raw; 0 while pending). */
    assignedAmount: string;
    /** Still locked in the auction locker. */
    locked: boolean;
    /** True once the sealed price has been revealed (revealed price > 0). */
    revealed: boolean;
    /** Revealed annualized rate (WAD, raw string) or null while still sealed. */
    revealedPriceWad: string | null;
    /** Auction still open — not complete and not cancelled (actionable). */
    active: boolean;
    auctionComplete: boolean;
    auctionCancelled: boolean;
    /** Reveal window opens (unix seconds). */
    revealTime: number;
    /** Auction closes / clears (unix seconds). */
    auctionEndTime: number;
}
/** A user's primary-auction submissions for one repo, split by side. */
export interface TermAuctionOrders {
    offers: TermAuctionOrder[];
    bids: TermAuctionOrder[];
}
/**
 * Pluggable Term public-data source. The hosted subgraph is the source today;
 * an on-chain reader could implement the same interface later. All methods
 * return null/[] when no endpoint is configured (see `resolveTermApiBase`).
 */
export interface TermBookSource {
    /** Best-APR + depth snapshot for a repo, or null when unavailable. */
    getBookTop(config: TermMarketConfig): Promise<TermBookTop | null>;
    /** Active secondary listings for a repo, or null when unavailable. */
    getListings?(config: TermMarketConfig): Promise<TermListing[] | null>;
    /**
     * A user's PRIMARY-auction submissions (offers + bids) for a repo — the
     * sealed-bid book that has no continuous/instant surface. Returns null when
     * no subgraph is configured. Prices stay sealed until reveal.
     */
    getAuctionOrders?(config: TermMarketConfig, account: string): Promise<TermAuctionOrders | null>;
    /**
     * ONE query → the aggregate top PLUS a bounded book slice (top `maxLevels`
     * per side). The public batch uses this so it captures a chunk of the order
     * book without a second request. Optional (stubs may omit).
     */
    getTopAndBook?(config: TermMarketConfig, maxLevels?: number): Promise<{
        top: TermBookTop;
        book: TermBook;
    } | null>;
}
/** A Term repo paired with its current top-of-book (null when the fetch failed). */
export interface TermMarketRaw {
    config: TermMarketConfig;
    top: TermBookTop | null;
    /** Bounded book slice (top-N levels/side); null/absent when unavailable. */
    book?: TermBook | null;
}
//# sourceMappingURL=types.d.ts.map