@morpho-org/morpho-sdk 5.2.0 → 5.3.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 (270) hide show
  1. package/README.md +46 -2
  2. package/lib/cjs/abis.d.ts +1 -0
  3. package/lib/cjs/abis.js +6 -1
  4. package/lib/cjs/actions/blue/borrow.d.ts +3 -7
  5. package/lib/cjs/actions/blue/borrow.js +5 -9
  6. package/lib/cjs/actions/blue/buildReallocationActions.d.ts +3 -4
  7. package/lib/cjs/actions/blue/buildReallocationActions.js +3 -4
  8. package/lib/cjs/actions/blue/refinance.d.ts +4 -8
  9. package/lib/cjs/actions/blue/refinance.js +10 -14
  10. package/lib/cjs/actions/blue/repay.d.ts +2 -5
  11. package/lib/cjs/actions/blue/repay.js +2 -5
  12. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +3 -6
  13. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +4 -7
  14. package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +2 -5
  15. package/lib/cjs/actions/blue/resolveRepayFunding.js +15 -12
  16. package/lib/cjs/actions/blue/supply.d.ts +2 -4
  17. package/lib/cjs/actions/blue/supply.js +6 -8
  18. package/lib/cjs/actions/blue/supplyCollateral.d.ts +2 -3
  19. package/lib/cjs/actions/blue/supplyCollateral.js +5 -6
  20. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +4 -9
  21. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +9 -14
  22. package/lib/cjs/actions/blue/withdraw.d.ts +9 -7
  23. package/lib/cjs/actions/blue/withdraw.js +18 -10
  24. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -1
  25. package/lib/cjs/actions/blue/withdrawCollateral.js +2 -2
  26. package/lib/cjs/actions/index.d.ts +2 -0
  27. package/lib/cjs/actions/index.js +1 -0
  28. package/lib/cjs/actions/midnight/authorization.d.ts +37 -0
  29. package/lib/cjs/actions/midnight/authorization.js +69 -0
  30. package/lib/cjs/actions/midnight/cancelOffer.d.ts +38 -0
  31. package/lib/cjs/actions/midnight/cancelOffer.js +73 -0
  32. package/lib/cjs/actions/midnight/index.d.ts +11 -0
  33. package/lib/cjs/actions/midnight/index.js +27 -0
  34. package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +52 -0
  35. package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +72 -0
  36. package/lib/cjs/actions/midnight/redeem.d.ts +43 -0
  37. package/lib/cjs/actions/midnight/redeem.js +79 -0
  38. package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +53 -0
  39. package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +121 -0
  40. package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.d.ts +40 -0
  41. package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.js +59 -0
  42. package/lib/cjs/actions/midnight/supplyCollateral.d.ts +45 -0
  43. package/lib/cjs/actions/midnight/supplyCollateral.js +83 -0
  44. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +51 -0
  45. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +128 -0
  46. package/lib/cjs/actions/midnight/takeBorrow.d.ts +57 -0
  47. package/lib/cjs/actions/midnight/takeBorrow.js +110 -0
  48. package/lib/cjs/actions/midnight/takeLend.d.ts +57 -0
  49. package/lib/cjs/actions/midnight/takeLend.js +110 -0
  50. package/lib/cjs/actions/midnight/types.d.ts +39 -0
  51. package/lib/cjs/actions/midnight/types.js +15 -0
  52. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -1
  53. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +5 -16
  54. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +5 -4
  55. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +10 -14
  56. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +2 -2
  57. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +11 -28
  58. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +1 -1
  59. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +5 -17
  60. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
  61. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +10 -4
  62. package/lib/cjs/actions/requirements/getRequirementsApproval.js +10 -4
  63. package/lib/cjs/actions/requirements/index.d.ts +1 -0
  64. package/lib/cjs/actions/requirements/index.js +1 -0
  65. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +49 -0
  66. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +76 -0
  67. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +44 -0
  68. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +78 -0
  69. package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +42 -0
  70. package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +70 -0
  71. package/lib/cjs/actions/requirements/midnight/index.d.ts +3 -0
  72. package/lib/cjs/actions/requirements/midnight/index.js +19 -0
  73. package/lib/cjs/actions/vaultV1/deposit.d.ts +3 -4
  74. package/lib/cjs/actions/vaultV1/deposit.js +7 -8
  75. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +2 -3
  76. package/lib/cjs/actions/vaultV1/migrateToV2.js +5 -6
  77. package/lib/cjs/actions/vaultV1/redeem.d.ts +1 -1
  78. package/lib/cjs/actions/vaultV1/redeem.js +2 -2
  79. package/lib/cjs/actions/vaultV1/withdraw.d.ts +1 -1
  80. package/lib/cjs/actions/vaultV1/withdraw.js +2 -2
  81. package/lib/cjs/actions/vaultV2/deposit.d.ts +3 -4
  82. package/lib/cjs/actions/vaultV2/deposit.js +7 -8
  83. package/lib/cjs/actions/vaultV2/forceRedeem.d.ts +2 -3
  84. package/lib/cjs/actions/vaultV2/forceRedeem.js +3 -4
  85. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
  86. package/lib/cjs/actions/vaultV2/forceWithdraw.js +2 -2
  87. package/lib/cjs/actions/vaultV2/redeem.d.ts +1 -1
  88. package/lib/cjs/actions/vaultV2/redeem.js +2 -2
  89. package/lib/cjs/actions/vaultV2/withdraw.d.ts +1 -1
  90. package/lib/cjs/actions/vaultV2/withdraw.js +2 -2
  91. package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
  92. package/lib/cjs/client/morphoViemExtension.js +5 -2
  93. package/lib/cjs/constants.d.ts +1 -0
  94. package/lib/cjs/constants.js +15 -1
  95. package/lib/cjs/entities/blue/blue.d.ts +5 -5
  96. package/lib/cjs/entities/blue/blue.js +99 -80
  97. package/lib/cjs/entities/index.d.ts +1 -0
  98. package/lib/cjs/entities/index.js +15 -0
  99. package/lib/cjs/entities/midnight/index.d.ts +2 -0
  100. package/lib/cjs/entities/midnight/index.js +18 -0
  101. package/lib/cjs/entities/midnight/midnight.d.ts +402 -0
  102. package/lib/cjs/entities/midnight/midnight.js +1036 -0
  103. package/lib/cjs/entities/midnight/types.d.ts +164 -0
  104. package/lib/cjs/entities/midnight/types.js +2 -0
  105. package/lib/cjs/entities/vaultV1/vaultV1.js +10 -17
  106. package/lib/cjs/entities/vaultV2/vaultV2.js +19 -21
  107. package/lib/cjs/errors.d.ts +1 -0
  108. package/lib/cjs/errors.js +17 -1
  109. package/lib/cjs/helpers/encodeDeallocation.d.ts +1 -0
  110. package/lib/cjs/helpers/encodeDeallocation.js +2 -1
  111. package/lib/cjs/helpers/index.d.ts +4 -1
  112. package/lib/cjs/helpers/index.js +8 -1
  113. package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +34 -0
  114. package/lib/cjs/helpers/signAndVerifyTypedData.js +58 -0
  115. package/lib/cjs/helpers/validate.d.ts +40 -1
  116. package/lib/cjs/helpers/validate.js +47 -5
  117. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +15 -0
  118. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +32 -0
  119. package/lib/cjs/helpers/validateMidnightMarket.d.ts +10 -0
  120. package/lib/cjs/helpers/validateMidnightMarket.js +24 -0
  121. package/lib/cjs/helpers/validateOfferSides.d.ts +21 -0
  122. package/lib/cjs/helpers/validateOfferSides.js +36 -0
  123. package/lib/cjs/helpers/validateRequirementSpender.d.ts +29 -0
  124. package/lib/cjs/helpers/validateRequirementSpender.js +49 -0
  125. package/lib/cjs/helpers/validateTakeableOffers.d.ts +18 -0
  126. package/lib/cjs/helpers/validateTakeableOffers.js +35 -0
  127. package/lib/cjs/midnight-api.d.ts +1 -0
  128. package/lib/cjs/midnight-api.js +17 -0
  129. package/lib/cjs/types/action.d.ts +189 -23
  130. package/lib/cjs/types/action.js +27 -7
  131. package/lib/cjs/types/client.d.ts +3 -2
  132. package/lib/cjs/types/error.d.ts +288 -119
  133. package/lib/cjs/types/error.js +259 -180
  134. package/lib/cjs/utils.d.ts +1 -0
  135. package/lib/cjs/utils.js +12 -2
  136. package/lib/esm/abis.d.ts +1 -0
  137. package/lib/esm/abis.js +1 -0
  138. package/lib/esm/actions/blue/borrow.d.ts +3 -7
  139. package/lib/esm/actions/blue/borrow.js +6 -10
  140. package/lib/esm/actions/blue/buildReallocationActions.d.ts +3 -4
  141. package/lib/esm/actions/blue/buildReallocationActions.js +3 -4
  142. package/lib/esm/actions/blue/refinance.d.ts +4 -8
  143. package/lib/esm/actions/blue/refinance.js +11 -15
  144. package/lib/esm/actions/blue/repay.d.ts +2 -5
  145. package/lib/esm/actions/blue/repay.js +2 -5
  146. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +3 -6
  147. package/lib/esm/actions/blue/repayWithdrawCollateral.js +5 -8
  148. package/lib/esm/actions/blue/resolveRepayFunding.d.ts +2 -5
  149. package/lib/esm/actions/blue/resolveRepayFunding.js +16 -13
  150. package/lib/esm/actions/blue/supply.d.ts +2 -4
  151. package/lib/esm/actions/blue/supply.js +7 -9
  152. package/lib/esm/actions/blue/supplyCollateral.d.ts +2 -3
  153. package/lib/esm/actions/blue/supplyCollateral.js +6 -7
  154. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +4 -9
  155. package/lib/esm/actions/blue/supplyCollateralBorrow.js +10 -15
  156. package/lib/esm/actions/blue/withdraw.d.ts +9 -7
  157. package/lib/esm/actions/blue/withdraw.js +19 -11
  158. package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -1
  159. package/lib/esm/actions/blue/withdrawCollateral.js +3 -3
  160. package/lib/esm/actions/index.d.ts +2 -0
  161. package/lib/esm/actions/index.js +1 -0
  162. package/lib/esm/actions/midnight/authorization.d.ts +37 -0
  163. package/lib/esm/actions/midnight/authorization.js +65 -0
  164. package/lib/esm/actions/midnight/cancelOffer.d.ts +38 -0
  165. package/lib/esm/actions/midnight/cancelOffer.js +69 -0
  166. package/lib/esm/actions/midnight/index.d.ts +11 -0
  167. package/lib/esm/actions/midnight/index.js +11 -0
  168. package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +52 -0
  169. package/lib/esm/actions/midnight/mempoolSubmitOffers.js +68 -0
  170. package/lib/esm/actions/midnight/redeem.d.ts +43 -0
  171. package/lib/esm/actions/midnight/redeem.js +75 -0
  172. package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +53 -0
  173. package/lib/esm/actions/midnight/repayWithdrawCollateral.js +117 -0
  174. package/lib/esm/actions/midnight/setterRatifierRatifyRoot.d.ts +40 -0
  175. package/lib/esm/actions/midnight/setterRatifierRatifyRoot.js +55 -0
  176. package/lib/esm/actions/midnight/supplyCollateral.d.ts +45 -0
  177. package/lib/esm/actions/midnight/supplyCollateral.js +79 -0
  178. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +51 -0
  179. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +124 -0
  180. package/lib/esm/actions/midnight/takeBorrow.d.ts +57 -0
  181. package/lib/esm/actions/midnight/takeBorrow.js +106 -0
  182. package/lib/esm/actions/midnight/takeLend.d.ts +57 -0
  183. package/lib/esm/actions/midnight/takeLend.js +106 -0
  184. package/lib/esm/actions/midnight/types.d.ts +39 -0
  185. package/lib/esm/actions/midnight/types.js +12 -0
  186. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -1
  187. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +6 -17
  188. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +5 -4
  189. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +12 -16
  190. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +2 -2
  191. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +12 -29
  192. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +1 -1
  193. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +5 -17
  194. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
  195. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +10 -4
  196. package/lib/esm/actions/requirements/getRequirementsApproval.js +10 -4
  197. package/lib/esm/actions/requirements/index.d.ts +1 -0
  198. package/lib/esm/actions/requirements/index.js +1 -0
  199. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +49 -0
  200. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +72 -0
  201. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +44 -0
  202. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +74 -0
  203. package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +42 -0
  204. package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +66 -0
  205. package/lib/esm/actions/requirements/midnight/index.d.ts +3 -0
  206. package/lib/esm/actions/requirements/midnight/index.js +3 -0
  207. package/lib/esm/actions/vaultV1/deposit.d.ts +3 -4
  208. package/lib/esm/actions/vaultV1/deposit.js +8 -9
  209. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +2 -3
  210. package/lib/esm/actions/vaultV1/migrateToV2.js +6 -7
  211. package/lib/esm/actions/vaultV1/redeem.d.ts +1 -1
  212. package/lib/esm/actions/vaultV1/redeem.js +3 -3
  213. package/lib/esm/actions/vaultV1/withdraw.d.ts +1 -1
  214. package/lib/esm/actions/vaultV1/withdraw.js +3 -3
  215. package/lib/esm/actions/vaultV2/deposit.d.ts +3 -4
  216. package/lib/esm/actions/vaultV2/deposit.js +8 -9
  217. package/lib/esm/actions/vaultV2/forceRedeem.d.ts +2 -3
  218. package/lib/esm/actions/vaultV2/forceRedeem.js +4 -5
  219. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
  220. package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -3
  221. package/lib/esm/actions/vaultV2/redeem.d.ts +1 -1
  222. package/lib/esm/actions/vaultV2/redeem.js +3 -3
  223. package/lib/esm/actions/vaultV2/withdraw.d.ts +1 -1
  224. package/lib/esm/actions/vaultV2/withdraw.js +3 -3
  225. package/lib/esm/client/morphoViemExtension.d.ts +1 -1
  226. package/lib/esm/client/morphoViemExtension.js +6 -3
  227. package/lib/esm/constants.d.ts +1 -0
  228. package/lib/esm/constants.js +1 -0
  229. package/lib/esm/entities/blue/blue.d.ts +5 -5
  230. package/lib/esm/entities/blue/blue.js +101 -82
  231. package/lib/esm/entities/index.d.ts +1 -0
  232. package/lib/esm/entities/index.js +1 -0
  233. package/lib/esm/entities/midnight/index.d.ts +2 -0
  234. package/lib/esm/entities/midnight/index.js +2 -0
  235. package/lib/esm/entities/midnight/midnight.d.ts +402 -0
  236. package/lib/esm/entities/midnight/midnight.js +1032 -0
  237. package/lib/esm/entities/midnight/types.d.ts +164 -0
  238. package/lib/esm/entities/midnight/types.js +1 -0
  239. package/lib/esm/entities/vaultV1/vaultV1.js +13 -20
  240. package/lib/esm/entities/vaultV2/vaultV2.js +9 -11
  241. package/lib/esm/errors.d.ts +1 -0
  242. package/lib/esm/errors.js +1 -0
  243. package/lib/esm/helpers/encodeDeallocation.d.ts +1 -0
  244. package/lib/esm/helpers/encodeDeallocation.js +3 -2
  245. package/lib/esm/helpers/index.d.ts +4 -1
  246. package/lib/esm/helpers/index.js +4 -1
  247. package/lib/esm/helpers/signAndVerifyTypedData.d.ts +34 -0
  248. package/lib/esm/helpers/signAndVerifyTypedData.js +54 -0
  249. package/lib/esm/helpers/validate.d.ts +40 -1
  250. package/lib/esm/helpers/validate.js +46 -5
  251. package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +15 -0
  252. package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +28 -0
  253. package/lib/esm/helpers/validateMidnightMarket.d.ts +10 -0
  254. package/lib/esm/helpers/validateMidnightMarket.js +20 -0
  255. package/lib/esm/helpers/validateOfferSides.d.ts +21 -0
  256. package/lib/esm/helpers/validateOfferSides.js +32 -0
  257. package/lib/esm/helpers/validateRequirementSpender.d.ts +29 -0
  258. package/lib/esm/helpers/validateRequirementSpender.js +45 -0
  259. package/lib/esm/helpers/validateTakeableOffers.d.ts +18 -0
  260. package/lib/esm/helpers/validateTakeableOffers.js +31 -0
  261. package/lib/esm/midnight-api.d.ts +1 -0
  262. package/lib/esm/midnight-api.js +1 -0
  263. package/lib/esm/types/action.d.ts +189 -23
  264. package/lib/esm/types/action.js +26 -7
  265. package/lib/esm/types/client.d.ts +3 -2
  266. package/lib/esm/types/error.d.ts +288 -119
  267. package/lib/esm/types/error.js +232 -154
  268. package/lib/esm/utils.d.ts +1 -0
  269. package/lib/esm/utils.js +1 -0
  270. package/package.json +11 -2
