@morpho-org/morpho-sdk 10.4.0 → 10.5.0-next.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 (221) hide show
  1. package/lib/cjs/abis.d.ts +1 -1
  2. package/lib/cjs/abis.js +5 -1
  3. package/lib/cjs/actions/blue/common.js +12 -3
  4. package/lib/cjs/blue/abis.d.ts +1 -1
  5. package/lib/cjs/blue/abis.js +5 -1
  6. package/lib/cjs/blue/entities.d.ts +4 -4
  7. package/lib/cjs/blue/entities.js +3 -1
  8. package/lib/cjs/blue/errors.d.ts +2 -2
  9. package/lib/cjs/blue/errors.js +5 -1
  10. package/lib/cjs/blue/fetch.d.ts +2 -2
  11. package/lib/cjs/blue/fetch.js +3 -1
  12. package/lib/cjs/blue/utils.d.ts +1 -1
  13. package/lib/cjs/blue/utils.js +2 -1
  14. package/lib/cjs/entities/index.d.ts +4 -4
  15. package/lib/cjs/entities/index.js +3 -1
  16. package/lib/cjs/entities/midnight/midnight.d.ts +100 -103
  17. package/lib/cjs/entities/midnight/midnight.js +99 -99
  18. package/lib/cjs/entities/vaultV1/vaultV1.js +0 -1
  19. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +34 -8
  20. package/lib/cjs/entities/vaultV2/vaultV2.js +39 -2
  21. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -2
  22. package/lib/cjs/entities/vaultV2BlueReallocationData.js +6 -2
  23. package/lib/cjs/errors.d.ts +4 -4
  24. package/lib/cjs/errors.js +7 -5
  25. package/lib/cjs/fetch.d.ts +2 -2
  26. package/lib/cjs/fetch.js +3 -1
  27. package/lib/cjs/helpers/deadShares.js +3 -0
  28. package/lib/cjs/helpers/validate.d.ts +11 -1
  29. package/lib/cjs/midnight/errors.d.ts +2 -1
  30. package/lib/cjs/midnight/errors.js +5 -4
  31. package/lib/cjs/transactionPlan/assemble.d.ts +24 -0
  32. package/lib/cjs/transactionPlan/assemble.js +25 -0
  33. package/lib/cjs/transactionPlan/blue/borrow.js +14 -64
  34. package/lib/cjs/transactionPlan/blue/refinance.js +9 -11
  35. package/lib/cjs/transactionPlan/blue/repay.js +10 -24
  36. package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +49 -45
  37. package/lib/cjs/transactionPlan/blue/stored.d.ts +26 -0
  38. package/lib/cjs/transactionPlan/blue/stored.js +87 -0
  39. package/lib/cjs/transactionPlan/blue/supply.js +7 -22
  40. package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +1 -1
  41. package/lib/cjs/transactionPlan/blue/supplyCollateral.js +10 -15
  42. package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +14 -64
  43. package/lib/cjs/transactionPlan/blue/withdraw.d.ts +2 -3
  44. package/lib/cjs/transactionPlan/blue/withdraw.js +67 -79
  45. package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +2 -3
  46. package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +31 -30
  47. package/lib/cjs/transactionPlan/deposit.js +4 -7
  48. package/lib/cjs/transactionPlan/intent.d.ts +1 -1
  49. package/lib/cjs/transactionPlan/midnight/makeBorrow.d.ts +1 -1
  50. package/lib/cjs/transactionPlan/midnight/makeBorrow.js +1 -1
  51. package/lib/cjs/transactionPlan/midnight/makeLend.d.ts +1 -1
  52. package/lib/cjs/transactionPlan/midnight/makeLend.js +1 -1
  53. package/lib/cjs/transactionPlan/midnight/makeRepay.d.ts +1 -1
  54. package/lib/cjs/transactionPlan/midnight/makeRepay.js +1 -1
  55. package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.d.ts +1 -1
  56. package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.js +1 -1
  57. package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.d.ts +1 -1
  58. package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.js +1 -1
  59. package/lib/cjs/transactionPlan/midnight/supplyCollateral.d.ts +1 -1
  60. package/lib/cjs/transactionPlan/midnight/supplyCollateral.js +1 -1
  61. package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.d.ts +1 -1
  62. package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.js +1 -1
  63. package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +1 -1
  64. package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.js +1 -1
  65. package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.d.ts +1 -1
  66. package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.js +1 -1
  67. package/lib/cjs/transactionPlan/midnight/takeBorrow.d.ts +2 -2
  68. package/lib/cjs/transactionPlan/midnight/takeBorrow.js +2 -2
  69. package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
  70. package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.js +1 -1
  71. package/lib/cjs/transactionPlan/midnight/takeWithdraw.d.ts +1 -1
  72. package/lib/cjs/transactionPlan/midnight/takeWithdraw.js +1 -1
  73. package/lib/cjs/transactionPlan/permit.d.ts +15 -2
  74. package/lib/cjs/transactionPlan/permit.js +26 -68
  75. package/lib/cjs/transactionPlan/plan.d.ts +51 -1
  76. package/lib/cjs/transactionPlan/plan.js +56 -13
  77. package/lib/cjs/transactionPlan/redeem.js +4 -7
  78. package/lib/cjs/transactionPlan/types.d.ts +4 -3
  79. package/lib/cjs/transactionPlan/vaultBinding.d.ts +29 -0
  80. package/lib/cjs/transactionPlan/vaultBinding.js +69 -0
  81. package/lib/cjs/transactionPlan/vaultRequirements.d.ts +20 -0
  82. package/lib/cjs/transactionPlan/vaultRequirements.js +37 -0
  83. package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +1 -1
  84. package/lib/cjs/transactionPlan/vaultv1/deposit.js +2 -13
  85. package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.d.ts +2 -2
  86. package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.js +10 -41
  87. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +1 -1
  88. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +6 -18
  89. package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -12
  90. package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +1 -1
  91. package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -13
  92. package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +1 -1
  93. package/lib/cjs/transactionPlan/vaultv2/deposit.js +2 -13
  94. package/lib/cjs/transactionPlan/vaultv2/forceRedeem.d.ts +1 -1
  95. package/lib/cjs/transactionPlan/vaultv2/forceRedeem.js +4 -7
  96. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +2 -2
  97. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +12 -42
  98. package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.d.ts +2 -2
  99. package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.js +10 -41
  100. package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +1 -1
  101. package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -13
  102. package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +1 -1
  103. package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -13
  104. package/lib/cjs/transactionPlan/withdraw.js +4 -7
  105. package/lib/cjs/types/error.d.ts +2 -1
  106. package/lib/cjs/types/error.js +3 -2
  107. package/lib/cjs/utils.d.ts +2 -2
  108. package/lib/cjs/utils.js +4 -2
  109. package/lib/cjs/version.d.ts +1 -1
  110. package/lib/cjs/version.js +1 -1
  111. package/lib/esm/abis.d.ts +1 -1
  112. package/lib/esm/abis.js +1 -1
  113. package/lib/esm/actions/blue/common.js +13 -4
  114. package/lib/esm/blue/abis.d.ts +1 -1
  115. package/lib/esm/blue/abis.js +1 -1
  116. package/lib/esm/blue/entities.d.ts +4 -4
  117. package/lib/esm/blue/entities.js +2 -2
  118. package/lib/esm/blue/errors.d.ts +2 -2
  119. package/lib/esm/blue/errors.js +2 -2
  120. package/lib/esm/blue/fetch.d.ts +2 -2
  121. package/lib/esm/blue/fetch.js +2 -2
  122. package/lib/esm/blue/utils.d.ts +1 -1
  123. package/lib/esm/blue/utils.js +1 -1
  124. package/lib/esm/entities/index.d.ts +4 -4
  125. package/lib/esm/entities/index.js +2 -2
  126. package/lib/esm/entities/midnight/midnight.d.ts +100 -103
  127. package/lib/esm/entities/midnight/midnight.js +99 -99
  128. package/lib/esm/entities/vaultV1/vaultV1.js +0 -1
  129. package/lib/esm/entities/vaultV2/vaultV2.d.ts +34 -8
  130. package/lib/esm/entities/vaultV2/vaultV2.js +40 -3
  131. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -2
  132. package/lib/esm/entities/vaultV2BlueReallocationData.js +6 -2
  133. package/lib/esm/errors.d.ts +4 -4
  134. package/lib/esm/errors.js +4 -4
  135. package/lib/esm/fetch.d.ts +2 -2
  136. package/lib/esm/fetch.js +2 -2
  137. package/lib/esm/helpers/deadShares.js +4 -1
  138. package/lib/esm/helpers/validate.d.ts +11 -1
  139. package/lib/esm/midnight/errors.d.ts +2 -1
  140. package/lib/esm/midnight/errors.js +2 -1
  141. package/lib/esm/transactionPlan/assemble.d.ts +24 -0
  142. package/lib/esm/transactionPlan/assemble.js +21 -0
  143. package/lib/esm/transactionPlan/blue/borrow.js +15 -65
  144. package/lib/esm/transactionPlan/blue/refinance.js +10 -12
  145. package/lib/esm/transactionPlan/blue/repay.js +11 -25
  146. package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +50 -46
  147. package/lib/esm/transactionPlan/blue/stored.d.ts +26 -0
  148. package/lib/esm/transactionPlan/blue/stored.js +80 -0
  149. package/lib/esm/transactionPlan/blue/supply.js +7 -22
  150. package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +1 -1
  151. package/lib/esm/transactionPlan/blue/supplyCollateral.js +10 -15
  152. package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +15 -65
  153. package/lib/esm/transactionPlan/blue/withdraw.d.ts +2 -3
  154. package/lib/esm/transactionPlan/blue/withdraw.js +70 -82
  155. package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +2 -3
  156. package/lib/esm/transactionPlan/blue/withdrawCollateral.js +32 -31
  157. package/lib/esm/transactionPlan/deposit.js +5 -8
  158. package/lib/esm/transactionPlan/intent.d.ts +1 -1
  159. package/lib/esm/transactionPlan/midnight/makeBorrow.d.ts +1 -1
  160. package/lib/esm/transactionPlan/midnight/makeBorrow.js +1 -1
  161. package/lib/esm/transactionPlan/midnight/makeLend.d.ts +1 -1
  162. package/lib/esm/transactionPlan/midnight/makeLend.js +1 -1
  163. package/lib/esm/transactionPlan/midnight/makeRepay.d.ts +1 -1
  164. package/lib/esm/transactionPlan/midnight/makeRepay.js +1 -1
  165. package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.d.ts +1 -1
  166. package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.js +1 -1
  167. package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.d.ts +1 -1
  168. package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.js +1 -1
  169. package/lib/esm/transactionPlan/midnight/supplyCollateral.d.ts +1 -1
  170. package/lib/esm/transactionPlan/midnight/supplyCollateral.js +1 -1
  171. package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.d.ts +1 -1
  172. package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.js +1 -1
  173. package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +1 -1
  174. package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.js +1 -1
  175. package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.d.ts +1 -1
  176. package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.js +1 -1
  177. package/lib/esm/transactionPlan/midnight/takeBorrow.d.ts +2 -2
  178. package/lib/esm/transactionPlan/midnight/takeBorrow.js +2 -2
  179. package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
  180. package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.js +1 -1
  181. package/lib/esm/transactionPlan/midnight/takeWithdraw.d.ts +1 -1
  182. package/lib/esm/transactionPlan/midnight/takeWithdraw.js +1 -1
  183. package/lib/esm/transactionPlan/permit.d.ts +15 -2
  184. package/lib/esm/transactionPlan/permit.js +25 -68
  185. package/lib/esm/transactionPlan/plan.d.ts +51 -1
  186. package/lib/esm/transactionPlan/plan.js +55 -13
  187. package/lib/esm/transactionPlan/redeem.js +5 -8
  188. package/lib/esm/transactionPlan/types.d.ts +4 -3
  189. package/lib/esm/transactionPlan/vaultBinding.d.ts +29 -0
  190. package/lib/esm/transactionPlan/vaultBinding.js +65 -0
  191. package/lib/esm/transactionPlan/vaultRequirements.d.ts +20 -0
  192. package/lib/esm/transactionPlan/vaultRequirements.js +34 -0
  193. package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +1 -1
  194. package/lib/esm/transactionPlan/vaultv1/deposit.js +3 -14
  195. package/lib/esm/transactionPlan/vaultv1/inKindRedeem.d.ts +2 -2
  196. package/lib/esm/transactionPlan/vaultv1/inKindRedeem.js +12 -43
  197. package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +1 -1
  198. package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +9 -21
  199. package/lib/esm/transactionPlan/vaultv1/redeem.js +2 -13
  200. package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +1 -1
  201. package/lib/esm/transactionPlan/vaultv1/withdraw.js +3 -14
  202. package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +1 -1
  203. package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -14
  204. package/lib/esm/transactionPlan/vaultv2/forceRedeem.d.ts +1 -1
  205. package/lib/esm/transactionPlan/vaultv2/forceRedeem.js +5 -8
  206. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +2 -2
  207. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +15 -45
  208. package/lib/esm/transactionPlan/vaultv2/inKindRedeem.d.ts +2 -2
  209. package/lib/esm/transactionPlan/vaultv2/inKindRedeem.js +12 -43
  210. package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +1 -1
  211. package/lib/esm/transactionPlan/vaultv2/redeem.js +3 -14
  212. package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +1 -1
  213. package/lib/esm/transactionPlan/vaultv2/withdraw.js +3 -14
  214. package/lib/esm/transactionPlan/withdraw.js +5 -8
  215. package/lib/esm/types/error.d.ts +2 -1
  216. package/lib/esm/types/error.js +3 -2
  217. package/lib/esm/utils.d.ts +2 -2
  218. package/lib/esm/utils.js +2 -2
  219. package/lib/esm/version.d.ts +1 -1
  220. package/lib/esm/version.js +1 -1
  221. package/package.json +7 -7
