@morpho-org/morpho-sdk 6.6.0 → 7.1.0-next.1

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 (195) hide show
  1. package/MIGRATION-v6-to-v7.md +297 -0
  2. package/README.md +26 -12
  3. package/lib/cjs/abis.d.ts +2 -2
  4. package/lib/cjs/abis.js +7 -2
  5. package/lib/cjs/actions/bundles/common.d.ts +9 -5
  6. package/lib/cjs/actions/bundles/common.js +22 -13
  7. package/lib/cjs/actions/midnight/authorization.d.ts +3 -2
  8. package/lib/cjs/actions/midnight/authorization.js +3 -2
  9. package/lib/cjs/actions/midnight/cancelAndMake.d.ts +153 -0
  10. package/lib/cjs/actions/midnight/cancelAndMake.js +292 -0
  11. package/lib/cjs/actions/midnight/index.d.ts +3 -3
  12. package/lib/cjs/actions/midnight/index.js +3 -3
  13. package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
  14. package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +105 -69
  15. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
  16. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +128 -71
  17. package/lib/cjs/actions/midnight/takeBorrow.d.ts +40 -28
  18. package/lib/cjs/actions/midnight/takeBorrow.js +95 -54
  19. package/lib/cjs/actions/midnight/takeLend.d.ts +51 -27
  20. package/lib/cjs/actions/midnight/takeLend.js +111 -54
  21. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
  22. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +201 -0
  23. package/lib/cjs/actions/midnight/takeWithdraw.d.ts +69 -0
  24. package/lib/cjs/actions/midnight/takeWithdraw.js +153 -0
  25. package/lib/cjs/actions/midnight/types.d.ts +7 -26
  26. package/lib/cjs/actions/midnight/types.js +0 -13
  27. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
  28. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +3 -2
  29. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
  30. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +5 -5
  31. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +2 -2
  32. package/lib/cjs/actions/requirements/getRequirementsApproval.js +2 -2
  33. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
  34. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +24 -13
  35. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
  36. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
  37. package/lib/cjs/actions/requirements/midnight/index.d.ts +0 -1
  38. package/lib/cjs/actions/requirements/midnight/index.js +0 -1
  39. package/lib/cjs/blue/abis.d.ts +1 -1
  40. package/lib/cjs/blue/abis.js +5 -1
  41. package/lib/cjs/blue/entities.d.ts +4 -4
  42. package/lib/cjs/blue/entities.js +3 -1
  43. package/lib/cjs/blue/errors.d.ts +2 -2
  44. package/lib/cjs/blue/errors.js +5 -1
  45. package/lib/cjs/blue/fetch.d.ts +2 -2
  46. package/lib/cjs/blue/fetch.js +3 -1
  47. package/lib/cjs/blue/utils.d.ts +1 -1
  48. package/lib/cjs/blue/utils.js +2 -1
  49. package/lib/cjs/constants.d.ts +1 -1
  50. package/lib/cjs/constants.js +2 -1
  51. package/lib/cjs/entities/index.d.ts +6 -6
  52. package/lib/cjs/entities/index.js +3 -1
  53. package/lib/cjs/entities/midnight/midnight.d.ts +585 -108
  54. package/lib/cjs/entities/midnight/midnight.js +984 -509
  55. package/lib/cjs/entities/midnight/types.d.ts +142 -60
  56. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +3 -2
  57. package/lib/cjs/entities/vaultV1/vaultV1.js +32 -34
  58. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +37 -12
  59. package/lib/cjs/entities/vaultV2/vaultV2.js +68 -41
  60. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +5 -3
  61. package/lib/cjs/entities/vaultV2BlueReallocationData.js +9 -3
  62. package/lib/cjs/errors.d.ts +4 -4
  63. package/lib/cjs/errors.js +10 -5
  64. package/lib/cjs/fetch.d.ts +2 -2
  65. package/lib/cjs/fetch.js +3 -1
  66. package/lib/cjs/helpers/callback.d.ts +54 -0
  67. package/lib/cjs/helpers/callback.js +73 -0
  68. package/lib/cjs/helpers/constant.d.ts +2 -0
  69. package/lib/cjs/helpers/constant.js +3 -1
  70. package/lib/cjs/helpers/index.d.ts +3 -2
  71. package/lib/cjs/helpers/index.js +6 -1
  72. package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +3 -3
  73. package/lib/cjs/helpers/signAndVerifyTypedData.js +3 -3
  74. package/lib/cjs/helpers/validate.d.ts +43 -2
  75. package/lib/cjs/helpers/validate.js +60 -3
  76. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
  77. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +3 -7
  78. package/lib/cjs/helpers/validateRequirementSpender.d.ts +3 -3
  79. package/lib/cjs/helpers/validateRequirementSpender.js +4 -5
  80. package/lib/cjs/midnight/abis.d.ts +1 -1
  81. package/lib/cjs/midnight/abis.js +3 -2
  82. package/lib/cjs/midnight/errors.d.ts +2 -1
  83. package/lib/cjs/midnight/errors.js +5 -4
  84. package/lib/cjs/midnight/types.d.ts +1 -1
  85. package/lib/cjs/types/action.d.ts +219 -90
  86. package/lib/cjs/types/action.js +103 -20
  87. package/lib/cjs/types/error.d.ts +126 -40
  88. package/lib/cjs/types/error.js +154 -49
  89. package/lib/cjs/utils.d.ts +2 -2
  90. package/lib/cjs/utils.js +4 -2
  91. package/lib/esm/abis.d.ts +2 -2
  92. package/lib/esm/abis.js +2 -2
  93. package/lib/esm/actions/bundles/common.d.ts +9 -5
  94. package/lib/esm/actions/bundles/common.js +22 -13
  95. package/lib/esm/actions/midnight/authorization.d.ts +3 -2
  96. package/lib/esm/actions/midnight/authorization.js +3 -2
  97. package/lib/esm/actions/midnight/cancelAndMake.d.ts +153 -0
  98. package/lib/esm/actions/midnight/cancelAndMake.js +288 -0
  99. package/lib/esm/actions/midnight/index.d.ts +3 -3
  100. package/lib/esm/actions/midnight/index.js +3 -3
  101. package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
  102. package/lib/esm/actions/midnight/repayWithdrawCollateral.js +108 -72
  103. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
  104. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +131 -74
  105. package/lib/esm/actions/midnight/takeBorrow.d.ts +40 -28
  106. package/lib/esm/actions/midnight/takeBorrow.js +98 -57
  107. package/lib/esm/actions/midnight/takeLend.d.ts +51 -27
  108. package/lib/esm/actions/midnight/takeLend.js +114 -57
  109. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
  110. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +197 -0
  111. package/lib/esm/actions/midnight/takeWithdraw.d.ts +69 -0
  112. package/lib/esm/actions/midnight/takeWithdraw.js +149 -0
  113. package/lib/esm/actions/midnight/types.d.ts +7 -26
  114. package/lib/esm/actions/midnight/types.js +1 -12
  115. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
  116. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +3 -2
  117. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
  118. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +5 -5
  119. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +2 -2
  120. package/lib/esm/actions/requirements/getRequirementsApproval.js +2 -2
  121. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
  122. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +25 -14
  123. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
  124. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
  125. package/lib/esm/actions/requirements/midnight/index.d.ts +0 -1
  126. package/lib/esm/actions/requirements/midnight/index.js +0 -1
  127. package/lib/esm/blue/abis.d.ts +1 -1
  128. package/lib/esm/blue/abis.js +1 -1
  129. package/lib/esm/blue/entities.d.ts +4 -4
  130. package/lib/esm/blue/entities.js +2 -2
  131. package/lib/esm/blue/errors.d.ts +2 -2
  132. package/lib/esm/blue/errors.js +2 -2
  133. package/lib/esm/blue/fetch.d.ts +2 -2
  134. package/lib/esm/blue/fetch.js +2 -2
  135. package/lib/esm/blue/utils.d.ts +1 -1
  136. package/lib/esm/blue/utils.js +1 -1
  137. package/lib/esm/constants.d.ts +1 -1
  138. package/lib/esm/constants.js +1 -1
  139. package/lib/esm/entities/index.d.ts +6 -6
  140. package/lib/esm/entities/index.js +2 -2
  141. package/lib/esm/entities/midnight/midnight.d.ts +585 -108
  142. package/lib/esm/entities/midnight/midnight.js +990 -515
  143. package/lib/esm/entities/midnight/types.d.ts +142 -60
  144. package/lib/esm/entities/vaultV1/vaultV1.d.ts +3 -2
  145. package/lib/esm/entities/vaultV1/vaultV1.js +33 -35
  146. package/lib/esm/entities/vaultV2/vaultV2.d.ts +37 -12
  147. package/lib/esm/entities/vaultV2/vaultV2.js +69 -42
  148. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +5 -3
  149. package/lib/esm/entities/vaultV2BlueReallocationData.js +9 -3
  150. package/lib/esm/errors.d.ts +4 -4
  151. package/lib/esm/errors.js +4 -4
  152. package/lib/esm/fetch.d.ts +2 -2
  153. package/lib/esm/fetch.js +2 -2
  154. package/lib/esm/helpers/callback.d.ts +54 -0
  155. package/lib/esm/helpers/callback.js +68 -0
  156. package/lib/esm/helpers/constant.d.ts +2 -0
  157. package/lib/esm/helpers/constant.js +2 -0
  158. package/lib/esm/helpers/index.d.ts +3 -2
  159. package/lib/esm/helpers/index.js +3 -2
  160. package/lib/esm/helpers/signAndVerifyTypedData.d.ts +3 -3
  161. package/lib/esm/helpers/signAndVerifyTypedData.js +3 -3
  162. package/lib/esm/helpers/validate.d.ts +43 -2
  163. package/lib/esm/helpers/validate.js +58 -2
  164. package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
  165. package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +3 -7
  166. package/lib/esm/helpers/validateRequirementSpender.d.ts +3 -3
  167. package/lib/esm/helpers/validateRequirementSpender.js +4 -5
  168. package/lib/esm/midnight/abis.d.ts +1 -1
  169. package/lib/esm/midnight/abis.js +1 -1
  170. package/lib/esm/midnight/errors.d.ts +2 -1
  171. package/lib/esm/midnight/errors.js +2 -1
  172. package/lib/esm/midnight/types.d.ts +1 -1
  173. package/lib/esm/types/action.d.ts +219 -90
  174. package/lib/esm/types/action.js +103 -19
  175. package/lib/esm/types/error.d.ts +126 -40
  176. package/lib/esm/types/error.js +135 -38
  177. package/lib/esm/utils.d.ts +2 -2
  178. package/lib/esm/utils.js +2 -2
  179. package/package.json +10 -10
  180. package/lib/cjs/actions/midnight/cancelOffer.d.ts +0 -38
  181. package/lib/cjs/actions/midnight/cancelOffer.js +0 -73
  182. package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
  183. package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +0 -72
  184. package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
  185. package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.js +0 -59
  186. package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
  187. package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -70
  188. package/lib/esm/actions/midnight/cancelOffer.d.ts +0 -38
  189. package/lib/esm/actions/midnight/cancelOffer.js +0 -69
  190. package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
  191. package/lib/esm/actions/midnight/mempoolSubmitOffers.js +0 -68
  192. package/lib/esm/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
  193. package/lib/esm/actions/midnight/setterRatifierRatifyRoot.js +0 -55
  194. package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
  195. package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -66
