@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.
@@ -1,11 +1,11 @@
1
1
  import { z } from "zod/v4";
2
- import { AbiEvent, Address, ChainContract, ChainFormatters, GetLogsReturnType, Hex, MulticallParameters, PublicClient, Transport, WalletClient } from "viem";
3
- import { Chain } from "viem/chains";
4
- import * as z$1 from "zod";
5
- import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
6
2
  import "reflect-metadata";
7
3
  import { OpenAPIDocument } from "openapi-metadata";
4
+ import * as z$1 from "zod";
8
5
  import { Client } from "openapi-fetch";
6
+ import { AbiEvent, Address, ChainContract, ChainFormatters, GetLogsReturnType, Hex, MulticallParameters, PublicClient, Transport, WalletClient } from "viem";
7
+ import { Chain } from "viem/chains";
8
+ import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
9
9
  import "@electric-sql/pglite";
10
10
  import "drizzle-orm/node-postgres";
11
11
  import "drizzle-orm/pglite";
@@ -36,9 +36,9 @@ declare const CollectorHealth: z.ZodObject<{
36
36
  updated_at: z.ZodNullable<z.ZodString>;
37
37
  lag: z.ZodNullable<z.ZodNumber>;
38
38
  status: z.ZodEnum<{
39
+ unknown: "unknown";
39
40
  live: "live";
40
41
  lagging: "lagging";
41
- unknown: "unknown";
42
42
  }>;
43
43
  initialized: z.ZodBoolean;
44
44
  }, z.core.$strip>;
@@ -49,9 +49,9 @@ declare const CollectorsHealthResponse: z.ZodArray<z.ZodObject<{
49
49
  updated_at: z.ZodNullable<z.ZodString>;
50
50
  lag: z.ZodNullable<z.ZodNumber>;
51
51
  status: z.ZodEnum<{
52
+ unknown: "unknown";
52
53
  live: "live";
53
54
  lagging: "lagging";
54
- unknown: "unknown";
55
55
  }>;
56
56
  initialized: z.ZodBoolean;
57
57
  }, z.core.$strip>>;
@@ -1419,7 +1419,7 @@ declare class ReorgError extends BaseError {
1419
1419
  constructor(blockNumber: number);
1420
1420
  }
1421
1421
  declare namespace Chain_d_exports {
1422
- export { Chain$1 as Chain, ChainId, Id, InvalidBatchSizeError, InvalidBlockRangeError, InvalidBlockWindowError, MissingBlockNumberError, Name, chainIds, chainNames, chains$1 as chains, getChain, getWhitelistedChains, streamLogs };
1422
+ export { Chain$1 as Chain, ChainId, Id, InvalidBatchSizeError, InvalidBlockRangeError, InvalidBlockWindowError, MissingBlockNumberError, Name, chainIds, chainNames, chains, getChain, getWhitelistedChains, streamLogs };
1423
1423
  }