@@ -5,17 +5,18 @@ exports.validateBlueWithdrawAuthorizationRequest = validateBlueWithdrawAuthoriza
5
5
  exports.buildBlueWithdraw = buildBlueWithdraw;
6
6
  exports.validateBlueWithdrawPlanAction = validateBlueWithdrawPlanAction;
7
7
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
8
- const morpho_ts_1 = require("@morpho-org/morpho-ts");
9
8
  const viem_1 = require("viem");
10
9
  const common_js_1 = require("../../actions/blue/common.js");
11
10
  const withdraw_js_1 = require("../../actions/blue/withdraw.js");
12
11
  const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
13
12
  const validate_js_1 = require("../../helpers/validate.js");
14
13
  const index_js_1 = require("../../types/index.js");
14
+ const assemble_js_1 = require("../assemble.js");
15
15
  const error_js_1 = require("../error.js");
16
16
  const validation_js_1 = require("../validation.js");
17
17
  const authorization_js_1 = require("./authorization.js");
18
18
  const prepare_js_1 = require("./prepare.js");
19
+ const stored_js_1 = require("./stored.js");
19
20
  /**
20
21
  * Prepares a BlueBundlesV1 withdrawal with only Morpho authorization prerequisites, never token approvals.
21
22
  * The caller supplies market and position snapshots; the SDK reads authorization but never signs.
@@ -48,7 +49,7 @@ const prepare_js_1 = require("./prepare.js");
48
49
  * @param params.supportSignature - Optional Morpho authorization signature preference; defaults to `false`, selecting a direct authorization transaction when needed. Neither mode requests a token allowance or Permit2 signature.
49
50
  * @param params.now - Optional reference timestamp in seconds, normally the latest block timestamp; defaults to the device clock.
50
51
  * @param params.expiresAt - Optional Unix expiry in safe-integer seconds, later than `now`; defaults to `now + 2h`.
51
- * @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to every built transaction; omitted by default.
52
+ * @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata, not to approval or authorization steps; omitted by default.
52
53
  * @param params.deployless - Optional shared intent field; unused because withdrawal reads no token metadata.
53
54
  * @returns A deep-frozen, data-only `{ version, chainId, account, expiresAt, steps, signatureRequests, calldataOrigin? }` plan with a withdrawal step. Direct Morpho authorization is a preceding step; signed authorization is consumed inline by the withdrawal. Attach signatures before building.
54
55
  * @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
@@ -79,7 +80,6 @@ const prepare_js_1 = require("./prepare.js");
79
80
  * @throws {WithdrawSharesExceedSupplyError} when `shares` exceeds the position's supply shares.
80
81
  * @throws {MissingContractCodeError} when registered BlueBundlesV1 or Blue has no deployed code.
81
82
  * @throws {viem.BaseError} when a chain, bytecode, authorization or nonce RPC read fails, or ABI encoding rejects malformed input.
82
- * @throws {UnexpectedRequirementSignatureError} when an authorization requirement returns a nonce that is not a bigint.
83
83
  * @throws {TransactionPlanSignatureMismatchError} when the authorization requirement does not match the prepared account, chain, nonce or deadline.
84
84
  * @example
85
85
  * ```ts
@@ -99,33 +99,65 @@ const prepare_js_1 = require("./prepare.js");
99
99
  * positionData: { chainId: mainnet.id, position },
100
100
  * now: (await client.getBlock()).timestamp,
101
101
  * });
102
- * // plan: { version: 1, chainId, account, expiresAt, steps, signatureRequests }
102
+ * // plan: { version: 2, chainId, account, expiresAt, steps, signatureRequests }
103
103
  * // Sign any pending Morpho authorization request, then build and submit each step in order.
104
104
  * ```
105
105
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
106
106
  */
