@morpho-org/morpho-sdk 10.3.0 → 10.4.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 (188) hide show
  1. package/README.md +172 -8
  2. package/lib/cjs/actions/midnight/redeem.d.ts +20 -3
  3. package/lib/cjs/actions/midnight/redeem.js +58 -1
  4. package/lib/cjs/actions/midnight/supplyCollateralWithNative.d.ts +24 -1
  5. package/lib/cjs/actions/midnight/supplyCollateralWithNative.js +41 -0
  6. package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +16 -2
  7. package/lib/cjs/actions/midnight/withdrawCollateral.js +26 -1
  8. package/lib/cjs/helpers/callback.d.ts +3 -2
  9. package/lib/cjs/helpers/callback.js +4 -20
  10. package/lib/cjs/helpers/computeMidnightPostWithdrawalCollateral.d.ts +17 -0
  11. package/lib/cjs/helpers/computeMidnightPostWithdrawalCollateral.js +30 -0
  12. package/lib/cjs/helpers/parseMidnightMaker.d.ts +21 -0
  13. package/lib/cjs/helpers/parseMidnightMaker.js +41 -1
  14. package/lib/cjs/helpers/validate.d.ts +49 -1
  15. package/lib/cjs/helpers/validate.js +87 -1
  16. package/lib/cjs/helpers/validateMidnightPublication.d.ts +10 -0
  17. package/lib/cjs/helpers/validateMidnightPublication.js +18 -1
  18. package/lib/cjs/helpers/validateMidnightTakeableOfferFields.d.ts +28 -0
  19. package/lib/cjs/helpers/validateMidnightTakeableOfferFields.js +85 -0
  20. package/lib/cjs/index.d.ts +2 -2
  21. package/lib/cjs/index.js +23 -1
  22. package/lib/cjs/midnight/utils.d.ts +1 -1
  23. package/lib/cjs/midnight/utils.js +2 -1
  24. package/lib/cjs/transactionPlan/blue/withdrawBuyCallback.d.ts +101 -0
  25. package/lib/cjs/transactionPlan/blue/withdrawBuyCallback.js +264 -0
  26. package/lib/cjs/transactionPlan/error.d.ts +27 -0
  27. package/lib/cjs/transactionPlan/error.js +30 -1
  28. package/lib/cjs/transactionPlan/index.d.ts +40 -1
  29. package/lib/cjs/transactionPlan/index.js +46 -5
  30. package/lib/cjs/transactionPlan/midnight/authorization.d.ts +15 -0
  31. package/lib/cjs/transactionPlan/midnight/authorization.js +45 -0
  32. package/lib/cjs/transactionPlan/midnight/cancelOffers.d.ts +80 -0
  33. package/lib/cjs/transactionPlan/midnight/cancelOffers.js +125 -0
  34. package/lib/cjs/transactionPlan/midnight/makeBorrow.d.ts +104 -0
  35. package/lib/cjs/transactionPlan/midnight/makeBorrow.js +126 -0
  36. package/lib/cjs/transactionPlan/midnight/makeLend.d.ts +140 -0
  37. package/lib/cjs/transactionPlan/midnight/makeLend.js +176 -0
  38. package/lib/cjs/transactionPlan/midnight/makeRepay.d.ts +118 -0
  39. package/lib/cjs/transactionPlan/midnight/makeRepay.js +118 -0
  40. package/lib/cjs/transactionPlan/midnight/makeWithdraw.d.ts +104 -0
  41. package/lib/cjs/transactionPlan/midnight/makeWithdraw.js +126 -0
  42. package/lib/cjs/transactionPlan/midnight/makerPublication.d.ts +55 -0
  43. package/lib/cjs/transactionPlan/midnight/makerPublication.js +315 -0
  44. package/lib/cjs/transactionPlan/midnight/market.d.ts +49 -0
  45. package/lib/cjs/transactionPlan/midnight/market.js +120 -0
  46. package/lib/cjs/transactionPlan/midnight/prepare.d.ts +244 -0
  47. package/lib/cjs/transactionPlan/midnight/prepare.js +547 -0
  48. package/lib/cjs/transactionPlan/midnight/publicationState.d.ts +24 -0
  49. package/lib/cjs/transactionPlan/midnight/publicationState.js +50 -0
  50. package/lib/cjs/transactionPlan/midnight/redeem.d.ts +102 -0
  51. package/lib/cjs/transactionPlan/midnight/redeem.js +170 -0
  52. package/lib/cjs/transactionPlan/midnight/reduceOnlySellFeasibility.d.ts +25 -0
  53. package/lib/cjs/transactionPlan/midnight/reduceOnlySellFeasibility.js +51 -0
  54. package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.d.ts +162 -0
  55. package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.js +328 -0
  56. package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.d.ts +155 -0
  57. package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.js +199 -0
  58. package/lib/cjs/transactionPlan/midnight/supplyCollateral.d.ts +96 -0
  59. package/lib/cjs/transactionPlan/midnight/supplyCollateral.js +190 -0
  60. package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.d.ts +112 -0
  61. package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.js +221 -0
  62. package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +129 -0
  63. package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.js +179 -0
  64. package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.d.ts +115 -0
  65. package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.js +259 -0
  66. package/lib/cjs/transactionPlan/midnight/takeBorrow.d.ts +304 -0
  67. package/lib/cjs/transactionPlan/midnight/takeBorrow.js +545 -0
  68. package/lib/cjs/transactionPlan/midnight/takeLend.d.ts +99 -0
  69. package/lib/cjs/transactionPlan/midnight/takeLend.js +263 -0
  70. package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +175 -0
  71. package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.js +440 -0
  72. package/lib/cjs/transactionPlan/midnight/takeWithdraw.d.ts +139 -0
  73. package/lib/cjs/transactionPlan/midnight/takeWithdraw.js +240 -0
  74. package/lib/cjs/transactionPlan/midnight/validation.d.ts +22 -0
  75. package/lib/cjs/transactionPlan/midnight/validation.js +158 -0
  76. package/lib/cjs/transactionPlan/midnight/withdrawCollateral.d.ts +130 -0
  77. package/lib/cjs/transactionPlan/midnight/withdrawCollateral.js +228 -0
  78. package/lib/cjs/transactionPlan/midnight/withdrawCollateralBatch.d.ts +142 -0
  79. package/lib/cjs/transactionPlan/midnight/withdrawCollateralBatch.js +232 -0
  80. package/lib/cjs/transactionPlan/plan.d.ts +48 -14
  81. package/lib/cjs/transactionPlan/plan.js +103 -18
  82. package/lib/cjs/transactionPlan/requirements.d.ts +7 -4
  83. package/lib/cjs/transactionPlan/requirements.js +2 -2
  84. package/lib/cjs/transactionPlan/serde.d.ts +13 -2
  85. package/lib/cjs/transactionPlan/serde.js +68 -21
  86. package/lib/cjs/transactionPlan/types.d.ts +147 -0
  87. package/lib/cjs/transactionPlan/validateActions.d.ts +3 -1
  88. package/lib/cjs/transactionPlan/validateActions.js +31 -3
  89. package/lib/cjs/transactionPlan/validation.d.ts +1 -1
  90. package/lib/cjs/transactionPlan/validation.js +37 -1
  91. package/lib/cjs/types/error.d.ts +2 -0
  92. package/lib/cjs/types/error.js +2 -0
  93. package/lib/cjs/version.d.ts +1 -1
  94. package/lib/cjs/version.js +1 -1
  95. package/lib/esm/actions/midnight/redeem.d.ts +20 -3
  96. package/lib/esm/actions/midnight/redeem.js +56 -0
  97. package/lib/esm/actions/midnight/supplyCollateralWithNative.d.ts +24 -1
  98. package/lib/esm/actions/midnight/supplyCollateralWithNative.js +40 -0
  99. package/lib/esm/actions/midnight/withdrawCollateral.d.ts +16 -2
  100. package/lib/esm/actions/midnight/withdrawCollateral.js +25 -1
  101. package/lib/esm/helpers/callback.d.ts +3 -2
  102. package/lib/esm/helpers/callback.js +5 -21
  103. package/lib/esm/helpers/computeMidnightPostWithdrawalCollateral.d.ts +17 -0
  104. package/lib/esm/helpers/computeMidnightPostWithdrawalCollateral.js +27 -0
  105. package/lib/esm/helpers/parseMidnightMaker.d.ts +21 -0
  106. package/lib/esm/helpers/parseMidnightMaker.js +40 -1
  107. package/lib/esm/helpers/validate.d.ts +49 -1
  108. package/lib/esm/helpers/validate.js +84 -1
  109. package/lib/esm/helpers/validateMidnightPublication.d.ts +10 -0
  110. package/lib/esm/helpers/validateMidnightPublication.js +16 -0
  111. package/lib/esm/helpers/validateMidnightTakeableOfferFields.d.ts +28 -0
  112. package/lib/esm/helpers/validateMidnightTakeableOfferFields.js +81 -0
  113. package/lib/esm/index.d.ts +2 -2
  114. package/lib/esm/index.js +1 -1
  115. package/lib/esm/midnight/utils.d.ts +1 -1
  116. package/lib/esm/midnight/utils.js +1 -1
  117. package/lib/esm/transactionPlan/blue/withdrawBuyCallback.d.ts +101 -0
  118. package/lib/esm/transactionPlan/blue/withdrawBuyCallback.js +259 -0
  119. package/lib/esm/transactionPlan/error.d.ts +27 -0
  120. package/lib/esm/transactionPlan/error.js +28 -0
  121. package/lib/esm/transactionPlan/index.d.ts +40 -1
  122. package/lib/esm/transactionPlan/index.js +20 -1
  123. package/lib/esm/transactionPlan/midnight/authorization.d.ts +15 -0
  124. package/lib/esm/transactionPlan/midnight/authorization.js +40 -0
  125. package/lib/esm/transactionPlan/midnight/cancelOffers.d.ts +80 -0
  126. package/lib/esm/transactionPlan/midnight/cancelOffers.js +120 -0
  127. package/lib/esm/transactionPlan/midnight/makeBorrow.d.ts +104 -0
  128. package/lib/esm/transactionPlan/midnight/makeBorrow.js +123 -0
  129. package/lib/esm/transactionPlan/midnight/makeLend.d.ts +140 -0
  130. package/lib/esm/transactionPlan/midnight/makeLend.js +172 -0
  131. package/lib/esm/transactionPlan/midnight/makeRepay.d.ts +118 -0
  132. package/lib/esm/transactionPlan/midnight/makeRepay.js +115 -0
  133. package/lib/esm/transactionPlan/midnight/makeWithdraw.d.ts +104 -0
  134. package/lib/esm/transactionPlan/midnight/makeWithdraw.js +123 -0
  135. package/lib/esm/transactionPlan/midnight/makerPublication.d.ts +55 -0
  136. package/lib/esm/transactionPlan/midnight/makerPublication.js +310 -0
  137. package/lib/esm/transactionPlan/midnight/market.d.ts +49 -0
  138. package/lib/esm/transactionPlan/midnight/market.js +112 -0
  139. package/lib/esm/transactionPlan/midnight/prepare.d.ts +244 -0
  140. package/lib/esm/transactionPlan/midnight/prepare.js +536 -0
  141. package/lib/esm/transactionPlan/midnight/publicationState.d.ts +24 -0
  142. package/lib/esm/transactionPlan/midnight/publicationState.js +47 -0
  143. package/lib/esm/transactionPlan/midnight/redeem.d.ts +102 -0
  144. package/lib/esm/transactionPlan/midnight/redeem.js +165 -0
  145. package/lib/esm/transactionPlan/midnight/reduceOnlySellFeasibility.d.ts +25 -0
  146. package/lib/esm/transactionPlan/midnight/reduceOnlySellFeasibility.js +47 -0
  147. package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.d.ts +162 -0
  148. package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.js +323 -0
  149. package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.d.ts +155 -0
  150. package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.js +196 -0
  151. package/lib/esm/transactionPlan/midnight/supplyCollateral.d.ts +96 -0
  152. package/lib/esm/transactionPlan/midnight/supplyCollateral.js +185 -0
  153. package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.d.ts +112 -0
  154. package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.js +216 -0
  155. package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +129 -0
  156. package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.js +176 -0
  157. package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.d.ts +115 -0
  158. package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.js +254 -0
  159. package/lib/esm/transactionPlan/midnight/takeBorrow.d.ts +304 -0
  160. package/lib/esm/transactionPlan/midnight/takeBorrow.js +539 -0
  161. package/lib/esm/transactionPlan/midnight/takeLend.d.ts +99 -0
  162. package/lib/esm/transactionPlan/midnight/takeLend.js +258 -0
  163. package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +175 -0
  164. package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.js +435 -0
  165. package/lib/esm/transactionPlan/midnight/takeWithdraw.d.ts +139 -0
  166. package/lib/esm/transactionPlan/midnight/takeWithdraw.js +236 -0
  167. package/lib/esm/transactionPlan/midnight/validation.d.ts +22 -0
  168. package/lib/esm/transactionPlan/midnight/validation.js +151 -0
  169. package/lib/esm/transactionPlan/midnight/withdrawCollateral.d.ts +130 -0
  170. package/lib/esm/transactionPlan/midnight/withdrawCollateral.js +223 -0
  171. package/lib/esm/transactionPlan/midnight/withdrawCollateralBatch.d.ts +142 -0
  172. package/lib/esm/transactionPlan/midnight/withdrawCollateralBatch.js +227 -0
  173. package/lib/esm/transactionPlan/plan.d.ts +48 -14
  174. package/lib/esm/transactionPlan/plan.js +99 -14
  175. package/lib/esm/transactionPlan/requirements.d.ts +7 -4
  176. package/lib/esm/transactionPlan/requirements.js +2 -2
  177. package/lib/esm/transactionPlan/serde.d.ts +13 -2
  178. package/lib/esm/transactionPlan/serde.js +49 -2
  179. package/lib/esm/transactionPlan/types.d.ts +147 -0
  180. package/lib/esm/transactionPlan/validateActions.d.ts +3 -1
  181. package/lib/esm/transactionPlan/validateActions.js +31 -3
  182. package/lib/esm/transactionPlan/validation.d.ts +1 -1
  183. package/lib/esm/transactionPlan/validation.js +38 -2
  184. package/lib/esm/types/error.d.ts +2 -0
  185. package/lib/esm/types/error.js +2 -0
  186. package/lib/esm/version.d.ts +1 -1
  187. package/lib/esm/version.js +1 -1
  188. package/package.json +4 -4