@@ -1,4 +1,102 @@
1
1
  import { UnknownDataError } from "@morpho-org/blue-sdk";
2
+ /**
3
+ * Thrown when a morpho-sdk input that must be non-negative is negative.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { NegativeInputError } from "@morpho-org/morpho-sdk";
8
+ *
9
+ * const error = new NegativeInputError("amount", -1n);
10
+ * if (error instanceof NegativeInputError) {
11
+ * console.error(error.field, error.value);
12
+ * }
13
+ * ```
14
+ */
15
+ export class NegativeInputError extends Error {
16
+ field;
17
+ value;
18
+ /**
19
+ * @param field - Public input field whose value is invalid.
20
+ * @param value - Negative bigint supplied for the field.
21
+ */
22
+ constructor(field, value) {
23
+ super(`Input "${field}" must be non-negative, got "${value}".`);
24
+ this.field = field;
25
+ this.value = value;
26
+ this.name = "NegativeInputError";
27
+ }
28
+ }
29
+ /**
30
+ * Thrown when a morpho-sdk input that must be positive is zero or negative.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import { NonPositiveInputError } from "@morpho-org/morpho-sdk";
35
+ *
36
+ * const error = new NonPositiveInputError("shares", 0n);
37
+ * if (error instanceof NonPositiveInputError) {
38
+ * console.error(error.field, error.value);
39
+ * }
40
+ * ```
41
+ */
42
+ export class NonPositiveInputError extends Error {
43
+ field;
44
+ value;
45
+ /**
46
+ * @param field - Public input field whose value is invalid.
47
+ * @param value - Zero or negative bigint supplied for the field.
48
+ */
49
+ constructor(field, value) {
50
+ super(`Input "${field}" must be positive, got "${value}".`);
51
+ this.field = field;
52
+ this.value = value;
53
+ this.name = "NonPositiveInputError";
54
+ }
55
+ }
56
+ /** @deprecated Use {@link NonPositiveInputError}. */
57
+ export const NonPositiveAssetAmountError = NonPositiveInputError;
58
+ /** @deprecated Use {@link NonPositiveInputError}. */
59
+ export const NonPositiveSharesAmountError = NonPositiveInputError;
60
+ /** @deprecated Use {@link NonPositiveInputError}. */
61
+ export const NonPositiveMaxSharePriceError = NonPositiveInputError;
62
+ /** @deprecated Use {@link NonPositiveInputError}. */
63
+ export const ZeroDepositAmountError = NonPositiveInputError;
64
+ /** @deprecated Use {@link NonPositiveInputError}. */
65
+ export const NonPositiveBorrowAmountError = NonPositiveInputError;
66
+ /** @deprecated Use {@link NonPositiveInputError}. */
67
+ export const ZeroCollateralAmountError = NonPositiveInputError;
68
+ /** @deprecated Use {@link NonPositiveInputError}. */
69
+ export const NonPositiveReallocationAmountError = NonPositiveInputError;
70
+ /** @deprecated Use {@link NonPositiveInputError}. */
71
+ export const NonPositiveRepayAmountError = NonPositiveInputError;
72
+ /** @deprecated Use {@link NonPositiveInputError}. */
73
+ export const NonPositiveRepayMaxSharePriceError = NonPositiveInputError;
74
+ /** @deprecated Use {@link NonPositiveInputError}. */
75
+ export const NonPositiveWithdrawCollateralAmountError = NonPositiveInputError;
76
+ /** @deprecated Use {@link NonPositiveInputError}. */
77
+ export const ZeroSupplyAmountError = NonPositiveInputError;
78
+ /** @deprecated Use {@link NonPositiveInputError}. */
79
+ export const NonPositiveWithdrawAmountError = NonPositiveInputError;
80
+ /** @deprecated Use {@link NegativeInputError}. */
81
+ export const NegativeSlippageToleranceError = NegativeInputError;
82
+ /** @deprecated Use {@link NegativeInputError}. */
83
+ export const NegativeNativeAmountError = NegativeInputError;
84
+ /** @deprecated Use {@link NegativeInputError}. */
85
+ export const NegativeReallocationFeeError = NegativeInputError;
86
+ /** @deprecated Use {@link NegativeInputError}. */
87
+ export const NonPositiveMinBorrowSharePriceError = NegativeInputError;
88
+ /** @deprecated Use {@link NegativeInputError}. */
89
+ export const NegativeSupplyAmountError = NegativeInputError;
90
+ /** @deprecated Use {@link NegativeInputError}. */
91
+ export const NegativeSupplyMaxSharePriceError = NegativeInputError;
92
+ /** @deprecated Use {@link NegativeInputError}. */
93
+ export const NegativeWithdrawMinSharePriceError = NegativeInputError;
94
+ /** @deprecated Use {@link NegativeInputError}. */
95
+ export const NegativeMinSharePriceError = NegativeInputError;
96
+ /** @deprecated Use {@link NegativeInputError}. */
97
+ export const NegativeBorrowSharesError = NegativeInputError;
98
+ /** @deprecated Use {@link NegativeInputError}. */
99
+ export const NegativeMaxRepaySharePriceError = NegativeInputError;
2
100
  /**
3
101
  * Typed errors thrown while encoding supported Bundler3 actions.
4
102
  *
@@ -75,21 +173,21 @@ export var BundlerErrors;
75
173
  /**
76
174
  * Thrown when `buildTx` receives more than one requirement signature of the same kind.
77
175
  *
78
- * A bundled path consumes at most one permit and one authorization signature; passing several of
79
- * the same kind is ambiguous and would silently drop all but the first, so it is rejected instead.
176
+ * A bundled path consumes at most one signature per accepted kind; passing several of the same
177
+ * kind is ambiguous and would silently drop all but the first, so it is rejected instead.
80
178
  *
81
179
  * @example
82
180
  * ```ts
83
181
  * import { AmbiguousRequirementSignaturesError } from "@morpho-org/morpho-sdk";
84
182
  *
85
183
  * if (error instanceof AmbiguousRequirementSignaturesError) {
86
- * // Pass a single permit (and at most one authorization) signature to buildTx.
184
+ * // Pass a single signature per accepted kind to buildTx.
87
185
  * }
88
186
  * ```
89
187
  */
