@morpho-org/morpho-sdk 9.8.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 (303) hide show
  1. package/MIGRATION-v9-to-v10.md +114 -0
  2. package/README.md +109 -13
  3. package/lib/cjs/actions/blue/common.js +4 -2
  4. package/lib/cjs/actions/blue/withdrawBuyCallback.js +2 -1
  5. package/lib/cjs/actions/bundles/common.js +20 -14
  6. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +3 -4
  7. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +3 -2
  8. package/lib/cjs/actions/midnight/cancelAndMake.d.ts +2 -1
  9. package/lib/cjs/actions/midnight/cancelAndMake.js +2 -1
  10. package/lib/cjs/actions/midnight/cancelOffers.d.ts +54 -0
  11. package/lib/cjs/actions/midnight/cancelOffers.js +108 -0
  12. package/lib/cjs/actions/midnight/index.d.ts +1 -0
  13. package/lib/cjs/actions/midnight/index.js +1 -0
  14. package/lib/cjs/actions/midnight/supplyCollateralBatch.js +4 -2
  15. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +1 -1
  16. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +3 -2
  17. package/lib/cjs/actions/midnight/takeBorrow.d.ts +1 -1
  18. package/lib/cjs/actions/midnight/takeBorrow.js +3 -2
  19. package/lib/cjs/actions/midnight/takeLend.d.ts +1 -1
  20. package/lib/cjs/actions/midnight/takeLend.js +3 -2
  21. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
  22. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +3 -2
  23. package/lib/cjs/actions/midnight/takeWithdraw.d.ts +1 -1
  24. package/lib/cjs/actions/midnight/takeWithdraw.js +3 -2
  25. package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +4 -2
  26. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -4
  27. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -1
  28. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +4 -6
  29. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +3 -3
  30. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -6
  31. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +3 -3
  32. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -6
  33. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +5 -13
  34. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +3 -5
  35. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +26 -23
  36. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +2 -1
  37. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +2 -1
  38. package/lib/cjs/actions/vaultV1/inKindRedeem.js +6 -3
  39. package/lib/cjs/actions/vaultV1/migrateToV2.js +1 -1
  40. package/lib/cjs/actions/vaultV2/forceWithdraw.js +4 -2
  41. package/lib/cjs/actions/vaultV2/inKindRedeem.js +4 -2
  42. package/lib/cjs/entities/blue/blue.d.ts +34 -28
  43. package/lib/cjs/entities/blue/blue.js +107 -77
  44. package/lib/cjs/entities/midnight/deadline.d.ts +2 -2
  45. package/lib/cjs/entities/midnight/deadline.js +4 -3
  46. package/lib/cjs/entities/midnight/midnight.d.ts +49 -51
  47. package/lib/cjs/entities/midnight/midnight.js +158 -138
  48. package/lib/cjs/entities/midnight/publication.d.ts +2 -0
  49. package/lib/cjs/entities/midnight/publication.js +193 -138
  50. package/lib/cjs/entities/midnight/types.d.ts +4 -4
  51. package/lib/cjs/entities/requirements/assertContractCode.js +4 -2
  52. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +3 -5
  53. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +24 -28
  54. package/lib/cjs/entities/requirements/getErc2612Permit.js +10 -5
  55. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -4
  56. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
  57. package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.d.ts +21 -0
  58. package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.js +111 -0
  59. package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.d.ts +20 -0
  60. package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.js +76 -0
  61. package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.d.ts +21 -0
  62. package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.js +93 -0
  63. package/lib/cjs/entities/vaultV1/inKindRedeemQuote.d.ts +25 -0
  64. package/lib/cjs/entities/vaultV1/inKindRedeemQuote.js +85 -0
  65. package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +20 -0
  66. package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +37 -0
  67. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +12 -12
  68. package/lib/cjs/entities/vaultV1/vaultV1.js +90 -194
  69. package/lib/cjs/entities/vaultV2/forceWithdrawQuote.d.ts +25 -0
  70. package/lib/cjs/entities/vaultV2/forceWithdrawQuote.js +189 -0
  71. package/lib/cjs/entities/vaultV2/inKindRedeemQuote.d.ts +28 -0
  72. package/lib/cjs/entities/vaultV2/inKindRedeemQuote.js +110 -0
  73. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +16 -16
  74. package/lib/cjs/entities/vaultV2/vaultV2.js +94 -385
  75. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +14 -0
  76. package/lib/cjs/entities/vaultV2BlueReallocationData.js +1599 -883
  77. package/lib/cjs/errors.d.ts +1 -1
  78. package/lib/cjs/errors.js +2 -1
  79. package/lib/cjs/helpers/deadShares.js +83 -47
  80. package/lib/cjs/helpers/encodeMidnightCalldata.js +4 -2
  81. package/lib/cjs/helpers/metadata.d.ts +14 -2
  82. package/lib/cjs/helpers/metadata.js +49 -8
  83. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +44 -27
  84. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +11 -2
  85. package/lib/cjs/helpers/utilization.js +10 -5
  86. package/lib/cjs/helpers/validate.js +88 -67
  87. package/lib/cjs/helpers/validateMidnightBounds.js +2 -1
  88. package/lib/cjs/helpers/validateMidnightCollateralBatch.js +2 -1
  89. package/lib/cjs/helpers/validateMidnightPublication.js +4 -2
  90. package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +177 -104
  91. package/lib/cjs/helpers/validatePositiveInput.js +2 -1
  92. package/lib/cjs/helpers/validateTakeableOffers.js +2 -1
  93. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +40 -22
  94. package/lib/cjs/index.d.ts +2 -2
  95. package/lib/cjs/index.js +10 -1
  96. package/lib/cjs/transactionPlan/approval.js +12 -1
  97. package/lib/cjs/transactionPlan/deposit.d.ts +22 -0
  98. package/lib/cjs/transactionPlan/deposit.js +139 -0
  99. package/lib/cjs/transactionPlan/error.d.ts +10 -8
  100. package/lib/cjs/transactionPlan/error.js +10 -8
  101. package/lib/cjs/transactionPlan/getTokenPermit.js +2 -1
  102. package/lib/cjs/transactionPlan/index.d.ts +18 -0
  103. package/lib/cjs/transactionPlan/index.js +23 -5
  104. package/lib/cjs/transactionPlan/intent.d.ts +3 -3
  105. package/lib/cjs/transactionPlan/intent.js +14 -7
  106. package/lib/cjs/transactionPlan/permit.d.ts +1 -1
  107. package/lib/cjs/transactionPlan/permit.js +86 -20
  108. package/lib/cjs/transactionPlan/plan.d.ts +16 -6
  109. package/lib/cjs/transactionPlan/plan.js +77 -24
  110. package/lib/cjs/transactionPlan/redeem.d.ts +18 -0
  111. package/lib/cjs/transactionPlan/redeem.js +63 -0
  112. package/lib/cjs/transactionPlan/requirements.d.ts +4 -3
  113. package/lib/cjs/transactionPlan/requirements.js +12 -6
  114. package/lib/cjs/transactionPlan/serde.d.ts +2 -2
  115. package/lib/cjs/transactionPlan/serde.js +45 -19
  116. package/lib/cjs/transactionPlan/shareSpending.d.ts +18 -0
  117. package/lib/cjs/transactionPlan/shareSpending.js +50 -0
  118. package/lib/cjs/transactionPlan/types.d.ts +117 -11
  119. package/lib/cjs/transactionPlan/validateActions.js +11 -1
  120. package/lib/cjs/transactionPlan/validation.js +6 -3
  121. package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +93 -0
  122. package/lib/cjs/transactionPlan/vaultv1/deposit.js +94 -0
  123. package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.d.ts +96 -0
  124. package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.js +203 -0
  125. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +94 -0
  126. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +217 -0
  127. package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +69 -0
  128. package/lib/cjs/transactionPlan/vaultv1/redeem.js +78 -0
  129. package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +77 -0
  130. package/lib/cjs/transactionPlan/vaultv1/withdraw.js +88 -0
  131. package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +18 -33
  132. package/lib/cjs/transactionPlan/vaultv2/deposit.js +19 -143
  133. package/lib/cjs/transactionPlan/vaultv2/forceRedeem.d.ts +74 -0
  134. package/lib/cjs/transactionPlan/vaultv2/forceRedeem.js +155 -0
  135. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +98 -0
  136. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +206 -0
  137. package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.d.ts +113 -0
  138. package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.js +206 -0
  139. package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +84 -0
  140. package/lib/cjs/transactionPlan/vaultv2/redeem.js +86 -0
  141. package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +18 -29
  142. package/lib/cjs/transactionPlan/vaultv2/withdraw.js +21 -126
  143. package/lib/cjs/transactionPlan/version.js +2 -1
  144. package/lib/cjs/transactionPlan/withdraw.d.ts +18 -0
  145. package/lib/cjs/transactionPlan/withdraw.js +94 -0
  146. package/lib/cjs/types/action.d.ts +26 -2
  147. package/lib/cjs/types/action.js +17 -9
  148. package/lib/cjs/types/error.d.ts +8 -1
  149. package/lib/cjs/types/error.js +21 -6
  150. package/lib/cjs/types/metadata.d.ts +12 -2
  151. package/lib/cjs/version.d.ts +1 -1
  152. package/lib/cjs/version.js +1 -1
  153. package/lib/esm/actions/blue/common.js +4 -2
  154. package/lib/esm/actions/blue/withdrawBuyCallback.js +2 -1
  155. package/lib/esm/actions/bundles/common.js +20 -14
  156. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +3 -4
  157. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +3 -2
  158. package/lib/esm/actions/midnight/cancelAndMake.d.ts +2 -1
  159. package/lib/esm/actions/midnight/cancelAndMake.js +2 -1
  160. package/lib/esm/actions/midnight/cancelOffers.d.ts +54 -0
  161. package/lib/esm/actions/midnight/cancelOffers.js +104 -0
  162. package/lib/esm/actions/midnight/index.d.ts +1 -0
  163. package/lib/esm/actions/midnight/index.js +1 -0
  164. package/lib/esm/actions/midnight/supplyCollateralBatch.js +4 -2
  165. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +1 -1
  166. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +3 -2
  167. package/lib/esm/actions/midnight/takeBorrow.d.ts +1 -1
  168. package/lib/esm/actions/midnight/takeBorrow.js +3 -2
  169. package/lib/esm/actions/midnight/takeLend.d.ts +1 -1
  170. package/lib/esm/actions/midnight/takeLend.js +3 -2
  171. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
  172. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +3 -2
  173. package/lib/esm/actions/midnight/takeWithdraw.d.ts +1 -1
  174. package/lib/esm/actions/midnight/takeWithdraw.js +3 -2
  175. package/lib/esm/actions/midnight/withdrawCollateralBatch.js +4 -2
  176. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -4
  177. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -1
  178. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +4 -6
  179. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +3 -3
  180. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -6
  181. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +3 -3
  182. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -6
  183. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +7 -15
  184. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +3 -5
  185. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +26 -23
  186. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +2 -1
  187. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +2 -1
  188. package/lib/esm/actions/vaultV1/inKindRedeem.js +6 -3
  189. package/lib/esm/actions/vaultV1/migrateToV2.js +1 -1
  190. package/lib/esm/actions/vaultV2/forceWithdraw.js +4 -2
  191. package/lib/esm/actions/vaultV2/inKindRedeem.js +4 -2
  192. package/lib/esm/entities/blue/blue.d.ts +34 -28
  193. package/lib/esm/entities/blue/blue.js +107 -77
  194. package/lib/esm/entities/midnight/deadline.d.ts +2 -2
  195. package/lib/esm/entities/midnight/deadline.js +4 -3
  196. package/lib/esm/entities/midnight/midnight.d.ts +49 -51
  197. package/lib/esm/entities/midnight/midnight.js +159 -139
  198. package/lib/esm/entities/midnight/publication.d.ts +2 -0
  199. package/lib/esm/entities/midnight/publication.js +193 -138
  200. package/lib/esm/entities/midnight/types.d.ts +4 -4
  201. package/lib/esm/entities/requirements/assertContractCode.js +4 -2
  202. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +3 -5
  203. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +25 -29
  204. package/lib/esm/entities/requirements/getErc2612Permit.js +10 -5
  205. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -4
  206. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
  207. package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.d.ts +21 -0
  208. package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.js +108 -0
  209. package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.d.ts +20 -0
  210. package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.js +73 -0
  211. package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.d.ts +21 -0
  212. package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.js +90 -0
  213. package/lib/esm/entities/vaultV1/inKindRedeemQuote.d.ts +25 -0
  214. package/lib/esm/entities/vaultV1/inKindRedeemQuote.js +82 -0
  215. package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +20 -0
  216. package/lib/esm/entities/vaultV1/migrateToV2Quote.js +34 -0
  217. package/lib/esm/entities/vaultV1/vaultV1.d.ts +12 -12
  218. package/lib/esm/entities/vaultV1/vaultV1.js +96 -200
  219. package/lib/esm/entities/vaultV2/forceWithdrawQuote.d.ts +25 -0
  220. package/lib/esm/entities/vaultV2/forceWithdrawQuote.js +186 -0
  221. package/lib/esm/entities/vaultV2/inKindRedeemQuote.d.ts +28 -0
  222. package/lib/esm/entities/vaultV2/inKindRedeemQuote.js +107 -0
  223. package/lib/esm/entities/vaultV2/vaultV2.d.ts +16 -16
  224. package/lib/esm/entities/vaultV2/vaultV2.js +102 -393
  225. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +14 -0
  226. package/lib/esm/entities/vaultV2BlueReallocationData.js +1599 -883
  227. package/lib/esm/errors.d.ts +1 -1
  228. package/lib/esm/errors.js +1 -1
  229. package/lib/esm/helpers/deadShares.js +83 -47
  230. package/lib/esm/helpers/encodeMidnightCalldata.js +4 -2
  231. package/lib/esm/helpers/metadata.d.ts +14 -2
  232. package/lib/esm/helpers/metadata.js +48 -8
  233. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +44 -27
  234. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +11 -2
  235. package/lib/esm/helpers/utilization.js +10 -5
  236. package/lib/esm/helpers/validate.js +88 -67
  237. package/lib/esm/helpers/validateMidnightBounds.js +2 -1
  238. package/lib/esm/helpers/validateMidnightCollateralBatch.js +2 -1
  239. package/lib/esm/helpers/validateMidnightPublication.js +4 -2
  240. package/lib/esm/helpers/validateMidnightTakeFeasibility.js +176 -103
  241. package/lib/esm/helpers/validatePositiveInput.js +2 -1
  242. package/lib/esm/helpers/validateTakeableOffers.js +2 -1
  243. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +40 -22
  244. package/lib/esm/index.d.ts +2 -2
  245. package/lib/esm/index.js +1 -1
  246. package/lib/esm/transactionPlan/approval.js +13 -2
  247. package/lib/esm/transactionPlan/deposit.d.ts +22 -0
  248. package/lib/esm/transactionPlan/deposit.js +135 -0
  249. package/lib/esm/transactionPlan/error.d.ts +10 -8
  250. package/lib/esm/transactionPlan/error.js +10 -8
  251. package/lib/esm/transactionPlan/getTokenPermit.js +2 -1
  252. package/lib/esm/transactionPlan/index.d.ts +18 -0
  253. package/lib/esm/transactionPlan/index.js +9 -0
  254. package/lib/esm/transactionPlan/intent.d.ts +3 -3
  255. package/lib/esm/transactionPlan/intent.js +14 -7
  256. package/lib/esm/transactionPlan/permit.d.ts +1 -1
  257. package/lib/esm/transactionPlan/permit.js +86 -20
  258. package/lib/esm/transactionPlan/plan.d.ts +16 -6
  259. package/lib/esm/transactionPlan/plan.js +73 -20
  260. package/lib/esm/transactionPlan/redeem.d.ts +18 -0
  261. package/lib/esm/transactionPlan/redeem.js +59 -0
  262. package/lib/esm/transactionPlan/requirements.d.ts +4 -3
  263. package/lib/esm/transactionPlan/requirements.js +12 -6
  264. package/lib/esm/transactionPlan/serde.d.ts +2 -2
  265. package/lib/esm/transactionPlan/serde.js +45 -19
  266. package/lib/esm/transactionPlan/shareSpending.d.ts +18 -0
  267. package/lib/esm/transactionPlan/shareSpending.js +47 -0
  268. package/lib/esm/transactionPlan/types.d.ts +117 -11
  269. package/lib/esm/transactionPlan/validateActions.js +11 -1
  270. package/lib/esm/transactionPlan/validation.js +6 -3
  271. package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +93 -0
  272. package/lib/esm/transactionPlan/vaultv1/deposit.js +90 -0
  273. package/lib/esm/transactionPlan/vaultv1/inKindRedeem.d.ts +96 -0
  274. package/lib/esm/transactionPlan/vaultv1/inKindRedeem.js +198 -0
  275. package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +94 -0
  276. package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +212 -0
  277. package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +69 -0
  278. package/lib/esm/transactionPlan/vaultv1/redeem.js +74 -0
  279. package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +77 -0
  280. package/lib/esm/transactionPlan/vaultv1/withdraw.js +84 -0
  281. package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +18 -33
  282. package/lib/esm/transactionPlan/vaultv2/deposit.js +21 -144
  283. package/lib/esm/transactionPlan/vaultv2/forceRedeem.d.ts +74 -0
  284. package/lib/esm/transactionPlan/vaultv2/forceRedeem.js +150 -0
  285. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +98 -0
  286. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +201 -0
  287. package/lib/esm/transactionPlan/vaultv2/inKindRedeem.d.ts +113 -0
  288. package/lib/esm/transactionPlan/vaultv2/inKindRedeem.js +201 -0
  289. package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +84 -0
  290. package/lib/esm/transactionPlan/vaultv2/redeem.js +82 -0
  291. package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +18 -29
  292. package/lib/esm/transactionPlan/vaultv2/withdraw.js +23 -127
  293. package/lib/esm/transactionPlan/version.js +2 -1
  294. package/lib/esm/transactionPlan/withdraw.d.ts +18 -0
  295. package/lib/esm/transactionPlan/withdraw.js +90 -0
  296. package/lib/esm/types/action.d.ts +26 -2
  297. package/lib/esm/types/action.js +17 -9
  298. package/lib/esm/types/error.d.ts +8 -1
  299. package/lib/esm/types/error.js +21 -6
  300. package/lib/esm/types/metadata.d.ts +12 -2
  301. package/lib/esm/version.d.ts +1 -1
  302. package/lib/esm/version.js +1 -1
  303. package/package.json +15 -14