@@ -69,16 +69,24 @@ export declare function getPendingSignatureRequests(plan: TransactionPlan): read
69
69
  * @param plan - Plan supplying referenced signature requests and the calldata origin; chain and account come from the action inputs.
70
70
  * @param step - Recipe to encode; missing signatures on unrelated supported steps do not block it.
71
71
  * @returns A frozen `{ to, data, value, action }`, ready to simulate or submit. `data` ends with the plan's `calldataOrigin` when one was set.
72
- * @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent.
73
- * @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
72
+ * @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent, a Midnight repayment type is unsupported, a Midnight market lists its collateral out of ascending token order, a Midnight single-collateral step has no bigint `collateralIndex`, or a Midnight collateral batch's list is not an array or holds a non-object entry (path under `$.inputs`).
73
+ * @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty, or a Midnight collateral batch entry's `collateralIndex` or `assets`, is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
74
74
  * @throws {InvalidSignatureError} If a stored signature has high s, cannot recover a public key or does not match the request owner.
75
75
  * @throws {UnsupportedTransactionPlanVersionError} If the plan version is unsupported.
76
76
  * @throws {UnsupportedTransactionPlanActionError} If any plan step or the selected step names an unsupported action type.
77
77
  * @throws {UnsupportedErc20ApprovalSpenderError} If an approval names an unregistered spender.
78
78
  * @throws {SameVaultMigrationError} If a migration's source and destination vaults are identical.
79
79
  * @throws {AmountAndSharesExclusiveError} If a migration supplies both `assets` and `shares`, or neither.
80
- * @throws {NonPositiveInputError} If a deposit, withdrawal or migration amount, a deposit or migration destination share-price bound, a Blue collateral amount, a deadline, force-redeem shares or deallocation amount is not positive.
80
+ * @throws {NonPositiveInputError} If a deposit, withdrawal or migration amount, a deposit or migration destination share-price bound, a collateral amount, Midnight redeem units, a deadline, force-redeem shares or deallocation amount is not positive, or a Midnight repayment step has a nonpositive full repayment cap or neither repays nor withdraws.
81
81
  * @throws {MarketIdMismatchError} If a Blue collateral step's market ID doesn't match its market parameters.
