import * as _morpho_dev_mempool from '@morpho-dev/mempool';
import { Compute, Offer, Errors, Format } from '@morpho-dev/mempool';
export * from '@morpho-dev/mempool';
import * as viem from 'viem';
import { Address, Account, Hex, PublicClient } from 'viem';
import { Chain as Chain$2 } from 'viem/chains';
import * as node_modules_zod_openapi_dist_components_DkyUTLcs_js from 'node_modules/zod-openapi/dist/components-DkyUTLcs.js';
import * as zod_v4 from 'zod/v4';
import { z, ZodError } from 'zod/v4';
import * as zod_v4_core from 'zod/v4/core';
import { PGlite } from '@electric-sql/pglite';
import { drizzle } from 'drizzle-orm/node-postgres';
import { drizzle as drizzle$1 } from 'drizzle-orm/pglite';
import { Pool } from 'pg';
export * from 'drizzle-orm';
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';

declare const chainNames: readonly ["ethereum", "base"];
type ChainName = (typeof chainNames)[number];
declare const ChainId: {
    ETHEREUM: bigint;
    BASE: bigint;
};
type ChainId = (typeof ChainId)[keyof typeof ChainId];
declare const chainIds: Set<bigint>;
type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
    id: ChainId;
    name: ChainName;
    whitelistedAssets: Set<Address>;
    morpho: Address;
}>;
declare function getChain(chainId: ChainId): Chain | undefined;
declare const chains: Record<ChainName, Chain>;

type Chain$1_Chain = Chain;
type Chain$1_ChainId = ChainId;
type Chain$1_ChainName = ChainName;
declare const Chain$1_chainIds: typeof chainIds;
declare const Chain$1_chainNames: typeof chainNames;
declare const Chain$1_chains: typeof chains;
declare const Chain$1_getChain: typeof getChain;
declare namespace Chain$1 {
  export { type Chain$1_Chain as Chain, type Chain$1_ChainId as ChainId, type Chain$1_ChainName as ChainName, Chain$1_chainIds as chainIds, Chain$1_chainNames as chainNames, Chain$1_chains as chains, Chain$1_getChain as getChain };
}

declare const OpenApi: node_modules_zod_openapi_dist_components_DkyUTLcs_js.OpenAPIObject;

declare const schemas: {
    readonly get_offers: z.ZodObject<{
        creators: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
        side: z.ZodOptional<z.ZodEnum<{
            buy: "buy";
            sell: "sell";
        }>>;
        chains: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<number[], string>>>;
        loan_tokens: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
        status: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<("valid" | "callback_not_supported" | "callback_error" | "unverified")[], string>>>;
        callback_addresses: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
        min_amount: z.ZodOptional<z.ZodBigInt>;
        max_amount: z.ZodOptional<z.ZodBigInt>;
        min_rate: z.ZodOptional<z.ZodBigInt>;
        max_rate: z.ZodOptional<z.ZodBigInt>;
        min_maturity: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
        max_maturity: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
        min_expiry: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
        max_expiry: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
        collateral_assets: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
        collateral_oracles: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>>;
        collateral_tuple: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<{
            asset: string;
            oracle: string | undefined;
            lltv: number | undefined;
        }[], string>>>;
        min_lltv: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
        max_lltv: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
        sort_by: z.ZodOptional<z.ZodEnum<{
            rate: "rate";
            maturity: "maturity";
            expiry: "expiry";
            amount: "amount";
        }>>;
        sort_order: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
            asc: "asc";
            desc: "desc";
        }>>>;
        cursor: z.ZodOptional<z.ZodString>;
        limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
    }, z.core.$strip>;
    readonly match_offers: z.ZodObject<{
        side: z.ZodEnum<{
            buy: "buy";
            sell: "sell";
        }>;
        chain_id: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>;
        rate: z.ZodOptional<z.ZodBigInt>;
        collaterals: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<{
            asset: string;
            oracle: string;
            lltv: bigint;
        }[], string>>>;
        maturity: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
        min_maturity: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
        max_maturity: z.ZodPipe<z.ZodOptional<z.ZodBigInt>, z.ZodTransform<number | undefined, bigint | undefined>>;
        loan_token: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
        creator: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
        status: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<("valid" | "callback_not_supported" | "callback_error" | "unverified")[], string>>>;
        cursor: z.ZodOptional<z.ZodString>;
        limit: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>>;
    }, z.core.$strip>;
};
type Action = keyof typeof schemas;
declare function parse<A extends Action>(action: A, query: unknown): z.infer<(typeof schemas)[A]>;
declare function safeParse<A extends Action>(action: A, query: unknown): z.ZodSafeParseResult<z.infer<(typeof schemas)[A]>>;

