@morpho-dev/router 0.8.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.
Files changed (30) hide show
  1. package/dist/cli.js +2417 -975
  2. package/dist/drizzle/migrations/0026_add-receiver-if-maker-is-seller.sql +1 -0
  3. package/dist/drizzle/migrations/0027_debt-to-transfers.sql +239 -0
  4. package/dist/drizzle/migrations/0028_obligation_id_and_keys.sql +247 -0
  5. package/dist/drizzle/migrations/0029_collateral-positions.sql +248 -0
  6. package/dist/drizzle/migrations/0030_remove_chain_id_from_offer.sql +37 -0
  7. package/dist/drizzle/migrations/meta/0026_snapshot.json +1454 -0
  8. package/dist/drizzle/migrations/meta/0027_snapshot.json +1581 -0
  9. package/dist/drizzle/migrations/meta/0028_snapshot.json +1632 -0
  10. package/dist/drizzle/migrations/meta/0029_snapshot.json +1619 -0
  11. package/dist/drizzle/migrations/meta/0030_snapshot.json +1652 -0
  12. package/dist/drizzle/migrations/meta/_journal.json +35 -0
  13. package/dist/evm/bytecode/morpho.txt +1 -1
  14. package/dist/index.browser.d.mts +561 -317
  15. package/dist/index.browser.d.mts.map +1 -1
  16. package/dist/index.browser.d.ts +557 -313
  17. package/dist/index.browser.d.ts.map +1 -1
  18. package/dist/index.browser.js +4032 -3816
  19. package/dist/index.browser.js.map +1 -1
  20. package/dist/index.browser.mjs +4026 -3816
  21. package/dist/index.browser.mjs.map +1 -1
  22. package/dist/index.node.d.mts +1067 -447
  23. package/dist/index.node.d.mts.map +1 -1
  24. package/dist/index.node.d.ts +1067 -447
  25. package/dist/index.node.d.ts.map +1 -1
  26. package/dist/index.node.js +2466 -1195
  27. package/dist/index.node.js.map +1 -1
  28. package/dist/index.node.mjs +2439 -1174
  29. package/dist/index.node.mjs.map +1 -1
  30. package/package.json +2 -2