@@ -182,8 +182,9 @@ function computeVaultV2ForceWithdrawPlan(params) {
182
182
  // Guard the exported planner: a non-positive `exitAssets` would flow a negative through
183
183
  // `min(exitAssets, withdrawable)` and return a plan with negative amounts. The entity and preview
184
184
  // reject it upstream; this protects direct importers of the advertised helper.
185
- if (exitAssets <= 0n)
185
+ if (exitAssets <= 0n) {
186
186
  throw new index_js_1.NonPositiveInputError("exitAssets", exitAssets);
187
+ }
187
188
  const penalty = vaultData.forceDeallocatePenalties[adapter.address] ?? 0n;
188
189
  const idleAssets = vaultData.assetBalance;
189
190
  // `min(adapterPosition, marketLiquidity)` per market, on interest-accrued market state — the
@@ -208,25 +209,7 @@ function computeVaultV2ForceWithdrawPlan(params) {
208
209
  if (liquidityMarketId != null && drainedFromLiquidityMarket > 0n) {
209
210
  availableByMarket.set(liquidityMarketId, blue_sdk_1.MathLib.zeroFloorSub(liquidityCapacity, drainedFromLiquidityMarket));
210
211
  }
211
- let coveredAssets = 0n;
212
- const nonEmpty = [];
213
- for (const available of availableByMarket.values()) {
214
- if (available <= 0n)
215
- continue;
216
- coveredAssets += available;
217
- nonEmpty.push(available);
218
- }
219
- // `maxExitAssets` must not depend on the requested amount. At the ceiling the penalty-free leg
220
- // always drains the liquidity market completely, so that market contributes nothing to the
221
- // force-deallocation loop — whereas a small request leaves part of it, which would overstate the
222
- // ceiling for callers using it to cap an input.
223
- let saturatedCoveredAssets = 0n;
224
- for (const [marketId, available] of availableByMarket) {
225
- if (marketId === liquidityMarketId)
226
- continue;
227
- if (available > 0n)
228
- saturatedCoveredAssets += available;
229
- }
212
+ const { coveredAssets, nonEmpty, saturatedCoveredAssets } = summarizeMarketCoverage(availableByMarket, liquidityMarketId);
230
213
  // Worst-case leg count is the ascending walk: the most markets the loop can touch is the number
231
214
  // of smallest positions that together reach `assetsToDeallocate`. Deliberately an upper bound, not
232
215
  // a replay of the contract's prefetched `marketIds` order (where an earlier market may cover the
@@ -239,9 +222,18 @@ function computeVaultV2ForceWithdrawPlan(params) {
239
222
  // coverage of the snapshot-vs-execution divergence.
240
223
  let penaltyLegs = 0;
241
224
  let remaining = assetsToDeallocate;
242
- for (const available of nonEmpty.toSorted((a, b) => a === b ? 0 : a > b ? 1 : -1)) {
243
- if (remaining <= 0n)
225
+ for (const available of nonEmpty.toSorted((a, b) => {
226
+ if (a === b) {
227
+ return 0;
228
+ }
229
+ if (a > b) {
230
+ return 1;
231
+ }
232
+ return -1;
233
+ })) {
234
+ if (remaining <= 0n) {
244
235
  break;
236
+ }
245
237
  penaltyLegs += 1;
246
238
  remaining -= blue_sdk_1.MathLib.min(available, remaining);
247
239
  }
@@ -435,3 +427,29 @@ function computeVaultV2ForceWithdrawMinSharesBurnt(params) {
435
427
  return vaultData.toShares(blue_sdk_1.MathLib.min(plan.withdrawnAssets +
436
428
  blue_sdk_1.MathLib.wMulUp(plan.assetsToDeallocate, plan.penalty), blue_sdk_1.MathLib.zeroFloorSub(plan.exitAssets, 1n)), "Down");
437
429
  }
430
+ /** Sums usable market liquidity and the ceiling's non-liquidity-market coverage. @internal */
431
+ function summarizeMarketCoverage(availableByMarket, liquidityMarketId) {
432
+ let coveredAssets = 0n;
433
+ const nonEmpty = [];
434
+ for (const available of availableByMarket.values()) {
435
+ if (available <= 0n) {
436
+ continue;
437
+ }
438
+ coveredAssets += available;
439
+ nonEmpty.push(available);
440
+ }
441
+ // `maxExitAssets` must not depend on the requested amount. At the ceiling the penalty-free leg
442
+ // always drains the liquidity market completely, so that market contributes nothing to the
443
+ // force-deallocation loop — whereas a small request leaves part of it, which would overstate the
444
+ // ceiling for callers using it to cap an input.
445
+ let saturatedCoveredAssets = 0n;
446
+ for (const [marketId, available] of availableByMarket) {
447
+ if (marketId === liquidityMarketId) {
448
+ continue;
449
+ }
450
+ if (available > 0n) {
451
+ saturatedCoveredAssets += available;
452
+ }
453
+ }
454
+ return { coveredAssets, nonEmpty, saturatedCoveredAssets };
455
+ }
@@ -3,7 +3,7 @@ export { validateClientChainId } from "./actions/requirements/validateClientChai
3
3
  export * from "./client/index.js";
4
4
  export * from "./entities/requirements/index.js";
5
5
  export * from "./helpers/index.js";
6
- export type { Action, Funding, IntentParams, ReferralFee, SignatureRequest, Step, TransactionPlan, VaultV2DepositPlanParams, VaultV2WithdrawPlanParams, } from "./transactionPlan/index.js";
7
- export { applySignatures, buildTransaction, buildTransactions, getPendingSignatureRequests, IncompleteTransactionPlanError, InvalidCalldataOriginError, InvalidTransactionPlanError, NonIntegerInputError, parseTransactionPlan, prepareVaultV2Deposit, prepareVaultV2Withdraw, serializeTransactionPlan, TransactionPlanSignatureMismatchError, UnsupportedTransactionPlanActionError, UnsupportedTransactionPlanVersionError, ZeroAccountError, } from "./transactionPlan/index.js";
6
+ export type { Action, Funding, IntentParams, ReferralFee, SignatureRequest, Step, TransactionPlan, VaultV1DepositPlanParams, VaultV1InKindRedeemPlanParams, VaultV1MigrateToV2PlanParams, VaultV1RedeemPlanParams, VaultV1WithdrawPlanParams, VaultV2DepositPlanParams, VaultV2ForceRedeemPlanParams, VaultV2ForceWithdrawPlanParams, VaultV2InKindRedeemPlanParams, VaultV2RedeemPlanParams, VaultV2WithdrawPlanParams, } from "./transactionPlan/index.js";
7
+ export { applySignatures, buildTransaction, buildTransactions, getPendingSignatureRequests, IncompleteTransactionPlanError, InvalidCalldataOriginError, InvalidTransactionPlanError, NonIntegerInputError, parseTransactionPlan, prepareVaultV1Deposit, prepareVaultV1InKindRedeem, prepareVaultV1MigrateToV2, prepareVaultV1Redeem, prepareVaultV1Withdraw, prepareVaultV2Deposit, prepareVaultV2ForceRedeem, prepareVaultV2ForceWithdraw, prepareVaultV2InKindRedeem, prepareVaultV2Redeem, prepareVaultV2Withdraw, serializeTransactionPlan, TransactionPlanSignatureMismatchError, UnsupportedTransactionPlanActionError, UnsupportedTransactionPlanVersionError, ZeroAccountError, } from "./transactionPlan/index.js";
8
8
  export * from "./types/index.js";
9
9
  export { version } from "./version.js";
package/lib/cjs/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.version = exports.ZeroAccountError = exports.UnsupportedTransactionPlanVersionError = exports.UnsupportedTransactionPlanActionError = exports.TransactionPlanSignatureMismatchError = exports.serializeTransactionPlan = exports.prepareVaultV2Withdraw = exports.prepareVaultV2Deposit = exports.parseTransactionPlan = exports.NonIntegerInputError = exports.InvalidTransactionPlanError = exports.InvalidCalldataOriginError = exports.IncompleteTransactionPlanError = exports.getPendingSignatureRequests = exports.buildTransactions = exports.buildTransaction = exports.applySignatures = exports.validateClientChainId = void 0;
17
+ exports.version = exports.ZeroAccountError = exports.UnsupportedTransactionPlanVersionError = exports.UnsupportedTransactionPlanActionError = exports.TransactionPlanSignatureMismatchError = exports.serializeTransactionPlan = exports.prepareVaultV2Withdraw = exports.prepareVaultV2Redeem = exports.prepareVaultV2InKindRedeem = exports.prepareVaultV2ForceWithdraw = exports.prepareVaultV2ForceRedeem = exports.prepareVaultV2Deposit = exports.prepareVaultV1Withdraw = exports.prepareVaultV1Redeem = exports.prepareVaultV1MigrateToV2 = exports.prepareVaultV1InKindRedeem = exports.prepareVaultV1Deposit = exports.parseTransactionPlan = exports.NonIntegerInputError = exports.InvalidTransactionPlanError = exports.InvalidCalldataOriginError = exports.IncompleteTransactionPlanError = exports.getPendingSignatureRequests = exports.buildTransactions = exports.buildTransaction = exports.applySignatures = exports.validateClientChainId = void 0;
18
18
  __exportStar(require("./actions/index.js"), exports);
19
19
  var validateClientChainId_js_1 = require("./actions/requirements/validateClientChainId.js");
20
20
  Object.defineProperty(exports, "validateClientChainId", { enumerable: true, get: function () { return validateClientChainId_js_1.validateClientChainId; } });
@@ -31,7 +31,16 @@ Object.defineProperty(exports, "InvalidCalldataOriginError", { enumerable: true,
31
31
  Object.defineProperty(exports, "InvalidTransactionPlanError", { enumerable: true, get: function () { return index_js_1.InvalidTransactionPlanError; } });
32
32
  Object.defineProperty(exports, "NonIntegerInputError", { enumerable: true, get: function () { return index_js_1.NonIntegerInputError; } });
33
33
  Object.defineProperty(exports, "parseTransactionPlan", { enumerable: true, get: function () { return index_js_1.parseTransactionPlan; } });
34
+ Object.defineProperty(exports, "prepareVaultV1Deposit", { enumerable: true, get: function () { return index_js_1.prepareVaultV1Deposit; } });
35
+ Object.defineProperty(exports, "prepareVaultV1InKindRedeem", { enumerable: true, get: function () { return index_js_1.prepareVaultV1InKindRedeem; } });
36
+ Object.defineProperty(exports, "prepareVaultV1MigrateToV2", { enumerable: true, get: function () { return index_js_1.prepareVaultV1MigrateToV2; } });
37
+ Object.defineProperty(exports, "prepareVaultV1Redeem", { enumerable: true, get: function () { return index_js_1.prepareVaultV1Redeem; } });
38
+ Object.defineProperty(exports, "prepareVaultV1Withdraw", { enumerable: true, get: function () { return index_js_1.prepareVaultV1Withdraw; } });
34
39
  Object.defineProperty(exports, "prepareVaultV2Deposit", { enumerable: true, get: function () { return index_js_1.prepareVaultV2Deposit; } });
40
+ Object.defineProperty(exports, "prepareVaultV2ForceRedeem", { enumerable: true, get: function () { return index_js_1.prepareVaultV2ForceRedeem; } });
41
+ Object.defineProperty(exports, "prepareVaultV2ForceWithdraw", { enumerable: true, get: function () { return index_js_1.prepareVaultV2ForceWithdraw; } });
42
+ Object.defineProperty(exports, "prepareVaultV2InKindRedeem", { enumerable: true, get: function () { return index_js_1.prepareVaultV2InKindRedeem; } });
43
+ Object.defineProperty(exports, "prepareVaultV2Redeem", { enumerable: true, get: function () { return index_js_1.prepareVaultV2Redeem; } });
35
44
  Object.defineProperty(exports, "prepareVaultV2Withdraw", { enumerable: true, get: function () { return index_js_1.prepareVaultV2Withdraw; } });
36
45
  Object.defineProperty(exports, "serializeTransactionPlan", { enumerable: true, get: function () { return index_js_1.serializeTransactionPlan; } });
37
46
  Object.defineProperty(exports, "TransactionPlanSignatureMismatchError", { enumerable: true, get: function () { return index_js_1.TransactionPlanSignatureMismatchError; } });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateApprovalPlanAction = validateApprovalPlanAction;
4
+ const error_js_1 = require("./error.js");
4
5
  const validation_js_1 = require("./validation.js");
5
6
  /** @internal Validates the stored ERC-20 approval action's input shape. */
6
7
  function validateApprovalPlanAction(action, path) {
@@ -10,7 +11,17 @@ function validateApprovalPlanAction(action, path) {
10
11
  fields: {
11
12
  token: "address",
12
13
  spender: "address",
13
- amount: "uint256 bigint",
14
14
  },
15
15
  });
16
+ if ((inputs.assets === undefined) === (inputs.shares === undefined)) {
17
+ throw new error_js_1.InvalidTransactionPlanError({
18
+ path: `${path}.inputs`,
19
+ reason: "expected exactly one of assets or shares",
20
+ });
21
+ }
22
+ const field = inputs.assets === undefined ? "shares" : "assets";
23
+ (0, validation_js_1.validatePlanField)(inputs[field], {
24
+ path: `${path}.inputs.${field}`,
25
+ type: "uint256 bigint",
26
+ });
16
27
  }
@@ -0,0 +1,22 @@
1
+ import { type AccrualVault, type AccrualVaultV2 } from "@morpho-org/blue-sdk";
2
+ import type { Client } from "viem";
3
+ import { type ReferenceTimestampParams } from "../types/index.js";
4
+ import { type Funding, type IntentParams } from "./intent.js";
5
+ import type { TransactionPlan } from "./types.js";
6
+ /** @internal Validates the stored Vault V1 or V2 deposit action's input shape. */
7
+ export declare function validateDepositPlanAction(action: Record<string, unknown>, path: string): void;
8
+ /** @internal Shared caller intent for a snapshot-quoted vault deposit. */
9
+ export interface DepositPlanParams<TSnapshot extends AccrualVault | AccrualVaultV2> extends IntentParams, ReferenceTimestampParams {
10
+ /** WAD-scaled tolerance for the share-price bound; defaults to `DEFAULT_SLIPPAGE_TOLERANCE`. */
11
+ readonly slippageTolerance?: bigint;
12
+ /** Caller-fetched accrual snapshot; only derived inputs are stored in the plan. */
13
+ readonly vault: TSnapshot;
14
+ /** Gross assets the account pays, before the referral fee. */
15
+ readonly assets: bigint;
16
+ /** Defaults to `{ type: "erc20" }`. */
17
+ readonly funding?: Funding;
18
+ }
19
+ /** @internal Prepares a deposit using its vault action and caller-supplied snapshot type. */
20
+ export declare function prepareVaultDeposit<TSnapshot extends AccrualVault | AccrualVaultV2>(client: Client, params: DepositPlanParams<TSnapshot> & {
21
+ readonly type: "vaultV1Deposit" | "vaultV2Deposit";
22
+ }): Promise<TransactionPlan>;
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateDepositPlanAction = validateDepositPlanAction;
4
+ exports.prepareVaultDeposit = prepareVaultDeposit;
5
+ const blue_sdk_1 = require("@morpho-org/blue-sdk");
6
+ const morpho_ts_1 = require("@morpho-org/morpho-ts");
7
+ const common_js_1 = require("../actions/bundles/common.js");
8
+ const validateClientChainId_js_1 = require("../actions/requirements/validateClientChainId.js");
9
+ const assertContractCode_js_1 = require("../entities/requirements/assertContractCode.js");
10
+ const index_js_1 = require("../helpers/index.js");
11
+ const validate_js_1 = require("../helpers/validate.js");
12
+ const index_js_2 = require("../types/index.js");
13
+ const error_js_1 = require("./error.js");
14
+ const intent_js_1 = require("./intent.js");
15
+ const requirements_js_1 = require("./requirements.js");
16
+ const validation_js_1 = require("./validation.js");
17
+ /** @internal Validates the stored Vault V1 or V2 deposit action's input shape. */
18
+ function validateDepositPlanAction(action, path) {
19
+ const inputs = (0, validation_js_1.validateVaultPlanAction)(action, path);
20
+ (0, validation_js_1.validatePlanFields)(inputs, {
21
+ path: `${path}.inputs`,
22
+ fields: { asset: "address", maxSharePrice: "uint256 bigint" },
23
+ });
24
+ if ((inputs.assets === undefined) === (inputs.nativeAssets === undefined)) {
25
+ throw new error_js_1.InvalidTransactionPlanError({
26
+ path: `${path}.inputs`,
27
+ reason: "expected exactly one of assets or nativeAssets",
28
+ });
29
+ }
30
+ const field = inputs.assets === undefined ? "nativeAssets" : "assets";
31
+ (0, validation_js_1.validatePlanField)(inputs[field], {
32
+ path: `${path}.inputs.${field}`,
33
+ type: "uint256 bigint",
34
+ });
35
+ }
36
+ function resolveDepositInputs(params, now) {
37
+ const { vault, chainId, assets } = params;
38
+ const intent = (0, intent_js_1.resolveIntent)(params, now);
39
+ const slippageTolerance = params.slippageTolerance ?? blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE;
40
+ (0, validate_js_1.validateSlippageTolerance)(slippageTolerance);
41
+ const native = (params.funding ?? { type: "erc20" }).type === "native";
42
+ if (assets <= 0n) {
43
+ throw new index_js_2.NonPositiveInputError("assets", assets);
44
+ }
45
+ // Reject amounts that cannot be encoded as uint256 before making RPC requests.
46
+ (0, validate_js_1.validateUint256Field)("assets", assets);
47
+ const common = (0, common_js_1.normalizeBundlesCommonParams)({
48
+ deadline: intent.deadline,
49
+ referralFeePct: intent.referralFeePct,
50
+ referralFeeRecipient: intent.referralFeeRecipient,
51
+ });
52
+ const { asset } = vault;
53
+ // Native funding must target the chain's wrapped-native vault asset.
54
+ if (native) {
55
+ (0, validate_js_1.validateNativeVaultAsset)(chainId, asset);
56
+ }
57
+ // The quote depends only on the snapshot and the intent, so it is fixed before any read.
58
+ const maxSharePrice = (0, index_js_1.computeVaultMaxSharePrice)({
59
+ vaultData: vault,
60
+ deadline: intent.deadline,
61
+ assets: assets - (0, common_js_1.getBundlesReferralFeeAssets)(assets, common.referralFeePct),
62
+ slippageTolerance,
63
+ });
64
+ return { intent, native, common, asset, maxSharePrice };
65
+ }
66
+ /** @internal Prepares a deposit using its vault action and caller-supplied snapshot type. */
67
+ async function prepareVaultDeposit(client, params) {
68
+ const { chainId, account, assets } = params;
69
+ const vault = params.vault.address;
70
+ const now = params.now ?? morpho_ts_1.Time.timestamp();
71
+ const { intent, native, common, asset, maxSharePrice } = resolveDepositInputs(params, now);
72
+ const spender = (0, morpho_ts_1.getChainAddress)(chainId, "bundles.vaultBundlesV1");
73
+ const [requirements] = await Promise.all([
74
+ (0, validateClientChainId_js_1.validateClientChainId)(client, chainId).then(() => native
75
+ ? []
76
+ : (0, requirements_js_1.getTokenRequirements)(client, {
77
+ token: asset,
78
+ spender,
79
+ amount: assets,
80
+ owner: account,
81
+ chainId,
82
+ deadline: intent.deadline,
83
+ now,
84
+ supportSignature: intent.supportSignature,
85
+ deployless: intent.deployless,
86
+ })),
87
+ (0, assertContractCode_js_1.assertRegistryTargetsHaveCode)(client, chainId, [
88
+ { role: "bundles.vaultBundlesV1", address: spender },
89
+ ]),
90
+ ]);
91
+ const approvals = [];
92
+ const signatureRequests = [];
93
+ const tokenPermitRequestId = `${params.type}:tokenPermit`;
94
+ for (const requirement of requirements) {
95
+ if ("sign" in requirement) {
96
+ signatureRequests.push((0, requirements_js_1.buildPermitSignatureRequest)(requirement, tokenPermitRequestId));
97
+ }
98
+ else {
99
+ approvals.push((0, requirements_js_1.buildApprovalStep)(requirement, {
100
+ id: approvals.length === 0
101
+ ? `${params.type}:approval`
102
+ : `${params.type}:approval:${approvals.length + 1}`,
103
+ chainId,
104
+ account,
105
+ denomination: "assets",
106
+ }));
107
+ }
108
+ }
109
+ return (0, morpho_ts_1.deepFreeze)(structuredClone({
110
+ version: 2,
111
+ account,
112
+ chainId,
113
+ expiresAt: intent.expiresAt,
114
+ ...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
115
+ steps: [
116
+ ...approvals,
117
+ {
118
+ id: params.type,
119
+ label: "Deposit into vault",
120
+ action: {
121
+ type: params.type,
122
+ inputs: {
123
+ chainId,
124
+ account,
125
+ vault,
126
+ asset,
127
+ maxSharePrice,
128
+ ...(native ? { nativeAssets: assets } : { assets }),
129
+ ...common,
130
+ },
131
+ signatureRequestIds: signatureRequests.length > 0
132
+ ? { tokenPermit: tokenPermitRequestId }
133
+ : {},
134
+ },
135
+ },
136
+ ],
137
+ signatureRequests,
138
+ }));
139
+ }
@@ -1,5 +1,6 @@
1
1
  import type { Address } from "viem";
2
2
  /**
3
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
3
4
  * Thrown when an operation's account is the zero address.
4
5
  * @example
5
6
  * ```ts
@@ -7,7 +8,6 @@ import type { Address } from "viem";
7
8
  * import { zeroAddress } from "viem";
8
9
  * const error = new ZeroAccountError(zeroAddress);
9
10
  * ```
10
- * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
11
11
  */
12
12
  export declare class ZeroAccountError extends Error {
13
13
  readonly account: Address;
@@ -15,8 +15,8 @@ export declare class ZeroAccountError extends Error {
15
15
  constructor(account: Address);
16
16
  }
17
17
  /**
18
- * A stored plan uses a format version this SDK cannot interpret.
19
18
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
19
+ * A stored plan uses a format version this SDK cannot interpret.
20
20
  */
21
21
  export declare class UnsupportedTransactionPlanVersionError extends Error {
22
22
  readonly version: number;
@@ -32,8 +32,8 @@ export declare class UnsupportedTransactionPlanVersionError extends Error {
32
32
  constructor(version: number);
33
33
  }
34
34
  /**
35
- * A selected plan step names an action this SDK cannot build.
36
35
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
36
+ * A selected plan step names an action this SDK cannot build.
37
37
  */
38
38
  export declare class UnsupportedTransactionPlanActionError extends Error {
39
39
  readonly actionType: string;
@@ -49,8 +49,8 @@ export declare class UnsupportedTransactionPlanActionError extends Error {
49
49
  constructor(actionType: string);
50
50
  }
51
51
  /**
52
- * Restored plan data has an invalid shape or inconsistent references.
53
52
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
53
+ * Restored plan data has an invalid shape or inconsistent references.
54
54
  */
55
55
  export declare class InvalidTransactionPlanError extends Error {
56
56
  /** JSON path of the first rejected value. */
@@ -73,11 +73,13 @@ export declare class InvalidTransactionPlanError extends Error {
73
73
  });
74
74
  }
75
75
  /**
76
- * A step references a signature request that is absent or has no signature yet.
77
76
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
77
+ * A step references a signature request that is absent or has no signature yet.
78
78
  */
79
79
  export declare class IncompleteTransactionPlanError extends Error {
80
80
  readonly id: string;
81
+ /** The missing dependency is a signature request. */
82
+ readonly kind = "signature";
81
83
  /**
82
84
  * Identifies the signature request needed to build the transaction.
83
85
  * @param id - Plan-local signature request ID.
@@ -90,8 +92,8 @@ export declare class IncompleteTransactionPlanError extends Error {
90
92
  constructor(id: string);
91
93
  }
92
94
  /**
93
- * A plan's signature request disagrees with its referencing action or has no reference.
94
95
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
96
+ * A plan's signature request disagrees with its referencing action or has no reference.
95
97
  */
96
98
  export declare class TransactionPlanSignatureMismatchError extends Error {
97
99
  readonly id: string;
@@ -108,8 +110,8 @@ export declare class TransactionPlanSignatureMismatchError extends Error {
108
110
  constructor(id: string, field: string);
109
111
  }
110
112
  /**
111
- * `calldataOrigin` is not a 0x-prefixed hex string holding a whole number of bytes.
112
113
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
114
+ * `calldataOrigin` is not a 0x-prefixed hex string holding a whole number of bytes.
113
115
  */
114
116
  export declare class InvalidCalldataOriginError extends Error {
115
117
  readonly calldataOrigin: string;
@@ -125,8 +127,8 @@ export declare class InvalidCalldataOriginError extends Error {
125
127
  constructor(calldataOrigin: string);
126
128
  }
127
129
  /**
128
- * A number input that must be an integer is fractional, infinite or not a number.
129
130
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
131
+ * A number input that must be an integer is fractional, infinite or not a number.
130
132
  */
131
133
  export declare class NonIntegerInputError extends Error {
132
134
  readonly field: string;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NonIntegerInputError = exports.InvalidCalldataOriginError = exports.TransactionPlanSignatureMismatchError = exports.IncompleteTransactionPlanError = exports.InvalidTransactionPlanError = exports.UnsupportedTransactionPlanActionError = exports.UnsupportedTransactionPlanVersionError = exports.ZeroAccountError = void 0;
4
4
  /**
5
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
5
6
  * Thrown when an operation's account is the zero address.
6
7
  * @example
7
8
  * ```ts
@@ -9,7 +10,6 @@ exports.NonIntegerInputError = exports.InvalidCalldataOriginError = exports.Tran
9
10
  * import { zeroAddress } from "viem";
10
11
  * const error = new ZeroAccountError(zeroAddress);
11
12
  * ```
12
- * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
13
13
  */
14
14
  class ZeroAccountError extends Error {
15
15
  account;
@@ -22,8 +22,8 @@ class ZeroAccountError extends Error {
22
22
  }
23
23
  exports.ZeroAccountError = ZeroAccountError;
24
24
  /**
25
- * A stored plan uses a format version this SDK cannot interpret.
26
25
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
26
+ * A stored plan uses a format version this SDK cannot interpret.
27
27
  */
28
28
  class UnsupportedTransactionPlanVersionError extends Error {
29
29
  version;
@@ -44,8 +44,8 @@ class UnsupportedTransactionPlanVersionError extends Error {
44
44
  }
45
45
  exports.UnsupportedTransactionPlanVersionError = UnsupportedTransactionPlanVersionError;
46
46
  /**
47
- * A selected plan step names an action this SDK cannot build.
48
47
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
48
+ * A selected plan step names an action this SDK cannot build.
49
49
  */
50
50
  class UnsupportedTransactionPlanActionError extends Error {
51
51
  actionType;
@@ -66,8 +66,8 @@ class UnsupportedTransactionPlanActionError extends Error {
66
66
  }
67
67
  exports.UnsupportedTransactionPlanActionError = UnsupportedTransactionPlanActionError;
68
68
  /**
69
- * Restored plan data has an invalid shape or inconsistent references.
70
69
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
70
+ * Restored plan data has an invalid shape or inconsistent references.
71
71
  */
72
72
  class InvalidTransactionPlanError extends Error {
73
73
  /** JSON path of the first rejected value. */
@@ -92,11 +92,13 @@ class InvalidTransactionPlanError extends Error {
92
92
  }
93
93
  exports.InvalidTransactionPlanError = InvalidTransactionPlanError;
94
94
  /**
95
- * A step references a signature request that is absent or has no signature yet.
96
95
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
96
+ * A step references a signature request that is absent or has no signature yet.
97
97
  */
98
98
  class IncompleteTransactionPlanError extends Error {
99
99
  id;
100
+ /** The missing dependency is a signature request. */
101
+ kind = "signature";
100
102
  /**
101
103
  * Identifies the signature request needed to build the transaction.
102
104
  * @param id - Plan-local signature request ID.
@@ -114,8 +116,8 @@ class IncompleteTransactionPlanError extends Error {
114
116
  }
115
117
  exports.IncompleteTransactionPlanError = IncompleteTransactionPlanError;
116
118
  /**
117
- * A plan's signature request disagrees with its referencing action or has no reference.
118
119
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
120
+ * A plan's signature request disagrees with its referencing action or has no reference.
119
121
  */
120
122
  class TransactionPlanSignatureMismatchError extends Error {
121
123
  id;
@@ -138,8 +140,8 @@ class TransactionPlanSignatureMismatchError extends Error {
138
140
  }
139
141
  exports.TransactionPlanSignatureMismatchError = TransactionPlanSignatureMismatchError;
140
142
  /**
141
- * `calldataOrigin` is not a 0x-prefixed hex string holding a whole number of bytes.
142
143
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
144
+ * `calldataOrigin` is not a 0x-prefixed hex string holding a whole number of bytes.
143
145
  */
144
146
  class InvalidCalldataOriginError extends Error {
145
147
  calldataOrigin;
@@ -160,8 +162,8 @@ class InvalidCalldataOriginError extends Error {
160
162
  }
161
163
  exports.InvalidCalldataOriginError = InvalidCalldataOriginError;
162
164
  /**
163
- * A number input that must be an integer is fractional, infinite or not a number.
164
165
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
166
+ * A number input that must be an integer is fractional, infinite or not a number.
165
167
  */
166
168
  class NonIntegerInputError extends Error {
167
169
  field;
@@ -12,7 +12,8 @@ const getErc2612Permit_js_1 = require("../entities/requirements/getErc2612Permit
12
12
  */
13
13
  async function getTokenPermit(client, params) {
14
14
  const { dai } = (0, blue_sdk_1.getChainAddresses)(params.chainId);
15
- if ((0, morpho_ts_1.isDefined)(dai) && (0, viem_1.isAddressEqual)(params.token, dai))
15
+ if ((0, morpho_ts_1.isDefined)(dai) && (0, viem_1.isAddressEqual)(params.token, dai)) {
16
16
  return undefined;
17
+ }
17
18
  return (0, getErc2612Permit_js_1.getErc2612Permit)(client, params);
18
19
  }
@@ -3,7 +3,25 @@ export type { Funding, IntentParams, ReferralFee, } from "./intent.js";
3
3
  export { applySignatures, buildTransaction, buildTransactions, getPendingSignatureRequests, } from "./plan.js";
4
4
  export { parseTransactionPlan, serializeTransactionPlan } from "./serde.js";
5
5
  export type { Action, SignatureRequest, Step, TransactionPlan, } from "./types.js";
6
+ export type { VaultV1DepositPlanParams } from "./vaultv1/deposit.js";
7
+ export { prepareVaultV1Deposit } from "./vaultv1/deposit.js";
8
+ export type { VaultV1InKindRedeemPlanParams } from "./vaultv1/inKindRedeem.js";
9
+ export { prepareVaultV1InKindRedeem } from "./vaultv1/inKindRedeem.js";
10
+ export type { VaultV1MigrateToV2PlanParams } from "./vaultv1/migrateToV2.js";
11
+ export { prepareVaultV1MigrateToV2 } from "./vaultv1/migrateToV2.js";
12
+ export type { VaultV1RedeemPlanParams } from "./vaultv1/redeem.js";
13
+ export { prepareVaultV1Redeem } from "./vaultv1/redeem.js";
14
+ export type { VaultV1WithdrawPlanParams } from "./vaultv1/withdraw.js";
15
+ export { prepareVaultV1Withdraw } from "./vaultv1/withdraw.js";
6
16
  export type { VaultV2DepositPlanParams } from "./vaultv2/deposit.js";
7
17
  export { prepareVaultV2Deposit } from "./vaultv2/deposit.js";
18
+ export type { VaultV2ForceRedeemPlanParams } from "./vaultv2/forceRedeem.js";
19
+ export { prepareVaultV2ForceRedeem } from "./vaultv2/forceRedeem.js";
20
+ export type { VaultV2ForceWithdrawPlanParams } from "./vaultv2/forceWithdraw.js";
21
+ export { prepareVaultV2ForceWithdraw } from "./vaultv2/forceWithdraw.js";
22
+ export type { VaultV2InKindRedeemPlanParams } from "./vaultv2/inKindRedeem.js";
23
+ export { prepareVaultV2InKindRedeem } from "./vaultv2/inKindRedeem.js";
24
+ export type { VaultV2RedeemPlanParams } from "./vaultv2/redeem.js";
25
+ export { prepareVaultV2Redeem } from "./vaultv2/redeem.js";
8
26
  export type { VaultV2WithdrawPlanParams } from "./vaultv2/withdraw.js";
9
27
  export { prepareVaultV2Withdraw } from "./vaultv2/withdraw.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareVaultV2Withdraw = exports.prepareVaultV2Deposit = exports.serializeTransactionPlan = exports.parseTransactionPlan = exports.getPendingSignatureRequests = exports.buildTransactions = exports.buildTransaction = exports.applySignatures = exports.ZeroAccountError = exports.UnsupportedTransactionPlanVersionError = exports.UnsupportedTransactionPlanActionError = exports.TransactionPlanSignatureMismatchError = exports.NonIntegerInputError = exports.InvalidTransactionPlanError = exports.InvalidCalldataOriginError = exports.IncompleteTransactionPlanError = void 0;
3
+ exports.prepareVaultV2Withdraw = exports.prepareVaultV2Redeem = exports.prepareVaultV2InKindRedeem = exports.prepareVaultV2ForceWithdraw = exports.prepareVaultV2ForceRedeem = exports.prepareVaultV2Deposit = exports.prepareVaultV1Withdraw = exports.prepareVaultV1Redeem = exports.prepareVaultV1MigrateToV2 = exports.prepareVaultV1InKindRedeem = exports.prepareVaultV1Deposit = exports.serializeTransactionPlan = exports.parseTransactionPlan = exports.getPendingSignatureRequests = exports.buildTransactions = exports.buildTransaction = exports.applySignatures = exports.ZeroAccountError = exports.UnsupportedTransactionPlanVersionError = exports.UnsupportedTransactionPlanActionError = exports.TransactionPlanSignatureMismatchError = exports.NonIntegerInputError = exports.InvalidTransactionPlanError = exports.InvalidCalldataOriginError = exports.IncompleteTransactionPlanError = void 0;
4
4
  var error_js_1 = require("./error.js");
5
5
  Object.defineProperty(exports, "IncompleteTransactionPlanError", { enumerable: true, get: function () { return error_js_1.IncompleteTransactionPlanError; } });
6
6
  Object.defineProperty(exports, "InvalidCalldataOriginError", { enumerable: true, get: function () { return error_js_1.InvalidCalldataOriginError; } });
@@ -18,7 +18,25 @@ Object.defineProperty(exports, "getPendingSignatureRequests", { enumerable: true
18
18
  var serde_js_1 = require("./serde.js");
19
19
  Object.defineProperty(exports, "parseTransactionPlan", { enumerable: true, get: function () { return serde_js_1.parseTransactionPlan; } });
20
20
  Object.defineProperty(exports, "serializeTransactionPlan", { enumerable: true, get: function () { return serde_js_1.serializeTransactionPlan; } });
21
- var deposit_js_1 = require("./vaultv2/deposit.js");
22
- Object.defineProperty(exports, "prepareVaultV2Deposit", { enumerable: true, get: function () { return deposit_js_1.prepareVaultV2Deposit; } });
23
- var withdraw_js_1 = require("./vaultv2/withdraw.js");
24
- Object.defineProperty(exports, "prepareVaultV2Withdraw", { enumerable: true, get: function () { return withdraw_js_1.prepareVaultV2Withdraw; } });
21
+ var deposit_js_1 = require("./vaultv1/deposit.js");
22
+ Object.defineProperty(exports, "prepareVaultV1Deposit", { enumerable: true, get: function () { return deposit_js_1.prepareVaultV1Deposit; } });
23
+ var inKindRedeem_js_1 = require("./vaultv1/inKindRedeem.js");
24
+ Object.defineProperty(exports, "prepareVaultV1InKindRedeem", { enumerable: true, get: function () { return inKindRedeem_js_1.prepareVaultV1InKindRedeem; } });
25
+ var migrateToV2_js_1 = require("./vaultv1/migrateToV2.js");
26
+ Object.defineProperty(exports, "prepareVaultV1MigrateToV2", { enumerable: true, get: function () { return migrateToV2_js_1.prepareVaultV1MigrateToV2; } });
27
+ var redeem_js_1 = require("./vaultv1/redeem.js");
28
+ Object.defineProperty(exports, "prepareVaultV1Redeem", { enumerable: true, get: function () { return redeem_js_1.prepareVaultV1Redeem; } });
29
+ var withdraw_js_1 = require("./vaultv1/withdraw.js");
30
+ Object.defineProperty(exports, "prepareVaultV1Withdraw", { enumerable: true, get: function () { return withdraw_js_1.prepareVaultV1Withdraw; } });
31
+ var deposit_js_2 = require("./vaultv2/deposit.js");
32
+ Object.defineProperty(exports, "prepareVaultV2Deposit", { enumerable: true, get: function () { return deposit_js_2.prepareVaultV2Deposit; } });
33
+ var forceRedeem_js_1 = require("./vaultv2/forceRedeem.js");
34
+ Object.defineProperty(exports, "prepareVaultV2ForceRedeem", { enumerable: true, get: function () { return forceRedeem_js_1.prepareVaultV2ForceRedeem; } });
35
+ var forceWithdraw_js_1 = require("./vaultv2/forceWithdraw.js");
36
+ Object.defineProperty(exports, "prepareVaultV2ForceWithdraw", { enumerable: true, get: function () { return forceWithdraw_js_1.prepareVaultV2ForceWithdraw; } });
37
+ var inKindRedeem_js_2 = require("./vaultv2/inKindRedeem.js");
38
+ Object.defineProperty(exports, "prepareVaultV2InKindRedeem", { enumerable: true, get: function () { return inKindRedeem_js_2.prepareVaultV2InKindRedeem; } });
39
+ var redeem_js_2 = require("./vaultv2/redeem.js");
40
+ Object.defineProperty(exports, "prepareVaultV2Redeem", { enumerable: true, get: function () { return redeem_js_2.prepareVaultV2Redeem; } });
41
+ var withdraw_js_2 = require("./vaultv2/withdraw.js");
42
+ Object.defineProperty(exports, "prepareVaultV2Withdraw", { enumerable: true, get: function () { return withdraw_js_2.prepareVaultV2Withdraw; } });
@@ -1,7 +1,7 @@
1
1
  import { type Address, type Hex } from "viem";
2
2
  /**
3
- * Which balance pays a deposit: the vault asset, or native currency the bundle wraps.
4
3
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
4
+ * Which balance pays a deposit: the vault asset, or native currency the bundle wraps.
5
5
  */
6
6
  export type Funding = {
7
7
  readonly type: "erc20";
@@ -9,16 +9,16 @@ export type Funding = {
9
9
  readonly type: "native";
10
10
  };
11
11
  /**
12
- * Referral fee in basis points of the gross amount, paid to `recipient`.
13
12
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
13
+ * Referral fee in basis points of the gross amount, paid to `recipient`.
14
14
  */
15
15
  export interface ReferralFee {
16
16
  readonly bps: number;
17
17
  readonly recipient: Address;
18
18
  }
19
19
  /**
20
- * Intent fields shared by every prepare function, mirroring the Actions API intent inputs.
21
20
  * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
21
+ * Intent fields shared by every prepare function, mirroring the Actions API intent inputs.
22
22
  */
23
23
  export interface IntentParams {
24
24
  readonly chainId: number;