declare const OfferStatusValues: readonly ["valid", "callback_not_supported", "callback_error", "unverified"];
type OfferStatus = (typeof OfferStatusValues)[number];
type OfferMetadata = {
    issue: string;
};
type RouterOffer = Offer.Offer & {
    consumed: bigint;
    status: OfferStatus;
    metadata?: OfferMetadata;
};
declare const RouterOfferSchema: (parameters?: {
    omitHash?: boolean;
}) => zod_v4.ZodObject<{
    offering: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
    assets: zod_v4.ZodBigInt;
    rate: zod_v4.ZodBigInt;
    maturity: zod_v4.ZodPipe<zod_v4.ZodNumber, zod_v4.ZodTransform<number & _morpho_dev_mempool.Brand<"Maturity">, number>>;
    expiry: zod_v4.ZodNumber;
    start: zod_v4.ZodNumber;
    nonce: zod_v4.ZodBigInt;
    buy: zod_v4.ZodBoolean;
    chainId: zod_v4.ZodBigInt;
    loanToken: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
    collaterals: zod_v4.ZodArray<zod_v4.ZodObject<{
        asset: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
        oracle: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
        lltv: zod_v4.ZodPipe<zod_v4.ZodBigInt, zod_v4.ZodTransform<bigint & _morpho_dev_mempool.Brand<"LLTV">, bigint>>;
    }, zod_v4_core.$strip>>;
    callback: zod_v4.ZodObject<{
        address: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
        data: zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>;
        gasLimit: zod_v4.ZodBigInt;
    }, zod_v4_core.$strip>;
    signature: zod_v4.ZodOptional<zod_v4.ZodPipe<zod_v4.ZodString, zod_v4.ZodTransform<`0x${string}`, string>>>;
    createdAt: zod_v4.ZodOptional<zod_v4.ZodNumber>;
    consumed: z.ZodBigInt;
    status: z.ZodEnum<{
        valid: "valid";
        callback_not_supported: "callback_not_supported";
        callback_error: "callback_error";
        unverified: "unverified";
    }>;
    metadata: z.ZodOptional<z.ZodObject<{
        issue: z.ZodString;
    }, z.core.$strip>>;
}, zod_v4_core.$strip>;
/**
 * Creates a router offer from a plain object.
 * @throws {InvalidRouterOfferError} If the router offer is invalid.
 * @param input - The router offer to create.
 * @returns The created router offer with its hash.
 */
declare function from(input: Omit<RouterOffer, "hash">): RouterOffer;
declare namespace from {
    type ErrorType = InvalidRouterOfferError;
}
/**
 * Creates a router offer from a snake case object.
 * @throws {InvalidRouterOfferError} If the router offer is invalid.
 * @param input - The router offer to create.
 * @returns The created router offer with its hash.
 */
declare function fromSnakeCase(input: Format.Snake<Omit<RouterOffer, "hash">>): RouterOffer;
declare namespace fromSnakeCase {
    type ErrorType = InvalidRouterOfferError;
}
/**
 * Converts a router offer to a snake case object.
 * @param offer - The router offer to convert.
 * @returns The converted router offer.
 */
declare function toSnakeCase(offer: RouterOffer): Format.Snake<RouterOffer>;
declare function random(): RouterOffer;
declare class InvalidRouterOfferError extends Errors.BaseError<ZodError | Error> {
    readonly name = "RouterOffer.InvalidRouterOfferError";
    constructor(error: ZodError | Error);
}

type RouterOffer$1_InvalidRouterOfferError = InvalidRouterOfferError;
declare const RouterOffer$1_InvalidRouterOfferError: typeof InvalidRouterOfferError;
type RouterOffer$1_OfferMetadata = OfferMetadata;
type RouterOffer$1_OfferStatus = OfferStatus;
declare const RouterOffer$1_OfferStatusValues: typeof OfferStatusValues;
type RouterOffer$1_RouterOffer = RouterOffer;
declare const RouterOffer$1_RouterOfferSchema: typeof RouterOfferSchema;
declare const RouterOffer$1_from: typeof from;
declare const RouterOffer$1_fromSnakeCase: typeof fromSnakeCase;
declare const RouterOffer$1_random: typeof random;
declare const RouterOffer$1_toSnakeCase: typeof toSnakeCase;
declare namespace RouterOffer$1 {
  export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, RouterOffer$1_from as from, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
}

type OfferResponse = {
    offer: Offer.Offer;
    consumed: bigint;
    status: OfferStatus;
    metadata?: OfferMetadata;
};
/**
 * Transforms a RouterOffer to OfferResponse format.
 * @param routerOffer - The router offer to transform.
 * @returns The router offer response with offer as a nested property.
 */
declare function toResponse(routerOffer: RouterOffer): OfferResponse;
/**
 * Transforms a OfferResponse to RouterOffer format.
 * @param offerResponse - The router offer response to transform.
 * @returns The router offer with all properties at the top level.
 */
declare function fromResponse(offerResponse: OfferResponse): RouterOffer;

type index$1_OfferResponse = OfferResponse;
declare const index$1_OpenApi: typeof OpenApi;
declare const index$1_fromResponse: typeof fromResponse;
declare const index$1_parse: typeof parse;
declare const index$1_safeParse: typeof safeParse;
declare const index$1_toResponse: typeof toResponse;
declare namespace index$1 {
  export { type index$1_OfferResponse as OfferResponse, index$1_OpenApi as OpenApi, index$1_fromResponse as fromResponse, index$1_parse as parse, index$1_safeParse as safeParse, index$1_toResponse as toResponse };
}

