@morpho-dev/router 0.9.0 → 0.10.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.
@@ -31,9 +31,9 @@ declare const CollectorHealth: z.ZodObject<{
31
31
  updated_at: z.ZodNullable<z.ZodString>;
32
32
  lag: z.ZodNullable<z.ZodNumber>;
33
33
  status: z.ZodEnum<{
34
+ unknown: "unknown";
34
35
  live: "live";
35
36
  lagging: "lagging";
36
- unknown: "unknown";
37
37
  }>;
38
38
  initialized: z.ZodBoolean;
39
39
  }, z.core.$strip>;
@@ -44,9 +44,9 @@ declare const CollectorsHealthResponse: z.ZodArray<z.ZodObject<{
44
44
  updated_at: z.ZodNullable<z.ZodString>;
45
45
  lag: z.ZodNullable<z.ZodNumber>;
46
46
  status: z.ZodEnum<{
47
+ unknown: "unknown";
47
48
  live: "live";
48
49
  lagging: "lagging";
49
- unknown: "unknown";
50
50
  }>;
51
51
  initialized: z.ZodBoolean;
52
52
  }, z.core.$strip>>;
@@ -1414,7 +1414,7 @@ declare class ReorgError extends BaseError {
1414
1414
  constructor(blockNumber: number);
1415
1415
  }
1416
1416
  declare namespace Chain_d_exports {
1417
- export { Chain$1 as Chain, ChainId, Id, InvalidBatchSizeError, InvalidBlockRangeError, InvalidBlockWindowError, MissingBlockNumberError, Name, chainIds, chainNames, chains$1 as chains, getChain, getWhitelistedChains, streamLogs };
1417
+ export { Chain$1 as Chain, ChainId, Id, InvalidBatchSizeError, InvalidBlockRangeError, InvalidBlockWindowError, MissingBlockNumberError, Name, chainIds, chainNames, chains, getChain, getWhitelistedChains, streamLogs };
1418
1418
  }
