@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
@@ -1,78 +1,20 @@
1
- import { DEFAULT_SLIPPAGE_TOLERANCE, } from "@morpho-org/blue-sdk";
2
- import { deepFreeze, getChainAddress, Time } from "@morpho-org/morpho-ts";
3
- import { isAddressEqual } from "viem";
4
- import { getBundlesReferralFeeAssets, normalizeBundlesCommonParams, selectBundlesTokenRequirementSignature, } from "../../actions/bundles/common.js";
5
- import { validateClientChainId } from "../../actions/requirements/validateClientChainId.js";
1
+ import { getChainAddress } from "@morpho-org/morpho-ts";
2
+ import { selectBundlesTokenRequirementSignature } from "../../actions/bundles/common.js";
6
3
  import { vaultV2Deposit } from "../../actions/vaultV2/deposit.js";
7
- import { assertRegistryTargetsHaveCode } from "../../entities/requirements/assertContractCode.js";
8
- import { computeVaultMaxSharePrice } from "../../helpers/index.js";
9
- import { validateNativeVaultAsset, validateSlippageTolerance, validateUint256Field, } from "../../helpers/validate.js";
10
- import { NonPositiveInputError, VaultAddressMismatchError, } from "../../types/index.js";
11
- import { InvalidTransactionPlanError } from "../error.js";
12
- import { resolveIntent } from "../intent.js";
4
+ import { prepareVaultDeposit } from "../deposit.js";
13
5
  import { getVaultPermit } from "../permit.js";
