@morpho-org/morpho-sdk 10.0.0-next.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/README.md +104 -12
  2. package/lib/cjs/abis.d.ts +1 -1
  3. package/lib/cjs/abis.js +1 -5
  4. package/lib/cjs/actions/blue/common.js +4 -2
  5. package/lib/cjs/actions/blue/withdrawBuyCallback.js +2 -1
  6. package/lib/cjs/actions/bundles/common.js +20 -14
  7. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +2 -1
  8. package/lib/cjs/actions/midnight/cancelOffers.js +2 -1
  9. package/lib/cjs/actions/midnight/supplyCollateralBatch.js +4 -2
  10. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +2 -1
  11. package/lib/cjs/actions/midnight/takeBorrow.js +2 -1
  12. package/lib/cjs/actions/midnight/takeLend.js +2 -1
  13. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +2 -1
  14. package/lib/cjs/actions/midnight/takeWithdraw.js +2 -1
  15. package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +4 -2
  16. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +2 -11
  17. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +2 -1
  18. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +2 -1
  19. package/lib/cjs/actions/vaultV1/inKindRedeem.js +6 -3
  20. package/lib/cjs/actions/vaultV1/migrateToV2.js +1 -1
  21. package/lib/cjs/actions/vaultV2/forceWithdraw.js +4 -2
  22. package/lib/cjs/actions/vaultV2/inKindRedeem.js +4 -2
  23. package/lib/cjs/blue/abis.d.ts +1 -1
  24. package/lib/cjs/blue/abis.js +1 -5
  25. package/lib/cjs/blue/entities.d.ts +4 -4
  26. package/lib/cjs/blue/entities.js +1 -3
  27. package/lib/cjs/blue/errors.d.ts +2 -2
  28. package/lib/cjs/blue/errors.js +1 -5
  29. package/lib/cjs/blue/fetch.d.ts +2 -2
  30. package/lib/cjs/blue/fetch.js +1 -3
  31. package/lib/cjs/blue/utils.d.ts +1 -1
  32. package/lib/cjs/blue/utils.js +1 -2
  33. package/lib/cjs/entities/blue/blue.js +8 -4
  34. package/lib/cjs/entities/index.d.ts +4 -4
  35. package/lib/cjs/entities/index.js +1 -3
  36. package/lib/cjs/entities/midnight/deadline.js +2 -1
  37. package/lib/cjs/entities/midnight/midnight.js +14 -7
  38. package/lib/cjs/entities/midnight/publication.js +73 -44
  39. package/lib/cjs/entities/requirements/assertContractCode.js +4 -2
  40. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +9 -13
  41. package/lib/cjs/entities/requirements/getErc2612Permit.js +10 -5
  42. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +2 -0
  43. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +7 -1
  44. package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.d.ts +21 -0
  45. package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.js +111 -0
  46. package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.d.ts +20 -0
  47. package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.js +76 -0
  48. package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.d.ts +21 -0
  49. package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.js +93 -0
  50. package/lib/cjs/entities/vaultV1/inKindRedeemQuote.d.ts +25 -0
  51. package/lib/cjs/entities/vaultV1/inKindRedeemQuote.js +85 -0
  52. package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +20 -0
  53. package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +37 -0
  54. package/lib/cjs/entities/vaultV1/vaultV1.js +51 -181
  55. package/lib/cjs/entities/vaultV2/forceWithdrawQuote.d.ts +25 -0
  56. package/lib/cjs/entities/vaultV2/forceWithdrawQuote.js +189 -0
  57. package/lib/cjs/entities/vaultV2/inKindRedeemQuote.d.ts +28 -0
  58. package/lib/cjs/entities/vaultV2/inKindRedeemQuote.js +110 -0
  59. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +8 -34
  60. package/lib/cjs/entities/vaultV2/vaultV2.js +62 -429
  61. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +2 -3
  62. package/lib/cjs/entities/vaultV2BlueReallocationData.js +346 -234
  63. package/lib/cjs/errors.d.ts +4 -4
  64. package/lib/cjs/errors.js +6 -7
  65. package/lib/cjs/fetch.d.ts +2 -2
  66. package/lib/cjs/fetch.js +1 -3
  67. package/lib/cjs/helpers/deadShares.js +34 -19
  68. package/lib/cjs/helpers/encodeMidnightCalldata.js +4 -2
  69. package/lib/cjs/helpers/metadata.js +12 -6
  70. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +10 -5
  71. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +6 -3
  72. package/lib/cjs/helpers/utilization.js +10 -5
  73. package/lib/cjs/helpers/validate.js +12 -6
  74. package/lib/cjs/helpers/validateMidnightBounds.js +2 -1
  75. package/lib/cjs/helpers/validateMidnightCollateralBatch.js +2 -1
  76. package/lib/cjs/helpers/validateMidnightPublication.js +4 -2
  77. package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +44 -22
  78. package/lib/cjs/helpers/validatePositiveInput.js +2 -1
  79. package/lib/cjs/helpers/validateTakeableOffers.js +2 -1
  80. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +14 -7
  81. package/lib/cjs/index.d.ts +2 -2
  82. package/lib/cjs/index.js +10 -1
  83. package/lib/cjs/midnight/errors.d.ts +1 -2
  84. package/lib/cjs/midnight/errors.js +4 -5
  85. package/lib/cjs/transactionPlan/approval.js +12 -1
  86. package/lib/cjs/transactionPlan/deposit.d.ts +22 -0
  87. package/lib/cjs/transactionPlan/deposit.js +139 -0
  88. package/lib/cjs/transactionPlan/error.d.ts +10 -8
  89. package/lib/cjs/transactionPlan/error.js +10 -8
  90. package/lib/cjs/transactionPlan/getTokenPermit.js +2 -1
  91. package/lib/cjs/transactionPlan/index.d.ts +18 -0
  92. package/lib/cjs/transactionPlan/index.js +23 -5
  93. package/lib/cjs/transactionPlan/intent.d.ts +3 -3
  94. package/lib/cjs/transactionPlan/intent.js +14 -7
  95. package/lib/cjs/transactionPlan/permit.d.ts +1 -1
  96. package/lib/cjs/transactionPlan/permit.js +86 -20
  97. package/lib/cjs/transactionPlan/plan.d.ts +16 -6
  98. package/lib/cjs/transactionPlan/plan.js +72 -22
  99. package/lib/cjs/transactionPlan/redeem.d.ts +18 -0
  100. package/lib/cjs/transactionPlan/redeem.js +63 -0
  101. package/lib/cjs/transactionPlan/requirements.d.ts +4 -3
  102. package/lib/cjs/transactionPlan/requirements.js +12 -6
  103. package/lib/cjs/transactionPlan/serde.d.ts +2 -2
  104. package/lib/cjs/transactionPlan/serde.js +41 -15
  105. package/lib/cjs/transactionPlan/shareSpending.d.ts +18 -0
  106. package/lib/cjs/transactionPlan/shareSpending.js +50 -0
  107. package/lib/cjs/transactionPlan/types.d.ts +117 -11
  108. package/lib/cjs/transactionPlan/validateActions.js +11 -1
  109. package/lib/cjs/transactionPlan/validation.js +6 -3
  110. package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +93 -0
  111. package/lib/cjs/transactionPlan/vaultv1/deposit.js +94 -0
  112. package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.d.ts +96 -0
  113. package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.js +203 -0
  114. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +94 -0
  115. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +217 -0
  116. package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +69 -0
  117. package/lib/cjs/transactionPlan/vaultv1/redeem.js +78 -0
  118. package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +77 -0
  119. package/lib/cjs/transactionPlan/vaultv1/withdraw.js +88 -0
  120. package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +14 -31
  121. package/lib/cjs/transactionPlan/vaultv2/deposit.js +15 -141
  122. package/lib/cjs/transactionPlan/vaultv2/forceRedeem.d.ts +74 -0
  123. package/lib/cjs/transactionPlan/vaultv2/forceRedeem.js +155 -0
  124. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +98 -0
  125. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +206 -0
  126. package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.d.ts +113 -0
  127. package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.js +206 -0
  128. package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +84 -0
  129. package/lib/cjs/transactionPlan/vaultv2/redeem.js +86 -0
  130. package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +14 -27
  131. package/lib/cjs/transactionPlan/vaultv2/withdraw.js +17 -124
  132. package/lib/cjs/transactionPlan/version.js +2 -1
  133. package/lib/cjs/transactionPlan/withdraw.d.ts +18 -0
  134. package/lib/cjs/transactionPlan/withdraw.js +94 -0
  135. package/lib/cjs/types/action.js +16 -8
  136. package/lib/cjs/types/error.d.ts +8 -1
  137. package/lib/cjs/types/error.js +10 -1
  138. package/lib/cjs/utils.d.ts +2 -2
  139. package/lib/cjs/utils.js +2 -4
  140. package/lib/cjs/version.d.ts +1 -1
  141. package/lib/cjs/version.js +1 -1
  142. package/lib/esm/abis.d.ts +1 -1
  143. package/lib/esm/abis.js +1 -1
  144. package/lib/esm/actions/blue/common.js +4 -2
  145. package/lib/esm/actions/blue/withdrawBuyCallback.js +2 -1
  146. package/lib/esm/actions/bundles/common.js +20 -14
  147. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +2 -1
  148. package/lib/esm/actions/midnight/cancelOffers.js +2 -1
  149. package/lib/esm/actions/midnight/supplyCollateralBatch.js +4 -2
  150. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +2 -1
  151. package/lib/esm/actions/midnight/takeBorrow.js +2 -1
  152. package/lib/esm/actions/midnight/takeLend.js +2 -1
  153. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +2 -1
  154. package/lib/esm/actions/midnight/takeWithdraw.js +2 -1
  155. package/lib/esm/actions/midnight/withdrawCollateralBatch.js +4 -2
  156. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +4 -13
  157. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +2 -1
  158. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +2 -1
  159. package/lib/esm/actions/vaultV1/inKindRedeem.js +6 -3
  160. package/lib/esm/actions/vaultV1/migrateToV2.js +1 -1
  161. package/lib/esm/actions/vaultV2/forceWithdraw.js +4 -2
  162. package/lib/esm/actions/vaultV2/inKindRedeem.js +4 -2
  163. package/lib/esm/blue/abis.d.ts +1 -1
  164. package/lib/esm/blue/abis.js +1 -1
  165. package/lib/esm/blue/entities.d.ts +4 -4
  166. package/lib/esm/blue/entities.js +2 -2
  167. package/lib/esm/blue/errors.d.ts +2 -2
  168. package/lib/esm/blue/errors.js +2 -2
  169. package/lib/esm/blue/fetch.d.ts +2 -2
  170. package/lib/esm/blue/fetch.js +2 -2
  171. package/lib/esm/blue/utils.d.ts +1 -1
  172. package/lib/esm/blue/utils.js +1 -1
  173. package/lib/esm/entities/blue/blue.js +8 -4
  174. package/lib/esm/entities/index.d.ts +4 -4
  175. package/lib/esm/entities/index.js +2 -2
  176. package/lib/esm/entities/midnight/deadline.js +2 -1
  177. package/lib/esm/entities/midnight/midnight.js +14 -7
  178. package/lib/esm/entities/midnight/publication.js +73 -44
  179. package/lib/esm/entities/requirements/assertContractCode.js +4 -2
  180. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +10 -14
  181. package/lib/esm/entities/requirements/getErc2612Permit.js +10 -5
  182. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +2 -0
  183. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +7 -1
  184. package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.d.ts +21 -0
  185. package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.js +108 -0
  186. package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.d.ts +20 -0
  187. package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.js +73 -0
  188. package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.d.ts +21 -0
  189. package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.js +90 -0
  190. package/lib/esm/entities/vaultV1/inKindRedeemQuote.d.ts +25 -0
  191. package/lib/esm/entities/vaultV1/inKindRedeemQuote.js +82 -0
  192. package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +20 -0
  193. package/lib/esm/entities/vaultV1/migrateToV2Quote.js +34 -0
  194. package/lib/esm/entities/vaultV1/vaultV1.js +57 -187
  195. package/lib/esm/entities/vaultV2/forceWithdrawQuote.d.ts +25 -0
  196. package/lib/esm/entities/vaultV2/forceWithdrawQuote.js +186 -0
  197. package/lib/esm/entities/vaultV2/inKindRedeemQuote.d.ts +28 -0
  198. package/lib/esm/entities/vaultV2/inKindRedeemQuote.js +107 -0
  199. package/lib/esm/entities/vaultV2/vaultV2.d.ts +8 -34
  200. package/lib/esm/entities/vaultV2/vaultV2.js +70 -437
  201. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +2 -3
  202. package/lib/esm/entities/vaultV2BlueReallocationData.js +346 -234
  203. package/lib/esm/errors.d.ts +4 -4
  204. package/lib/esm/errors.js +4 -4
  205. package/lib/esm/fetch.d.ts +2 -2
  206. package/lib/esm/fetch.js +2 -2
  207. package/lib/esm/helpers/deadShares.js +35 -20
  208. package/lib/esm/helpers/encodeMidnightCalldata.js +4 -2
  209. package/lib/esm/helpers/metadata.js +12 -6
  210. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +10 -5
  211. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +6 -3
  212. package/lib/esm/helpers/utilization.js +10 -5
  213. package/lib/esm/helpers/validate.js +12 -6
  214. package/lib/esm/helpers/validateMidnightBounds.js +2 -1
  215. package/lib/esm/helpers/validateMidnightCollateralBatch.js +2 -1
  216. package/lib/esm/helpers/validateMidnightPublication.js +4 -2
  217. package/lib/esm/helpers/validateMidnightTakeFeasibility.js +44 -22
  218. package/lib/esm/helpers/validatePositiveInput.js +2 -1
  219. package/lib/esm/helpers/validateTakeableOffers.js +2 -1
  220. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +14 -7
  221. package/lib/esm/index.d.ts +2 -2
  222. package/lib/esm/index.js +1 -1
  223. package/lib/esm/midnight/errors.d.ts +1 -2
  224. package/lib/esm/midnight/errors.js +1 -2
  225. package/lib/esm/transactionPlan/approval.js +13 -2
  226. package/lib/esm/transactionPlan/deposit.d.ts +22 -0
  227. package/lib/esm/transactionPlan/deposit.js +135 -0
  228. package/lib/esm/transactionPlan/error.d.ts +10 -8
  229. package/lib/esm/transactionPlan/error.js +10 -8
  230. package/lib/esm/transactionPlan/getTokenPermit.js +2 -1
  231. package/lib/esm/transactionPlan/index.d.ts +18 -0
  232. package/lib/esm/transactionPlan/index.js +9 -0
  233. package/lib/esm/transactionPlan/intent.d.ts +3 -3
  234. package/lib/esm/transactionPlan/intent.js +14 -7
  235. package/lib/esm/transactionPlan/permit.d.ts +1 -1
  236. package/lib/esm/transactionPlan/permit.js +86 -20
  237. package/lib/esm/transactionPlan/plan.d.ts +16 -6
  238. package/lib/esm/transactionPlan/plan.js +68 -18
  239. package/lib/esm/transactionPlan/redeem.d.ts +18 -0
  240. package/lib/esm/transactionPlan/redeem.js +59 -0
  241. package/lib/esm/transactionPlan/requirements.d.ts +4 -3
  242. package/lib/esm/transactionPlan/requirements.js +12 -6
  243. package/lib/esm/transactionPlan/serde.d.ts +2 -2
  244. package/lib/esm/transactionPlan/serde.js +41 -15
  245. package/lib/esm/transactionPlan/shareSpending.d.ts +18 -0
  246. package/lib/esm/transactionPlan/shareSpending.js +47 -0
  247. package/lib/esm/transactionPlan/types.d.ts +117 -11
  248. package/lib/esm/transactionPlan/validateActions.js +11 -1
  249. package/lib/esm/transactionPlan/validation.js +6 -3
  250. package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +93 -0
  251. package/lib/esm/transactionPlan/vaultv1/deposit.js +90 -0
  252. package/lib/esm/transactionPlan/vaultv1/inKindRedeem.d.ts +96 -0
  253. package/lib/esm/transactionPlan/vaultv1/inKindRedeem.js +198 -0
  254. package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +94 -0
  255. package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +212 -0
  256. package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +69 -0
  257. package/lib/esm/transactionPlan/vaultv1/redeem.js +74 -0
  258. package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +77 -0
  259. package/lib/esm/transactionPlan/vaultv1/withdraw.js +84 -0
  260. package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +14 -31
  261. package/lib/esm/transactionPlan/vaultv2/deposit.js +17 -142
  262. package/lib/esm/transactionPlan/vaultv2/forceRedeem.d.ts +74 -0
  263. package/lib/esm/transactionPlan/vaultv2/forceRedeem.js +150 -0
  264. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +98 -0
  265. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +201 -0
  266. package/lib/esm/transactionPlan/vaultv2/inKindRedeem.d.ts +113 -0
  267. package/lib/esm/transactionPlan/vaultv2/inKindRedeem.js +201 -0
  268. package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +84 -0
  269. package/lib/esm/transactionPlan/vaultv2/redeem.js +82 -0
  270. package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +14 -27
  271. package/lib/esm/transactionPlan/vaultv2/withdraw.js +19 -125
  272. package/lib/esm/transactionPlan/version.js +2 -1
  273. package/lib/esm/transactionPlan/withdraw.d.ts +18 -0
  274. package/lib/esm/transactionPlan/withdraw.js +90 -0
  275. package/lib/esm/types/action.js +16 -8
  276. package/lib/esm/types/error.d.ts +8 -1
  277. package/lib/esm/types/error.js +10 -1
  278. package/lib/esm/utils.d.ts +2 -2
  279. package/lib/esm/utils.js +2 -2
  280. package/lib/esm/version.d.ts +1 -1
  281. package/lib/esm/version.js +1 -1
  282. package/package.json +15 -15
