@morpho-org/morpho-sdk 6.6.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/MIGRATION-v6-to-v7.md +291 -0
  2. package/README.md +26 -12
  3. package/lib/cjs/abis.d.ts +1 -1
  4. package/lib/cjs/abis.js +3 -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/constants.d.ts +1 -1
  40. package/lib/cjs/constants.js +2 -1
  41. package/lib/cjs/entities/index.d.ts +2 -2
  42. package/lib/cjs/entities/midnight/midnight.d.ts +582 -108
  43. package/lib/cjs/entities/midnight/midnight.js +981 -509
  44. package/lib/cjs/entities/midnight/types.d.ts +142 -60
  45. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +2 -1
  46. package/lib/cjs/entities/vaultV1/vaultV1.js +1 -0
  47. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +2 -1
  48. package/lib/cjs/entities/vaultV2/vaultV2.js +1 -0
  49. package/lib/cjs/helpers/callback.d.ts +54 -0
  50. package/lib/cjs/helpers/callback.js +73 -0
  51. package/lib/cjs/helpers/constant.d.ts +2 -0
  52. package/lib/cjs/helpers/constant.js +3 -1
  53. package/lib/cjs/helpers/index.d.ts +3 -2
  54. package/lib/cjs/helpers/index.js +6 -1
  55. package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +3 -3
  56. package/lib/cjs/helpers/signAndVerifyTypedData.js +3 -3
  57. package/lib/cjs/helpers/validate.d.ts +43 -2
  58. package/lib/cjs/helpers/validate.js +60 -3
  59. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
  60. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +3 -7
  61. package/lib/cjs/helpers/validateRequirementSpender.d.ts +3 -3
  62. package/lib/cjs/helpers/validateRequirementSpender.js +4 -5
  63. package/lib/cjs/midnight/abis.d.ts +1 -1
  64. package/lib/cjs/midnight/abis.js +3 -2
  65. package/lib/cjs/midnight/types.d.ts +1 -1
  66. package/lib/cjs/types/action.d.ts +117 -89
  67. package/lib/cjs/types/action.js +1 -19
  68. package/lib/cjs/types/error.d.ts +126 -40
  69. package/lib/cjs/types/error.js +154 -49
  70. package/lib/esm/abis.d.ts +1 -1
  71. package/lib/esm/abis.js +1 -1
  72. package/lib/esm/actions/bundles/common.d.ts +9 -5
  73. package/lib/esm/actions/bundles/common.js +22 -13
  74. package/lib/esm/actions/midnight/authorization.d.ts +3 -2
  75. package/lib/esm/actions/midnight/authorization.js +3 -2
  76. package/lib/esm/actions/midnight/cancelAndMake.d.ts +153 -0
  77. package/lib/esm/actions/midnight/cancelAndMake.js +288 -0
  78. package/lib/esm/actions/midnight/index.d.ts +3 -3
  79. package/lib/esm/actions/midnight/index.js +3 -3
  80. package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
  81. package/lib/esm/actions/midnight/repayWithdrawCollateral.js +108 -72
  82. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
  83. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +131 -74
  84. package/lib/esm/actions/midnight/takeBorrow.d.ts +40 -28
  85. package/lib/esm/actions/midnight/takeBorrow.js +98 -57
  86. package/lib/esm/actions/midnight/takeLend.d.ts +51 -27
  87. package/lib/esm/actions/midnight/takeLend.js +114 -57
  88. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
  89. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +197 -0
  90. package/lib/esm/actions/midnight/takeWithdraw.d.ts +69 -0
  91. package/lib/esm/actions/midnight/takeWithdraw.js +149 -0
  92. package/lib/esm/actions/midnight/types.d.ts +7 -26
  93. package/lib/esm/actions/midnight/types.js +1 -12
  94. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
  95. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +3 -2
  96. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
  97. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +5 -5
  98. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +2 -2
  99. package/lib/esm/actions/requirements/getRequirementsApproval.js +2 -2
  100. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
  101. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +25 -14
  102. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
  103. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
  104. package/lib/esm/actions/requirements/midnight/index.d.ts +0 -1
  105. package/lib/esm/actions/requirements/midnight/index.js +0 -1
  106. package/lib/esm/constants.d.ts +1 -1
  107. package/lib/esm/constants.js +1 -1
  108. package/lib/esm/entities/index.d.ts +2 -2
  109. package/lib/esm/entities/midnight/midnight.d.ts +582 -108
  110. package/lib/esm/entities/midnight/midnight.js +987 -515
  111. package/lib/esm/entities/midnight/types.d.ts +142 -60
  112. package/lib/esm/entities/vaultV1/vaultV1.d.ts +2 -1
  113. package/lib/esm/entities/vaultV1/vaultV1.js +1 -0
  114. package/lib/esm/entities/vaultV2/vaultV2.d.ts +2 -1
  115. package/lib/esm/entities/vaultV2/vaultV2.js +1 -0
  116. package/lib/esm/helpers/callback.d.ts +54 -0
  117. package/lib/esm/helpers/callback.js +68 -0
  118. package/lib/esm/helpers/constant.d.ts +2 -0
  119. package/lib/esm/helpers/constant.js +2 -0
  120. package/lib/esm/helpers/index.d.ts +3 -2
  121. package/lib/esm/helpers/index.js +3 -2
  122. package/lib/esm/helpers/signAndVerifyTypedData.d.ts +3 -3
  123. package/lib/esm/helpers/signAndVerifyTypedData.js +3 -3
  124. package/lib/esm/helpers/validate.d.ts +43 -2
  125. package/lib/esm/helpers/validate.js +58 -2
  126. package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
  127. package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +3 -7
  128. package/lib/esm/helpers/validateRequirementSpender.d.ts +3 -3
  129. package/lib/esm/helpers/validateRequirementSpender.js +4 -5
  130. package/lib/esm/midnight/abis.d.ts +1 -1
  131. package/lib/esm/midnight/abis.js +1 -1
  132. package/lib/esm/midnight/types.d.ts +1 -1
  133. package/lib/esm/types/action.d.ts +117 -89
  134. package/lib/esm/types/action.js +1 -18
  135. package/lib/esm/types/error.d.ts +126 -40
  136. package/lib/esm/types/error.js +135 -38
  137. package/package.json +8 -7
  138. package/lib/cjs/actions/midnight/cancelOffer.d.ts +0 -38
  139. package/lib/cjs/actions/midnight/cancelOffer.js +0 -73
  140. package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
  141. package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +0 -72
  142. package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
  143. package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.js +0 -59
  144. package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
  145. package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -70
  146. package/lib/esm/actions/midnight/cancelOffer.d.ts +0 -38
  147. package/lib/esm/actions/midnight/cancelOffer.js +0 -69
  148. package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
  149. package/lib/esm/actions/midnight/mempoolSubmitOffers.js +0 -68
  150. package/lib/esm/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
  151. package/lib/esm/actions/midnight/setterRatifierRatifyRoot.js +0 -55
  152. package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
  153. package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -66