@@ -70,8 +70,7 @@ export declare const validateMidnightMarketChainId: (market: MidnightMarketInput
70
70
  * the provided user address.
71
71
  *
72
72
  * Used at `sign()` time by the shared `signAndVerifyTypedData` helper (which
73
- * backs the permit, Permit2, Blue authorization, and Midnight offer-root
74
- * signature flows) and by `encodeVaultSharesPermit`, to enforce builder =
73
+ * backs the permit, Permit2, and Blue authorization signature flows) and by `encodeVaultSharesPermit`, to enforce builder =
75
74
  * signer: the signing flow is
76
75
  * the only path where an account/address mismatch is a real security concern
77
76
  * (rather than just an integrator footgun).
@@ -163,6 +162,48 @@ export declare const validateChainId: (clientChainId: number | undefined, expect
163
162
  * @throws {NativeAmountOnNonWNativeAssetError} if the asset is not wNative.
164
163
  */
165
164
  export declare const validateNativeAsset: (chainId: number, asset: Address) => void;
165
+ /**
166
+ * Validates native ETH funding against the wNative tokens pulled by a MidnightBundlesV2 action.
167
+ *
168
+ * @param params.chainId - Chain used to resolve wNative.
169
+ * @param params.nativeAmount - Optional native ETH sent as `value`; the bundle wraps it into the
170
+ * chain's wNative and transfers it to `msg.sender` before pulling. It may cover part or all of the
171
+ * maximum wNative amount this call can pull, but not more. Any wrapped native not pulled stays in
172
+ * the sender's wallet as wNative. The wNative approval to `MidnightBundlesV2` is still required
173
+ * for the full pulled amount.
174
+ * @param params.pulls - Token pulls performed by the bundle action.
175
+ * @returns The transaction `value` and the `wrappedNative` contract argument.
176
+ * @throws {NegativeInputError} when `nativeAmount` is negative.
177
+ * @throws {ChainWNativeMissingError} when wNative is not configured for the chain.
178
+ * @throws {NativeAmountOnNonWNativeAssetError} when pulls are non-empty and none use wNative.
179
+ * @throws {InputExceedsMaxError} when `nativeAmount` exceeds the maximum wNative pull, including
180
+ * when the call pulls none.
181
+ * @example
182
+ * ```ts
183
+ * import { getChainAddress } from "@morpho-org/morpho-ts";
184
+ * import { validateMidnightNativeAmount } from "@morpho-org/morpho-sdk";
185
+ *
186
+ * const wNative = getChainAddress(8453, "wNative");
187
+ * const funding = validateMidnightNativeAmount({
188
+ * chainId: 8453,
189
+ * nativeAmount: 1_000n,
190
+ * pulls: [{ token: wNative, assets: 2_000n }],
191
+ * });
192
+ * funding.value; // 1_000n
193
+ * funding.wrappedNative; // wNative
194
+ * ```
195
+ */
196
+ export declare const validateMidnightNativeAmount: (params: {
197
+ readonly chainId: number;
198
+ readonly nativeAmount?: bigint;
199
+ readonly pulls: readonly {
200
+ readonly token: Address;
201
+ readonly assets: bigint;
202
+ }[];
203
+ }) => {
204
+ value: bigint;
205
+ wrappedNative: Address;
206
+ };
166
207
  /** @internal Validates native funding against a vault's wrapped-native asset. */
167
208
  export declare const validateNativeVaultAsset: (chainId: number, vaultAsset: Address) => void;
168
209
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateSlippageTolerance = exports.validateVaultV2BlueReallocations = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validateNativeVaultAsset = exports.validateNativeAsset = exports.validateChainId = exports.validatePositionHealth = exports.validateAccrualPosition = exports.validateMidnightMarketChainId = exports.validateReferralFee = exports.validateDeadline = exports.validateUint256Field = void 0;
3
+ exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateSlippageTolerance = exports.validateVaultV2BlueReallocations = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validateNativeVaultAsset = exports.validateMidnightNativeAmount = exports.validateNativeAsset = exports.validateChainId = exports.validatePositionHealth = exports.validateAccrualPosition = exports.validateMidnightMarketChainId = exports.validateReferralFee = exports.validateDeadline = exports.validateUint256Field = void 0;
4
4
  exports.validateUserAddress = validateUserAddress;
5
5
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
6
6
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
@@ -113,8 +113,7 @@ exports.validateMidnightMarketChainId = validateMidnightMarketChainId;
113
113
  * the provided user address.
114
114
  *
115
115
  * Used at `sign()` time by the shared `signAndVerifyTypedData` helper (which
116
- * backs the permit, Permit2, Blue authorization, and Midnight offer-root
117
- * signature flows) and by `encodeVaultSharesPermit`, to enforce builder =
116
+ * backs the permit, Permit2, and Blue authorization signature flows) and by `encodeVaultSharesPermit`, to enforce builder =
118
117
  * signer: the signing flow is