type GetParameters = {
    /** Filter by multiple creator addresses (comma-separated) */
    creators?: string[];
    /** Filter by offer type: buy offers or sell offers */
    side?: "buy" | "sell";
    /** Filter by multiple blockchain networks (comma-separated chain IDs) */
    chains?: number[];
    /** Filter by multiple loan assets (comma-separated) */
    loanTokens?: string[];
    /** Filter by multiple statuses (comma-separated) */
    status?: OfferStatus[];
    /** Filter by multiple callback addresses (comma-separated) */
    callbackAddresses?: string[];
    /** Minimum amount of assets in the offer */
    minAmount?: bigint;
    /** Maximum amount of assets in the offer */
    maxAmount?: bigint;
    /** Minimum rate per asset (in wei) */
    minRate?: bigint;
    /** Maximum rate per asset (in wei) */
    maxRate?: bigint;
    /** Minimum maturity timestamp (Unix timestamp in seconds) */
    minMaturity?: number;
    /** Maximum maturity timestamp (Unix timestamp in seconds) */
    maxMaturity?: number;
    /** Minimum expiry timestamp (Unix timestamp in seconds) */
    minExpiry?: number;
    /** Maximum expiry timestamp (Unix timestamp in seconds) */
    maxExpiry?: number;
    /** Filter by multiple collateral assets (comma-separated) */
    collateralAssets?: string[];
    /** Filter by multiple rate oracles (comma-separated) */
    collateralOracles?: string[];
    /** Filter by collateral combinations */
    collateralTuple?: Array<{
        asset: string;
        oracle?: string;
        lltv?: number;
    }>;
    /** Minimum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal) */
    minLltv?: number;
    /** Maximum Loan-to-Value ratio (LLTV) for collateral (percentage as decimal) */
    maxLltv?: number;
    /** Field to sort results by */
    sortBy?: "rate" | "maturity" | "expiry" | "amount";
    /** Sort direction: asc (ascending) or desc (descending, default) */
    sortOrder?: "asc" | "desc";
    /** Pagination cursor in base64url-encoded format */
    cursor?: string;
    /** Maximum number of offers to return. Defaults to 20. Maximum is 100. */
    limit?: number;
};
type MatchParameters = {
    /** The desired side of the match: 'buy' if you want to buy, 'sell' if you want to sell */
    side: "buy" | "sell";
    /** The blockchain network chain ID */
    chainId: number;
    /** Rate per asset (in wei) for matching offers */
    rate?: bigint;
    /** Collateral requirements */
    collaterals?: Array<{
        asset: string;
        oracle: string;
        lltv: bigint;
    }>;
    /** Exact maturity timestamp (Unix timestamp in seconds) */
    maturity?: number;
    /** Minimum maturity timestamp (Unix timestamp in seconds, inclusive) */
    minMaturity?: number;
    /** Maximum maturity timestamp (Unix timestamp in seconds, inclusive) */
    maxMaturity?: number;
    /** The loan asset address to match against */
    loanToken?: string;
    /** Filter by a specific offer creator address */
    creator?: string;
    /** Filter by multiple statuses (comma-separated) */
    status?: OfferStatus[];
    /** Pagination cursor in base64url-encoded format */
    cursor?: string;
    /** Maximum number of offers to return. Defaults to 20. Maximum is 100. */
    limit?: number;
};
type RouterClientConfig = {
    readonly url: URL;
    readonly headers: Headers;
};
type Client = Compute<RouterClientConfig & {
    get: (parameters: GetParameters) => Promise<{
        cursor: string | null;
        offers: OfferResponse[];
    }>;
    match: (parameters: MatchParameters) => Promise<{
        cursor: string | null;
        offers: OfferResponse[];
    }>;
}>;
declare function connect(opts?: {
    url?: string;
    apiKey?: string;
}): Client;
declare namespace connect {
    type ErrorType = InvalidUrlError;
}
/**
 * Get offers from the router.
 * @returns The offers with pagination cursor.
 */
declare function get(config: RouterClientConfig, parameters: GetParameters): Promise<{
    cursor: string | null;
    offers: OfferResponse[];
}>;
declare namespace get {
    type ErrorType = GetApiErrorType;
}
/**
 * Match offers from the router.
 * @returns The matched offers with pagination cursor.
 */
declare function match(config: RouterClientConfig, parameters: MatchParameters): Promise<{
    cursor: string | null;
    offers: OfferResponse[];
}>;
declare namespace match {
    type ErrorType = GetApiErrorType;
}
type GetApiErrorType = HttpGetOffersFailedError | HttpUnauthorizedError | HttpForbiddenError | HttpRateLimitError;
declare class InvalidUrlError extends Errors.BaseError {
    name: string;
    constructor(url: string);
}
declare class HttpUnauthorizedError extends Errors.BaseError {
    name: string;
    constructor();
}
declare class HttpForbiddenError extends Errors.BaseError {
    name: string;
    constructor();
}
declare class HttpRateLimitError extends Errors.BaseError {
    name: string;
    constructor();
}
declare class HttpGetOffersFailedError extends Errors.BaseError {
    name: string;
    constructor(message: string, { details }?: {
        details?: string;
    });
}

type PgDB = ReturnType<typeof drizzle> & {
    name: "pg";
    pool: Pool;
};
type PGLiteDB = ReturnType<typeof drizzle$1> & {
    name: "pglite";
    pool: PGlite;
};
type DB = PgDB | PGLiteDB;
declare function create$1({ type, endpoint, }: {
    type?: "pg" | "pglite";
    endpoint?: string;
}): DB;
declare function applyMigrations(db: DB): Promise<void>;
declare function applyMigrationsPostgres(db: DB): Promise<void>;
declare function clean(db: DB): Promise<void>;

type OfferDB_DB = DB;
declare const OfferDB_applyMigrations: typeof applyMigrations;
declare const OfferDB_applyMigrationsPostgres: typeof applyMigrationsPostgres;
declare const OfferDB_clean: typeof clean;
declare namespace OfferDB {
  export { type OfferDB_DB as DB, OfferDB_applyMigrations as applyMigrations, OfferDB_applyMigrationsPostgres as applyMigrationsPostgres, OfferDB_clean as clean, create$1 as create };
}

