@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
@@ -1,4 +1,48 @@
1
1
  import { AmbiguousRequirementSignaturesError, UnexpectedRequirementSignatureError, UnsupportedRequirementSignatureError, } from "./error.js";
2
+ /**
3
+ * Narrows an action requirement to an ERC-20 approval transaction.
4
+ *
5
+ * @param requirement - The requirement returned by `getRequirements()` to test.
6
+ * @returns `true` when `requirement.action.type` is `"erc20Approval"`.
7
+ * @example
8
+ * ```ts
9
+ * import { vaults } from "@morpho-org/morpho-test";
10
+ * import {
11
+ * isRequirementApproval,
12
+ * morphoViemExtension,
13
+ * } from "@morpho-org/morpho-sdk";
14
+ * import { createWalletClient, http, publicActions, zeroAddress } from "viem";
15
+ * import { mainnet } from "viem/chains";
16
+ *
17
+ * const client = createWalletClient({
18
+ * chain: mainnet,
19
+ * transport: http(),
20
+ * account: zeroAddress,
21
+ * })
22
+ * .extend(publicActions)
23
+ * .extend(morphoViemExtension());
24
+ *
25
+ * const vault = client.morpho.vaultV1(
26
+ * vaults[mainnet.id].steakUsdc.address,
27
+ * mainnet.id,
28
+ * );
29
+ * const vaultData = await vault.getData();
30
+ * const handle = vault.deposit({
31
+ * amount: 1_000_000n,
32
+ * userAddress: zeroAddress,
33
+ * vaultData,
34
+ * });
35
+ *
36
+ * for (const requirement of await handle.getRequirements()) {
37
+ * if (!isRequirementApproval(requirement)) continue;
38
+ *
39
+ * const { amount, spender } = requirement.action.args;
40
+ * const hash = await client.sendTransaction(requirement);
41
+ * console.log({ amount, spender, hash });
42
+ * await client.waitForTransactionReceipt({ hash });
43
+ * }
44
+ * ```
45
+ */
2
46
  export function isRequirementApproval(requirement) {
3
47
  return (typeof requirement === "object" &&
4
48
  requirement !== null &&
@@ -11,7 +55,54 @@ export function isRequirementApproval(requirement) {
11
55
  "type" in requirement.action &&
12
56
  requirement.action.type === "erc20Approval");
13
57
  }
14
- /** Checks whether an action requirement is a Blue authorization call. */
58
+ /**
59
+ * Narrows an action requirement to a Blue authorization call.
60
+ *
61
+ * @param requirement - The requirement returned by `getRequirements()` to test.
62
+ * @returns `true` when the requirement is a call whose `action.type` is `"blueAuthorization"`.
63
+ * @example
64
+ * ```ts
65
+ * import { AccrualPosition } from "@morpho-org/blue-sdk";
66
+ * import { markets } from "@morpho-org/morpho-test";
67
+ * import { Time } from "@morpho-org/morpho-ts";
68
+ * import { createWalletClient, http, publicActions, zeroAddress } from "viem";
69
+ * import { mainnet } from "viem/chains";
70
+ * import {
71
+ * isRequirementBlueAuthorization,
72
+ * morphoViemExtension,
73
+ * } from "@morpho-org/morpho-sdk";
74
+ *
75
+ * const client = createWalletClient({
76
+ * chain: mainnet,
77
+ * transport: http(),
78
+ * account: zeroAddress,
79
+ * })
80
+ * .extend(publicActions)
81
+ * .extend(morphoViemExtension());
82
+ *
83
+ * const blue = client.morpho.blue(
84
+ * markets[mainnet.id].usdc_wbtc,
85
+ * mainnet.id,
86
+ * );
87
+ * const positionData = new AccrualPosition(
88
+ * { user: zeroAddress, supplyShares: 0n, borrowShares: 0n, collateral: 10n ** 8n },
89
+ * await blue.getMarketData(),
90
+ * );
91
+ * const handle = blue.borrow({
92
+ * userAddress: zeroAddress,
93
+ * borrowAssets: 1_000_000n,
94
+ * positionData,
95
+ * deadline: Time.timestamp() + 600n,
96
+ * });
97
+ *
98
+ * for (const requirement of await handle.getRequirements()) {
99
+ * if (!isRequirementBlueAuthorization(requirement)) continue;
100
+ *
101
+ * const hash = await client.sendTransaction(requirement);
102
+ * await client.waitForTransactionReceipt({ hash });
103
+ * }
104
+ * ```
105
+ */
15
106
  export function isRequirementBlueAuthorization(requirement) {
16
107
  return (typeof requirement === "object" &&
17
108
  requirement !== null &&
@@ -74,19 +165,20 @@ export function isPermit2SignatureTransferSignature(signature) {
74
165
  *
75
166
  * @param signature - The signed requirement to test.
76
167
  * @returns `true` when `signature.action.type` is `"authorization"`.
168
+ * @example
169
+ * ```ts
170
+ * import {
171
+ * isAuthorizationSignature,
172
+ * type RequirementSignature,
173
+ * } from "@morpho-org/morpho-sdk";
174
+ *
175
+ * const getAuthorizationNonce = (signature: RequirementSignature): bigint | undefined =>
176
+ * isAuthorizationSignature(signature) ? signature.args.nonce : undefined;
177
+ * ```
77
178
  */
78
179
  export function isAuthorizationSignature(signature) {
79
180
  return signature.action.type === "authorization";
80
181
  }
81
- /**
82
- * Narrows a {@link RequirementSignature} to a Midnight offer-root signature.
83
- *
84
- * @param signature - The signed requirement to test.
85
- * @returns `true` when `signature.action.type` is `"midnightOfferRootSignature"`.
86
- */
87
- export function isMidnightOfferRootSignature(signature) {
88
- return signature.action.type === "midnightOfferRootSignature";
89
- }
90
182
  /**
91
183
  * Splits a `buildTx` signature array into its typed requirement-signature slots, rejecting
92
184
  * ambiguous or unexpected input so a path never silently consumes the wrong signature.
@@ -101,7 +193,6 @@ export function isMidnightOfferRootSignature(signature) {
101
193
  * @param accepts.permit - Whether an ERC-2612 signature is consumed.
102
194
  * @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
103
195
  * @param accepts.authorization - Whether a Morpho authorization signature is consumed.
104
- * @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
105
196
  * @returns The accepted signature in each typed slot, when present.
106
197
  * @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
107
198
  * @throws {UnsupportedRequirementSignatureError} when a signature has an unsupported action type.
@@ -122,11 +213,9 @@ export function selectRequirementSignatures(signatures, accepts) {
122
213
  const permits = signatures.filter(isPermitSignature);
123
214
  const permit2Transfers = signatures.filter(isPermit2SignatureTransferSignature);
124
215
  const authorizations = signatures.filter(isAuthorizationSignature);
125
- const midnightOfferRoots = signatures.filter(isMidnightOfferRootSignature);
126
216
  const unsupported = signatures.find((signature) => !isPermitSignature(signature) &&
127
217
  !isPermit2SignatureTransferSignature(signature) &&
128
- !isAuthorizationSignature(signature) &&
129
- !isMidnightOfferRootSignature(signature));
218
+ !isAuthorizationSignature(signature));
130
219
  if (unsupported != null)
131
220
  throw new UnsupportedRequirementSignatureError(unsupported.action.type);
132
221
  if (!accepts.permit && permits.length > 0)
@@ -135,20 +224,15 @@ export function selectRequirementSignatures(signatures, accepts) {
135
224
  throw new UnexpectedRequirementSignatureError("permit2SignatureTransfer");
136
225
  if (!accepts.authorization && authorizations.length > 0)
137
226
  throw new UnexpectedRequirementSignatureError("authorization");
138
- if (!accepts.midnightOfferRoot && midnightOfferRoots.length > 0)
139
- throw new UnexpectedRequirementSignatureError("midnightOfferRootSignature");
140
227
  if (permits.length > 1)
141
228
  throw new AmbiguousRequirementSignaturesError("permit", permits.length);
142
229
  if (permit2Transfers.length > 1)
143
230
  throw new AmbiguousRequirementSignaturesError("permit2SignatureTransfer", permit2Transfers.length);
144
231
  if (authorizations.length > 1)
145
232
  throw new AmbiguousRequirementSignaturesError("authorization", authorizations.length);
146
- if (midnightOfferRoots.length > 1)
147
- throw new AmbiguousRequirementSignaturesError("midnightOfferRootSignature", midnightOfferRoots.length);
148
233
  return {
149
234
  permit: permits[0],
150
235
  permit2SignatureTransfer: permit2Transfers[0],
151
236
  authorization: authorizations[0],
152
- midnightOfferRoot: midnightOfferRoots[0],
153
237
  };
154
238
  }
@@ -500,7 +500,8 @@ export declare class BundlesPermitMismatchError extends Error {
500
500
  /**
501
501
  * @param params - Permit mismatch values used to explain the rejection.
502
502
  * @param params.field - Permit field that does not match the exit.
503
- * @param params.expected - Value required by the exit.
503
+ * @param params.expected - Value required by the exit. For `field: "amount"` on an
504
+ * operation that accepts a range of permit amounts, an inclusive `"[min, max]"` range.
504
505
  * @param params.actual - Value supplied by the signature.
505
506
  * @param params.cause - Original parser failure when signature decoding is wrapped.
506
507
  */
@@ -632,7 +633,7 @@ export declare class MaxRepayAssetsBelowRepayAssetsError extends Error {
632
633
  constructor(maxRepayAssets: bigint, repayAssets: bigint);
633
634
  }
634
635
  /** Requirement signature kind accepted by action-output transaction builders. */
635
- export type RequirementSignatureKind = "permit" | "permit2SignatureTransfer" | "authorization" | "midnightOfferRootSignature";
636
+ export type RequirementSignatureKind = "permit" | "permit2SignatureTransfer" | "authorization";
636
637
  /**
637
638
  * Thrown when `buildTx` receives more than one requirement signature of the same kind.
638
639
  *
@@ -709,11 +710,10 @@ export declare class UnsupportedErc20ApprovalSpenderError extends Error {
709
710
  readonly chainId: number;
710
711
  readonly permit2?: Address;
711
712
  readonly midnight?: Address;
712
- readonly midnightBundles?: Address;
713
713
  readonly supportedSpenders?: readonly (Address | undefined)[];
714
714
  });
715
715
  }
716
- /** Thrown when a Midnight authorization requirement targets an unsupported operator. */
716
+ /** Thrown when a Midnight authorization target (a requirement operator, or the ratifier that `midnightCancelAndMake` activates and MidnightBundlesV2 authorizes) is not registered for the chain. */
717
717
  export declare class UnsupportedMidnightAuthorizationTargetError extends Error {
718
718
  constructor(params: {
719
719
  readonly authorized: Address;
@@ -1027,12 +1027,19 @@ export declare class ReallocationAdapterSupplySharesUnderflowError extends Error
1027
1027
  readonly withdrawnShares: bigint;
1028
1028
  });
1029
1029
  }
1030
- /** Thrown when a Midnight amount exceeds the maximum offer-cap value accepted onchain. */
1031
- export declare class MidnightAmountExceedsMaxOfferCapError extends Error {
1030
+ /** Thrown when a Midnight batch cancellation has no offer groups. */
1031
+ export declare class EmptyMidnightGroupCancellationsError extends Error {
1032
+ constructor();
1033
+ }
1034
+ /** Thrown when a Midnight flow passes a collateral market with no collateral supplies. */
1035
+ export declare class EmptyMidnightCollateralSuppliesError extends Error {
1036
+ constructor();
1037
+ }
1038
+ /** Thrown when a Midnight batch cancellation lists the same offer group twice. */
1039
+ export declare class DuplicateMidnightGroupCancellationError extends Error {
1032
1040
  constructor(params: {
1033
- readonly label: string;
1034
- readonly amount: bigint;
1035
- readonly maxOfferCap: bigint;
1041
+ readonly index: number;
1042
+ readonly group: Hex;
1036
1043
  });
1037
1044
  }
1038
1045
  /** Thrown when a Midnight flow needs at least one takeable offer. */
@@ -1047,6 +1054,12 @@ export declare class MidnightOfferSideMismatchError extends Error {
1047
1054
  actualBuy: boolean;
1048
1055
  });
1049
1056
  }
1057
+ /** Thrown when a Midnight maker method that is not a limit exit receives a reduce-only offer. */
1058
+ export declare class MidnightOfferReduceOnlyError extends Error {
1059
+ constructor(params: {
1060
+ readonly index: number;
1061
+ });
1062
+ }
1050
1063
  /** Thrown when a Midnight maker offer belongs to a different account than the action flow. */
1051
1064
  export declare class MidnightOfferMakerMismatchError extends Error {
1052
1065
  constructor(params: {
@@ -1055,6 +1068,74 @@ export declare class MidnightOfferMakerMismatchError extends Error {
1055
1068
  readonly actualMaker: Address;
1056
1069
  });
1057
1070
  }
1071
+ /** Thrown when a Midnight maker offer sets a nonzero continuous fee cap. */
1072
+ export declare class MidnightOfferContinuousFeeCapError extends Error {
1073
+ /** Offer index in the maker tree. */
1074
+ readonly index: number;
1075
+ /** Continuous fee cap supplied on the offer. */
1076
+ readonly continuousFeeCap: bigint;
1077
+ /**
1078
+ * @param params - Offer index and rejected fee cap.
1079
+ * @param params.index - Offer index in the maker tree.
1080
+ * @param params.continuousFeeCap - Continuous fee cap supplied on the offer.
1081
+ */
1082
+ constructor(params: {
1083
+ readonly index: number;
1084
+ readonly continuousFeeCap: bigint;
1085
+ });
1086
+ }
1087
+ /** Thrown when a Midnight sell offer routes its seller proceeds to another address. */
1088
+ export declare class MidnightOfferSellerReceiverMismatchError extends Error {
1089
+ /** Offer index in the maker tree. */
1090
+ readonly index: number;
1091
+ /** Offer maker, which must receive seller proceeds. */
1092
+ readonly expectedReceiver: Address;
1093
+ /** Seller receiver supplied on the offer. */
1094
+ readonly actualReceiver: Address;
1095
+ /**
1096
+ * @param params - Offer index and expected and actual seller receivers.
1097
+ * @param params.index - Offer index in the maker tree.
1098
+ * @param params.expectedReceiver - Offer maker, which must receive seller proceeds.
1099
+ * @param params.actualReceiver - Seller receiver supplied on the offer.
1100
+ */
1101
+ constructor(params: {
1102
+ readonly index: number;
1103
+ readonly expectedReceiver: Address;
1104
+ readonly actualReceiver: Address;
1105
+ });
1106
+ }
1107
+ /** Thrown when a Midnight taker flow uses an unbounded target or deadline. */
1108
+ export declare class UnboundedMidnightTakeInputError extends Error {
1109
+ readonly field: "target.units" | "target.maxBuyerAssets" | "target.maxUnits" | "deadline";
1110
+ /**
1111
+ * @param field - Target or deadline input set to `maxUint256`.
1112
+ */
1113
+ constructor(field: "target.units" | "target.maxBuyerAssets" | "target.maxUnits" | "deadline");
1114
+ }
1115
+ /** Thrown when a Midnight taker flow uses a zero address as its receiver. */
1116
+ export declare class MidnightZeroReceiverError extends Error {
1117
+ readonly field: "receiver";
1118
+ /**
1119
+ * @param field - Receiver field containing the zero address.
1120
+ */
1121
+ constructor(field: "receiver");
1122
+ }
1123
+ /** Thrown when a Midnight take deadline is more than one hour from the current time. */
1124
+ export declare class MidnightTakeDeadlineTooFarError extends Error {
1125
+ /** Deadline supplied by the caller. */
1126
+ readonly deadline: bigint;
1127
+ /** Accepted maximum deadline. */
1128
+ readonly maxDeadline: bigint;
1129
+ /**
1130
+ * @param params - Supplied deadline and accepted maximum.
1131
+ * @param params.deadline - Deadline supplied by the caller.
1132
+ * @param params.maxDeadline - Latest accepted deadline.
1133
+ */
1134
+ constructor(params: {
1135
+ readonly deadline: bigint;
1136
+ readonly maxDeadline: bigint;
1137
+ });
1138
+ }
1058
1139
  /** Thrown when a Midnight maker offer targets a different chain than the action flow. */
1059
1140
  export declare class MidnightOfferMarketChainMismatchError extends Error {
1060
1141
  constructor(params: {
@@ -1086,58 +1167,57 @@ export declare class MidnightOfferMarketLoanTokenMismatchError extends Error {
1086
1167
  readonly actualLoanToken: Address;
1087
1168
  });
1088
1169
  }
1089
- /** Thrown when a quoted Midnight takeable offer belongs to a different market than the requested flow. */
1090
- export declare class MidnightTakeableOfferMarketMismatchError extends Error {
1170
+ /** Thrown when a Blue-funded Midnight lend offer does not use the maker's derived `BlueBuyCallback`. */
1171
+ export declare class MidnightOfferCallbackMismatchError extends Error {
1091
1172
  constructor(params: {
1092
- index: number;
1093
- expectedMarket: string;
1094
- actualMarket: string;
1173
+ readonly index: number;
1174
+ readonly expectedCallback: Address;
1175
+ readonly actualCallback: Address;
1095
1176
  });
1096
1177
  }
1097
- /** Thrown when a Midnight offer tree uses an unsupported ratifier address. */
1098
- export declare class UnknownMidnightRatifierError extends Error {
1178
+ /** Thrown when a Blue-funded Midnight lend offer's callback data is not the ABI-encoded Blue market. */
1179
+ export declare class MidnightOfferCallbackDataMismatchError extends Error {
1099
1180
  constructor(params: {
1100
- ratifier: Address;
1101
- ecrecoverRatifier: Address;
1102
- setterRatifier: Address;
1181
+ readonly index: number;
1182
+ readonly expectedCallbackData: Hex;
1183
+ readonly actualCallbackData: Hex;
1103
1184
  });
1104
1185
  }
1105
- /** Thrown when a Midnight Ecrecover maker flow builds the submit transaction before signing. */
1106
- export declare class MissingMidnightOfferRootSignatureError extends Error {
1107
- constructor();
1186
+ /** Thrown when loan assets would be parked in a Morpho Blue market with no existing supply. */
1187
+ export declare class EmptyBlueParkingMarketError extends Error {
1188
+ constructor(params: {
1189
+ readonly marketId: MarketId;
1190
+ });
1108
1191
  }
1109
- /** Thrown when a Midnight offer-root signature does not match the prepared tree root. */
1110
- export declare class MidnightOfferRootMismatchError extends Error {
1192
+ /** Thrown when parked assets would mint no Morpho Blue supply shares. */
1193
+ export declare class ZeroBlueParkingSharesError extends Error {
1111
1194
  constructor(params: {
1112
- expectedRoot: string;
1113
- actualRoot: string;
1195
+ readonly marketId: MarketId;
1196
+ readonly assets: bigint;
1114
1197
  });
1115
1198
  }
1116
- /** Thrown when a Midnight offer-root signature was produced by another maker account. */
1117
- export declare class MidnightOfferRootOwnerMismatchError extends Error {
1199
+ /** Thrown when a quoted Midnight takeable offer belongs to a different market than the requested flow. */
1200
+ export declare class MidnightTakeableOfferMarketMismatchError extends Error {
1118
1201
  constructor(params: {
1119
- expectedOwner: Address;
1120
- actualOwner: Address;
1202
+ index: number;
1203
+ expectedMarket: string;
1204
+ actualMarket: string;
1121
1205
  });
1122
1206
  }
1123
- /** Thrown when a Midnight offer-root signature targets another ratifier. */
1124
- export declare class MidnightOfferRootRatifierMismatchError extends Error {
1207
+ /** Thrown when a Midnight offer's ratifier does not match its tree's ratifier route. */
1208
+ export declare class MidnightOfferRatifierMismatchError extends Error {
1125
1209
  constructor(params: {
1210
+ index: number;
1126
1211
  expectedRatifier: Address;
1127
1212
  actualRatifier: Address;
1128
1213
  });
1129
1214
  }
1130
- /** Thrown when a Midnight offer-root signature was produced for another offer count. */
1131
- export declare class MidnightOfferRootOfferCountMismatchError extends Error {
1215
+ /** Thrown when a Midnight repost cancels a group it also publishes. */
1216
+ export declare class MidnightReplacementGroupCancelledError extends Error {
1132
1217
  constructor(params: {
1133
- expectedOffers: number;
1134
- actualOffers: number;
1218
+ readonly group: Hex;
1135
1219
  });
1136
1220
  }
1137
- /** Thrown when a Midnight offer-root signature carries no encoded payload. */
1138
- export declare class UnpreparedMidnightOfferRootSignatureError extends Error {
1139
- constructor();
1140
- }
1141
1221
  /** Thrown when a Midnight redeem flow finds no credit units for the user. */
1142
1222
  export declare class NoMidnightCreditToRedeemError extends Error {
1143
1223
  constructor(market: string);
@@ -1209,3 +1289,9 @@ export declare class RefinanceSameMarketError extends Error {
1209
1289
  export declare class RefinanceTokenMismatchError extends Error {
1210
1290
  constructor(sourceMarket: string, targetMarket: string);
1211
1291
  }
1292
+ /** Thrown when a maker limit-exit offer can increase or open a position. */
1293
+ export declare class MidnightOfferNotReduceOnlyError extends Error {
1294
+ constructor(params: {
1295
+ readonly index: number;
1296
+ });
1297
+ }