14
- import { buildApprovalStep, buildPermitSignatureRequest, getTokenRequirements, } from "../requirements.js";
15
- import { validatePlanField, validatePlanFields, validateVaultPlanAction, } from "../validation.js";
16
- /** @internal Validates the stored Vault V2 deposit action's input shape. */
17
- export function validateDepositPlanAction(action, path) {
18
- const inputs = validateVaultPlanAction(action, path);
19
- validatePlanFields(inputs, {
20
- path: `${path}.inputs`,
21
- fields: { asset: "address", maxSharePrice: "uint256 bigint" },
22
- });
23
- if ((inputs.amount === undefined) === (inputs.nativeAmount === undefined))
24
- throw new InvalidTransactionPlanError({
25
- path: `${path}.inputs`,
26
- reason: "expected exactly one of amount or nativeAmount",
27
- });
28
- const field = inputs.amount === undefined ? "nativeAmount" : "amount";
29
- validatePlanField(inputs[field], {
30
- path: `${path}.inputs.${field}`,
31
- type: "uint256 bigint",
32
- });
33
- }
34
- function resolveDepositInputs(params, now) {
35
- const { vault, chainId, amount, vaultData } = params;
36
- const intent = resolveIntent(params, now);
37
- const slippageTolerance = params.slippageTolerance ?? DEFAULT_SLIPPAGE_TOLERANCE;
38
- validateSlippageTolerance(slippageTolerance);
39
- const native = (params.funding ?? { type: "erc20" }).type === "native";
40
- if (amount <= 0n)
41
- throw new NonPositiveInputError("amount", amount);
42
- // Reject amounts that cannot be encoded as uint256 before making RPC requests.
43
- validateUint256Field("amount", amount);
44
- const common = normalizeBundlesCommonParams({
45
- deadline: intent.deadline,
46
- referralFeePct: intent.referralFeePct,
47
- referralFeeRecipient: intent.referralFeeRecipient,
48
- });
49
- if (!isAddressEqual(vaultData.address, vault))
50
- throw new VaultAddressMismatchError(vaultData.address, vault);
51
- const { asset } = vaultData;
52
- // Native funding must target the chain's wrapped-native vault asset.
53
- if (native)
54
- validateNativeVaultAsset(chainId, asset);
55
- // The quote depends only on the snapshot and the intent, so it is fixed before any read.
56
- const maxSharePrice = computeVaultMaxSharePrice({
57
- vaultData,
58
- deadline: intent.deadline,
59
- assets: amount - getBundlesReferralFeeAssets(amount, common.referralFeePct),
60
- slippageTolerance,
61
- });
62
- return { intent, native, common, asset, maxSharePrice };
63
- }
64
6
  /**
7
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
65
8
  * Prepares a deposit plan from caller intent and a vault snapshot, reading the token prerequisites
66
9
  * directly. The quote is fixed on the deposit step at preparation, so the returned plan is static:
67
10
  * only signatures are added before building.
68
11
  * @param client - Viem client for `params.chainId`, used for allowance and permit metadata reads only.
69
- * @param params.vault - Vault V2 contract receiving the net deposit.
70
- * @param params.vaultData - Caller-fetched `AccrualVaultV2` snapshot of `vault`, used to derive the asset and deadline-accrued share-price bound.
12
+ * @param params.vault - Caller-fetched AccrualVaultV2 snapshot used for the quote; the address is vault.address.
71
13
  * @param params.chainId - Chain containing the vault and registered VaultBundlesV1 contract.
72
14
  * @param params.account - Non-zero account funding, signing and sending the deposit.
73
- * @param params.amount - Positive gross deposit in asset base units, before referral fees.
15
+ * @param params.assets - Positive gross deposit in asset base units, before referral fees.
74
16
  * @param params.funding.type - Optional funding source: `"erc20"` (default) or `"native"`; native funding requires the vault asset to be wNative.
75
- * @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be below 10,000.
17
+ * @param params.referralFee.bps - Optional integer fee in basis points of the gross assets; defaults to zero and must be below 10,000.
76
18
  * @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
77
19
  * @param params.slippageTolerance - Optional WAD-scaled tolerance for the share-price bound; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
78
20
  * @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
@@ -83,15 +25,14 @@ function resolveDepositInputs(params, now) {
83
25
  * @returns A plan with approvals, concrete signature requests and the deposit step.
84
26
  * @throws {ZeroAccountError} when `account` is the zero address.
85
27
  * @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
86
- * @throws {NonPositiveInputError} when `expiresAt`, `amount`, net assets or previewed shares are not positive.
28
+ * @throws {NonPositiveInputError} when `expiresAt`, `assets`, net assets or previewed shares are not positive.
87
29
  * @throws {ExpiredDeadlineError} when `expiresAt` is at or before `now` (device clock when `now` is omitted).
88
30
  * @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
89
- * @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 10,000 or `amount` exceeds uint256.
31
+ * @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 10,000 or `assets` exceeds uint256.
90
32
  * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
91
33
  * @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
92
34
  * @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
93
35
  * @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
94
- * @throws {VaultAddressMismatchError} when `vaultData` describes another vault.
95
36
  * @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a vault whose asset is not wNative.
96
37
  * @throws {ChainIdMismatchError} when the client targets another chain.
97
38
  * @throws {MissingContractCodeError} when the VaultBundlesV1 contract is absent.
@@ -105,88 +46,19 @@ function resolveDepositInputs(params, now) {
105
46
  * const client = createPublicClient({ chain: mainnet, transport: http() });
106
47
  * const vault = "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145";
107
48
  * const plan = await prepareVaultV2Deposit(client, {
108
- * vault, chainId: 1, account: "0x0000000000000000000000000000000000000001", amount: 1_000_000n, supportSignature: true,
109
- * vaultData: await fetchAccrualVaultV2(vault, client),
49
+ * chainId: 1, account: "0x0000000000000000000000000000000000000001", assets: 1_000_000n, supportSignature: true,
50
+ * vault: await fetchAccrualVaultV2(vault, client),
110
51
  * now: (await client.getBlock()).timestamp,
111
52
  * });
112
53
  * // Sign the pending requests, verify and attach with applySignatures, then build.
113
54
  * ```
114
- * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
115
55
  */
