@morpho-dev/router 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,9 +34,9 @@ declare const CollectorHealth: z.ZodObject<{
34
34
  updated_at: z.ZodNullable<z.ZodString>;
35
35
  lag: z.ZodNullable<z.ZodNumber>;
36
36
  status: z.ZodEnum<{
37
+ unknown: "unknown";
37
38
  live: "live";
38
39
  lagging: "lagging";
39
- unknown: "unknown";
40
40
  }>;
41
41
  initialized: z.ZodBoolean;
42
42
  }, z.core.$strip>;
@@ -47,9 +47,9 @@ declare const CollectorsHealthResponse: z.ZodArray<z.ZodObject<{
47
47
  updated_at: z.ZodNullable<z.ZodString>;
48
48
  lag: z.ZodNullable<z.ZodNumber>;
49
49
  status: z.ZodEnum<{
50
+ unknown: "unknown";
50
51
  live: "live";
51
52
  lagging: "lagging";
52
- unknown: "unknown";
53
53
  }>;
54
54
  initialized: z.ZodBoolean;
55
55
  }, z.core.$strip>>;
@@ -891,7 +891,7 @@ declare function toSnakeCase$1<T>(obj: T): Snake<T>;
891
891
  declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
892
892
  declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
893
893
  declare namespace Obligation_d_exports {
894
- export { CollateralsAreNotSortedError, InvalidObligationError, Obligation, ObligationSchema, from$11 as from, fromSnakeCase$2 as fromSnakeCase, id, random$2 as random };
894
+ export { CollateralsAreNotSortedError, InvalidObligationError, Obligation, ObligationSchema, from$11 as from, fromOffer$1 as fromOffer, fromSnakeCase$2 as fromSnakeCase, id, random$2 as random };
895
895
  }
896
896
  type Obligation = {
897
897
  /** The chain id where the liquidity for this obligation is located. */chainId: Id; /** The token that is being borrowed for this obligation. */
@@ -999,6 +999,18 @@ declare function random$2(): random$2.ReturnType;
999
999
  declare namespace random$2 {
1000
1000
  type ReturnType = Obligation;
1001
1001
  }
1002
+ /**
1003
+ * Creates an obligation from an offer.
1004
+ * @constructor
1005
+ *
1006
+ * @param offer - The offer to create the obligation from.
1007
+ * @returns The created obligation. {@link fromOffer.ReturnType}
1008
+ */
1009
+ declare function fromOffer$1(offer: Offer): fromOffer$1.ReturnType;
1010
+ declare namespace fromOffer$1 {
1011
+ type Parameters = Offer;
1012
+ type ReturnType = Obligation;
1013
+ }
1002
1014
  declare class InvalidObligationError extends BaseError<z$1.ZodError | Error> {
1003
1015
  readonly name = "Obligation.InvalidObligationError";
1004
1016
  constructor(error: z$1.ZodError | Error);
@@ -1008,7 +1020,7 @@ declare class CollateralsAreNotSortedError extends BaseError {
1008
1020
  constructor();
1009
1021
  }
1010
1022
  declare namespace Offer_d_exports {
1011
- export { AccountNotSetError, InvalidOfferError, Offer, OfferConsumed, OfferInput, OfferSchema, RandomConfig, Status, Validation, consumedEvent, decode$1 as decode, domain, encode$1 as encode, from$10 as from, fromSnakeCase$1 as fromSnakeCase, hash, obligationId, random$1 as random, serialize, sign, signatureMsg, toSnakeCase, types };
1023
+ export { InvalidOfferError, Offer, OfferConsumed, OfferInput, OfferSchema, RandomConfig, Status, Validation, consumedEvent, decode$1 as decode, domain, encode$1 as encode, from$10 as from, fromSnakeCase$1 as fromSnakeCase, hash, obligationId, random$1 as random, serialize, toSnakeCase, types };
1012
1024
  }
1013
1025
  type Offer = {
1014
1026
  /** The address that made the offer. */readonly maker: Address; /** The amount of assets offered. Mutually exclusive with obligationUnits and obligationShares. */
@@ -1247,15 +1259,6 @@ declare const types: {
1247
1259
  readonly type: "bytes";
1248
1260
  }];
1249
1261
  };
1250
- /**
1251
- * Signs an array of offers.
1252
- * @throws {Error} If the wallet account is not set.
1253
- * @param offers - The offers to sign.
1254
- * @param wallet - The wallet to sign the offers with.
1255
- * @returns The signed offers.
1256
- */
1257
- declare function sign(offers: Offer[], wallet: WalletClient): Promise<Hex>;
1258
- declare function signatureMsg(offers: Offer[]): Hex;
1259
1262
  declare function hash(offer: Offer): Hex;
1260
1263
  /**
1261
1264
  * Calculates the obligation id for an offer based on the smart contract's Obligation struct.
@@ -1313,12 +1316,8 @@ declare class InvalidOfferError extends BaseError<z$1.ZodError | Error> {
1313
1316
  */
1314
1317
  get formattedMessage(): string;
1315
1318
  }
1316
- declare class AccountNotSetError extends BaseError {
1317
- readonly name = "Offer.AccountNotSetError";
1318
- constructor();
1319
- }
1320
1319
  declare namespace Oracle_d_exports {
1321
- export { Conversion, Oracle, from$9 as from };
1320
+ export { Conversion, Oracle, from$9 as from, fromCollateral, fromOffer, fromOffers };
1322
1321
  }