107
107
  async function prepareBlueWithdraw(client, params) {
108
- const { maxPenalty } = params;
109
- await (0, validateClientChainId_js_1.validateClientChainId)(client, params.chainId);
108
+ const { maxPenalty, chainId, account } = params;
109
+ const supplied = params.reallocations ?? [];
110
+ let reallocations;
111
+ try {
112
+ reallocations = structuredClone(Array.isArray(supplied)
113
+ ? supplied.map((entry) => {
114
+ if (entry === null ||
115
+ typeof entry !== "object" ||
116
+ "withdrawals" in entry ||
117
+ "fee" in entry) {
118
+ return entry;
119
+ }
120
+ const { vault, from, to, assets, penalty } = entry;
121
+ return { vault, from, to, assets, penalty };
122
+ })
123
+ : supplied);
124
+ }
125
+ catch (cause) {
126
+ throw new index_js_1.InvalidVaultV2BlueReallocationShapeError({ cause });
127
+ }
128
+ await (0, validateClientChainId_js_1.validateClientChainId)(client, chainId);
110
129
  const { positionData: snapshot } = params;
111
130
  if (snapshot == null) {
112
131
  throw new index_js_1.MissingAccrualPositionError(params.marketId);
113
132
  }
114
133
  const withdrawals = [];
115
- const { intent: resolvedIntent, steps, signatureRequests, } = await (0, prepare_js_1.prepareBlue)({ client, params }, (intent) => {
134
+ const captured = {
135
+ chainId,
136
+ account,
137
+ marketId: params.marketId,
138
+ marketData: params.marketData,
139
+ positionData: snapshot,
140
+ now: params.now,
141
+ expiresAt: params.expiresAt,
142
+ supportSignature: params.supportSignature,
143
+ referralFee: params.referralFee,
144
+ calldataOrigin: params.calldataOrigin,
145
+ deployless: params.deployless,
146
+ };
147
+ const { intent: resolvedIntent, steps, signatureRequests, } = await (0, prepare_js_1.prepareBlue)({ client, params: captured }, (intent) => {
116
148
  const inputs = {
117
- chainId: params.chainId,
118
- account: params.account,
149
+ chainId,
150
+ account,
119
151
  marketParams: {
120
- loanToken: params.marketData.market.params.loanToken,
121
- collateralToken: params.marketData.market.params.collateralToken,
122
- oracle: params.marketData.market.params.oracle,
123
- irm: params.marketData.market.params.irm,
124
- lltv: params.marketData.market.params.lltv,
152
+ loanToken: captured.marketData.market.params.loanToken,
153
+ collateralToken: captured.marketData.market.params.collateralToken,
154
+ oracle: captured.marketData.market.params.oracle,
155
+ irm: captured.marketData.market.params.irm,
156
+ lltv: captured.marketData.market.params.lltv,
125
157
  },
126
158
  withdrawAssets: "assets" in params ? (params.assets ?? 0n) : 0n,
127
159
  withdrawShares: "shares" in params ? (params.shares ?? 0n) : 0n,
128
- reallocations: params.reallocations ?? [],
160
+ reallocations,
129
161
  ...(maxPenalty !== undefined && { maxPenalty }),
130
162
  deadline: intent.deadline,
131
163
  referralFeePct: intent.referralFeePct,
@@ -157,7 +189,7 @@ async function prepareBlueWithdraw(client, params) {
157
189
  positionData,
158
190
  withdrawShares: inputs.withdrawShares,
159
191
  withdrawAssets: inputs.withdrawAssets,
160
- marketId: params.marketId,
192
+ marketId: captured.marketId,
161
193
  });
162
194
  withdrawals.push({
163
195
  id: "blueWithdraw",
@@ -166,14 +198,8 @@ async function prepareBlueWithdraw(client, params) {
166
198
  });
167
199
  return { id: "blueWithdraw", needsAuthorization: true };
168
200
  });
169
- return (0, morpho_ts_1.deepFreeze)(structuredClone({
170
- version: 2,
171
- chainId: params.chainId,
172
- account: params.account,
173
- expiresAt: resolvedIntent.expiresAt,
174
- ...(resolvedIntent.calldataOrigin && {
175
- calldataOrigin: resolvedIntent.calldataOrigin,
176
- }),
201
+ return (0, assemble_js_1.freezePlan)({
202
+ ...(0, assemble_js_1.planHeader)({ chainId, account }, resolvedIntent),
177
203
  steps: [
178
204
  ...steps,
179
205
  ...withdrawals.map((step) => {
@@ -196,7 +222,7 @@ async function prepareBlueWithdraw(client, params) {
196
222
  }),
197
223
  ],
198
224
  signatureRequests,
199
- }));
225
+ }, { detach: true });
200
226
  }
201
227
  /** @internal Binds an inline authorization to the withdrawal that consumes it. */
202
228
  function validateBlueWithdrawAuthorizationRequest(request, action) {
@@ -250,7 +276,7 @@ function buildBlueWithdraw(action, requests = []) {
250
276
  },
251
277
  };
252
278
  }
253
- const targetMarketParams = new blue_sdk_1.MarketParams(marketParams);
279
+ const targetMarketParams = toEncoderMarketParams(marketParams);
254
280
  // Reject malformed entries with typed errors before reading their source fields.
255
281
  (0, validate_js_1.validateVaultV2BlueReallocations)(args.reallocations, {
256
282
  targetMarketId: targetMarketParams.id,
@@ -261,7 +287,7 @@ function buildBlueWithdraw(action, requests = []) {
261
287
  from: entry.from.type === "market"
262
288
  ? {
263
289
  ...entry.from,
264
- marketParams: new blue_sdk_1.MarketParams(entry.from.marketParams),
290
+ marketParams: toEncoderMarketParams(entry.from.marketParams),
265
291
  }
266
292
  : entry.from,
267
293
  }));
@@ -275,6 +301,15 @@ function buildBlueWithdraw(action, requests = []) {
275
301
  },
276
302
  });
277
303
  }