@@ -6,7 +6,6 @@ exports.isRequirementSignature = isRequirementSignature;
6
6
  exports.isPermitSignature = isPermitSignature;
7
7
  exports.isPermit2SignatureTransferSignature = isPermit2SignatureTransferSignature;
8
8
  exports.isAuthorizationSignature = isAuthorizationSignature;
9
- exports.isMidnightOfferRootSignature = isMidnightOfferRootSignature;
10
9
  exports.selectRequirementSignatures = selectRequirementSignatures;
11
10
  const error_js_1 = require("./error.js");
12
11
  function isRequirementApproval(requirement) {
@@ -88,15 +87,6 @@ function isPermit2SignatureTransferSignature(signature) {
88
87
  function isAuthorizationSignature(signature) {
89
88
  return signature.action.type === "authorization";
90
89
  }
91
- /**
92
- * Narrows a {@link RequirementSignature} to a Midnight offer-root signature.
93
- *
94
- * @param signature - The signed requirement to test.
95
- * @returns `true` when `signature.action.type` is `"midnightOfferRootSignature"`.
96
- */
97
- function isMidnightOfferRootSignature(signature) {
98
- return signature.action.type === "midnightOfferRootSignature";
99
- }
100
90
  /**
101
91
  * Splits a `buildTx` signature array into its typed requirement-signature slots, rejecting
102
92
  * ambiguous or unexpected input so a path never silently consumes the wrong signature.
@@ -111,7 +101,6 @@ function isMidnightOfferRootSignature(signature) {
111
101
  * @param accepts.permit - Whether an ERC-2612 signature is consumed.
112
102
  * @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
113
103
  * @param accepts.authorization - Whether a Morpho authorization signature is consumed.
114
- * @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
115
104
  * @returns The accepted signature in each typed slot, when present.
116
105
  * @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
117
106
  * @throws {UnsupportedRequirementSignatureError} when a signature has an unsupported action type.
@@ -132,11 +121,9 @@ function selectRequirementSignatures(signatures, accepts) {
132
121
  const permits = signatures.filter(isPermitSignature);
133
122
  const permit2Transfers = signatures.filter(isPermit2SignatureTransferSignature);
134
123
  const authorizations = signatures.filter(isAuthorizationSignature);
135
- const midnightOfferRoots = signatures.filter(isMidnightOfferRootSignature);
136
124
  const unsupported = signatures.find((signature) => !isPermitSignature(signature) &&
137
125
  !isPermit2SignatureTransferSignature(signature) &&
138
- !isAuthorizationSignature(signature) &&
139
- !isMidnightOfferRootSignature(signature));
126
+ !isAuthorizationSignature(signature));
140
127
  if (unsupported != null)
141
128
  throw new error_js_1.UnsupportedRequirementSignatureError(unsupported.action.type);
142
129
  if (!accepts.permit && permits.length > 0)
@@ -145,20 +132,15 @@ function selectRequirementSignatures(signatures, accepts) {
145
132
  throw new error_js_1.UnexpectedRequirementSignatureError("permit2SignatureTransfer");
146
133
  if (!accepts.authorization && authorizations.length > 0)
147
134
  throw new error_js_1.UnexpectedRequirementSignatureError("authorization");
148
- if (!accepts.midnightOfferRoot && midnightOfferRoots.length > 0)
149
- throw new error_js_1.UnexpectedRequirementSignatureError("midnightOfferRootSignature");
150
135
  if (permits.length > 1)
151
136
  throw new error_js_1.AmbiguousRequirementSignaturesError("permit", permits.length);
152
137
  if (permit2Transfers.length > 1)
153
138
  throw new error_js_1.AmbiguousRequirementSignaturesError("permit2SignatureTransfer", permit2Transfers.length);
154
139
  if (authorizations.length > 1)
155
140
  throw new error_js_1.AmbiguousRequirementSignaturesError("authorization", authorizations.length);
156
- if (midnightOfferRoots.length > 1)
157
- throw new error_js_1.AmbiguousRequirementSignaturesError("midnightOfferRootSignature", midnightOfferRoots.length);
158
141
  return {
159
142
  permit: permits[0],
160
143
  permit2SignatureTransfer: permit2Transfers[0],
161
144
  authorization: authorizations[0],
162
- midnightOfferRoot: midnightOfferRoots[0],
163
145
  };
164
146
  }
@@ -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
+ }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DepositOwnerMismatchError = exports.DepositAssetMismatchError = exports.DepositAmountMismatchError = exports.EmptyDeallocationsError = exports.ExcessiveSlippageToleranceError = exports.MissingAccrualPositionError = exports.UnsupportedMidnightAuthorizationTargetError = exports.UnsupportedErc20ApprovalSpenderError = exports.ApprovalAmountLessThanSpendAmountError = exports.MissingClientPropertyError = exports.CryptoUnavailableError = exports.ChainIdMismatchError = exports.AddressMismatchError = exports.UnsupportedRequirementSignatureError = exports.UnexpectedRequirementSignatureError = exports.AmbiguousRequirementSignaturesError = exports.MaxRepayAssetsBelowRepayAssetsError = exports.ReallocationsRequireBorrowError = exports.UnsupportedAuthorizationOperatorError = exports.ReallocationLoanTokenMismatchError = exports.SameVaultMigrationError = exports.AmountAndSharesExclusiveError = exports.MixedBundlesFundingError = exports.ReferralFeePctExceededError = exports.ReferralFeeRecipientMissingError = exports.NativeFundingAmountMismatchError = exports.NoUnusedPermit2NonceError = exports.Permit2SignatureTransferNonceAlreadyUsedError = exports.BundlesRequirementSignatureMismatchError = exports.BundlesPermitMismatchError = exports.VaultIsBlueFeeRecipientError = exports.VaultMorphoMismatchError = exports.InsufficientBlueBalanceForInKindRedeemError = exports.InKindRedeemCoverageError = exports.InKindRedeemZeroDeallocationError = exports.VaultV2ForceWithdrawFeeSharesExceedBurnError = exports.VaultV2ForceWithdrawSharePriceBelowFloorError = exports.VaultV2ForceWithdrawZeroSharePriceError = exports.VaultV2ForceWithdrawZeroWithdrawalError = exports.VaultV2ForceWithdrawCoverageError = exports.VaultV2UndecodableLiquidityDataError = exports.VaultV2UnsupportedLiquidityAdapterError = exports.VaultV2UnsupportedExitAdapterError = exports.AdapterNotPartOfVaultError = exports.VaultV2SingleAdapterRequiredError = exports.ExpiredDeadlineError = exports.EmptyMarketParamsListError = exports.InputExceedsMaxError = exports.NonPositiveInputError = exports.NegativeInputError = void 0;
4
- exports.MutuallyExclusiveWithdrawAmountsError = exports.InsufficientMidnightWithdrawableLiquidityError = exports.MidnightRedeemExceedsCreditError = exports.NoMidnightCreditToRedeemError = exports.UnpreparedMidnightOfferRootSignatureError = exports.MidnightOfferRootOfferCountMismatchError = exports.MidnightOfferRootRatifierMismatchError = exports.MidnightOfferRootOwnerMismatchError = exports.MidnightOfferRootMismatchError = exports.MissingMidnightOfferRootSignatureError = exports.UnknownMidnightRatifierError = exports.MidnightTakeableOfferMarketMismatchError = exports.MidnightOfferMarketLoanTokenMismatchError = exports.MidnightMarketAddressMismatchError = exports.MidnightOfferMarketAddressMismatchError = exports.MidnightOfferMarketChainMismatchError = exports.MidnightOfferMakerMismatchError = exports.MidnightOfferSideMismatchError = exports.EmptyMidnightTakeableOffersError = exports.MidnightAmountExceedsMaxOfferCapError = exports.ReallocationAdapterSupplySharesUnderflowError = exports.ReallocationAllocationUnderflowError = exports.UnknownReallocationAdapterError = exports.UnknownReallocationMarketPublicAllocatorConfigError = exports.UnknownReallocationActiveAdaptersError = exports.UnknownReallocationPublicAllocatorConfigError = exports.UnknownReallocationAllocationError = exports.UnknownReallocationVaultError = exports.UnknownReallocationMarketError = exports.InsufficientSharedLiquidityError = exports.RepaySharesExceedDebtError = exports.InvalidSignatureError = exports.RepayExceedsDebtError = exports.WithdrawMakesPositionUnhealthyError = exports.WithdrawExceedsCollateralError = exports.MutuallyExclusiveRepayAmountsError = exports.InconsistentReallocationPenaltyError = exports.InvalidReallocationSourceTypeError = exports.InvalidReallocationAddressError = exports.InvalidVaultV2BlueReallocationShapeError = exports.ReallocationWithdrawalOnTargetMarketError = exports.AccrualPositionUserMismatchError = exports.MarketIdMismatchError = exports.MissingMarketPriceError = exports.BorrowExceedsSafeLtvError = exports.NativeAmountOnNonWNativeAssetError = exports.VaultAddressMismatchError = exports.ChainWNativeMissingError = exports.NativeAmountOnNonWNativeVaultError = exports.DepositSpenderMismatchError = void 0;
5
- exports.RefinanceTokenMismatchError = exports.RefinanceSameMarketError = exports.VaultAssetMismatchError = exports.ReallocationWithdrawExceedsMarketSupplyError = exports.WithdrawSharesExceedSupplyError = exports.WithdrawExceedsSupplyError = void 0;
4
+ exports.ZeroBlueParkingSharesError = exports.EmptyBlueParkingMarketError = exports.MidnightOfferCallbackDataMismatchError = exports.MidnightOfferCallbackMismatchError = exports.MidnightOfferMarketLoanTokenMismatchError = exports.MidnightMarketAddressMismatchError = exports.MidnightOfferMarketAddressMismatchError = exports.MidnightOfferMarketChainMismatchError = exports.MidnightTakeDeadlineTooFarError = exports.MidnightZeroReceiverError = exports.UnboundedMidnightTakeInputError = exports.MidnightOfferSellerReceiverMismatchError = exports.MidnightOfferContinuousFeeCapError = exports.MidnightOfferMakerMismatchError = exports.MidnightOfferReduceOnlyError = exports.MidnightOfferSideMismatchError = exports.EmptyMidnightTakeableOffersError = exports.DuplicateMidnightGroupCancellationError = exports.EmptyMidnightCollateralSuppliesError = exports.EmptyMidnightGroupCancellationsError = exports.ReallocationAdapterSupplySharesUnderflowError = exports.ReallocationAllocationUnderflowError = exports.UnknownReallocationAdapterError = exports.UnknownReallocationMarketPublicAllocatorConfigError = exports.UnknownReallocationActiveAdaptersError = exports.UnknownReallocationPublicAllocatorConfigError = exports.UnknownReallocationAllocationError = exports.UnknownReallocationVaultError = exports.UnknownReallocationMarketError = exports.InsufficientSharedLiquidityError = exports.RepaySharesExceedDebtError = exports.InvalidSignatureError = exports.RepayExceedsDebtError = exports.WithdrawMakesPositionUnhealthyError = exports.WithdrawExceedsCollateralError = exports.MutuallyExclusiveRepayAmountsError = exports.InconsistentReallocationPenaltyError = exports.InvalidReallocationSourceTypeError = exports.InvalidReallocationAddressError = exports.InvalidVaultV2BlueReallocationShapeError = exports.ReallocationWithdrawalOnTargetMarketError = exports.AccrualPositionUserMismatchError = exports.MarketIdMismatchError = exports.MissingMarketPriceError = exports.BorrowExceedsSafeLtvError = exports.NativeAmountOnNonWNativeAssetError = exports.VaultAddressMismatchError = exports.ChainWNativeMissingError = exports.NativeAmountOnNonWNativeVaultError = exports.DepositSpenderMismatchError = void 0;
5
+ exports.MidnightOfferNotReduceOnlyError = exports.RefinanceTokenMismatchError = exports.RefinanceSameMarketError = exports.VaultAssetMismatchError = exports.ReallocationWithdrawExceedsMarketSupplyError = exports.WithdrawSharesExceedSupplyError = exports.WithdrawExceedsSupplyError = exports.MutuallyExclusiveWithdrawAmountsError = exports.InsufficientMidnightWithdrawableLiquidityError = exports.MidnightRedeemExceedsCreditError = exports.NoMidnightCreditToRedeemError = exports.MidnightReplacementGroupCancelledError = exports.MidnightOfferRatifierMismatchError = exports.MidnightTakeableOfferMarketMismatchError = void 0;
6
6
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
7
7
  /**
8
8
  * Thrown when a morpho-sdk input that must be non-negative is negative.
@@ -584,7 +584,8 @@ class BundlesPermitMismatchError extends Error {
584
584
  /**
585
585
  * @param params - Permit mismatch values used to explain the rejection.
586
586
  * @param params.field - Permit field that does not match the exit.
587
- * @param params.expected - Value required by the exit.
587
+ * @param params.expected - Value required by the exit. For `field: "amount"` on an
588
+ * operation that accepts a range of permit amounts, an inclusive `"[min, max]"` range.
588
589
  * @param params.actual - Value supplied by the signature.
589
590
  * @param params.cause - Original parser failure when signature decoding is wrapped.
590
591
  */
@@ -883,18 +884,14 @@ exports.ApprovalAmountLessThanSpendAmountError = ApprovalAmountLessThanSpendAmou
883
884
  /** Thrown when a requirement encoder targets an unsupported spender. */
884
885
  class UnsupportedErc20ApprovalSpenderError extends Error {
885
886
  constructor(params) {
886
- const supported = (params.supportedSpenders ?? [
887
- params.permit2,
888
- params.midnight,
889
- params.midnightBundles,
890
- ])
887
+ const supported = (params.supportedSpenders ?? [params.permit2, params.midnight])
891
888
  .filter((address) => address != null)
892
889
  .join('", "');
893
890
  super(`Requirement spender "${params.spender}" is not supported on chain "${params.chainId}". Use "${supported}".`);
894
891
  }
895
892
  }
896
893
  exports.UnsupportedErc20ApprovalSpenderError = UnsupportedErc20ApprovalSpenderError;
897
- /** Thrown when a Midnight authorization requirement targets an unsupported operator. */
894
+ /** Thrown when a Midnight authorization target (a requirement operator, or the ratifier that `midnightCancelAndMake` activates and MidnightBundlesV2 authorizes) is not registered for the chain. */
898
895
  class UnsupportedMidnightAuthorizationTargetError extends Error {
899
896
  constructor(params) {
900
897
  super(`Midnight authorization target "${params.authorized}" is not supported on chain "${params.chainId}". Use "${params.supportedTargets.join('", "')}".`);
@@ -1294,13 +1291,27 @@ class ReallocationAdapterSupplySharesUnderflowError extends Error {
1294
1291
  }
1295
1292
  }
1296
1293
  exports.ReallocationAdapterSupplySharesUnderflowError = ReallocationAdapterSupplySharesUnderflowError;
1297
- /** Thrown when a Midnight amount exceeds the maximum offer-cap value accepted onchain. */
1298
- class MidnightAmountExceedsMaxOfferCapError extends Error {
1294
+ /** Thrown when a Midnight batch cancellation has no offer groups. */
1295
+ class EmptyMidnightGroupCancellationsError extends Error {
1296
+ constructor() {
1297
+ super("Midnight group cancellations cannot be empty. Pass at least one offer group to cancel.");
1298
+ }
1299
+ }
1300
+ exports.EmptyMidnightGroupCancellationsError = EmptyMidnightGroupCancellationsError;
1301
+ /** Thrown when a Midnight flow passes a collateral market with no collateral supplies. */
1302
+ class EmptyMidnightCollateralSuppliesError extends Error {
1303
+ constructor() {
1304
+ super("Midnight collateral supplies cannot be empty. Pass at least one collateral supply, or use `makeBorrow` to publish without collateral.");
1305
+ }
1306
+ }
1307
+ exports.EmptyMidnightCollateralSuppliesError = EmptyMidnightCollateralSuppliesError;
1308
+ /** Thrown when a Midnight batch cancellation lists the same offer group twice. */
1309
+ class DuplicateMidnightGroupCancellationError extends Error {
1299
1310
  constructor(params) {
1300
- super(`Midnight ${params.label} "${params.amount}" exceeds maximum offer cap "${params.maxOfferCap}". Reduce the amount to the maximum offer cap or less.`);
1311
+ super(`Midnight group cancellation "${params.index}" repeats group "${params.group}". Pass each offer group once.`);
1301
1312
  }
1302
1313
  }
1303
- exports.MidnightAmountExceedsMaxOfferCapError = MidnightAmountExceedsMaxOfferCapError;
1314
+ exports.DuplicateMidnightGroupCancellationError = DuplicateMidnightGroupCancellationError;
1304
1315
  /** Thrown when a Midnight flow needs at least one takeable offer. */
1305
1316
  class EmptyMidnightTakeableOffersError extends Error {
1306
1317
  constructor() {
@@ -1315,6 +1326,13 @@ class MidnightOfferSideMismatchError extends Error {
1315
1326
  }
1316
1327
  }
1317
1328
  exports.MidnightOfferSideMismatchError = MidnightOfferSideMismatchError;
1329
+ /** Thrown when a Midnight maker method that is not a limit exit receives a reduce-only offer. */
1330
+ class MidnightOfferReduceOnlyError extends Error {
1331
+ constructor(params) {
1332
+ super(`Midnight offer "${params.index}" is reduce-only. Rebuild the offer with reduceOnly=false; reduce-only exits need a dedicated exit flow.`);
1333
+ }
1334
+ }
1335
+ exports.MidnightOfferReduceOnlyError = MidnightOfferReduceOnlyError;
1318
1336
  /** Thrown when a Midnight maker offer belongs to a different account than the action flow. */
1319
1337
  class MidnightOfferMakerMismatchError extends Error {
1320
1338
  constructor(params) {
@@ -1322,6 +1340,93 @@ class MidnightOfferMakerMismatchError extends Error {
1322
1340
  }
1323
1341
  }
1324
1342
  exports.MidnightOfferMakerMismatchError = MidnightOfferMakerMismatchError;
1343
+ /** Thrown when a Midnight maker offer sets a nonzero continuous fee cap. */
1344
+ class MidnightOfferContinuousFeeCapError extends Error {
1345
+ /** Offer index in the maker tree. */
1346
+ index;
1347
+ /** Continuous fee cap supplied on the offer. */
1348
+ continuousFeeCap;
1349
+ /**
1350
+ * @param params - Offer index and rejected fee cap.
1351
+ * @param params.index - Offer index in the maker tree.
1352
+ * @param params.continuousFeeCap - Continuous fee cap supplied on the offer.
1353
+ */
1354
+ constructor(params) {
1355
+ super(`Midnight offer "${params.index}" has continuous fee cap "${params.continuousFeeCap}". Maker offers must use 0n; rebuild the offer with its fee cap set to zero.`);
1356
+ this.index = params.index;
1357
+ this.continuousFeeCap = params.continuousFeeCap;
1358
+ this.name = "MidnightOfferContinuousFeeCapError";
1359
+ }
1360
+ }
1361
+ exports.MidnightOfferContinuousFeeCapError = MidnightOfferContinuousFeeCapError;
1362
+ /** Thrown when a Midnight sell offer routes its seller proceeds to another address. */
1363
+ class MidnightOfferSellerReceiverMismatchError extends Error {
1364
+ /** Offer index in the maker tree. */
1365
+ index;
1366
+ /** Offer maker, which must receive seller proceeds. */
1367
+ expectedReceiver;
1368
+ /** Seller receiver supplied on the offer. */
1369
+ actualReceiver;
1370
+ /**
1371
+ * @param params - Offer index and expected and actual seller receivers.
1372
+ * @param params.index - Offer index in the maker tree.
1373
+ * @param params.expectedReceiver - Offer maker, which must receive seller proceeds.
1374
+ * @param params.actualReceiver - Seller receiver supplied on the offer.
1375
+ */
1376
+ constructor(params) {
1377
+ super(`Midnight sell offer "${params.index}" routes seller proceeds to "${params.actualReceiver}", expected its maker "${params.expectedReceiver}". Set receiverIfMakerIsSeller to the maker address.`);
1378
+ this.index = params.index;
1379
+ this.expectedReceiver = params.expectedReceiver;
1380
+ this.actualReceiver = params.actualReceiver;
1381
+ this.name = "MidnightOfferSellerReceiverMismatchError";
1382
+ }
1383
+ }
1384
+ exports.MidnightOfferSellerReceiverMismatchError = MidnightOfferSellerReceiverMismatchError;
1385
+ /** Thrown when a Midnight taker flow uses an unbounded target or deadline. */
1386
+ class UnboundedMidnightTakeInputError extends Error {
1387
+ field;
1388
+ /**
1389
+ * @param field - Target or deadline input set to `maxUint256`.
1390
+ */
1391
+ constructor(field) {
1392
+ super(`Midnight "${field}" cannot be maxUint256. Provide an explicit bounded value.`);
1393
+ this.field = field;
1394
+ this.name = "UnboundedMidnightTakeInputError";
1395
+ }
1396
+ }
1397
+ exports.UnboundedMidnightTakeInputError = UnboundedMidnightTakeInputError;
1398
+ /** Thrown when a Midnight taker flow uses a zero address as its receiver. */
1399
+ class MidnightZeroReceiverError extends Error {
1400
+ field;
1401
+ /**
1402
+ * @param field - Receiver field containing the zero address.
1403
+ */
1404
+ constructor(field) {
1405
+ super(`Midnight "${field}" cannot be the zero address. Provide a valid recipient.`);
1406
+ this.field = field;
1407
+ this.name = "MidnightZeroReceiverError";
1408
+ }
1409
+ }
1410
+ exports.MidnightZeroReceiverError = MidnightZeroReceiverError;
1411
+ /** Thrown when a Midnight take deadline is more than one hour from the current time. */
1412
+ class MidnightTakeDeadlineTooFarError extends Error {
1413
+ /** Deadline supplied by the caller. */
1414
+ deadline;
1415
+ /** Accepted maximum deadline. */
1416
+ maxDeadline;
1417
+ /**
1418
+ * @param params - Supplied deadline and accepted maximum.
1419
+ * @param params.deadline - Deadline supplied by the caller.
1420
+ * @param params.maxDeadline - Latest accepted deadline.
1421
+ */
1422
+ constructor(params) {
1423
+ super(`Midnight take deadline "${params.deadline}" is later than the one-hour limit "${params.maxDeadline}". Choose a deadline within the next hour.`);
1424
+ this.deadline = params.deadline;
1425
+ this.maxDeadline = params.maxDeadline;
1426
+ this.name = "MidnightTakeDeadlineTooFarError";
1427
+ }
1428
+ }
1429
+ exports.MidnightTakeDeadlineTooFarError = MidnightTakeDeadlineTooFarError;
1325
1430
  /** Thrown when a Midnight maker offer targets a different chain than the action flow. */
1326
1431
  class MidnightOfferMarketChainMismatchError extends Error {
1327
1432
  constructor(params) {
@@ -1350,62 +1455,55 @@ class MidnightOfferMarketLoanTokenMismatchError extends Error {
1350
1455
  }
1351
1456
  }
1352
1457
  exports.MidnightOfferMarketLoanTokenMismatchError = MidnightOfferMarketLoanTokenMismatchError;
1353
- /** Thrown when a quoted Midnight takeable offer belongs to a different market than the requested flow. */
1354
- class MidnightTakeableOfferMarketMismatchError extends Error {
1458
+ /** Thrown when a Blue-funded Midnight lend offer does not use the maker's derived `BlueBuyCallback`. */
1459
+ class MidnightOfferCallbackMismatchError extends Error {
1355
1460
  constructor(params) {
1356
- super(`Midnight takeable offer "${params.index}" belongs to market "${params.actualMarket}", expected "${params.expectedMarket}". Refresh the quote and try again.`);
1461
+ super(`Midnight offer "${params.index}" uses callback "${params.actualCallback}", expected the maker's BlueBuyCallback "${params.expectedCallback}". Rebuild the offer with the derived callback.`);
1357
1462
  }
1358
1463
  }
1359
- exports.MidnightTakeableOfferMarketMismatchError = MidnightTakeableOfferMarketMismatchError;
1360
- /** Thrown when a Midnight offer tree uses an unsupported ratifier address. */
1361
- class UnknownMidnightRatifierError extends Error {
1464
+ exports.MidnightOfferCallbackMismatchError = MidnightOfferCallbackMismatchError;
1465
+ /** Thrown when a Blue-funded Midnight lend offer's callback data is not the ABI-encoded Blue market. */
1466
+ class MidnightOfferCallbackDataMismatchError extends Error {
1362
1467
  constructor(params) {
1363
- super(`Midnight offer tree uses ratifier "${params.ratifier}", expected "${params.ecrecoverRatifier}" or "${params.setterRatifier}". Rebuild the tree with a supported ratifier.`);
1364
- }
1365
- }
1366
- exports.UnknownMidnightRatifierError = UnknownMidnightRatifierError;
1367
- /** Thrown when a Midnight Ecrecover maker flow builds the submit transaction before signing. */
1368
- class MissingMidnightOfferRootSignatureError extends Error {
1369
- constructor() {
1370
- super("Midnight offer root signature is missing. Sign the offer-root requirement before building the submit transaction.");
1468
+ super(`Midnight offer "${params.index}" uses callback data "${params.actualCallbackData}", expected "${params.expectedCallbackData}". Set the callback data to the ABI-encoded Blue market the assets are parked in.`);
1371
1469
  }
1372
1470
  }
1373
- exports.MissingMidnightOfferRootSignatureError = MissingMidnightOfferRootSignatureError;
1374
- /** Thrown when a Midnight offer-root signature does not match the prepared tree root. */
1375
- class MidnightOfferRootMismatchError extends Error {
1471
+ exports.MidnightOfferCallbackDataMismatchError = MidnightOfferCallbackDataMismatchError;
1472
+ /** Thrown when loan assets would be parked in a Morpho Blue market with no existing supply. */
1473
+ class EmptyBlueParkingMarketError extends Error {
1376
1474
  constructor(params) {
1377
- super(`Midnight offer root mismatch: expected "${params.expectedRoot}", got "${params.actualRoot}". Rebuild the flow and sign again.`);
1475
+ super(`Morpho Blue market "${params.marketId}" has no supply shares. Parking assets in an empty market is exposed to supply-share-price inflation; choose a market with existing supply.`);
1378
1476
  }
1379
1477
  }
1380
- exports.MidnightOfferRootMismatchError = MidnightOfferRootMismatchError;
1381
- /** Thrown when a Midnight offer-root signature was produced by another maker account. */
1382
- class MidnightOfferRootOwnerMismatchError extends Error {
1478
+ exports.EmptyBlueParkingMarketError = EmptyBlueParkingMarketError;
1479
+ /** Thrown when parked assets would mint no Morpho Blue supply shares. */
1480
+ class ZeroBlueParkingSharesError extends Error {
1383
1481
  constructor(params) {
1384
- super(`Midnight offer root owner mismatch: expected "${params.expectedOwner}", got "${params.actualOwner}". Rebuild the flow and sign again.`);
1482
+ super(`Supplying "${params.assets}" assets to Morpho Blue market "${params.marketId}" mints zero supply shares at its current share price; park more assets or choose another market.`);
1385
1483
  }
1386
1484
  }
1387
- exports.MidnightOfferRootOwnerMismatchError = MidnightOfferRootOwnerMismatchError;
1388
- /** Thrown when a Midnight offer-root signature targets another ratifier. */
1389
- class MidnightOfferRootRatifierMismatchError extends Error {
1485
+ exports.ZeroBlueParkingSharesError = ZeroBlueParkingSharesError;
1486
+ /** Thrown when a quoted Midnight takeable offer belongs to a different market than the requested flow. */
1487
+ class MidnightTakeableOfferMarketMismatchError extends Error {
1390
1488
  constructor(params) {
1391
- super(`Midnight offer root ratifier mismatch: expected "${params.expectedRatifier}", got "${params.actualRatifier}". Rebuild the flow and sign again.`);
1489
+ super(`Midnight takeable offer "${params.index}" belongs to market "${params.actualMarket}", expected "${params.expectedMarket}". Refresh the quote and try again.`);
1392
1490
  }
1393
1491
  }
1394
- exports.MidnightOfferRootRatifierMismatchError = MidnightOfferRootRatifierMismatchError;
1395
- /** Thrown when a Midnight offer-root signature was produced for another offer count. */
1396
- class MidnightOfferRootOfferCountMismatchError extends Error {
1492
+ exports.MidnightTakeableOfferMarketMismatchError = MidnightTakeableOfferMarketMismatchError;
1493
+ /** Thrown when a Midnight offer's ratifier does not match its tree's ratifier route. */
1494
+ class MidnightOfferRatifierMismatchError extends Error {
1397
1495
  constructor(params) {
1398
- super(`Midnight offer root offer-count mismatch: expected "${params.expectedOffers}", got "${params.actualOffers}". Rebuild the flow and sign again.`);
1496
+ super(`Midnight offer "${params.index}" uses ratifier "${params.actualRatifier}", expected "${params.expectedRatifier}" for its tree type. Rebuild the offer with the tree's ratifier.`);
1399
1497
  }
1400
1498
  }
1401
- exports.MidnightOfferRootOfferCountMismatchError = MidnightOfferRootOfferCountMismatchError;
1402
- /** Thrown when a Midnight offer-root signature carries no encoded payload. */
1403
- class UnpreparedMidnightOfferRootSignatureError extends Error {
1404
- constructor() {
1405
- super("Midnight offer root signature carries no encoded payload. Sign the offer-root requirement (its signature already includes the payload) before building the submit transaction.");
1499
+ exports.MidnightOfferRatifierMismatchError = MidnightOfferRatifierMismatchError;
1500
+ /** Thrown when a Midnight repost cancels a group it also publishes. */
1501
+ class MidnightReplacementGroupCancelledError extends Error {
1502
+ constructor(params) {
1503
+ super(`Midnight offer group "${params.group}" is both published and cancelled. Give replacement offers a fresh group.`);
1406
1504
  }
1407
1505
  }
1408
- exports.UnpreparedMidnightOfferRootSignatureError = UnpreparedMidnightOfferRootSignatureError;
1506
+ exports.MidnightReplacementGroupCancelledError = MidnightReplacementGroupCancelledError;
1409
1507
  /** Thrown when a Midnight redeem flow finds no credit units for the user. */
1410
1508
  class NoMidnightCreditToRedeemError extends Error {
1411
1509
  constructor(market) {
@@ -1484,3 +1582,10 @@ class RefinanceTokenMismatchError extends Error {
1484
1582
  }
1485
1583
  }
1486
1584
  exports.RefinanceTokenMismatchError = RefinanceTokenMismatchError;
1585
+ /** Thrown when a maker limit-exit offer can increase or open a position. */
1586
+ class MidnightOfferNotReduceOnlyError extends Error {
1587
+ constructor(params) {
1588
+ super(`Midnight exit offer "${params.index}" must have reduceOnly=true. Rebuild the offer tree for the exit intent.`);
1589
+ }
1590
+ }
1591
+ exports.MidnightOfferNotReduceOnlyError = MidnightOfferNotReduceOnlyError;
package/lib/esm/abis.d.ts CHANGED
@@ -4,7 +4,7 @@ export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi,
4
4
  preLiquidationAbi as bluePreLiquidationAbi,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
6
6
  preLiquidationFactoryAbi as bluePreLiquidationFactoryAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
7
- export { ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
7
+ export { blueBuyCallbackFactoryAbi as midnightBlueBuyCallbackFactoryAbi, ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
8
8
  /** ABI for the VaultExitBundlesV1 periphery contract. */
9
9
  export declare const vaultExitBundlesV1Abi: readonly [{
10
10
  readonly type: "constructor";
package/lib/esm/abis.js CHANGED
@@ -4,7 +4,7 @@ export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi,
4
4
  preLiquidationAbi as bluePreLiquidationAbi,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
6
6
  preLiquidationFactoryAbi as bluePreLiquidationFactoryAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
7
- export { ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
7
+ export { blueBuyCallbackFactoryAbi as midnightBlueBuyCallbackFactoryAbi, ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
8
8
  /** ABI for the VaultExitBundlesV1 periphery contract. */
9
9
  export const vaultExitBundlesV1Abi = [
10
10
  {