90
188
  export class AmbiguousRequirementSignaturesError extends Error {
91
189
  /**
92
- * @param kind - The over-supplied signature kind (`"permit"` or `"authorization"`).
190
+ * @param kind - The over-supplied signature kind.
93
191
  * @param count - How many signatures of that kind were received.
94
192
  */
95
193
  constructor(kind, count) {
@@ -97,9 +195,8 @@ export class AmbiguousRequirementSignaturesError extends Error {
97
195
  }
98
196
  }
99
197
  /**
100
- * Thrown when `buildTx` receives a requirement signature of a kind the operation does not consume
101
- * (for example an authorization signature on a plain supply path). Surfacing it prevents a signed
102
- * authorization or permit from being silently ignored.
198
+ * Thrown when `buildTx` receives a requirement signature of a kind the operation does not consume.
199
+ * Surfacing it prevents a signed requirement from being silently ignored.
103
200
  *
104
201
  * @example
105
202
  * ```ts
@@ -112,30 +209,12 @@ export class AmbiguousRequirementSignaturesError extends Error {
112
209
  */
113
210
  export class UnexpectedRequirementSignatureError extends Error {
114
211
  /**
115
- * @param kind - The unexpected signature kind (`"permit"` or `"authorization"`).
212
+ * @param kind - The unexpected signature kind.
116
213
  */
117
214
  constructor(kind) {
118
215
  super(`Received a ${kind} signature that this operation does not consume. Remove it from the buildTx signatures array.`);
119
216
  }
120
217
  }
121
- /** Thrown when an asset amount is required to be positive but is zero or negative. */
122
- export class NonPositiveAssetAmountError extends Error {
123
- constructor(origin) {
124
- super(`Asset amount must be positive for address ${origin}`);
125
- }
126
- }
127
- /** Thrown when a shares amount is required to be positive but is zero or negative. */
128
- export class NonPositiveSharesAmountError extends Error {
129
- constructor(vault) {
130
- super(`Shares amount must be positive for address: ${vault}`);
131
- }
132
- }
133
- /** Thrown when a vault deposit's `maxSharePrice` slippage bound is zero or negative. */
134
- export class NonPositiveMaxSharePriceError extends Error {
135
- constructor(vault) {
136
- super(`Max share price must be positive for vault: ${vault}`);
137
- }
138
- }
139
218
  /** Thrown when a viem client's account address does not match the address required by the call. */
140
219
  export class AddressMismatchError extends Error {
141
220
  constructor(clientAddress, argsAddress) {
@@ -148,6 +227,12 @@ export class ChainIdMismatchError extends Error {
148
227
  super(`Chain ID mismatch between client: ${clientChainId} and args: ${argsChainId}`);
149
228
  }
150
229
  }
230
+ /** Thrown when a runtime crypto API is required but unavailable. */
231
+ export class CryptoUnavailableError extends Error {
232
+ constructor(feature) {
233
+ super(`Crypto API is required for ${feature} but is unavailable.`);
234
+ }
235
+ }
151
236
  /** Thrown when the viem client is missing a property the call requires (e.g. `account.address`). */
152
237
  export class MissingClientPropertyError extends Error {
153
238
  constructor(property) {
@@ -174,16 +259,18 @@ export class UnsupportedErc20ApprovalSpenderError extends Error {
174
259
  super(`Requirement spender "${params.spender}" is not supported on chain "${params.chainId}". Use "${supported}".`);
175
260
  }
176
261
  }
177
- /** Thrown when a slippage tolerance is negative. */
178
- export class NegativeSlippageToleranceError extends Error {
179
- constructor(slippageTolerance) {
180
- super(`Slippage tolerance ${slippageTolerance} must not be negative`);
262
+ /** Thrown when a Midnight authorization requirement targets an unsupported operator. */
263
+ export class UnsupportedMidnightAuthorizationTargetError extends Error {
264
+ constructor(params) {
265
+ super(`Midnight authorization target "${params.authorized}" is not supported on chain "${params.chainId}". Use "${params.supportedTargets.join('", "')}".`);
181
266
  }
182
267
  }
183
- /** Thrown when a Morpho accrual position is missing for a market the call needs to read. */
268
+ /** Thrown when a Morpho accrual position required by a call is missing. */
184
269
  export class MissingAccrualPositionError extends Error {
185
270
  constructor(market) {
186
- super(`Accrual position is missing for market: ${market}`);
271
+ super(market == null
272
+ ? "Accrual position is missing. Fetch the position data and try again."
273
+ : `Accrual position is missing for market: ${market}`);
187
274
  }
188
275
  }
189
276
  /** Thrown when a slippage tolerance exceeds `MAX_SLIPPAGE_TOLERANCE` (10%). */
@@ -210,6 +297,18 @@ export class DepositAssetMismatchError extends Error {
210
297
  super(`Deposit asset "${depositAsset}" does not match requirement signature asset "${signatureAsset}"`);
211
298
  }
212
299
  }
300
+ /** Thrown when a deposit's owner differs from the owner the supplied permit / permit2 signature was issued for. */
301
+ export class DepositOwnerMismatchError extends Error {
302
+ constructor(depositOwner, signatureOwner) {
303
+ super(`Deposit owner "${depositOwner}" does not match requirement signature owner "${signatureOwner}"`);
304
+ }
305
+ }
306
+ /** Thrown when a deposit's spender differs from the spender the supplied permit / permit2 signature was issued for. */
307
+ export class DepositSpenderMismatchError extends Error {
308
+ constructor(depositSpender, signatureSpender) {
309
+ super(`Deposit spender "${depositSpender}" does not match requirement signature spender "${signatureSpender}"`);
310
+ }
311
+ }
213
312
  /** Thrown when a `permit2` requirement signature is missing the `expiration` field. */
214
313
  export class Permit2ExpirationMissingError extends Error {
215
314
  constructor() {
@@ -228,36 +327,12 @@ export class ChainWNativeMissingError extends Error {
228
327
  super(`Chain ${chainId} does not have a configured wrapped native token (wNative)`);
229
328
  }
230
329
  }
231
- /** Thrown when `nativeAmount` is negative. */
232
- export class NegativeNativeAmountError extends Error {
233
- constructor(nativeAmount) {
234
- super(`Native amount must not be negative, got ${nativeAmount}`);
235
- }
236
- }
237
- /** Thrown when both `amount` and `nativeAmount` resolve to zero on a vault deposit. */
238
- export class ZeroDepositAmountError extends Error {
239
- constructor(vault) {
240
- super(`Total deposit amount must be positive for vault: ${vault}. Both amount and nativeAmount are zero.`);
241
- }
242
- }
243
330
  /** Thrown when a vault entity's address does not match the vault address embedded in the call's args. */
244
331
  export class VaultAddressMismatchError extends Error {
245
332
  constructor(vaultAddress, argsVaultAddress) {
246
333
  super(`Vault address mismatch between vault: ${vaultAddress} and args: ${argsVaultAddress}`);
247
334
  }
248
335
  }
249
- /** Thrown when a market borrow amount is zero or negative. */
250
- export class NonPositiveBorrowAmountError extends Error {
251
- constructor(market) {
252
- super(`Borrow amount must be positive for market: ${market}`);
253
- }
254
- }
255
- /** Thrown when both `amount` and `nativeAmount` resolve to zero on a market collateral supply. */
256
- export class ZeroCollateralAmountError extends Error {
257
- constructor(market) {
258
- super(`Total collateral amount must be positive for market: ${market}. Both amount and nativeAmount are zero.`);
259
- }
260
- }
261
336
  /** Thrown when an action uses `nativeAmount` but the target asset is not the chain's wNative. */
262
337
  export class NativeAmountOnNonWNativeAssetError extends Error {
263
338
  constructor(asset, wNative) {
@@ -290,24 +365,12 @@ export class AccrualPositionUserMismatchError extends Error {
290
365
  super(`Accrual position user ${positionUser} does not match expected user ${expectedUser}`);
291
366
  }
292
367
  }
293
- /** Thrown when a reallocation's fee is negative. */
294
- export class NegativeReallocationFeeError extends Error {
295
- constructor(vault) {
296
- super(`Reallocation fee must not be negative for vault: ${vault}`);
297
- }
298
- }
299
368
  /** Thrown when a reallocation has no withdrawals. */
300
369
  export class EmptyReallocationWithdrawalsError extends Error {
301
370
  constructor(vault) {
302
371
  super(`Reallocation withdrawals list cannot be empty for vault: ${vault}`);
303
372
  }
304
373
  }
305
- /** Thrown when a reallocation withdrawal amount is zero or negative. */
306
- export class NonPositiveReallocationAmountError extends Error {
307
- constructor(vault, market) {
308
- super(`Reallocation withdrawal amount must be positive for vault ${vault} on market ${market}`);
309
- }
310
- }
311
374
  /** Thrown when a reallocation withdrawal references the operation's target market (which would be a no-op or self-deal). */
312
375
  export class ReallocationWithdrawalOnTargetMarketError extends Error {
313
376
  constructor(vault, marketId) {
@@ -320,19 +383,6 @@ export class UnsortedReallocationWithdrawalsError extends Error {
320
383
  super(`Reallocation withdrawals must be strictly sorted by market ID for vault ${vault}. Market ${marketId} is out of order.`);
321
384
  }
322
385
  }
323
- /**
324
- * Thrown when a market repay's `transferAmount` is zero or negative.
325
- *
326
- * @deprecated No longer thrown. The repay action layer no longer validates `transferAmount`
327
- * directly (assets mode uses {@link NonPositiveRepayAmountError}; shares mode allows a zero
328
- * ERC-20 transfer for fully-native repays). Retained as exported API for back-compat; slated
329
- * for removal in a future major.
330
- */
331
- export class NonPositiveTransferAmountError extends Error {
332
- constructor(market) {
333
- super(`Transfer amount must be positive for market: ${market}`);
334
- }
335
- }
336
386
  /**
337
387
  * Thrown when a market repay in assets mode has `transferAmount !== amount + nativeAmount` — the
338
388
  * pre-resolved ERC-20 pull plus the wrapped native must equal the assets repaid, so the bundle
@@ -343,44 +393,12 @@ export class TransferAmountNotEqualToAssetsError extends Error {
343
393
  super(`Transfer amount ${params.transferAmount} is not equal to repay assets ${params.assets} for market: ${params.market}. In assets mode, transferAmount must equal amount + nativeAmount.`);
344
394
  }
345
395
  }
346
- /**
347
- * Thrown when a shares-mode repay's `nativeAmount` exceeds `transferAmount`, which
348
- * would make the ERC-20 amount to pull (`transferAmount − nativeAmount`) negative.
349
- *
350
- * @deprecated No longer thrown. A shares-mode repay now accepts a `nativeAmount` that
351
- * covers (or exceeds) the full repaid assets: it wraps the native, pulls no ERC-20, and
352
- * the bundle skims the residual wNative back to the receiver. This class is retained for
353
- * one minor for API stability and will be removed in the next major.
354
- */
355
- export class NativeAmountExceedsTransferAmountError extends Error {
356
- constructor(params) {
357
- super(`Native amount ${params.nativeAmount} exceeds transfer amount ${params.transferAmount} for market: ${params.market}. Reduce nativeAmount to at most transferAmount.`);
358
- }
359
- }
360
396
  /** Thrown when a market repay specifies both `assets` and `shares` as non-zero (modes are mutually exclusive). */
361
397
  export class MutuallyExclusiveRepayAmountsError extends Error {
362
398
  constructor(market) {
363
399
  super(`Exactly one of assets or shares must be non-zero for market: ${market}. Both were provided.`);
364
400
  }
365
401
  }
366
- /** Thrown when a market repay has non-positive amounts: both `assets` and `shares` are zero, or either is negative. */
367
- export class NonPositiveRepayAmountError extends Error {
368
- constructor(market) {
369
- super(`Repay amount must be positive for market: ${market}`);
370
- }
371
- }
372
- /** Thrown when a market repay's `maxSharePrice` slippage bound is zero or negative. */
373
- export class NonPositiveRepayMaxSharePriceError extends Error {
374
- constructor(market) {
375
- super(`Max share price must be positive for market: ${market}`);
376
- }
377
- }
378
- /** Thrown when a market `withdrawCollateral` amount is zero or negative. */
379
- export class NonPositiveWithdrawCollateralAmountError extends Error {
380
- constructor(market) {
381
- super(`Withdraw collateral amount must be positive for market: ${market}`);
382
- }
383
- }
384
402
  /** Thrown when a withdraw amount exceeds the position's available collateral. */
385
403
  export class WithdrawExceedsCollateralError extends Error {
386
404
  constructor(params) {
@@ -497,40 +515,118 @@ export class UnknownReallocationPositionError extends UnknownDataError {
497
515
  this.marketId = marketId;
498
516
  }
499
517
  }
500
- /** Thrown when a market borrow's `minSharePrice` slippage bound is negative. */
501
- export class NonPositiveMinBorrowSharePriceError extends Error {
502
- constructor(market) {
503
- super(`Min share price must be non-negative for market: ${market}`);
518
+ /** Thrown when a Midnight amount exceeds the maximum offer-cap value accepted onchain. */
519
+ export class MidnightAmountExceedsMaxOfferCapError extends Error {
520
+ constructor(params) {
521
+ super(`Midnight ${params.label} "${params.amount}" exceeds maximum offer cap "${params.maxOfferCap}". Reduce the amount to the maximum offer cap or less.`);
504
522
  }
505
523
  }
506
- /** Thrown when a market loan-asset supply amount is negative. */
507
- export class NegativeSupplyAmountError extends Error {
508
- constructor(market) {
509
- super(`Supply amount must be non-negative for market: ${market}`);
524
+ /** Thrown when a Midnight flow needs at least one takeable offer. */
525
+ export class EmptyMidnightTakeableOffersError extends Error {
526
+ constructor() {
527
+ super("Midnight takeable offers cannot be empty. Refresh the quote and try again.");
510
528
  }
511
529
  }
512
- /** Thrown when a market loan-asset supply's `maxSharePrice` slippage bound is negative. */
513
- export class NegativeSupplyMaxSharePriceError extends Error {
514
- constructor(market) {
515
- super(`Max share price must be non-negative for market: ${market}`);
530
+ /** Thrown when a Midnight offer has the wrong maker side for the requested flow. */
531
+ export class MidnightOfferSideMismatchError extends Error {
532
+ constructor(params) {
533
+ super(`Midnight offer "${params.index}" has buy="${params.actualBuy}", expected "${params.expectedBuy}". Use the matching flow or rebuild the offer list.`);
516
534
  }
517
535
  }
518
- /** Thrown when both `amount` and `nativeAmount` resolve to zero on a market loan-asset supply. */
519
- export class ZeroSupplyAmountError extends Error {
520
- constructor(market) {
521
- super(`Total supply amount must be positive for market: ${market}. Both amount and nativeAmount are zero.`);
536
+ /** Thrown when a Midnight maker offer belongs to a different account than the action flow. */
537
+ export class MidnightOfferMakerMismatchError extends Error {
538
+ constructor(params) {
539
+ super(`Midnight offer "${params.index}" belongs to maker "${params.actualMaker}", expected "${params.expectedMaker}". Rebuild the offer set for the active account.`);
522
540
  }
523
541
  }
524
- /** Thrown when a market loan-asset withdraw has both `assets` and `shares` zero, or either negative. */
525
- export class NonPositiveWithdrawAmountError extends Error {
526
- constructor(market) {
527
- super(`Withdraw amount must be positive for market: ${market}`);
542
+ /** Thrown when a Midnight maker offer targets a different chain than the action flow. */
543
+ export class MidnightOfferMarketChainMismatchError extends Error {
544
+ constructor(params) {
545
+ super(`Midnight offer "${params.index}" targets chain "${params.actualChainId}", expected "${params.expectedChainId}". Rebuild the offer set for the selected chain.`);
546
+ }
547
+ }
548
+ /** Thrown when a Midnight maker offer targets a different Midnight contract than the action flow. */
549
+ export class MidnightOfferMarketAddressMismatchError extends Error {
550
+ constructor(params) {
551
+ super(`Midnight offer "${params.index}" targets Midnight "${params.actualMidnight}", expected "${params.expectedMidnight}". Rebuild the offer set for the selected chain.`);
552
+ }
553
+ }
554
+ /** Thrown when a Midnight market targets a different deployment than the selected chain. */
555
+ export class MidnightMarketAddressMismatchError extends Error {
556
+ constructor(params) {
557
+ super(`Midnight market targets contract "${params.actualMidnight}", expected "${params.expectedMidnight}". Use market data from the selected chain deployment.`);
558
+ }
559
+ }
560
+ /** Thrown when a Midnight make-lend offer does not use the approved loan token. */
561
+ export class MidnightOfferMarketLoanTokenMismatchError extends Error {
562
+ constructor(params) {
563
+ super(`Midnight offer "${params.index}" uses loan token "${params.actualLoanToken}", expected "${params.expectedLoanToken}". Rebuild the lend offer set for the approved loan token.`);
564
+ }
565
+ }
566
+ /** Thrown when a quoted Midnight takeable offer belongs to a different market than the requested flow. */
567
+ export class MidnightTakeableOfferMarketMismatchError extends Error {
568
+ constructor(params) {
569
+ super(`Midnight takeable offer "${params.index}" belongs to market "${params.actualMarket}", expected "${params.expectedMarket}". Refresh the quote and try again.`);
570
+ }
571
+ }
572
+ /** Thrown when a Midnight offer tree uses an unsupported ratifier address. */
573
+ export class UnknownMidnightRatifierError extends Error {
574
+ constructor(params) {
575
+ super(`Midnight offer tree uses ratifier "${params.ratifier}", expected "${params.ecrecoverRatifier}" or "${params.setterRatifier}". Rebuild the tree with a supported ratifier.`);
528
576
  }
529
577
  }
530
- /** Thrown when a market loan-asset withdraw's `minSharePrice` slippage bound is negative. */
531
- export class NegativeWithdrawMinSharePriceError extends Error {
578
+ /** Thrown when a Midnight Ecrecover maker flow builds the submit transaction before signing. */
579
+ export class MissingMidnightOfferRootSignatureError extends Error {
580
+ constructor() {
581
+ super("Midnight offer root signature is missing. Sign the offer-root requirement before building the submit transaction.");
582
+ }
583
+ }
584
+ /** Thrown when a Midnight offer-root signature does not match the prepared tree root. */
585
+ export class MidnightOfferRootMismatchError extends Error {
586
+ constructor(params) {
587
+ super(`Midnight offer root mismatch: expected "${params.expectedRoot}", got "${params.actualRoot}". Rebuild the flow and sign again.`);
588
+ }
589
+ }
590
+ /** Thrown when a Midnight offer-root signature was produced by another maker account. */
591
+ export class MidnightOfferRootOwnerMismatchError extends Error {
592
+ constructor(params) {
593
+ super(`Midnight offer root owner mismatch: expected "${params.expectedOwner}", got "${params.actualOwner}". Rebuild the flow and sign again.`);
594
+ }
595
+ }
596
+ /** Thrown when a Midnight offer-root signature targets another ratifier. */
597
+ export class MidnightOfferRootRatifierMismatchError extends Error {
598
+ constructor(params) {
599
+ super(`Midnight offer root ratifier mismatch: expected "${params.expectedRatifier}", got "${params.actualRatifier}". Rebuild the flow and sign again.`);
600
+ }
601
+ }
602
+ /** Thrown when a Midnight offer-root signature was produced for another offer count. */
603
+ export class MidnightOfferRootOfferCountMismatchError extends Error {
604
+ constructor(params) {
605
+ super(`Midnight offer root offer-count mismatch: expected "${params.expectedOffers}", got "${params.actualOffers}". Rebuild the flow and sign again.`);
606
+ }
607
+ }
608
+ /** Thrown when a Midnight offer-root signature was not prepared by this maker flow. */
609
+ export class UnpreparedMidnightOfferRootSignatureError extends Error {
610
+ constructor() {
611
+ super("Midnight offer root signature was not prepared for this offer tree. Sign this flow's offer-root requirement before building the submit transaction.");
612
+ }
613
+ }
614
+ /** Thrown when a Midnight redeem flow finds no credit units for the user. */
615
+ export class NoMidnightCreditToRedeemError extends Error {
532
616
  constructor(market) {
533
- super(`Min share price must be non-negative for market: ${market}`);
617
+ super(`No Midnight credit is available to redeem for market "${market}".`);
618
+ }
619
+ }
620
+ /** Thrown when a Midnight redeem amount exceeds the user's accrued credit. */
621
+ export class MidnightRedeemExceedsCreditError extends Error {
622
+ constructor(params) {
623
+ super(`Midnight redeem amount exceeds position credit on market "${params.market}": units "${params.units}", credit "${params.credit}". Redeem less or refresh the position data.`);
624
+ }
625
+ }
626
+ /** Thrown when a Midnight redeem amount exceeds the market's currently withdrawable liquidity. */
627
+ export class InsufficientMidnightWithdrawableLiquidityError extends Error {
628
+ constructor(params) {
629
+ super(`Midnight withdrawable liquidity is insufficient on market "${params.market}": units "${params.units}", withdrawable "${params.withdrawable}". Try again later or redeem less.`);
534
630
  }
535
631
  }
536
632
  /** Thrown when a loan-asset withdraw specifies both `assets` and `shares` as non-zero (modes are mutually exclusive). */
@@ -571,30 +667,12 @@ export class VaultAssetMismatchError extends Error {
571
667
  super(`Source vault asset ${sourceAsset} does not match target vault asset ${targetAsset}`);
572
668
  }
573
669
  }
574
- /** Thrown when a vault redeem's `minSharePrice` slippage bound is negative. */
575
- export class NegativeMinSharePriceError extends Error {
576
- constructor(vault) {
577
- super(`Min share price must be non-negative for vault: ${vault}`);
578
- }
579
- }
580
- /** Thrown when a refinance's `borrowShares` argument is negative. */
581
- export class NegativeBorrowSharesError extends Error {
582
- constructor(market) {
583
- super(`Borrow shares must be non-negative for market: ${market}`);
584
- }
585
- }
586
670
  /** Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive). */
587
671
  export class BorrowAmountAndSharesExclusiveError extends Error {
588
672
  constructor(market) {
589
673
  super(`Exactly one of borrowAssets or borrowShares must be non-zero for market: ${market}. Both were provided.`);
590
674
  }
591
675
  }
592
- /** Thrown when a refinance's `maxRepaySharePrice` slippage bound is negative. */
593
- export class NegativeMaxRepaySharePriceError extends Error {
594
- constructor(market) {
595
- super(`Max repay share price must be non-negative for market: ${market}`);
596
- }
597
- }
598
676
  /** Thrown when a refinance has identical source and target market ids (a refinance to the same market is a costly no-op). */
599
677
  export class RefinanceSameMarketError extends Error {
600
678
  constructor(market) {
@@ -1,6 +1,7 @@
1
1
  export type { CapacityLimit, RoundingDirection } from "@morpho-org/blue-sdk";
2
2
  export { AdaptiveCurveIrmLib, CapacityLimitReason, MarketUtils, MathLib, SharesMath, VaultUtils, } from "@morpho-org/blue-sdk";
3
3
  export { decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
4
+ export { EcrecoverRatifierUtils, GroupUtils, OfferUtils, Payload, RatifierUtils, SetterRatifierUtils, TakeAmountsLib, TickLib, TreeUtils, } from "@morpho-org/midnight-sdk";
4
5
  export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, WithId, WithIndex, } from "@morpho-org/morpho-ts";
5
6
  export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
6
7
  export { computeReallocations } from "./helpers/computeReallocations.js";
package/lib/esm/utils.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { AdaptiveCurveIrmLib, CapacityLimitReason, MarketUtils, MathLib, SharesMath, VaultUtils, } from "@morpho-org/blue-sdk";
2
2
  export { decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
3
+ export { EcrecoverRatifierUtils, GroupUtils, OfferUtils, Payload, RatifierUtils, SetterRatifierUtils, TakeAmountsLib, TickLib, TreeUtils, } from "@morpho-org/midnight-sdk";
3
4
  export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
4
5
  export { computeReallocations } from "./helpers/computeReallocations.js";
5
6
  export { addTransactionMetadata } from "./helpers/metadata.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/morpho-sdk",
3
3
  "description": "Abstraction layer for Morpho's complexity.",
4
- "version": "5.2.0",
4
+ "version": "5.3.1",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Foulks-Plb <https://x.com/FoulkPlb>"
@@ -75,6 +75,11 @@
75
75
  "import": "./lib/esm/format.js",
76
76
  "require": "./lib/cjs/format.js"
77
77
  },
78
+ "./midnight-api": {
79
+ "types": "./lib/esm/midnight-api.d.ts",
80
+ "import": "./lib/esm/midnight-api.js",
81
+ "require": "./lib/cjs/midnight-api.js"
82
+ },
78
83
  "./types": {
79
84
  "types": "./lib/esm/types.d.ts",
80
85
  "import": "./lib/esm/types.js",
@@ -118,6 +123,9 @@
118
123
  "format": [
119
124
  "lib/esm/format.d.ts"
120
125
  ],
126
+ "midnight-api": [
127
+ "lib/esm/midnight-api.d.ts"
128
+ ],
121
129
  "types": [
122
130
  "lib/esm/types.d.ts"
123
131
  ],
@@ -139,6 +147,7 @@
139
147
  "zod": "^4.4.3",
140
148
  "@morpho-org/blue-sdk": "^6.3.1",
141
149
  "@morpho-org/blue-sdk-viem": "^5.2.0",
150
+ "@morpho-org/midnight-sdk": "^1.2.0",
142
151
  "@morpho-org/morpho-ts": "^2.8.0"
143
152
  },
144
153
  "peerDependencies": {
@@ -152,7 +161,7 @@
152
161
  "vitest": "^4.1.9",
153
162
  "@morpho-org/bundler-sdk-viem": "^5.0.3",
154
163
  "@morpho-org/simulation-sdk": "^4.0.3",
155
- "@morpho-org/test": "^2.8.2"
164
+ "@morpho-org/test": "^2.8.3"
156
165
  },
157
166
  "scripts": {
158
167
  "prepublish": "$npm_execpath build",