1424
1424
  type Chain$1 = Compute<Omit<Chain<ChainFormatters, {
1425
1425
  morpho: ChainContract;
@@ -1460,7 +1460,7 @@ type Id = (typeof ChainId)[Uppercase<Name>];
1460
1460
  declare const chainIds: readonly Id[];
1461
1461
  declare function getChain(chainId: Id): Chain$1 | undefined;
1462
1462
  declare const getWhitelistedChains: () => Chain$1[];
1463
- declare const chains$1: Record<Lowercase<Name>, Chain$1>;
1463
+ declare const chains: Record<Lowercase<Name>, Chain$1>;
1464
1464
  declare function streamLogs<abiEvent extends AbiEvent | undefined = undefined>(parameters: {
1465
1465
  client: PublicClient;
1466
1466
  contractAddress?: Address;
@@ -1538,13 +1538,23 @@ declare class InvalidLLTVError extends BaseError {
1538
1538
  }
1539
1539
  declare const LLTVSchema: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
1540
1540
  declare namespace Collateral_d_exports {
1541
- export { Collateral, CollateralSchema, CollateralsSchema, from$13 as from, random$3 as random };
1541
+ export { Collateral, CollateralSchema, CollateralsSchema, abi$1 as abi, from$13 as from, random$3 as random };
1542
1542
  }
1543
1543
  type Collateral = {
1544
1544
  /** Asset being used as collateral. */asset: Address; /** Liquidation Loan-to-Value of the collateral. */
1545
1545
  lltv: LLTV; /** Oracle contract used to price the collateral. */
1546
1546
  oracle: Address;
1547
1547
  };
1548
+ declare const abi$1: readonly [{
1549
+ readonly type: "address";
1550
+ readonly name: "token";
1551
+ }, {
1552
+ readonly type: "uint256";
1553
+ readonly name: "lltv";
1554
+ }, {
1555
+ readonly type: "address";
1556
+ readonly name: "oracle";
1557
+ }];
1548
1558
  declare const CollateralSchema: z$1.ZodObject<{
1549
1559
  asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1550
1560
  oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
@@ -1658,102 +1668,33 @@ declare class DenominatorIsZeroError extends BaseError {
1658
1668
  readonly name = "ERC4626.DenominatorIsZeroError";
1659
1669
  constructor();
1660
1670
  }
1661
- declare namespace Liquidity_d_exports {
1662
- export { LiquidityLink, LiquidityPool, OfferLiquidityPool, calculateMaxDebt, generateAllowancePoolId, generateBalancePoolId, generateDebtPoolId, generateMarketLiquidityPoolId, generateObligationCollateralPoolId, generateUserVaultPositionPoolId, generateVaultPositionPoolId };
1671
+ declare namespace Format_d_exports {
1672
+ export { Snake, fromSnakeCase$3 as fromSnakeCase, stringifyBigint, toSnakeCase$1 as toSnakeCase };
1663
1673
  }
1674
+ /** The snake case representation of a type with bigint values stringified. */
1675
+ type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
1676
+ /** Make arrays/tuples and object props mutable, deeply. */
1677
+ 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;
1678
+ /** Stringifies bigint values to strings and preserves branded primitives. */
1679
+ 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;
1680
+ /** Key remapping that also preserves branded primitives. */
1681
+ 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;
1682
+ 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;
1664
1683
  /**
1665
- * Represents a liquidity pool with a unique ID and amount.
1666
- */
1667
- type LiquidityPool = {
1668
- id: string;
1669
- amount: bigint;
1670
- };
1671
- /**
1672
- * Represents a hierarchical relationship between two liquidity pools.
1673
- */
1674
- type LiquidityLink = {
1675
- parentPoolId: string;
1676
- childPoolId: string;
1677
- priority: number;
1678
- };
1679
- /**
1680
- * Represents the connection between an offer and its liquidity pools.
1681
- */
1682
- type OfferLiquidityPool = {
1683
- offerHash: Hex;
1684
- poolId: string;
1685
- /**
1686
- * The available capacity/liquidity from this pool for this offer.
1687
- * Matches allowance amount from pool below.
1688
- */
1689
- amount: bigint;
1690
- };
1691
- /**
1692
- * Calculate maximum debt capacity from collateral amount.
1693
- * @param amount - Collateral amount
1694
- * @param oraclePrice - Oracle price (scaled to 36 decimals)
1695
- * @param lltv - Loan-to-value ratio (scaled to 18 decimals)
1696
- * @returns Maximum debt capacity
1697
- */
1698
- declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
1699
- /**
1700
- * Generate pool ID for balance pools.
1701
- */
1702
- declare function generateBalancePoolId(parameters: {
1703
- user: Address;
1704
- chainId: Id;
1705
- token: Address;
1706
- }): string;
1707
- /**
1708
- * Generate pool ID for allowance pools.
1709
- */
1710
- declare function generateAllowancePoolId(parameters: {
1711
- user: Address;
1712
- chainId: Id;
1713
- token: Address;
1714
- }): string;
1715
- /**
1716
- * Generate pool ID for obligation collateral pools.
1717
- * Obligation collateral pools represent collateral already deposited in the obligation.
1718
- * These pools are shared across all offers with the same obligation.
1719
- */
1720
- declare function generateObligationCollateralPoolId(parameters: {
1721
- user: Address;
1722
- chainId: Id;
1723
- obligationId: Hex;
1724
- token: Address;
1725
- }): string;
1726
- /**
1727
- * Generate pool ID for debt pools.
1728
- */
1729
- declare function generateDebtPoolId(parameters: {
1730
- user: Address;
1731
- chainId: Id;
1732
- obligationId: Hex;
1733
- }): string;
1734
- /**
1735
- * Generate pool ID for user position in a vault.
1736
- */
1737
- declare function generateUserVaultPositionPoolId(parameters: {
1738
- user: Address;
1739
- chainId: Id;
1740
- vault: Address;
1741
- }): string;
1742
- /**
1743
- * Generate pool ID for vault position in a market.
1684
+ * Formats object keys to snake case.
1685
+ * Preserves ethereum addresses as is.
1686
+ * Converts ethereum addresses to checksummed if used as values.
1687
+ * Stringifies bigint values to strings.
1744
1688
  */
1745
- declare function generateVaultPositionPoolId(parameters: {
1746
- vault: Address;
1747
- chainId: Id;
1748
- marketId: string;
1749
- }): string;
1689
+ declare function toSnakeCase$1<T>(obj: T): Snake<T>;
1750
1690
  /**
1751
- * Generate pool ID for market total liquidity.
1691
+ * Formats a snake case object to its camel case type.
1692
+ * Preserves ethereum addresses as is.
1693
+ * Converts checksummed ethereum addresses to lowercase if used as values.
1694
+ * @warning Does not unstringify bigint values.
1752
1695
  */
1753
- declare function generateMarketLiquidityPoolId(parameters: {
1754
- chainId: Id;
1755
- marketId: string;
1756
- }): string;
1696
+ declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
1697
+ declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
1757
1698
  declare namespace Maturity_d_exports {
1758
1699
  export { InvalidDateError, InvalidFormatError, InvalidOptionError, Maturity, MaturityOptions, MaturitySchema, MaturityType, from$12 as from };
1759
1700
  }
@@ -1802,44 +1743,15 @@ declare class InvalidOptionError extends BaseError {
1802
1743
  readonly name = "Maturity.InvalidOptionError";
1803
1744
  constructor(input: string);
1804
1745
  }
1805
- declare namespace Format_d_exports {
1806
- export { Snake, fromSnakeCase$3 as fromSnakeCase, stringifyBigint, toSnakeCase$1 as toSnakeCase };
1807
- }
1808
- /** The snake case representation of a type with bigint values stringified. */
1809
- type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
1810
- /** Make arrays/tuples and object props mutable, deeply. */
1811
- 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;
1812
- /** Stringifies bigint values to strings and preserves branded primitives. */
1813
- 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;
1814
- /** Key remapping that also preserves branded primitives. */
1815
- 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;
1816
- 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;
1817
- /**
1818
- * Formats object keys to snake case.
1819
- * Preserves ethereum addresses as is.
1820
- * Converts ethereum addresses to checksummed if used as values.
1821
- * Stringifies bigint values to strings.
1822
- */
1823
- declare function toSnakeCase$1<T>(obj: T): Snake<T>;
1824
- /**
1825
- * Formats a snake case object to its camel case type.
1826
- * Preserves ethereum addresses as is.
1827
- * Converts checksummed ethereum addresses to lowercase if used as values.
1828
- * @warning Does not unstringify bigint values.
1829
- */
1830
- declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
1831
- declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
1832
1746
  declare namespace Obligation_d_exports {
1833
- export { CollateralsAreNotSortedError, InvalidObligationError, Obligation, ObligationSchema, from$11 as from, fromOffer$1 as fromOffer, fromSnakeCase$2 as fromSnakeCase, id, random$2 as random };
1747
+ 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 };
1834
1748
  }
1835
- type Obligation = {
1836
- /** The chain id where the liquidity for this obligation is located. */chainId: Id; /** The token that is being borrowed for this obligation. */
1837
- loanToken: Address; /** The exact set of collaterals required to borrow the loan token. */
1749
+ type Obligation$1 = {
1750
+ /** The token that is being borrowed for this obligation. */loanToken: Address; /** The exact set of collaterals required to borrow the loan token. */
1838
1751
  collaterals: Collateral[]; /** The maturity of the obligation. */
1839
1752
  maturity: Maturity;
1840
1753
  };
1841
1754
  declare const ObligationSchema: z$1.ZodObject<{
1842
- chainId: z$1.ZodNumber;
1843
1755
  loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1844
1756
  collaterals: z$1.ZodArray<z$1.ZodObject<{
1845
1757
  asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
@@ -1848,6 +1760,49 @@ declare const ObligationSchema: z$1.ZodObject<{
1848
1760
  }, z$1.core.$strip>>;
1849
1761
  maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
1850
1762
  }, z$1.core.$strip>;
1763
+ declare const abi: readonly [{
1764
+ readonly type: "address";
1765
+ readonly name: "loanToken";
1766
+ }, {
1767
+ readonly type: "tuple[]";
1768
+ readonly name: "collaterals";
1769
+ readonly components: readonly [{
1770
+ readonly type: "address";
1771
+ readonly name: "token";
1772
+ }, {
1773
+ readonly type: "uint256";
1774
+ readonly name: "lltv";
1775
+ }, {
1776
+ readonly type: "address";
1777
+ readonly name: "oracle";
1778
+ }];
1779
+ }, {
1780
+ readonly type: "uint256";
1781
+ readonly name: "maturity";
1782
+ }];
1783
+ declare const tupleAbi: readonly [{
1784
+ readonly type: "tuple";
1785
+ readonly components: readonly [{
1786
+ readonly type: "address";
1787
+ readonly name: "loanToken";
1788
+ }, {
1789
+ readonly type: "tuple[]";
1790
+ readonly name: "collaterals";
1791
+ readonly components: readonly [{
1792
+ readonly type: "address";
1793
+ readonly name: "token";
1794
+ }, {
1795
+ readonly type: "uint256";
1796
+ readonly name: "lltv";
1797
+ }, {
1798
+ readonly type: "address";
1799
+ readonly name: "oracle";
1800
+ }];
1801
+ }, {
1802
+ readonly type: "uint256";
1803
+ readonly name: "maturity";
1804
+ }];
1805
+ }];
1851
1806
  /**
1852
1807
  * Creates an obligation from the given parameters.
1853
1808
  * @constructor
@@ -1858,7 +1813,6 @@ declare const ObligationSchema: z$1.ZodObject<{
1858
1813
  * @example
1859
1814
  * ```ts
1860
1815
  * const obligation = Obligation.from({
1861
- * chainId: 1,
1862
1816
  * loanToken: privateKeyToAccount(generatePrivateKey()).address,
1863
1817
  * collaterals: [
1864
1818
  * Collateral.from({
@@ -1874,12 +1828,11 @@ declare const ObligationSchema: z$1.ZodObject<{
1874
1828
  declare function from$11(parameters: from$11.Parameters): from$11.ReturnType;
1875
1829
  declare namespace from$11 {
1876
1830
  type Parameters = {
1877
- /** The chain id where the liquidity for this obligation is located. */chainId: number; /** The token that is being borrowed for this obligation. */
1878
- loanToken: Address; /** The exact set of collaterals required to borrow the loan token. Must be sorted alphabetically by address. */
1831
+ /** 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. */
1879
1832
  collaterals: from$13.Parameters[] | readonly from$13.Parameters[]; /** The maturity of the obligation. */
1880
1833
  maturity: from$12.Parameters;
1881
1834
  };
1882
- type ReturnType = Obligation;
1835
+ type ReturnType = Obligation$1;
1883
1836
  type ErrorType = InvalidObligationError;
1884
1837
  }
1885
1838
  /**
@@ -1890,30 +1843,27 @@ declare namespace from$11 {
1890
1843
  */
1891
1844
  declare function fromSnakeCase$2(input: fromSnakeCase$2.Parameters): fromSnakeCase$2.ReturnType;
1892
1845
  declare namespace fromSnakeCase$2 {
1893
- type Parameters = Snake<Omit<Obligation, "chainId"> & {
1894
- chainId: number;
1895
- }>;
1896
- type ReturnType = Obligation;
1846
+ type Parameters = Snake<Obligation$1>;
1847
+ type ReturnType = Obligation$1;
1897
1848
  type ErrorType = InvalidObligationError;
1898
1849
  }
1899
1850
  /**
1900
- * Calculates the obligation id based on the smart contract's Obligation struct.
1901
- * The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals, maturity)).
1851
+ * Calculates a canonical key for an obligation payload.
1852
+ * The key is computed as keccak256(abi.encode(loanToken, collaterals, maturity)).
1902
1853
  * @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
1903
- * @param parameters - {@link id.Parameters}
1904
- * @returns The obligation id as a 32-byte hex string. {@link id.ReturnType}
1854
+ * @param parameters - {@link key.Parameters}
1855
+ * @returns The obligation key as a 32-byte hex string. {@link key.ReturnType}
1905
1856
  *
1906
1857
  * @example
1907
1858
  * ```ts
1908
1859
  * const obligation = Obligation.random();
1909
- * const id = Obligation.id(obligation);
1910
- * console.log(id); // 0x1234567890123456789012345678901234567890123456789012345678901234
1860
+ * const key = Obligation.key(obligation);
1861
+ * console.log(key); // 0x1234567890123456789012345678901234567890123456789012345678901234
1911
1862
  * ```
1912
1863
  */
1913
- declare function id(parameters: id.Parameters): id.ReturnType;
1914
- declare namespace id {
1864
+ declare function key$1(parameters: key$1.Parameters): key$1.ReturnType;
1865
+ declare namespace key$1 {
1915
1866
  type Parameters = {
1916
- chainId: number;
1917
1867
  loanToken: Address;
1918
1868
  collaterals: {
1919
1869
  asset: Address;
@@ -1936,7 +1886,7 @@ declare namespace id {
1936
1886
  */
1937
1887
  declare function random$2(): random$2.ReturnType;
1938
1888
  declare namespace random$2 {
1939
- type ReturnType = Obligation;
1889
+ type ReturnType = Obligation$1;
1940
1890
  }
1941
1891
  /**
1942
1892
  * Creates an obligation from an offer.
@@ -1948,7 +1898,7 @@ declare namespace random$2 {
1948
1898
  declare function fromOffer$1(offer: Offer): fromOffer$1.ReturnType;
1949
1899
  declare namespace fromOffer$1 {
1950
1900
  type Parameters = Offer;
1951
- type ReturnType = Obligation;
1901
+ type ReturnType = Obligation$1;
1952
1902
  }
1953
1903
  declare class InvalidObligationError extends BaseError<z$1.ZodError | Error> {
1954
1904
  readonly name = "Obligation.InvalidObligationError";
@@ -1958,8 +1908,135 @@ declare class CollateralsAreNotSortedError extends BaseError {
1958
1908
  readonly name = "Obligation.CollateralsAreNotSortedError";
1959
1909
  constructor();
1960
1910
  }
1911
+ declare namespace Id_d_exports {
1912
+ export { Obligation, creationCode, toId };
1913
+ }
1914
+ type Obligation = Obligation$1;
1915
+ /**
1916
+ * Builds the same creation code as `IdLib.creationCode` in Solidity.
1917
+ *
1918
+ * Layout: `prefix (11 bytes) + chainId (32 bytes) + morphoV2 (20 bytes) + abi.encode(obligation)`.
1919
+ *
1920
+ * @param parameters - {@link creationCode.Parameters}
1921
+ * @returns The CREATE2 init code bytes. {@link creationCode.ReturnType}
1922
+ */
1923
+ declare function creationCode(parameters: creationCode.Parameters): creationCode.ReturnType;
1924
+ declare namespace creationCode {
1925
+ type Parameters = {
1926
+ obligation: Obligation;
1927
+ chainId: Id;
1928
+ morphoV2: Address;
1929
+ };
1930
+ type ReturnType = Hex;
1931
+ }
1932
+ /**
1933
+ * Computes the same id as `IdLib.toId` in Solidity.
1934
+ * @param parameters - {@link toId.Parameters}
1935
+ * @returns The obligation id. {@link toId.ReturnType}
1936
+ */
1937
+ declare function toId(parameters: toId.Parameters): toId.ReturnType;
1938
+ declare namespace toId {
1939
+ type Parameters = creationCode.Parameters;
1940
+ type ReturnType = Hex;
1941
+ }
1942
+ declare namespace Liquidity_d_exports {
1943
+ export { LiquidityLink, LiquidityPool, OfferLiquidityPool, calculateMaxDebt, generateAllowancePoolId, generateBalancePoolId, generateDebtPoolId, generateMarketLiquidityPoolId, generateObligationCollateralPoolId, generateUserVaultPositionPoolId, generateVaultPositionPoolId };
1944
+ }
1945
+ /**
1946
+ * Represents a liquidity pool with a unique ID and amount.
1947
+ */
1948
+ type LiquidityPool = {
1949
+ id: string;
1950
+ amount: bigint;
1951
+ };
1952
+ /**
1953
+ * Represents a hierarchical relationship between two liquidity pools.
1954
+ */
1955
+ type LiquidityLink = {
1956
+ parentPoolId: string;
1957
+ childPoolId: string;
1958
+ priority: number;
1959
+ };
1960
+ /**
1961
+ * Represents the connection between an offer and its liquidity pools.
1962
+ */
1963
+ type OfferLiquidityPool = {
1964
+ offerHash: Hex;
1965
+ poolId: string;
1966
+ /**
1967
+ * The available capacity/liquidity from this pool for this offer.
1968
+ * Matches allowance amount from pool below.
1969
+ */
1970
+ amount: bigint;
1971
+ };
1972
+ /**
1973
+ * Calculate maximum debt capacity from collateral amount.
1974
+ * @param amount - Collateral amount
1975
+ * @param oraclePrice - Oracle price (scaled to 36 decimals)
1976
+ * @param lltv - Loan-to-value ratio (scaled to 18 decimals)
1977
+ * @returns Maximum debt capacity
1978
+ */
1979
+ declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
1980
+ /**
1981
+ * Generate pool ID for balance pools.
1982
+ */
1983
+ declare function generateBalancePoolId(parameters: {
1984
+ user: Address;
1985
+ chainId: Id;
1986
+ token: Address;
1987
+ }): string;
1988
+ /**
1989
+ * Generate pool ID for allowance pools.
1990
+ */
1991
+ declare function generateAllowancePoolId(parameters: {
1992
+ user: Address;
1993
+ chainId: Id;
1994
+ token: Address;
1995
+ }): string;
1996
+ /**
1997
+ * Generate pool ID for obligation collateral pools.
1998
+ * Obligation collateral pools represent collateral already deposited in the obligation.
1999
+ * These pools are shared across all offers with the same obligation.
2000
+ */
2001
+ declare function generateObligationCollateralPoolId(parameters: {
2002
+ user: Address;
2003
+ chainId: Id;
2004
+ obligationId: Hex;
2005
+ token: Address;
2006
+ }): string;
2007
+ /**
2008
+ * Generate pool ID for debt pools.
2009
+ */
2010
+ declare function generateDebtPoolId(parameters: {
2011
+ user: Address;
2012
+ chainId: Id;
2013
+ obligationId: Hex;
2014
+ }): string;
2015
+ /**
2016
+ * Generate pool ID for user position in a vault.
2017
+ */
2018
+ declare function generateUserVaultPositionPoolId(parameters: {
2019
+ user: Address;
2020
+ chainId: Id;
2021
+ vault: Address;
2022
+ }): string;
2023
+ /**
2024
+ * Generate pool ID for vault position in a market.
2025
+ */
2026
+ declare function generateVaultPositionPoolId(parameters: {
2027
+ vault: Address;
2028
+ chainId: Id;
2029
+ marketId: string;
2030
+ }): string;
2031
+ /**
2032
+ * Generate pool ID for market total liquidity.
2033
+ */
2034
+ declare function generateMarketLiquidityPoolId(parameters: {
2035
+ chainId: Id;
2036
+ marketId: string;
2037
+ }): string;
1961
2038
  declare namespace Offer_d_exports {
1962
- 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 };
2039
+ 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 };
1963
2040
  }
1964
2041
  type Offer = {
1965
2042
  /** The address that made the offer. */readonly maker: Address; /** The amount of assets offered. Mutually exclusive with obligationUnits and obligationShares. */
@@ -1972,8 +2049,7 @@ type Offer = {
1972
2049
  readonly start: number; /** The group. Used for OCO (One-Cancelled-Other) mechanism. */
1973
2050
  readonly group: Hex; /** The session. Used for session-based offer management. */
1974
2051
  readonly session: Hex; /** The side of the offer. `true` for buy, `false` for sell. */
1975
- readonly buy: boolean; /** The chain id where the liquidity for this offer is located. */
1976
- readonly chainId: Id; /** The token that is being borrowed. */
2052
+ readonly buy: boolean; /** The token that is being borrowed. */
1977
2053
  readonly loanToken: Address; /** The exact set of collaterals required to borrow the loan token. */
1978
2054
  readonly collaterals: readonly Collateral[]; /** The optional callback data to retrieve the maker funds. */
1979
2055
  readonly callback: {
@@ -1988,6 +2064,7 @@ declare enum Status {
1988
2064
  }
1989
2065
  type Validation = {
1990
2066
  offerHash: Hex;
2067
+ obligationId: Hex;
1991
2068
  status: Status;
1992
2069
  };
1993
2070
  declare const OfferSchema: () => z$1.ZodObject<{
@@ -2002,7 +2079,6 @@ declare const OfferSchema: () => z$1.ZodObject<{
2002
2079
  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>>;
2003
2080
  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>>;
2004
2081
  buy: z$1.ZodBoolean;
2005
- chainId: z$1.ZodNumber;
2006
2082
  loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
2007
2083
  collaterals: z$1.ZodArray<z$1.ZodObject<{
2008
2084
  asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
@@ -2026,8 +2102,7 @@ declare const OfferSchema: () => z$1.ZodObject<{
2026
2102
  *
2027
2103
  * All values validated to be non-negative and within bytes32 range.
2028
2104
  */
2029
- type OfferInput = Compute<Omit<Offer, "chainId" | "group" | "session" | "obligationUnits" | "obligationShares" | "receiverIfMakerIsSeller"> & {
2030
- chainId: number;
2105
+ type OfferInput = Compute<Omit<Offer, "group" | "session" | "obligationUnits" | "obligationShares" | "receiverIfMakerIsSeller"> & {
2031
2106
  group: Hex | bigint | number | string; /** Optional: defaults to zero bytes32. */
2032
2107
  session?: Hex | bigint | number | string; /** Optional: defaults to 0n. Mutually exclusive with assets and obligationShares. */
2033
2108
  obligationUnits?: bigint; /** Optional: defaults to 0n. Mutually exclusive with assets and obligationUnits. */
@@ -2079,7 +2154,6 @@ declare const serialize: (offer: Offer) => {
2079
2154
  group: `0x${string}`;
2080
2155
  session: `0x${string}`;
2081
2156
  buy: boolean;
2082
- chainId: Id;
2083
2157
  loanToken: `0x${string}`;
2084
2158
  collaterals: {
2085
2159
  asset: `0x${string}`;
@@ -2094,7 +2168,6 @@ declare const serialize: (offer: Offer) => {
2094
2168
  hash: `0x${string}`;
2095
2169
  };
2096
2170
  type RandomConfig = {
2097
- chains?: Chain$1[];
2098
2171
  loanTokens?: Address[];
2099
2172
  collateralTokens?: Address[];
2100
2173
  assetsDecimals?: Record<Address, number>;
@@ -2124,96 +2197,28 @@ type RandomConfig = {
2124
2197
  */
2125
2198
  declare function random$1(config?: RandomConfig): Offer;
2126
2199
  /**
2127
- * Creates an EIP-712 domain object.
2128
- * @param chainId - The chain ID.
2129
- * @returns The EIP-712 domain object.
2130
- */
2131
- declare const domain: (chainId: number) => {
2132
- chainId: bigint;
2133
- verifyingContract: "0x0000000000000000000000000000000000000000";
2134
- };
2135
- /**
2136
- * The EIP-712 types for the offer.
2137
- * @warning The ordering of the types should NEVER be changed. The offer hash is computed based on the order of the types.
2138
- * @returns The EIP-712 types.
2200
+ * Computes the canonical chain-agnostic offer hash.
2201
+ * The hash is `keccak256(abi.encode(offer))` using {@link encode}.
2202
+ *
2203
+ * @param offer - Offer payload to hash.
2204
+ * @returns 32-byte offer hash.
2139
2205
  */
2140
- declare const types: {
2141
- readonly EIP712Domain: readonly [{
2142
- readonly name: "chainId";
2143
- readonly type: "uint256";
2144
- }, {
2145
- readonly name: "verifyingContract";
2146
- readonly type: "address";
2147
- }];
2148
- readonly Offer: readonly [{
2149
- readonly name: "maker";
2150
- readonly type: "address";
2151
- }, {
2152
- readonly name: "assets";
2153
- readonly type: "uint256";
2154
- }, {
2155
- readonly name: "obligationUnits";
2156
- readonly type: "uint256";
2157
- }, {
2158
- readonly name: "obligationShares";
2159
- readonly type: "uint256";
2160
- }, {
2161
- readonly name: "tick";
2162
- readonly type: "uint256";
2163
- }, {
2164
- readonly name: "maturity";
2165
- readonly type: "uint256";
2166
- }, {
2167
- readonly name: "expiry";
2168
- readonly type: "uint256";
2169
- }, {
2170
- readonly name: "group";
2171
- readonly type: "bytes32";
2172
- }, {
2173
- readonly name: "session";
2174
- readonly type: "bytes32";
2175
- }, {
2176
- readonly name: "buy";
2177
- readonly type: "bool";
2178
- }, {
2179
- readonly name: "loanToken";
2180
- readonly type: "address";
2181
- }, {
2182
- readonly name: "collaterals";
2183
- readonly type: "Collateral[]";
2184
- }, {
2185
- readonly name: "callback";
2186
- readonly type: "Callback";
2187
- }, {
2188
- readonly name: "receiverIfMakerIsSeller";
2189
- readonly type: "address";
2190
- }];
2191
- readonly Collateral: readonly [{
2192
- readonly name: "asset";
2193
- readonly type: "address";
2194
- }, {
2195
- readonly name: "oracle";
2196
- readonly type: "address";
2197
- }, {
2198
- readonly name: "lltv";
2199
- readonly type: "uint256";
2200
- }];
2201
- readonly Callback: readonly [{
2202
- readonly name: "address";
2203
- readonly type: "address";
2204
- }, {
2205
- readonly name: "data";
2206
- readonly type: "bytes";
2207
- }];
2208
- };
2209
2206
  declare function hash(offer: Offer): Hex;
2210
2207
  /**
2211
- * Calculates the obligation id for an offer based on the smart contract's Obligation struct.
2212
- * The id is computed as keccak256(abi.encode(chainId, loanToken, collaterals (sorted by token address), maturity)).
2208
+ * Calculates the onchain obligation id for an offer.
2209
+ * The id is computed with {@link Id.toId}.
2213
2210
  * @param offer - The offer to calculate the obligation id for.
2211
+ * @param parameters - The chain context used by the onchain id function.
2214
2212
  * @returns The obligation id as a 32-byte hex string.
2215
2213
  */
2216
- declare function obligationId(offer: Offer): Hex;
2214
+ declare function obligationId(offer: Offer, parameters: obligationId.Parameters): obligationId.ReturnType;
2215
+ declare namespace obligationId {
2216
+ type Parameters = {
2217
+ chainId: Id;
2218
+ morphoV2: Address;
2219
+ };
2220
+ type ReturnType = Hex;
2221
+ }
2217
2222
  declare function encode$1(offer: Offer): `0x${string}`;
2218
2223
  declare function decode$1(data: Hex): Offer;
2219
2224
  type OfferConsumed = {
@@ -2327,6 +2332,160 @@ declare const consumedEvent: {
2327
2332
  }];
2328
2333
  readonly anonymous: false;
2329
2334
  };
2335
+ /**
2336
+ * ABI for the Repay event emitted by the MorphoV2 contract.
2337
+ */
2338
+ declare const repayEvent: {
2339
+ readonly type: "event";
2340
+ readonly name: "Repay";
2341
+ readonly inputs: readonly [{
2342
+ readonly name: "caller";
2343
+ readonly type: "address";
2344
+ readonly indexed: true;
2345
+ readonly internalType: "address";
2346
+ }, {
2347
+ readonly name: "id";
2348
+ readonly type: "bytes32";
2349
+ readonly indexed: true;
2350
+ readonly internalType: "bytes32";
2351
+ }, {
2352
+ readonly name: "obligationUnits";
2353
+ readonly type: "uint256";
2354
+ readonly indexed: false;
2355
+ readonly internalType: "uint256";
2356
+ }, {
2357
+ readonly name: "onBehalf";
2358
+ readonly type: "address";
2359
+ readonly indexed: true;
2360
+ readonly internalType: "address";
2361
+ }];
2362
+ readonly anonymous: false;
2363
+ };
2364
+ /**
2365
+ * ABI for the Liquidate event emitted by the MorphoV2 contract.
2366
+ */
2367
+ declare const liquidateEvent: {
2368
+ readonly type: "event";
2369
+ readonly name: "Liquidate";
2370
+ readonly inputs: readonly [{
2371
+ readonly name: "caller";
2372
+ readonly type: "address";
2373
+ readonly indexed: true;
2374
+ readonly internalType: "address";
2375
+ }, {
2376
+ readonly name: "id";
2377
+ readonly type: "bytes32";
2378
+ readonly indexed: true;
2379
+ readonly internalType: "bytes32";
2380
+ }, {
2381
+ readonly name: "seizures";
2382
+ readonly type: "tuple[]";
2383
+ readonly indexed: false;
2384
+ readonly internalType: "struct IMorphoV2.Seizure[]";
2385
+ readonly components: readonly [{
2386
+ readonly name: "collateralIndex";
2387
+ readonly type: "uint256";
2388
+ readonly internalType: "uint256";
2389
+ }, {
2390
+ readonly name: "repaid";
2391
+ readonly type: "uint256";
2392
+ readonly internalType: "uint256";
2393
+ }, {
2394
+ readonly name: "seized";
2395
+ readonly type: "uint256";
2396
+ readonly internalType: "uint256";
2397
+ }];
2398
+ }, {
2399
+ readonly name: "borrower";
2400
+ readonly type: "address";
2401
+ readonly indexed: true;
2402
+ readonly internalType: "address";
2403
+ }, {
2404
+ readonly name: "totalRepaid";
2405
+ readonly type: "uint256";
2406
+ readonly indexed: false;
2407
+ readonly internalType: "uint256";
2408
+ }, {
2409
+ readonly name: "badDebt";
2410
+ readonly type: "uint256";
2411
+ readonly indexed: false;
2412
+ readonly internalType: "uint256";
2413
+ }];
2414
+ readonly anonymous: false;
2415
+ };
2416
+ /**
2417
+ * ABI for the SupplyCollateral event emitted by the MorphoV2 contract.
2418
+ */
2419
+ declare const supplyCollateralEvent: {
2420
+ readonly type: "event";
2421
+ readonly name: "SupplyCollateral";
2422
+ readonly inputs: readonly [{
2423
+ readonly name: "caller";
2424
+ readonly type: "address";
2425
+ readonly indexed: false;
2426
+ readonly internalType: "address";
2427
+ }, {
2428
+ readonly name: "id";
2429
+ readonly type: "bytes32";
2430
+ readonly indexed: true;
2431
+ readonly internalType: "bytes32";
2432
+ }, {
2433
+ readonly name: "collateral";
2434
+ readonly type: "address";
2435
+ readonly indexed: true;
2436
+ readonly internalType: "address";
2437
+ }, {
2438
+ readonly name: "assets";
2439
+ readonly type: "uint256";
2440
+ readonly indexed: false;
2441
+ readonly internalType: "uint256";
2442
+ }, {
2443
+ readonly name: "onBehalf";
2444
+ readonly type: "address";
2445
+ readonly indexed: true;
2446
+ readonly internalType: "address";
2447
+ }];
2448
+ readonly anonymous: false;
2449
+ };
2450
+ /**
2451
+ * ABI for the WithdrawCollateral event emitted by the MorphoV2 contract.
2452
+ */
2453
+ declare const withdrawCollateralEvent: {
2454
+ readonly type: "event";
2455
+ readonly name: "WithdrawCollateral";
2456
+ readonly inputs: readonly [{
2457
+ readonly name: "caller";
2458
+ readonly type: "address";
2459
+ readonly indexed: false;
2460
+ readonly internalType: "address";
2461
+ }, {
2462
+ readonly name: "id";
2463
+ readonly type: "bytes32";
2464
+ readonly indexed: true;
2465
+ readonly internalType: "bytes32";
2466
+ }, {
2467
+ readonly name: "collateral";
2468
+ readonly type: "address";
2469
+ readonly indexed: true;
2470
+ readonly internalType: "address";
2471
+ }, {
2472
+ readonly name: "assets";
2473
+ readonly type: "uint256";
2474
+ readonly indexed: false;
2475
+ readonly internalType: "uint256";
2476
+ }, {
2477
+ readonly name: "onBehalf";
2478
+ readonly type: "address";
2479
+ readonly indexed: true;
2480
+ readonly internalType: "address";
2481
+ }, {
2482
+ readonly name: "receiver";
2483
+ readonly type: "address";
2484
+ readonly indexed: false;
2485
+ readonly internalType: "address";
2486
+ }];
2487
+ readonly anonymous: false;
2488
+ };
2330
2489
  declare class InvalidOfferError extends BaseError<z$1.ZodError | Error> {
2331
2490
  readonly name = "Offer.InvalidOfferError";
2332
2491
  constructor(error: z$1.ZodError | Error);
@@ -2396,6 +2555,7 @@ declare namespace fromCollateral {
2396
2555
  declare function fromOffer(parameters: fromOffer.Parameters): fromOffer.ReturnType;
2397
2556
  declare namespace fromOffer {
2398
2557
  type Parameters = {
2558
+ chainId: Id;
2399
2559
  offer: Offer;
2400
2560
  blockNumber: number;
2401
2561
  price?: bigint | null;
@@ -2412,6 +2572,7 @@ declare namespace fromOffer {
2412
2572
  declare function fromOffers(parameters: fromOffers.Parameters): fromOffers.ReturnType;
2413
2573
  declare namespace fromOffers {
2414
2574
  type Parameters = {
2575
+ chainId: Id;
2415
2576
  offers: Offer[];
2416
2577
  blockNumber: number;
2417
2578
  price?: bigint | null;
@@ -2450,7 +2611,7 @@ declare namespace Conversion {
2450
2611
  }): bigint;
2451
2612
  }
2452
2613
  declare namespace Position_d_exports {
2453
- export { Position, Type, from$8 as from };
2614
+ export { Position, Type, from$8 as from, positionTypeId };
2454
2615
  }
2455
2616
  type Position = {
2456
2617
  /** The chain id. */chainId: Id;
@@ -2465,13 +2626,17 @@ type Position = {
2465
2626
  /** The underlying asset of the position.
2466
2627
  * For ERC20 positions, this equals the contract address.
2467
2628
  * For vault positions, this is the vault's underlying asset.
2629
+ * For debt positions, this is the zero address (sentinel).
2630
+ * For collateral positions, this is the collateral token address.
2468
2631
  */
2469
- asset?: Address; /** The block number at which the position was last updated. */
2632
+ asset: Address; /** The block number at which the position was last updated. */
2470
2633
  blockNumber: number;
2471
2634
  };
2472
2635
  declare enum Type {
2473
2636
  ERC20 = "erc20",
2474
- VAULT_V1 = "vault_v1"
2637
+ VAULT_V1 = "vault_v1",
2638
+ DEBT_OF = "debtOf",
2639
+ COLLATERAL_OF = "collateralOf"
2475
2640
  }
2476
2641
  /**
2477
2642
  * @constructor
@@ -2487,11 +2652,17 @@ declare namespace from$8 {
2487
2652
  user: Address;
2488
2653
  type: Type;
2489
2654
  balance?: bigint;
2490
- asset?: Address;
2655
+ asset: Address;
2491
2656
  blockNumber: number;
2492
2657
  };
2493
2658
  type ReturnType = Position;
2494
2659
  }
2660
+ /**
2661
+ * Maps a {@link Type} enum value to its 1-based integer ID used in the database.
2662
+ * @param type - The position type.
2663
+ * @returns The 1-based integer ID.
2664
+ */
2665
+ declare const positionTypeId: (type: Type) => number;
2495
2666
  declare namespace Quote_d_exports {
2496
2667
  export { InvalidQuoteError, Quote, QuoteInput, Side, from$7 as from, fromSnakeCase, random };
2497
2668
  }
@@ -2680,6 +2851,8 @@ type Transfer = {
2680
2851
  from: Address;
2681
2852
  to: Address;
2682
2853
  value: bigint;
2854
+ type: Type; /** The underlying asset of the transfer's position. */
2855
+ asset: Address;
2683
2856
  blockNumber: number;
2684
2857
  };
2685
2858
  /**
@@ -2703,6 +2876,8 @@ declare namespace from$5 {
2703
2876
  from: Address;
2704
2877
  to: Address;
2705
2878
  value: bigint;
2879
+ type: Type;
2880
+ asset: Address;
2706
2881
  blockNumber: number;
2707
2882
  };
2708
2883
  type ReturnType = Transfer;
@@ -3957,7 +4132,12 @@ interface components {
3957
4132
  block_number: number;
3958
4133
  };
3959
4134
  ValidateOffersRequest: {
3960
- /** @description Array of offers in snake_case format. Required, non-empty. */offers: components["schemas"]["ValidateOfferRequest"][];
4135
+ /**
4136
+ * @description Chain id used for chain-scoped validation rules.
4137
+ * @example 1
4138
+ */
4139
+ chain_id: number; /** @description Array of offers in snake_case format. Required, non-empty. */
4140
+ offers: components["schemas"]["ValidateOfferRequest"][];
3961
4141
  };
3962
4142
  ValidateOfferRequest: {
3963
4143
  /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */maker: string; /** @example 369216000000000000000000 */
@@ -3970,8 +4150,7 @@ interface components {
3970
4150
  start: number; /** @example 0x000000000000000000000000000000000000000000000000000000000008b8f4 */
3971
4151
  group: string; /** @example 0x0000000000000000000000000000000000000000000000000000000000000000 */
3972
4152
  session: string; /** @example false */
3973
- buy: boolean; /** @example 1 */
3974
- chain_id: number; /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
4153
+ buy: boolean; /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
3975
4154
  loan_token: string;
3976
4155
  /**
3977
4156
  * @example [
@@ -4034,15 +4213,17 @@ type ObligationResponse = paths["/v1/obligations"]["get"]["responses"]["200"]["c
4034
4213
  * @constructor
4035
4214
  * @param obligation - {@link Obligation}
4036
4215
  * @param quote - {@link Quote}
4216
+ * @param chainId - The chain id used to compute `id`.
4037
4217
  * @returns The created `ObligationResponse`. {@link ObligationResponse}
4038
4218
  */
4039
- declare function from$3(obligation: Obligation, quote: Quote): ObligationResponse;
4219
+ declare function from$3(obligation: Obligation$1, quote: Quote, chainId: Id): ObligationResponse;
4040
4220
  declare namespace OfferResponse_d_exports {
4041
4221
  export { Input, OfferResponse, from$2 as from };
4042
4222
  }
4043
4223
  type OfferResponse = paths["/v1/offers"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
4044
4224
  type Input = Readonly<{
4045
4225
  hash: Hex;
4226
+ obligationId: Hex;
4046
4227
  maker: Address;
4047
4228
  assets: bigint;
4048
4229
  obligationUnits: bigint;
@@ -4118,7 +4299,8 @@ type PaginationParams = {
4118
4299
  };
4119
4300
  declare namespace getByUser {
4120
4301
  type Parameters = PaginationParams & {
4121
- /** The user address to get positions for. */user: Address;
4302
+ /** The user address to get positions for. */user: Address; /** The type of position to get. Default is all types. */
4303
+ type?: Type;
4122
4304
  };
4123
4305
  type PositionWithReserved = {
4124
4306
  chainId: Id;
@@ -4239,6 +4421,7 @@ declare const schemas: {
4239
4421
  limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
4240
4422
  }, z$1.core.$strip>;
4241
4423
  readonly validate_offers: z$1.ZodObject<{
4424
+ chain_id: z$1.ZodNumber;
4242
4425
  offers: z$1.ZodArray<z$1.ZodUnknown>;
4243
4426
  }, z$1.core.$strict>;
4244
4427
  readonly get_user_positions: z$1.ZodObject<{
@@ -4353,8 +4536,9 @@ declare namespace getObligations {
4353
4536
  };
4354
4537
  type ReturnType = {
4355
4538
  obligations: Compute<{
4356
- /** The obligation id. Uses {@link Obligation.id} to calculate the id.*/id: () => Hex;
4357
- } & Obligation & Omit<Quote, "obligationId">>[]; /** The pagination cursor. */
4539
+ /** The obligation id returned by the API. */id: Hex; /** The chain id used to compute the obligation id. */
4540
+ chainId: Id;
4541
+ } & Obligation$1 & Omit<Quote, "obligationId">>[]; /** The pagination cursor. */
4358
4542
  cursor: string | null;
4359
4543
  };
4360
4544
  type ErrorType = GetApiErrorType;
@@ -4526,7 +4710,10 @@ type GatekeeperClient = {
4526
4710
  statusCode: number;
4527
4711
  body: ConfigRulesPayload;
4528
4712
  }>; /** Validate offers and return decision results. */
4529
- isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>; /** Base URL for the gatekeeper service. */
4713
+ isAllowed: (parameters: {
4714
+ offers: Offer[];
4715
+ chainId: number;
4716
+ }) => Promise<Result<Offer, string>>; /** Base URL for the gatekeeper service. */
4530
4717
  baseUrl: string;
4531
4718
  };
4532
4719
  type ClientConfig = {
@@ -4542,14 +4729,18 @@ type ClientConfig = {
4542
4729
  */
4543
4730
  declare function createHttpClient(config: ClientConfig): GatekeeperClient;
4544
4731
  declare namespace Gatekeeper_d_exports {
4545
- export { Gatekeeper, Rules, create };
4732
+ export { Gatekeeper, Rules, RulesFactory, create };
4546
4733
  }
4547
4734
  type Rules = readonly Rule<Offer, string>[];
4735
+ type RulesFactory = (chainId: Id) => Rules;
4548
4736
  type Gatekeeper = {
4549
- isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>;
4737
+ isAllowed: (parameters: {
4738
+ offers: Offer[];
4739
+ chainId: Id;
4740
+ }) => Promise<Result<Offer, string>>;
4550
4741
  };
4551
4742
  type GatekeeperParameters = {
4552
- rules: Rules;
4743
+ rules: RulesFactory;
4553
4744
  };
4554
4745
  /**
4555
4746
  * Create a gatekeeper instance with the provided rules.
@@ -4559,25 +4750,13 @@ type GatekeeperParameters = {
4559
4750
  declare function create(parameters: GatekeeperParameters): Gatekeeper;
4560
4751
  //#endregion
4561
4752
  //#region src/gatekeeper/morphoRules.d.ts
4562
- 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">)[];
4753
+ declare const morphoRules: (parameters: {
4754
+ chains: Chain$1[];
4755
+ chainId: Id;
4756
+ }) => (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">)[];
4563
4757
  declare namespace Rules_d_exports {
4564
- export { ValidityParameters, amountMutualExclusivity, callback, chains, collateralToken, loanToken, maturity, oracle, sameMaker, validity };
4758
+ export { amountMutualExclusivity, callback, collateralToken, loanToken, maturity, oracle, sameMaker };
4565
4759
  }
4566
- type ValidityParameters = {
4567
- client: PublicClient<Transport, Chain$1>;
4568
- };
4569
- /**
4570
- * set of rules to validate offers.
4571
- *
4572
- * @param _parameters - Validity parameters with chain and client
4573
- * @returns Array of validation rules to evaluate against offers
4574
- */
4575
- declare function validity(_parameters: ValidityParameters): Rule<Offer, "expiry">[];
4576
- declare const chains: ({
4577
- chains
4578
- }: {
4579
- chains: Chain$1[];
4580
- }) => Rule<Offer, "chain_ids">;
4581
4760
  declare const maturity: ({
4582
4761
  maturities
4583
4762
  }: {
@@ -4595,9 +4774,11 @@ declare const callback: ({
4595
4774
  * @returns The issue that was found. If the offer is valid, this will be undefined.
4596
4775
  */
4597
4776
  declare const loanToken: ({
4598
- assetsByChainId
4777
+ assetsByChainId,
4778
+ chainId
4599
4779
  }: {
4600
4780
  assetsByChainId: Partial<Record<Id, Address[]>>;
4781
+ chainId: Id;
4601
4782
  }) => Rule<Offer, "loan_token">;
4602
4783
  /**
4603
4784
  * A validation rule that checks if the offer's collateral tokens are allowed for its chain.
@@ -4605,9 +4786,11 @@ declare const loanToken: ({
4605
4786
  * @returns The issue that was found. If the offer is valid, this will be undefined.
4606
4787
  */
4607
4788
  declare const collateralToken: ({
4608
- collateralAssetsByChainId
4789
+ collateralAssetsByChainId,
4790
+ chainId
4609
4791
  }: {
4610
4792
  collateralAssetsByChainId: Partial<Record<Id, Address[]>>;
4793
+ chainId: Id;
4611
4794
  }) => Rule<Offer, "collateral_token">;
4612
4795
  /**
4613
4796
  * A validation rule that checks if the offer's oracle addresses are allowed for its chain.
@@ -4615,9 +4798,11 @@ declare const collateralToken: ({
4615
4798
  * @returns The issue that was found. If the offer is valid, this will be undefined.
4616
4799
  */
4617
4800
  declare const oracle: ({
4618
- oraclesByChainId
4801
+ oraclesByChainId,
4802
+ chainId
4619
4803
  }: {
4620
4804
  oraclesByChainId: Partial<Record<Id, Address[]>>;
4805
+ chainId: Id;
4621
4806
  }) => Rule<Offer, "oracle">;
4622
4807
  /**
4623
4808
  * A batch validation rule that ensures all offers in a tree have the same maker address.
@@ -4823,5 +5008,5 @@ declare namespace index_d_exports$2 {
4823
5008
  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 };
4824
5009
  }
4825
5010
  //#endregion
4826
- 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 };
5011
+ 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 };
4827
5012
  //# sourceMappingURL=index.browser.d.mts.map