@@ -8,17 +8,18 @@ import type { Action, SignatureRequest, Step } from "./types.js";
8
8
  * @returns The unsigned request with a concrete nonce.
9
9
  * @throws {UnexpectedRequirementSignatureError} If the permit requirement has no nonce.
10
10
  */
11
- export declare function buildPermitSignatureRequest(requirement: Requirement<Erc2612RequirementSignature>, id: string): SignatureRequest;
11
+ export declare function buildPermitSignatureRequest(requirement: Pick<Requirement<Erc2612RequirementSignature>, "action">, id: string): SignatureRequest;
12
12
  /**
13
13
  * @internal Converts an approval transaction into a step with prepared chain/account inputs.
14
14
  * @param requirement - Direct token approval prerequisite.
15
- * @param params - Step ID, chain and account selected by the preparer.
15
+ * @param params - Step ID, chain, account and token denomination selected by the preparer.
16
16
  * @returns The approval recipe labeled for token spending.
17
17
  */
18
- export declare function buildApprovalStep(requirement: Readonly<Transaction<ERC20ApprovalAction>>, { id, chainId, account, }: {
18
+ export declare function buildApprovalStep(requirement: Readonly<Transaction<ERC20ApprovalAction>>, { id, chainId, account, denomination, }: {
19
19
  readonly id: string;
20
20
  readonly chainId: number;
21
21
  readonly account: Address;
22
+ readonly denomination: "assets" | "shares";
22
23
  }): Step<Extract<Action, {
23
24
  type: "erc20Approval";
24
25
  }>>;
@@ -12,8 +12,9 @@ import { getTokenPermit } from "./getTokenPermit.js";
12
12
  */
13
13
  export function buildPermitSignatureRequest(requirement, id) {
14
14
  const { nonce, ...args } = requirement.action.args;
15
- if (nonce === undefined)
15
+ if (nonce === undefined) {
16
16
  throw new UnexpectedRequirementSignatureError(requirement.action.type);
17
+ }
17
18
  return {
18
19
  id,
19
20
  kind: "permit",
@@ -24,10 +25,10 @@ export function buildPermitSignatureRequest(requirement, id) {
24
25
  /**
25
26
  * @internal Converts an approval transaction into a step with prepared chain/account inputs.
26
27
  * @param requirement - Direct token approval prerequisite.
27
- * @param params - Step ID, chain and account selected by the preparer.
28
+ * @param params - Step ID, chain, account and token denomination selected by the preparer.
28
29
  * @returns The approval recipe labeled for token spending.
29
30
  */
30
- export function buildApprovalStep(requirement, { id, chainId, account, }) {
31
+ export function buildApprovalStep(requirement, { id, chainId, account, denomination, }) {
31
32
  return {
32
33
  id,
33
34
  label: "Approve token spending",
@@ -35,7 +36,10 @@ export function buildApprovalStep(requirement, { id, chainId, account, }) {
35
36
  type: "erc20Approval",
36
37
  inputs: {
37
38
  token: requirement.to,
38
- ...requirement.action.args,
39
+ spender: requirement.action.args.spender,
40
+ ...(denomination === "assets"
41
+ ? { assets: requirement.action.args.amount }
42
+ : { shares: requirement.action.args.amount }),
39
43
  chainId,
40
44
  account,
41
45
  },
@@ -55,15 +59,17 @@ export async function getTokenRequirements(client, params) {
55
59
  functionName: "allowance",
56
60
  args: [params.owner, params.spender],
57
61
  });
58
- if (allowance >= params.amount)
62
+ if (allowance >= params.amount) {
59
63
  return [];
64
+ }
60
65
  if (params.supportSignature) {
61
66
  const permit = await getTokenPermit(client, {
62
67
  ...params,
63
68
  supportDeployless: params.deployless,
64
69
  });
65
- if (permit !== undefined)
70
+ if (permit !== undefined) {
66
71
  return [permit];
72
+ }
67
73
  }
68
74
  return getRequirementsApproval({
69
75
  address: params.token,
@@ -1,5 +1,6 @@
1
1
  import type { TransactionPlan } from "./types.js";
2
2
  /**
3
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
3
4
  * Serializes plan data with a bigint replacer. No validation is performed.
4
5
  * @param plan - Plan to save.
5
6
  * @returns JSON with `$bigint` tags for bigint quantities.
@@ -8,10 +9,10 @@ import type { TransactionPlan } from "./types.js";
8
9
  * import { serializeTransactionPlan, type TransactionPlan } from "@morpho-org/morpho-sdk";
9
10
  * const save = (plan: TransactionPlan) => serializeTransactionPlan(plan);
10
11
  * ```
11
- * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
12
12
  */
13
13
  export declare function serializeTransactionPlan(plan: TransactionPlan): string;
14
14
  /**
15
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
15
16
  * Restores bigint fields and validates version, action/request shapes, uint256 ranges, unique IDs,
16
17
  * references, per-action chain/account and permit/action consistency, including signed requests.
17
18
  * Extra keys are allowed. No clock or RPC is used: expiry, live state, signature ownership and
@@ -28,6 +29,5 @@ export declare function serializeTransactionPlan(plan: TransactionPlan): string;
28
29
  * import { parseTransactionPlan } from "@morpho-org/morpho-sdk";
29
30
  * const restore = (saved: string) => parseTransactionPlan(saved);
30
31
  * ```
31
- * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
32
32
  */
33
33
  export declare function parseTransactionPlan(json: string): TransactionPlan;
@@ -1,19 +1,35 @@
1
1
  import { isAddressEqual } from "viem";
2
2
  import { validateApprovalPlanAction } from "./approval.js";
3
+ import { validateDepositPlanAction } from "./deposit.js";
3
4
  import { InvalidTransactionPlanError, TransactionPlanSignatureMismatchError, } from "./error.js";
4
5
  import { validatePermitPlanRequest } from "./permit.js";
5
6
  import { getPendingSignatureRequests } from "./plan.js";
7
+ import { validateRedeemPlanAction } from "./redeem.js";
6
8
  import { validateTransactionPlanActions } from "./validateActions.js";
7
9
  import { getPlanObject, validatePlanField, validatePlanFields, } from "./validation.js";
8
- import { validateDepositPlanAction } from "./vaultv2/deposit.js";
9
- import { validateWithdrawPlanAction } from "./vaultv2/withdraw.js";
10
+ import { validateInKindRedeemPlanAction as validateVaultV1InKindRedeemPlanAction } from "./vaultv1/inKindRedeem.js";
11
+ import { validateMigrateToV2PlanAction } from "./vaultv1/migrateToV2.js";
12
+ import { validateForceRedeemPlanAction } from "./vaultv2/forceRedeem.js";
13
+ import { validateForceWithdrawPlanAction } from "./vaultv2/forceWithdraw.js";
14
+ import { validateInKindRedeemPlanAction } from "./vaultv2/inKindRedeem.js";
10
15
  import { validateTransactionPlanVersion } from "./version.js";
16
+ import { validateWithdrawPlanAction } from "./withdraw.js";
11
17
  const actionValidators = {
18
+ vaultV1InKindRedeem: validateVaultV1InKindRedeemPlanAction,
12
19
  erc20Approval: validateApprovalPlanAction,
20
+ vaultV2Redeem: validateRedeemPlanAction,
21
+ vaultV2ForceWithdraw: validateForceWithdrawPlanAction,
22
+ vaultV1Deposit: validateDepositPlanAction,
23
+ vaultV1Redeem: validateRedeemPlanAction,
24
+ vaultV1MigrateToV2: validateMigrateToV2PlanAction,
13
25
  vaultV2Deposit: validateDepositPlanAction,
14
26
  vaultV2Withdraw: validateWithdrawPlanAction,
27
+ vaultV2ForceRedeem: validateForceRedeemPlanAction,
28
+ vaultV1Withdraw: validateWithdrawPlanAction,
29
+ vaultV2InKindRedeem: validateInKindRedeemPlanAction,
15
30
  };
16
31
  /**
32
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
17
33
  * Serializes plan data with a bigint replacer. No validation is performed.
18
34
  * @param plan - Plan to save.
19
35
  * @returns JSON with `$bigint` tags for bigint quantities.
@@ -22,7 +38,6 @@ const actionValidators = {
22
38
  * import { serializeTransactionPlan, type TransactionPlan } from "@morpho-org/morpho-sdk";
23
39
  * const save = (plan: TransactionPlan) => serializeTransactionPlan(plan);
24
40
  * ```
25
- * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
26
41
  */
27
42
  export function serializeTransactionPlan(plan) {
28
43
  return JSON.stringify(plan, function (key) {
@@ -32,6 +47,7 @@ export function serializeTransactionPlan(plan) {
32
47
  });
33
48
  }
34
49
  /**
50
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
35
51
  * Restores bigint fields and validates version, action/request shapes, uint256 ranges, unique IDs,
36
52
  * references, per-action chain/account and permit/action consistency, including signed requests.
37
53
  * Extra keys are allowed. No clock or RPC is used: expiry, live state, signature ownership and
@@ -48,7 +64,6 @@ export function serializeTransactionPlan(plan) {
48
64
  * import { parseTransactionPlan } from "@morpho-org/morpho-sdk";
49
65
  * const restore = (saved: string) => parseTransactionPlan(saved);
50
66
  * ```
51
- * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
52
67
  */
53
68
  export function parseTransactionPlan(json) {
54
69
  let restored;
@@ -80,11 +95,12 @@ export function parseTransactionPlan(json) {
80
95
  signatureRequests: "array",
81
96
  },
82
97
  });
83
- if (plan.calldataOrigin !== undefined)
98
+ if (plan.calldataOrigin !== undefined) {
84
99
  validatePlanField(plan.calldataOrigin, {
85
100
  path: "$.calldataOrigin",
86
101
  type: "hex",
87
102
  });
103
+ }
88
104
  const steps = plan.steps;
89
105
  const requests = plan.signatureRequests;
90
106
  const stepIds = new Set();
@@ -95,11 +111,12 @@ export function parseTransactionPlan(json) {
95
111
  path,
96
112
  fields: { id: "string", label: "string" },
97
113
  });
98
- if (stepIds.has(step.id))
114
+ if (stepIds.has(step.id)) {
99
115
  throw new InvalidTransactionPlanError({
100
116
  path: `${path}.id`,
101
117
  reason: "expected a unique step ID",
102
118
  });
119
+ }
103
120
  stepIds.add(step.id);
104
121
  const action = getPlanObject(step.action, `${path}.action`);
105
122
  validatePlanField(action.type, {
@@ -118,16 +135,18 @@ export function parseTransactionPlan(json) {
118
135
  fields: { chainId: "positive safe integer", account: "address" },
119
136
  });
120
137
  actionValidators[step.action.type](action, path);
121
- if (inputs.chainId !== plan.chainId)
138
+ if (inputs.chainId !== plan.chainId) {
122
139
  throw new InvalidTransactionPlanError({
123
140
  path: `${path}.inputs.chainId`,
124
141
  reason: "expected the plan chainId",
125
142
  });
126
- if (!isAddressEqual(inputs.account, plan.account))
143
+ }
144
+ if (!isAddressEqual(inputs.account, plan.account)) {
127
145
  throw new InvalidTransactionPlanError({
128
146
  path: `${path}.inputs.account`,
129
147
  reason: "expected the plan account",
130
148
  });
149
+ }
131
150
  }
132
151
  const requestIds = new Set();
133
152
  for (const [index, value] of requests.entries()) {
@@ -137,31 +156,35 @@ export function parseTransactionPlan(json) {
137
156
  path,
138
157
  fields: { id: "string", kind: "string" },
139
158
  });
140
- if (requestIds.has(request.id))
159
+ if (requestIds.has(request.id)) {
141
160
  throw new InvalidTransactionPlanError({
142
161
  path: `${path}.id`,
143
162
  reason: "expected a unique signature request ID",
144
163
  });
164
+ }
145
165
  requestIds.add(request.id);
146
- if (request.kind !== "permit")
166
+ if (request.kind !== "permit") {
147
167
  throw new InvalidTransactionPlanError({
148
168
  path: `${path}.kind`,
149
169
  reason: "expected a supported signature request kind (permit)",
150
170
  });
171
+ }
151
172
  validatePermitPlanRequest(request, path);
152
173
  }
153
174
  for (const [index, step] of steps.entries()) {
154
- if (!("signatureRequestIds" in step.action))
175
+ if (!("signatureRequestIds" in step.action)) {
155
176
  continue;
177
+ }
156
178
  const path = `$.steps[${index}].action.signatureRequestIds`;
157
179
  const ids = getPlanObject(step.action.signatureRequestIds, path);
158
180
  for (const [role, id] of Object.entries(ids)) {
159
181
  validatePlanField(id, { path: `${path}.${role}`, type: "string" });
160
- if (!requestIds.has(id))
182
+ if (!requestIds.has(id)) {
161
183
  throw new InvalidTransactionPlanError({
162
184
  path: `${path}.${role}`,
163
185
  reason: "expected an existing signature request ID",
164
186
  });
187
+ }
165
188
  }
166
189
  }
167
190
  const result = restored;
@@ -179,12 +202,15 @@ export function parseTransactionPlan(json) {
179
202
  if (cause instanceof TransactionPlanSignatureMismatchError) {
180
203
  const index = result.signatureRequests.findIndex((request) => request.id === cause.id);
181
204
  let field = `typedData.${cause.field}`;
182
- if (cause.field === "reference")
205
+ if (cause.field === "reference") {
183
206
  field = "id";
184
- else if (cause.field === "value")
207
+ }
208
+ else if (cause.field === "value") {
185
209
  field = "args.amount";
186
- else if (cause.field.startsWith("args."))
210
+ }
211
+ else if (cause.field.startsWith("args.")) {
187
212
  field = cause.field;
213
+ }
188
214
  throw new InvalidTransactionPlanError({
189
215
  path: `$.signatureRequests[${index}].${field}`,
190
216
  reason: "expected agreement with every referencing action",
@@ -0,0 +1,18 @@
1
+ import type { Token } from "@morpho-org/blue-sdk";
2
+ import type { Address, Client } from "viem";
3
+ import type { SignatureRequest, Step } from "./types.js";
4
+ /** @internal Resolves unlimited share authorization after chain validation in each read path. */
5
+ export declare function getVaultShareSpendingRequirements(client: Client, params: {
6
+ readonly type: "vaultV1MigrateToV2" | "vaultV1Withdraw" | "vaultV2Withdraw" | "vaultV1Redeem" | "vaultV2Redeem";
7
+ readonly shareToken: Token;
8
+ readonly account: Address;
9
+ readonly chainId: number;
10
+ readonly requiredShareAllowance: bigint;
11
+ readonly deadline: bigint;
12
+ readonly supportSignature: boolean;
13
+ readonly now: bigint;
14
+ }): Promise<{
15
+ approvals: Step<import("./types.js").Action>[];
16
+ signatureRequests: SignatureRequest[];
17
+ tokenPermitRequestId: string;
18
+ }>;
@@ -0,0 +1,47 @@
1
+ import { getChainAddress } from "@morpho-org/morpho-ts";
2
+ import { validateClientChainId } from "../actions/requirements/validateClientChainId.js";
3
+ import { assertRegistryTargetsHaveCode } from "../entities/requirements/assertContractCode.js";
4
+ import { getVaultBundlesSharesRequirements } from "../entities/requirements/getVaultBundlesSharesRequirements.js";
5
+ import { validateChainId } from "../helpers/validate.js";
6
+ import { buildApprovalStep, buildPermitSignatureRequest, } from "./requirements.js";
7
+ /** @internal Resolves unlimited share authorization after chain validation in each read path. */
8
+ export async function getVaultShareSpendingRequirements(client, params) {
9
+ const { type, chainId, account } = params;
10
+ // Reject a declared chain mismatch before starting concurrent reads.
11
+ validateChainId(client.chain?.id, chainId);
12
+ const spender = getChainAddress(chainId, "bundles.vaultBundlesV1");
13
+ const [, , requirements] = await Promise.all([
14
+ validateClientChainId(client, chainId),
15
+ assertRegistryTargetsHaveCode(client, chainId, [
16
+ { role: "bundles.vaultBundlesV1", address: spender },
17
+ ]),
18
+ getVaultBundlesSharesRequirements(client, {
19
+ vaultData: params.shareToken,
20
+ version: type.startsWith("vaultV1") ? "vaultV1" : "vaultV2",
21
+ owner: account,
22
+ chainId,
23
+ requiredShareAllowance: params.requiredShareAllowance,
24
+ deadline: params.deadline,
25
+ supportSignature: params.supportSignature,
26
+ now: params.now,
27
+ }),
28
+ ]);
29
+ const approvals = [];
30
+ const signatureRequests = [];
31
+ const tokenPermitRequestId = `${type}:tokenPermit`;
32
+ const requirement = requirements[0];
33
+ if (requirement !== undefined) {
34
+ if ("sign" in requirement) {
35
+ signatureRequests.push(buildPermitSignatureRequest(requirement, tokenPermitRequestId));
36
+ }
37
+ else {
38
+ approvals.push(buildApprovalStep(requirement, {
39
+ id: `${type}:approval`,
40
+ chainId,
41
+ account,
42
+ denomination: "shares",
43
+ }));
44
+ }
45
+ }
46
+ return { approvals, signatureRequests, tokenPermitRequestId };
47
+ }
@@ -1,9 +1,16 @@
1
+ import type { InputMarketParams } from "@morpho-org/blue-sdk";
1
2
  import type { Address, Hex } from "viem";
2
- import type { BundlesFundingArgs, PermitAction, RequirementTypedData } from "../types/index.js";
3
+ import type { PermitAction, RequirementTypedData, VaultV1MigrateToV2AmountArgs } from "../types/index.js";
3
4
  interface ActionInputs {
4
5
  readonly chainId: number;
5
6
  readonly account: Address;
6
7
  }
8
+ /** Plain deallocation fields persisted by force-redeem plans, without class-derived values. */
9
+ interface StoredDeallocation {
10
+ readonly adapter: Address;
11
+ readonly assets: bigint;
12
+ readonly marketParams?: InputMarketParams;
13
+ }
7
14
  interface VaultInputs extends ActionInputs {
8
15
  readonly vault: Address;
9
16
  readonly deadline: bigint;
@@ -16,41 +23,140 @@ type VaultSignatureRequestIds = {
16
23
  readonly tokenPermit?: string;
17
24
  };
18
25
  /**
19
- * Recipes supported by Vault V2 plans. Each `type` equals the `action.type` of the
26
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
27
+ * Recipes supported by vault plans. Each `type` equals the `action.type` of the
20
28
  * {@link TransactionAction} it builds.
21
29
  * Snapshot-derived values such as the asset and the quote are fixed on `inputs` at preparation;
22
30
  * each action also carries its own chain and account on `inputs`.
23
31
  * the role map `signatureRequestIds` is a step's only request reference.
24
- * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
25
32
  */
26
33
  export type Action = {
34
+ readonly type: "vaultV2ForceRedeem";
35
+ readonly inputs: ActionInputs & {
36
+ readonly vault: Address;
37
+ readonly redeem: {
38
+ readonly shares: bigint;
39
+ };
40
+ readonly deallocations: readonly StoredDeallocation[];
41
+ };
42
+ } | {
43
+ readonly type: "vaultV1Redeem";
44
+ readonly inputs: VaultInputs & {
45
+ readonly shares: bigint;
46
+ };
47
+ readonly signatureRequestIds: VaultSignatureRequestIds;
48
+ } | {
49
+ readonly type: "vaultV1MigrateToV2";
50
+ readonly inputs: ActionInputs & VaultV1MigrateToV2AmountArgs & {
51
+ readonly sourceVault: Address;
52
+ readonly targetVault: Address;
53
+ readonly asset: Address;
54
+ readonly maxSharePrice: bigint;
55
+ readonly vault: Address;
56
+ readonly requiredShareAllowance: bigint;
57
+ readonly deadline: bigint;
58
+ readonly referralFeePct: bigint;
59
+ readonly referralFeeRecipient: Address;
60
+ };
61
+ readonly signatureRequestIds: VaultSignatureRequestIds;
62
+ } | {
63
+ readonly type: "vaultV1InKindRedeem";
64
+ readonly inputs: ActionInputs & {
65
+ readonly vault: Address;
66
+ readonly assets: bigint;
67
+ readonly deadline: bigint;
68
+ readonly marketParamsList: readonly InputMarketParams[];
69
+ };
70
+ readonly signatureRequestIds: VaultSignatureRequestIds;
71
+ } | {
27
72
  readonly type: "erc20Approval";
28
73
  readonly inputs: ActionInputs & {
29
74
  readonly token: Address;
30
75
  readonly spender: Address;
31
- readonly amount: bigint;
32
- };
76
+ } & ({
77
+ readonly assets: bigint;
78
+ readonly shares?: never;
79
+ } | {
80
+ readonly shares: bigint;
81
+ readonly assets?: never;
82
+ });
33
83
  } | {
34
84
  readonly type: "vaultV2Deposit";
35
- readonly inputs: VaultInputs & BundlesFundingArgs & {
85
+ readonly inputs: VaultInputs & ({
86
+ readonly assets: bigint;
87
+ readonly nativeAssets?: never;
88
+ } | {
89
+ readonly nativeAssets: bigint;
90
+ readonly assets?: never;
91
+ }) & {
92
+ /** Vault asset read from the snapshot. */
93
+ readonly asset: Address;
94
+ /** Deadline-accrued RAY-scaled bound quoted from the snapshot for the net deposit. */
95
+ readonly maxSharePrice: bigint;
96
+ };
97
+ readonly signatureRequestIds: VaultSignatureRequestIds;
98
+ } | {
99
+ readonly type: "vaultV1Deposit";
100
+ readonly inputs: VaultInputs & ({
101
+ readonly assets: bigint;
102
+ readonly nativeAssets?: never;
103
+ } | {
104
+ readonly nativeAssets: bigint;
105
+ readonly assets?: never;
106
+ }) & {
36
107
  /** Vault asset read from the snapshot. */
37
108
  readonly asset: Address;
38
109
  /** Deadline-accrued RAY-scaled bound quoted from the snapshot for the net deposit. */
39
110
  readonly maxSharePrice: bigint;
40
111
  };
41
112
  readonly signatureRequestIds: VaultSignatureRequestIds;
113
+ } | {
114
+ readonly type: "vaultV1Withdraw";
115
+ readonly inputs: VaultInputs & {
116
+ readonly assets: bigint;
117
+ /** Minimum share allowance quoted from the snapshot for the gross withdrawal. */
118
+ readonly requiredShareAllowance: bigint;
119
+ };
120
+ readonly signatureRequestIds: VaultSignatureRequestIds;
121
+ } | {
122
+ readonly type: "vaultV2InKindRedeem";
123
+ readonly inputs: ActionInputs & {
124
+ readonly vault: Address;
125
+ readonly adapter: Address;
126
+ readonly assets: bigint;
127
+ readonly deadline: bigint;
128
+ readonly marketParamsList: readonly InputMarketParams[];
129
+ };
130
+ readonly signatureRequestIds: VaultSignatureRequestIds;
42
131
  } | {
43
132
  readonly type: "vaultV2Withdraw";
44
133
  readonly inputs: VaultInputs & {
45
- readonly amount: bigint;
134
+ readonly assets: bigint;
46
135
  /** Minimum share allowance quoted from the snapshot for the gross withdrawal. */
47
136
  readonly requiredShareAllowance: bigint;
48
137
  };
49
138
  readonly signatureRequestIds: VaultSignatureRequestIds;
139
+ } | {
140
+ readonly type: "vaultV2Redeem";
141
+ readonly inputs: VaultInputs & {
142
+ /** Exact shares to burn; no quote is required. */
143
+ readonly shares: bigint;
144
+ };
145
+ readonly signatureRequestIds: VaultSignatureRequestIds;
146
+ } | {
147
+ readonly type: "vaultV2ForceWithdraw";
148
+ readonly inputs: VaultInputs & {
149
+ readonly adapter: Address;
150
+ /** Penalty-inclusive assets debited from the account's position. */
151
+ readonly assets: bigint;
152
+ /** Snapshot-derived lower bound on the realized exit share price. */
153
+ readonly minSharePriceE27: bigint;
154
+ };
155
+ readonly signatureRequestIds: VaultSignatureRequestIds;
50
156
  };
51
157
  /**
52
- * A recipe with a plan-unique `id`; its request dependencies are the roles its action names.
53
158
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
159
+ * A recipe with a plan-unique `id`; its request dependencies are the roles its action names.
54
160
  */
55
161
  export interface Step<TAction extends Action = Action> {
56
162
  readonly id: string;
@@ -58,9 +164,9 @@ export interface Step<TAction extends Action = Action> {
58
164
  readonly action: TAction;
59
165
  }
60
166
  /**
167
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
61
168
  * ERC-2612 permit request exposed as `{ id, kind, typedData }`. `signature` is undefined until the
62
169
  * account signs `typedData`. Protocol milestones add further `kind`s such as Blue authorization.
63
- * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
64
170
  */
65
171
  export interface SignatureRequest {
66
172
  readonly id: string;
@@ -72,13 +178,13 @@ export interface SignatureRequest {
72
178
  readonly signature?: Hex;
73
179
  }
74
180
  /**
181
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
75
182
  * Data-only operation prepared for one chain and account from the caller's intent and a vault
76
183
  * snapshot. Every step and signature request carries its own `id`, unique within the plan. Once
77
184
  * prepared, a plan is static: only signatures are added before building.
78
- * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
79
185
  */
80
186
  export interface TransactionPlan {
81
- readonly version: 1;
187
+ readonly version: 2;
82
188
  readonly chainId: number;
83
189
  readonly account: Address;
84
190
  /** Unix seconds. One expiry governs every step deadline and signature deadline. */
@@ -9,8 +9,18 @@ export function validateTransactionPlanActions(steps) {
9
9
  for (const step of steps) {
10
10
  const actionType = step.action.type;
11
11
  if (actionType !== "erc20Approval" &&
12
+ actionType !== "vaultV1Deposit" &&
13
+ actionType !== "vaultV1MigrateToV2" &&
14
+ actionType !== "vaultV1InKindRedeem" &&
12
15
  actionType !== "vaultV2Deposit" &&
13
- actionType !== "vaultV2Withdraw")
16
+ actionType !== "vaultV2Withdraw" &&
17
+ actionType !== "vaultV2Redeem" &&
18
+ actionType !== "vaultV2ForceWithdraw" &&
19
+ actionType !== "vaultV2ForceRedeem" &&
20
+ actionType !== "vaultV1Withdraw" &&
21
+ actionType !== "vaultV1Redeem" &&
22
+ actionType !== "vaultV2InKindRedeem") {
14
23
  throw new UnsupportedTransactionPlanActionError(actionType);
24
+ }
15
25
  }
16
26
  }
@@ -29,22 +29,25 @@ export function validatePlanField(value, options) {
29
29
  valid = Array.isArray(value);
30
30
  break;
31
31
  }
32
- if (!valid)
32
+ if (!valid) {
33
33
  throw new InvalidTransactionPlanError({ path, reason: `expected ${type}` });
34
+ }
34
35
  }
35
36
  /** @internal Requires a non-null, non-array JSON object. */
36
37
  export function getPlanObject(value, path) {
37
- if (typeof value !== "object" || value === null || Array.isArray(value))
38
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
38
39
  throw new InvalidTransactionPlanError({
39
40
  path,
40
41
  reason: "expected an object",
41
42
  });
43
+ }
42
44
  return value;
43
45
  }
44
46
  /** @internal Validates required fields while permitting additional keys. */
45
47
  export function validatePlanFields(value, options) {
46
- for (const [key, type] of Object.entries(options.fields))
48
+ for (const [key, type] of Object.entries(options.fields)) {
47
49
  validatePlanField(value[key], { path: `${options.path}.${key}`, type });
50
+ }
48
51
  }
49
52
  /** @internal Validates the shared stored vault-action fields and role map. */
50
53
  export function validateVaultPlanAction(action, path) {