@morpho-org/morpho-sdk 9.6.0-next.0 → 9.7.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 (211) hide show
  1. package/MIGRATION-v6-to-v7.md +1 -1
  2. package/README.md +123 -3
  3. package/lib/cjs/abis.d.ts +1 -1
  4. package/lib/cjs/abis.js +1 -5
  5. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -2
  6. package/lib/cjs/actions/bundles/common.js +39 -32
  7. package/lib/cjs/actions/midnight/cancelAndMake.js +20 -98
  8. package/lib/cjs/actions/midnight/index.d.ts +2 -0
  9. package/lib/cjs/actions/midnight/index.js +2 -0
  10. package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +5 -6
  11. package/lib/cjs/actions/midnight/supplyCollateralBatch.d.ts +39 -0
  12. package/lib/cjs/actions/midnight/supplyCollateralBatch.js +91 -0
  13. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +31 -32
  14. package/lib/cjs/actions/midnight/takeBorrow.js +24 -23
  15. package/lib/cjs/actions/midnight/takeLend.js +24 -23
  16. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +20 -19
  17. package/lib/cjs/actions/midnight/takeWithdraw.js +24 -23
  18. package/lib/cjs/actions/midnight/withdrawCollateralBatch.d.ts +44 -0
  19. package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +104 -0
  20. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -0
  21. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -0
  22. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +1 -0
  23. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +1 -0
  24. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +1 -0
  25. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +1 -0
  26. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -0
  27. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +1 -0
  28. package/lib/cjs/actions/vaultV1/migrateToV2.js +7 -7
  29. package/lib/cjs/blue/abis.d.ts +1 -1
  30. package/lib/cjs/blue/abis.js +1 -5
  31. package/lib/cjs/blue/entities.d.ts +4 -4
  32. package/lib/cjs/blue/entities.js +1 -3
  33. package/lib/cjs/blue/errors.d.ts +2 -2
  34. package/lib/cjs/blue/errors.js +1 -5
  35. package/lib/cjs/blue/fetch.d.ts +2 -2
  36. package/lib/cjs/blue/fetch.js +1 -3
  37. package/lib/cjs/blue/utils.d.ts +1 -1
  38. package/lib/cjs/blue/utils.js +1 -2
  39. package/lib/cjs/entities/index.d.ts +5 -5
  40. package/lib/cjs/entities/index.js +1 -3
  41. package/lib/cjs/entities/midnight/midnight.d.ts +77 -3
  42. package/lib/cjs/entities/midnight/midnight.js +174 -0
  43. package/lib/cjs/entities/midnight/types.d.ts +16 -0
  44. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +12 -46
  45. package/lib/cjs/entities/requirements/getErc2612Permit.d.ts +7 -0
  46. package/lib/cjs/entities/requirements/getErc2612Permit.js +60 -0
  47. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +2 -2
  48. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +3 -3
  49. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +10 -35
  50. package/lib/cjs/entities/vaultV2/vaultV2.js +1 -33
  51. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -5
  52. package/lib/cjs/entities/vaultV2BlueReallocationData.js +3 -9
  53. package/lib/cjs/errors.d.ts +4 -4
  54. package/lib/cjs/errors.js +6 -7
  55. package/lib/cjs/fetch.d.ts +2 -2
  56. package/lib/cjs/fetch.js +1 -3
  57. package/lib/cjs/helpers/deadShares.js +0 -2
  58. package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +1 -0
  59. package/lib/cjs/helpers/signAndVerifyTypedData.js +12 -5
  60. package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.d.ts +68 -0
  61. package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.js +129 -0
  62. package/lib/cjs/helpers/validateMidnightCollateralBatch.d.ts +15 -0
  63. package/lib/cjs/helpers/validateMidnightCollateralBatch.js +28 -0
  64. package/lib/cjs/helpers/validateMidnightCollateralSupplies.d.ts +17 -0
  65. package/lib/cjs/helpers/validateMidnightCollateralSupplies.js +28 -0
  66. package/lib/cjs/helpers/validatePositiveInput.d.ts +10 -0
  67. package/lib/cjs/helpers/validatePositiveInput.js +18 -0
  68. package/lib/cjs/index.d.ts +2 -0
  69. package/lib/cjs/index.js +18 -1
  70. package/lib/cjs/midnight/errors.d.ts +1 -2
  71. package/lib/cjs/midnight/errors.js +5 -5
  72. package/lib/cjs/transactionPlan/approval.d.ts +2 -0
  73. package/lib/cjs/transactionPlan/approval.js +16 -0
  74. package/lib/cjs/transactionPlan/error.d.ts +145 -0
  75. package/lib/cjs/transactionPlan/error.js +186 -0
  76. package/lib/cjs/transactionPlan/getTokenPermit.d.ts +11 -0
  77. package/lib/cjs/transactionPlan/getTokenPermit.js +18 -0
  78. package/lib/cjs/transactionPlan/index.d.ts +9 -0
  79. package/lib/cjs/transactionPlan/index.js +24 -0
  80. package/lib/cjs/transactionPlan/intent.d.ts +51 -0
  81. package/lib/cjs/transactionPlan/intent.js +54 -0
  82. package/lib/cjs/transactionPlan/permit.d.ts +13 -0
  83. package/lib/cjs/transactionPlan/permit.js +145 -0
  84. package/lib/cjs/transactionPlan/plan.d.ts +99 -0
  85. package/lib/cjs/transactionPlan/plan.js +232 -0
  86. package/lib/cjs/transactionPlan/requirements.d.ts +44 -0
  87. package/lib/cjs/transactionPlan/requirements.js +79 -0
  88. package/lib/cjs/transactionPlan/serde.d.ts +33 -0
  89. package/lib/cjs/transactionPlan/serde.js +205 -0
  90. package/lib/cjs/transactionPlan/types.d.ts +91 -0
  91. package/lib/cjs/transactionPlan/types.js +2 -0
  92. package/lib/cjs/transactionPlan/validateActions.d.ts +8 -0
  93. package/lib/cjs/transactionPlan/validateActions.js +19 -0
  94. package/lib/cjs/transactionPlan/validation.d.ts +17 -0
  95. package/lib/cjs/transactionPlan/validation.js +70 -0
  96. package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +81 -0
  97. package/lib/cjs/transactionPlan/vaultv2/deposit.js +211 -0
  98. package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +77 -0
  99. package/lib/cjs/transactionPlan/vaultv2/withdraw.js +190 -0
  100. package/lib/cjs/transactionPlan/version.d.ts +2 -0
  101. package/lib/cjs/transactionPlan/version.js +9 -0
  102. package/lib/cjs/types/action.d.ts +18 -3
  103. package/lib/cjs/types/error.d.ts +23 -2
  104. package/lib/cjs/types/error.js +45 -5
  105. package/lib/cjs/utils.d.ts +2 -2
  106. package/lib/cjs/utils.js +2 -4
  107. package/lib/esm/abis.d.ts +1 -1
  108. package/lib/esm/abis.js +1 -1
  109. package/lib/esm/actions/blue/repayWithdrawCollateral.js +2 -2
  110. package/lib/esm/actions/bundles/common.js +39 -32
  111. package/lib/esm/actions/midnight/cancelAndMake.js +25 -103
  112. package/lib/esm/actions/midnight/index.d.ts +2 -0
  113. package/lib/esm/actions/midnight/index.js +2 -0
  114. package/lib/esm/actions/midnight/repayWithdrawCollateral.js +5 -6
  115. package/lib/esm/actions/midnight/supplyCollateralBatch.d.ts +39 -0
  116. package/lib/esm/actions/midnight/supplyCollateralBatch.js +87 -0
  117. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +33 -34
  118. package/lib/esm/actions/midnight/takeBorrow.js +25 -24
  119. package/lib/esm/actions/midnight/takeLend.js +25 -24
  120. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +20 -19
  121. package/lib/esm/actions/midnight/takeWithdraw.js +25 -24
  122. package/lib/esm/actions/midnight/withdrawCollateralBatch.d.ts +44 -0
  123. package/lib/esm/actions/midnight/withdrawCollateralBatch.js +100 -0
  124. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -0
  125. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -0
  126. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +1 -0
  127. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +1 -0
  128. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +1 -0
  129. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +1 -0
  130. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -0
  131. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +1 -0
  132. package/lib/esm/actions/vaultV1/migrateToV2.js +8 -8
  133. package/lib/esm/blue/abis.d.ts +1 -1
  134. package/lib/esm/blue/abis.js +1 -1
  135. package/lib/esm/blue/entities.d.ts +4 -4
  136. package/lib/esm/blue/entities.js +2 -2
  137. package/lib/esm/blue/errors.d.ts +2 -2
  138. package/lib/esm/blue/errors.js +2 -2
  139. package/lib/esm/blue/fetch.d.ts +2 -2
  140. package/lib/esm/blue/fetch.js +2 -2
  141. package/lib/esm/blue/utils.d.ts +1 -1
  142. package/lib/esm/blue/utils.js +1 -1
  143. package/lib/esm/entities/index.d.ts +5 -5
  144. package/lib/esm/entities/index.js +2 -2
  145. package/lib/esm/entities/midnight/midnight.d.ts +77 -3
  146. package/lib/esm/entities/midnight/midnight.js +176 -2
  147. package/lib/esm/entities/midnight/types.d.ts +16 -0
  148. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +14 -48
  149. package/lib/esm/entities/requirements/getErc2612Permit.d.ts +7 -0
  150. package/lib/esm/entities/requirements/getErc2612Permit.js +57 -0
  151. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +2 -2
  152. package/lib/esm/entities/vaultV1/vaultV1.d.ts +3 -3
  153. package/lib/esm/entities/vaultV2/vaultV2.d.ts +10 -35
  154. package/lib/esm/entities/vaultV2/vaultV2.js +1 -33
  155. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -5
  156. package/lib/esm/entities/vaultV2BlueReallocationData.js +3 -9
  157. package/lib/esm/errors.d.ts +4 -4
  158. package/lib/esm/errors.js +4 -4
  159. package/lib/esm/fetch.d.ts +2 -2
  160. package/lib/esm/fetch.js +2 -2
  161. package/lib/esm/helpers/deadShares.js +1 -3
  162. package/lib/esm/helpers/signAndVerifyTypedData.d.ts +1 -0
  163. package/lib/esm/helpers/signAndVerifyTypedData.js +13 -6
  164. package/lib/esm/helpers/validateMidnightCancelAndMakePublication.d.ts +68 -0
  165. package/lib/esm/helpers/validateMidnightCancelAndMakePublication.js +124 -0
  166. package/lib/esm/helpers/validateMidnightCollateralBatch.d.ts +15 -0
  167. package/lib/esm/helpers/validateMidnightCollateralBatch.js +25 -0
  168. package/lib/esm/helpers/validateMidnightCollateralSupplies.d.ts +17 -0
  169. package/lib/esm/helpers/validateMidnightCollateralSupplies.js +24 -0
  170. package/lib/esm/helpers/validatePositiveInput.d.ts +10 -0
  171. package/lib/esm/helpers/validatePositiveInput.js +14 -0
  172. package/lib/esm/index.d.ts +2 -0
  173. package/lib/esm/index.js +1 -0
  174. package/lib/esm/midnight/errors.d.ts +1 -2
  175. package/lib/esm/midnight/errors.js +1 -2
  176. package/lib/esm/transactionPlan/approval.d.ts +2 -0
  177. package/lib/esm/transactionPlan/approval.js +13 -0
  178. package/lib/esm/transactionPlan/error.d.ts +145 -0
  179. package/lib/esm/transactionPlan/error.js +175 -0
  180. package/lib/esm/transactionPlan/getTokenPermit.d.ts +11 -0
  181. package/lib/esm/transactionPlan/getTokenPermit.js +15 -0
  182. package/lib/esm/transactionPlan/index.d.ts +9 -0
  183. package/lib/esm/transactionPlan/index.js +5 -0
  184. package/lib/esm/transactionPlan/intent.d.ts +51 -0
  185. package/lib/esm/transactionPlan/intent.js +51 -0
  186. package/lib/esm/transactionPlan/permit.d.ts +13 -0
  187. package/lib/esm/transactionPlan/permit.js +140 -0
  188. package/lib/esm/transactionPlan/plan.d.ts +99 -0
  189. package/lib/esm/transactionPlan/plan.js +226 -0
  190. package/lib/esm/transactionPlan/requirements.d.ts +44 -0
  191. package/lib/esm/transactionPlan/requirements.js +74 -0
  192. package/lib/esm/transactionPlan/serde.d.ts +33 -0
  193. package/lib/esm/transactionPlan/serde.js +201 -0
  194. package/lib/esm/transactionPlan/types.d.ts +91 -0
  195. package/lib/esm/transactionPlan/types.js +1 -0
  196. package/lib/esm/transactionPlan/validateActions.d.ts +8 -0
  197. package/lib/esm/transactionPlan/validateActions.js +16 -0
  198. package/lib/esm/transactionPlan/validation.d.ts +17 -0
  199. package/lib/esm/transactionPlan/validation.js +64 -0
  200. package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +81 -0
  201. package/lib/esm/transactionPlan/vaultv2/deposit.js +206 -0
  202. package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +77 -0
  203. package/lib/esm/transactionPlan/vaultv2/withdraw.js +185 -0
  204. package/lib/esm/transactionPlan/version.d.ts +2 -0
  205. package/lib/esm/transactionPlan/version.js +6 -0
  206. package/lib/esm/types/action.d.ts +18 -3
  207. package/lib/esm/types/error.d.ts +23 -2
  208. package/lib/esm/types/error.js +40 -3
  209. package/lib/esm/utils.d.ts +2 -2
  210. package/lib/esm/utils.js +2 -2
  211. package/package.json +8 -7