119
118
  * the only path where an account/address mismatch is a real security concern
120
119
  * (rather than just an integrator footgun).
@@ -242,6 +241,64 @@ const validateNativeAsset = (chainId, asset) => {
242
241
  }
243
242
  };
244
243
  exports.validateNativeAsset = validateNativeAsset;
244
+ /**
245
+ * Validates native ETH funding against the wNative tokens pulled by a MidnightBundlesV2 action.
246
+ *
247
+ * @param params.chainId - Chain used to resolve wNative.
248
+ * @param params.nativeAmount - Optional native ETH sent as `value`; the bundle wraps it into the
249
+ * chain's wNative and transfers it to `msg.sender` before pulling. It may cover part or all of the
250
+ * maximum wNative amount this call can pull, but not more. Any wrapped native not pulled stays in
251
+ * the sender's wallet as wNative. The wNative approval to `MidnightBundlesV2` is still required
252
+ * for the full pulled amount.
253
+ * @param params.pulls - Token pulls performed by the bundle action.
254
+ * @returns The transaction `value` and the `wrappedNative` contract argument.
255
+ * @throws {NegativeInputError} when `nativeAmount` is negative.
256
+ * @throws {ChainWNativeMissingError} when wNative is not configured for the chain.
257
+ * @throws {NativeAmountOnNonWNativeAssetError} when pulls are non-empty and none use wNative.
258
+ * @throws {InputExceedsMaxError} when `nativeAmount` exceeds the maximum wNative pull, including
259
+ * when the call pulls none.
260
+ * @example
261
+ * ```ts
262
+ * import { getChainAddress } from "@morpho-org/morpho-ts";
263
+ * import { validateMidnightNativeAmount } from "@morpho-org/morpho-sdk";
264
+ *
265
+ * const wNative = getChainAddress(8453, "wNative");
266
+ * const funding = validateMidnightNativeAmount({
267
+ * chainId: 8453,
268
+ * nativeAmount: 1_000n,
269
+ * pulls: [{ token: wNative, assets: 2_000n }],
270
+ * });
271
+ * funding.value; // 1_000n
272
+ * funding.wrappedNative; // wNative
273
+ * ```
274
+ */
275
+ const validateMidnightNativeAmount = (params) => {
276
+ const { nativeAmount, chainId, pulls } = params;
277
+ if (nativeAmount === undefined || nativeAmount === 0n) {
278
+ return { value: 0n, wrappedNative: viem_1.zeroAddress };
279
+ }
280
+ if (nativeAmount < 0n) {
281
+ throw new index_js_1.NegativeInputError("nativeAmount", nativeAmount);
282
+ }
283
+ const { wNative } = (0, blue_sdk_1.getChainAddresses)(chainId);
284
+ if (!(0, morpho_ts_1.isDefined)(wNative)) {
285
+ throw new index_js_1.ChainWNativeMissingError(chainId);
286
+ }
287
+ const wNativePulled = pulls.reduce((total, pull) => (0, viem_1.isAddressEqual)(pull.token, wNative) ? total + pull.assets : total, 0n);
288
+ const firstPull = pulls[0];
289
+ if (firstPull && !pulls.some((pull) => (0, viem_1.isAddressEqual)(pull.token, wNative))) {
290
+ throw new index_js_1.NativeAmountOnNonWNativeAssetError(firstPull.token, wNative);
291
+ }
292
+ if (nativeAmount > wNativePulled) {
293
+ throw new index_js_1.InputExceedsMaxError({
294
+ field: "nativeAmount",
295
+ value: nativeAmount,
296
+ max: wNativePulled,
297
+ });
298
+ }
299
+ return { value: nativeAmount, wrappedNative: wNative };
300
+ };
301
+ exports.validateMidnightNativeAmount = validateMidnightNativeAmount;
245
302
  /** @internal Validates native funding against a vault's wrapped-native asset. */