304
+ function toEncoderMarketParams(marketParams) {
305
+ const { loanToken, collateralToken, oracle, irm, lltv } = marketParams;
306
+ const tuple = { loanToken, collateralToken, oracle, irm, lltv };
307
+ return {
308
+ ...tuple,
309
+ id: blue_sdk_1.MarketUtils.getMarketId(tuple),
310
+ liquidationIncentiveFactor: blue_sdk_1.MarketUtils.getLiquidationIncentiveFactor(tuple),
311
+ };
312
+ }
278
313
  /** @internal Validates stored withdrawal scalars and allocator input shapes. */
279
314
  function validateBlueWithdrawPlanAction(action, path) {
280
315
  const inputs = (0, validation_js_1.getPlanObject)(action.inputs, `${path}.inputs`);
@@ -300,60 +335,13 @@ function validateBlueWithdrawPlanAction(action, path) {
300
335
  fields: {
301
336
  withdrawAssets: "uint256 bigint",
302
337
  withdrawShares: "uint256 bigint",
303
- deadline: "uint256 bigint",
304
- referralFeePct: "uint256 bigint",
305
- referralFeeRecipient: "address",
338
+ ...stored_js_1.BUNDLES_COMMON_FIELDS,
306
339
  reallocations: "array",
307
340
  },
308
341
  });