1419
1419
  type Chain$1 = Compute<Omit<Chain<ChainFormatters, {
1420
1420
  morpho: ChainContract;
@@ -1455,7 +1455,7 @@ type Id = (typeof ChainId)[Uppercase<Name>];
1455
1455
  declare const chainIds: readonly Id[];
1456
1456
  declare function getChain(chainId: Id): Chain$1 | undefined;
1457
1457
  declare const getWhitelistedChains: () => Chain$1[];
1458
- declare const chains$1: Record<Lowercase<Name>, Chain$1>;
1458
+ declare const chains: Record<Lowercase<Name>, Chain$1>;
1459
1459
  declare function streamLogs<abiEvent extends AbiEvent | undefined = undefined>(parameters: {
1460
1460
  client: PublicClient;
1461
1461
  contractAddress?: Address;
@@ -1533,13 +1533,23 @@ declare class InvalidLLTVError extends BaseError {
1533
1533
  }
1534
1534
  declare const LLTVSchema: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
1535
1535
  declare namespace Collateral_d_exports {
1536
- export { Collateral, CollateralSchema, CollateralsSchema, from$13 as from, random$3 as random };
1536
+ export { Collateral, CollateralSchema, CollateralsSchema, abi$1 as abi, from$13 as from, random$3 as random };
1537
1537
  }
1538
1538
  type Collateral = {
1539
1539
  /** Asset being used as collateral. */asset: Address; /** Liquidation Loan-to-Value of the collateral. */
1540
1540
  lltv: LLTV; /** Oracle contract used to price the collateral. */
1541
1541
  oracle: Address;
1542
1542
  };
1543
+ declare const abi$1: readonly [{
1544
+ readonly type: "address";
1545
+ readonly name: "token";
1546
+ }, {
1547
+ readonly type: "uint256";
1548
+ readonly name: "lltv";
1549
+ }, {
1550
+ readonly type: "address";
1551
+ readonly name: "oracle";
1552
+ }];
1543
1553
  declare const CollateralSchema: z$1.ZodObject<{
1544
1554
  asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1545
1555
  oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
@@ -1653,102 +1663,33 @@ declare class DenominatorIsZeroError extends BaseError {
1653
1663
  readonly name = "ERC4626.DenominatorIsZeroError";
1654
1664
  constructor();
1655
1665
  }
1656
- declare namespace Liquidity_d_exports {
1657
- export { LiquidityLink, LiquidityPool, OfferLiquidityPool, calculateMaxDebt, generateAllowancePoolId, generateBalancePoolId, generateDebtPoolId, generateMarketLiquidityPoolId, generateObligationCollateralPoolId, generateUserVaultPositionPoolId, generateVaultPositionPoolId };
1666
+ declare namespace Format_d_exports {
1667
+ export { Snake, fromSnakeCase$3 as fromSnakeCase, stringifyBigint, toSnakeCase$1 as toSnakeCase };
1658
1668
  }
1669
+ /** The snake case representation of a type with bigint values stringified. */
1670
+ type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
1671
+ /** Make arrays/tuples and object props mutable, deeply. */
1672
+ type DeepMutable<T> = T extends ((...args: unknown[]) => unknown) ? T : T extends number | string | boolean | symbol | bigint | null | undefined ? T : T extends readonly [...infer R] ? { -readonly [K in keyof R]: DeepMutable<R[K]> } : T extends ReadonlyArray<infer U> ? Array<DeepMutable<U>> : T extends object ? { -readonly [K in keyof T]: DeepMutable<T[K]> } : T;
1673
+ /** Stringifies bigint values to strings and preserves branded primitives. */
1674
+ type StringifiedBigint<T> = [T] extends [bigint] ? string : [T] extends [`0x${string}`] ? string : T extends number ? T : T extends string ? T : T extends boolean ? T : T extends symbol ? T : T extends null | undefined ? T : T extends readonly (infer U)[] ? readonly StringifiedBigint<U>[] : T extends object ? { [K in keyof T]: StringifiedBigint<T[K]> } : T;
1675
+ /** Key remapping that also preserves branded primitives. */
1676
+ type SnakeKeys<T> = T extends readonly (infer U)[] ? readonly SnakeKeys<U>[] : T extends number | string | boolean | symbol | null | undefined ? T : T extends object ? { [K in keyof T as ToSnakeCase<Extract<K, string>>]: SnakeKeys<T[K]> } : T;
1677
+ type ToSnakeCase<S extends string> = S extends `${infer Head}${infer Tail}` ? Tail extends Uncapitalize<Tail> ? `${Lowercase<Head>}${ToSnakeCase<Tail>}` : `${Lowercase<Head>}_${ToSnakeCase<Uncapitalize<Tail>>}` : S;
1659
1678
  /**
1660
- * Represents a liquidity pool with a unique ID and amount.
1661
- */
1662
- type LiquidityPool = {
1663
- id: string;
1664
- amount: bigint;
1665
- };
1666
- /**
1667
- * Represents a hierarchical relationship between two liquidity pools.
1668
- */
1669
- type LiquidityLink = {
1670
- parentPoolId: string;
1671
- childPoolId: string;
1672
- priority: number;
1673
- };
1674
- /**
1675
- * Represents the connection between an offer and its liquidity pools.
1676
- */
1677
- type OfferLiquidityPool = {
1678
- offerHash: Hex;
1679
- poolId: string;
1680
- /**
1681
- * The available capacity/liquidity from this pool for this offer.
1682
- * Matches allowance amount from pool below.
1683
- */
1684
- amount: bigint;
1685
- };
1686
- /**
1687
- * Calculate maximum debt capacity from collateral amount.
1688
- * @param amount - Collateral amount
1689
- * @param oraclePrice - Oracle price (scaled to 36 decimals)
1690
- * @param lltv - Loan-to-value ratio (scaled to 18 decimals)
1691
- * @returns Maximum debt capacity
1692
- */
1693
- declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
1694
- /**
1695
- * Generate pool ID for balance pools.
1696
- */
1697
- declare function generateBalancePoolId(parameters: {
1698
- user: Address;
1699
- chainId: Id;
1700
- token: Address;
1701
- }): string;
1702
- /**
1703
- * Generate pool ID for allowance pools.
1704
- */
1705
- declare function generateAllowancePoolId(parameters: {
1706
- user: Address;
1707
- chainId: Id;
1708
- token: Address;
1709
- }): string;
1710
- /**
1711
- * Generate pool ID for obligation collateral pools.
1712
- * Obligation collateral pools represent collateral already deposited in the obligation.
1713
- * These pools are shared across all offers with the same obligation.
1714
- */
1715
- declare function generateObligationCollateralPoolId(parameters: {
1716
- user: Address;
1717
- chainId: Id;
1718
- obligationId: Hex;
1719
- token: Address;
1720
- }): string;
1721
- /**
1722
- * Generate pool ID for debt pools.
1723
- */
1724
- declare function generateDebtPoolId(parameters: {
1725
- user: Address;
1726
- chainId: Id;
1727
- obligationId: Hex;
1728
- }): string;
1729
- /**
1730
- * Generate pool ID for user position in a vault.
1731
- */
1732
- declare function generateUserVaultPositionPoolId(parameters: {
1733
- user: Address;
1734
- chainId: Id;
1735
- vault: Address;
1736
- }): string;
1737
- /**
1738
- * Generate pool ID for vault position in a market.
1679
+ * Formats object keys to snake case.
1680
+ * Preserves ethereum addresses as is.
1681
+ * Converts ethereum addresses to checksummed if used as values.
1682
+ * Stringifies bigint values to strings.
1739
1683
  */
1740
- declare function generateVaultPositionPoolId(parameters: {
1741
- vault: Address;
1742
- chainId: Id;
1743
- marketId: string;
1744
- }): string;
1684
+ declare function toSnakeCase$1<T>(obj: T): Snake<T>;
1745
1685
  /**
1746
- * Generate pool ID for market total liquidity.
1686
+ * Formats a snake case object to its camel case type.
1687
+ * Preserves ethereum addresses as is.
1688
+ * Converts checksummed ethereum addresses to lowercase if used as values.
1689
+ * @warning Does not unstringify bigint values.
1747
1690
  */
1748
- declare function generateMarketLiquidityPoolId(parameters: {
1749
- chainId: Id;
1750
- marketId: string;
1751
- }): string;
1691
+ declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
1692
+ declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
1752
1693
  declare namespace Maturity_d_exports {
1753
1694
  export { InvalidDateError, InvalidFormatError, InvalidOptionError, Maturity, MaturityOptions, MaturitySchema, MaturityType, from$12 as from };
1754
1695
  }
@@ -1797,44 +1738,15 @@ declare class InvalidOptionError extends BaseError {
1797
1738
  readonly name = "Maturity.InvalidOptionError";
1798
1739
  constructor(input: string);
1799
1740
  }
1800
- declare namespace Format_d_exports {
1801
- export { Snake, fromSnakeCase$3 as fromSnakeCase, stringifyBigint, toSnakeCase$1 as toSnakeCase };
1802
- }
1803
- /** The snake case representation of a type with bigint values stringified. */
1804
- type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
1805
- /** Make arrays/tuples and object props mutable, deeply. */
1806
- type DeepMutable<T> = T extends ((...args: unknown[]) => unknown) ? T : T extends number | string | boolean | symbol | bigint | null | undefined ? T : T extends readonly [...infer R] ? { -readonly [K in keyof R]: DeepMutable<R[K]> } : T extends ReadonlyArray<infer U> ? Array<DeepMutable<U>> : T extends object ? { -readonly [K in keyof T]: DeepMutable<T[K]> } : T;
1807
- /** Stringifies bigint values to strings and preserves branded primitives. */
1808
- type StringifiedBigint<T> = [T] extends [bigint] ? string : [T] extends [`0x${string}`] ? string : T extends number ? T : T extends string ? T : T extends boolean ? T : T extends symbol ? T : T extends null | undefined ? T : T extends readonly (infer U)[] ? readonly StringifiedBigint<U>[] : T extends object ? { [K in keyof T]: StringifiedBigint<T[K]> } : T;
1809
- /** Key remapping that also preserves branded primitives. */
1810
- type SnakeKeys<T> = T extends readonly (infer U)[] ? readonly SnakeKeys<U>[] : T extends number | string | boolean | symbol | null | undefined ? T : T extends object ? { [K in keyof T as ToSnakeCase<Extract<K, string>>]: SnakeKeys<T[K]> } : T;
1811
- type ToSnakeCase<S extends string> = S extends `${infer Head}${infer Tail}` ? Tail extends Uncapitalize<Tail> ? `${Lowercase<Head>}${ToSnakeCase<Tail>}` : `${Lowercase<Head>}_${ToSnakeCase<Uncapitalize<Tail>>}` : S;
1812
- /**
1813
- * Formats object keys to snake case.
1814
- * Preserves ethereum addresses as is.
1815
- * Converts ethereum addresses to checksummed if used as values.
1816
- * Stringifies bigint values to strings.
1817
- */
1818
- declare function toSnakeCase$1<T>(obj: T): Snake<T>;
1819
- /**
1820
- * Formats a snake case object to its camel case type.
1821
- * Preserves ethereum addresses as is.
1822
- * Converts checksummed ethereum addresses to lowercase if used as values.
1823
- * @warning Does not unstringify bigint values.
1824
- */
1825
- declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
1826
- declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
1827
1741
  declare namespace Obligation_d_exports {
1828
- export { CollateralsAreNotSortedError, InvalidObligationError, Obligation, ObligationSchema, from$11 as from, fromOffer$1 as fromOffer, fromSnakeCase$2 as fromSnakeCase, id, random$2 as random };
1742
+ export { CollateralsAreNotSortedError, InvalidObligationError, Obligation$1 as Obligation, ObligationSchema, abi, from$11 as from, fromOffer$1 as fromOffer, fromSnakeCase$2 as fromSnakeCase, key$1 as key, random$2 as random, tupleAbi };
1829
1743
  }
1830
- type Obligation = {
1831
- /** The chain id where the liquidity for this obligation is located. */chainId: Id; /** The token that is being borrowed for this obligation. */
1832
- loanToken: Address; /** The exact set of collaterals required to borrow the loan token. */
1744
+ type Obligation$1 = {
1745
+ /** The token that is being borrowed for this obligation. */loanToken: Address; /** The exact set of collaterals required to borrow the loan token. */
1833
1746
  collaterals: Collateral[]; /** The maturity of the obligation. */
1834
1747
  maturity: Maturity;
1835
1748
  };
1836
1749
  declare const ObligationSchema: z$1.ZodObject<{
1837
- chainId: z$1.ZodNumber;
1838
1750
  loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1839
1751
  collaterals: z$1.ZodArray<z$1.ZodObject<{
1840
1752
  asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
@@ -1843,6 +1755,49 @@ declare const ObligationSchema: z$1.ZodObject<{
1843
1755
  }, z$1.core.$strip>>;
1844
1756
  maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
1845
1757
  }, z$1.core.$strip>;
1758
+ declare const abi: readonly [{
1759
+ readonly type: "address";
1760
+ readonly name: "loanToken";
1761
+ }, {
1762
+ readonly type: "tuple[]";
1763
+ readonly name: "collaterals";
1764
+ readonly components: readonly [{
1765
+ readonly type: "address";
1766
+ readonly name: "token";
1767
+ }, {
1768
+ readonly type: "uint256";
1769
+ readonly name: "lltv";
1770
+ }, {
1771
+ readonly type: "address";
1772
+ readonly name: "oracle";
1773
+ }];
1774
+ }, {
1775
+ readonly type: "uint256";
1776
+ readonly name: "maturity";
1777
+ }];
1778
+ declare const tupleAbi: readonly [{
1779
+ readonly type: "tuple";
1780
+ readonly components: readonly [{
1781
+ readonly type: "address";
1782
+ readonly name: "loanToken";
1783
+ }, {
1784
+ readonly type: "tuple[]";
1785
+ readonly name: "collaterals";
1786
+ readonly components: readonly [{
1787
+ readonly type: "address";
1788
+ readonly name: "token";
1789
+ }, {
1790
+ readonly type: "uint256";
1791
+ readonly name: "lltv";
1792
+ }, {
1793
+ readonly type: "address";
1794
+ readonly name: "oracle";
1795
+ }];
1796
+ }, {
1797
+ readonly type: "uint256";
1798
+ readonly name: "maturity";
1799
+ }];
1800
+ }];
1846
1801
  /**
1847
1802
  * Creates an obligation from the given parameters.
1848
1803
  * @constructor
@@ -1853,7 +1808,6 @@ declare const ObligationSchema: z$1.ZodObject<{
1853
1808
  * @example
1854
1809
  * ```ts
1855
1810
  * const obligation = Obligation.from({
1856
- * chainId: 1,
1857
1811
  * loanToken: privateKeyToAccount(generatePrivateKey()).address,
1858
1812
  * collaterals: [
1859
1813
  * Collateral.from({
@@ -1869,12 +1823,11 @@ declare const ObligationSchema: z$1.ZodObject<{
1869
1823
  declare function from$11(parameters: from$11.Parameters): from$11.ReturnType;
1870
1824
  declare namespace from$11 {
1871
1825
  type Parameters = {
1872
- /** The chain id where the liquidity for this obligation is located. */chainId: number; /** The token that is being borrowed for this obligation. */
1873
- loanToken: Address; /** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
1826
+ /** The token that is being borrowed for this obligation. */loanToken: Address; /** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
1874
1827
  collaterals: from$13.Parameters[] | readonly from$13.Parameters[]; /** The maturity of the obligation. */
1875
1828
  maturity: from$12.Parameters;
1876
1829
  };
1877
- type ReturnType = Obligation;
1830
+ type ReturnType = Obligation$1;
1878
1831
  type ErrorType = InvalidObligationError;
1879
1832
  }
1880
1833
  /**
@@ -1885,30 +1838,27 @@ declare namespace from$11 {
1885
1838
  */
1886
1839
  declare function fromSnakeCase$2(input: fromSnakeCase$2.Parameters): fromSnakeCase$2.ReturnType;
1887
1840
  declare namespace fromSnakeCase$2 {
1888
- type Parameters = Snake<Omit<Obligation, "chainId"> & {
1889
- chainId: number;
1890
- }>;
1891
- type ReturnType = Obligation;
1841
+ type Parameters = Snake<Obligation$1>;
1842
+ type ReturnType = Obligation$1;
1892
1843
  type ErrorType = InvalidObligationError;
1893
1844
  }
1894
1845
  /**
1895
- * Calculates the obligation id based on the smart contract's Obligation struct.
1896
- * The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals, maturity)).
1846
+ * Calculates a canonical key for an obligation payload.
1847
+ * The key is computed as keccak256(abi.encode(loanToken, collaterals, maturity)).
1897
1848
  * @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
1898
- * @param parameters - {@link id.Parameters}
1899
- * @returns The obligation id as a 32-byte hex string. {@link id.ReturnType}
1849
+ * @param parameters - {@link key.Parameters}
1850
+ * @returns The obligation key as a 32-byte hex string. {@link key.ReturnType}
1900
1851
  *
1901
1852
  * @example
1902
1853
  * ```ts
1903
1854
  * const obligation = Obligation.random();
1904
- * const id = Obligation.id(obligation);
1905
- * console.log(id); // 0x1234567890123456789012345678901234567890123456789012345678901234
1855
+ * const key = Obligation.key(obligation);
1856
+ * console.log(key); // 0x1234567890123456789012345678901234567890123456789012345678901234
1906
1857
  * ```
1907
1858
  */
1908
- declare function id(parameters: id.Parameters): id.ReturnType;
1909
- declare namespace id {
1859
+ declare function key$1(parameters: key$1.Parameters): key$1.ReturnType;
1860
+ declare namespace key$1 {
1910
1861
  type Parameters = {
1911
- chainId: number;
1912
1862
  loanToken: Address;
1913
1863
  collaterals: {
1914
1864
  asset: Address;
@@ -1931,7 +1881,7 @@ declare namespace id {
1931
1881
  */
1932
1882
  declare function random$2(): random$2.ReturnType;
1933
1883
  declare namespace random$2 {
1934
- type ReturnType = Obligation;
1884
+ type ReturnType = Obligation$1;
1935
1885
  }
1936
1886
  /**
1937
1887
  * Creates an obligation from an offer.
@@ -1943,7 +1893,7 @@ declare namespace random$2 {
1943
1893
  declare function fromOffer$1(offer: Offer): fromOffer$1.ReturnType;
1944
1894
  declare namespace fromOffer$1 {
1945
1895
  type Parameters = Offer;
1946
- type ReturnType = Obligation;
1896
+ type ReturnType = Obligation$1;
1947
1897
  }
1948
1898
  declare class InvalidObligationError extends BaseError<z$1.ZodError | Error> {
1949
1899
  readonly name = "Obligation.InvalidObligationError";
@@ -1953,8 +1903,135 @@ declare class CollateralsAreNotSortedError extends BaseError {
1953
1903
  readonly name = "Obligation.CollateralsAreNotSortedError";
1954
1904
  constructor();
1955
1905
  }
1906
+ declare namespace Id_d_exports {
1907
+ export { Obligation, creationCode, toId };
1908
+ }
1909
+ type Obligation = Obligation$1;
1910
+ /**
1911
+ * Builds the same creation code as `IdLib.creationCode` in Solidity.
1912
+ *
1913
+ * Layout: `prefix (11 bytes) + chainId (32 bytes) + morphoV2 (20 bytes) + abi.encode(obligation)`.
1914
+ *
1915
+ * @param parameters - {@link creationCode.Parameters}
1916
+ * @returns The CREATE2 init code bytes. {@link creationCode.ReturnType}
1917
+ */
1918
+ declare function creationCode(parameters: creationCode.Parameters): creationCode.ReturnType;
1919
+ declare namespace creationCode {
1920
+ type Parameters = {
1921
+ obligation: Obligation;
1922
+ chainId: Id;
1923
+ morphoV2: Address;
1924
+ };
1925
+ type ReturnType = Hex;
1926
+ }
1927
+ /**
1928
+ * Computes the same id as `IdLib.toId` in Solidity.
1929
+ * @param parameters - {@link toId.Parameters}
1930
+ * @returns The obligation id. {@link toId.ReturnType}
1931
+ */
1932
+ declare function toId(parameters: toId.Parameters): toId.ReturnType;
1933
+ declare namespace toId {
1934
+ type Parameters = creationCode.Parameters;
1935
+ type ReturnType = Hex;
1936
+ }
1937
+ declare namespace Liquidity_d_exports {
1938
+ export { LiquidityLink, LiquidityPool, OfferLiquidityPool, calculateMaxDebt, generateAllowancePoolId, generateBalancePoolId, generateDebtPoolId, generateMarketLiquidityPoolId, generateObligationCollateralPoolId, generateUserVaultPositionPoolId, generateVaultPositionPoolId };
1939
+ }
1940
+ /**
1941
+ * Represents a liquidity pool with a unique ID and amount.
1942
+ */
1943
+ type LiquidityPool = {
1944
+ id: string;
1945
+ amount: bigint;
1946
+ };
1947
+ /**
1948
+ * Represents a hierarchical relationship between two liquidity pools.
1949
+ */
1950
+ type LiquidityLink = {
1951
+ parentPoolId: string;
1952
+ childPoolId: string;
1953
+ priority: number;
1954
+ };
1955
+ /**
1956
+ * Represents the connection between an offer and its liquidity pools.
1957
+ */
1958
+ type OfferLiquidityPool = {
1959
+ offerHash: Hex;
1960
+ poolId: string;
1961
+ /**
1962
+ * The available capacity/liquidity from this pool for this offer.
1963
+ * Matches allowance amount from pool below.
1964
+ */
1965
+ amount: bigint;
1966
+ };
1967
+ /**
1968
+ * Calculate maximum debt capacity from collateral amount.
1969
+ * @param amount - Collateral amount
1970
+ * @param oraclePrice - Oracle price (scaled to 36 decimals)
1971
+ * @param lltv - Loan-to-value ratio (scaled to 18 decimals)
1972
+ * @returns Maximum debt capacity
1973
+ */
1974
+ declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
1975
+ /**
1976
+ * Generate pool ID for balance pools.
1977
+ */
1978
+ declare function generateBalancePoolId(parameters: {
1979
+ user: Address;
1980
+ chainId: Id;
1981
+ token: Address;
1982
+ }): string;
1983
+ /**
1984
+ * Generate pool ID for allowance pools.
1985
+ */
1986
+ declare function generateAllowancePoolId(parameters: {
1987
+ user: Address;
1988
+ chainId: Id;
1989
+ token: Address;
1990
+ }): string;
1991
+ /**
1992
+ * Generate pool ID for obligation collateral pools.
1993
+ * Obligation collateral pools represent collateral already deposited in the obligation.
1994
+ * These pools are shared across all offers with the same obligation.
1995
+ */
1996
+ declare function generateObligationCollateralPoolId(parameters: {
1997
+ user: Address;
1998
+ chainId: Id;
1999
+ obligationId: Hex;
2000
+ token: Address;
2001
+ }): string;
2002
+ /**
2003
+ * Generate pool ID for debt pools.
2004
+ */
2005
+ declare function generateDebtPoolId(parameters: {
2006
+ user: Address;
2007
+ chainId: Id;
2008
+ obligationId: Hex;
2009
+ }): string;
2010
+ /**
2011
+ * Generate pool ID for user position in a vault.
2012
+ */
2013
+ declare function generateUserVaultPositionPoolId(parameters: {
2014
+ user: Address;
2015
+ chainId: Id;
2016
+ vault: Address;
2017
+ }): string;
2018
+ /**
2019
+ * Generate pool ID for vault position in a market.
2020
+ */
2021
+ declare function generateVaultPositionPoolId(parameters: {
2022
+ vault: Address;
2023
+ chainId: Id;
2024
+ marketId: string;
2025
+ }): string;
2026
+ /**
2027
+ * Generate pool ID for market total liquidity.
2028
+ */
2029
+ declare function generateMarketLiquidityPoolId(parameters: {
2030
+ chainId: Id;
2031
+ marketId: string;
2032
+ }): string;
1956
2033
  declare namespace Offer_d_exports {
1957
- 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, takeEvent, toSnakeCase, types };
2034
+ export { InvalidOfferError, Offer, OfferConsumed, OfferInput, OfferSchema, RandomConfig, Status, Validation, consumedEvent, decode$1 as decode, encode$1 as encode, from$10 as from, fromSnakeCase$1 as fromSnakeCase, hash, liquidateEvent, obligationId, random$1 as random, repayEvent, serialize, supplyCollateralEvent, takeEvent, toSnakeCase, withdrawCollateralEvent };
1958
2035
  }
1959
2036
  type Offer = {
1960
2037
  /** The address that made the offer. */readonly maker: Address; /** The amount of assets offered. Mutually exclusive with obligationUnits and obligationShares. */
@@ -1967,8 +2044,7 @@ type Offer = {
1967
2044
  readonly start: number; /** The group. Used for OCO (One-Cancelled-Other) mechanism. */
1968
2045
  readonly group: Hex; /** The session. Used for session-based offer management. */
1969
2046
  readonly session: Hex; /** The side of the offer. `true` for buy, `false` for sell. */
1970
- readonly buy: boolean; /** The chain id where the liquidity for this offer is located. */
1971
- readonly chainId: Id; /** The token that is being borrowed. */
2047
+ readonly buy: boolean; /** The token that is being borrowed. */
1972
2048
  readonly loanToken: Address; /** The exact set of collaterals required to borrow the loan token. */
1973
2049
  readonly collaterals: readonly Collateral[]; /** The optional callback data to retrieve the maker funds. */
1974
2050
  readonly callback: {
@@ -1983,6 +2059,7 @@ declare enum Status {
1983
2059
  }
1984
2060
  type Validation = {
1985
2061
  offerHash: Hex;
2062
+ obligationId: Hex;
1986
2063
  status: Status;
1987
2064
  };
1988
2065
  declare const OfferSchema: () => z$1.ZodObject<{
@@ -1997,7 +2074,6 @@ declare const OfferSchema: () => z$1.ZodObject<{
1997
2074
  group: z$1.ZodPipe<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber, z$1.ZodBigInt]>, z$1.ZodTransform<`0x${string}`, string | number | bigint>>;
1998
2075
  session: z$1.ZodPipe<z$1.ZodDefault<z$1.ZodOptional<z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber, z$1.ZodBigInt]>>>, z$1.ZodTransform<`0x${string}`, string | number | bigint>>;
1999
2076
  buy: z$1.ZodBoolean;
2000
- chainId: z$1.ZodNumber;
2001
2077
  loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
2002
2078
  collaterals: z$1.ZodArray<z$1.ZodObject<{
2003
2079
  asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
@@ -2021,8 +2097,7 @@ declare const OfferSchema: () => z$1.ZodObject<{
2021
2097
  *
2022
2098
  * All values validated to be non-negative and within bytes32 range.
2023
2099
  */
2024
- type OfferInput = Compute<Omit<Offer, "chainId" | "group" | "session" | "obligationUnits" | "obligationShares" | "receiverIfMakerIsSeller"> & {
2025
- chainId: number;
2100
+ type OfferInput = Compute<Omit<Offer, "group" | "session" | "obligationUnits" | "obligationShares" | "receiverIfMakerIsSeller"> & {
2026
2101
  group: Hex | bigint | number | string; /** Optional: defaults to zero bytes32. */
2027
2102
  session?: Hex | bigint | number | string; /** Optional: defaults to 0n. Mutually exclusive with assets and obligationShares. */
2028
2103
  obligationUnits?: bigint; /** Optional: defaults to 0n. Mutually exclusive with assets and obligationUnits. */
@@ -2074,7 +2149,6 @@ declare const serialize: (offer: Offer) => {
2074
2149
  group: `0x${string}`;
2075
2150
  session: `0x${string}`;
2076
2151
  buy: boolean;
2077
- chainId: Id;
2078
2152
  loanToken: `0x${string}`;
2079
2153
  collaterals: {
2080
2154
  asset: `0x${string}`;
@@ -2089,7 +2163,6 @@ declare const serialize: (offer: Offer) => {
2089
2163
  hash: `0x${string}`;
2090
2164
  };
2091
2165
  type RandomConfig = {
2092
- chains?: Chain$1[];
2093
2166
  loanTokens?: Address[];
2094
2167
  collateralTokens?: Address[];
2095
2168
  assetsDecimals?: Record<Address, number>;
@@ -2119,96 +2192,28 @@ type RandomConfig = {
2119
2192
  */
2120
2193
  declare function random$1(config?: RandomConfig): Offer;
2121
2194
  /**
2122
- * Creates an EIP-712 domain object.
2123
- * @param chainId - The chain ID.
2124
- * @returns The EIP-712 domain object.
2125
- */
2126
- declare const domain: (chainId: number) => {
2127
- chainId: bigint;
2128
- verifyingContract: "0x0000000000000000000000000000000000000000";
2129
- };
2130
- /**
2131
- * The EIP-712 types for the offer.
2132
- * @warning The ordering of the types should NEVER be changed. The offer hash is computed based on the order of the types.
2133
- * @returns The EIP-712 types.
2195
+ * Computes the canonical chain-agnostic offer hash.
2196
+ * The hash is `keccak256(abi.encode(offer))` using {@link encode}.
2197
+ *
2198
+ * @param offer - Offer payload to hash.
2199
+ * @returns 32-byte offer hash.
2134
2200
  */
2135
- declare const types: {
2136
- readonly EIP712Domain: readonly [{
2137
- readonly name: "chainId";
2138
- readonly type: "uint256";
2139
- }, {
2140
- readonly name: "verifyingContract";
2141
- readonly type: "address";
2142
- }];
2143
- readonly Offer: readonly [{
2144
- readonly name: "maker";
2145
- readonly type: "address";
2146
- }, {
2147
- readonly name: "assets";
2148
- readonly type: "uint256";
2149
- }, {
2150
- readonly name: "obligationUnits";
2151
- readonly type: "uint256";
2152
- }, {
2153
- readonly name: "obligationShares";
2154
- readonly type: "uint256";
2155
- }, {
2156
- readonly name: "tick";
2157
- readonly type: "uint256";
2158
- }, {
2159
- readonly name: "maturity";
2160
- readonly type: "uint256";
2161
- }, {
2162
- readonly name: "expiry";
2163
- readonly type: "uint256";
2164
- }, {
2165
- readonly name: "group";
2166
- readonly type: "bytes32";
2167
- }, {
2168
- readonly name: "session";
2169
- readonly type: "bytes32";
2170
- }, {
2171
- readonly name: "buy";
2172
- readonly type: "bool";
2173
- }, {
2174
- readonly name: "loanToken";
2175
- readonly type: "address";
2176
- }, {
2177
- readonly name: "collaterals";
2178
- readonly type: "Collateral[]";
2179
- }, {
2180
- readonly name: "callback";
2181
- readonly type: "Callback";
2182
- }, {
2183
- readonly name: "receiverIfMakerIsSeller";
2184
- readonly type: "address";
2185
- }];
2186
- readonly Collateral: readonly [{
2187
- readonly name: "asset";
2188
- readonly type: "address";
2189
- }, {
2190
- readonly name: "oracle";
2191
- readonly type: "address";
2192
- }, {
2193
- readonly name: "lltv";
2194
- readonly type: "uint256";
2195
- }];
2196
- readonly Callback: readonly [{
2197
- readonly name: "address";
2198
- readonly type: "address";
2199
- }, {
2200
- readonly name: "data";
2201
- readonly type: "bytes";
2202
- }];
2203
- };
2204
2201
  declare function hash(offer: Offer): Hex;
2205
2202
  /**
2206
- * Calculates the obligation id for an offer based on the smart contract's Obligation struct.
2207
- * The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals (sorted by token address), maturity)).
2203
+ * Calculates the onchain obligation id for an offer.
2204
+ * The id is computed with {@link Id.toId}.
2208
2205
  * @param offer - The offer to calculate the obligation id for.
2206
+ * @param parameters - The chain context used by the onchain id function.
2209
2207
  * @returns The obligation id as a 32-byte hex string.
2210
2208
  */
2211
- declare function obligationId(offer: Offer): Hex;
2209
+ declare function obligationId(offer: Offer, parameters: obligationId.Parameters): obligationId.ReturnType;
2210
+ declare namespace obligationId {
2211
+ type Parameters = {
2212
+ chainId: Id;
2213
+ morphoV2: Address;
2214
+ };
2215
+ type ReturnType = Hex;
2216
+ }
2212
2217
  declare function encode$1(offer: Offer): `0x${string}`;
2213
2218
  declare function decode$1(data: Hex): Offer;
2214
2219
  type OfferConsumed = {
@@ -2322,6 +2327,160 @@ declare const consumedEvent: {
2322
2327
  }];
2323
2328
  readonly anonymous: false;
2324
2329
  };
2330
+ /**
2331
+ * ABI for the Repay event emitted by the MorphoV2 contract.
2332
+ */
2333
+ declare const repayEvent: {
2334
+ readonly type: "event";
2335
+ readonly name: "Repay";
2336
+ readonly inputs: readonly [{
2337
+ readonly name: "caller";
2338
+ readonly type: "address";
2339
+ readonly indexed: true;
2340
+ readonly internalType: "address";
2341
+ }, {
2342
+ readonly name: "id";
2343
+ readonly type: "bytes32";
2344
+ readonly indexed: true;
2345
+ readonly internalType: "bytes32";
2346
+ }, {
2347
+ readonly name: "obligationUnits";
2348
+ readonly type: "uint256";
2349
+ readonly indexed: false;
2350
+ readonly internalType: "uint256";
2351
+ }, {
2352
+ readonly name: "onBehalf";
2353
+ readonly type: "address";
2354
+ readonly indexed: true;
2355
+ readonly internalType: "address";
2356
+ }];
2357
+ readonly anonymous: false;
2358
+ };
2359
+ /**
2360
+ * ABI for the Liquidate event emitted by the MorphoV2 contract.
2361
+ */
2362
+ declare const liquidateEvent: {
2363
+ readonly type: "event";
2364
+ readonly name: "Liquidate";
2365
+ readonly inputs: readonly [{
2366
+ readonly name: "caller";
2367
+ readonly type: "address";
2368
+ readonly indexed: true;
2369
+ readonly internalType: "address";
2370
+ }, {
2371
+ readonly name: "id";
2372
+ readonly type: "bytes32";
2373
+ readonly indexed: true;
2374
+ readonly internalType: "bytes32";
2375
+ }, {
2376
+ readonly name: "seizures";
2377
+ readonly type: "tuple[]";
2378
+ readonly indexed: false;
2379
+ readonly internalType: "struct IMorphoV2.Seizure[]";
2380
+ readonly components: readonly [{
2381
+ readonly name: "collateralIndex";
2382
+ readonly type: "uint256";
2383
+ readonly internalType: "uint256";
2384
+ }, {
2385
+ readonly name: "repaid";
2386
+ readonly type: "uint256";
2387
+ readonly internalType: "uint256";
2388
+ }, {
2389
+ readonly name: "seized";
2390
+ readonly type: "uint256";
2391
+ readonly internalType: "uint256";
2392
+ }];
2393
+ }, {
2394
+ readonly name: "borrower";
2395
+ readonly type: "address";
2396
+ readonly indexed: true;
2397
+ readonly internalType: "address";
2398
+ }, {
2399
+ readonly name: "totalRepaid";
2400
+ readonly type: "uint256";
2401
+ readonly indexed: false;
2402
+ readonly internalType: "uint256";
2403
+ }, {
2404
+ readonly name: "badDebt";
2405
+ readonly type: "uint256";
2406
+ readonly indexed: false;
2407
+ readonly internalType: "uint256";
2408
+ }];
2409
+ readonly anonymous: false;
2410
+ };
2411
+ /**
2412
+ * ABI for the SupplyCollateral event emitted by the MorphoV2 contract.
2413
+ */
2414
+ declare const supplyCollateralEvent: {
2415
+ readonly type: "event";
2416
+ readonly name: "SupplyCollateral";
2417
+ readonly inputs: readonly [{
2418
+ readonly name: "caller";
2419
+ readonly type: "address";
2420
+ readonly indexed: false;
2421
+ readonly internalType: "address";
2422
+ }, {
2423
+ readonly name: "id";
2424
+ readonly type: "bytes32";
2425
+ readonly indexed: true;
2426
+ readonly internalType: "bytes32";
2427
+ }, {
2428
+ readonly name: "collateral";
2429
+ readonly type: "address";
2430
+ readonly indexed: true;
2431
+ readonly internalType: "address";
2432
+ }, {
2433
+ readonly name: "assets";
2434
+ readonly type: "uint256";
2435
+ readonly indexed: false;
2436
+ readonly internalType: "uint256";
2437
+ }, {
2438
+ readonly name: "onBehalf";
2439
+ readonly type: "address";
2440
+ readonly indexed: true;
2441
+ readonly internalType: "address";
2442
+ }];
2443
+ readonly anonymous: false;
2444
+ };
2445
+ /**
2446
+ * ABI for the WithdrawCollateral event emitted by the MorphoV2 contract.
2447
+ */
2448
+ declare const withdrawCollateralEvent: {
2449
+ readonly type: "event";
2450
+ readonly name: "WithdrawCollateral";
2451
+ readonly inputs: readonly [{
2452
+ readonly name: "caller";
2453
+ readonly type: "address";
2454
+ readonly indexed: false;
2455
+ readonly internalType: "address";
2456
+ }, {
2457
+ readonly name: "id";
2458
+ readonly type: "bytes32";
2459
+ readonly indexed: true;
2460
+ readonly internalType: "bytes32";
2461
+ }, {
2462
+ readonly name: "collateral";
2463
+ readonly type: "address";
2464
+ readonly indexed: true;
2465
+ readonly internalType: "address";
2466
+ }, {
2467
+ readonly name: "assets";
2468
+ readonly type: "uint256";
2469
+ readonly indexed: false;
2470
+ readonly internalType: "uint256";
2471
+ }, {
2472
+ readonly name: "onBehalf";
2473
+ readonly type: "address";
2474
+ readonly indexed: true;
2475
+ readonly internalType: "address";
2476
+ }, {
2477
+ readonly name: "receiver";
2478
+ readonly type: "address";
2479
+ readonly indexed: false;
2480
+ readonly internalType: "address";
2481
+ }];
2482
+ readonly anonymous: false;
2483
+ };
2325
2484
  declare class InvalidOfferError extends BaseError<z$1.ZodError | Error> {
2326
2485
  readonly name = "Offer.InvalidOfferError";
2327
2486
  constructor(error: z$1.ZodError | Error);
@@ -2391,6 +2550,7 @@ declare namespace fromCollateral {
2391
2550
  declare function fromOffer(parameters: fromOffer.Parameters): fromOffer.ReturnType;
2392
2551
  declare namespace fromOffer {
2393
2552
  type Parameters = {
2553
+ chainId: Id;
2394
2554
  offer: Offer;
2395
2555
  blockNumber: number;
2396
2556
  price?: bigint | null;
@@ -2407,6 +2567,7 @@ declare namespace fromOffer {
2407
2567
  declare function fromOffers(parameters: fromOffers.Parameters): fromOffers.ReturnType;
2408
2568
  declare namespace fromOffers {
2409
2569
  type Parameters = {
2570
+ chainId: Id;
2410
2571
  offers: Offer[];
2411
2572
  blockNumber: number;
2412
2573
  price?: bigint | null;
@@ -2445,7 +2606,7 @@ declare namespace Conversion {
2445
2606
  }): bigint;
2446
2607
  }
2447
2608
  declare namespace Position_d_exports {
2448
- export { Position, Type, from$8 as from };
2609
+ export { Position, Type, from$8 as from, positionTypeId };
2449
2610
  }
2450
2611
  type Position = {
2451
2612
  /** The chain id. */chainId: Id;
@@ -2460,13 +2621,17 @@ type Position = {
2460
2621
  /** The underlying asset of the position.
2461
2622
  * For ERC20 positions, this equals the contract address.
2462
2623
  * For vault positions, this is the vault's underlying asset.
2624
+ * For debt positions, this is the zero address (sentinel).
2625
+ * For collateral positions, this is the collateral token address.
2463
2626
  */
2464
- asset?: Address; /** The block number at which the position was last updated. */
2627
+ asset: Address; /** The block number at which the position was last updated. */
2465
2628
  blockNumber: number;
2466
2629
  };
2467
2630
  declare enum Type {
2468
2631
  ERC20 = "erc20",
2469
- VAULT_V1 = "vault_v1"
2632
+ VAULT_V1 = "vault_v1",
2633
+ DEBT_OF = "debtOf",
2634
+ COLLATERAL_OF = "collateralOf"
2470
2635
  }
2471
2636
  /**
2472
2637
  * @constructor
@@ -2482,11 +2647,17 @@ declare namespace from$8 {
2482
2647
  user: Address;
2483
2648
  type: Type;
2484
2649
  balance?: bigint;
2485
- asset?: Address;
2650
+ asset: Address;
2486
2651
  blockNumber: number;
2487
2652
  };
2488
2653
  type ReturnType = Position;
2489
2654
  }
2655
+ /**
2656
+ * Maps a {@link Type} enum value to its 1-based integer ID used in the database.
2657
+ * @param type - The position type.
2658
+ * @returns The 1-based integer ID.
2659
+ */
2660
+ declare const positionTypeId: (type: Type) => number;
2490
2661
  declare namespace Quote_d_exports {
2491
2662
  export { InvalidQuoteError, Quote, QuoteInput, Side, from$7 as from, fromSnakeCase, random };
2492
2663
  }
@@ -2675,6 +2846,8 @@ type Transfer = {
2675
2846
  from: Address;
2676
2847
  to: Address;
2677
2848
  value: bigint;
2849
+ type: Type; /** The underlying asset of the transfer's position. */
2850
+ asset: Address;
2678
2851
  blockNumber: number;
2679
2852
  };
2680
2853
  /**
@@ -2698,6 +2871,8 @@ declare namespace from$5 {
2698
2871
  from: Address;
2699
2872
  to: Address;
2700
2873
  value: bigint;
2874
+ type: Type;
2875
+ asset: Address;
2701
2876
  blockNumber: number;
2702
2877
  };
2703
2878
  type ReturnType = Transfer;
@@ -3952,7 +4127,12 @@ interface components {
3952
4127
  block_number: number;
3953
4128
  };
3954
4129
  ValidateOffersRequest: {
3955
- /** @description Array of offers in snake_case format. Required, non-empty. */offers: components["schemas"]["ValidateOfferRequest"][];
4130
+ /**
4131
+ * @description Chain id used for chain-scoped validation rules.
4132
+ * @example 1
4133
+ */
4134
+ chain_id: number; /** @description Array of offers in snake_case format. Required, non-empty. */
4135
+ offers: components["schemas"]["ValidateOfferRequest"][];
3956
4136
  };
3957
4137
  ValidateOfferRequest: {
3958
4138
  /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */maker: string; /** @example 369216000000000000000000 */
@@ -3965,8 +4145,7 @@ interface components {
3965
4145
  start: number; /** @example 0x000000000000000000000000000000000000000000000000000000000008b8f4 */
3966
4146
  group: string; /** @example 0x0000000000000000000000000000000000000000000000000000000000000000 */
3967
4147
  session: string; /** @example false */
3968
- buy: boolean; /** @example 1 */
3969
- chain_id: number; /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
4148
+ buy: boolean; /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
3970
4149
  loan_token: string;
3971
4150
  /**
3972
4151
  * @example [
@@ -4029,15 +4208,17 @@ type ObligationResponse = paths["/v1/obligations"]["get"]["responses"]["200"]["c
4029
4208
  * @constructor
4030
4209
  * @param obligation - {@link Obligation}
4031
4210
  * @param quote - {@link Quote}
4211
+ * @param chainId - The chain id used to compute `id`.
4032
4212
  * @returns The created `ObligationResponse`. {@link ObligationResponse}
4033
4213
  */
4034
- declare function from$3(obligation: Obligation, quote: Quote): ObligationResponse;
4214
+ declare function from$3(obligation: Obligation$1, quote: Quote, chainId: Id): ObligationResponse;
4035
4215
  declare namespace OfferResponse_d_exports {
4036
4216
  export { Input, OfferResponse, from$2 as from };
4037
4217
  }
4038
4218
  type OfferResponse = paths["/v1/offers"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
4039
4219
  type Input = Readonly<{
4040
4220
  hash: Hex;
4221
+ obligationId: Hex;
4041
4222
  maker: Address;
4042
4223
  assets: bigint;
4043
4224
  obligationUnits: bigint;
@@ -4113,7 +4294,8 @@ type PaginationParams = {
4113
4294
  };
4114
4295
  declare namespace getByUser {
4115
4296
  type Parameters = PaginationParams & {
4116
- /** The user address to get positions for. */user: Address;
4297
+ /** The user address to get positions for. */user: Address; /** The type of position to get. Default is all types. */
4298
+ type?: Type;
4117
4299
  };
4118
4300
  type PositionWithReserved = {
4119
4301
  chainId: Id;
@@ -4234,6 +4416,7 @@ declare const schemas: {
4234
4416
  limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
4235
4417
  }, z$1.core.$strip>;
4236
4418
  readonly validate_offers: z$1.ZodObject<{
4419
+ chain_id: z$1.ZodNumber;
4237
4420
  offers: z$1.ZodArray<z$1.ZodUnknown>;
4238
4421
  }, z$1.core.$strict>;
4239
4422
  readonly get_user_positions: z$1.ZodObject<{
@@ -4348,8 +4531,9 @@ declare namespace getObligations {
4348
4531
  };
4349
4532
  type ReturnType = {
4350
4533
  obligations: Compute<{
4351
- /** The obligation id. Uses {@link Obligation.id} to calculate the id.*/id: () => Hex;
4352
- } & Obligation & Omit<Quote, "obligationId">>[]; /** The pagination cursor. */
4534
+ /** The obligation id returned by the API. */id: Hex; /** The chain id used to compute the obligation id. */
4535
+ chainId: Id;
4536
+ } & Obligation$1 & Omit<Quote, "obligationId">>[]; /** The pagination cursor. */
4353
4537
  cursor: string | null;
4354
4538
  };
4355
4539
  type ErrorType = GetApiErrorType;
@@ -4521,7 +4705,10 @@ type GatekeeperClient = {
4521
4705
  statusCode: number;
4522
4706
  body: ConfigRulesPayload;
4523
4707
  }>; /** Validate offers and return decision results. */
4524
- isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>; /** Base URL for the gatekeeper service. */
4708
+ isAllowed: (parameters: {
4709
+ offers: Offer[];
4710
+ chainId: number;
4711
+ }) => Promise<Result<Offer, string>>; /** Base URL for the gatekeeper service. */
4525
4712
  baseUrl: string;
4526
4713
  };
4527
4714
  type ClientConfig = {
@@ -4537,14 +4724,18 @@ type ClientConfig = {
4537
4724
  */
4538
4725
  declare function createHttpClient(config: ClientConfig): GatekeeperClient;
4539
4726
  declare namespace Gatekeeper_d_exports {
4540
- export { Gatekeeper, Rules, create };
4727
+ export { Gatekeeper, Rules, RulesFactory, create };
4541
4728
  }
4542
4729
  type Rules = readonly Rule<Offer, string>[];
4730
+ type RulesFactory = (chainId: Id) => Rules;
4543
4731
  type Gatekeeper = {
4544
- isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>;
4732
+ isAllowed: (parameters: {
4733
+ offers: Offer[];
4734
+ chainId: Id;
4735
+ }) => Promise<Result<Offer, string>>;
4545
4736
  };
4546
4737
  type GatekeeperParameters = {
4547
- rules: Rules;
4738
+ rules: RulesFactory;
4548
4739
  };
4549
4740
  /**
4550
4741
  * Create a gatekeeper instance with the provided rules.
@@ -4554,25 +4745,13 @@ type GatekeeperParameters = {
4554
4745
  declare function create(parameters: GatekeeperParameters): Gatekeeper;
4555
4746
  //#endregion
4556
4747
  //#region src/gatekeeper/morphoRules.d.ts
4557
- declare const morphoRules: (chains: Chain$1[]) => (Rule<Offer, "mixed_maker"> | Rule<Offer, "amount_mutual_exclusivity"> | Rule<Offer, "chain_ids"> | Rule<Offer, "maturity"> | Rule<Offer, "callback"> | Rule<Offer, "loan_token"> | Rule<Offer, "collateral_token"> | Rule<Offer, "oracle">)[];
4748
+ declare const morphoRules: (parameters: {
4749
+ chains: Chain$1[];
4750
+ chainId: Id;
4751
+ }) => (Rule<Offer, "mixed_maker"> | Rule<Offer, "amount_mutual_exclusivity"> | Rule<Offer, "maturity"> | Rule<Offer, "callback"> | Rule<Offer, "loan_token"> | Rule<Offer, "collateral_token"> | Rule<Offer, "oracle">)[];
4558
4752
  declare namespace Rules_d_exports {
4559
- export { ValidityParameters, amountMutualExclusivity, callback, chains, collateralToken, loanToken, maturity, oracle, sameMaker, validity };
4753
+ export { amountMutualExclusivity, callback, collateralToken, loanToken, maturity, oracle, sameMaker };
4560
4754
  }
4561
- type ValidityParameters = {
4562
- client: PublicClient<Transport, Chain$1>;
4563
- };
4564
- /**
4565
- * set of rules to validate offers.
4566
- *
4567
- * @param _parameters - Validity parameters with chain and client
4568
- * @returns Array of validation rules to evaluate against offers
4569
- */
4570
- declare function validity(_parameters: ValidityParameters): Rule<Offer, "expiry">[];
4571
- declare const chains: ({
4572
- chains
4573
- }: {
4574
- chains: Chain$1[];
4575
- }) => Rule<Offer, "chain_ids">;
4576
4755
  declare const maturity: ({
4577
4756
  maturities
4578
4757
  }: {
@@ -4590,9 +4769,11 @@ declare const callback: ({
4590
4769
  * @returns The issue that was found. If the offer is valid, this will be undefined.
4591
4770
  */
4592
4771
  declare const loanToken: ({
4593
- assetsByChainId
4772
+ assetsByChainId,
4773
+ chainId
4594
4774
  }: {
4595
4775
  assetsByChainId: Partial<Record<Id, Address[]>>;
4776
+ chainId: Id;
4596
4777
  }) => Rule<Offer, "loan_token">;
4597
4778
  /**
4598
4779
  * A validation rule that checks if the offer's collateral tokens are allowed for its chain.
@@ -4600,9 +4781,11 @@ declare const loanToken: ({
4600
4781
  * @returns The issue that was found. If the offer is valid, this will be undefined.
4601
4782
  */
4602
4783
  declare const collateralToken: ({
4603
- collateralAssetsByChainId
4784
+ collateralAssetsByChainId,
4785
+ chainId
4604
4786
  }: {
4605
4787
  collateralAssetsByChainId: Partial<Record<Id, Address[]>>;
4788
+ chainId: Id;
4606
4789
  }) => Rule<Offer, "collateral_token">;
4607
4790
  /**
4608
4791
  * A validation rule that checks if the offer's oracle addresses are allowed for its chain.
@@ -4610,9 +4793,11 @@ declare const collateralToken: ({
4610
4793
  * @returns The issue that was found. If the offer is valid, this will be undefined.
4611
4794
  */
4612
4795
  declare const oracle: ({
4613
- oraclesByChainId
4796
+ oraclesByChainId,
4797
+ chainId
4614
4798
  }: {
4615
4799
  oraclesByChainId: Partial<Record<Id, Address[]>>;
4800
+ chainId: Id;
4616
4801
  }) => Rule<Offer, "oracle">;
4617
4802
  /**
4618
4803
  * A batch validation rule that ensures all offers in a tree have the same maker address.
@@ -4818,5 +5003,5 @@ declare namespace index_d_exports$2 {
4818
5003
  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 };
4819
5004
  }
4820
5005
  //#endregion
4821
- 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, 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, Tick_d_exports as Tick, 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 };
5006
+ 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, 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, Id_d_exports as Id, 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, Tick_d_exports as Tick, 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 };
4822
5007
  //# sourceMappingURL=index.browser.d.ts.map