116
56
  export async function prepareVaultV2Deposit(client, params) {
117
- const { vault, chainId, account, amount } = params;
118
- const now = params.now ?? Time.timestamp();
119
- const { intent, native, common, asset, maxSharePrice } = resolveDepositInputs(params, now);
120
- const spender = getChainAddress(chainId, "bundles.vaultBundlesV1");
121
- const [requirements] = await Promise.all([
122
- validateClientChainId(client, chainId).then(() => native
123
- ? []
124
- : getTokenRequirements(client, {
125
- token: asset,
126
- spender,
127
- amount,
128
- owner: account,
129
- chainId,
130
- deadline: intent.deadline,
131
- now,
132
- supportSignature: intent.supportSignature,
133
- deployless: intent.deployless,
134
- })),
135
- assertRegistryTargetsHaveCode(client, chainId, [
136
- { role: "bundles.vaultBundlesV1", address: spender },
137
- ]),
138
- ]);
139
- const approvals = [];
140
- const signatureRequests = [];
141
- const tokenPermitRequestId = "vaultV2Deposit:tokenPermit";
142
- for (const requirement of requirements) {
143
- if ("sign" in requirement) {
144
- signatureRequests.push(buildPermitSignatureRequest(requirement, tokenPermitRequestId));
145
- }
146
- else {
147
- approvals.push(buildApprovalStep(requirement, {
148
- id: approvals.length === 0
149
- ? "vaultV2Deposit:approval"
150
- : `vaultV2Deposit:approval:${approvals.length + 1}`,
151
- chainId,
152
- account,
153
- }));
154
- }
155
- }
156
- return deepFreeze(structuredClone({
157
- version: 1,
158
- account,
159
- chainId,
160
- expiresAt: intent.expiresAt,
161
- ...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
162
- steps: [
163
- ...approvals,
164
- {
165
- id: "vaultV2Deposit",
166
- label: "Deposit into vault",
167
- action: {
168
- type: "vaultV2Deposit",
169
- inputs: {
170
- chainId,
171
- account,
172
- vault,
173
- asset,
174
- maxSharePrice,
175
- ...(native ? { nativeAmount: amount } : { amount }),
176
- ...common,
177
- },
178
- signatureRequestIds: signatureRequests.length > 0
179
- ? { tokenPermit: tokenPermitRequestId }
180
- : {},
181
- },
182
- },
183
- ],
184
- signatureRequests,
185
- }));
57
+ return prepareVaultDeposit(client, { ...params, type: "vaultV2Deposit" });
186
58
  }
187
59
  /** @internal Encodes the deposit from its self-contained inputs and resolved signature requests. */