309
- (0, validation_js_1.validatePlanFields)((0, validation_js_1.getPlanObject)(inputs.marketParams, `${path}.inputs.marketParams`), {
310
- path: `${path}.inputs.marketParams`,
311
- fields: {
312
- loanToken: "address",
313
- collateralToken: "address",
314
- oracle: "address",
315
- irm: "address",
316
- lltv: "uint256 bigint",
317
- },
342
+ (0, stored_js_1.validateStoredBlueMarketParams)(inputs.marketParams, `${path}.inputs.marketParams`);
343
+ (0, stored_js_1.validateStoredReallocations)(inputs.reallocations, {
344
+ path: `${path}.inputs.reallocations`,
345
+ marketParams: stored_js_1.validateStoredBlueMarketParams,
318
346
  });
319
- for (const [index, value] of inputs.reallocations.entries()) {
320
- const entryPath = `${path}.inputs.reallocations[${index}]`;
321
- const entry = (0, validation_js_1.getPlanObject)(value, entryPath);
322
- (0, validation_js_1.validatePlanFields)(entry, {
323
- path: entryPath,
324
- fields: {
325
- vault: "address",
326
- assets: "uint256 bigint",
327
- penalty: "uint256 bigint",
328
- },
329
- });
330
- (0, validation_js_1.validatePlanFields)((0, validation_js_1.getPlanObject)(entry.to, `${entryPath}.to`), {
331
- path: `${entryPath}.to`,
332
- fields: { adapter: "address" },
333
- });
334
- const from = (0, validation_js_1.getPlanObject)(entry.from, `${entryPath}.from`);
335
- if (from.type === "idle") {
336
- continue;
337
- }
338
- if (from.type !== "market") {
339
- throw new error_js_1.InvalidTransactionPlanError({
340
- path: `${entryPath}.from.type`,
341
- reason: "expected market or idle",
342
- });
343
- }
344
- (0, validation_js_1.validatePlanFields)(from, {
345
- path: `${entryPath}.from`,
346
- fields: { adapter: "address" },
347
- });
348
- (0, validation_js_1.validatePlanFields)((0, validation_js_1.getPlanObject)(from.marketParams, `${entryPath}.from.marketParams`), {
349
- path: `${entryPath}.from.marketParams`,
350
- fields: {
351
- loanToken: "address",
352
- collateralToken: "address",
353
- oracle: "address",
354
- irm: "address",
355
- lltv: "uint256 bigint",
356
- },
357
- });
358
- }
359
347
  }
@@ -48,7 +48,7 @@ export interface BlueWithdrawCollateralPlanParams extends IntentParams, Referenc
48
48
  * @param params.supportSignature - Optional Morpho authorization signature preference, defaulting to `false`; otherwise prepares a direct authorization transaction when needed.
49
49
  * @param params.now - Optional reference timestamp in Unix seconds, normally the latest block timestamp; defaults to the device clock.
50
50
  * @param params.expiresAt - Optional safe-integer Unix expiry later than `now`; defaults to `now + 2h` and governs every deadline.
51
- * @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended verbatim to every built transaction.
51
+ * @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended verbatim to the action transaction's calldata; approval and authorization steps carry none.
52
52
  * @param params.deployless - Optional shared intent field; unused because this operation reads no token metadata or allowances.
53
53
  * @returns A deep-frozen, data-only `TransactionPlan` with chain, account, expiry, withdrawal step,
54
54
  * and any preceding Morpho authorization step and signature request. The caller signs; the SDK never does.
@@ -74,7 +74,6 @@ export interface BlueWithdrawCollateralPlanParams extends IntentParams, Referenc
74
74
  * @throws {viem.BaseError} when a contract-code, chain ID, authorization or nonce RPC read fails.
75
75
  * @example
76
76
  * ```ts
77
- * import assert from "node:assert/strict";
78
77
  * import { markets } from "@morpho-org/morpho-test";
79
78
  * import { fetchAccrualPosition } from "@morpho-org/morpho-sdk/blue/fetch";
80
79
  * import {
@@ -89,7 +88,7 @@ export interface BlueWithdrawCollateralPlanParams extends IntentParams, Referenc
89
88
  * if (!ethereum) throw new Error("Install an Ethereum wallet to continue.");
90
89
  * const wallet = createWalletClient({ chain: mainnet, transport: custom(ethereum) });
91
90
  * const [account] = await wallet.requestAddresses();
92
- * assert(account, "Connect a wallet holding collateral in this market.");
91
+ * if (!account) throw new Error("Connect a wallet holding collateral in this market.");
93
92
  * const market = markets[mainnet.id].usdc_wbtc;
94
93
  * const position = await fetchAccrualPosition(account, market.id, client);
95
94
  * const plan = await prepareBlueWithdrawCollateral(client, {
@@ -12,10 +12,12 @@ const constant_js_1 = require("../../helpers/constant.js");
12
12
  const getBlueBundlesV1QuoteTimestamp_js_1 = require("../../helpers/getBlueBundlesV1QuoteTimestamp.js");
13
13
  const validate_js_1 = require("../../helpers/validate.js");
14
14
  const index_js_1 = require("../../types/index.js");
15
+ const assemble_js_1 = require("../assemble.js");
15
16
  const error_js_1 = require("../error.js");
16
17
  const validation_js_1 = require("../validation.js");
17
18
  const authorization_js_1 = require("./authorization.js");
18
19
  const prepare_js_1 = require("./prepare.js");
20
+ const stored_js_1 = require("./stored.js");
19
21
  /**
20
22
  * Prepares a BlueBundlesV1 collateral withdrawal with direct or inline signed Morpho authorization.
21
23
  * Health uses the expiry floored at max(now, lastUpdate), with the entity's LLTV buffer.
@@ -36,7 +38,7 @@ const prepare_js_1 = require("./prepare.js");
36
38
  * @param params.supportSignature - Optional Morpho authorization signature preference, defaulting to `false`; otherwise prepares a direct authorization transaction when needed.
37
39
  * @param params.now - Optional reference timestamp in Unix seconds, normally the latest block timestamp; defaults to the device clock.
38
40
  * @param params.expiresAt - Optional safe-integer Unix expiry later than `now`; defaults to `now + 2h` and governs every deadline.
39
- * @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended verbatim to every built transaction.
41
+ * @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended verbatim to the action transaction's calldata; approval and authorization steps carry none.
40
42
  * @param params.deployless - Optional shared intent field; unused because this operation reads no token metadata or allowances.
41
43
  * @returns A deep-frozen, data-only `TransactionPlan` with chain, account, expiry, withdrawal step,
42
44
  * and any preceding Morpho authorization step and signature request. The caller signs; the SDK never does.
@@ -62,7 +64,6 @@ const prepare_js_1 = require("./prepare.js");
62
64
  * @throws {viem.BaseError} when a contract-code, chain ID, authorization or nonce RPC read fails.
63
65
  * @example
64
66
  * ```ts
65
- * import assert from "node:assert/strict";
66
67
  * import { markets } from "@morpho-org/morpho-test";
67
68
  * import { fetchAccrualPosition } from "@morpho-org/morpho-sdk/blue/fetch";
68
69
  * import {
@@ -77,7 +78,7 @@ const prepare_js_1 = require("./prepare.js");
77
78
  * if (!ethereum) throw new Error("Install an Ethereum wallet to continue.");
78
79
  * const wallet = createWalletClient({ chain: mainnet, transport: custom(ethereum) });
79
80
  * const [account] = await wallet.requestAddresses();
80
- * assert(account, "Connect a wallet holding collateral in this market.");
81
+ * if (!account) throw new Error("Connect a wallet holding collateral in this market.");
81
82
  * const market = markets[mainnet.id].usdc_wbtc;
82
83
  * const position = await fetchAccrualPosition(account, market.id, client);
83
84
  * const plan = await prepareBlueWithdrawCollateral(client, {
@@ -98,10 +99,25 @@ const prepare_js_1 = require("./prepare.js");
98
99
  */
99
100
  async function prepareBlueWithdrawCollateral(client, params) {
100
101
  const now = params.now ?? morpho_ts_1.Time.timestamp();
101
- const { chainId, account, collateralAssets, marketId } = params;
102
- const { loanToken, collateralToken, oracle, irm, lltv } = params.marketData.market.params;
102
+ const { chainId, account, collateralAssets, marketId, marketData, positionData, expiresAt, supportSignature, referralFee, calldataOrigin, deployless, } = params;
103
+ const { loanToken, collateralToken, oracle, irm, lltv } = marketData.market.params;
103
104
  const marketParams = { loanToken, collateralToken, oracle, irm, lltv };
104
- const { intent, steps, signatureRequests, morphoAuthorizationRequestId } = await (0, prepare_js_1.prepareBlue)({ client, params: { ...params, now } }, (resolvedIntent) => {
105
+ const { intent, steps, signatureRequests, morphoAuthorizationRequestId } = await (0, prepare_js_1.prepareBlue)({
106
+ client,
107
+ params: {
108
+ chainId,
109
+ account,
110
+ marketId,
111
+ marketData,
112
+ positionData,
113
+ now,
114
+ expiresAt,
115
+ supportSignature,
116
+ referralFee,
117
+ calldataOrigin,
118
+ deployless,
119
+ },
120
+ }, (resolvedIntent) => {
105
121
  // Reject invalid fees and deadlines before authorization reads.
106
122
  (0, common_js_1.normalizeBundlesCommonParams)(resolvedIntent);
107
123
  if (collateralAssets <= 0n) {
@@ -109,7 +125,7 @@ async function prepareBlueWithdrawCollateral(client, params) {
109
125
  }
110
126
  // Reject amounts outside the ABI range before reading authorization state.
111
127
  (0, validate_js_1.validateUint256Field)("collateralAssets", collateralAssets);
112
- const position = params.positionData.position;
128
+ const { position } = positionData;
113
129
  // Validate health against the same accrual horizon used by the existing handle.
114
130
  (0, validate_js_1.validatePositionHealthAfterWithdraw)({
115
131
  positionData: position.borrowShares === 0n
@@ -125,12 +141,8 @@ async function prepareBlueWithdrawCollateral(client, params) {
125
141
  });
126
142
  return { id: "blueWithdrawCollateral", needsAuthorization: true };
127
143
  });
128
- return (0, morpho_ts_1.deepFreeze)({
129
- version: 2,
130
- chainId,
131
- account,
132
- expiresAt: intent.expiresAt,
133
- ...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
144
+ return (0, assemble_js_1.freezePlan)({
145
+ ...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
134
146
  steps: [
135
147
  ...steps,
136
148
  {
@@ -138,9 +150,9 @@ async function prepareBlueWithdrawCollateral(client, params) {
138
150
  label: "Withdraw Blue collateral",
139
151
  action: {
140
152
  type: "blueWithdrawCollateral",
141
- signatureRequestIds: morphoAuthorizationRequestId === undefined
142
- ? {}
143
- : { morphoAuthorization: morphoAuthorizationRequestId },
153
+ signatureRequestIds: (0, stored_js_1.signatureRoles)({
154
+ morphoAuthorization: morphoAuthorizationRequestId,
155
+ }),
144
156
  inputs: {
145
157
  chainId,
146
158
  account,
@@ -158,7 +170,7 @@ async function prepareBlueWithdrawCollateral(client, params) {
158
170
  },
159
171
  ],
160
172
  signatureRequests,
161
- });
173
+ }, { detach: false });
162
174
  }
163
175
  /** @internal Binds an inline authorization to the collateral withdrawal that consumes it. */
164
176
  function validateBlueWithdrawCollateralAuthorizationRequest(request, action) {
@@ -236,19 +248,8 @@ function validateBlueWithdrawCollateralPlanAction(action, path) {
236
248
  fields: {
237
249
  collateralAssets: "uint256 bigint",
238
250
  maxLtv: "uint256 bigint",
239
- deadline: "uint256 bigint",
240
- referralFeePct: "uint256 bigint",
241
- referralFeeRecipient: "address",
242
- },
243
- });
244
- (0, validation_js_1.validatePlanFields)((0, validation_js_1.getPlanObject)(inputs.marketParams, `${path}.inputs.marketParams`), {
245
- path: `${path}.inputs.marketParams`,
246
- fields: {
247
- loanToken: "address",
248
- collateralToken: "address",
249
- oracle: "address",
250
- irm: "address",
251
- lltv: "uint256 bigint",
251
+ ...stored_js_1.BUNDLES_COMMON_FIELDS,
252
252
  },
253
253
  });
254
+ (0, stored_js_1.validateStoredBlueMarketParams)(inputs.marketParams, `${path}.inputs.marketParams`);
254
255
  }
@@ -10,6 +10,7 @@ const assertContractCode_js_1 = require("../entities/requirements/assertContract
10
10
  const index_js_1 = require("../helpers/index.js");
11
11
  const validate_js_1 = require("../helpers/validate.js");
12
12
  const index_js_2 = require("../types/index.js");
13
+ const assemble_js_1 = require("./assemble.js");
13
14
  const error_js_1 = require("./error.js");
14
15
  const intent_js_1 = require("./intent.js");
15
16
  const requirements_js_1 = require("./requirements.js");
@@ -99,12 +100,8 @@ async function prepareVaultDeposit(client, params) {
99
100
  ]);
100
101
  const approvals = requirements?.approvals ?? [];
101
102
  const signatureRequests = requirements?.permit === undefined ? [] : [requirements.permit];
102
- return (0, morpho_ts_1.deepFreeze)(structuredClone({
103
- version: 2,
104
- account,
105
- chainId,
106
- expiresAt: intent.expiresAt,
107
- ...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
103
+ return (0, assemble_js_1.freezePlan)({
104
+ ...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
108
105
  steps: [
109
106
  ...approvals,
110
107
  {
@@ -128,5 +125,5 @@ async function prepareVaultDeposit(client, params) {
128
125
  },
129
126
  ],
130
127
  signatureRequests,
131
- }));
128
+ }, { detach: true });
132
129
  }
@@ -29,7 +29,7 @@ export interface IntentParams {
29
29
  readonly supportSignature?: boolean;
30
30
  /** Unix seconds. Defaults to two hours from now. */
31
31
  readonly expiresAt?: number;
32
- /** Optional attribution bytes (at most 1 MiB) appended verbatim to every built transaction's calldata. */
32
+ /** Optional attribution bytes (at most 1 MiB) appended verbatim to the action transaction's calldata; ERC-20 approval, Morpho authorization and Midnight authorization steps carry none. */
33
33
  readonly calldataOrigin?: Hex;
34
34
  /** Whether token metadata reads for permits may use deployless aggregation. */
35
35
  readonly deployless?: boolean;
@@ -28,7 +28,7 @@ export type MidnightMakeBorrowPlanParams = MidnightMakerPublicationPlanParams;
28
28
  * Omitting it cancels nothing (an untyped JavaScript `null` does too).
29
29
  * @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
30
30
  * @param params.expiresAt - Unix seconds. Defaults to the earlier of `now + 2h` and the first offer expiry minus one second.
31
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
31
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
32
32
  * @returns A frozen plan with persisted publication data that can be restored and built offline.
33
33
  * @throws {InvalidBigIntInputError} If a supplied non-null `now` or a cancellation ceiling is not a bigint; checked before any request.
34
34
  * @throws {ZeroAccountError} If the submitting account is zero.
@@ -27,7 +27,7 @@ const prepare_js_1 = require("./prepare.js");
27
27
  * Omitting it cancels nothing (an untyped JavaScript `null` does too).
28
28
  * @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
29
29
  * @param params.expiresAt - Unix seconds. Defaults to the earlier of `now + 2h` and the first offer expiry minus one second.
30
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
30
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
31
31
  * @returns A frozen plan with persisted publication data that can be restored and built offline.
32
32
  * @throws {InvalidBigIntInputError} If a supplied non-null `now` or a cancellation ceiling is not a bigint; checked before any request.
33
33
  * @throws {ZeroAccountError} If the submitting account is zero.
@@ -40,7 +40,7 @@ export interface MidnightMakeLendPlanParams extends MidnightMakerPublicationPlan
40
40
  * @param params.reservedLoanAssets - Optional loan assets reserved by other open groups, excluding cancelled groups; defaults to `0n`.
41
41
  * @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
42
42
  * @param params.expiresAt - Unix seconds. Defaults to the earlier of `now + 2h` and the first offer expiry minus one second.
43
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
43
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
44
44
  * @returns A frozen, signature-free plan whose publication payload can be built offline.
45
45
  * @throws {InvalidBigIntInputError} If `loanAssets`, a cancellation ceiling, or a supplied non-null `now`
46
46
  * or `reservedLoanAssets` is not a bigint; checked before any request.
@@ -34,7 +34,7 @@ const prepare_js_1 = require("./prepare.js");
34
34
  * @param params.reservedLoanAssets - Optional loan assets reserved by other open groups, excluding cancelled groups; defaults to `0n`.
35
35
  * @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
36
36
  * @param params.expiresAt - Unix seconds. Defaults to the earlier of `now + 2h` and the first offer expiry minus one second.
37
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
37
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
38
38
  * @returns A frozen, signature-free plan whose publication payload can be built offline.
39
39
  * @throws {InvalidBigIntInputError} If `loanAssets`, a cancellation ceiling, or a supplied non-null `now`
40
40
  * or `reservedLoanAssets` is not a bigint; checked before any request.
@@ -36,7 +36,7 @@ export type MidnightMakeRepayPlanParams = MidnightMakeLendPlanParams;
36
36
  * @param params.reservedLoanAssets - Optional loan assets reserved by other open groups, excluding cancelled groups; defaults to `0n`.
37
37
  * @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
38
38
  * @param params.expiresAt - Unix seconds. Defaults to the earlier of `now + 2h` and the earliest offer expiry minus one second.
39
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
39
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
40
40
  * @returns A frozen, signature-free plan.
41
41
  * @throws {InvalidBigIntInputError} If `loanAssets`, a cancellation ceiling, or a supplied non-null `now`
42
42
  * or `reservedLoanAssets` is not a bigint; checked before any request.
@@ -31,7 +31,7 @@ const makeLend_js_1 = require("./makeLend.js");
31
31
  * @param params.reservedLoanAssets - Optional loan assets reserved by other open groups, excluding cancelled groups; defaults to `0n`.
32
32
  * @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
33
33
  * @param params.expiresAt - Unix seconds. Defaults to the earlier of `now + 2h` and the earliest offer expiry minus one second.
34
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
34
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
35
35
  * @returns A frozen, signature-free plan.
36
36
  * @throws {InvalidBigIntInputError} If `loanAssets`, a cancellation ceiling, or a supplied non-null `now`
37
37
  * or `reservedLoanAssets` is not a bigint; checked before any request.
@@ -76,7 +76,7 @@ export interface MidnightRepayWithdrawCollateralPlanParams extends Pick<IntentPa
76
76
  * @param params.now - Reference time in Unix seconds, normally the latest block's timestamp.
77
77
  * omitting it uses the device clock (an untyped JavaScript `null` does too); that fallback is deprecated.
78
78
  * @param params.expiresAt - Bundle execution deadline in Unix seconds. Defaults to two hours after `now`.
79
- * @param params.calldataOrigin - Optional attribution bytes (at most 1 MiB) appended to each transaction's calldata.
79
+ * @param params.calldataOrigin - Optional attribution bytes (at most 1 MiB) appended to each operation transaction's calldata; approval and authorization steps carry none.
80
80
  * @returns A frozen plan with prerequisite calls first and no signature requests.
81
81
  * @throws {InvalidBigIntInputError} If a supplied non-null `now`, the active repayment amount or a withdrawal's `collateralIndex` or `assets` is not a bigint; checked before any request.
82
82
  * @throws {MarketIdMismatchError} If the position belongs to another market.
@@ -58,7 +58,7 @@ const actionId = "midnightRepayWithdrawCollateral";
58
58
  * @param params.now - Reference time in Unix seconds, normally the latest block's timestamp.
59
59
  * omitting it uses the device clock (an untyped JavaScript `null` does too); that fallback is deprecated.
60
60
  * @param params.expiresAt - Bundle execution deadline in Unix seconds. Defaults to two hours after `now`.
61
- * @param params.calldataOrigin - Optional attribution bytes (at most 1 MiB) appended to each transaction's calldata.
61
+ * @param params.calldataOrigin - Optional attribution bytes (at most 1 MiB) appended to each operation transaction's calldata; approval and authorization steps carry none.
62
62
  * @returns A frozen plan with prerequisite calls first and no signature requests.
63
63
  * @throws {InvalidBigIntInputError} If a supplied non-null `now`, the active repayment amount or a withdrawal's `collateralIndex` or `assets` is not a bigint; checked before any request.
64
64
  * @throws {MarketIdMismatchError} If the position belongs to another market.
@@ -56,7 +56,7 @@ export interface MidnightSupplyBlueMakeLendPlanParams extends MidnightMakerPubli
56
56
  * @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
57
57
  * The share preview uses the pinned block's timestamp instead.
58
58
  * @param params.expiresAt - Unix seconds. Defaults to the earlier of now + 2 hours and one second before the first offer expiry.
59
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
59
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
60
60
  * @returns A frozen plan with opaque publication bytes, buildable without the tree or API.
61
61
  * @throws {InvalidBigIntInputError} If a supplied non-null `now` is not a bigint; checked first.
62
62
  * @throws {ZeroAccountError} If the submitting account is zero.
@@ -48,7 +48,7 @@ const actionId = "midnightSupplyBlueMakeLend";
48
48
  * @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
49
49
  * The share preview uses the pinned block's timestamp instead.
50
50
  * @param params.expiresAt - Unix seconds. Defaults to the earlier of now + 2 hours and one second before the first offer expiry.
51
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
51
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
52
52
  * @returns A frozen plan with opaque publication bytes, buildable without the tree or API.
53
53
  * @throws {InvalidBigIntInputError} If a supplied non-null `now` is not a bigint; checked first.
54
54
  * @throws {ZeroAccountError} If the submitting account is zero.
@@ -39,7 +39,7 @@ export interface MidnightSupplyCollateralPlanParams extends Pick<IntentParams, "
39
39
  * @param params.collateralAssets - Positive collateral quantity in token base units.
40
40
  * @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
41
41
  * @param params.expiresAt - Plan expiry in Unix seconds; defaults to two hours after `now`. Midnight does not enforce it onchain.
42
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
42
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
43
43
  * @returns A frozen plan whose steps must be submitted in order from `params.account`.
44
44
  * @throws {InvalidBigIntInputError} when a supplied non-null `now`, the collateral amount or the index
45
45
  * is not a bigint.
@@ -32,7 +32,7 @@ const actionId = "midnightSupplyCollateral";
32
32
  * @param params.collateralAssets - Positive collateral quantity in token base units.
33
33
  * @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
34
34
  * @param params.expiresAt - Plan expiry in Unix seconds; defaults to two hours after `now`. Midnight does not enforce it onchain.
35
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
35
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
36
36
  * @returns A frozen plan whose steps must be submitted in order from `params.account`.
37
37
  * @throws {InvalidBigIntInputError} when a supplied non-null `now`, the collateral amount or the index
38
38
  * is not a bigint.
@@ -54,7 +54,7 @@ export interface MidnightSupplyCollateralBatchPlanParams extends Pick<IntentPara
54
54
  * @param params.collateralSupplies - Nonempty ordered supplies, one per collateral index.
55
55
  * @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
56
56
  * @param params.expiresAt - Plan expiry in Unix seconds; defaults to two hours after `now`. Midnight does not enforce it onchain.
57
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
57
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
58
58
  * @returns A frozen plan whose approval steps, if any, precede the multicall step; send them in order from `params.account`.
59
59
  * @throws {InvalidBigIntInputError} If a supplied non-null `now`, or a supply's `collateralIndex` or `assets`, is not a bigint; checked before any request.
60
60
  * @throws {ZeroAccountError} If the account is the zero address.
@@ -42,7 +42,7 @@ const actionId = "midnightSupplyCollateralBatch";
42
42
  * @param params.collateralSupplies - Nonempty ordered supplies, one per collateral index.
43
43
  * @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
44
44
  * @param params.expiresAt - Plan expiry in Unix seconds; defaults to two hours after `now`. Midnight does not enforce it onchain.
45
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
45
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
46
46
  * @returns A frozen plan whose approval steps, if any, precede the multicall step; send them in order from `params.account`.
47
47
  * @throws {InvalidBigIntInputError} If a supplied non-null `now`, or a supply's `collateralIndex` or `assets`, is not a bigint; checked before any request.
48
48
  * @throws {ZeroAccountError} If the account is the zero address.
@@ -42,7 +42,7 @@ export interface MidnightSupplyCollateralMakeBorrowPlanParams extends MidnightMa
42
42
  * @param params.nativeAmount - Optional native ETH in wei, capped by the wrapped-native collateral pull.
43
43
  * @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
44
44
  * @param params.expiresAt - Unix seconds. The default is the earlier of now + 2 hours and the first offer expiry minus one second.
45
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
45
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
46
46
  * @returns A frozen plan that builds offline from saved steps and opaque offer payload bytes.
47
47
  * @throws {InvalidBigIntInputError} If a supplied non-null `now`, a cancellation ceiling, or a collateral
48
48
  * index or amount is not a bigint; checked before any request.
@@ -35,7 +35,7 @@ const actionId = "midnightSupplyCollateralMakeBorrow";
35
35
  * @param params.nativeAmount - Optional native ETH in wei, capped by the wrapped-native collateral pull.
36
36
  * @param params.now - Reference Unix timestamp in seconds for plan expiry; omitting it uses the device clock (an untyped JavaScript `null` does too).
37
37
  * @param params.expiresAt - Unix seconds. The default is the earlier of now + 2 hours and the first offer expiry minus one second.
38
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
38
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
39
39
  * @returns A frozen plan that builds offline from saved steps and opaque offer payload bytes.
40
40
  * @throws {InvalidBigIntInputError} If a supplied non-null `now`, a cancellation ceiling, or a collateral
41
41
  * index or amount is not a bigint; checked before any request.
@@ -50,7 +50,7 @@ export interface MidnightSupplyCollateralWithNativePlanParams extends Pick<Inten
50
50
  * @param params.nativeAmount - Positive native funding in wei, at most `collateralAssets`; any rest is pulled as wNative.
51
51
  * @param params.now - Reference Unix timestamp in seconds; omitting it uses the device clock (an untyped JavaScript `null` does too).
52
52
  * @param params.expiresAt - Bundle execution deadline in Unix seconds; defaults to two hours after `now`.
53
- * @param params.calldataOrigin - Optional attribution bytes appended to each built transaction.
53
+ * @param params.calldataOrigin - Optional attribution bytes appended to each operation transaction's calldata; approval and authorization steps carry none.
54
54
  * @returns A frozen plan whose steps must be submitted in order from `params.account`.
55
55
  * @throws {InvalidBigIntInputError} If a supplied non-null `now`, the collateral amount or the index is not a bigint; checked before any request.
56
56
  * @throws {ZeroAccountError} If the account is the zero address.