1323
1322
  /**
1324
1323
  * An oracle contract that provides price information for assets.
@@ -1344,6 +1343,55 @@ declare namespace from$9 {
1344
1343
  };
1345
1344
  type ReturnType = Oracle;
1346
1345
  }
1346
+ /**
1347
+ * Creates an oracle from a collateral.
1348
+ * @constructor
1349
+ *
1350
+ * @param parameters - {@link fromCollateral.Parameters}
1351
+ * @returns The created oracle. {@link fromCollateral.ReturnType}
1352
+ */
1353
+ declare function fromCollateral(parameters: fromCollateral.Parameters): fromCollateral.ReturnType;
1354
+ declare namespace fromCollateral {
1355
+ type Parameters = {
1356
+ chainId: Id;
1357
+ collateral: Collateral;
1358
+ blockNumber: number;
1359
+ price?: bigint | null;
1360
+ };
1361
+ type ReturnType = Oracle;
1362
+ }
1363
+ /**
1364
+ * Creates oracles from a single offer.
1365
+ * @constructor
1366
+ *
1367
+ * @param parameters - {@link fromOffer.Parameters}
1368
+ * @returns The created oracles. {@link fromOffer.ReturnType}
1369
+ */
1370
+ declare function fromOffer(parameters: fromOffer.Parameters): fromOffer.ReturnType;
1371
+ declare namespace fromOffer {
1372
+ type Parameters = {
1373
+ offer: Offer;
1374
+ blockNumber: number;
1375
+ price?: bigint | null;
1376
+ };
1377
+ type ReturnType = Oracle[];
1378
+ }
1379
+ /**
1380
+ * Creates oracles from a list of offers.
1381
+ * @constructor
1382
+ *
1383
+ * @param parameters - {@link fromOffers.Parameters}
1384
+ * @returns The created oracles. {@link fromOffers.ReturnType}
1385
+ */
1386
+ declare function fromOffers(parameters: fromOffers.Parameters): fromOffers.ReturnType;
1387
+ declare namespace fromOffers {
1388
+ type Parameters = {
1389
+ offers: Offer[];
1390
+ blockNumber: number;
1391
+ price?: bigint | null;
1392
+ };
1393
+ type ReturnType = Oracle[];
1394
+ }
1347
1395
  /**
1348
1396
  * Conversion utilities for converting between collateral and loan token amounts
1349
1397
  * using oracle prices and LLTV
@@ -1599,7 +1647,7 @@ declare namespace from$5 {
1599
1647
  type ReturnType = Transfer;
1600
1648
  }
1601
1649
  declare namespace Tree_d_exports {
1602
- export { DecodeError, EncodeError, Proof, Tree, TreeError, VERSION, decode, encode, encodeUnsigned, from$4 as from, proofs };
1650
+ export { DecodeError, EncodeError, NormalizedSignatureDomain, Proof, SignatureDomain, SignatureDomainError, Tree, TreeError, VERSION, decode, encode, encodeUnsigned, from$4 as from, proofs, signatureDomain, signatureTypes };
1603
1651
  }
1604
1652
  /**
1605
1653
  * A merkle tree of offers built from offer hashes.
@@ -1614,6 +1662,31 @@ type Proof = {
1614
1662
  path: Hex[];
1615
1663
  };
1616
1664
  declare const VERSION = 1;
1665
+ type SignatureDomain = {
1666
+ /** Chain id used in the EIP-712 domain. */chainId: number | bigint; /** MorphoV2 contract address used as verifying contract. */
1667
+ verifyingContract: Address;
1668
+ };
1669
+ /** Normalized Root signature domain (BigInt chain id, lowercase address). */
1670
+ type NormalizedSignatureDomain = {
1671
+ chainId: bigint;
1672
+ verifyingContract: Address;
1673
+ };
1674
+ /**
1675
+ * EIP-712 types for signing the tree root (Root(bytes32 root)).
1676
+ */
1677
+ declare const signatureTypes: {
1678
+ readonly EIP712Domain: readonly [{
1679
+ readonly name: "chainId";
1680
+ readonly type: "uint256";
1681
+ }, {
1682
+ readonly name: "verifyingContract";
1683
+ readonly type: "address";
1684
+ }];
1685
+ readonly Root: readonly [{
1686
+ readonly name: "root";
1687
+ readonly type: "bytes32";
1688
+ }];
1689
+ };
1617
1690
  /**
1618
1691
  * Builds a Merkle tree from a list of offers.
1619
1692
  *
@@ -1636,6 +1709,11 @@ declare const from$4: (offers: Offer[]) => Tree;
1636
1709
  * @returns Array of proofs - {@link Proof}
1637
1710
  */
1638
1711
  declare const proofs: (tree: Tree) => Proof[];
1712
+ /**
1713
+ * Normalizes a Root signature domain (BigInt chain id, lowercase address).
1714
+ * @throws {SignatureDomainError} When the domain is invalid.
1715
+ */
1716
+ declare const signatureDomain: (domain: SignatureDomain) => NormalizedSignatureDomain;
1639
1717
  /**
1640
1718
  * Encodes a merkle tree with signature into hex calldata for onchain broadcast.
1641
1719
  *
@@ -1643,15 +1721,21 @@ declare const proofs: (tree: Tree) => Proof[];
1643
1721
  * - `{vv}`: 1-byte version (currently 0x01)
1644
1722
  * - `{gzip([...offers])}`: gzipped JSON array of serialized offers
1645
1723
  * - `{root}`: 32-byte merkle root
1646
- * - `{signature}`: 65-byte EIP-191 signature over raw root bytes
1724
+ * - `{signature}`: 65-byte EIP-712 signature over Root(bytes32 root)
1647
1725
  *
1648
1726
  * Validates signature authenticity and root integrity before encoding.
1649
1727
  *
1650
1728
  * @example
1651
1729
  * ```typescript
1652
1730
  * const tree = Tree.from(offers);
1653
- * const signature = await wallet.signMessage({ message: { raw: tree.root } });
1654
- * const calldata = await Tree.encode(tree, signature);
1731
+ * const signature = await wallet.signTypedData({
1732
+ * account: wallet.account,
1733
+ * domain: Tree.signatureDomain({ chainId, verifyingContract }),
1734
+ * types: Tree.signatureTypes,
1735
+ * primaryType: "Root",
1736
+ * message: { root: tree.root },
1737
+ * });
1738
+ * const calldata = await Tree.encode(tree, signature, { chainId, verifyingContract });
1655
1739
  * await broadcast(calldata);
1656
1740
  * ```
1657
1741
  *
@@ -1661,16 +1745,23 @@ declare const proofs: (tree: Tree) => Proof[];
1661
1745
  * const tree = Tree.from(offers);
1662
1746
  * const compressed = gzip(JSON.stringify(tree.offers.map(Offer.serialize)));
1663
1747
  * const partial = `0x01${bytesToHex(compressed)}${tree.root.slice(2)}`;
1664
- * const signature = await wallet.signMessage({ message: { raw: tree.root } });
1748
+ * const signature = await wallet.signTypedData({
1749
+ * account: wallet.account,
1750
+ * domain: Tree.signatureDomain({ chainId, verifyingContract }),
1751
+ * types: Tree.signatureTypes,
1752
+ * primaryType: "Root",
1753
+ * message: { root: tree.root },
1754
+ * });
1665
1755
  * const calldata = `${partial}${signature.slice(2)}`;
1666
1756
  * ```
1667
1757
  *
1668
1758
  * @param tree - Merkle tree of offers
1669
- * @param signature - EIP-191 signature over raw root bytes
1759
+ * @param signature - EIP-712 signature over Root(bytes32 root)
1760
+ * @param domain - EIP-712 domain with chain id and verifying contract
1670
1761
  * @returns Hex-encoded calldata ready for onchain broadcast
1671
1762
  * @throws {EncodeError} If signature verification fails or root mismatch
1672
1763
  */