type GetOffersFilters = {
    creators?: string[];
    side?: "buy" | "sell";
    chains?: number[];
    loanTokens?: string[];
    status?: OfferStatus[];
    callbackAddresses?: string[];
    minAmount?: bigint;
    maxAmount?: bigint;
    minRate?: bigint;
    maxRate?: bigint;
    minMaturity?: number;
    maxMaturity?: number;
    minExpiry?: number;
    maxExpiry?: number;
    collateralAssets?: string[];
    collateralOracles?: string[];
    collateralTuple?: Array<{
        asset: string;
        oracle?: string;
        lltv?: number;
    }>;
    minLltv?: number;
    maxLltv?: number;
    sortBy?: "rate" | "maturity" | "expiry" | "amount";
    sortOrder?: "asc" | "desc";
    cursor?: string;
    limit?: number;
};
interface FindMatchingOffersParams {
    side: "buy" | "sell";
    chainId: number;
    rate?: bigint;
    collaterals?: Array<{
        asset: string;
        oracle: string;
        lltv: bigint;
    }>;
    maturity?: number;
    minMaturity?: number;
    maxMaturity?: number;
    loanToken?: string;
    creator?: string;
    /** Filter by offer status; if omitted defaults to ["valid"] */
    status?: OfferStatus[];
    /** Cursor string returned by a previous call, for pagination */
    cursor?: string;
    /** Page size; defaults to 20 */
    limit?: number;
}
interface GetAllParams {
    query?: GetOffersFilters;
}
type OfferRepositoryConfig = {
    /** The database instance to use for operations. */
    db: DB;
};
/**
 * The `OfferRepository` is responsible for managing offer data in the database.
 */
type OfferRepository = {
    /** Create a single offer in the database. */
    create: (parameters: {
        offer: Offer.Offer;
        status: OfferStatus;
        metadata?: OfferMetadata;
    }) => Promise<string>;
    /** Create multiple offers in the database. */
    createMany: (parameters: {
        offer: Offer.Offer;
        status: OfferStatus;
        metadata?: OfferMetadata;
    }[]) => Promise<string[]>;
    /** Get all offers from the database with optional filtering, sorting, and pagination. */
    getAll: (params?: GetAllParams) => Promise<{
        offers: RouterOffer[];
        nextCursor: string | null;
    }>;
    /** Find offers that match the specified parameters, with cursor pagination. */
    findMatchingOffers: (params: FindMatchingOffersParams) => Promise<{
        offers: RouterOffer[];
        nextCursor: string | null;
    }>;
    /** Delete an offer and its associated collaterals by hash. */
    delete: (hash: Offer.Offer["hash"]) => Promise<boolean>;
    /** Delete multiple offers and their associated collaterals by hashes. */
    deleteMany: (hashes: Offer.Offer["hash"][]) => Promise<number>;
    /** Update the status of an offer. */
    updateStatus: (parameters: {
        offerHash: Offer.Offer["hash"];
        status: OfferStatus;
        metadata?: OfferMetadata;
    }) => Promise<void>;
    updateConsumedAmount: (parameters: {
        chainId: Offer.Offer["chainId"];
        offering: Offer.Offer["offering"];
        nonce: Offer.Offer["nonce"];
        consumed: bigint;
    }) => Promise<void>;
};
/**
 * Creates a new OfferRepository instance.
 */
declare function create(config: OfferRepositoryConfig): OfferRepository;
type TestOfferRepository = OfferRepository;
declare function createTest(): TestOfferRepository;

type OfferRepository$1_FindMatchingOffersParams = FindMatchingOffersParams;
type OfferRepository$1_GetAllParams = GetAllParams;
type OfferRepository$1_GetOffersFilters = GetOffersFilters;
type OfferRepository$1_OfferRepository = OfferRepository;
type OfferRepository$1_OfferRepositoryConfig = OfferRepositoryConfig;
type OfferRepository$1_TestOfferRepository = TestOfferRepository;
declare const OfferRepository$1_create: typeof create;
declare const OfferRepository$1_createTest: typeof createTest;
declare namespace OfferRepository$1 {
  export { type OfferRepository$1_FindMatchingOffersParams as FindMatchingOffersParams, type OfferRepository$1_GetAllParams as GetAllParams, type OfferRepository$1_GetOffersFilters as GetOffersFilters, type OfferRepository$1_OfferRepository as OfferRepository, type OfferRepository$1_OfferRepositoryConfig as OfferRepositoryConfig, type OfferRepository$1_TestOfferRepository as TestOfferRepository, OfferRepository$1_create as create, OfferRepository$1_createTest as createTest };
}