@@ -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";
@@ -582,7 +582,7 @@ declare const MorphoV2: readonly [{
582
582
  readonly stateMutability: "nonpayable";
583
583
  readonly inputs: readonly [{
584
584
  readonly type: "address";
585
- readonly name: "recipient";
585
+ readonly name: "feeRecipient";
586
586
  }];
587
587
  readonly outputs: readonly [];
588
588
  }, {
@@ -662,6 +662,15 @@ declare const MorphoV2: readonly [{
662
662
  }, {
663
663
  readonly type: "address";
664
664
  readonly name: "taker";
665
+ }, {
666
+ readonly type: "address";
667
+ readonly name: "takerCallback";
668
+ }, {
669
+ readonly type: "bytes";
670
+ readonly name: "takerCallbackData";
671
+ }, {
672
+ readonly type: "address";
673
+ readonly name: "receiverIfTakerIsSeller";
665
674
  }, {
666
675
  readonly type: "tuple";
667
676
  readonly components: readonly [{
@@ -723,6 +732,9 @@ declare const MorphoV2: readonly [{
723
732
  }, {
724
733
  readonly type: "bytes";
725
734
  readonly name: "callbackData";
735
+ }, {
736
+ readonly type: "address";
737
+ readonly name: "receiverIfMakerIsSeller";
726
738
  }];
727
739
  readonly name: "offer";
728
740
  }, {
@@ -744,12 +756,6 @@ declare const MorphoV2: readonly [{
744
756
  }, {
745
757
  readonly type: "bytes32[]";
746
758
  readonly name: "proof";
747
- }, {
748
- readonly type: "address";
749
- readonly name: "takerCallback";
750
- }, {
751
- readonly type: "bytes";
752
- readonly name: "takerCallbackData";
753
759
  }];
754
760
  readonly outputs: readonly [{
755
761
  readonly type: "uint256";
@@ -871,6 +877,9 @@ declare const MorphoV2: readonly [{
871
877
  }, {
872
878
  readonly type: "address";
873
879
  readonly name: "onBehalf";
880
+ }, {
881
+ readonly type: "address";
882
+ readonly name: "receiver";
874
883
  }];
875
884
  readonly outputs: readonly [{
876
885
  readonly type: "uint256";
@@ -913,6 +922,9 @@ declare const MorphoV2: readonly [{
913
922
  }, {
914
923
  readonly type: "address";
915
924
  readonly name: "onBehalf";
925
+ }, {
926
+ readonly type: "address";
927
+ readonly name: "receiver";
916
928
  }];
917
929
  readonly outputs: readonly [];
918
930
  }, {
@@ -1100,7 +1112,7 @@ declare const MorphoV2: readonly [{
1100
1112
  readonly type: "event";
1101
1113
  readonly inputs: readonly [{
1102
1114
  readonly type: "address";
1103
- readonly name: "recipient";
1115
+ readonly name: "feeRecipient";
1104
1116
  readonly indexed: true;
1105
1117
  }];
1106
1118
  }, {
@@ -1175,6 +1187,9 @@ declare const MorphoV2: readonly [{
1175
1187
  }, {
1176
1188
  readonly type: "bool";
1177
1189
  readonly name: "sellerIsBorrower";
1190
+ }, {
1191
+ readonly type: "address";
1192
+ readonly name: "sellerReceiver";
1178
1193
  }, {
1179
1194
  readonly type: "bytes32";
1180
1195
  readonly name: "group";
@@ -1188,7 +1203,6 @@ declare const MorphoV2: readonly [{
1188
1203
  readonly inputs: readonly [{
1189
1204
  readonly type: "address";
1190
1205
  readonly name: "caller";
1191
- readonly indexed: true;
1192
1206
  }, {
1193
1207
  readonly type: "bytes32";
1194
1208
  readonly name: "id";
@@ -1203,6 +1217,10 @@ declare const MorphoV2: readonly [{
1203
1217
  readonly type: "address";
1204
1218
  readonly name: "onBehalf";
1205
1219
  readonly indexed: true;
1220
+ }, {
1221
+ readonly type: "address";
1222
+ readonly name: "receiver";
1223
+ readonly indexed: true;
1206
1224
  }];
1207
1225
  }, {
1208
1226
  readonly name: "WithdrawCollateral";
@@ -1225,6 +1243,9 @@ declare const MorphoV2: readonly [{
1225
1243
  readonly type: "address";
1226
1244
  readonly name: "onBehalf";
1227
1245
  readonly indexed: true;
1246
+ }, {
1247
+ readonly type: "address";
1248
+ readonly name: "receiver";
1228
1249
  }];
1229
1250
  }];
1230
1251
  type MorphoV2 = typeof MorphoV2;
@@ -1398,7 +1419,7 @@ declare class ReorgError extends BaseError {
1398
1419
  constructor(blockNumber: number);
1399
1420
  }
1400
1421
  declare namespace Chain_d_exports {
1401
- 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 };
1402
1423
  }
1403
1424
  type Chain$1 = Compute<Omit<Chain<ChainFormatters, {
1404
1425
  morpho: ChainContract;
@@ -1439,7 +1460,7 @@ type Id = (typeof ChainId)[Uppercase<Name>];
1439
1460
  declare const chainIds: readonly Id[];
1440
1461
  declare function getChain(chainId: Id): Chain$1 | undefined;
1441
1462
  declare const getWhitelistedChains: () => Chain$1[];
1442
- declare const chains$1: Record<Lowercase<Name>, Chain$1>;
1463
+ declare const chains: Record<Lowercase<Name>, Chain$1>;
1443
1464
  declare function streamLogs<abiEvent extends AbiEvent | undefined = undefined>(parameters: {
1444
1465
  client: PublicClient;
1445
1466
  contractAddress?: Address;
@@ -1517,13 +1538,23 @@ declare class InvalidLLTVError extends BaseError {
1517
1538
  }
1518
1539
  declare const LLTVSchema: z$1.ZodPipe<z$1.ZodBigInt, z$1.ZodTransform<LLTV, bigint>>;
1519
1540
  declare namespace Collateral_d_exports {
1520
- 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 };
1521
1542
  }
1522
1543
  type Collateral = {
1523
1544
  /** Asset being used as collateral. */asset: Address; /** Liquidation Loan-to-Value of the collateral. */
1524
1545
  lltv: LLTV; /** Oracle contract used to price the collateral. */
1525
1546
  oracle: Address;
1526
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
+ }];
1527
1558
  declare const CollateralSchema: z$1.ZodObject<{
1528
1559
  asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1529
1560
  oracle: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
@@ -1637,102 +1668,33 @@ declare class DenominatorIsZeroError extends BaseError {
1637
1668
  readonly name = "ERC4626.DenominatorIsZeroError";
1638
1669
  constructor();
1639
1670
  }
1640
- declare namespace Liquidity_d_exports {
1641
- 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 };
1642
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;
1643
1683
  /**
1644
- * Represents a liquidity pool with a unique ID and amount.
1645
- */
1646
- type LiquidityPool = {
1647
- id: string;
1648
- amount: bigint;
1649
- };
1650
- /**
1651
- * Represents a hierarchical relationship between two liquidity pools.
1652
- */
1653
- type LiquidityLink = {
1654
- parentPoolId: string;
1655
- childPoolId: string;
1656
- priority: number;
1657
- };
1658
- /**
1659
- * Represents the connection between an offer and its liquidity pools.
1660
- */
1661
- type OfferLiquidityPool = {
1662
- offerHash: Hex;
1663
- poolId: string;
1664
- /**
1665
- * The available capacity/liquidity from this pool for this offer.
1666
- * Matches allowance amount from pool below.
1667
- */
1668
- amount: bigint;
1669
- };
1670
- /**
1671
- * Calculate maximum debt capacity from collateral amount.
1672
- * @param amount - Collateral amount
1673
- * @param oraclePrice - Oracle price (scaled to 36 decimals)
1674
- * @param lltv - Loan-to-value ratio (scaled to 18 decimals)
1675
- * @returns Maximum debt capacity
1676
- */
1677
- declare function calculateMaxDebt(amount: bigint, oraclePrice: bigint, lltv: bigint): bigint;
1678
- /**
1679
- * Generate pool ID for balance pools.
1680
- */
1681
- declare function generateBalancePoolId(parameters: {
1682
- user: Address;
1683
- chainId: Id;
1684
- token: Address;
1685
- }): string;
1686
- /**
1687
- * Generate pool ID for allowance pools.
1688
- */
1689
- declare function generateAllowancePoolId(parameters: {
1690
- user: Address;
1691
- chainId: Id;
1692
- token: Address;
1693
- }): string;
1694
- /**
1695
- * Generate pool ID for obligation collateral pools.
1696
- * Obligation collateral pools represent collateral already deposited in the obligation.
1697
- * These pools are shared across all offers with the same obligation.
1698
- */
1699
- declare function generateObligationCollateralPoolId(parameters: {
1700
- user: Address;
1701
- chainId: Id;
1702
- obligationId: Hex;
1703
- token: Address;
1704
- }): string;
1705
- /**
1706
- * Generate pool ID for debt pools.
1707
- */
1708
- declare function generateDebtPoolId(parameters: {
1709
- user: Address;
1710
- chainId: Id;
1711
- obligationId: Hex;
1712
- }): string;
1713
- /**
1714
- * Generate pool ID for user position in a vault.
1715
- */
1716
- declare function generateUserVaultPositionPoolId(parameters: {
1717
- user: Address;
1718
- chainId: Id;
1719
- vault: Address;
1720
- }): string;
1721
- /**
1722
- * 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.
1723
1688
  */
1724
- declare function generateVaultPositionPoolId(parameters: {
1725
- vault: Address;
1726
- chainId: Id;
1727
- marketId: string;
1728
- }): string;
1689
+ declare function toSnakeCase$1<T>(obj: T): Snake<T>;
1729
1690
  /**
1730
- * 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.
1731
1695
  */
1732
- declare function generateMarketLiquidityPoolId(parameters: {
1733
- chainId: Id;
1734
- marketId: string;
1735
- }): string;
1696
+ declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
1697
+ declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
1736
1698
  declare namespace Maturity_d_exports {
1737
1699
  export { InvalidDateError, InvalidFormatError, InvalidOptionError, Maturity, MaturityOptions, MaturitySchema, MaturityType, from$12 as from };
1738
1700
  }
@@ -1781,44 +1743,15 @@ declare class InvalidOptionError extends BaseError {
1781
1743
  readonly name = "Maturity.InvalidOptionError";
1782
1744
  constructor(input: string);
1783
1745
  }
1784
- declare namespace Format_d_exports {
1785
- export { Snake, fromSnakeCase$3 as fromSnakeCase, stringifyBigint, toSnakeCase$1 as toSnakeCase };
1786
- }
1787
- /** The snake case representation of a type with bigint values stringified. */
1788
- type Snake<T> = DeepMutable<SnakeKeys<StringifiedBigint<T>>>;
1789
- /** Make arrays/tuples and object props mutable, deeply. */
1790
- 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;
1791
- /** Stringifies bigint values to strings and preserves branded primitives. */
1792
- 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;
1793
- /** Key remapping that also preserves branded primitives. */
1794
- 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;
1795
- 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;
1796
- /**
1797
- * Formats object keys to snake case.
1798
- * Preserves ethereum addresses as is.
1799
- * Converts ethereum addresses to checksummed if used as values.
1800
- * Stringifies bigint values to strings.
1801
- */
1802
- declare function toSnakeCase$1<T>(obj: T): Snake<T>;
1803
- /**
1804
- * Formats a snake case object to its camel case type.
1805
- * Preserves ethereum addresses as is.
1806
- * Converts checksummed ethereum addresses to lowercase if used as values.
1807
- * @warning Does not unstringify bigint values.
1808
- */
1809
- declare function fromSnakeCase$3<T>(obj: Snake<T>): T;
1810
- declare function stringifyBigint<T>(value: T): StringifiedBigint<T>;
1811
1746
  declare namespace Obligation_d_exports {
1812
- 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 };
1813
1748
  }
1814
- type Obligation = {
1815
- /** The chain id where the liquidity for this obligation is located. */chainId: Id; /** The token that is being borrowed for this obligation. */
1816
- 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. */
1817
1751
  collaterals: Collateral[]; /** The maturity of the obligation. */
1818
1752
  maturity: Maturity;
1819
1753
  };
1820
1754
  declare const ObligationSchema: z$1.ZodObject<{
1821
- chainId: z$1.ZodNumber;
1822
1755
  loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1823
1756
  collaterals: z$1.ZodArray<z$1.ZodObject<{
1824
1757
  asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
@@ -1827,6 +1760,49 @@ declare const ObligationSchema: z$1.ZodObject<{
1827
1760
  }, z$1.core.$strip>>;
1828
1761
  maturity: z$1.ZodPipe<z$1.ZodNumber, z$1.ZodTransform<Maturity, number>>;
1829
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
+ }];
1830
1806
  /**
1831
1807
  * Creates an obligation from the given parameters.
1832
1808
  * @constructor
@@ -1837,7 +1813,6 @@ declare const ObligationSchema: z$1.ZodObject<{
1837
1813
  * @example
1838
1814
  * ```ts
1839
1815
  * const obligation = Obligation.from({
1840
- * chainId: 1,
1841
1816
  * loanToken: privateKeyToAccount(generatePrivateKey()).address,
1842
1817
  * collaterals: [
1843
1818
  * Collateral.from({
@@ -1853,12 +1828,11 @@ declare const ObligationSchema: z$1.ZodObject<{
1853
1828
  declare function from$11(parameters: from$11.Parameters): from$11.ReturnType;
1854
1829
  declare namespace from$11 {
1855
1830
  type Parameters = {
1856
- /** The chain id where the liquidity for this obligation is located. */chainId: number; /** The token that is being borrowed for this obligation. */
1857
- 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. */
1858
1832
  collaterals: from$13.Parameters[] | readonly from$13.Parameters[]; /** The maturity of the obligation. */
1859
1833
  maturity: from$12.Parameters;
1860
1834
  };
1861
- type ReturnType = Obligation;
1835
+ type ReturnType = Obligation$1;
1862
1836
  type ErrorType = InvalidObligationError;
1863
1837
  }
1864
1838
  /**
@@ -1869,30 +1843,27 @@ declare namespace from$11 {
1869
1843
  */
1870
1844
  declare function fromSnakeCase$2(input: fromSnakeCase$2.Parameters): fromSnakeCase$2.ReturnType;
1871
1845
  declare namespace fromSnakeCase$2 {
1872
- type Parameters = Snake<Omit<Obligation, "chainId"> & {
1873
- chainId: number;
1874
- }>;
1875
- type ReturnType = Obligation;
1846
+ type Parameters = Snake<Obligation$1>;
1847
+ type ReturnType = Obligation$1;
1876
1848
  type ErrorType = InvalidObligationError;
1877
1849
  }
1878
1850
  /**
1879
- * Calculates the obligation id based on the smart contract's Obligation struct.
1880
- * 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)).
1881
1853
  * @throws If the collaterals are not sorted alphabetically by address. {@link CollateralsAreNotSortedError}
1882
- * @param parameters - {@link id.Parameters}
1883
- * @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}
1884
1856
  *
1885
1857
  * @example
1886
1858
  * ```ts
1887
1859
  * const obligation = Obligation.random();
1888
- * const id = Obligation.id(obligation);
1889
- * console.log(id); // 0x1234567890123456789012345678901234567890123456789012345678901234
1860
+ * const key = Obligation.key(obligation);
1861
+ * console.log(key); // 0x1234567890123456789012345678901234567890123456789012345678901234
1890
1862
  * ```
1891
1863
  */
1892
- declare function id(parameters: id.Parameters): id.ReturnType;
1893
- declare namespace id {
1864
+ declare function key$1(parameters: key$1.Parameters): key$1.ReturnType;
1865
+ declare namespace key$1 {
1894
1866
  type Parameters = {
1895
- chainId: number;
1896
1867
  loanToken: Address;
1897
1868
  collaterals: {
1898
1869
  asset: Address;
@@ -1915,7 +1886,7 @@ declare namespace id {
1915
1886
  */
1916
1887
  declare function random$2(): random$2.ReturnType;
1917
1888
  declare namespace random$2 {
1918
- type ReturnType = Obligation;
1889
+ type ReturnType = Obligation$1;
1919
1890
  }
1920
1891
  /**
1921
1892
  * Creates an obligation from an offer.
@@ -1927,7 +1898,7 @@ declare namespace random$2 {
1927
1898
  declare function fromOffer$1(offer: Offer): fromOffer$1.ReturnType;
1928
1899
  declare namespace fromOffer$1 {
1929
1900
  type Parameters = Offer;
1930
- type ReturnType = Obligation;
1901
+ type ReturnType = Obligation$1;
1931
1902
  }
1932
1903
  declare class InvalidObligationError extends BaseError<z$1.ZodError | Error> {
1933
1904
  readonly name = "Obligation.InvalidObligationError";
@@ -1937,8 +1908,135 @@ declare class CollateralsAreNotSortedError extends BaseError {
1937
1908
  readonly name = "Obligation.CollateralsAreNotSortedError";
1938
1909
  constructor();
1939
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;
1940
2038
  declare namespace Offer_d_exports {
1941
- 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 };
1942
2040
  }
1943
2041
  type Offer = {
1944
2042
  /** The address that made the offer. */readonly maker: Address; /** The amount of assets offered. Mutually exclusive with obligationUnits and obligationShares. */
@@ -1951,14 +2049,14 @@ type Offer = {
1951
2049
  readonly start: number; /** The group. Used for OCO (One-Cancelled-Other) mechanism. */
1952
2050
  readonly group: Hex; /** The session. Used for session-based offer management. */
1953
2051
  readonly session: Hex; /** The side of the offer. `true` for buy, `false` for sell. */
1954
- readonly buy: boolean; /** The chain id where the liquidity for this offer is located. */
1955
- readonly chainId: Id; /** The token that is being borrowed. */
2052
+ readonly buy: boolean; /** The token that is being borrowed. */
1956
2053
  readonly loanToken: Address; /** The exact set of collaterals required to borrow the loan token. */
1957
2054
  readonly collaterals: readonly Collateral[]; /** The optional callback data to retrieve the maker funds. */
1958
2055
  readonly callback: {
1959
2056
  readonly address: Address;
1960
2057
  readonly data: Hex;
1961
- };
2058
+ }; /** Receiver of loan token proceeds when maker is seller on `take()`. */
2059
+ readonly receiverIfMakerIsSeller: Address;
1962
2060
  };
1963
2061
  declare enum Status {
1964
2062
  VALID = "VALID",
@@ -1966,6 +2064,7 @@ declare enum Status {
1966
2064
  }
1967
2065
  type Validation = {
1968
2066
  offerHash: Hex;
2067
+ obligationId: Hex;
1969
2068
  status: Status;
1970
2069
  };
1971
2070
  declare const OfferSchema: () => z$1.ZodObject<{
@@ -1980,7 +2079,6 @@ declare const OfferSchema: () => z$1.ZodObject<{
1980
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>>;
1981
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>>;
1982
2081
  buy: z$1.ZodBoolean;
1983
- chainId: z$1.ZodNumber;
1984
2082
  loanToken: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1985
2083
  collaterals: z$1.ZodArray<z$1.ZodObject<{
1986
2084
  asset: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
@@ -1991,6 +2089,7 @@ declare const OfferSchema: () => z$1.ZodObject<{
1991
2089
  address: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1992
2090
  data: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1993
2091
  }, z$1.core.$strip>;
2092
+ receiverIfMakerIsSeller: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
1994
2093
  }, z$1.core.$strip>;
1995
2094
  /**
1996
2095
  * Input type for creating offers. Accepts flexible group types that will be coerced to Hex.
@@ -2003,12 +2102,12 @@ declare const OfferSchema: () => z$1.ZodObject<{
2003
2102
  *
2004
2103
  * All values validated to be non-negative and within bytes32 range.
2005
2104
  */
2006
- type OfferInput = Compute<Omit<Offer, "chainId" | "group" | "session" | "obligationUnits" | "obligationShares"> & {
2007
- chainId: number;
2105
+ type OfferInput = Compute<Omit<Offer, "group" | "session" | "obligationUnits" | "obligationShares" | "receiverIfMakerIsSeller"> & {
2008
2106
  group: Hex | bigint | number | string; /** Optional: defaults to zero bytes32. */
2009
2107
  session?: Hex | bigint | number | string; /** Optional: defaults to 0n. Mutually exclusive with assets and obligationShares. */
2010
2108
  obligationUnits?: bigint; /** Optional: defaults to 0n. Mutually exclusive with assets and obligationUnits. */
2011
- obligationShares?: bigint;
2109
+ obligationShares?: bigint; /** Optional: defaults to maker for backward compatibility. */
2110
+ receiverIfMakerIsSeller?: Address;
2012
2111
  }>;
2013
2112
  /**
2014
2113
  * Creates an offer from a plain object.
@@ -2026,9 +2125,9 @@ declare namespace from$10 {
2026
2125
  * @param input - The offer to create.
2027
2126
  * @returns The created offer.
2028
2127
  */
2029
- declare function fromSnakeCase$1(input: Snake<Omit<Offer, "chainId" | "session"> & {
2030
- chainId: number;
2031
- session: string;
2128
+ declare function fromSnakeCase$1(input: Snake<Omit<Offer, "session" | "receiverIfMakerIsSeller"> & {
2129
+ session?: Hex;
2130
+ receiverIfMakerIsSeller?: Address;
2032
2131
  }>): Offer;
2033
2132
  /**
2034
2133
  * Converts an offer to a snake case object.
@@ -2055,7 +2154,6 @@ declare const serialize: (offer: Offer) => {
2055
2154
  group: `0x${string}`;
2056
2155
  session: `0x${string}`;
2057
2156
  buy: boolean;
2058
- chainId: Id;
2059
2157
  loanToken: `0x${string}`;
2060
2158
  collaterals: {
2061
2159
  asset: `0x${string}`;
@@ -2066,10 +2164,10 @@ declare const serialize: (offer: Offer) => {
2066
2164
  address: `0x${string}`;
2067
2165
  data: `0x${string}`;
2068
2166
  };
2167
+ receiverIfMakerIsSeller: `0x${string}`;
2069
2168
  hash: `0x${string}`;
2070
2169
  };
2071
2170
  type RandomConfig = {
2072
- chains?: Chain$1[];
2073
2171
  loanTokens?: Address[];
2074
2172
  collateralTokens?: Address[];
2075
2173
  assetsDecimals?: Record<Address, number>;
@@ -2088,6 +2186,7 @@ type RandomConfig = {
2088
2186
  address: Address;
2089
2187
  data: Hex;
2090
2188
  };
2189
+ receiverIfMakerIsSeller?: Address;
2091
2190
  collaterals?: readonly Collateral[];
2092
2191
  };
2093
2192
  /**
@@ -2098,93 +2197,28 @@ type RandomConfig = {
2098
2197
  */
2099
2198
  declare function random$1(config?: RandomConfig): Offer;
2100
2199
  /**
2101
- * Creates an EIP-712 domain object.
2102
- * @param chainId - The chain ID.
2103
- * @returns The EIP-712 domain object.
2104
- */
2105
- declare const domain: (chainId: number) => {
2106
- chainId: bigint;
2107
- verifyingContract: "0x0000000000000000000000000000000000000000";
2108
- };
2109
- /**
2110
- * The EIP-712 types for the offer.
2111
- * @warning The ordering of the types should NEVER be changed. The offer hash is computed based on the order of the types.
2112
- * @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.
2113
2205
  */
2114
- declare const types: {
2115
- readonly EIP712Domain: readonly [{
2116
- readonly name: "chainId";
2117
- readonly type: "uint256";
2118
- }, {
2119
- readonly name: "verifyingContract";
2120
- readonly type: "address";
2121
- }];
2122
- readonly Offer: readonly [{
2123
- readonly name: "maker";
2124
- readonly type: "address";
2125
- }, {
2126
- readonly name: "assets";
2127
- readonly type: "uint256";
2128
- }, {
2129
- readonly name: "obligationUnits";
2130
- readonly type: "uint256";
2131
- }, {
2132
- readonly name: "obligationShares";
2133
- readonly type: "uint256";
2134
- }, {
2135
- readonly name: "tick";
2136
- readonly type: "uint256";
2137
- }, {
2138
- readonly name: "maturity";
2139
- readonly type: "uint256";
2140
- }, {
2141
- readonly name: "expiry";
2142
- readonly type: "uint256";
2143
- }, {
2144
- readonly name: "group";
2145
- readonly type: "bytes32";
2146
- }, {
2147
- readonly name: "session";
2148
- readonly type: "bytes32";
2149
- }, {
2150
- readonly name: "buy";
2151
- readonly type: "bool";
2152
- }, {
2153
- readonly name: "loanToken";
2154
- readonly type: "address";
2155
- }, {
2156
- readonly name: "collaterals";
2157
- readonly type: "Collateral[]";
2158
- }, {
2159
- readonly name: "callback";
2160
- readonly type: "Callback";
2161
- }];
2162
- readonly Collateral: readonly [{
2163
- readonly name: "asset";
2164
- readonly type: "address";
2165
- }, {
2166
- readonly name: "oracle";
2167
- readonly type: "address";
2168
- }, {
2169
- readonly name: "lltv";
2170
- readonly type: "uint256";
2171
- }];
2172
- readonly Callback: readonly [{
2173
- readonly name: "address";
2174
- readonly type: "address";
2175
- }, {
2176
- readonly name: "data";
2177
- readonly type: "bytes";
2178
- }];
2179
- };
2180
2206
  declare function hash(offer: Offer): Hex;
2181
2207
  /**
2182
- * Calculates the obligation id for an offer based on the smart contract's Obligation struct.
2183
- * 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}.
2184
2210
  * @param offer - The offer to calculate the obligation id for.
2211
+ * @param parameters - The chain context used by the onchain id function.
2185
2212
  * @returns The obligation id as a 32-byte hex string.
2186
2213
  */
2187
- 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
+ }
2188
2222
  declare function encode$1(offer: Offer): `0x${string}`;
2189
2223
  declare function decode$1(data: Hex): Offer;
2190
2224
  type OfferConsumed = {
@@ -2256,6 +2290,11 @@ declare const takeEvent: {
2256
2290
  readonly type: "bool";
2257
2291
  readonly indexed: false;
2258
2292
  readonly internalType: "bool";
2293
+ }, {
2294
+ readonly name: "sellerReceiver";
2295
+ readonly type: "address";
2296
+ readonly indexed: false;
2297
+ readonly internalType: "address";
2259
2298
  }, {
2260
2299
  readonly name: "group";
2261
2300
  readonly type: "bytes32";
@@ -2293,6 +2332,160 @@ declare const consumedEvent: {
2293
2332
  }];
2294
2333
  readonly anonymous: false;
2295
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
+ };
2296
2489
  declare class InvalidOfferError extends BaseError<z$1.ZodError | Error> {
2297
2490
  readonly name = "Offer.InvalidOfferError";
2298
2491
  constructor(error: z$1.ZodError | Error);
@@ -2362,6 +2555,7 @@ declare namespace fromCollateral {
2362
2555
  declare function fromOffer(parameters: fromOffer.Parameters): fromOffer.ReturnType;
2363
2556
  declare namespace fromOffer {
2364
2557
  type Parameters = {
2558
+ chainId: Id;
2365
2559
  offer: Offer;
2366
2560
  blockNumber: number;
2367
2561
  price?: bigint | null;
@@ -2378,6 +2572,7 @@ declare namespace fromOffer {
2378
2572
  declare function fromOffers(parameters: fromOffers.Parameters): fromOffers.ReturnType;
2379
2573
  declare namespace fromOffers {
2380
2574
  type Parameters = {
2575
+ chainId: Id;
2381
2576
  offers: Offer[];
2382
2577
  blockNumber: number;
2383
2578
  price?: bigint | null;
@@ -2416,7 +2611,7 @@ declare namespace Conversion {
2416
2611
  }): bigint;
2417
2612
  }
2418
2613
  declare namespace Position_d_exports {
2419
- export { Position, Type, from$8 as from };
2614
+ export { Position, Type, from$8 as from, positionTypeId };
2420
2615
  }
2421
2616
  type Position = {
2422
2617
  /** The chain id. */chainId: Id;
@@ -2431,13 +2626,17 @@ type Position = {
2431
2626
  /** The underlying asset of the position.
2432
2627
  * For ERC20 positions, this equals the contract address.
2433
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.
2434
2631
  */
2435
- 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. */
2436
2633
  blockNumber: number;
2437
2634
  };
2438
2635
  declare enum Type {
2439
2636
  ERC20 = "erc20",
2440
- VAULT_V1 = "vault_v1"
2637
+ VAULT_V1 = "vault_v1",
2638
+ DEBT_OF = "debtOf",
2639
+ COLLATERAL_OF = "collateralOf"
2441
2640
  }
2442
2641
  /**
2443
2642
  * @constructor
@@ -2453,32 +2652,38 @@ declare namespace from$8 {
2453
2652
  user: Address;
2454
2653
  type: Type;
2455
2654
  balance?: bigint;
2456
- asset?: Address;
2655
+ asset: Address;
2457
2656
  blockNumber: number;
2458
2657
  };
2459
2658
  type ReturnType = Position;
2460
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;
2461
2666
  declare namespace Quote_d_exports {
2462
- export { InvalidQuoteError, Quote, QuoteSchema, from$7 as from, fromSnakeCase, random };
2667
+ export { InvalidQuoteError, Quote, QuoteInput, Side, from$7 as from, fromSnakeCase, random };
2463
2668
  }
2464
- type Quote = {
2669
+ type Side = {
2670
+ /** The best side tick, or null when no active quote exists. */tick: number | null; /** The side price for the obligation. (18 decimals). */
2671
+ price: bigint;
2672
+ };
2673
+ type QuoteInput = {
2465
2674
  /** The obligation id. */obligationId: Hex;
2466
2675
  ask: {
2467
- /** The ask price for the obligation. (18 decimals). */price: bigint;
2676
+ /** The best ask tick, or null when there is no active ask quote. */tick: number | null;
2468
2677
  };
2469
2678
  bid: {
2470
- /** The bid price for the obligation. (18 decimals). */price: bigint;
2679
+ /** The best bid tick, or null when there is no active bid quote. */tick: number | null;
2471
2680
  };
2472
2681
  };
2473
- declare const QuoteSchema: z$1.ZodObject<{
2474
- obligationId: z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>;
2475
- ask: z$1.ZodObject<{
2476
- price: z$1.ZodBigInt;
2477
- }, z$1.core.$strip>;
2478
- bid: z$1.ZodObject<{
2479
- price: z$1.ZodBigInt;
2480
- }, z$1.core.$strip>;
2481
- }, z$1.core.$strip>;
2682
+ type Quote = {
2683
+ /** The obligation id. */obligationId: Hex;
2684
+ ask: Side;
2685
+ bid: Side;
2686
+ };
2482
2687
  /**
2483
2688
  * Creates a quote for a given obligation.
2484
2689
  * @constructor
@@ -2488,12 +2693,12 @@ declare const QuoteSchema: z$1.ZodObject<{
2488
2693
  *
2489
2694
  * @example
2490
2695
  * ```ts
2491
- * const quote = Quote.from({ obligationId: "0x123", ask: { price: 100n }, bid: { price: 100n } });
2696
+ * const quote = Quote.from({ obligationId: "0x123", ask: { tick: 500 }, bid: { tick: 510 } });
2492
2697
  * ```
2493
2698
  */
2494
2699
  declare function from$7(parameters: from$7.Parameters): from$7.ReturnType;
2495
2700
  declare namespace from$7 {
2496
- type Parameters = Quote;
2701
+ type Parameters = QuoteInput;
2497
2702
  type ReturnType = Quote;
2498
2703
  type ErrorType = InvalidQuoteError;
2499
2704
  }
@@ -2505,7 +2710,7 @@ declare namespace from$7 {
2505
2710
  */
2506
2711
  declare function fromSnakeCase(snake: fromSnakeCase.Parameters): fromSnakeCase.ReturnType;
2507
2712
  declare namespace fromSnakeCase {
2508
- type Parameters = Snake<Quote>;
2713
+ type Parameters = Snake<QuoteInput>;
2509
2714
  type ReturnType = Quote;
2510
2715
  type ErrorType = from$7.ErrorType;
2511
2716
  }
@@ -2646,6 +2851,8 @@ type Transfer = {
2646
2851
  from: Address;
2647
2852
  to: Address;
2648
2853
  value: bigint;
2854
+ type: Type; /** The underlying asset of the transfer's position. */
2855
+ asset: Address;
2649
2856
  blockNumber: number;
2650
2857
  };
2651
2858
  /**
@@ -2669,6 +2876,8 @@ declare namespace from$5 {
2669
2876
  from: Address;
2670
2877
  to: Address;
2671
2878
  value: bigint;
2879
+ type: Type;
2880
+ asset: Address;
2672
2881
  blockNumber: number;
2673
2882
  };
2674
2883
  type ReturnType = Transfer;
@@ -3132,11 +3341,16 @@ interface paths {
3132
3341
  };
3133
3342
  /**
3134
3343
  * List all obligations
3135
- * @description Returns a list of obligations with their current best ask and bid. Obligations are sorted by their id in ascending order by default.
3344
+ * @description Returns a list of obligations with their current best ask and bid. Sorting is customizable with the sort parameter and defaults to id ascending.
3136
3345
  */
3137
3346
  get: {
3138
3347
  parameters: {
3139
3348
  query?: {
3349
+ /**
3350
+ * @description Sort order as comma-separated fields (`id`, `ask`, `bid`, `maturity`). Prefix with `-` for descending order. Max 3 fields.
3351
+ * @example -ask,bid,maturity
3352
+ */
3353
+ sort?: string;
3140
3354
  /**
3141
3355
  * @description Filter by exact maturity timestamps (comma-separated, unix seconds).
3142
3356
  * @example 1761922800,1764524800
@@ -3163,8 +3377,8 @@ interface paths {
3163
3377
  */
3164
3378
  limit?: number;
3165
3379
  /**
3166
- * @description Obligation id cursor for pagination.
3167
- * @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc
3380
+ * @description Pagination cursor in base64url-encoded format.
3381
+ * @example eyJzb3J0IjpbImlkIl0sImlkIjoiMHgxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAiLCJhc2siOiIwIiwiYmlkIjoiMCIsIm1hdHVyaXR5IjoxNzYxOTIyODAwfQ
3168
3382
  */
3169
3383
  cursor?: string;
3170
3384
  };
@@ -3649,7 +3863,8 @@ interface components {
3649
3863
  * "group": "0x000000000000000000000000000000000000000000000000000000000008b8f4",
3650
3864
  * "session": "0x0000000000000000000000000000000000000000000000000000000000000000",
3651
3865
  * "callback": "0x0000000000000000000000000000000000000000",
3652
- * "callback_data": "0x"
3866
+ * "callback_data": "0x",
3867
+ * "receiver_if_maker_is_seller": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401"
3653
3868
  * },
3654
3869
  * "offer_hash": "0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427",
3655
3870
  * "obligation_id": "0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc",
@@ -3693,7 +3908,8 @@ interface components {
3693
3908
  * "group": "0x000000000000000000000000000000000000000000000000000000000008b8f4",
3694
3909
  * "session": "0x0000000000000000000000000000000000000000000000000000000000000000",
3695
3910
  * "callback": "0x0000000000000000000000000000000000000000",
3696
- * "callback_data": "0x"
3911
+ * "callback_data": "0x",
3912
+ * "receiver_if_maker_is_seller": "0x7b093658BE7f90B63D7c359e8f408e503c2D9401"
3697
3913
  * }
3698
3914
  */
3699
3915
  offer: components["schemas"]["OfferDataResponse"]; /** @example 0xac4bd8318ec914f89f8af913f162230575b0ac0696a19256bc12138c5cfe1427 */
@@ -3739,7 +3955,8 @@ interface components {
3739
3955
  group: string; /** @example 0x0000000000000000000000000000000000000000000000000000000000000000 */
3740
3956
  session: string; /** @example 0x0000000000000000000000000000000000000000 */
3741
3957
  callback: string; /** @example 0x */
3742
- callback_data: string;
3958
+ callback_data: string; /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
3959
+ receiver_if_maker_is_seller: string;
3743
3960
  };
3744
3961
  ObligationOfferResponse: {
3745
3962
  /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */loan_token: string;
@@ -3761,7 +3978,7 @@ interface components {
3761
3978
  oracle: string;
3762
3979
  };
3763
3980
  ObligationListResponse: {
3764
- meta: components["schemas"]["Meta"]; /** @example 0x25690ae1aee324a005be565f3bcdd16dbf8daf7969b26c181c8b8f467dad9abc */
3981
+ meta: components["schemas"]["Meta"]; /** @example eyJzb3J0IjpbImlkIl0sImlkIjoiMHgxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAiLCJhc2siOiIwIiwiYmlkIjoiMCIsIm1hdHVyaXR5IjoxNzYxOTIyODAwfQ */
3765
3982
  cursor: string | null; /** @description List of obligations with takable offers. */
3766
3983
  data: components["schemas"]["ObligationResponse"][];
3767
3984
  };
@@ -3775,10 +3992,20 @@ interface components {
3775
3992
  bid: components["schemas"]["BidResponse"];
3776
3993
  };
3777
3994
  AskResponse: {
3778
- /** @example 1000000000000000000 */price: string;
3995
+ /**
3996
+ * @description Best ask tick. Null when there is no active ask quote.
3997
+ * @example 500
3998
+ */
3999
+ tick: number | null; /** @example 1000000000000000000 */
4000
+ price: string;
3779
4001
  };
3780
4002
  BidResponse: {
3781
- /** @example 1000000000000000000 */price: string;
4003
+ /**
4004
+ * @description Best bid tick. Null when there is no active bid quote.
4005
+ * @example 500
4006
+ */
4007
+ tick: number | null; /** @example 1000000000000000000 */
4008
+ price: string;
3782
4009
  };
3783
4010
  ObligationSingleSuccessResponse: {
3784
4011
  meta: components["schemas"]["Meta"]; /** @example null */
@@ -3905,7 +4132,12 @@ interface components {
3905
4132
  block_number: number;
3906
4133
  };
3907
4134
  ValidateOffersRequest: {
3908
- /** @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"][];
3909
4141
  };
3910
4142
  ValidateOfferRequest: {
3911
4143
  /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */maker: string; /** @example 369216000000000000000000 */
@@ -3918,8 +4150,7 @@ interface components {
3918
4150
  start: number; /** @example 0x000000000000000000000000000000000000000000000000000000000008b8f4 */
3919
4151
  group: string; /** @example 0x0000000000000000000000000000000000000000000000000000000000000000 */
3920
4152
  session: string; /** @example false */
3921
- buy: boolean; /** @example 1 */
3922
- chain_id: number; /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
4153
+ buy: boolean; /** @example 0xC9A9C45C0eB717f8b5F193Af6bAa05A1c0Ac5078 */
3923
4154
  loan_token: string;
3924
4155
  /**
3925
4156
  * @example [
@@ -3937,7 +4168,8 @@ interface components {
3937
4168
  * "data": "0x"
3938
4169
  * }
3939
4170
  */
3940
- callback: components["schemas"]["ValidateCallbackRequest"];
4171
+ callback: components["schemas"]["ValidateCallbackRequest"]; /** @example 0x7b093658BE7f90B63D7c359e8f408e503c2D9401 */
4172
+ receiver_if_maker_is_seller: string;
3941
4173
  };
3942
4174
  ValidateCollateralRequest: {
3943
4175
  /** @example 0x34Cf890dB685FC536E05652FB41f02090c3fb751 */asset: string; /** @example 0x45093658BE7f90B63D7c359e8f408e503c2D9401 */
@@ -3980,15 +4212,18 @@ type ObligationResponse = paths["/v1/obligations"]["get"]["responses"]["200"]["c
3980
4212
  * Creates an `ObligationResponse` from a `Obligation`.
3981
4213
  * @constructor
3982
4214
  * @param obligation - {@link Obligation}
4215
+ * @param quote - {@link Quote}
4216
+ * @param chainId - The chain id used to compute `id`.
3983
4217
  * @returns The created `ObligationResponse`. {@link ObligationResponse}
3984
4218
  */
3985
- declare function from$3(obligation: Obligation, quote: Quote): ObligationResponse;
4219
+ declare function from$3(obligation: Obligation$1, quote: Quote, chainId: Id): ObligationResponse;
3986
4220
  declare namespace OfferResponse_d_exports {
3987
4221
  export { Input, OfferResponse, from$2 as from };
3988
4222
  }
3989
4223
  type OfferResponse = paths["/v1/offers"]["get"]["responses"]["200"]["content"]["application/json"]["data"][number];
3990
4224
  type Input = Readonly<{
3991
4225
  hash: Hex;
4226
+ obligationId: Hex;
3992
4227
  maker: Address;
3993
4228
  assets: bigint;
3994
4229
  obligationUnits: bigint;
@@ -4011,6 +4246,7 @@ type Input = Readonly<{
4011
4246
  address: Address;
4012
4247
  data: Hex;
4013
4248
  };
4249
+ receiverIfMakerIsSeller: Address;
4014
4250
  root?: Hex | undefined;
4015
4251
  proof?: Hex[] | undefined;
4016
4252
  signature?: Hex | undefined;
@@ -4063,7 +4299,8 @@ type PaginationParams = {
4063
4299
  };
4064
4300
  declare namespace getByUser {
4065
4301
  type Parameters = PaginationParams & {
4066
- /** 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;
4067
4304
  };
4068
4305
  type PositionWithReserved = {
4069
4306
  chainId: Id;
@@ -4132,11 +4369,11 @@ declare const schemas: {
4132
4369
  cursor: z$1.ZodOptional<z$1.ZodString>;
4133
4370
  limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
4134
4371
  types: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodTransform<{} | null | undefined, unknown>, z$1.ZodArray<z$1.ZodEnum<{
4135
- oracle: "oracle";
4136
4372
  maturity: "maturity";
4137
4373
  callback: "callback";
4138
4374
  loan_token: "loan_token";
4139
4375
  collateral_token: "collateral_token";
4376
+ oracle: "oracle";
4140
4377
  }>>>>;
4141
4378
  chains: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodTransform<{} | null | undefined, unknown>, z$1.ZodArray<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>>>>;
4142
4379
  }, z$1.core.$strip>;
@@ -4168,6 +4405,7 @@ declare const schemas: {
4168
4405
  loan_tokens: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodTransform<{} | null | undefined, unknown>, z$1.ZodArray<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>>>;
4169
4406
  collateral_tokens: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodTransform<{} | null | undefined, unknown>, z$1.ZodArray<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<`0x${string}`, string>>>>>;
4170
4407
  maturities: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodTransform<{} | null | undefined, unknown>, z$1.ZodArray<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>>>>;
4408
+ sort: z$1.ZodOptional<z$1.ZodPipe<z$1.ZodTransform<{} | null | undefined, unknown>, z$1.ZodArray<z$1.ZodString>>>;
4171
4409
  limit: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodPipe<z$1.ZodPipe<z$1.ZodString, z$1.ZodTransform<number, string>>, z$1.ZodNumber>>>;
4172
4410
  }, z$1.core.$strip>;
4173
4411
  readonly get_obligation: z$1.ZodObject<{
@@ -4183,6 +4421,7 @@ declare const schemas: {
4183
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>>>;
4184
4422
  }, z$1.core.$strip>;
4185
4423
  readonly validate_offers: z$1.ZodObject<{
4424
+ chain_id: z$1.ZodNumber;
4186
4425
  offers: z$1.ZodArray<z$1.ZodUnknown>;
4187
4426
  }, z$1.core.$strict>;
4188
4427
  readonly get_user_positions: z$1.ZodObject<{
@@ -4284,18 +4523,22 @@ declare namespace getOffers {
4284
4523
  }
4285
4524
  declare function getObligations(apiClient: Client<paths>, parameters?: getObligations.Parameters): Promise<getObligations.ReturnType>;
4286
4525
  declare namespace getObligations {
4526
+ type SortField = "id" | "ask" | "bid" | "maturity";
4527
+ type SortEntry = SortField | `-${SortField}`;
4287
4528
  type Parameters = {
4288
- /** Pagination cursor is a 32-byte hex string. */cursor?: Hex; /** Maximum number of obligations to return. @default 20 */
4529
+ /** Pagination cursor in base64url-encoded format. */cursor?: string; /** Maximum number of obligations to return. @default 20 */
4289
4530
  limit?: number; /** Filter by chain IDs (comma-separated). */
4290
4531
  chainIds?: number[]; /** Filter by loan token addresses (comma-separated). */
4291
4532
  loanTokens?: Address[]; /** Filter by collateral tokens (comma-separated, matches any collateral). */
4292
4533
  collateralTokens?: Address[]; /** Filter by exact maturity timestamps (comma-separated, unix seconds). */
4293
- maturities?: number[];
4534
+ maturities?: number[]; /** Sort order entries in priority order. Prefix with '-' for descending. Max 3 fields. */
4535
+ sort?: SortEntry[];
4294
4536
  };
4295
4537
  type ReturnType = {
4296
4538
  obligations: Compute<{
4297
- /** The obligation id. Uses {@link Obligation.id} to calculate the id.*/id: () => Hex;
4298
- } & 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. */
4299
4542
  cursor: string | null;
4300
4543
  };
4301
4544
  type ErrorType = GetApiErrorType;
@@ -4467,7 +4710,10 @@ type GatekeeperClient = {
4467
4710
  statusCode: number;
4468
4711
  body: ConfigRulesPayload;
4469
4712
  }>; /** Validate offers and return decision results. */
4470
- 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. */
4471
4717
  baseUrl: string;
4472
4718
  };
4473
4719
  type ClientConfig = {
@@ -4483,14 +4729,18 @@ type ClientConfig = {
4483
4729
  */
4484
4730
  declare function createHttpClient(config: ClientConfig): GatekeeperClient;
4485
4731
  declare namespace Gatekeeper_d_exports {
4486
- export { Gatekeeper, Rules, create };
4732
+ export { Gatekeeper, Rules, RulesFactory, create };
4487
4733
  }
4488
4734
  type Rules = readonly Rule<Offer, string>[];
4735
+ type RulesFactory = (chainId: Id) => Rules;
4489
4736
  type Gatekeeper = {
4490
- isAllowed: (offers: Offer[]) => Promise<Result<Offer, string>>;
4737
+ isAllowed: (parameters: {
4738
+ offers: Offer[];
4739
+ chainId: Id;
4740
+ }) => Promise<Result<Offer, string>>;
4491
4741
  };
4492
4742
  type GatekeeperParameters = {
4493
- rules: Rules;
4743
+ rules: RulesFactory;
4494
4744
  };
4495
4745
  /**
4496
4746
  * Create a gatekeeper instance with the provided rules.
@@ -4500,25 +4750,13 @@ type GatekeeperParameters = {
4500
4750
  declare function create(parameters: GatekeeperParameters): Gatekeeper;
4501
4751
  //#endregion
4502
4752
  //#region src/gatekeeper/morphoRules.d.ts
4503
- 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">)[];
4504
4757
  declare namespace Rules_d_exports {
4505
- export { ValidityParameters, amountMutualExclusivity, callback, chains, collateralToken, loanToken, maturity, oracle, sameMaker, validity };
4758
+ export { amountMutualExclusivity, callback, collateralToken, loanToken, maturity, oracle, sameMaker };
4506
4759
  }
4507
- type ValidityParameters = {
4508
- client: PublicClient<Transport, Chain$1>;
4509
- };
4510
- /**
4511
- * set of rules to validate offers.
4512
- *
4513
- * @param _parameters - Validity parameters with chain and client
4514
- * @returns Array of validation rules to evaluate against offers
4515
- */
4516
- declare function validity(_parameters: ValidityParameters): Rule<Offer, "expiry">[];
4517
- declare const chains: ({
4518
- chains
4519
- }: {
4520
- chains: Chain$1[];
4521
- }) => Rule<Offer, "chain_ids">;
4522
4760
  declare const maturity: ({
4523
4761
  maturities
4524
4762
  }: {
@@ -4536,9 +4774,11 @@ declare const callback: ({
4536
4774
  * @returns The issue that was found. If the offer is valid, this will be undefined.
4537
4775
  */
4538
4776
  declare const loanToken: ({
4539
- assetsByChainId
4777
+ assetsByChainId,
4778
+ chainId
4540
4779
  }: {
4541
4780
  assetsByChainId: Partial<Record<Id, Address[]>>;
4781
+ chainId: Id;
4542
4782
  }) => Rule<Offer, "loan_token">;
4543
4783
  /**
4544
4784
  * A validation rule that checks if the offer's collateral tokens are allowed for its chain.
@@ -4546,9 +4786,11 @@ declare const loanToken: ({
4546
4786
  * @returns The issue that was found. If the offer is valid, this will be undefined.
4547
4787
  */
4548
4788
  declare const collateralToken: ({
4549
- collateralAssetsByChainId
4789
+ collateralAssetsByChainId,
4790
+ chainId
4550
4791
  }: {
4551
4792
  collateralAssetsByChainId: Partial<Record<Id, Address[]>>;
4793
+ chainId: Id;
4552
4794
  }) => Rule<Offer, "collateral_token">;
4553
4795
  /**
4554
4796
  * A validation rule that checks if the offer's oracle addresses are allowed for its chain.
@@ -4556,9 +4798,11 @@ declare const collateralToken: ({
4556
4798
  * @returns The issue that was found. If the offer is valid, this will be undefined.
4557
4799
  */
4558
4800
  declare const oracle: ({
4559
- oraclesByChainId
4801
+ oraclesByChainId,
4802
+ chainId
4560
4803
  }: {
4561
4804
  oraclesByChainId: Partial<Record<Id, Address[]>>;
4805
+ chainId: Id;
4562
4806
  }) => Rule<Offer, "oracle">;
4563
4807
  /**
4564
4808
  * A batch validation rule that ensures all offers in a tree have the same maker address.
@@ -4764,5 +5008,5 @@ declare namespace index_d_exports$2 {
4764
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 };
4765
5009
  }
4766
5010
  //#endregion
4767
- 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 };
4768
5012
  //# sourceMappingURL=index.browser.d.mts.map