246
303
  const validateNativeVaultAsset = (chainId, vaultAsset) => {
247
304
  const { wNative } = (0, blue_sdk_1.getChainAddresses)(chainId);
@@ -5,7 +5,7 @@ import { type Address } from "viem";
5
5
  * @param params - Authorization target validation parameters.
6
6
  * @param params.chainId - Chain id used to resolve supported Midnight operators.
7
7
  * @param params.authorized - Operator address receiving authorization.
8
- * @returns Nothing after the operator matches MidnightBundles or a supported ratifier.
8
+ * @returns Nothing after the operator matches MidnightBundlesV2.
9
9
  * @throws {UnsupportedMidnightAuthorizationTargetError} when `authorized` is not a supported operator.
10
10
  * @internal
11
11
  */
@@ -10,17 +10,13 @@ const index_js_1 = require("../types/index.js");
10
10
  * @param params - Authorization target validation parameters.
11
11
  * @param params.chainId - Chain id used to resolve supported Midnight operators.
12
12
  * @param params.authorized - Operator address receiving authorization.
13
- * @returns Nothing after the operator matches MidnightBundles or a supported ratifier.
13
+ * @returns Nothing after the operator matches MidnightBundlesV2.
14
14
  * @throws {UnsupportedMidnightAuthorizationTargetError} when `authorized` is not a supported operator.
15
15
  * @internal
16
16
  */
17
17
  const validateMidnightAuthorizationTarget = (params) => {
18
- const { midnightBundles, ecrecoverRatifier, setterRatifier } = (0, morpho_ts_1.getChainAddresses)(params.chainId);
19
- const supportedTargets = [
20
- midnightBundles,
21
- ecrecoverRatifier,
22
- setterRatifier,
23
- ].filter((target) => target != null);
18
+ const { midnightBundlesV2 } = (0, morpho_ts_1.getChainAddresses)(params.chainId);
19
+ const supportedTargets = midnightBundlesV2 == null ? [] : [midnightBundlesV2];
24
20
  if (!supportedTargets.some((supported) => (0, viem_1.isAddressEqual)(params.authorized, supported))) {
25
21
  throw new index_js_1.UnsupportedMidnightAuthorizationTargetError({
26
22
  authorized: params.authorized,
@@ -1,6 +1,6 @@
1
1
  import { type Address } from "@morpho-org/blue-sdk";
2
2
  /** Supported spender slots that can be validated against the chain address registry. */
3
- export type RequirementSpenderKey = "permit2" | "midnight" | "midnightBundles" | "vaultExitBundlesV1" | "vaultBundlesV1" | "blueBundlesV1";
3
+ export type RequirementSpenderKey = "permit2" | "midnight" | "midnightBundlesV2" | "vaultExitBundlesV1" | "vaultBundlesV1" | "blueBundlesV1";
4
4
  /**
5
5
  * Validates that a requirement encoder spender matches one of the allowed chain addresses.
6
6
  *
@@ -18,8 +18,8 @@ export type RequirementSpenderKey = "permit2" | "midnight" | "midnightBundles" |
18
18
  *
19
19
  * validateRequirementSpender({
20
20
  * chainId: 8453,
21
- * spender: getChainAddress(8453, "midnightBundles"),
22
- * allowed: ["midnightBundles"],
21
+ * spender: getChainAddress(8453, "midnight"),
22
+ * allowed: ["midnight"],
23
23
  * });
24
24
  * ```
25
25
  */
@@ -21,17 +21,17 @@ const index_js_1 = require("../types/index.js");
21
21
  *
22
22
  * validateRequirementSpender({
23
23
  * chainId: 8453,
24
- * spender: getChainAddress(8453, "midnightBundles"),
25
- * allowed: ["midnightBundles"],
24
+ * spender: getChainAddress(8453, "midnight"),
25
+ * allowed: ["midnight"],
26
26
  * });
27
27
  * ```
28
28
  */
29
29
  const validateRequirementSpender = (params) => {
30
- const { permit2, midnight, midnightBundles, bundles } = (0, blue_sdk_1.getChainAddresses)(params.chainId);
30
+ const { permit2, midnight, midnightBundlesV2, bundles } = (0, blue_sdk_1.getChainAddresses)(params.chainId);
31
31
  const addresses = {
32
32
  permit2,
33
33
  midnight,
34
- midnightBundles,
34
+ midnightBundlesV2,
35
35
  vaultExitBundlesV1: bundles?.vaultExitBundlesV1,
36
36
  vaultBundlesV1: bundles?.vaultBundlesV1,
37
37
  blueBundlesV1: bundles?.blueBundlesV1,
@@ -43,7 +43,6 @@ const validateRequirementSpender = (params) => {
43
43
  chainId: params.chainId,
44
44
  permit2,
45
45
  midnight,
46
- midnightBundles,
47
46
  supportedSpenders,
48
47
  });
49
48
  }
@@ -1 +1 @@
1
- export { ecrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, priceRatifierV1Abi, rateRatifierV1Abi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
1
+ export { blueBuyCallbackFactoryAbi, ecrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, priceRatifierV1Abi, rateRatifierV1Abi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setterRatifierAbi = exports.rateRatifierV1Abi = exports.priceRatifierV1Abi = exports.midnightBundlesAbi = exports.midnightAbi = exports.ecrecoverRatifierAbi = void 0;
3
+ exports.setterRatifierAbi = exports.rateRatifierV1Abi = exports.priceRatifierV1Abi = exports.midnightBundlesV2Abi = exports.midnightAbi = exports.ecrecoverRatifierAbi = exports.blueBuyCallbackFactoryAbi = void 0;
4
4
  var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
5
+ Object.defineProperty(exports, "blueBuyCallbackFactoryAbi", { enumerable: true, get: function () { return midnight_sdk_1.blueBuyCallbackFactoryAbi; } });
5
6
  Object.defineProperty(exports, "ecrecoverRatifierAbi", { enumerable: true, get: function () { return midnight_sdk_1.ecrecoverRatifierAbi; } });
6
7
  Object.defineProperty(exports, "midnightAbi", { enumerable: true, get: function () { return midnight_sdk_1.midnightAbi; } });
7
- Object.defineProperty(exports, "midnightBundlesAbi", { enumerable: true, get: function () { return midnight_sdk_1.midnightBundlesAbi; } });
8
+ Object.defineProperty(exports, "midnightBundlesV2Abi", { enumerable: true, get: function () { return midnight_sdk_1.midnightBundlesV2Abi; } });
8
9
  Object.defineProperty(exports, "priceRatifierV1Abi", { enumerable: true, get: function () { return midnight_sdk_1.priceRatifierV1Abi; } });
9
10
  Object.defineProperty(exports, "rateRatifierV1Abi", { enumerable: true, get: function () { return midnight_sdk_1.rateRatifierV1Abi; } });
10
11
  Object.defineProperty(exports, "setterRatifierAbi", { enumerable: true, get: function () { return midnight_sdk_1.setterRatifierAbi; } });
@@ -1 +1,2 @@
1
- export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
1
+ export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
2
+ export { InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, } from "@morpho-org/morpho-ts";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnknownCollateralIndexError = exports.TickOutOfRangeError = exports.SettlementFeeExceedsPriceError = exports.RatifierV1TakerNotAllowedError = exports.RateRatifierV1BoundOverflowError = exports.PriceGreaterThanOneError = exports.PayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidTypedDataSignatureError = exports.InvalidTreeHeightError = exports.InvalidTreeError = exports.InvalidTickSpacingError = exports.InvalidRatifierV1AddressError = exports.InvalidRateRatifierV1TimeError = exports.InvalidRateRatifierV1TickError = exports.InvalidRateRatifierV1RateError = exports.InvalidPositionLossFactorError = exports.InvalidPositionAccrualTimestampError = exports.InvalidPositionAccrualStateError = exports.InvalidOfferParameterError = exports.InvalidOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMarketParameterError = exports.InvalidEcrecoverSignatureVError = exports.ChainIdMismatchError = void 0;
3
+ exports.InvalidPositionLossFactorError = exports.InvalidPositionAccrualTimestampError = exports.InvalidPositionAccrualStateError = exports.UnknownCollateralIndexError = exports.TickOutOfRangeError = exports.SettlementFeeExceedsPriceError = exports.RatifierV1TakerNotAllowedError = exports.RateRatifierV1BoundOverflowError = exports.PriceGreaterThanOneError = exports.PayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidTypedDataSignatureError = exports.InvalidTreeHeightError = exports.InvalidTreeError = exports.InvalidTickSpacingError = exports.InvalidRatifierV1AddressError = exports.InvalidRateRatifierV1TimeError = exports.InvalidRateRatifierV1TickError = exports.InvalidRateRatifierV1RateError = exports.InvalidOfferParameterError = exports.InvalidOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMarketParameterError = exports.InvalidEcrecoverSignatureVError = exports.ChainIdMismatchError = void 0;
4
4
  var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
5
5
  Object.defineProperty(exports, "ChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
6
6
  Object.defineProperty(exports, "InvalidEcrecoverSignatureVError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidEcrecoverSignatureVError; } });
@@ -9,9 +9,6 @@ Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerabl
9
9
  Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
10
10
  Object.defineProperty(exports, "InvalidOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
11
11
  Object.defineProperty(exports, "InvalidOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
12
- Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
13
- Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
14
- Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
15
12
  Object.defineProperty(exports, "InvalidRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
16
13
  Object.defineProperty(exports, "InvalidRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
17
14
  Object.defineProperty(exports, "InvalidRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
@@ -29,3 +26,7 @@ Object.defineProperty(exports, "RatifierV1TakerNotAllowedError", { enumerable: t
29
26
  Object.defineProperty(exports, "SettlementFeeExceedsPriceError", { enumerable: true, get: function () { return midnight_sdk_1.SettlementFeeExceedsPriceError; } });
30
27
  Object.defineProperty(exports, "TickOutOfRangeError", { enumerable: true, get: function () { return midnight_sdk_1.TickOutOfRangeError; } });
31
28
  Object.defineProperty(exports, "UnknownCollateralIndexError", { enumerable: true, get: function () { return midnight_sdk_1.UnknownCollateralIndexError; } });
29
+ var morpho_ts_1 = require("@morpho-org/morpho-ts");
30
+ Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
31
+ Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
32
+ Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
@@ -1 +1 @@
1
- export type { BuildFixedRateOfferChainParams, DecodedEcrecoverRatifierData, DecodedPriceRatifierV1Data, DecodedRateRatifierV1Data, DecodedSetterRatifierData, DeploylessFetchParameters, EcrecoverRatificationTypedData, EcrecoverRatifierDataDigestParams, EcrecoverRatifierDataParams, EcrecoverRatifierDataRequest, EcrecoverRatifierDataVerificationParams, EcrecoverRatifierRatifyParams, EcrecoverRatifierRatifyRequest, EcrecoverRatifierRootDigestParams, EcrecoverRatifierSignRequest, EcrecoverRatifierTypedDataParams, EcrecoverRatifierTypedDataRequest, EcrecoverSignatureInput, FixedRateOfferChainLeg, GetRatifierInfoParams, MidnightCallParameters, MidnightFetchParams, PriceRatifierV1Leaf, PriceRatifierV1LeafStruct, PriceRatifierV1TreeDescriptor, PriceRatifierV1TreeInput, RateRatifierV1Leaf, RateRatifierV1LeafStruct, RateRatifierV1TreeDescriptor, RateRatifierV1TreeInput, RatifierInfo, SetterRatifierDataParams, SetterRatifierDataRequest, SetterRatifierDataVerificationParams, SetterRatifierRatifyRequest, VerifiedEcrecoverRatifierData, } from "@morpho-org/midnight-sdk";
1
+ export type { BuildFixedRateOfferChainParams, CollateralTransfer, DecodedEcrecoverRatifierData, DecodedPriceRatifierV1Data, DecodedRateRatifierV1Data, DecodedSetterRatifierData, DeploylessFetchParameters, EcrecoverRatificationTypedData, EcrecoverRatifierDataDigestParams, EcrecoverRatifierDataParams, EcrecoverRatifierDataRequest, EcrecoverRatifierDataVerificationParams, EcrecoverRatifierRatifyParams, EcrecoverRatifierRatifyRequest, EcrecoverRatifierRootDigestParams, EcrecoverRatifierSignRequest, EcrecoverRatifierTypedDataParams, EcrecoverRatifierTypedDataRequest, EcrecoverSignatureInput, FixedRateOfferChainLeg, GetRatifierInfoParams, GroupCancellation, MidnightCallParameters, MidnightFetchParams, PriceRatifierV1Leaf, PriceRatifierV1LeafStruct, PriceRatifierV1TreeDescriptor, PriceRatifierV1TreeInput, RateRatifierV1Leaf, RateRatifierV1LeafStruct, RateRatifierV1TreeDescriptor, RateRatifierV1TreeInput, RatifierInfo, SetterRatifierDataParams, SetterRatifierDataRequest, SetterRatifierDataVerificationParams, SetterRatifierRatifyRequest, VerifiedEcrecoverRatifierData, } from "@morpho-org/midnight-sdk";