82
+ * @throws {MidnightMarketAddressMismatchError} If a Midnight collateral, redeem or repayment step's market targets another Midnight deployment.
83
+ * @throws {ChainIdMismatchError} If a Midnight redeem or repayment step's market targets another chain.
84
+ * @throws {MidnightZeroOnBehalfError} If a Midnight redeem, `midnightWithdrawCollateral`, `midnightWithdrawCollateralBatch` or `midnightSupplyCollateralWithNative` step names the zero address as its account.
85
+ * @throws {MidnightZeroReceiverError} If a Midnight redeem, `midnightWithdrawCollateral` or `midnightWithdrawCollateralBatch` step, or a `midnightRepayWithdrawCollateral` step that withdraws collateral, names the zero address as its receiver.
86
+ * @throws {MidnightContractReceiverError} If a Midnight redeem, `midnightWithdrawCollateral` or `midnightWithdrawCollateralBatch` step, or a `midnightRepayWithdrawCollateral` step that withdraws collateral, names a blocked protocol or token contract as its receiver.
87
+ * @throws {MidnightCalldataEncodingError} If the market tuple or withdrawal arguments cannot be encoded for a Midnight redeem step, or a Midnight repayment step has malformed addresses or other unencodable inputs.
88
+ * @throws {InvalidMarketParameterError} If a Midnight collateral, redeem, take or repayment step has an invalid market configuration.
89
+ * @throws {UnknownCollateralIndexError} If a Midnight collateral or repayment step targets an index not configured on its market.
82
90
  * @throws {NativeAmountOnNonWNativeAssetError} If a native-funded Blue collateral step targets a token other than wNative.
83
91
  * @throws {ChainWNativeMissingError} If a native-funded Blue collateral step targets a chain without registered wNative.
84
92
  * @throws {EmptyDeallocationsError} If a force-redeem step has no deallocations.
@@ -90,8 +98,10 @@ export declare function getPendingSignatureRequests(plan: TransactionPlan): read
90
98
  * @throws {TransactionPlanSignatureMismatchError} If a referenced request disagrees with the step's action or its encoding arguments.
91
99
  * @throws {BundlesPermitMismatchError} If a stored signature cannot be parsed or a signed permit's encoding arguments do not match the step.
92
100
  * @throws {MarketIdMismatchError} If a Blue market ID differs from its parameter tuple.
93
- * @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative.
94
- * @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), or withdrawal-only funding is nonzero.
101
+ * @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative, or a Midnight repayment's exact asset amount or native funding is negative.
102
+ * @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), withdrawal-only funding is nonzero, Midnight redeem units exceed uint128, or a Midnight batch collateral supply amount exceeds uint128.
103
+ * For `midnightRepayWithdrawCollateral`, if `repay.assets` or `repay.maxBuyerAssets` is at least `maxUint256`,
104
+ * a withdrawal amount or deadline exceeds uint256, or native funding exceeds the repayment pull.
95
105
  * @throws {MutuallyExclusiveRepayAmountsError} If a Blue repayment specifies both nonzero assets and shares.
96
106
  * @throws {MaxRepayAssetsBelowRepayAssetsError} If exact-asset funding cannot cover repayment plus referral fees.
97
107
  * @throws {NativeFundingAmountMismatchError} If Blue native funding does not equal the full repayment cap.
@@ -104,8 +114,15 @@ export declare function getPendingSignatureRequests(plan: TransactionPlan): read
104
114
  * @throws {DepositSpenderMismatchError} If a token signature names another spender.
105
115
  * @throws {UnsupportedRequirementSignatureError} If a token signature has an unsupported action type.
106
116
  * @throws {BundlesRequirementSignatureMismatchError} If a Blue signature cannot be bound or parsed safely.
107
- * @throws {UnsupportedChainIdError} If a Blue action's chain is absent from the registry.
108
- * @throws {UnknownAddressError} If BlueBundlesV1 is not registered on the action's chain.
117
+ * @throws {UnsupportedChainIdError} If a Blue or Midnight action's chain is absent from the registry.
118
+ * @throws {UnknownAddressError} If BlueBundlesV1, Midnight core, or MidnightBundlesV2 for a Midnight repayment step is not registered on the action's chain.
119
+ * @throws {EmptyMidnightGroupCancellationsError} If a Midnight cancellation lists no groups.
120
+ * @throws {InvalidMidnightHexInputError} If a Midnight cancellation group is not 32 bytes.
121
+ * @throws {DuplicateMidnightGroupCancellationError} If a Midnight cancellation lists a group twice.
122
+ * @throws {EmptyMidnightCollateralWithdrawalsError} If a Midnight batch collateral withdrawal lists no withdrawals.
123
+ * @throws {EmptyMidnightCollateralSuppliesError} If a Midnight batch collateral supply lists no supplies.
124
+ * @throws {DuplicateMidnightCollateralIndexError} If a Midnight batch collateral supply or withdrawal repeats a collateral index.
125
+ * @throws {MidnightZeroOnBehalfError} If a Midnight cancellation's account is the zero address.
109
126
  * @example
110
127
  * ```ts
111
128
  * import { buildTransaction, parseTransactionPlan } from "@morpho-org/morpho-sdk";
@@ -121,16 +138,23 @@ export declare function buildTransaction(plan: TransactionPlan, step: Step): Rea
121
138
  * Builds every step of the plan in order.
122
139
  * @param plan - Plan whose referenced signature requests all carry a signature.
123
140
  * @returns Frozen SDK transactions in step order; discriminate on `action.type` for per-step handling.
124
- * @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent.
125
- * @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
141
+ * @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent, a Midnight repayment type is unsupported, a Midnight market lists its collateral out of ascending token order, a Midnight single-collateral step has no bigint `collateralIndex`, or a Midnight collateral batch's list is not an array or holds a non-object entry (path under `$.inputs`).
142
+ * @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty, or a Midnight collateral batch entry's `collateralIndex` or `assets`, is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
126
143
  * @throws {InvalidSignatureError} If a stored signature has high s, cannot recover a public key or does not match the request owner.
127
144
  * @throws {UnsupportedTransactionPlanVersionError} If the plan version is unsupported, including empty plans.
128
145
  * @throws {UnsupportedTransactionPlanActionError} If any plan step names an unsupported action type, before reading requests.
129
146
  * @throws {UnsupportedErc20ApprovalSpenderError} If an approval names an unregistered spender.
130
147
  * @throws {SameVaultMigrationError} If a migration's source and destination vaults are identical.
131
148
  * @throws {AmountAndSharesExclusiveError} If a migration supplies both `assets` and `shares`, or neither.
132
- * @throws {NonPositiveInputError} If a deposit, withdrawal or migration amount, a deposit or migration destination share-price bound, a Blue collateral amount, a deadline, force-redeem shares or deallocation amount is not positive.
149
+ * @throws {NonPositiveInputError} If a deposit, withdrawal or migration amount, a deposit or migration destination share-price bound, a collateral amount, Midnight redeem units, a deadline, force-redeem shares or deallocation amount is not positive, or a Midnight repayment step has a nonpositive full repayment cap or neither repays nor withdraws.
133
150
  * @throws {MarketIdMismatchError} If a Blue collateral step's market ID doesn't match its market parameters.
151
+ * @throws {MidnightMarketAddressMismatchError} If a Midnight collateral, redeem or repayment step's market targets another Midnight deployment.
152
+ * @throws {ChainIdMismatchError} If a Midnight redeem or repayment step's market targets another chain.
153
+ * @throws {MidnightZeroOnBehalfError} If a Midnight redeem, `midnightWithdrawCollateral`, `midnightWithdrawCollateralBatch` or `midnightSupplyCollateralWithNative` step names the zero address as its account.
154
+ * @throws {MidnightZeroReceiverError} If a Midnight redeem, `midnightWithdrawCollateral` or `midnightWithdrawCollateralBatch` step, or a `midnightRepayWithdrawCollateral` step that withdraws collateral, names the zero address as its receiver.
155
+ * @throws {MidnightContractReceiverError} If a Midnight redeem, `midnightWithdrawCollateral` or `midnightWithdrawCollateralBatch` step, or a `midnightRepayWithdrawCollateral` step that withdraws collateral, names a blocked protocol or token contract as its receiver.
156
+ * @throws {MidnightCalldataEncodingError} If the market tuple or withdrawal arguments cannot be encoded for a Midnight redeem step, or a Midnight repayment step has malformed addresses or other unencodable inputs.
157
+ * @throws {UnknownCollateralIndexError} If a Midnight collateral or repayment step targets an index not configured on its market.
134
158
  * @throws {NativeAmountOnNonWNativeAssetError} If a native-funded Blue collateral step targets a token other than wNative.
135
159
  * @throws {ChainWNativeMissingError} If a native-funded Blue collateral step targets a chain without registered wNative.
136
160
  * @throws {EmptyDeallocationsError} If a force-redeem step has no deallocations.
@@ -139,11 +163,14 @@ export declare function buildTransaction(plan: TransactionPlan, step: Step): Rea
139
163
  * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
140
164
  * @throws {ReferralFeeRecipientMissingError} If a positive referral fee has no nonzero recipient.
141
165
  * @throws {IncompleteTransactionPlanError} If any step references a signature request or signature that is missing.
166
+ * @throws {InvalidMarketParameterError} If a Midnight collateral, redeem, take or repayment step has an invalid market configuration.
142
167
  * @throws {TransactionPlanSignatureMismatchError} If a referenced request disagrees with its action or encoding arguments.
143
168
  * @throws {BundlesPermitMismatchError} If a stored signature cannot be parsed or a signed permit's encoding arguments do not match the step.
144
169
  * @throws {MarketIdMismatchError} If a Blue market ID differs from its parameter tuple.
145
- * @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative.
146
- * @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), or withdrawal-only funding is nonzero.
170
+ * @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative, or a Midnight repayment's exact asset amount or native funding is negative.
171
+ * @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), withdrawal-only funding is nonzero, Midnight redeem units exceed uint128, or a Midnight batch collateral supply amount exceeds uint128.
172
+ * For `midnightRepayWithdrawCollateral`, if `repay.assets` or `repay.maxBuyerAssets` is at least `maxUint256`,
173
+ * a withdrawal amount or deadline exceeds uint256, or native funding exceeds the repayment pull.
147
174
  * @throws {MutuallyExclusiveRepayAmountsError} If a Blue repayment specifies both nonzero assets and shares.
148
175
  * @throws {MaxRepayAssetsBelowRepayAssetsError} If exact-asset funding cannot cover repayment plus referral fees.
149
176
  * @throws {NativeFundingAmountMismatchError} If Blue native funding does not equal the full repayment cap.
@@ -156,8 +183,15 @@ export declare function buildTransaction(plan: TransactionPlan, step: Step): Rea
156
183
  * @throws {DepositSpenderMismatchError} If a token signature names another spender.
157
184
  * @throws {UnsupportedRequirementSignatureError} If a token signature has an unsupported action type.
158
185
  * @throws {BundlesRequirementSignatureMismatchError} If a Blue signature cannot be bound or parsed safely.
159
- * @throws {UnsupportedChainIdError} If a Blue action's chain is absent from the registry.
160
- * @throws {UnknownAddressError} If BlueBundlesV1 is not registered on the action's chain.
186
+ * @throws {UnsupportedChainIdError} If a Blue or Midnight action's chain is absent from the registry.
187
+ * @throws {UnknownAddressError} If BlueBundlesV1, Midnight core, or MidnightBundlesV2 for a Midnight repayment step is not registered on the action's chain.
188
+ * @throws {EmptyMidnightGroupCancellationsError} If a Midnight cancellation lists no groups.
189
+ * @throws {InvalidMidnightHexInputError} If a Midnight cancellation group is not 32 bytes.
190
+ * @throws {DuplicateMidnightGroupCancellationError} If a Midnight cancellation lists a group twice.
191
+ * @throws {EmptyMidnightCollateralWithdrawalsError} If a Midnight batch collateral withdrawal lists no withdrawals.
192
+ * @throws {EmptyMidnightCollateralSuppliesError} If a Midnight batch collateral supply lists no supplies.
193
+ * @throws {DuplicateMidnightCollateralIndexError} If a Midnight batch collateral supply or withdrawal repeats a collateral index.
194
+ * @throws {MidnightZeroOnBehalfError} If a Midnight cancellation's account is the zero address.
161
195
  * @example
162
196
  * ```ts
