import { type MarketInput } from "@morpho-org/midnight-sdk"; import { type Address } from "viem"; import { type Metadata, type MidnightTakeBorrowAction, type Transaction } from "../../types/index.js"; import type { MidnightTakeableOffer } from "./types.js"; /** Parameters for encoding a Midnight borrow take from already selected offers. */ export interface MidnightTakeBorrowParams { readonly chainId: number; readonly market: MarketInput; readonly loanAssets: bigint; readonly maxUnits: bigint; readonly taker: Address; /** Bundle execution deadline timestamp. Pass `maxUint256` explicitly for no expiry. */ readonly deadline: bigint; readonly takeableOffers: readonly MidnightTakeableOffer[]; readonly metadata?: Metadata; } /** * Encodes a Midnight bundle that borrows loan assets by taking lend-side offers. * * Prefer `client.morpho.midnight(chainId).takeBorrow(...)` in app flows so * authorization requirements are resolved first. Use this low-level builder * only after the Midnight API has returned takeable offers and the caller has * already handled prerequisites. * * @param params.chainId - Chain id used to resolve `MidnightBundles`. * @param params.market - Midnight market traded by every takeable offer. * @param params.loanAssets - Loan assets the borrower receives. * @param params.maxUnits - Maximum debt units accepted from the bundle quote. * @param params.taker - Borrower address executing the bundle. * @param params.deadline - Bundle execution deadline timestamp; pass `maxUint256` explicitly for no expiry. * @param params.takeableOffers - ABI-ready lend-side offers returned by the Midnight API. * @param params.metadata - Optional analytics metadata appended to calldata. * @returns A deep-frozen `Transaction` targeting `MidnightBundles`. * @throws {NonPositiveInputError} when `loanAssets` or `maxUnits` is non-positive. * @throws {NegativeInputError} when `deadline` is negative. * @throws {EmptyMidnightTakeableOffersError} when no offers are provided. * @throws {MidnightOfferSideMismatchError} when any offer is not lend-side. * @throws {MidnightTakeableOfferMarketMismatchError} when any offer belongs to another market. * @throws {ChainIdMismatchError} when the market targets another chain. * @throws {MidnightMarketAddressMismatchError} when the market targets another Midnight deployment. * @example * ```ts * import { maxUint256 } from "viem"; * import { midnightTakeBorrow } from "@morpho-org/morpho-sdk"; * * const tx = midnightTakeBorrow({ * chainId: 8453, * market: marketData.params, * loanAssets: 1_000_000n, * maxUnits: 1_100_000n, * taker: borrower, * takeableOffers: quote.data.takeableOffers, * deadline: maxUint256, * }); * ``` */ export declare const midnightTakeBorrow: (params: MidnightTakeBorrowParams) => Readonly>;