declare const offers: drizzle_orm_pg_core.PgTableWithColumns<{
    name: "offers";
    schema: undefined;
    columns: {
        hash: drizzle_orm_pg_core.PgColumn<{
            name: "hash";
            tableName: "offers";
            dataType: "string";
            columnType: "PgVarchar";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: true;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            length: 66;
        }>;
        offering: drizzle_orm_pg_core.PgColumn<{
            name: "offering";
            tableName: "offers";
            dataType: "string";
            columnType: "PgVarchar";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            length: 42;
        }>;
        assets: drizzle_orm_pg_core.PgColumn<{
            name: "assets";
            tableName: "offers";
            dataType: "bigint";
            columnType: "PgBigInt64";
            data: bigint;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        rate: drizzle_orm_pg_core.PgColumn<{
            name: "rate";
            tableName: "offers";
            dataType: "bigint";
            columnType: "PgBigInt64";
            data: bigint;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        maturity: drizzle_orm_pg_core.PgColumn<{
            name: "maturity";
            tableName: "offers";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        expiry: drizzle_orm_pg_core.PgColumn<{
            name: "expiry";
            tableName: "offers";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        start: drizzle_orm_pg_core.PgColumn<{
            name: "start";
            tableName: "offers";
            dataType: "number";
            columnType: "PgInteger";
            data: number;
            driverParam: string | number;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        nonce: drizzle_orm_pg_core.PgColumn<{
            name: "nonce";
            tableName: "offers";
            dataType: "bigint";
            columnType: "PgBigInt64";
            data: bigint;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        buy: drizzle_orm_pg_core.PgColumn<{
            name: "buy";
            tableName: "offers";
            dataType: "boolean";
            columnType: "PgBoolean";
            data: boolean;
            driverParam: boolean;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        chainId: drizzle_orm_pg_core.PgColumn<{
            name: "chain_id";
            tableName: "offers";
            dataType: "bigint";
            columnType: "PgBigInt64";
            data: bigint;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        loanToken: drizzle_orm_pg_core.PgColumn<{
            name: "loan_token";
            tableName: "offers";
            dataType: "string";
            columnType: "PgVarchar";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            length: 42;
        }>;
        callbackAddress: drizzle_orm_pg_core.PgColumn<{
            name: "callback_address";
            tableName: "offers";
            dataType: "string";
            columnType: "PgVarchar";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            length: 42;
        }>;
        callbackData: drizzle_orm_pg_core.PgColumn<{
            name: "callback_data";
            tableName: "offers";
            dataType: "string";
            columnType: "PgText";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        callbackGasLimit: drizzle_orm_pg_core.PgColumn<{
            name: "callback_gas_limit";
            tableName: "offers";
            dataType: "bigint";
            columnType: "PgBigInt64";
            data: bigint;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        signature: drizzle_orm_pg_core.PgColumn<{
            name: "signature";
            tableName: "offers";
            dataType: "string";
            columnType: "PgVarchar";
            data: string;
            driverParam: string;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            length: 132;
        }>;
        createdAt: drizzle_orm_pg_core.PgColumn<{
            name: "created_at";
            tableName: "offers";
            dataType: "date";
            columnType: "PgTimestamp";
            data: Date;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
    };
    dialect: "pg";
}>;
declare const offerCollaterals: drizzle_orm_pg_core.PgTableWithColumns<{
    name: "offer_collaterals";
    schema: undefined;
    columns: {
        id: drizzle_orm_pg_core.PgColumn<{
            name: "id";
            tableName: "offer_collaterals";
            dataType: "number";
            columnType: "PgSerial";
            data: number;
            driverParam: number;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: true;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        offerHash: drizzle_orm_pg_core.PgColumn<{
            name: "offer_hash";
            tableName: "offer_collaterals";
            dataType: "string";
            columnType: "PgVarchar";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            length: 66;
        }>;
        asset: drizzle_orm_pg_core.PgColumn<{
            name: "asset";
            tableName: "offer_collaterals";
            dataType: "string";
            columnType: "PgVarchar";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            length: 42;
        }>;
        oracle: drizzle_orm_pg_core.PgColumn<{
            name: "oracle";
            tableName: "offer_collaterals";
            dataType: "string";
            columnType: "PgVarchar";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            length: 42;
        }>;
        lltv: drizzle_orm_pg_core.PgColumn<{
            name: "lltv";
            tableName: "offer_collaterals";
            dataType: "bigint";
            columnType: "PgBigInt64";
            data: bigint;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
    };
    dialect: "pg";
}>;
declare const offerStatus: drizzle_orm_pg_core.PgTableWithColumns<{
    name: "offer_status";
    schema: undefined;
    columns: {
        id: drizzle_orm_pg_core.PgColumn<{
            name: "id";
            tableName: "offer_status";
            dataType: "number";
            columnType: "PgSerial";
            data: number;
            driverParam: number;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: true;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        offerHash: drizzle_orm_pg_core.PgColumn<{
            name: "offer_hash";
            tableName: "offer_status";
            dataType: "string";
            columnType: "PgVarchar";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            length: 66;
        }>;
        status: drizzle_orm_pg_core.PgColumn<{
            name: "status";
            tableName: "offer_status";
            dataType: "string";
            columnType: "PgText";
            data: "valid" | "callback_not_supported" | "callback_error" | "unverified";
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            $type: "valid" | "callback_not_supported" | "callback_error" | "unverified";
        }>;
        metadata: drizzle_orm_pg_core.PgColumn<{
            name: "metadata";
            tableName: "offer_status";
            dataType: "json";
            columnType: "PgJsonb";
            data: unknown;
            driverParam: unknown;
            notNull: false;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        createdAt: drizzle_orm_pg_core.PgColumn<{
            name: "created_at";
            tableName: "offer_status";
            dataType: "date";
            columnType: "PgTimestamp";
            data: Date;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
    };
    dialect: "pg";
}>;
declare const consumed: drizzle_orm_pg_core.PgTableWithColumns<{
    name: "consumed_per_user_and_nonce";
    schema: undefined;
    columns: {
        id: drizzle_orm_pg_core.PgColumn<{
            name: "id";
            tableName: "consumed_per_user_and_nonce";
            dataType: "number";
            columnType: "PgSerial";
            data: number;
            driverParam: number;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: true;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        chainId: drizzle_orm_pg_core.PgColumn<{
            name: "chain_id";
            tableName: "consumed_per_user_and_nonce";
            dataType: "bigint";
            columnType: "PgBigInt64";
            data: bigint;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        offering: drizzle_orm_pg_core.PgColumn<{
            name: "offering";
            tableName: "consumed_per_user_and_nonce";
            dataType: "string";
            columnType: "PgVarchar";
            data: string;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: [string, ...string[]];
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {
            length: 42;
        }>;
        nonce: drizzle_orm_pg_core.PgColumn<{
            name: "nonce";
            tableName: "consumed_per_user_and_nonce";
            dataType: "bigint";
            columnType: "PgBigInt64";
            data: bigint;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        consumed: drizzle_orm_pg_core.PgColumn<{
            name: "consumed";
            tableName: "consumed_per_user_and_nonce";
            dataType: "bigint";
            columnType: "PgBigInt64";
            data: bigint;
            driverParam: string;
            notNull: true;
            hasDefault: false;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
        createdAt: drizzle_orm_pg_core.PgColumn<{
            name: "created_at";
            tableName: "consumed_per_user_and_nonce";
            dataType: "date";
            columnType: "PgTimestamp";
            data: Date;
            driverParam: string;
            notNull: true;
            hasDefault: true;
            isPrimaryKey: false;
            isAutoincrement: false;
            hasRuntimeDefault: false;
            enumValues: undefined;
            baseColumn: never;
            identity: undefined;
            generated: undefined;
        }, {}, {}>;
    };
    dialect: "pg";
}>;

/**
 * Start a local router server.
 * @example
 * ```ts
 * import { Router } from "@morpho-dev/router";
 * await Router.serve(); // local router server running on http://localhost:8081
 * ```
 */
declare function serve(parameters: {
    port: number;
    store?: OfferRepository;
}): Promise<void>;

type index_Client = Client;
type index_GetParameters = GetParameters;
type index_HttpForbiddenError = HttpForbiddenError;
declare const index_HttpForbiddenError: typeof HttpForbiddenError;
type index_HttpGetOffersFailedError = HttpGetOffersFailedError;
declare const index_HttpGetOffersFailedError: typeof HttpGetOffersFailedError;
type index_HttpRateLimitError = HttpRateLimitError;
declare const index_HttpRateLimitError: typeof HttpRateLimitError;
type index_HttpUnauthorizedError = HttpUnauthorizedError;
declare const index_HttpUnauthorizedError: typeof HttpUnauthorizedError;
type index_InvalidUrlError = InvalidUrlError;
declare const index_InvalidUrlError: typeof InvalidUrlError;
type index_MatchParameters = MatchParameters;
type index_RouterClientConfig = RouterClientConfig;
declare const index_connect: typeof connect;
declare const index_get: typeof get;
declare const index_match: typeof match;
declare const index_serve: typeof serve;
declare namespace index {
  export { type index_Client as Client, type index_GetParameters as GetParameters, index_HttpForbiddenError as HttpForbiddenError, index_HttpGetOffersFailedError as HttpGetOffersFailedError, index_HttpRateLimitError as HttpRateLimitError, index_HttpUnauthorizedError as HttpUnauthorizedError, index_InvalidUrlError as InvalidUrlError, type index_MatchParameters as MatchParameters, type index_RouterClientConfig as RouterClientConfig, index_connect as connect, index_get as get, index_match as match, index_serve as serve };
}

declare const users: Account[];
declare const assetList: readonly ["USDC", "DAI"];
declare const mockAddress: (asset: (typeof assetList)[number]) => `0x${string}`;
declare const assetMethods: readonly ["balanceOf", "allowance"];
type AssetMethod = (typeof assetMethods)[number];
type MethodParameters = {
    balanceOf: {
        address: Address;
        value: bigint;
    };
    allowance: {
        owner: Address;
        spender: Address;
        value: bigint;
    };
};
type MockedAsset = {
    address: Address;
    set: (slot: Hex | AssetMethod, parameters: Hex | bigint | MethodParameters[AssetMethod]) => Promise<void>;
};
type Mocked = {
    name: string;
    publicClient: PublicClient;
} & Record<(typeof assetList)[number], MockedAsset>;
declare function mock(name: string): Promise<Mocked>;

type EVM_AssetMethod = AssetMethod;
type EVM_MethodParameters = MethodParameters;
type EVM_Mocked = Mocked;
type EVM_MockedAsset = MockedAsset;
declare const EVM_assetList: typeof assetList;
declare const EVM_assetMethods: typeof assetMethods;
declare const EVM_mock: typeof mock;
declare const EVM_mockAddress: typeof mockAddress;
declare const EVM_users: typeof users;
declare namespace EVM {
  export { type EVM_AssetMethod as AssetMethod, type EVM_MethodParameters as MethodParameters, type EVM_Mocked as Mocked, type EVM_MockedAsset as MockedAsset, EVM_assetList as assetList, EVM_assetMethods as assetMethods, EVM_mock as mock, EVM_mockAddress as mockAddress, EVM_users as users };
}

declare const LogLevelValues: readonly ["silent", "trace", "debug", "info", "warn", "error", "fatal"];
type LogLevel = (typeof LogLevelValues)[number];
type LogFn = {
    <T extends object>(obj: T, msg?: string, ...args: unknown[]): void;
    (obj: unknown, msg?: string, ...args: unknown[]): void;
    (msg: string, ...args: unknown[]): void;
};
type Logger = {
    trace: LogFn;
    debug: LogFn;
    info: LogFn;
    warn: LogFn;
    error: LogFn;
    fatal: LogFn;
};
declare function defaultLogger(): Logger;
declare function runWithLogger<T>(logger: Logger, fn: () => Promise<T>): Promise<T>;
declare function getLogger(): Logger;

type Logger$1_LogFn = LogFn;
type Logger$1_LogLevel = LogLevel;
declare const Logger$1_LogLevelValues: typeof LogLevelValues;
type Logger$1_Logger = Logger;
declare const Logger$1_defaultLogger: typeof defaultLogger;
declare const Logger$1_getLogger: typeof getLogger;
declare const Logger$1_runWithLogger: typeof runWithLogger;
declare namespace Logger$1 {
  export { type Logger$1_LogFn as LogFn, type Logger$1_LogLevel as LogLevel, Logger$1_LogLevelValues as LogLevelValues, type Logger$1_Logger as Logger, Logger$1_defaultLogger as defaultLogger, Logger$1_getLogger as getLogger, Logger$1_runWithLogger as runWithLogger };
}

declare const types: readonly ["offer_created", "offer_matched", "offer_validation"];
type Type = (typeof types)[number];
type EventPayload = {
    offer_created: {
        readonly offer: Offer.Offer;
    };
    offer_matched: {
        readonly offer: Offer.Offer;
    };
    offer_validation: {
        readonly offer: Offer.Offer;
    };
};
type BaseEvent<T extends Type> = {
    readonly id: string;
    readonly type: T;
};
type RouterEvent = Compute<{
    [K in keyof EventPayload]: BaseEvent<K> & EventPayload[K];
}[keyof EventPayload]>;
/**
 * Builds a deterministic event id based on the event type.
 * For `offer_created` it returns `offer_created:${offer.hash.toLowerCase()}`.
 * For `offer_matched` it returns `offer_matched:${offer.hash.toLowerCase()}`.
 */
declare function buildId(event: Omit<RouterEvent, "id">): string;

type RouterEvent$1_RouterEvent = RouterEvent;
type RouterEvent$1_Type = Type;
declare const RouterEvent$1_buildId: typeof buildId;
declare const RouterEvent$1_types: typeof types;
declare namespace RouterEvent$1 {
  export { type RouterEvent$1_RouterEvent as RouterEvent, type RouterEvent$1_Type as Type, RouterEvent$1_buildId as buildId, RouterEvent$1_types as types };
}

/**
 * Splits an array into batches of a specified size.
 * @param array The array to split.
 * @param batchSize The size of each batch.
 * @returns An iterator that yields each batch.
 * @example
 * ```typescript
 * const array = [1, 2, 3, 4, 5];
 * for (const batch of batch(array, 2)) {
 *  console.log(batch);
 * }
 * // Output:
 * // [1, 2]
 * // [3, 4]
 * // [5]
 * ```
 */
declare function batch$1<T>(array: Array<T>, batchSize: number): Generator<T[], void, unknown>;

type Cursor = {
    sort: "rate" | "maturity" | "expiry" | "amount";
    dir: "asc" | "desc";
    rate?: string;
    maturity?: number;
    expiry?: number;
    assets?: string;
    hash: string;
};
declare function validateCursor(cursor: unknown): cursor is Cursor;
declare function encodeCursor(c: Cursor): string;
declare function decodeCursor(token?: string): Cursor | null;

/**
 * Polls a function at a specified interval.
 * Inspired by https://github.com/wevm/viem/blob/845994d20275d08ff892018e237a4b599eeefb6a/src/utils/poll.ts
 */
declare function poll<data>(fn: ({ unpoll }: {
    unpoll: () => void;
}) => Promise<data | undefined>, { interval }: {
    interval: number;
}): () => boolean;

declare function wait(time: number): Promise<unknown>;

/**
 * A validation rule.
 */
type Rule<T, Name extends string = string, Ctx = void> = {
    kind: "single";
    name: Name;
    run: Single<T, Name, Ctx>;
} | {
    kind: "batch";
    name: Name;
    run: Batch<T, Name, Ctx>;
};
type RuleNames<Rules extends readonly {
    name: string;
}[]> = Rules[number]["name"];
/**
 * A single item validation rule.
 * @param item - The item to validate.
 * @param ctx - The context of the validation.
 * @returns The issue that was found. If the item is valid, this will be undefined.
 */
type Single<T, RuleName extends string, Ctx = void> = (item: T, ctx: Ctx) => Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined | Promise<Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>;
/**
 * A batch item validation rule.
 * @param items - The items to validate.
 * @param ctx - The context of the validation.
 * @returns A map of the items to the issue that was found.
 */
type Batch<T, RuleName extends string, Ctx = void> = (items: T[], ctx: Ctx) => Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined> | Promise<Map<number, Omit<Issue<T, RuleName>, "ruleName" | "item"> | undefined>>;
/**
 * Create a validation rule iterating over a single item at a time.
 * @param name - The name of the rule.
 * @param run - The function that validates the rule.
 * @returns The created rule.
 */
declare function single<Name extends string, T, Ctx = void>(name: Name, run: Single<T, Name, Ctx>): Rule<T, Name, Ctx>;
/**
 * Create a validation rule iterating over a batch of items at a time.
 * @param name - The name of the rule.
 * @param run - The function that validates the rule.
 * @returns The created rule.
 */
declare function batch<Name extends string, T, Ctx = void>(name: Name, run: Batch<T, Name, Ctx>): Rule<T, Name, Ctx>;
type MorphoContext = {
    publicClients: Partial<Record<ChainName, PublicClient>>;
};
declare function morpho(parameters: {
    whitelistedChains: Chain[];
}): (Rule<{
    readonly offering: Address;
    readonly assets: bigint;
    readonly rate: bigint;
    readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
    readonly expiry: number;
    readonly nonce: bigint;
    readonly buy: boolean;
    readonly chainId: bigint;
    readonly loanToken: Address;
    readonly start: number;
    readonly collaterals: readonly {
        asset: Address;
        oracle: Address;
        lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
    }[];
    readonly callback: {
        readonly address: Address;
        readonly data: viem.Hex;
        readonly gasLimit: bigint;
    };
    readonly hash: viem.Hex;
    signature?: viem.Hex;
    createdAt?: number;
}, "chain_id", MorphoContext> | Rule<{
    readonly offering: Address;
    readonly assets: bigint;
    readonly rate: bigint;
    readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
    readonly expiry: number;
    readonly nonce: bigint;
    readonly buy: boolean;
    readonly chainId: bigint;
    readonly loanToken: Address;
    readonly start: number;
    readonly collaterals: readonly {
        asset: Address;
        oracle: Address;
        lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
    }[];
    readonly callback: {
        readonly address: Address;
        readonly data: viem.Hex;
        readonly gasLimit: bigint;
    };
    readonly hash: viem.Hex;
    signature?: viem.Hex;
    createdAt?: number;
}, "loan_token", MorphoContext> | Rule<{
    readonly offering: Address;
    readonly assets: bigint;
    readonly rate: bigint;
    readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
    readonly expiry: number;
    readonly nonce: bigint;
    readonly buy: boolean;
    readonly chainId: bigint;
    readonly loanToken: Address;
    readonly start: number;
    readonly collaterals: readonly {
        asset: Address;
        oracle: Address;
        lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
    }[];
    readonly callback: {
        readonly address: Address;
        readonly data: viem.Hex;
        readonly gasLimit: bigint;
    };
    readonly hash: viem.Hex;
    signature?: viem.Hex;
    createdAt?: number;
}, "expiry", MorphoContext> | Rule<{
    readonly offering: Address;
    readonly assets: bigint;
    readonly rate: bigint;
    readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
    readonly expiry: number;
    readonly nonce: bigint;
    readonly buy: boolean;
    readonly chainId: bigint;
    readonly loanToken: Address;
    readonly start: number;
    readonly collaterals: readonly {
        asset: Address;
        oracle: Address;
        lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
    }[];
    readonly callback: {
        readonly address: Address;
        readonly data: viem.Hex;
        readonly gasLimit: bigint;
    };
    readonly hash: viem.Hex;
    signature?: viem.Hex;
    createdAt?: number;
}, "empty_callback", MorphoContext> | Rule<{
    readonly offering: Address;
    readonly assets: bigint;
    readonly rate: bigint;
    readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
    readonly expiry: number;
    readonly nonce: bigint;
    readonly buy: boolean;
    readonly chainId: bigint;
    readonly loanToken: Address;
    readonly start: number;
    readonly collaterals: readonly {
        asset: Address;
        oracle: Address;
        lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
    }[];
    readonly callback: {
        readonly address: Address;
        readonly data: viem.Hex;
        readonly gasLimit: bigint;
    };
    readonly hash: viem.Hex;
    signature?: viem.Hex;
    createdAt?: number;
}, "sell_offers_empty_callback", MorphoContext> | Rule<{
    readonly offering: Address;
    readonly assets: bigint;
    readonly rate: bigint;
    readonly maturity: number & _morpho_dev_mempool.Brand<"Maturity">;
    readonly expiry: number;
    readonly nonce: bigint;
    readonly buy: boolean;
    readonly chainId: bigint;
    readonly loanToken: Address;
    readonly start: number;
    readonly collaterals: readonly {
        asset: Address;
        oracle: Address;
        lltv: bigint & _morpho_dev_mempool.Brand<"LLTV">;
    }[];
    readonly callback: {
        readonly address: Address;
        readonly data: viem.Hex;
        readonly gasLimit: bigint;
    };
    readonly hash: viem.Hex;
    signature?: viem.Hex;
    createdAt?: number;
}, "buy_offers_empty_callback", MorphoContext>)[];

type ValidationRule_Batch<T, RuleName extends string, Ctx = void> = Batch<T, RuleName, Ctx>;
type ValidationRule_MorphoContext = MorphoContext;
type ValidationRule_Rule<T, Name extends string = string, Ctx = void> = Rule<T, Name, Ctx>;
type ValidationRule_RuleNames<Rules extends readonly {
    name: string;
}[]> = RuleNames<Rules>;
type ValidationRule_Single<T, RuleName extends string, Ctx = void> = Single<T, RuleName, Ctx>;
declare const ValidationRule_batch: typeof batch;
declare const ValidationRule_morpho: typeof morpho;
declare const ValidationRule_single: typeof single;
declare namespace ValidationRule {
  export { type ValidationRule_Batch as Batch, type ValidationRule_MorphoContext as MorphoContext, type ValidationRule_Rule as Rule, type ValidationRule_RuleNames as RuleNames, type ValidationRule_Single as Single, ValidationRule_batch as batch, ValidationRule_morpho as morpho, ValidationRule_single as single };
}

/**
 * A validation issue.
 */
type Issue<T, RuleName extends string = string> = {
    /** The name of the rule that caused the issue. */
    ruleName: RuleName;
    /** The message of the issue. */
    message: string;
    /** The item that was not valid. */
    item: T;
};
/**
 * The result of a validation.
 */
type Result<T, RuleName extends string = string> = {
    /** The items that were valid. */
    valid: T[];
    /** The reports of the failed validations. */
    issues: Issue<T, RuleName>[];
};
declare function run<T, Name extends string, Rules extends readonly Rule<T, Name, void>[]>(parameters: {
    items: T[];
    rules: Rules;
    chunkSize?: number;
}): Promise<Result<T, RuleNames<Rules>>>;
declare function run<T, Ctx, Name extends string, Rules extends readonly Rule<T, Name, Ctx>[]>(parameters: {
    items: T[];
    rules: Rules;
    ctx: Ctx;
    chunkSize?: number;
}): Promise<Result<T, RuleNames<Rules>>>;

type Validation_Issue<T, RuleName extends string = string> = Issue<T, RuleName>;
type Validation_Result<T, RuleName extends string = string> = Result<T, RuleName>;
declare const Validation_run: typeof run;
declare namespace Validation {
  export { type Validation_Issue as Issue, type Validation_Result as Result, Validation_run as run };
}

export { index$1 as ApiSchema, Chain$1 as Chain, type Cursor, EVM, Logger$1 as Logger, OfferDB, OfferRepository$1 as OfferRepository, index as Router, RouterEvent$1 as RouterEvent, RouterOffer$1 as RouterOffer, Validation, ValidationRule, batch$1 as batch, consumed, decodeCursor, encodeCursor, offerCollaterals, offerStatus, offers, poll, validateCursor, wait };