163
197
  * import { buildTransactions, type TransactionPlan } from "@morpho-org/morpho-sdk";
@@ -21,21 +21,36 @@ const supply_js_1 = require("./blue/supply.js");
21
21
  const supplyCollateral_js_1 = require("./blue/supplyCollateral.js");
22
22
  const supplyCollateralBorrow_js_1 = require("./blue/supplyCollateralBorrow.js");
23
23
  const withdraw_js_1 = require("./blue/withdraw.js");
24
+ const withdrawBuyCallback_js_1 = require("./blue/withdrawBuyCallback.js");
24
25
  const withdrawCollateral_js_1 = require("./blue/withdrawCollateral.js");
25
26
  const error_js_2 = require("./error.js");
27
+ const authorization_js_2 = require("./midnight/authorization.js");
28
+ const cancelOffers_js_1 = require("./midnight/cancelOffers.js");
29
+ const makerPublication_js_1 = require("./midnight/makerPublication.js");
30
+ const redeem_js_1 = require("./midnight/redeem.js");
31
+ const repayWithdrawCollateral_js_2 = require("./midnight/repayWithdrawCollateral.js");
32
+ const supplyCollateral_js_2 = require("./midnight/supplyCollateral.js");
33
+ const supplyCollateralBatch_js_1 = require("./midnight/supplyCollateralBatch.js");
34
+ const supplyCollateralWithNative_js_1 = require("./midnight/supplyCollateralWithNative.js");
35
+ const takeBorrow_js_1 = require("./midnight/takeBorrow.js");
36
+ const takeLend_js_1 = require("./midnight/takeLend.js");
37
+ const takeRepayWithdrawCollateral_js_1 = require("./midnight/takeRepayWithdrawCollateral.js");
38
+ const takeWithdraw_js_1 = require("./midnight/takeWithdraw.js");
39
+ const withdrawCollateral_js_2 = require("./midnight/withdrawCollateral.js");
40
+ const withdrawCollateralBatch_js_1 = require("./midnight/withdrawCollateralBatch.js");
26
41
  const permit_js_1 = require("./permit.js");
27
42
  const validateActions_js_1 = require("./validateActions.js");
28
43
  const validation_js_1 = require("./validation.js");
29
44
  const deposit_js_1 = require("./vaultv1/deposit.js");
30
45
  const inKindRedeem_js_1 = require("./vaultv1/inKindRedeem.js");
31
46
  const migrateToV2_js_1 = require("./vaultv1/migrateToV2.js");
32
- const redeem_js_1 = require("./vaultv1/redeem.js");
47
+ const redeem_js_2 = require("./vaultv1/redeem.js");
33
48
  const withdraw_js_2 = require("./vaultv1/withdraw.js");
34
49
  const deposit_js_2 = require("./vaultv2/deposit.js");
35
50
  const forceRedeem_js_1 = require("./vaultv2/forceRedeem.js");
36
51
  const forceWithdraw_js_1 = require("./vaultv2/forceWithdraw.js");
37
52
  const inKindRedeem_js_2 = require("./vaultv2/inKindRedeem.js");
38
- const redeem_js_2 = require("./vaultv2/redeem.js");
53
+ const redeem_js_3 = require("./vaultv2/redeem.js");
39
54
  const withdraw_js_3 = require("./vaultv2/withdraw.js");
40
55
  const version_js_1 = require("./version.js");