188
60
  export function buildVaultV2Deposit(action, requests) {
189
- const { asset, chainId, account, ...args } = action.inputs;
61
+ const { asset, chainId, account, assets, nativeAssets, ...args } = action.inputs;
190
62
  const signature = getVaultPermit(requests, {
191
63
  id: action.signatureRequestIds.tokenPermit,
192
64
  asset,
@@ -194,13 +66,16 @@ export function buildVaultV2Deposit(action, requests) {
194
66
  });
195
67
  const requirementSignature = selectBundlesTokenRequirementSignature(signature ? [signature] : [], {
196
68
  spender: getChainAddress(chainId, "bundles.vaultBundlesV1"),
197
- amount: action.inputs.amount ?? action.inputs.nativeAmount,
69
+ amount: assets ?? nativeAssets,
198
70
  deadline: action.inputs.deadline,
199
71
  });
200
72
  return vaultV2Deposit({
201
73
  vault: { chainId, address: action.inputs.vault, asset },
202
74
  args: {
203
75
  ...args,
76
+ ...(nativeAssets === undefined
77
+ ? { amount: assets }
78
+ : { nativeAmount: nativeAssets }),
204
79
  userAddress: account,
205
80
  requirementSignature,
206
81
  },
@@ -0,0 +1,74 @@
1
+ import type { Address, Client } from "viem";
2
+ import type { ReferenceTimestampParams, Transaction, VaultV2ForceRedeemAction } from "../../types/index.js";
3
+ import { type IntentParams } from "../intent.js";
4
+ import type { Action, TransactionPlan } from "../types.js";
5
+ /** @internal Validates the stored force-redeem action's plain input shape. */
6
+ export declare function validateForceRedeemPlanAction(action: Record<string, unknown>, path: string): void;
7
+ /**
8
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
9
+ * Caller-supplied shares and deallocations for the vault's native force-redeem multicall.
10
+ * No approval or signature is needed.
11
+ * @example
12
+ * ```ts
13
+ * const params: VaultV2ForceRedeemPlanParams = {
14
+ * vaultAddress, chainId: 1, account, shares: 100n,
15
+ * deallocations: [{ adapter, assets: 100n }],
16
+ * };
17
+ * ```
18
+ */
19
+ export interface VaultV2ForceRedeemPlanParams extends Pick<IntentParams, "chainId" | "account" | "expiresAt" | "calldataOrigin">, ReferenceTimestampParams {
20
+ readonly vaultAddress: Address;
21
+ readonly shares: bigint;
22
+ /** Fixed, ordered asset deallocations executed before redeeming. Include any required penalty buffer. */
23
+ readonly deallocations: Extract<Action, {
24
+ type: "vaultV2ForceRedeem";
25
+ }>["inputs"]["deallocations"];
26
+ }
27
+ /**
28
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
29
+ * Prepares one vault multicall, fixing the supplied deallocations and shares in the plan.
30
+ * Shares and deallocation penalties are burned from `account`; redeemed assets go to `account`.
31
+ * No permissions are requested, and expiry is plan metadata, not an onchain deadline.
32
+ * @param client - Client used to validate the chain, not retained by the plan.
33
+ * @param params.vaultAddress - Vault V2 whose shares are redeemed.
34
+ * @param params.chainId - Chain containing the vault.
35
+ * @param params.account - Share owner submitting the multicall and receiving the redeemed assets.
36
+ * @param params.shares - Positive shares to redeem, in vault share base units.
37
+ * @param params.deallocations - Non-empty, ordered deallocations with positive `assets` in asset base units, including any penalty buffer.
38
+ * @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
39
+ * @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` and is plan metadata only.
40
+ * @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
41
+ * @returns A deep-frozen `TransactionPlan` containing one `vaultV2ForceRedeem` step and no signature requests.
42
+ * @throws {ChainIdMismatchError} If the client targets another chain.
43
+ * @throws {EmptyDeallocationsError} If `deallocations` is empty.
44
+ * @throws {NonPositiveInputError} If expiry, shares or any deallocation assets are non-positive.
45
+ * @throws {ZeroAccountError} If `account` is the zero address.
46
+ * @throws {NonIntegerInputError} If `expiresAt` is not a safe integer.
47
+ * @throws {ExpiredDeadlineError} If `expiresAt` is not in the future.
48
+ * @throws {InvalidCalldataOriginError} If `calldataOrigin` is empty, malformed or has an odd number of hex digits.
49
+ * @example
50
+ * ```ts
51
+ * import { prepareVaultV2ForceRedeem, type TransactionPlan } from "@morpho-org/morpho-sdk";
52
+ * import { createPublicClient, http } from "viem";
53
+ * import { mainnet } from "viem/chains";
54
+ *
55
+ * // Fixture addresses for preparation only; use your vault, adapter and share owner before execution.
56
+ * const IN_KIND_VAULT = "0x0000000000000000000000000000000000001001";
57
+ * const IN_KIND_ADAPTER = "0x0000000000000000000000000000000000001002";
58
+ * const IN_KIND_USER = "0x0000000000000000000000000000000000001004";
59
+ * const client = createPublicClient({ chain: mainnet, transport: http() });
60
+ * const plan: TransactionPlan = await prepareVaultV2ForceRedeem(client, {
61
+ * vaultAddress: IN_KIND_VAULT, chainId: mainnet.id, account: IN_KIND_USER,
62
+ * shares: 100n,
63
+ * now: (await client.getBlock()).timestamp,
64
+ * deallocations: [{ adapter: IN_KIND_ADAPTER, assets: 100n }],
65
+ * });
66
+ * // plan.steps contains one step with action.type === "vaultV2ForceRedeem".
67
+ * // plan.signatureRequests is []; the caller signs and submits the built transaction.
68
+ * ```
69
+ */
70
+ export declare function prepareVaultV2ForceRedeem(client: Client, params: VaultV2ForceRedeemPlanParams): Promise<TransactionPlan>;
71
+ /** @internal Encodes the fixed multicall through the same action as the forceRedeem handle. */
72
+ export declare function buildVaultV2ForceRedeem(action: Extract<Action, {
73
+ type: "vaultV2ForceRedeem";
74
+ }>): Readonly<Transaction<VaultV2ForceRedeemAction>>;
@@ -0,0 +1,150 @@
1
+ import { MarketUtils } from "@morpho-org/blue-sdk";
2
+ import { deepFreeze, Time } from "@morpho-org/morpho-ts";
3
+ import { validateClientChainId } from "../../actions/requirements/validateClientChainId.js";
4
+ import { vaultV2ForceRedeem } from "../../actions/vaultV2/forceRedeem.js";
5
+ import { resolveIntent } from "../intent.js";
6
+ import { getPlanObject, validatePlanFields } from "../validation.js";
7
+ /** @internal Validates the stored force-redeem action's plain input shape. */
8
+ export function validateForceRedeemPlanAction(action, path) {
9
+ const inputPath = `${path}.inputs`;
10
+ const inputs = getPlanObject(action.inputs, inputPath);
11
+ validatePlanFields(inputs, {
12
+ path: inputPath,
13
+ fields: { vault: "address", deallocations: "array" },
14
+ });
15
+ validatePlanFields(getPlanObject(inputs.redeem, `${inputPath}.redeem`), {
16
+ path: `${inputPath}.redeem`,
17
+ fields: { shares: "uint256 bigint" },
18
+ });
19
+ for (const [index, value] of inputs.deallocations.entries()) {
20
+ const entryPath = `${inputPath}.deallocations[${index}]`;
21
+ const entry = getPlanObject(value, entryPath);
22
+ validatePlanFields(entry, {
23
+ path: entryPath,
24
+ fields: { adapter: "address", assets: "uint256 bigint" },
25
+ });
26
+ if (entry.marketParams !== undefined) {
27
+ validatePlanFields(getPlanObject(entry.marketParams, `${entryPath}.marketParams`), {
28
+ path: `${entryPath}.marketParams`,
29
+ fields: {
30
+ loanToken: "address",
31
+ collateralToken: "address",
32
+ oracle: "address",
33
+ irm: "address",
34
+ lltv: "uint256 bigint",
35
+ },
36
+ });
37
+ }
38
+ }
39
+ }
40
+ /**
41
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
42
+ * Prepares one vault multicall, fixing the supplied deallocations and shares in the plan.
43
+ * Shares and deallocation penalties are burned from `account`; redeemed assets go to `account`.
44
+ * No permissions are requested, and expiry is plan metadata, not an onchain deadline.
45
+ * @param client - Client used to validate the chain, not retained by the plan.
46
+ * @param params.vaultAddress - Vault V2 whose shares are redeemed.
47
+ * @param params.chainId - Chain containing the vault.
48
+ * @param params.account - Share owner submitting the multicall and receiving the redeemed assets.
49
+ * @param params.shares - Positive shares to redeem, in vault share base units.
50
+ * @param params.deallocations - Non-empty, ordered deallocations with positive `assets` in asset base units, including any penalty buffer.
51
+ * @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
52
+ * @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` and is plan metadata only.
53
+ * @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
54
+ * @returns A deep-frozen `TransactionPlan` containing one `vaultV2ForceRedeem` step and no signature requests.
55
+ * @throws {ChainIdMismatchError} If the client targets another chain.
56
+ * @throws {EmptyDeallocationsError} If `deallocations` is empty.
57
+ * @throws {NonPositiveInputError} If expiry, shares or any deallocation assets are non-positive.
58
+ * @throws {ZeroAccountError} If `account` is the zero address.
59
+ * @throws {NonIntegerInputError} If `expiresAt` is not a safe integer.
60
+ * @throws {ExpiredDeadlineError} If `expiresAt` is not in the future.
61
+ * @throws {InvalidCalldataOriginError} If `calldataOrigin` is empty, malformed or has an odd number of hex digits.
62
+ * @example
63
+ * ```ts
64
+ * import { prepareVaultV2ForceRedeem, type TransactionPlan } from "@morpho-org/morpho-sdk";
65
+ * import { createPublicClient, http } from "viem";
66
+ * import { mainnet } from "viem/chains";
67
+ *
68
+ * // Fixture addresses for preparation only; use your vault, adapter and share owner before execution.
69
+ * const IN_KIND_VAULT = "0x0000000000000000000000000000000000001001";
70
+ * const IN_KIND_ADAPTER = "0x0000000000000000000000000000000000001002";
71
+ * const IN_KIND_USER = "0x0000000000000000000000000000000000001004";
72
+ * const client = createPublicClient({ chain: mainnet, transport: http() });
73
+ * const plan: TransactionPlan = await prepareVaultV2ForceRedeem(client, {
74
+ * vaultAddress: IN_KIND_VAULT, chainId: mainnet.id, account: IN_KIND_USER,
75
+ * shares: 100n,
76
+ * now: (await client.getBlock()).timestamp,
77
+ * deallocations: [{ adapter: IN_KIND_ADAPTER, assets: 100n }],
78
+ * });
79
+ * // plan.steps contains one step with action.type === "vaultV2ForceRedeem".
80
+ * // plan.signatureRequests is []; the caller signs and submits the built transaction.
81
+ * ```
82
+ */
83
+ export async function prepareVaultV2ForceRedeem(client, params) {
84
+ const now = params.now ?? Time.timestamp();
85
+ const intent = resolveIntent(params, now);
86
+ const plan = structuredClone({
87
+ version: 2,
88
+ account: params.account,
89
+ chainId: params.chainId,
90
+ expiresAt: intent.expiresAt,
91
+ ...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
92
+ steps: [
93
+ {
94
+ id: "vaultV2ForceRedeem",
95
+ label: "Force redeem from vault",
96
+ action: {
97
+ type: "vaultV2ForceRedeem",
98
+ inputs: {
99
+ chainId: params.chainId,
100
+ account: params.account,
101
+ vault: params.vaultAddress,
102
+ redeem: { shares: params.shares },
103
+ deallocations: params.deallocations.map(({ adapter, assets, marketParams }) => ({
104
+ adapter,
105
+ assets,
106
+ ...(marketParams && {
107
+ marketParams: {
108
+ loanToken: marketParams.loanToken,
109
+ collateralToken: marketParams.collateralToken,
110
+ oracle: marketParams.oracle,
111
+ irm: marketParams.irm,
112
+ lltv: marketParams.lltv,
113
+ },
114
+ }),
115
+ })),
116
+ },
117
+ },
118
+ },
119
+ ],
120
+ signatureRequests: [],
121
+ });
122
+ // Validate the cloned inputs with the action encoder before returning a plan.
123
+ buildVaultV2ForceRedeem(plan.steps[0].action);
124
+ await validateClientChainId(client, params.chainId);
125
+ return deepFreeze(plan);
126
+ }
127
+ /** @internal Encodes the fixed multicall through the same action as the forceRedeem handle. */
128
+ export function buildVaultV2ForceRedeem(action) {
129
+ return vaultV2ForceRedeem({
130
+ vault: { address: action.inputs.vault },
131
+ args: {
132
+ deallocations: action.inputs.deallocations.map(({ adapter, assets, marketParams }) => ({
133
+ adapter,
134
+ amount: assets,
135
+ ...(marketParams && {
136
+ marketParams: {
137
+ ...marketParams,
138
+ id: MarketUtils.getMarketId(marketParams),
139
+ liquidationIncentiveFactor: MarketUtils.getLiquidationIncentiveFactor(marketParams),
140
+ },
141
+ }),
142
+ })),
143
+ redeem: {
144
+ shares: action.inputs.redeem.shares,
145
+ recipient: action.inputs.account,
146
+ },
147
+ onBehalf: action.inputs.account,
148
+ },
149
+ });
150
+ }
@@ -0,0 +1,98 @@
1
+ import type { AccrualVaultV2 } from "@morpho-org/blue-sdk";
2
+ import { type Address, type Client } from "viem";
3
+ import { type ReferenceTimestampParams, type Transaction, type VaultV2ForceWithdrawAction } from "../../types/index.js";
4
+ import { type IntentParams } from "../intent.js";
5
+ import type { Action, SignatureRequest, TransactionPlan } from "../types.js";
6
+ /**
7
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
8
+ * Caller intent for a Vault V2 forced exit through VaultExitBundlesV1.
9
+ * @example
10
+ * ```ts
11
+ * import type { AccrualVaultV2 } from "@morpho-org/blue-sdk";
12
+ * import type { VaultV2ForceWithdrawPlanParams } from "@morpho-org/morpho-sdk";
13
+ * import type { Address } from "viem";
14
+ * const intent = (vault: AccrualVaultV2, account: Address): VaultV2ForceWithdrawPlanParams => ({
15
+ * vault, account, chainId: 1, assets: 1_000_000n,
16
+ * });
17
+ * ```
18
+ */
19
+ export interface VaultV2ForceWithdrawPlanParams extends Omit<IntentParams, "deployless">, ReferenceTimestampParams {
20
+ /** Snapshot fetched by the caller; never stored in the plan. */
21
+ readonly vault: AccrualVaultV2;
22
+ /** Penalty-inclusive assets debited; received assets exclude penalties and referral fees. */
23
+ readonly assets: bigint;
24
+ /** Optional assertion that this is the vault's sole supported adapter. */
25
+ readonly adapter?: Address;
26
+ /** WAD-scaled tolerance for the derived floor; omitted values use the entity default. */
27
+ readonly slippageTolerance?: bigint;
28
+ }
29
+ /**
30
+ * @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
31
+ * Prepares a static forced-exit plan using shared snapshot quoting and requirement helpers.
32
+ * The adapter and realized share-price floor are fixed at preparation. VaultExitBundlesV1
33
+ * withdraws penalty-free liquidity first, then force-deallocates the remaining assets onchain.
34
+ * No fetch requests or Permit2 prerequisites are needed.
35
+ * @param client - Plain viem client for `params.chainId`, used for allowance, nonce and code reads.
36
+ * @param params.vault - Caller-fetched accrual snapshot used for the exit quote; its address identifies the vault.
37
+ * @param params.chainId - Chain containing the vault and registered VaultExitBundlesV1 contract.
38
+ * @param params.account - Non-zero account signing and sending the exit and receiving its assets.
39
+ * @param params.assets - Positive penalty-inclusive exit assets in asset base units; received assets exclude penalties and referral fees.
40
+ * @param params.adapter - Optional assertion that this address is the vault's sole supported adapter.
41
+ * @param params.slippageTolerance - Optional WAD-scaled tolerance used to derive the realized share-price floor; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
42
+ * @param params.referralFee.bps - Optional integer fee in basis points of withdrawn assets, after penalties; defaults to zero and must be below 10,000. The fee is deducted after the share-price check.
43
+ * @param params.referralFee.recipient - Optional fee recipient; must be non-zero when the fee is positive.
44
+ * @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; insufficient allowance produces an unlimited direct share approval, or an unlimited share permit when `true`.
45
+ * @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
46
+ * @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now` and within the fee-projection horizon; defaults to `now + 2h`.
47
+ * @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
48
+ * @returns A deep-frozen plan containing ordered share approvals, if needed, followed by the forced exit and its concrete permit request, if needed.
49
+ * @throws {ZeroAccountError} when `account` is the zero address.
50
+ * @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
51
+ * @throws {NonPositiveInputError} when `expiresAt` or `assets` is not positive.
52
+ * @throws {ExpiredDeadlineError} when the expiry has elapsed, including during requirement resolution.
53
+ * @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
54
+ * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
55
+ * @throws {InputExceedsMaxError} when the fee exceeds 10,000 bps, an input exceeds uint256 or the expiry exceeds the fee-projection horizon.
56
+ * @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
57
+ * @throws {ChainIdMismatchError} when the client declares or serves another chain.
58
+ * @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000.
59
+ * @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
60
+ * @throws {VaultV2SingleAdapterRequiredError} when the snapshot does not have exactly one adapter.
61
+ * @throws {AdapterNotPartOfVaultError} when the adapter assertion does not match the vault's adapter.
62
+ * @throws {VaultV2UnsupportedExitAdapterError} when the sole adapter is not a MorphoMarketV1AdapterV2.
63
+ * @throws {VaultV2UnsupportedLiquidityAdapterError} when the liquidity adapter is neither unset nor the sole supported adapter.
64
+ * @throws {VaultV2UndecodableLiquidityDataError} when the configured liquidity data cannot be decoded as market parameters.
65
+ * @throws {VaultV2ForceWithdrawZeroWithdrawalError} when the exit produces no assets after penalties.
66
+ * @throws {VaultV2ForceWithdrawCoverageError} when the adapter's markets cannot cover the required deallocation.
67
+ * @throws {VaultV2ForceWithdrawFeeSharesExceedBurnError} when projected fee mints erase the net share burn.
68
+ * @throws {VaultV2ForceWithdrawZeroSharePriceError} when the derived share-price floor rounds to zero.
69
+ * @throws {UnsupportedChainIdError} when the chain has no address registry.
70
+ * @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the chain.
71
+ * @throws {MissingContractCodeError} when the registered exit bundle has no code.
72
+ * @throws {viem.BaseError} when a chain, code, allowance or nonce read fails.
73
+ * @throws {UnexpectedRequirementSignatureError} when a permit requirement omits its nonce.
74
+ * @throws {UnsupportedRequirementSignatureError} when a requirement is neither an approval nor an ERC-2612 permit.
75
+ * @example
76
+ * ```ts
77
+ * import { prepareVaultV2ForceWithdraw, buildTransactions } from "@morpho-org/morpho-sdk";
78
+ * import { fetchAccrualVaultV2 } from "@morpho-org/morpho-sdk/fetch";
79
+ * import { createPublicClient, http, type Address } from "viem";
80
+ * import { mainnet } from "viem/chains";
81
+ * const client = createPublicClient({ chain: mainnet, transport: http() });
82
+ * export async function forceWithdraw(vault: Address, account: Address) {
83
+ * const plan = await prepareVaultV2ForceWithdraw(client, {
84
+ * account, chainId: 1, assets: 1_000_000n,
85
+ * vault: await fetchAccrualVaultV2(vault, client),
86
+ * now: (await client.getBlock()).timestamp,
87
+ * });
88
+ * return buildTransactions(plan); // Submit approvals before the exit, from account.
89
+ * }
90
+ * ```
91
+ */
92
+ export declare function prepareVaultV2ForceWithdraw(client: Client, params: VaultV2ForceWithdrawPlanParams): Promise<TransactionPlan>;
93
+ /** @internal Encodes the forced exit from fixed inputs and its referenced vault-share permit. */
94
+ export declare function buildVaultV2ForceWithdraw(action: Extract<Action, {
95
+ type: "vaultV2ForceWithdraw";
96
+ }>, requests: readonly SignatureRequest[]): Readonly<Transaction<VaultV2ForceWithdrawAction>>;
97
+ /** @internal Validates the stored forced withdrawal inputs. */
98
+ export declare function validateForceWithdrawPlanAction(action: Record<string, unknown>, path: string): void;