import { type MarketInput } from "@morpho-org/midnight-sdk"; import { type Address } from "viem"; import { type Metadata, type MidnightTakeLendAction, type Transaction } from "../../types/index.js"; import { type MidnightTakeableOffer } from "./types.js"; /** Parameters for encoding a Midnight lend take from already selected offers. */ export interface MidnightTakeLendParams { readonly chainId: number; readonly market: MarketInput; readonly assets: bigint; readonly minUnits: bigint; readonly taker: Address; readonly takeableOffers: readonly MidnightTakeableOffer[]; /** Bundle execution deadline timestamp. Pass `maxUint256` explicitly for no expiry. */ readonly deadline: bigint; readonly metadata?: Metadata; } /** * Encodes a Midnight bundle that lends loan assets by taking borrow-side offers. * * Prefer `client.morpho.midnight(chainId).takeLend(...)` in app flows so * approval and 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.assets - Loan assets the lender spends. * @param params.minUnits - Minimum units accepted from the bundle quote. * @param params.taker - Lender address executing the bundle. * @param params.takeableOffers - ABI-ready borrow-side offers returned by the Midnight API. * @param params.deadline - Bundle execution deadline timestamp; pass `maxUint256` explicitly for no expiry. * @param params.metadata - Optional analytics metadata appended to calldata. * @returns A deep-frozen `Transaction` targeting `MidnightBundles`. * @throws {NonPositiveInputError} when `assets <= 0n`. * @throws {NegativeInputError} when `minUnits` or `deadline` is negative. * @throws {EmptyMidnightTakeableOffersError} when no offers are provided. * @throws {MidnightOfferSideMismatchError} when any offer is not borrow-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 { midnightTakeLend } from "@morpho-org/morpho-sdk"; * * const tx = midnightTakeLend({ * chainId: 8453, * market: marketData.params, * assets: 1_000_000n, * minUnits: 900_000n, * taker: lender, * takeableOffers: quote.data.takeableOffers, * deadline: maxUint256, * }); * ``` */ export declare const midnightTakeLend: (params: MidnightTakeLendParams) => Readonly>;