41
56
  /**
@@ -329,6 +344,8 @@ function encodeStep(action, requests) {
329
344
  return (0, withdraw_js_1.buildBlueWithdraw)(action, requests);
330
345
  case "blueWithdrawCollateral":
331
346
  return (0, withdrawCollateral_js_1.buildBlueWithdrawCollateral)(action, requests);
347
+ case "blueWithdrawBuyCallback":
348
+ return (0, withdrawBuyCallback_js_1.buildBlueWithdrawBuyCallback)(action);
332
349
  case "blueRepayWithdrawCollateral":
333
350
  return (0, repayWithdrawCollateral_js_1.buildBlueRepayWithdrawCollateral)(action, requests);
334
351
  case "blueRefinance":
@@ -342,18 +359,52 @@ function encodeStep(action, requests) {
342
359
  return (0, deposit_js_1.buildVaultV1Deposit)(action, requests);
343
360
  case "morphoAuthorization":
344
361
  return (0, authorization_js_1.buildMorphoAuthorization)(action);
362
+ case "midnightAuthorization":
363
+ return (0, authorization_js_2.buildMidnightAuthorization)(action);
364
+ case "midnightMakeBorrow":
365
+ case "midnightMakeLend":
366
+ case "midnightMakeRepay":
367
+ case "midnightMakeWithdraw":
368
+ case "midnightSupplyCollateralMakeBorrow":
369
+ case "midnightSupplyBlueMakeLend":
370
+ return (0, makerPublication_js_1.buildMidnightMakerPublication)(action);
371
+ case "midnightTakeBorrow":
372
+ case "midnightSupplyCollateralTakeBorrow":
373
+ return (0, takeBorrow_js_1.buildMidnightTakeBorrow)(action);
374
+ case "midnightTakeWithdraw":
375
+ return (0, takeWithdraw_js_1.buildMidnightTakeWithdraw)(action);
376
+ case "midnightRepayWithdrawCollateral":
377
+ return (0, repayWithdrawCollateral_js_2.buildMidnightRepayWithdrawCollateral)(action);
378
+ case "midnightTakeLend":
379
+ return (0, takeLend_js_1.buildMidnightTakeLend)(action);
380
+ case "midnightSupplyCollateral":
381
+ return (0, supplyCollateral_js_2.buildMidnightSupplyCollateral)(action);
382
+ case "midnightSupplyCollateralBatch":
383
+ return (0, supplyCollateralBatch_js_1.buildMidnightSupplyCollateralBatch)(action);
384
+ case "midnightSupplyCollateralWithNative":
385
+ return (0, supplyCollateralWithNative_js_1.buildMidnightSupplyCollateralWithNative)(action);
386
+ case "midnightWithdrawCollateral":
387
+ return (0, withdrawCollateral_js_2.buildMidnightWithdrawCollateral)(action);
388
+ case "midnightWithdrawCollateralBatch":
389
+ return (0, withdrawCollateralBatch_js_1.buildMidnightWithdrawCollateralBatch)(action);
390
+ case "midnightRedeem":
391
+ return (0, redeem_js_1.buildMidnightRedeem)(action);
392
+ case "midnightTakeRepayWithdrawCollateral":
393
+ return (0, takeRepayWithdrawCollateral_js_1.buildMidnightTakeRepayWithdrawCollateral)(action);
394
+ case "midnightCancelOffers":
395
+ return (0, cancelOffers_js_1.buildMidnightCancelOffers)(action);
345
396
  case "vaultV2Deposit":
346
397
  return (0, deposit_js_2.buildVaultV2Deposit)(action, requests);
347
398
  case "vaultV2Withdraw":
348
399
  return (0, withdraw_js_3.buildVaultV2Withdraw)(action, requests);
349
400
  case "vaultV2Redeem":
350
- return (0, redeem_js_2.buildVaultV2Redeem)(action, requests);
401
+ return (0, redeem_js_3.buildVaultV2Redeem)(action, requests);
351
402
  case "vaultV2ForceWithdraw":
352
403
  return (0, forceWithdraw_js_1.buildVaultV2ForceWithdraw)(action, requests);
353
404
  case "vaultV1Withdraw":
354
405
  return (0, withdraw_js_2.buildVaultV1Withdraw)(action, requests);
355
406
  case "vaultV1Redeem":
356
- return (0, redeem_js_1.buildVaultV1Redeem)(action, requests);
407
+ return (0, redeem_js_2.buildVaultV1Redeem)(action, requests);
357
408
  case "vaultV2InKindRedeem":
358
409
  return (0, inKindRedeem_js_2.buildVaultV2InKindRedeem)(action, requests);
359
410
  }
@@ -370,16 +421,24 @@ function encodeStep(action, requests) {
370
421
  * @param plan - Plan supplying referenced signature requests and the calldata origin; chain and account come from the action inputs.
371
422
  * @param step - Recipe to encode; missing signatures on unrelated supported steps do not block it.
372
423
  * @returns A frozen `{ to, data, value, action }`, ready to simulate or submit. `data` ends with the plan's `calldataOrigin` when one was set.
373
- * @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent.
374
- * @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
424
+ * @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent, a Midnight repayment type is unsupported, a Midnight market lists its collateral out of ascending token order, a Midnight single-collateral step has no bigint `collateralIndex`, or a Midnight collateral batch's list is not an array or holds a non-object entry (path under `$.inputs`).
425
+ * @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty, or a Midnight collateral batch entry's `collateralIndex` or `assets`, is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
375
426
  * @throws {InvalidSignatureError} If a stored signature has high s, cannot recover a public key or does not match the request owner.
376
427
  * @throws {UnsupportedTransactionPlanVersionError} If the plan version is unsupported.
377
428
  * @throws {UnsupportedTransactionPlanActionError} If any plan step or the selected step names an unsupported action type.
378
429
  * @throws {UnsupportedErc20ApprovalSpenderError} If an approval names an unregistered spender.
379
430
  * @throws {SameVaultMigrationError} If a migration's source and destination vaults are identical.
380
431
  * @throws {AmountAndSharesExclusiveError} If a migration supplies both `assets` and `shares`, or neither.
381
- * @throws {NonPositiveInputError} If a deposit, withdrawal or migration amount, a deposit or migration destination share-price bound, a Blue collateral amount, a deadline, force-redeem shares or deallocation amount is not positive.
432
+ * @throws {NonPositiveInputError} If a deposit, withdrawal or migration amount, a deposit or migration destination share-price bound, a collateral amount, Midnight redeem units, a deadline, force-redeem shares or deallocation amount is not positive, or a Midnight repayment step has a nonpositive full repayment cap or neither repays nor withdraws.
382
433
  * @throws {MarketIdMismatchError} If a Blue collateral step's market ID doesn't match its market parameters.
434
+ * @throws {MidnightMarketAddressMismatchError} If a Midnight collateral, redeem or repayment step's market targets another Midnight deployment.
435
+ * @throws {ChainIdMismatchError} If a Midnight redeem or repayment step's market targets another chain.
436
+ * @throws {MidnightZeroOnBehalfError} If a Midnight redeem, `midnightWithdrawCollateral`, `midnightWithdrawCollateralBatch` or `midnightSupplyCollateralWithNative` step names the zero address as its account.
437
+ * @throws {MidnightZeroReceiverError} If a Midnight redeem, `midnightWithdrawCollateral` or `midnightWithdrawCollateralBatch` step, or a `midnightRepayWithdrawCollateral` step that withdraws collateral, names the zero address as its receiver.
438
+ * @throws {MidnightContractReceiverError} If a Midnight redeem, `midnightWithdrawCollateral` or `midnightWithdrawCollateralBatch` step, or a `midnightRepayWithdrawCollateral` step that withdraws collateral, names a blocked protocol or token contract as its receiver.
439
+ * @throws {MidnightCalldataEncodingError} If the market tuple or withdrawal arguments cannot be encoded for a Midnight redeem step, or a Midnight repayment step has malformed addresses or other unencodable inputs.
440
+ * @throws {InvalidMarketParameterError} If a Midnight collateral, redeem, take or repayment step has an invalid market configuration.
441
+ * @throws {UnknownCollateralIndexError} If a Midnight collateral or repayment step targets an index not configured on its market.
383
442
  * @throws {NativeAmountOnNonWNativeAssetError} If a native-funded Blue collateral step targets a token other than wNative.
384
443
  * @throws {ChainWNativeMissingError} If a native-funded Blue collateral step targets a chain without registered wNative.
385
444
  * @throws {EmptyDeallocationsError} If a force-redeem step has no deallocations.
@@ -391,8 +450,10 @@ function encodeStep(action, requests) {
391
450
  * @throws {TransactionPlanSignatureMismatchError} If a referenced request disagrees with the step's action or its encoding arguments.
392
451
  * @throws {BundlesPermitMismatchError} If a stored signature cannot be parsed or a signed permit's encoding arguments do not match the step.
393
452
  * @throws {MarketIdMismatchError} If a Blue market ID differs from its parameter tuple.
394
- * @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative.
395
- * @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), or withdrawal-only funding is nonzero.
453
+ * @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative, or a Midnight repayment's exact asset amount or native funding is negative.
454
+ * @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), withdrawal-only funding is nonzero, Midnight redeem units exceed uint128, or a Midnight batch collateral supply amount exceeds uint128.
455
+ * For `midnightRepayWithdrawCollateral`, if `repay.assets` or `repay.maxBuyerAssets` is at least `maxUint256`,
456
+ * a withdrawal amount or deadline exceeds uint256, or native funding exceeds the repayment pull.
396
457
  * @throws {MutuallyExclusiveRepayAmountsError} If a Blue repayment specifies both nonzero assets and shares.
397
458
  * @throws {MaxRepayAssetsBelowRepayAssetsError} If exact-asset funding cannot cover repayment plus referral fees.
398
459
  * @throws {NativeFundingAmountMismatchError} If Blue native funding does not equal the full repayment cap.
@@ -405,8 +466,15 @@ function encodeStep(action, requests) {
405
466
  * @throws {DepositSpenderMismatchError} If a token signature names another spender.
406
467
  * @throws {UnsupportedRequirementSignatureError} If a token signature has an unsupported action type.
407
468
  * @throws {BundlesRequirementSignatureMismatchError} If a Blue signature cannot be bound or parsed safely.
408
- * @throws {UnsupportedChainIdError} If a Blue action's chain is absent from the registry.
409
- * @throws {UnknownAddressError} If BlueBundlesV1 is not registered on the action's chain.
469
+ * @throws {UnsupportedChainIdError} If a Blue or Midnight action's chain is absent from the registry.
470
+ * @throws {UnknownAddressError} If BlueBundlesV1, Midnight core, or MidnightBundlesV2 for a Midnight repayment step is not registered on the action's chain.
471
+ * @throws {EmptyMidnightGroupCancellationsError} If a Midnight cancellation lists no groups.
472
+ * @throws {InvalidMidnightHexInputError} If a Midnight cancellation group is not 32 bytes.
473
+ * @throws {DuplicateMidnightGroupCancellationError} If a Midnight cancellation lists a group twice.
474
+ * @throws {EmptyMidnightCollateralWithdrawalsError} If a Midnight batch collateral withdrawal lists no withdrawals.
475
+ * @throws {EmptyMidnightCollateralSuppliesError} If a Midnight batch collateral supply lists no supplies.
476
+ * @throws {DuplicateMidnightCollateralIndexError} If a Midnight batch collateral supply or withdrawal repeats a collateral index.
477
+ * @throws {MidnightZeroOnBehalfError} If a Midnight cancellation's account is the zero address.
410
478
  * @example
411
479
  * ```ts
412
480
  * import { buildTransaction, parseTransactionPlan } from "@morpho-org/morpho-sdk";
@@ -468,16 +536,23 @@ function buildTransaction(plan, step) {
468
536
  * Builds every step of the plan in order.
469
537
  * @param plan - Plan whose referenced signature requests all carry a signature.
470
538
  * @returns Frozen SDK transactions in step order; discriminate on `action.type` for per-step handling.
471
- * @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent.
472
- * @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
539
+ * @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent, a Midnight repayment type is unsupported, a Midnight market lists its collateral out of ascending token order, a Midnight single-collateral step has no bigint `collateralIndex`, or a Midnight collateral batch's list is not an array or holds a non-object entry (path under `$.inputs`).
540
+ * @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty, or a Midnight collateral batch entry's `collateralIndex` or `assets`, is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
473
541
  * @throws {InvalidSignatureError} If a stored signature has high s, cannot recover a public key or does not match the request owner.
474
542
  * @throws {UnsupportedTransactionPlanVersionError} If the plan version is unsupported, including empty plans.
475
543
  * @throws {UnsupportedTransactionPlanActionError} If any plan step names an unsupported action type, before reading requests.
476
544
  * @throws {UnsupportedErc20ApprovalSpenderError} If an approval names an unregistered spender.
477
545
  * @throws {SameVaultMigrationError} If a migration's source and destination vaults are identical.
478
546
  * @throws {AmountAndSharesExclusiveError} If a migration supplies both `assets` and `shares`, or neither.
479
- * @throws {NonPositiveInputError} If a deposit, withdrawal or migration amount, a deposit or migration destination share-price bound, a Blue collateral amount, a deadline, force-redeem shares or deallocation amount is not positive.
547
+ * @throws {NonPositiveInputError} If a deposit, withdrawal or migration amount, a deposit or migration destination share-price bound, a collateral amount, Midnight redeem units, a deadline, force-redeem shares or deallocation amount is not positive, or a Midnight repayment step has a nonpositive full repayment cap or neither repays nor withdraws.
480
548
  * @throws {MarketIdMismatchError} If a Blue collateral step's market ID doesn't match its market parameters.
549
+ * @throws {MidnightMarketAddressMismatchError} If a Midnight collateral, redeem or repayment step's market targets another Midnight deployment.
550
+ * @throws {ChainIdMismatchError} If a Midnight redeem or repayment step's market targets another chain.
551
+ * @throws {MidnightZeroOnBehalfError} If a Midnight redeem, `midnightWithdrawCollateral`, `midnightWithdrawCollateralBatch` or `midnightSupplyCollateralWithNative` step names the zero address as its account.
552
+ * @throws {MidnightZeroReceiverError} If a Midnight redeem, `midnightWithdrawCollateral` or `midnightWithdrawCollateralBatch` step, or a `midnightRepayWithdrawCollateral` step that withdraws collateral, names the zero address as its receiver.
553
+ * @throws {MidnightContractReceiverError} If a Midnight redeem, `midnightWithdrawCollateral` or `midnightWithdrawCollateralBatch` step, or a `midnightRepayWithdrawCollateral` step that withdraws collateral, names a blocked protocol or token contract as its receiver.
554
+ * @throws {MidnightCalldataEncodingError} If the market tuple or withdrawal arguments cannot be encoded for a Midnight redeem step, or a Midnight repayment step has malformed addresses or other unencodable inputs.
555
+ * @throws {UnknownCollateralIndexError} If a Midnight collateral or repayment step targets an index not configured on its market.
481
556
  * @throws {NativeAmountOnNonWNativeAssetError} If a native-funded Blue collateral step targets a token other than wNative.
482
557
  * @throws {ChainWNativeMissingError} If a native-funded Blue collateral step targets a chain without registered wNative.
483
558
  * @throws {EmptyDeallocationsError} If a force-redeem step has no deallocations.
@@ -486,11 +561,14 @@ function buildTransaction(plan, step) {
486
561
  * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
487
562
  * @throws {ReferralFeeRecipientMissingError} If a positive referral fee has no nonzero recipient.
488
563
  * @throws {IncompleteTransactionPlanError} If any step references a signature request or signature that is missing.
564
+ * @throws {InvalidMarketParameterError} If a Midnight collateral, redeem, take or repayment step has an invalid market configuration.
489
565
  * @throws {TransactionPlanSignatureMismatchError} If a referenced request disagrees with its action or encoding arguments.
490
566
  * @throws {BundlesPermitMismatchError} If a stored signature cannot be parsed or a signed permit's encoding arguments do not match the step.
491
567
  * @throws {MarketIdMismatchError} If a Blue market ID differs from its parameter tuple.
492
- * @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative.
493
- * @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), or withdrawal-only funding is nonzero.
568
+ * @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative, or a Midnight repayment's exact asset amount or native funding is negative.
569
+ * @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), withdrawal-only funding is nonzero, Midnight redeem units exceed uint128, or a Midnight batch collateral supply amount exceeds uint128.
570
+ * For `midnightRepayWithdrawCollateral`, if `repay.assets` or `repay.maxBuyerAssets` is at least `maxUint256`,
571
+ * a withdrawal amount or deadline exceeds uint256, or native funding exceeds the repayment pull.
494
572
  * @throws {MutuallyExclusiveRepayAmountsError} If a Blue repayment specifies both nonzero assets and shares.
495
573
  * @throws {MaxRepayAssetsBelowRepayAssetsError} If exact-asset funding cannot cover repayment plus referral fees.
496
574
  * @throws {NativeFundingAmountMismatchError} If Blue native funding does not equal the full repayment cap.
@@ -503,8 +581,15 @@ function buildTransaction(plan, step) {
503
581
  * @throws {DepositSpenderMismatchError} If a token signature names another spender.
504
582
  * @throws {UnsupportedRequirementSignatureError} If a token signature has an unsupported action type.
505
583
  * @throws {BundlesRequirementSignatureMismatchError} If a Blue signature cannot be bound or parsed safely.
506
- * @throws {UnsupportedChainIdError} If a Blue action's chain is absent from the registry.
507
- * @throws {UnknownAddressError} If BlueBundlesV1 is not registered on the action's chain.
584
+ * @throws {UnsupportedChainIdError} If a Blue or Midnight action's chain is absent from the registry.
585
+ * @throws {UnknownAddressError} If BlueBundlesV1, Midnight core, or MidnightBundlesV2 for a Midnight repayment step is not registered on the action's chain.
586
+ * @throws {EmptyMidnightGroupCancellationsError} If a Midnight cancellation lists no groups.
587
+ * @throws {InvalidMidnightHexInputError} If a Midnight cancellation group is not 32 bytes.
588
+ * @throws {DuplicateMidnightGroupCancellationError} If a Midnight cancellation lists a group twice.
589
+ * @throws {EmptyMidnightCollateralWithdrawalsError} If a Midnight batch collateral withdrawal lists no withdrawals.
590
+ * @throws {EmptyMidnightCollateralSuppliesError} If a Midnight batch collateral supply lists no supplies.
591
+ * @throws {DuplicateMidnightCollateralIndexError} If a Midnight batch collateral supply or withdrawal repeats a collateral index.
592
+ * @throws {MidnightZeroOnBehalfError} If a Midnight cancellation's account is the zero address.
508
593
  * @example
509
594
  * ```ts
510
595
  * import { buildTransactions, type TransactionPlan } from "@morpho-org/morpho-sdk";
@@ -25,19 +25,22 @@ export declare function buildApprovalStep(requirement: Readonly<Transaction<ERC2
25
25
  }): Step<Extract<Action, {
26
26
  type: "erc20Approval";
27
27
  }>>;
28
- interface TokenRequirementsParams {
28
+ type TokenRequirementsParams = {
29
29
  readonly token: Address;
30
30
  readonly spender: Address;
31
31
  readonly amount: bigint;
32
32
  readonly owner: Address;
33
33
  readonly chainId: number;
34
+ readonly approvalId: (index: number) => string;
35
+ } & ({
36
+ readonly supportSignature?: false;
37
+ } | {
38
+ readonly supportSignature: boolean;
34
39
  readonly deadline: bigint;
35
40
  readonly now: bigint;
36
- readonly supportSignature: boolean;
37
41
  readonly deployless: boolean | undefined;
38
42
  readonly permitId: string;
39
- readonly approvalId: (index: number) => string;
40
- }
43
+ });
41
44
  /**
42
45
  * @internal Resolves the token prerequisite of a bundles pull without Permit2. A sufficient
43
46
  * direct allowance yields nothing. Otherwise signature support prefers an ERC-2612 permit when
@@ -57,7 +57,7 @@ function buildApprovalStep(requirement, { id, chainId, account, denomination, })
57
57
  * available and falls back to a direct unlimited approval. Without signature support, always approve.
58
58
  */