1673
- declare const encode: (tree: Tree, signature: Hex) => Promise<Hex>;
1764
+ declare const encode: (tree: Tree, signature: Hex, domain: SignatureDomain) => Promise<Hex>;
1674
1765
  /**
1675
1766
  * Encodes a merkle tree without a signature into hex payload for client-side signing.
1676
1767
  *
@@ -1700,15 +1791,16 @@ declare const encodeUnsigned: (tree: Tree) => Hex;
1700
1791
  *
1701
1792
  * @example
1702
1793
  * ```typescript
1703
- * const { tree, signature, signer } = await Tree.decode(calldata);
1794
+ * const { tree, signature, signer } = await Tree.decode(calldata, { chainId, verifyingContract });
1704
1795
  * console.log(`Tree signed by ${signer} with ${tree.offers.length} offers`);
1705
1796
  * ```
1706
1797
  *
1707
1798
  * @param encoded - Hex calldata in format `0x{vv}{gzip}{root}{signature}`
1799
+ * @param domain - EIP-712 domain with chain id and verifying contract
1708
1800
  * @returns Validated tree, signature, and recovered signer address
1709
1801
  * @throws {DecodeError} If version invalid, signature invalid, or root mismatch
1710
1802
  */
1711
- declare const decode: (encoded: Hex) => Promise<{
1803
+ declare const decode: (encoded: Hex, domain: SignatureDomain) => Promise<{
1712
1804
  tree: Tree;
1713
1805
  signature: Hex;
1714
1806
  signer: Address;
@@ -1737,6 +1829,13 @@ declare class DecodeError extends BaseError {
1737
1829
  name: string;
1738
1830
  constructor(reason: string);
1739
1831
  }
1832
+ /**
1833
+ * Error thrown when an invalid signature domain is supplied.
1834
+ */
1835
+ declare class SignatureDomainError extends BaseError {
1836
+ name: string;
1837
+ constructor(reason: string);
1838
+ }
1740
1839
  //#endregion
1741
1840
  //#region src/api/Schema/generated/swagger.d.ts
1742
1841
  /**
@@ -1812,7 +1911,7 @@ interface paths {
1812
1911
  patch?: never;
1813
1912
  trace?: never;
1814
1913
  };
1815
- "/v1/config": {
1914
+ "/v1/config/contracts": {
1816
1915
  parameters: {
1817
1916
  query?: never;
1818
1917
  header?: never;
@@ -1820,12 +1919,28 @@ interface paths {
1820
1919
  cookie?: never;
1821
1920
  };
1822
1921
  /**
1823
- * Get router configuration
1824
- * @description Returns chain configurations including contract addresses and supported callback types.
1922
+ * Get indexer contract configuration
1923
+ * @description Returns contract addresses used by indexers (mempool, v2) and multicall for indexed chains.
1825
1924
  */
1826
1925
  get: {
1827
1926
  parameters: {
1828
- query?: never;
1927
+ query?: {
1928
+ /**
1929
+ * @description Filter by chain IDs (comma-separated).
1930
+ * @example 1,8453
1931
+ */
1932
+ chains?: number[];
1933
+ /**
1934
+ * @description Maximum number of contracts to return (max 1000).
1935
+ * @example 1000
1936
+ */
1937
+ limit?: number;
1938
+ /**
1939
+ * @description Pagination cursor in chain_id:address format (lowercase address).
1940
+ * @example 505050505:0xd946246695a9259f3b33a78629026f61b3ab40af
1941
+ */
1942
+ cursor?: string;
1943
+ };
1829
1944
  header?: never;
1830
1945
  path?: never;
1831
1946
  cookie?: never;
@@ -1837,7 +1952,66 @@ interface paths {
1837
1952
  [name: string]: unknown;
1838
1953
  };
1839
1954
  content: {
1840
- "application/json": components["schemas"]["ConfigSuccessResponse"];
1955
+ "application/json": components["schemas"]["ConfigContractsSuccessResponse"];
1956
+ };
1957
+ };
1958
+ };
1959
+ };
1960
+ put?: never;
1961
+ post?: never;
1962
+ delete?: never;
1963
+ options?: never;
1964
+ head?: never;
1965
+ patch?: never;
1966
+ trace?: never;
1967
+ };
1968
+ "/v1/config/rules": {
1969
+ parameters: {
1970
+ query?: never;
1971
+ header?: never;
1972
+ path?: never;
1973
+ cookie?: never;
1974
+ };
1975
+ /**
1976
+ * Get config rules
1977
+ * @description Returns configured rules for supported chains.
1978
+ */
1979
+ get: {
1980
+ parameters: {
1981
+ query?: {
1982
+ /**
1983
+ * @description Filter by chain IDs (comma-separated).
1984
+ * @example 1,8453
1985
+ */
1986
+ chains?: number[];
1987
+ /**
1988
+ * @description Filter by rule types (comma-separated).
1989
+ * @example maturity,loan_token
1990
+ */
1991
+ types?: string[];
1992
+ /**
1993
+ * @description Maximum number of rules to return (max 1000).
1994
+ * @example 100
1995
+ */
1996
+ limit?: number;
1997
+ /**
1998
+ * @description Pagination cursor in type:chain_id:<value> format.
1999
+ * @example maturity:1:1730415600:end_of_next_month
2000
+ */
2001
+ cursor?: string;
2002
+ };
2003
+ header?: never;
2004
+ path?: never;
2005
+ cookie?: never;
2006
+ };
2007
+ requestBody?: never;
2008
+ responses: {
2009
+ /** @description Success */200: {
2010
+ headers: {
2011
+ [name: string]: unknown;
2012
+ };
2013
+ content: {
2014
+ "application/json": components["schemas"]["ConfigRulesSuccessResponse"];
1841
2015
  };
1842
2016
  };
1843
2017
  };
@@ -2258,15 +2432,6 @@ interface paths {
2258
2432
  /**
2259
2433
  * Validate offers
2260
2434
  * @description Validates offers against router validation rules. Returns unsigned payload + root on success, or issues only on validation failure.
2261
- *
2262
- * **Available validation rules:**
2263
- * - **parse_error**: Returns when an offer fails to parse due to invalid format or missing required fields
2264
- * - **mixed_maker**: Validates that all offers in a batch have the same maker address
2265
- * - **amount_mutual_exclusivity**: Validates that at most one of (assets, obligationUnits, obligationShares) is non-zero
2266
- * - **chain_ids**: Validates that offer chain is one of: [109111114]
2267
- * - **maturity**: Validates that offer maturity is one of: [end_of_month, end_of_next_month]
2268
- * - **callback**: Validates callbacks: buy empty callback is allowed; sell offers must use a non-empty callback; non-empty callbacks must target one of [0x3333333333333333333333333333333333333333, 0x4444444444444444444444444444444444444444, 0x1111111111111111111111111111111111111111, 0x2222222222222222222222222222222222222222]
2269
- * - **token**: Validates that offer loan token and collateral tokens are in the allowed assets list for the offer chain
2270
2435
  */
2271
2436
  post: {
2272
2437
  parameters: {
@@ -2305,6 +2470,56 @@ interface paths {
2305
2470
  patch?: never;
2306
2471
  trace?: never;
2307
2472
  };
2473
+ "/v1/callbacks": {
2474
+ parameters: {
2475
+ query?: never;
2476
+ header?: never;
2477
+ path?: never;
2478
+ cookie?: never;
2479
+ };
2480
+ get?: never;
2481
+ put?: never;
2482
+ /**
2483
+ * Resolve callback types
2484
+ * @description Returns callback types for callback addresses grouped by chain.
2485
+ */
2486
+ post: {
2487
+ parameters: {
2488
+ query?: never;
2489
+ header?: never;
2490
+ path?: never;
2491
+ cookie?: never;
2492
+ };
2493
+ requestBody?: {
2494
+ content: {
2495
+ "application/json": components["schemas"]["CallbackTypesRequest"];
2496
+ };
2497
+ };
2498
+ responses: {
2499
+ /** @description Success */200: {
2500
+ headers: {
2501
+ [name: string]: unknown;
2502
+ };
2503
+ content: {
2504
+ "application/json": components["schemas"]["CallbackTypesSuccessResponse"];
2505
+ };
2506
+ }; /** @description Bad Request */
2507
+ 400: {
2508
+ headers: {
2509
+ [name: string]: unknown;
2510
+ };
2511
+ content: {
2512
+ "application/json": components["schemas"]["BadRequestResponse"];
2513
+ };
2514
+ };
2515
+ };
2516
+ };
2517
+ delete?: never;
2518
+ options?: never;
2519
+ head?: never;
2520
+ patch?: never;
2521
+ trace?: never;
2522
+ };
2308
2523
  }
2309
2524
  interface components {
2310
2525
  schemas: {
@@ -2342,39 +2557,78 @@ interface components {
2342
2557
  */
2343
2558
  details: Record<string, never>;
2344
2559
  };
2345
- ConfigSuccessResponse: {
2560
+ ConfigContractsSuccessResponse: {
2346
2561
  meta: components["schemas"]["Meta"]; /** @example null */
2347
2562
  cursor: string | null;
2348
2563
  /**
2349
- * @description Array of chain configurations for all indexed chains.
2564
+ * @description Indexer contract configuration for all indexed chains.
2350
2565
  * @example [
2351
2566
  * {
2352
2567
  * "chain_id": 505050505,
2353
- * "contracts": {
2354
- * "mempool": "0xD946246695A9259F3B33a78629026F61B3Ab40aF"
2355
- * },
2356
- * "callbacks": [
2357
- * "buy_with_empty_callback"
2358
- * ]
2568
+ * "address": "0xD946246695A9259F3B33a78629026F61B3Ab40aF",
2569
+ * "name": "mempool"
2570
+ * },
2571
+ * {
2572
+ * "chain_id": 505050505,
2573
+ * "address": "0x8A409D5D6394fC197c596d4E6E2c35e5d13f8a4d",
2574
+ * "name": "multicall"
2575
+ * },
2576
+ * {
2577
+ * "chain_id": 505050505,
2578
+ * "address": "0x23DFBc4B8B80C14CC5e25011B8491f268395BAd6",
2579
+ * "name": "v2"
2359
2580
  * }
2360
2581
  * ]
2361
2582
  */
2362
- data: components["schemas"]["ConfigDataResponse"][];
2583
+ data: components["schemas"]["ConfigContractResponse"][];
2584
+ };
2585
+ ConfigContractResponse: {
2586
+ /** @example 505050505 */chain_id: number; /** @example 0xD946246695A9259F3B33a78629026F61B3Ab40aF */
2587
+ address: string;
2588
+ /**
2589
+ * @example mempool
2590
+ * @enum {string}
2591
+ */
2592
+ name: "mempool" | "multicall" | "v2";
2363
2593
  };
2364
- ConfigDataResponse: {
2365
- /** @example 505050505 */chain_id: number;
2366
- contracts: components["schemas"]["ConfigContractsResponse"];
2594
+ ConfigRulesSuccessResponse: {
2595
+ meta: components["schemas"]["ConfigRulesMeta"]; /** @example null */
2596
+ cursor: string | null;
2367
2597
  /**
2368
- * @description Supported callback types for this chain.
2598
+ * @description Configured rules returned by the router API.
2369
2599
  * @example [
2370
- * "buy_with_empty_callback"
2600
+ * {
2601
+ * "type": "maturity",
2602
+ * "chain_id": 1,
2603
+ * "name": "end_of_next_month",
2604
+ * "timestamp": 1730415600
2605
+ * },
2606
+ * {
2607
+ * "type": "callback",
2608
+ * "chain_id": 1,
2609
+ * "address": "0x1111111111111111111111111111111111111111",
2610
+ * "callback_type": "sell_erc20_callback"
2611
+ * },
2612
+ * {
2613
+ * "type": "loan_token",
2614
+ * "chain_id": 1,
2615
+ * "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
2616
+ * }
2371
2617
  * ]
2372
- * @enum {string}
2373
2618
  */
2374
- callbacks: "buy_with_empty_callback" | "buy_erc20" | "buy_vault_v1_callback" | "sell_erc20_callback";
2619
+ data: components["schemas"]["ConfigRulesRuleResponse"][];
2375
2620
  };
2376
- ConfigContractsResponse: {
2377
- /** @example 0xD946246695A9259F3B33a78629026F61B3Ab40aF */mempool: string;
2621
+ ConfigRulesMeta: {
2622
+ /** @example 2024-01-01T12:00:00.000Z */timestamp: string; /** @example f1d2d2f924e986ac86fdf7b36c94bcdf */
2623
+ checksum: string;
2624
+ };
2625
+ ConfigRulesRuleResponse: {
2626
+ /** @example maturity */type: string; /** @example 1 */
2627
+ chain_id: number; /** @example end_of_next_month */
2628
+ name?: string; /** @example 1730415600 */
2629
+ timestamp?: number; /** @example 0x1111111111111111111111111111111111111111 */
2630
+ address?: string; /** @example sell_erc20_callback */
2631
+ callback_type?: string;
2378
2632
  };
2379
2633
  OfferListResponse: {
2380
2634
  meta: components["schemas"]["Meta"]; /** @example eyJvZmZzZXQiOjEwMH0 */
@@ -2716,6 +2970,84 @@ interface components {
2716
2970
  */
2717
2971
  root: string;
2718
2972
  };
2973
+ CallbackTypesRequest: {
2974
+ /**
2975
+ * @example [
2976
+ * {
2977
+ * "chain_id": 1,
2978
+ * "addresses": [
2979
+ * "0x1111111111111111111111111111111111111111",
2980
+ * "0x3333333333333333333333333333333333333333",
2981
+ * "0x9999999999999999999999999999999999999999"
2982
+ * ]
2983
+ * }
2984
+ * ]
2985
+ */
2986
+ callbacks: components["schemas"]["CallbackTypesChainRequest"][];
2987
+ };
2988
+ CallbackTypesChainRequest: {
2989
+ /** @example 1 */chain_id: number;
2990
+ /**
2991
+ * @example [
2992
+ * "0x1111111111111111111111111111111111111111",
2993
+ * "0x3333333333333333333333333333333333333333",
2994
+ * "0x9999999999999999999999999999999999999999"
2995
+ * ]
2996
+ */
2997
+ addresses: string[];
2998
+ };
2999
+ CallbackTypesSuccessResponse: {
3000
+ meta: components["schemas"]["Meta"]; /** @example maturity:1:1730415600:end_of_next_month */
3001
+ cursor: string | null;
3002
+ /**
3003
+ * @description Callback types grouped by chain.
3004
+ * @example [
3005
+ * {
3006
+ * "chain_id": 1,
3007
+ * "sell_erc20_callback": [
3008
+ * "0x1111111111111111111111111111111111111111"
3009
+ * ],
3010
+ * "buy_erc20": [
3011
+ * "0x5555555555555555555555555555555555555555"
3012
+ * ],
3013
+ * "buy_vault_v1_callback": [
3014
+ * "0x3333333333333333333333333333333333333333"
3015
+ * ],
3016
+ * "not_supported": [
3017
+ * "0x9999999999999999999999999999999999999999"
3018
+ * ]
3019
+ * }
3020
+ * ]
3021
+ */
3022
+ data: components["schemas"]["CallbackTypesChainResponse"][];
3023
+ };
3024
+ CallbackTypesChainResponse: {
3025
+ /** @example 1 */chain_id: number;
3026
+ /**
3027
+ * @example [
3028
+ * "0x3333333333333333333333333333333333333333"
3029
+ * ]
3030
+ */
3031
+ buy_vault_v1_callback?: string[];
3032
+ /**
3033
+ * @example [
3034
+ * "0x1111111111111111111111111111111111111111"
3035
+ * ]
3036
+ */
3037
+ sell_erc20_callback?: string[];
3038
+ /**
3039
+ * @example [
3040
+ * "0x5555555555555555555555555555555555555555"
3041
+ * ]
3042
+ */
3043
+ buy_erc20?: string[];
3044
+ /**
3045
+ * @example [
3046
+ * "0x9999999999999999999999999999999999999999"
3047
+ * ]
3048
+ */
3049
+ not_supported: string[];
3050
+ };
2719
3051
  };
2720
3052
  responses: never;
2721
3053
  parameters: never;
@@ -2777,45 +3109,6 @@ type Input = Readonly<{
2777
3109
  */
2778
3110
  declare function from$2(input: Input): OfferResponse;
2779
3111
  //#endregion
2780
- //#region src/gatekeeper/types.d.ts
2781
- type RuleInfo = {
2782
- name: string;
2783
- description: string;
2784
- };
2785
- type RulesProvider = {
2786
- getRules: () => Promise<RuleInfo[]>;
2787
- };
2788
- type ValidationIssue = {
2789
- index: number;
2790
- rule: string;
2791
- message: string;
2792
- };
2793
- type ValidateOffersSuccess = {
2794
- payload: Hex;
2795
- root: Hex;
2796
- };
2797
- type ValidateOffersIssues = {
2798
- issues: ValidationIssue[];
2799
- };
2800
- type ValidateOffersData = ValidateOffersSuccess | ValidateOffersIssues;
2801
- type SuccessPayload<T> = {
2802
- meta: {
2803
- timestamp: string;
2804
- };
2805
- cursor: string | null;
2806
- data: T;
2807
- };
2808
- type ErrorPayload = {
2809
- meta: {
2810
- timestamp: string;
2811
- };
2812
- error: {
2813
- code: string;
2814
- message: string;
2815
- details?: unknown;
2816
- };
2817
- };
2818
- //#endregion
2819
3112
  //#region src/api/Schema/openapi.d.ts
2820
3113
  declare class BooksController {
2821
3114
  getBook(): Promise<void>;
@@ -2823,6 +3116,9 @@ declare class BooksController {
2823
3116
  declare class ValidateController {
2824
3117
  validateOffers(): Promise<void>;
2825
3118
  }
3119
+ declare class CallbacksController {
3120
+ resolveCallbackTypes(): Promise<void>;
3121
+ }
2826
3122
  declare class OffersController {
2827
3123
  getOffers(): Promise<void>;
2828
3124
  }
@@ -2831,8 +3127,11 @@ declare class HealthController {
2831
3127
  getCollectorsHealth(): Promise<void>;
2832
3128
  getChainsHealth(): Promise<void>;
2833
3129
  }
2834
- declare class ConfigController {
2835
- getConfig(): Promise<void>;
3130
+ declare class ConfigContractsController {
3131
+ getConfigContracts(): Promise<void>;
3132
+ }
3133
+ declare class ConfigRulesController {
3134
+ getConfigRules(): Promise<void>;
2836
3135
  }
2837
3136
  declare class ObligationsController {
2838
3137
  getObligations(): Promise<void>;
@@ -2841,10 +3140,7 @@ declare class ObligationsController {
2841
3140
  declare class UsersController {
2842
3141
  getUserPositions(): Promise<void>;
2843
3142
  }
2844
- type OpenApiOptions = {
2845
- rules?: RuleInfo[];
2846
- };
2847
- declare const OpenApi: (options?: OpenApiOptions) => Promise<OpenAPIDocument>;
3143
+ declare const OpenApi: () => Promise<OpenAPIDocument>;
2848
3144
  //#endregion
2849
3145
  //#region src/database/domains/Positions.d.ts
2850
3146
  type PaginationParams = {
@@ -2911,6 +3207,21 @@ declare const schemas: {
2911
3207
  false: "false";
2912
3208
  }>, z$1.ZodTransform<boolean, "0" | "1" | "true" | "false">>>;
2913
3209
  }, z$1.core.$strip>;
3210
+ readonly get_config_contracts: z$1.ZodObject<{
3211
+ cursor: z$1.ZodOptional<z$1.ZodString>;
3212
+ limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
3213
+ chains: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodTransform<{} | null | undefined, unknown>, z$1.ZodArray<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>>>>;
3214
+ }, z$1.core.$strip>;
3215
+ readonly get_config_rules: z$1.ZodObject<{
3216
+ cursor: z$1.ZodOptional<z$1.ZodString>;
3217
+ limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
3218
+ types: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodTransform<{} | null | undefined, unknown>, z$1.ZodArray<z$1.ZodEnum<{
3219
+ maturity: "maturity";
3220
+ callback: "callback";
3221
+ loan_token: "loan_token";
3222
+ }>>>>;
3223
+ chains: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodTransform<{} | null | undefined, unknown>, z$1.ZodArray<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>>>>;
3224
+ }, z$1.core.$strip>;
2914
3225
  readonly get_offers: z$1.ZodObject<{
2915
3226
  side: z$1.ZodOptional<z$1.ZodEnum<{
2916
3227
  buy: "buy";
@@ -2944,6 +3255,12 @@ declare const schemas: {
2944
3255
  readonly validate_offers: z$1.ZodObject<{
2945
3256
  offers: z$1.ZodArray<z$1.ZodUnknown>;
2946
3257
  }, z$1.core.$strict>;
3258
+ readonly callback_types: z$1.ZodObject<{
3259
+ callbacks: z$1.ZodArray<z$1.ZodObject<{
3260
+ chain_id: z$1.ZodNumber;
3261
+ addresses: z$1.ZodArray<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>;
3262
+ }, z$1.core.$strict>>;
3263
+ }, z$1.core.$strict>;
2947
3264
  readonly get_user_positions: z$1.ZodObject<{
2948
3265
  user_address: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
2949
3266
  cursor: z$1.ZodOptional<z$1.ZodString>;
@@ -2954,7 +3271,7 @@ type Action = keyof typeof schemas;
2954
3271
  declare function parse<A extends Action>(action: A, query: unknown): z$1.infer<(typeof schemas)[A]>;
2955
3272
  declare function safeParse<A extends Action>(action: A, query: unknown, error?: z$1.core.$ZodErrorMap<z$1.core.$ZodIssue>): z$1.ZodSafeParseResult<z$1.infer<(typeof schemas)[A]>>;
2956
3273
  declare namespace index_d_exports$1 {
2957
- export { BookResponse_d_exports as BookResponse, BooksController, ChainHealth, ChainsHealthResponse, CollectorHealth, CollectorsHealthResponse, ConfigController, HealthController, ObligationResponse_d_exports as ObligationResponse, ObligationsController, OfferResponse_d_exports as OfferResponse, OffersController, OpenApi, OpenApiOptions, PositionResponse_d_exports as PositionResponse, RouterStatusResponse, UsersController, ValidateController, parse, safeParse };
3274
+ export { BookResponse_d_exports as BookResponse, BooksController, CallbacksController, ChainHealth, ChainsHealthResponse, CollectorHealth, CollectorsHealthResponse, ConfigContractsController, ConfigRulesController, HealthController, ObligationResponse_d_exports as ObligationResponse, ObligationsController, OfferResponse_d_exports as OfferResponse, OffersController, OpenApi, PositionResponse_d_exports as PositionResponse, RouterStatusResponse, UsersController, ValidateController, parse, safeParse };
2958
3275
  }
2959
3276
  declare namespace Client_d_exports$1 {
2960
3277
  export { Client$2 as Client, ConnectOptions, HttpForbiddenError, HttpGetApiFailedError, HttpRateLimitError, HttpUnauthorizedError, InvalidUrlError, connect$1 as connect, getObligations, getOffers };
@@ -3152,21 +3469,91 @@ declare function run<T, Name extends string, Rules extends readonly Rule<T, Name
3152
3469
  rules: Rules;
3153
3470
  chunkSize?: number;
3154
3471
  }): Promise<Result<T, RuleNames<Rules>>>;
3472
+ //#endregion
3473
+ //#region src/gatekeeper/types.d.ts
3474
+ type ConfigRule = {
3475
+ type: "maturity";
3476
+ chain_id: Id;
3477
+ name: MaturityType;
3478
+ timestamp: Maturity;
3479
+ } | {
3480
+ type: "callback";
3481
+ chain_id: Id;
3482
+ address: Address;
3483
+ callback_type: Exclude<Type$1, Type$1.BuyWithEmptyCallback>;
3484
+ } | {
3485
+ type: "loan_token";
3486
+ chain_id: Id;
3487
+ address: Address;
3488
+ };
3489
+ type ValidationIssue = {
3490
+ index: number;
3491
+ rule: string;
3492
+ message: string;
3493
+ };
3494
+ type ValidateOffersSuccess = {
3495
+ payload: Hex;
3496
+ root: Hex;
3497
+ };
3498
+ type ValidateOffersIssues = {
3499
+ issues: ValidationIssue[];
3500
+ };
3501
+ type ValidateOffersData = ValidateOffersSuccess | ValidateOffersIssues;
3502
+ type CallbackType = Type$1 | "not_supported";
3503
+ type CallbackTypesRequest = {
3504
+ callbacks: Array<{
3505
+ chain_id: Id;
3506
+ addresses: Address[];
3507
+ }>;
3508
+ };
3509
+ type CallbackTypesResponse = Array<{
3510
+ chain_id: Id;
3511
+ } & Partial<Record<CallbackType, Address[]>>>;
3512
+ type ConfigRulesPayload = SuccessPayload<ConfigRule[]> | ErrorPayload;
3513
+ type SuccessPayload<T> = {
3514
+ meta: {
3515
+ timestamp: string;
3516
+ checksum?: string;
3517
+ };
3518
+ cursor: string | null;
3519
+ data: T;
3520
+ };
3521
+ type ErrorPayload = {
3522
+ meta: {
3523
+ timestamp: string;
3524
+ checksum?: string;
3525
+ };
3526
+ error: {
3527
+ code: string;
3528
+ message: string;
3529
+ details?: unknown;
3530
+ };
3531
+ };
3155
3532
  declare namespace Client_d_exports {
3156
3533
  export { ClientConfig, GatekeeperClient, createHttpClient };
3157
3534
  }
3158
- type GatekeeperClient = RulesProvider & {
3535
+ type GatekeeperClient = {
3159
3536
  /** Validate offers and return the raw response payload. */validate: (body: unknown) => Promise<{
3160
3537
  statusCode: number;
3161
3538
  body: unknown;
3539
+ }>; /** Get configured rules for supported chains. */
3540
+ getConfigRules: (query?: {
3541
+ cursor?: string;
3542
+ limit?: number | string;
3543
+ types?: Array<ConfigRule["type"]> | ConfigRule["type"];
3544
+ }) => Promise<{
3545
+ statusCode: number;
3546
+ body: ConfigRulesPayload;
3162
3547
  }>; /** Validate offers and return decision results. */
3163
- isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>; /** Base URL for the gatekeeper service. */
3548
+ isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>; /** Resolve callback types for callback addresses. */
3549
+ getCallbackTypes: (request: CallbackTypesRequest) => Promise<CallbackTypesResponse>; /** Base URL for the gatekeeper service. */
3164
3550
  baseUrl: string;
3165
3551
  };
3166
3552
  type ClientConfig = {
3167
3553
  baseUrl: string;
3168
3554
  timeoutMs?: number;
3169
3555
  fetchFn?: typeof fetch;
3556
+ originSecret?: string;
3170
3557
  };
3171
3558
  /**
3172
3559
  * Create an HTTP client for a gatekeeper service.
@@ -3174,65 +3561,12 @@ type ClientConfig = {
3174
3561
  * @returns An HTTP-backed gatekeeper client. {@link GatekeeperClient}
3175
3562
  */
3176
3563
  declare function createHttpClient(config: ClientConfig): GatekeeperClient;
3177
- declare namespace GateConfig_d_exports {
3178
- export { CallbackConfig, GateConfig, assets, configs, getCallback, getCallbackAddresses, getCallbackType, getCallbackTypeAddresses };
3179
- }
3180
- type GateConfig = {
3181
- callbacks?: CallbackConfig[];
3182
- maturities?: MaturityType[];
3183
- };
3184
- type CallbackConfig = {
3185
- type: Type$1.BuyVaultV1Callback;
3186
- addresses: Address[];
3187
- vaultFactories: Address[];
3188
- } | {
3189
- type: Type$1.SellERC20Callback;
3190
- addresses: Address[];
3191
- } | {
3192
- type: Type$1.BuyWithEmptyCallback;
3193
- };
3194
- declare function getCallback(chain: Name, type: Type$1.BuyVaultV1Callback): Extract<CallbackConfig, {
3195
- type: Type$1.BuyVaultV1Callback;
3196
- }> | undefined;
3197
- declare function getCallback(chain: Name, type: Type$1.SellERC20Callback): Extract<CallbackConfig, {
3198
- type: Type$1.SellERC20Callback;
3199
- }> | undefined;
3200
- declare function getCallback(chain: Name, type: Type$1.BuyWithEmptyCallback): Extract<CallbackConfig, {
3201
- type: Type$1.BuyWithEmptyCallback;
3202
- }> | undefined;
3203
- declare function getCallback(chain: Name, type: Type$1): CallbackConfig | undefined;
3204
- /**
3205
- * Attempts to infer the configured callback type from a callback address on a chain.
3206
- * Skips the empty callback type as it does not carry addresses.
3207
- *
3208
- * @param chain - Chain name for which to infer the callback type
3209
- * @param address - Callback contract address
3210
- * @returns The callback type when found, otherwise undefined
3211
- */
3212
- declare function getCallbackType(chain: Name, address: Address): Type$1.BuyWithEmptyCallback | Type$1.BuyVaultV1Callback | Type$1.SellERC20Callback | undefined;
3213
- /**
3214
- * Returns the callback addresses for a given chain and callback type, if it exists.
3215
- * @param chain - Chain name for which to read the validation configuration
3216
- * @param type - Callback type to retrieve
3217
- * @returns The matching callback addresses or an empty array if not configured
3218
- */
3219
- declare function getCallbackTypeAddresses(chain: Name, type: Type$1): Address[];
3220
- /**
3221
- * Returns the list of allowed non-empty callback addresses for a chain.
3222
- *
3223
- * @param chain - Chain name
3224
- * @returns Array of allowed callback addresses (lowercased). Empty when none configured
3225
- */
3226
- declare const getCallbackAddresses: (chain: Name) => Address[];
3227
- declare const assets: Record<string, Address[]>;
3228
- declare const configs: Record<Name, GateConfig>;
3229
3564
  declare namespace Gatekeeper_d_exports {
3230
3565
  export { Gatekeeper, Rules, create };
3231
3566
  }
3232
3567
  type Rules = readonly Rule<Offer, string>[];
3233
3568
  type Gatekeeper = {
3234
3569
  isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>;
3235
- getRules: () => Promise<RuleInfo[]>;
3236
3570
  };
3237
3571
  type GatekeeperParameters = {
3238
3572
  rules: Rules;
@@ -3304,7 +3638,8 @@ declare function from(parameters: from.Parameters): from.ReturnType;
3304
3638
  declare namespace from {
3305
3639
  type Parameters = {
3306
3640
  /** The viem client to use. */client: WalletClient; /** The mempool address. */
3307
- mempoolAddress: Address; /** The block window to use for the mempool. Defaults to 100. */
3641
+ mempoolAddress: Address; /** The MorphoV2 contract address used for signature verification. */
3642
+ morphoAddress?: Address; /** The block window to use for the mempool. Defaults to 100. */
3308
3643
  blockWindow?: number;
3309
3644
  };
3310
3645
  type ReturnType = Client$1;
@@ -3489,5 +3824,5 @@ declare namespace index_d_exports$2 {
3489
3824
  export { BaseError, GlobalErrorType, Group_d_exports as Group, Random_d_exports as Random, ReorgError, Snake, time_d_exports as Time, atMostOneNonZero, batch, batchMulticall, fromSnakeCase$3 as fromSnakeCase, lazy, max$1 as max, min, poll, retry, stringifyBigint, toSnakeCase$1 as toSnakeCase, wait };
3490
3825
  }
3491
3826
  //#endregion
3492
- export { index_d_exports as Abi, Brand, BrandTypeId, Callback_d_exports as Callback, Chain_d_exports as Chain, ChainRegistry_d_exports as ChainRegistry, Collateral_d_exports as Collateral, Compute, ERC4626_d_exports as ERC4626, ErrorPayload, Errors_d_exports as Errors, Format_d_exports as Format, GateConfig_d_exports as GateConfig, Gatekeeper_d_exports as Gatekeeper, Client_d_exports as GatekeeperClient, LLTV_d_exports as LLTV, Liquidity_d_exports as Liquidity, Maturity_d_exports as Maturity, MempoolClient_d_exports as Mempool, Obligation_d_exports as Obligation, Offer_d_exports as Offer, Oracle_d_exports as Oracle, Position_d_exports as Position, Quote_d_exports as Quote, index_d_exports$1 as RouterApi, Client_d_exports$1 as RouterClient, RuleInfo, Rules_d_exports as Rules, RulesProvider, SuccessPayload, time_d_exports as Time, TradingFee_d_exports as TradingFee, Transfer_d_exports as Transfer, Tree_d_exports as Tree, index_d_exports$2 as Utils, ValidateOffersData, ValidateOffersIssues, ValidateOffersSuccess, Gate_d_exports as Validation, ValidationIssue, morphoRules };
3827
+ export { index_d_exports as Abi, Brand, BrandTypeId, Callback_d_exports as Callback, CallbackType, CallbackTypesRequest, CallbackTypesResponse, Chain_d_exports as Chain, ChainRegistry_d_exports as ChainRegistry, Collateral_d_exports as Collateral, Compute, ConfigRule, ConfigRulesPayload, ERC4626_d_exports as ERC4626, ErrorPayload, Errors_d_exports as Errors, Format_d_exports as Format, Gatekeeper_d_exports as Gatekeeper, Client_d_exports as GatekeeperClient, LLTV_d_exports as LLTV, Liquidity_d_exports as Liquidity, Maturity_d_exports as Maturity, MempoolClient_d_exports as Mempool, Obligation_d_exports as Obligation, Offer_d_exports as Offer, Oracle_d_exports as Oracle, Position_d_exports as Position, Quote_d_exports as Quote, index_d_exports$1 as RouterApi, Client_d_exports$1 as RouterClient, Rules_d_exports as Rules, SuccessPayload, time_d_exports as Time, TradingFee_d_exports as TradingFee, Transfer_d_exports as Transfer, Tree_d_exports as Tree, index_d_exports$2 as Utils, ValidateOffersData, ValidateOffersIssues, ValidateOffersSuccess, Gate_d_exports as Validation, ValidationIssue, morphoRules };
3493
3828
  //# sourceMappingURL=index.browser.d.mts.map