@@ -46,6 +46,7 @@ export interface EncodeVaultSharesPermitParams {
46
46
  * wallet account differs from `userAddress`.
47
47
  * @throws {ChainIdMismatchError} from `sign()` when the wallet targets another chain.
48
48
  * @throws {InvalidSignatureError} from `sign()` when signature recovery fails.
49
+ * @throws {MalformedSignatureError} from `sign()` when the wallet returns a malformed signature.
49
50
  * @throws {InvalidPermitDomainChainIdError} when a Vault V1 permit domain targets another chain or omits `chainId`.
50
51
  * @throws {InvalidPermitDomainVerifyingContractError} when a Vault V1 permit domain targets another token or omits `verifyingContract`.
51
52
  * @throws {UnsupportedPermitDomainExtensionsError} when a Vault V1 permit domain advertises unsupported extensions.
@@ -33,6 +33,7 @@ import { ExpiredDeadlineError, } from "../../../types/index.js";
33
33
  * wallet account differs from `userAddress`.
34
34
  * @throws {ChainIdMismatchError} from `sign()` when the wallet targets another chain.
35
35
  * @throws {InvalidSignatureError} from `sign()` when signature recovery fails.
36
+ * @throws {MalformedSignatureError} from `sign()` when the wallet returns a malformed signature.
36
37
  * @throws {InvalidPermitDomainChainIdError} when a Vault V1 permit domain targets another chain or omits `chainId`.
37
38
  * @throws {InvalidPermitDomainVerifyingContractError} when a Vault V1 permit domain targets another token or omits `verifyingContract`.
38
39
  * @throws {UnsupportedPermitDomainExtensionsError} when a Vault V1 permit domain advertises unsupported extensions.
@@ -2,7 +2,8 @@ import { getChainAddress } from "@morpho-org/morpho-ts";
2
2
  import { encodeFunctionData, isAddressEqual } from "viem";
3
3
  import { vaultBundlesV1Abi } from "../../abis.js";
4
4
  import { validateUint256Field } from "../../helpers/validate.js";
5
- import { AmountAndSharesExclusiveError, NonPositiveInputError, SameVaultMigrationError, VaultAssetMismatchError, } from "../../types/index.js";
5
+ import { validatePositiveInput } from "../../helpers/validatePositiveInput.js";
6
+ import { AmountAndSharesExclusiveError, SameVaultMigrationError, VaultAssetMismatchError, } from "../../types/index.js";
6
7
  import { finalizeVaultBundlesV1Transaction, getBundlesReferralFeeAssets, getBundlesSharesPermit, normalizeBundlesCommonParams, } from "../bundles/common.js";
7
8
  /**
8
9
  * Encodes an assets-or-shares Vault V1 to Vault V2 migration through VaultBundlesV1.
@@ -86,14 +87,13 @@ export const vaultV1MigrateToV2 = (params) => {
86
87
  throw new AmountAndSharesExclusiveError();
87
88
  }
88
89
  const selectedAmount = assets ?? shares ?? 0n;
89
- if (selectedAmount <= 0n) {
90
- throw new NonPositiveInputError(assets != null ? "assets" : "shares", selectedAmount);
91
- }
92
- if (params.args.maxSharePriceVaultV2 <= 0n) {
93
- throw new NonPositiveInputError("maxSharePriceVaultV2", params.args.maxSharePriceVaultV2);
94
- }
90
+ const amountField = assets != null ? "assets" : "shares";
91
+ // Validation only; rejects non-positive migration amounts.
92
+ validatePositiveInput(amountField, selectedAmount);
93
+ // Validation only; rejects non-positive share-price bounds.
94
+ validatePositiveInput("maxSharePriceVaultV2", params.args.maxSharePriceVaultV2);
95
95
  // Reject ABI overflow with SDK errors before calldata encoding.
96
- validateUint256Field(assets != null ? "assets" : "shares", selectedAmount);
96
+ validateUint256Field(amountField, selectedAmount);
97
97
  validateUint256Field("maxSharePriceVaultV2", params.args.maxSharePriceVaultV2);
98
98
  const common = normalizeBundlesCommonParams(params.args);
99
99
  const spender = getChainAddress(params.vault.chainId, "bundles.vaultBundlesV1");
@@ -1,5 +1,5 @@
1
1
  export { marketParamsAbi } from "@morpho-org/blue-sdk";
2
- export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
2
+ export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
3
3
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
4
  preLiquidationAbi,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
@@ -1,5 +1,5 @@
1
1
  export { marketParamsAbi } from "@morpho-org/blue-sdk";
2
- export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
2
+ export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
3
3
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
4
  preLiquidationAbi,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
@@ -1,10 +1,10 @@
1
- export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MidnightAdapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition,
1
+ export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  IPreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MidnightAdapter, IVaultV2MidnightAdapterAccrualMarket, IVaultV2MidnightAdapterCollateralParams, IVaultV2MidnightAdapterMarket, IVaultV2MidnightAdapterMarketData, IVaultV2MidnightAdapterMarketState, IVaultV2MidnightAdapterPosition, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, VaultV2MidnightAdapterAccrualMarket, VaultV2MidnightAdapterMarketData, } from "@morpho-org/blue-sdk";
6
- export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MidnightAdapter, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
5
+ IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
6
+ export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
7
7
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
8
8
  PreLiquidationParams,
9
9
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
10
- PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MidnightAdapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
10
+ PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
@@ -1,5 +1,5 @@
1
- export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MidnightAdapter, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
1
+ export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  PreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MidnightAdapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
5
+ PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
@@ -1,4 +1,4 @@
1
- export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError, InvalidPositionAccrualStateError, InvalidPositionLossFactorError, InvalidVaultV2MidnightAdapterMarketsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
1
+ export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
4
- export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnresolvedBlockNumberError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
4
+ export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
@@ -1,4 +1,4 @@
1
- export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError, InvalidPositionAccrualStateError, InvalidPositionLossFactorError, InvalidVaultV2MidnightAdapterMarketsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
1
+ export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
4
- export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnresolvedBlockNumberError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
4
+ export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
@@ -1,5 +1,5 @@
1
- export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MidnightAdapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
1
+ export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  fetchPreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MidnightAdapter, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
5
+ fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
@@ -1,5 +1,5 @@
1
- export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MidnightAdapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
1
+ export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  fetchPreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MidnightAdapter, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
5
+ fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
@@ -3,5 +3,5 @@ export { AdaptiveCurveIrmLib, CapacityLimitReason,
3
3
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
4
  defaultPreLiquidationParamsRegistry,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
6
- getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2MidnightAdapterUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
6
+ getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
7
7
  export { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
@@ -2,5 +2,5 @@ export { AdaptiveCurveIrmLib, CapacityLimitReason,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  defaultPreLiquidationParamsRegistry,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2MidnightAdapterUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
5
+ getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
6
6
  export { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
@@ -1,18 +1,18 @@
1
- export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MidnightAdapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition,
1
+ export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  IPreLiquidationParams as IBluePreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MidnightAdapter, IVaultV2MidnightAdapterAccrualMarket, IVaultV2MidnightAdapterCollateralParams, IVaultV2MidnightAdapterMarket, IVaultV2MidnightAdapterMarketData, IVaultV2MidnightAdapterMarketState, IVaultV2MidnightAdapterPosition, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, VaultV2MidnightAdapterAccrualMarket, VaultV2MidnightAdapterMarketData, } from "@morpho-org/blue-sdk";
6
- export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MidnightAdapter, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
5
+ IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
6
+ export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
7
7
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
8
8
  PreLiquidationParams as BluePreLiquidationParams,
9
9
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
10
- PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MidnightAdapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
10
+ PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
11
11
  export type { AnyTree as MidnightAnyTree, AnyTreeSnapshot as MidnightAnyTreeSnapshot, BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, EcrecoverTreeCreateRequest as MidnightEcrecoverTreeCreateRequest, GroupInput as MidnightGroupInput, IAccrualPosition as IMidnightAccrualPosition, ICollateralParams as IMidnightCollateralParams, IGroup as IMidnightGroup, IMarket as IMidnightMarket, IMarketParams as IMidnightMarketParams, IOffer as IMidnightOffer, IPosition as IMidnightPosition, MarketInput as MidnightMarketInput, OfferStruct as MidnightOfferStruct, PriceRatifierV1TreeCreateRequest as MidnightPriceRatifierV1TreeCreateRequest, RateRatifierV1TreeCreateRequest as MidnightRateRatifierV1TreeCreateRequest, RatifierKind as MidnightRatifierKind, RatifierTreeInput as MidnightRatifierTreeInput, RatifierTypes as MidnightRatifierTypes, SetterTreeCreateRequest as MidnightSetterTreeCreateRequest, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeCreateRequest as MidnightTreeCreateRequest, TreeData as MidnightTreeData, TreeDescriptor as MidnightTreeDescriptor, TreeEntry as MidnightTreeEntry, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, TreeSnapshot as MidnightTreeSnapshot, TypedRatifierTreeInput as MidnightTypedRatifierTreeInput, TypedTreeMempoolValidateParams as MidnightTypedTreeMempoolValidateParams, } from "@morpho-org/midnight-sdk";
12
12
  export { AccrualPosition as MidnightAccrualPosition, Group as MidnightGroup, Market as MidnightMarket, MarketParams as MidnightMarketParams, Offer as MidnightOffer, Position as MidnightPosition, Tree as MidnightTree, } from "@morpho-org/midnight-sdk";
13
13
  export type { BlueActions, BlueTokenRequirementsParams, } from "./blue/index.js";
14
14
  export { MorphoBlue } from "./blue/index.js";
15
- export type { GetOffersDataParams as MidnightGetOffersDataParams, GetPositionDataParams as MidnightGetPositionDataParams, MakeLendParams as MidnightMakeLendParams, MakeOffersOutput as MidnightMakeOffersOutput, MakeOffersParams as MidnightMakeOffersParams, MarketActionParams as MidnightMarketActionParams, MidnightMakerTreeInput, MidnightPositionHealthParams, OffersData as MidnightOffersData, OfferValidationParams as MidnightOfferValidationParams, RedeemParams as MidnightRedeemParams, RepayWithdrawCollateralParams as MidnightRepayWithdrawCollateralParams, SupplyBlueMakeLendParams as MidnightSupplyBlueMakeLendParams, SupplyCollateralMakeBorrowParams as MidnightSupplyCollateralMakeBorrowParams, SupplyCollateralParams as MidnightSupplyCollateralParams, SupplyCollateralTakeBorrowParams as MidnightSupplyCollateralTakeBorrowParams, TakeBorrowParams as MidnightTakeBorrowParams, TakeLendParams as MidnightTakeLendParams, TakeRepayWithdrawCollateralParams as MidnightTakeRepayWithdrawCollateralParams, TakeWithdrawParams as MidnightTakeWithdrawParams, WithdrawCollateralParams as MidnightWithdrawCollateralParams, } from "./midnight/index.js";
15
+ export type { GetOffersDataParams as MidnightGetOffersDataParams, GetPositionDataParams as MidnightGetPositionDataParams, MakeLendParams as MidnightMakeLendParams, MakeOffersOutput as MidnightMakeOffersOutput, MakeOffersParams as MidnightMakeOffersParams, MarketActionParams as MidnightMarketActionParams, MidnightMakerTreeInput, MidnightPositionHealthParams, OffersData as MidnightOffersData, OfferValidationParams as MidnightOfferValidationParams, RedeemParams as MidnightRedeemParams, RepayWithdrawCollateralParams as MidnightRepayWithdrawCollateralParams, SupplyBlueMakeLendParams as MidnightSupplyBlueMakeLendParams, SupplyCollateralBatchParams as MidnightSupplyCollateralBatchParams, SupplyCollateralMakeBorrowParams as MidnightSupplyCollateralMakeBorrowParams, SupplyCollateralParams as MidnightSupplyCollateralParams, SupplyCollateralTakeBorrowParams as MidnightSupplyCollateralTakeBorrowParams, TakeBorrowParams as MidnightTakeBorrowParams, TakeLendParams as MidnightTakeLendParams, TakeRepayWithdrawCollateralParams as MidnightTakeRepayWithdrawCollateralParams, TakeWithdrawParams as MidnightTakeWithdrawParams, WithdrawCollateralBatchParams as MidnightWithdrawCollateralBatchParams, WithdrawCollateralParams as MidnightWithdrawCollateralParams, } from "./midnight/index.js";
16
16
  export { type MidnightActionOutput, type MidnightActions, type MidnightRequirementsParams, MorphoMidnight, } from "./midnight/index.js";
17
17
  export * from "./requirements/index.js";
18
18
  export { MorphoVaultV1 } from "./vaultV1/index.js";
@@ -1,8 +1,8 @@
1
- export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MidnightAdapter, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
1
+ export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  PreLiquidationParams as BluePreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MidnightAdapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
5
+ PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
6
6
  export { AccrualPosition as MidnightAccrualPosition, Group as MidnightGroup, Market as MidnightMarket, MarketParams as MidnightMarketParams, Offer as MidnightOffer, Position as MidnightPosition, Tree as MidnightTree, } from "@morpho-org/midnight-sdk";
7
7
  export { MorphoBlue } from "./blue/index.js";
8
8
  export { MorphoMidnight, } from "./midnight/index.js";
@@ -1,8 +1,8 @@
1
1
  import { type AccrualPosition, type Market, type MidnightFetchParams } from "@morpho-org/midnight-sdk";
2
2
  import { type Address, type Hex } from "viem";
3
3
  import type { MorphoClientType } from "../../types/client.js";
4
- import { type MidnightCancelAndMakeAction, type MidnightGroupCancellation, type MidnightRedeemAction, type MidnightRepayWithdrawCollateralAction, type MidnightSupplyCollateralAction, type MidnightSupplyCollateralTakeBorrowAction, type MidnightTakeBorrowAction, type MidnightTakeLendAction, type MidnightTakeRepayWithdrawCollateralAction, type MidnightTakeWithdrawAction, type MidnightWithdrawCollateralAction } from "../../types/index.js";
5
- import type { GetOffersDataParams, GetPositionDataParams, MakeLendParams, MakeOffersOutput, MakeOffersParams, MidnightActionOutput, OffersData, RedeemParams, RepayWithdrawCollateralParams, SupplyBlueMakeLendParams, SupplyCollateralMakeBorrowParams, SupplyCollateralParams, SupplyCollateralTakeBorrowParams, TakeBorrowParams, TakeLendParams, TakeRepayWithdrawCollateralParams, TakeWithdrawParams, WithdrawCollateralParams } from "./types.js";
4
+ import { type MidnightCancelAndMakeAction, type MidnightGroupCancellation, type MidnightRedeemAction, type MidnightRepayWithdrawCollateralAction, type MidnightSupplyCollateralAction, type MidnightSupplyCollateralBatchAction, type MidnightSupplyCollateralTakeBorrowAction, type MidnightTakeBorrowAction, type MidnightTakeLendAction, type MidnightTakeRepayWithdrawCollateralAction, type MidnightTakeWithdrawAction, type MidnightWithdrawCollateralAction, type MidnightWithdrawCollateralBatchAction } from "../../types/index.js";
5
+ import type { GetOffersDataParams, GetPositionDataParams, MakeLendParams, MakeOffersOutput, MakeOffersParams, MidnightActionOutput, OffersData, RedeemParams, RepayWithdrawCollateralParams, SupplyBlueMakeLendParams, SupplyCollateralBatchParams, SupplyCollateralMakeBorrowParams, SupplyCollateralParams, SupplyCollateralTakeBorrowParams, TakeBorrowParams, TakeLendParams, TakeRepayWithdrawCollateralParams, TakeWithdrawParams, WithdrawCollateralBatchParams, WithdrawCollateralParams } from "./types.js";
6
6
  /**
7
7
  * Entity methods exposed by `client.morpho.midnight(chainId)`.
8
8
  *
@@ -30,7 +30,7 @@ import type { GetOffersDataParams, GetPositionDataParams, MakeLendParams, MakeOf
30
30
  * const tx = output.buildTx();
31
31
  * ```
32
32
  */
33
- export type MidnightActions = Pick<MorphoMidnight, "getMarketData" | "getPositionData" | "getOffersData" | "takeLend" | "takeBorrow" | "takeWithdraw" | "supplyCollateralTakeBorrow" | "takeRepayWithdrawCollateral" | "supplyCollateral" | "withdrawCollateral" | "makeLend" | "makeBorrow" | "supplyBlueMakeLend" | "makeWithdraw" | "makeRepay" | "supplyCollateralMakeBorrow" | "redeem" | "repayWithdrawCollateral" | "cancelOffers">;
33
+ export type MidnightActions = Pick<MorphoMidnight, "getMarketData" | "getPositionData" | "getOffersData" | "takeLend" | "takeBorrow" | "takeWithdraw" | "supplyCollateralTakeBorrow" | "takeRepayWithdrawCollateral" | "supplyCollateral" | "supplyCollateralBatch" | "withdrawCollateral" | "withdrawCollateralBatch" | "makeLend" | "makeBorrow" | "supplyBlueMakeLend" | "makeWithdraw" | "makeRepay" | "supplyCollateralMakeBorrow" | "redeem" | "repayWithdrawCollateral" | "cancelOffers">;
34
34
  /**
35
35
  * Entity facade for Midnight fixed-rate action flows.
36
36
  *
@@ -637,6 +637,52 @@ export declare class MorphoMidnight {
637
637
  * ```
638
638
  */
639
639
  withdrawCollateral(params: WithdrawCollateralParams): MidnightActionOutput<MidnightWithdrawCollateralAction>;
640
+ /**
641
+ * Withdraws an ordered collateral batch atomically from Midnight without bundle authorization or token pulls.
642
+ *
643
+ * Uses the supplied position snapshot to resolve maxUint256 and check collateral health.
644
+ * Duplicates are rejected, unlike bundle flows which sum them.
645
+ * No requirements or RPC reads are needed. The signing account must be accountAddress.
646
+ *
647
+ * @param params - Market, owner-bound position, collateral prices and withdrawal amount.
648
+ * @param params.accountAddress - Collateral owner. This account must send the transaction.
649
+ * @param params.marketData - Hydrated market snapshot used for validation and transaction construction.
650
+ * @param params.positionData - Owner-bound position snapshot returned by getPositionData.
651
+ * @param params.collateralPrices - Oracle prices indexed like positionData.collateral and scaled by
652
+ * ORACLE_PRICE_SCALE; required when the position has debt, otherwise an empty array is safe.
653
+ * @param params.collateralWithdrawals - Nonempty ordered withdrawals, one per index.
654
+ * maxUint256 resolves that index's full snapshot balance.
655
+ * @param params.receiver - Account receiving the withdrawn collateral; defaults to accountAddress.
656
+ * @returns Lazy handles for a direct Midnight withdrawal.
657
+ * @throws {ChainIdMismatchError} when the client or market targets another chain.
658
+ * @throws {MidnightCalldataEncodingError} when accountAddress is malformed or an input cannot be ABI-encoded.
659
+ * @throws {MidnightZeroAccountError} when accountAddress is zero.
660
+ * @throws {MidnightMarketAddressMismatchError} when marketData targets another Midnight deployment.
661
+ * @throws {MissingMarketPriceError} when debt is positive and held collateral has no supplied price.
662
+ * @throws {MarketIdMismatchError} when positionData belongs to another market.
663
+ * @throws {AccrualPositionUserMismatchError} when positionData belongs to another account.
664
+ * @throws {UnknownCollateralIndexError} when collateralIndex is not configured.
665
+ * @throws {EmptyMidnightCollateralWithdrawalsError} when the list is empty.
666
+ * @throws {DuplicateMidnightCollateralIndexError} when an index repeats.
667
+ * @throws {NonPositiveInputError} when the resolved amount is not positive.
668
+ * @throws {InputExceedsMaxError} when assets exceeds uint128.
669
+ * @throws {WithdrawExceedsCollateralError} when assets exceeds the collateral balance.
670
+ * @throws {WithdrawMakesPositionUnhealthyError} when remaining collateral cannot safely cover debt.
671
+ * @throws {MidnightZeroReceiverError} when receiver is zero.
672
+ * @throws {MidnightContractReceiverError} when receiver cannot safely receive collateral.
673
+ * @example
674
+ * ```ts
675
+ * const output = midnight.withdrawCollateralBatch({
676
+ * accountAddress: user,
677
+ * marketData,
678
+ * positionData,
679
+ * collateralPrices,
680
+ * collateralWithdrawals: [{ collateralIndex: 0n, assets: 1_000n }],
681
+ * });
682
+ * const tx = output.buildTx();
683
+ * ```
684
+ */
685
+ withdrawCollateralBatch(params: WithdrawCollateralBatchParams): MidnightActionOutput<MidnightWithdrawCollateralBatchAction>;
640
686
  /**
641
687
  * Prepares a direct collateral supply using a caller-provided market snapshot.
642
688
  *
@@ -675,6 +721,34 @@ export declare class MorphoMidnight {
675
721
  * ```
676
722
  */
677
723
  supplyCollateral(params: SupplyCollateralParams): MidnightActionOutput<MidnightSupplyCollateralAction>;
724
+ /**
725
+ * Prepares ordered direct collateral supplies in one Midnight multicall.
726
+ * Pass one entry per index: duplicates are rejected, unlike bundle flows which sum them.
727
+ *
728
+ * @param params.accountAddress - Sender and collateral beneficiary.
729
+ * @param params.marketData - Snapshot of the target market.
730
+ * @param params.collateralSupplies - Ordered supplies with optional reserved allowance amounts.
731
+ * @returns A lazy approval resolver and synchronous stateless transaction builder.
732
+ * @throws {ChainIdMismatchError} when the client or market targets another chain.
733
+ * @throws {MidnightMarketAddressMismatchError} when the deployment differs.
734
+ * @throws {MidnightCalldataEncodingError} when the account is malformed.
735
+ * @throws {NegativeInputError} when reserved assets are negative.
736
+ * @throws {NonPositiveInputError} when assets are not positive.
737
+ * @throws {InputExceedsMaxError} when assets exceed uint128.
738
+ * @throws {UnknownCollateralIndexError} when an index is not configured.
739
+ * @throws {EmptyMidnightCollateralSuppliesError} when the list is empty.
740
+ * @throws {DuplicateMidnightCollateralIndexError} when an index repeats.
741
+ * @throws {MidnightZeroOnBehalfError} when requirements or construction uses the zero account.
742
+ * @example
743
+ * ```ts
744
+ * const output = midnight.supplyCollateralBatch({
745
+ * accountAddress: user, marketData,
746
+ * collateralSupplies: [{ collateralIndex: 0n, assets: 100n }],
747
+ * });
748
+ * const tx = output.buildTx();
749
+ * ```
750
+ */
751
+ supplyCollateralBatch(params: SupplyCollateralBatchParams): MidnightActionOutput<MidnightSupplyCollateralBatchAction>;
678
752
  /**
679
753
  * Prepares an atomic lend-offer publication or repost through `MidnightBundlesV2`.
680
754
  *
@@ -3,7 +3,7 @@ import { fetchMarket as fetchBlueMarket } from "@morpho-org/blue-sdk-viem";
3
3
  import { fetchAccrualPosition, fetchMarket, MarketParams, MarketUtils, Payload, PriceRatifierV1, RateRatifierV1, Tree, } from "@morpho-org/midnight-sdk";
4
4
  import { _try, getChainAddress, Time } from "@morpho-org/morpho-ts";
5
5
  import { isAddress, isAddressEqual, maxUint256, zeroAddress, } from "viem";
6
- import { midnightCancelAndMake, midnightRedeem, midnightRepayWithdrawCollateral, midnightSupplyCollateral, midnightSupplyCollateralTakeBorrow, midnightTakeBorrow, midnightTakeLend, midnightTakeRepayWithdrawCollateral, midnightTakeWithdraw, midnightWithdrawCollateral, } from "../../actions/midnight/index.js";
6
+ import { midnightCancelAndMake, midnightRedeem, midnightRepayWithdrawCollateral, midnightSupplyCollateral, midnightSupplyCollateralBatch, midnightSupplyCollateralTakeBorrow, midnightTakeBorrow, midnightTakeLend, midnightTakeRepayWithdrawCollateral, midnightTakeWithdraw, midnightWithdrawCollateral, midnightWithdrawCollateralBatch, } from "../../actions/midnight/index.js";
7
7
  import { getMidnightApprovalRequirements, getMidnightAuthorizationRequirement, } from "../../actions/requirements/index.js";
8
8
  import { validateClientChainId } from "../../actions/requirements/validateClientChainId.js";
9
9
  import { getMidnightBlueBuyCallbackAddress, getMidnightBlueBuyCallbackData, } from "../../helpers/callback.js";
@@ -12,11 +12,12 @@ import { encodeMidnightMarketId, wrapMidnightEncoding, } from "../../helpers/enc
12
12
  import { getMidnightMaxSafeDebt, validateChainId, } from "../../helpers/index.js";
13
13
  import { validateMidnightAccount, validateMidnightAddress, } from "../../helpers/validateMidnightAccount.js";
14
14
  import { validateMidnightUint128Field } from "../../helpers/validateMidnightBounds.js";
15
+ import { validateMidnightCollateralBatch } from "../../helpers/validateMidnightCollateralBatch.js";
15
16
  import { validateMidnightMarket } from "../../helpers/validateMidnightMarket.js";
16
17
  import { validateMidnightBytes32 } from "../../helpers/validateMidnightPublication.js";
17
18
  import { validateMidnightTakeFeasibility } from "../../helpers/validateMidnightTakeFeasibility.js";
18
19
  import { validateOfferSides } from "../../helpers/validateOfferSides.js";
19
- import { AccrualPositionUserMismatchError, BorrowExceedsSafeLtvError, EmptyBlueParkingMarketError, InsufficientMidnightWithdrawableLiquidityError, MarketIdMismatchError, MidnightInvalidAccountAddressError, MidnightOfferCallbackDataMismatchError, MidnightOfferCallbackMismatchError, MidnightOfferContinuousFeeCapError, MidnightOfferMakerMismatchError, MidnightOfferMarketAddressMismatchError, MidnightOfferMarketChainMismatchError, MidnightOfferMarketLoanTokenMismatchError, MidnightOfferNotReduceOnlyError, MidnightOfferRatifierMismatchError, MidnightOfferReduceOnlyError, MidnightOfferSellerReceiverMismatchError, MidnightRedeemExceedsCreditError, MidnightRepayExceedsDebtError, MidnightTakeDeadlineTooFarError, MidnightTakeTargetUnreachableError, MidnightZeroOnBehalfError, MissingAccrualPositionError, NegativeInputError, NoMidnightCreditToRedeemError, NonPositiveInputError, WithdrawExceedsCollateralError, WithdrawMakesPositionUnhealthyError, ZeroBlueParkingSharesError, } from "../../types/index.js";
20
+ import { AccrualPositionUserMismatchError, BorrowExceedsSafeLtvError, EmptyBlueParkingMarketError, EmptyMidnightCollateralSuppliesError, EmptyMidnightCollateralWithdrawalsError, InsufficientMidnightWithdrawableLiquidityError, MarketIdMismatchError, MidnightInvalidAccountAddressError, MidnightOfferCallbackDataMismatchError, MidnightOfferCallbackMismatchError, MidnightOfferContinuousFeeCapError, MidnightOfferMakerMismatchError, MidnightOfferMarketAddressMismatchError, MidnightOfferMarketChainMismatchError, MidnightOfferMarketLoanTokenMismatchError, MidnightOfferNotReduceOnlyError, MidnightOfferRatifierMismatchError, MidnightOfferReduceOnlyError, MidnightOfferSellerReceiverMismatchError, MidnightRedeemExceedsCreditError, MidnightRepayExceedsDebtError, MidnightTakeDeadlineTooFarError, MidnightTakeTargetUnreachableError, MidnightZeroOnBehalfError, MissingAccrualPositionError, NegativeInputError, NoMidnightCreditToRedeemError, NonPositiveInputError, WithdrawExceedsCollateralError, WithdrawMakesPositionUnhealthyError, ZeroBlueParkingSharesError, } from "../../types/index.js";
20
21
  import { validateMidnightDeadline } from "./deadline.js";
21
22
  import { fetchMidnightMakerOfferStates, offerMarketParams, validateMidnightMakerOfferCallbacks, validateMidnightMakerOfferStates, } from "./publication.js";
22
23
  const validatePositionBinding = (params) => {
@@ -1161,6 +1162,106 @@ export class MorphoMidnight {
1161
1162
  }
1162
1163
  return { getRequirements: async () => [], buildTx: () => tx };
1163
1164
  }
1165
+ /**
1166
+ * Withdraws an ordered collateral batch atomically from Midnight without bundle authorization or token pulls.
1167
+ *
1168
+ * Uses the supplied position snapshot to resolve maxUint256 and check collateral health.
1169
+ * Duplicates are rejected, unlike bundle flows which sum them.
1170
+ * No requirements or RPC reads are needed. The signing account must be accountAddress.
1171
+ *
1172
+ * @param params - Market, owner-bound position, collateral prices and withdrawal amount.
1173
+ * @param params.accountAddress - Collateral owner. This account must send the transaction.
1174
+ * @param params.marketData - Hydrated market snapshot used for validation and transaction construction.
1175
+ * @param params.positionData - Owner-bound position snapshot returned by getPositionData.
1176
+ * @param params.collateralPrices - Oracle prices indexed like positionData.collateral and scaled by
1177
+ * ORACLE_PRICE_SCALE; required when the position has debt, otherwise an empty array is safe.
1178
+ * @param params.collateralWithdrawals - Nonempty ordered withdrawals, one per index.
1179
+ * maxUint256 resolves that index's full snapshot balance.
1180
+ * @param params.receiver - Account receiving the withdrawn collateral; defaults to accountAddress.
1181
+ * @returns Lazy handles for a direct Midnight withdrawal.
1182
+ * @throws {ChainIdMismatchError} when the client or market targets another chain.
1183
+ * @throws {MidnightCalldataEncodingError} when accountAddress is malformed or an input cannot be ABI-encoded.
1184
+ * @throws {MidnightZeroAccountError} when accountAddress is zero.
1185
+ * @throws {MidnightMarketAddressMismatchError} when marketData targets another Midnight deployment.
1186
+ * @throws {MissingMarketPriceError} when debt is positive and held collateral has no supplied price.
1187
+ * @throws {MarketIdMismatchError} when positionData belongs to another market.
1188
+ * @throws {AccrualPositionUserMismatchError} when positionData belongs to another account.
1189
+ * @throws {UnknownCollateralIndexError} when collateralIndex is not configured.
1190
+ * @throws {EmptyMidnightCollateralWithdrawalsError} when the list is empty.
1191
+ * @throws {DuplicateMidnightCollateralIndexError} when an index repeats.
1192
+ * @throws {NonPositiveInputError} when the resolved amount is not positive.
1193
+ * @throws {InputExceedsMaxError} when assets exceeds uint128.
1194
+ * @throws {WithdrawExceedsCollateralError} when assets exceeds the collateral balance.
1195
+ * @throws {WithdrawMakesPositionUnhealthyError} when remaining collateral cannot safely cover debt.
1196
+ * @throws {MidnightZeroReceiverError} when receiver is zero.
1197
+ * @throws {MidnightContractReceiverError} when receiver cannot safely receive collateral.
1198
+ * @example
1199
+ * ```ts
1200
+ * const output = midnight.withdrawCollateralBatch({
1201
+ * accountAddress: user,
1202
+ * marketData,
1203
+ * positionData,
1204
+ * collateralPrices,
1205
+ * collateralWithdrawals: [{ collateralIndex: 0n, assets: 1_000n }],
1206
+ * });
1207
+ * const tx = output.buildTx();
1208
+ * ```
1209
+ */
1210
+ withdrawCollateralBatch(params) {
1211
+ validateChainId(this.client.viemClient.chain?.id, this.chainId);
1212
+ // Reject invalid owners before preparing the direct call.
1213
+ validateMidnightAccount("accountAddress", params.accountAddress);
1214
+ validateMarketData(params.marketData, this.chainId);
1215
+ validatePositionBinding(params);
1216
+ // Direct batches reject duplicates instead of summing them.
1217
+ validateMidnightCollateralBatch(params.collateralWithdrawals, new EmptyMidnightCollateralWithdrawalsError());
1218
+ const collateralWithdrawals = params.collateralWithdrawals.map(({ collateralIndex, assets }) => {
1219
+ // Reject unconfigured indexes before reading the position balance.
1220
+ MarketUtils.getCollateralByIndex(params.marketData.params, collateralIndex);
1221
+ return {
1222
+ collateralIndex,
1223
+ assets: assets === maxUint256
1224
+ ? (params.positionData.collateral[Number(collateralIndex)] ?? 0n)
1225
+ : assets,
1226
+ };
1227
+ });
1228
+ const tx = midnightWithdrawCollateralBatch({
1229
+ chainId: this.chainId,
1230
+ market: params.marketData.params,
1231
+ collateralWithdrawals,
1232
+ onBehalf: params.accountAddress,
1233
+ receiver: params.receiver ?? params.accountAddress,
1234
+ metadata: this.client.options.metadata,
1235
+ });
1236
+ const collateral = Array.from({ length: params.marketData.params.collateralParams.length }, (_, i) => params.positionData.collateral[i] ?? 0n);
1237
+ for (const { collateralIndex, assets } of collateralWithdrawals) {
1238
+ const index = Number(collateralIndex);
1239
+ const available = collateral[index];
1240
+ if (assets > available) {
1241
+ throw new WithdrawExceedsCollateralError({
1242
+ withdrawAmount: assets,
1243
+ available,
1244
+ market: params.marketData.id,
1245
+ });
1246
+ }
1247
+ collateral[index] = available - assets;
1248
+ }
1249
+ if (params.positionData.debt > 0n) {
1250
+ const maxSafeDebt = getMidnightMaxSafeDebt({
1251
+ market: params.marketData,
1252
+ collateral,
1253
+ collateralPrices: params.collateralPrices,
1254
+ });
1255
+ if (params.positionData.debt > maxSafeDebt) {
1256
+ throw new WithdrawMakesPositionUnhealthyError({
1257
+ withdrawAmount: collateralWithdrawals.reduce((sum, entry) => sum + entry.assets, 0n),
1258
+ borrowAssets: params.positionData.debt,
1259
+ maxSafeBorrow: maxSafeDebt,
1260
+ });
1261
+ }
1262
+ }
1263
+ return { getRequirements: async () => [], buildTx: () => tx };
1264
+ }
1164
1265
  /**
1165
1266
  * Prepares a direct collateral supply using a caller-provided market snapshot.
1166
1267
  *
@@ -1235,6 +1336,79 @@ export class MorphoMidnight {
1235
1336
  }),
1236
1337
  };
1237
1338
  }
1339
+ /**
1340
+ * Prepares ordered direct collateral supplies in one Midnight multicall.
1341
+ * Pass one entry per index: duplicates are rejected, unlike bundle flows which sum them.
1342
+ *
1343
+ * @param params.accountAddress - Sender and collateral beneficiary.
1344
+ * @param params.marketData - Snapshot of the target market.
1345
+ * @param params.collateralSupplies - Ordered supplies with optional reserved allowance amounts.
1346
+ * @returns A lazy approval resolver and synchronous stateless transaction builder.
1347
+ * @throws {ChainIdMismatchError} when the client or market targets another chain.
1348
+ * @throws {MidnightMarketAddressMismatchError} when the deployment differs.
1349
+ * @throws {MidnightCalldataEncodingError} when the account is malformed.
1350
+ * @throws {NegativeInputError} when reserved assets are negative.
1351
+ * @throws {NonPositiveInputError} when assets are not positive.
1352
+ * @throws {InputExceedsMaxError} when assets exceed uint128.
1353
+ * @throws {UnknownCollateralIndexError} when an index is not configured.
1354
+ * @throws {EmptyMidnightCollateralSuppliesError} when the list is empty.
1355
+ * @throws {DuplicateMidnightCollateralIndexError} when an index repeats.
1356
+ * @throws {MidnightZeroOnBehalfError} when requirements or construction uses the zero account.
1357
+ * @example
1358
+ * ```ts
1359
+ * const output = midnight.supplyCollateralBatch({
1360
+ * accountAddress: user, marketData,
1361
+ * collateralSupplies: [{ collateralIndex: 0n, assets: 100n }],
1362
+ * });
1363
+ * const tx = output.buildTx();
1364
+ * ```
1365
+ */
1366
+ supplyCollateralBatch(params) {
1367
+ validateChainId(this.client.viemClient.chain?.id, this.chainId);
1368
+ // Reject malformed accounts before resolving token requirements.
1369
+ validateMidnightAddress("accountAddress", params.accountAddress);
1370
+ validateMarketData(params.marketData, this.chainId);
1371
+ // Reject empty and duplicate-index batches before resolving allowance thresholds.
1372
+ validateMidnightCollateralBatch(params.collateralSupplies, new EmptyMidnightCollateralSuppliesError());
1373
+ for (const supply of params.collateralSupplies) {
1374
+ assertPositiveAmount("assets", supply.assets);
1375
+ validateMidnightUint128Field("assets", supply.assets);
1376
+ assertNonNegativeAmount("reservedCollateralAssets", supply.reservedCollateralAssets ?? 0n);
1377
+ // Fail eagerly for collateral absent from the supplied snapshot.
1378
+ params.marketData.getCollateralByIndex(supply.collateralIndex);
1379
+ }
1380
+ const midnight = getChainAddress(this.chainId, "midnight");
1381
+ return {
1382
+ getRequirements: async (_requirementsParams) => {
1383
+ if (isAddressEqual(params.accountAddress, zeroAddress)) {
1384
+ throw new MidnightZeroOnBehalfError("onBehalf");
1385
+ }
1386
+ const amounts = new Map();
1387
+ for (const supply of params.collateralSupplies) {
1388
+ const token = params.marketData.getCollateralByIndex(supply.collateralIndex).token;
1389
+ amounts.set(token, (amounts.get(token) ?? 0n) +
1390
+ supply.assets +
1391
+ (supply.reservedCollateralAssets ?? 0n));
1392
+ }
1393
+ const requirements = await Promise.all([...amounts].map(([token, amount]) => getMidnightApprovalRequirements({
1394
+ viemClient: this.client.viemClient,
1395
+ chainId: this.chainId,
1396
+ token,
1397
+ owner: params.accountAddress,
1398
+ spender: midnight,
1399
+ amount,
1400
+ })));
1401
+ return requirements.flat();
1402
+ },
1403
+ buildTx: () => midnightSupplyCollateralBatch({
1404
+ chainId: this.chainId,
1405
+ market: params.marketData.params,
1406
+ collateralSupplies: params.collateralSupplies.map(({ collateralIndex, assets }) => ({ collateralIndex, assets })),
1407
+ onBehalf: params.accountAddress,
1408
+ metadata: this.client.options.metadata,
1409
+ }),
1410
+ };
1411
+ }
1238
1412
  /**
1239
1413
  * Prepares an atomic lend-offer publication or repost through `MidnightBundlesV2`.
1240
1414
  *
@@ -235,6 +235,15 @@ export interface SupplyCollateralParams extends MarketActionParams {
235
235
  readonly reservedCollateralAssets?: bigint;
236
236
  readonly collateralIndex?: bigint;
237
237
  }
238
+ /** Parameters for an atomic direct Midnight collateral supply batch. */
239
+ export interface SupplyCollateralBatchParams extends MarketActionParams {
240
+ readonly collateralSupplies: readonly {
241
+ readonly collateralIndex: bigint;
242
+ readonly assets: bigint;
243
+ /** Additional assets included only in the allowance threshold. */
244
+ readonly reservedCollateralAssets?: bigint;
245
+ }[];
246
+ }
238
247
  /** Parameters for a direct Midnight collateral withdrawal. */
239
248
  export interface WithdrawCollateralParams extends MarketActionParams, MidnightPositionHealthParams {
240
249
  readonly collateralIndex?: bigint;
@@ -243,6 +252,13 @@ export interface WithdrawCollateralParams extends MarketActionParams, MidnightPo
243
252
  /** Defaults to accountAddress. */
244
253
  readonly receiver?: Address;
245
254
  }
255
+ /** Parameters for an atomic direct Midnight collateral withdrawal batch. */
256
+ export interface WithdrawCollateralBatchParams extends MarketActionParams, MidnightPositionHealthParams {
257
+ /** Ordered unique indexes; maxUint256 resolves that index's whole snapshot balance. */
258
+ readonly collateralWithdrawals: readonly MidnightCollateralTransfer[];
259
+ /** Defaults to accountAddress for every withdrawal. */
260
+ readonly receiver?: Address;
261
+ }
246
262
  /** Parameters for the Midnight redeem flow. */
247
263
  export interface RedeemParams {
248
264
  readonly accountAddress: Address;