59
59
  async function getTokenRequirements(client, params) {
60
- const { token, spender, amount, owner, chainId, permitId, approvalId } = params;
60
+ const { token, spender, amount, owner, chainId, approvalId } = params;
61
61
  // The allowance is trusted as returned by the RPC. See THREAT_MODEL.md, RPC.
62
62
  const allowance = await (0, actions_1.readContract)(client, {
63
63
  abi: viem_1.erc20Abi,
@@ -71,7 +71,7 @@ async function getTokenRequirements(client, params) {
71
71
  if (params.supportSignature) {
72
72
  const permit = await (0, getTokenPermit_js_1.getTokenPermit)(client, {
73
73
  ...params,
74
- id: permitId,
74
+ id: params.permitId,
75
75
  supportDeployless: params.deployless,
76
76
  });
77
77
  if (permit !== undefined) {
@@ -15,8 +15,19 @@ export declare function serializeTransactionPlan(plan: TransactionPlan): string;
15
15
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
16
16
  * Restores bigint fields and validates version, action/request shapes, uint256 ranges, unique IDs,
17
17
  * references, per-action chain/account and signature-request consistency, including signed requests.
18
- * Extra keys are allowed. No clock or RPC is used: current expiry, live state and
19
- * action-layer business constraints are not checked. Stored signatures are recovered offline.
18
+ * Extra keys are allowed. Midnight maker publications, `midnightSupplyCollateralTakeBorrow`,
19
+ * `midnightTakeRepayWithdrawCollateral` and `midnightSupplyCollateralWithNative` also rerun their
20
+ * builders' static input checks, so a stored recipe that fails those checks throws here. Restore compares the stored market of
21
+ * `midnightSupplyCollateralMakeBorrow`, `midnightSupplyCollateralTakeBorrow` and
22
+ * `midnightTakeRepayWithdrawCollateral` with the registered Midnight deployment, and each maker
23
+ * publication's ratifier with the registry. It does not decode maker offer payloads, so their offer
24
+ * markets are not checked, and other Midnight actions check only the stored market's shape and
25
+ * chain. Restoring `midnightSupplyCollateralWithNative` also looks up the chain's Midnight core,
26
+ * wNative and MidnightBundlesV2 registry entries, so register custom deployments before parsing.
27
+ * Building can still fail: other deployment lookups, such as the Midnight bundle address of other
28
+ * actions, run only in `buildTransactions`. No clock or RPC is used:
29
+ * current expiry, live state and other action-layer business constraints are not checked. Stored
30
+ * signatures are recovered offline.
20
31
  * Permits bind owner, token, spender, value, nonce, deadline and chain; Morpho authorizations bind
21
32
  * owner, authorized address, nonce, deadline and chain, not operation amounts, markets or referral fees/recipients.
22
33
  * Parsing does not prove authenticity or intent for unsigned fields;
@@ -13,14 +13,29 @@ const supply_js_1 = require("./blue/supply.js");
13
13
  const supplyCollateral_js_1 = require("./blue/supplyCollateral.js");
14
14
  const supplyCollateralBorrow_js_1 = require("./blue/supplyCollateralBorrow.js");
15
15
  const withdraw_js_1 = require("./blue/withdraw.js");
16
+ const withdrawBuyCallback_js_1 = require("./blue/withdrawBuyCallback.js");
16
17
  const withdrawCollateral_js_1 = require("./blue/withdrawCollateral.js");
17
18
  const deposit_js_1 = require("./deposit.js");
18
19
  const error_js_2 = require("./error.js");
20
+ const authorization_js_2 = require("./midnight/authorization.js");
21
+ const cancelOffers_js_1 = require("./midnight/cancelOffers.js");
22
+ const makerPublication_js_1 = require("./midnight/makerPublication.js");
23
+ const redeem_js_1 = require("./midnight/redeem.js");
24
+ const repayWithdrawCollateral_js_2 = require("./midnight/repayWithdrawCollateral.js");
25
+ const supplyCollateral_js_2 = require("./midnight/supplyCollateral.js");
26
+ const supplyCollateralBatch_js_1 = require("./midnight/supplyCollateralBatch.js");
27
+ const supplyCollateralWithNative_js_1 = require("./midnight/supplyCollateralWithNative.js");
28
+ const takeBorrow_js_1 = require("./midnight/takeBorrow.js");
29
+ const takeLend_js_1 = require("./midnight/takeLend.js");
30
+ const takeRepayWithdrawCollateral_js_1 = require("./midnight/takeRepayWithdrawCollateral.js");
31
+ const validation_js_1 = require("./midnight/validation.js");
32
+ const withdrawCollateral_js_2 = require("./midnight/withdrawCollateral.js");
33
+ const withdrawCollateralBatch_js_1 = require("./midnight/withdrawCollateralBatch.js");
19
34
  const permit_js_1 = require("./permit.js");
20
35
  const plan_js_1 = require("./plan.js");
21
- const redeem_js_1 = require("./redeem.js");
36
+ const redeem_js_2 = require("./redeem.js");
22
37
  const validateActions_js_1 = require("./validateActions.js");
23
- const validation_js_1 = require("./validation.js");
38
+ const validation_js_2 = require("./validation.js");
24
39
  const inKindRedeem_js_1 = require("./vaultv1/inKindRedeem.js");
25
40
  const migrateToV2_js_1 = require("./vaultv1/migrateToV2.js");
26
41
  const forceRedeem_js_1 = require("./vaultv2/forceRedeem.js");
@@ -37,15 +52,36 @@ const actionValidators = {
37
52
  blueRepay: repay_js_1.validateBlueRepayPlanAction,
38
53
  blueWithdraw: withdraw_js_1.validateBlueWithdrawPlanAction,
39
54
  blueWithdrawCollateral: withdrawCollateral_js_1.validateBlueWithdrawCollateralPlanAction,
55
+ blueWithdrawBuyCallback: withdrawBuyCallback_js_1.validateBlueWithdrawBuyCallbackPlanAction,
40
56
  blueRepayWithdrawCollateral: repayWithdrawCollateral_js_1.validateRepayWithdrawCollateralPlanAction,
41
57
  blueRefinance: refinance_js_1.validateRefinancePlanAction,
42
58
  erc20Approval: approval_js_1.validateApprovalPlanAction,
43
- vaultV2Redeem: redeem_js_1.validateRedeemPlanAction,
59
+ vaultV2Redeem: redeem_js_2.validateRedeemPlanAction,
44
60
  vaultV2ForceWithdraw: forceWithdraw_js_1.validateForceWithdrawPlanAction,
45
61
  vaultV1Deposit: deposit_js_1.validateDepositPlanAction,
46
- vaultV1Redeem: redeem_js_1.validateRedeemPlanAction,
62
+ vaultV1Redeem: redeem_js_2.validateRedeemPlanAction,
47
63
  vaultV1MigrateToV2: migrateToV2_js_1.validateMigrateToV2PlanAction,
48
64
  morphoAuthorization: authorization_js_1.validateMorphoAuthorizationPlanAction,
65
+ midnightAuthorization: authorization_js_2.validateSignaturelessMidnightAction,
66
+ midnightMakeBorrow: makerPublication_js_1.validateMidnightMakerPublicationPlanAction,
67
+ midnightMakeLend: makerPublication_js_1.validateMidnightMakerPublicationPlanAction,
68
+ midnightMakeRepay: makerPublication_js_1.validateMidnightMakerPublicationPlanAction,
69
+ midnightMakeWithdraw: makerPublication_js_1.validateMidnightMakerPublicationPlanAction,
70
+ midnightSupplyBlueMakeLend: makerPublication_js_1.validateMidnightMakerPublicationPlanAction,
71
+ midnightSupplyCollateralMakeBorrow: makerPublication_js_1.validateMidnightMakerPublicationPlanAction,
72
+ midnightTakeBorrow: validation_js_1.validateMidnightSellPlanAction,
73
+ midnightSupplyCollateralTakeBorrow: takeBorrow_js_1.validateMidnightSupplyCollateralTakeBorrowPlanAction,
74
+ midnightTakeLend: takeLend_js_1.validateMidnightTakeLendPlanAction,
75
+ midnightSupplyCollateral: supplyCollateral_js_2.validateMidnightSupplyCollateralPlanAction,
76
+ midnightSupplyCollateralBatch: supplyCollateralBatch_js_1.validateMidnightSupplyCollateralBatchPlanAction,
77
+ midnightSupplyCollateralWithNative: supplyCollateralWithNative_js_1.validateMidnightSupplyCollateralWithNativePlanAction,
78
+ midnightWithdrawCollateral: withdrawCollateral_js_2.validateMidnightWithdrawCollateralPlanAction,
79
+ midnightWithdrawCollateralBatch: withdrawCollateralBatch_js_1.validateMidnightWithdrawCollateralBatchPlanAction,
80
+ midnightRedeem: redeem_js_1.validateMidnightRedeemPlanAction,
81
+ midnightTakeRepayWithdrawCollateral: takeRepayWithdrawCollateral_js_1.validateMidnightTakeRepayWithdrawCollateralPlanAction,
82
+ midnightTakeWithdraw: validation_js_1.validateMidnightSellPlanAction,
83
+ midnightRepayWithdrawCollateral: repayWithdrawCollateral_js_2.validateMidnightRepayWithdrawCollateralPlanAction,
84
+ midnightCancelOffers: cancelOffers_js_1.validateMidnightCancelOffersPlanAction,
49
85
  vaultV2Deposit: deposit_js_1.validateDepositPlanAction,
50
86
  vaultV2Withdraw: withdraw_js_2.validateWithdrawPlanAction,
51
87
  vaultV2ForceRedeem: forceRedeem_js_1.validateForceRedeemPlanAction,
@@ -74,8 +110,19 @@ function serializeTransactionPlan(plan) {
74
110
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
75
111
  * Restores bigint fields and validates version, action/request shapes, uint256 ranges, unique IDs,
76
112
  * references, per-action chain/account and signature-request consistency, including signed requests.
77
- * Extra keys are allowed. No clock or RPC is used: current expiry, live state and
78
- * action-layer business constraints are not checked. Stored signatures are recovered offline.
113
+ * Extra keys are allowed. Midnight maker publications, `midnightSupplyCollateralTakeBorrow`,
114
+ * `midnightTakeRepayWithdrawCollateral` and `midnightSupplyCollateralWithNative` also rerun their
115
+ * builders' static input checks, so a stored recipe that fails those checks throws here. Restore compares the stored market of
116
+ * `midnightSupplyCollateralMakeBorrow`, `midnightSupplyCollateralTakeBorrow` and
117
+ * `midnightTakeRepayWithdrawCollateral` with the registered Midnight deployment, and each maker
118
+ * publication's ratifier with the registry. It does not decode maker offer payloads, so their offer
119
+ * markets are not checked, and other Midnight actions check only the stored market's shape and
120
+ * chain. Restoring `midnightSupplyCollateralWithNative` also looks up the chain's Midnight core,
121
+ * wNative and MidnightBundlesV2 registry entries, so register custom deployments before parsing.
122
+ * Building can still fail: other deployment lookups, such as the Midnight bundle address of other
123
+ * actions, run only in `buildTransactions`. No clock or RPC is used:
124
+ * current expiry, live state and other action-layer business constraints are not checked. Stored
125
+ * signatures are recovered offline.
79
126
  * Permits bind owner, token, spender, value, nonce, deadline and chain; Morpho authorizations bind
80
127
  * owner, authorized address, nonce, deadline and chain, not operation amounts, markets or referral fees/recipients.
81
128
  * Parsing does not prove authenticity or intent for unsigned fields;
@@ -109,10 +156,10 @@ function parseTransactionPlan(json) {
109
156
  cause,
110
157
  });
111
158
  }
112
- const plan = (0, validation_js_1.getPlanObject)(restored, "$");
113
- (0, validation_js_1.validatePlanField)(plan.version, { path: "$.version", type: "safe integer" });
159
+ const plan = (0, validation_js_2.getPlanObject)(restored, "$");
160
+ (0, validation_js_2.validatePlanField)(plan.version, { path: "$.version", type: "safe integer" });
114
161
  (0, version_js_1.validateTransactionPlanVersion)(plan.version);
115
- (0, validation_js_1.validatePlanFields)(plan, {
162
+ (0, validation_js_2.validatePlanFields)(plan, {
116
163
  path: "$",
117
164
  fields: {
118
165
  chainId: "positive safe integer",
@@ -126,13 +173,13 @@ function parseTransactionPlan(json) {
126
173
  const requests = plan.signatureRequests;
127
174
  for (const [index, value] of steps.entries()) {
128
175
  const path = `$.steps[${index}]`;
129
- const step = (0, validation_js_1.getPlanObject)(value, path);
130
- (0, validation_js_1.validatePlanFields)(step, {
176
+ const step = (0, validation_js_2.getPlanObject)(value, path);
177
+ (0, validation_js_2.validatePlanFields)(step, {
131
178
  path,
132
179
  fields: { id: "string", label: "string" },
133
180
  });
134
- const action = (0, validation_js_1.getPlanObject)(step.action, `${path}.action`);
135
- (0, validation_js_1.validatePlanField)(action.type, {
181
+ const action = (0, validation_js_2.getPlanObject)(step.action, `${path}.action`);
182
+ (0, validation_js_2.validatePlanField)(action.type, {
136
183
  path: `${path}.action.type`,
137
184
  type: "string",
138
185
  });
@@ -141,9 +188,9 @@ function parseTransactionPlan(json) {
141
188
  (0, validateActions_js_1.validateTransactionPlanActions)(steps);
142
189
  for (const [index, step] of steps.entries()) {
143
190
  const path = `$.steps[${index}].action`;
144
- const action = (0, validation_js_1.getPlanObject)(step.action, path);
145
- const inputs = (0, validation_js_1.getPlanObject)(action.inputs, `${path}.inputs`);
146
- (0, validation_js_1.validatePlanFields)(inputs, {
191
+ const action = (0, validation_js_2.getPlanObject)(step.action, path);
192
+ const inputs = (0, validation_js_2.getPlanObject)(action.inputs, `${path}.inputs`);
193
+ (0, validation_js_2.validatePlanFields)(inputs, {
147
194
  path: `${path}.inputs`,
148
195
  fields: { chainId: "positive safe integer", account: "address" },
149
196
  });
@@ -152,8 +199,8 @@ function parseTransactionPlan(json) {
152
199
  const requestIds = new Set();
153
200
  for (const [index, value] of requests.entries()) {
154
201
  const path = `$.signatureRequests[${index}]`;
155
- const request = (0, validation_js_1.getPlanObject)(value, path);
156
- (0, validation_js_1.validatePlanFields)(request, {
202
+ const request = (0, validation_js_2.getPlanObject)(value, path);
203
+ (0, validation_js_2.validatePlanFields)(request, {
157
204
  path,
158
205
  fields: { id: "string", kind: "string" },
159
206
  });
@@ -165,9 +212,9 @@ function parseTransactionPlan(json) {
165
212
  continue;
166
213
  }
167
214
  const path = `$.steps[${index}].action.signatureRequestIds`;
168
- const ids = (0, validation_js_1.getPlanObject)(step.action.signatureRequestIds, path);
215
+ const ids = (0, validation_js_2.getPlanObject)(step.action.signatureRequestIds, path);
169
216
  for (const [role, id] of Object.entries(ids)) {
170
- (0, validation_js_1.validatePlanField)(id, { path: `${path}.${role}`, type: "string" });
217
+ (0, validation_js_2.validatePlanField)(id, { path: `${path}.${role}`, type: "string" });
171
218
  if (!requestIds.has(id)) {
172
219
  throw new error_js_2.InvalidTransactionPlanError({
173
220
  path: `${path}.${role}`,
@@ -178,7 +225,7 @@ function parseTransactionPlan(json) {
178
225
  }
179
226
  const result = restored;
180
227
  // Apply the same context and deadline rules as direct builders.
181
- (0, validation_js_1.validateTransactionPlanHeader)(result);
228
+ (0, validation_js_2.validateTransactionPlanHeader)(result);
182
229
  try {
183
230
  // Check references and request/action consistency, including restored signatures.
184
231
  (0, plan_js_1.getPendingSignatureRequests)(result);