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

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
@@ -0,0 +1,186 @@
1
+ import { DEFAULT_SLIPPAGE_TOLERANCE, MathLib, } from "@morpho-org/blue-sdk";
2
+ import { _try, Time } from "@morpho-org/morpho-ts";
3
+ import { maxUint256 } from "viem";
4
+ import { computeMinForceWithdrawSharePrice, computeVaultV2ForceWithdrawFeeSharesMinted, computeVaultV2ForceWithdrawMinSharesBurnt, computeVaultV2ForceWithdrawPlan, computeVaultV2ForceWithdrawSharesBurnt, MAX_SLIPPAGE_TOLERANCE, resolveVaultV2ForceWithdrawEligibility, validateSlippageTolerance, } from "../../helpers/index.js";
5
+ import { validateDeadline, validateReferralFee, validateUint256Field, } from "../../helpers/validate.js";
6
+ import { AdapterNotPartOfVaultError, ExpiredDeadlineError, InputExceedsMaxError, NonPositiveInputError, VaultV2ForceWithdrawCoverageError, VaultV2ForceWithdrawFeeSharesExceedBurnError, VaultV2ForceWithdrawSharePriceBelowFloorError, VaultV2ForceWithdrawZeroSharePriceError, VaultV2ForceWithdrawZeroWithdrawalError, VaultV2SingleAdapterRequiredError, VaultV2UndecodableLiquidityDataError, VaultV2UnsupportedExitAdapterError, VaultV2UnsupportedLiquidityAdapterError, } from "../../types/index.js";
7
+ const VAULT_V2_FEE_PROJECTION_HORIZON = Time.s.from.y(1n);
8
+ /** Resolves the supported adapter or reports the existing eligibility error. @internal */
9
+ function resolveForceWithdrawAdapter({ vaultData, adapterOverride, vault, }) {
10
+ const eligibility = resolveVaultV2ForceWithdrawEligibility(vaultData, adapterOverride);
11
+ switch (eligibility.type) {
12
+ case "eligible":
13
+ return eligibility;
14
+ case "adapterCount":
15
+ throw new VaultV2SingleAdapterRequiredError(vault, eligibility.adapters);
16
+ case "adapterMismatch":
17
+ throw new AdapterNotPartOfVaultError(vault, eligibility.adapter);
18
+ case "unsupportedAdapter":
19
+ throw new VaultV2UnsupportedExitAdapterError(eligibility.adapter);
20
+ case "unsupportedLiquidityAdapter":
21
+ throw new VaultV2UnsupportedLiquidityAdapterError({
22
+ vault: vault,
23
+ liquidityAdapter: eligibility.liquidityAdapter,
24
+ adapter: eligibility.adapter,
25
+ });
26
+ case "undecodableLiquidityData":
27
+ throw new VaultV2UndecodableLiquidityDataError({
28
+ vault: vault,
29
+ liquidityAdapter: eligibility.liquidityAdapter,
30
+ liquidityData: eligibility.liquidityData,
31
+ cause: eligibility.cause,
32
+ });
33
+ }
34
+ }
35
+ /** Validates and resolves the quote's execution and fee-projection deadline. @internal */
36
+ function resolveForceWithdrawDeadline({ deadlineOverride, now, }) {
37
+ const deadline = deadlineOverride ?? now + Time.s.from.h(2n);
38
+ // Reject the same bounds the action enforces, before `getRequirements()` can walk the caller
39
+ // through a vault-share approval or an EIP-712 permit for a deadline `buildTx()` cannot encode.
40
+ validateDeadline(deadline);
41
+ if (deadline <= now) {
42
+ throw new ExpiredDeadlineError(deadline, now);
43
+ }
44
+ const maxDeadline = now + VAULT_V2_FEE_PROJECTION_HORIZON;
45
+ if (deadline > maxDeadline) {
46
+ throw new InputExceedsMaxError({
47
+ field: "deadline",
48
+ value: deadline,
49
+ max: maxDeadline,
50
+ });
51
+ }
52
+ return deadline;
53
+ }
54
+ /**
55
+ * @internal Computes the fixed exit quote from a snapshot without reads or signing.
56
+ * @param params - Snapshot, caller intent and explicit quote timestamp.
57
+ * @returns Fixed action fields and the minimum share allowance.
58
+ */
59
+ export function computeVaultV2ForceWithdrawQuote({ exitAssets, vaultData, userAddress, adapter: adapterOverride, deadline: deadlineOverride, slippageTolerance = DEFAULT_SLIPPAGE_TOLERANCE, minSharePriceE27: minSharePriceE27Override, referralFeePct = 0n, referralFeeRecipient, now, vault, }) {
60
+ if (exitAssets <= 0n) {
61
+ throw new NonPositiveInputError("exitAssets", exitAssets);
62
+ }
63
+ validateUint256Field("exitAssets", exitAssets);
64
+ validateSlippageTolerance(slippageTolerance);
65
+ // Called for its throws only: the raw pair is forwarded to the action, which normalizes it
66
+ // again on the encode path so a direct action caller gets the same guarantees.
67
+ validateReferralFee({ referralFeePct, referralFeeRecipient });
68
+ if (minSharePriceE27Override != null) {
69
+ // An unbounded override reopens the exact hole this path closes: the contract reads
70
+ // `minSharePriceE27 == 0` as "no bound".
71
+ if (minSharePriceE27Override <= 0n) {
72
+ throw new NonPositiveInputError("minSharePriceE27", minSharePriceE27Override);
73
+ }
74
+ // And an override the uint256 slot cannot hold must fail here rather than after
75
+ // `getRequirements()` has already asked for an approval or a permit signature.
76
+ validateUint256Field("minSharePriceE27", minSharePriceE27Override);
77
+ }
78
+ const deadline = resolveForceWithdrawDeadline({ deadlineOverride, now });
79
+ const eligibility = resolveForceWithdrawAdapter({
80
+ vaultData,
81
+ adapterOverride,
82
+ vault,
83
+ });
84
+ const { adapter: accrualAdapter, liquidityMarketId } = eligibility;
85
+ const adapter = accrualAdapter.address;
86
+ const plan = computeVaultV2ForceWithdrawPlan({
87
+ vaultData,
88
+ adapter: accrualAdapter,
89
+ liquidityMarketId,
90
+ exitAssets,
91
+ timestamp: now,
92
+ });
93
+ if (plan.withdrawnAssets <= 0n) {
94
+ throw new VaultV2ForceWithdrawZeroWithdrawalError({
95
+ vault: vault,
96
+ exitAssets,
97
+ penalty: plan.penalty,
98
+ });
99
+ }
100
+ // The contract's force-deallocation loop is unbounded: under-coverage panics on-chain.
101
+ if (plan.coveredAssets < plan.assetsToDeallocate) {
102
+ throw new VaultV2ForceWithdrawCoverageError({
103
+ required: plan.assetsToDeallocate,
104
+ covered: plan.coveredAssets,
105
+ maxExitAssets: plan.maxExitAssets,
106
+ });
107
+ }
108
+ const projectionTimestamp = deadline;
109
+ // VaultExitBundlesV1 measures shares as `sharesBefore - balanceAfter`; its first withdrawal
110
+ // accrues the vault before burning. The realized price sits between the raw snapshot price
111
+ // (pending fee mints not yet diluting it) and the `now` projection (interest the chain may not
112
+ // have accrued yet, e.g. when the wall clock runs ahead of the chain). Price the floor off the
113
+ // larger *net* burn of the two endpoints — the raw snapshot mints no fee shares, the `now`
114
+ // accrual mints `feeSharesNow` — so it never exceeds either, and use the projected deadline
115
+ // accrual for the fee-mint guard.
116
+ const { vault: nowVaultData } = vaultData.accrueInterest(MathLib.max(now, vaultData.lastUpdate));
117
+ const { vault: projectedVaultData } = vaultData.accrueInterest(MathLib.max(projectionTimestamp, vaultData.lastUpdate));
118
+ const sharesBurntRaw = computeVaultV2ForceWithdrawSharesBurnt({
119
+ vaultData,
120
+ deadlineVaultData: vaultData,
121
+ plan,
122
+ });
123
+ const sharesBurntNow = computeVaultV2ForceWithdrawSharesBurnt({
124
+ vaultData: nowVaultData,
125
+ deadlineVaultData: nowVaultData,
126
+ plan,
127
+ });
128
+ const feeSharesNow = computeVaultV2ForceWithdrawFeeSharesMinted({
129
+ vaultData,
130
+ owner: userAddress,
131
+ timestamp: now,
132
+ });
133
+ const feeSharesProjected = computeVaultV2ForceWithdrawFeeSharesMinted({
134
+ vaultData,
135
+ owner: userAddress,
136
+ timestamp: projectionTimestamp,
137
+ });
138
+ const minSharesBurntProjected = computeVaultV2ForceWithdrawMinSharesBurnt({
139
+ vaultData: projectedVaultData,
140
+ plan,
141
+ });
142
+ // When fee shares are minted, the projected pair bounds every execution time in the window.
143
+ if (feeSharesProjected > 0n &&
144
+ feeSharesProjected >= minSharesBurntProjected) {
145
+ throw new VaultV2ForceWithdrawFeeSharesExceedBurnError({
146
+ vault: vault,
147
+ userAddress,
148
+ sharesBurnt: minSharesBurntProjected,
149
+ feeShares: feeSharesProjected,
150
+ });
151
+ }
152
+ // sharesBurntNow ≥ minSharesBurntNow ≥ minSharesBurntProjected > feeSharesProjected ≥ feeSharesNow
153
+ const sharesBurntForFloor = MathLib.max(sharesBurntRaw, sharesBurntNow - feeSharesNow);
154
+ if (minSharePriceE27Override != null) {
155
+ // The maximum-slippage threshold only bounds the override; unlike the transaction floor it
156
+ // may round to zero, in which case every positive override is acceptable.
157
+ const minAllowedSharePriceE27 = _try(() => computeMinForceWithdrawSharePrice({
158
+ withdrawnAssets: plan.withdrawnAssets,
159
+ sharesBurnt: sharesBurntForFloor,
160
+ slippageTolerance: MAX_SLIPPAGE_TOLERANCE,
161
+ }), VaultV2ForceWithdrawZeroSharePriceError) ?? 1n;
162
+ if (minSharePriceE27Override < minAllowedSharePriceE27) {
163
+ throw new VaultV2ForceWithdrawSharePriceBelowFloorError({
164
+ minSharePriceE27: minSharePriceE27Override,
165
+ floorE27: minAllowedSharePriceE27,
166
+ });
167
+ }
168
+ }
169
+ const minSharePriceE27 = minSharePriceE27Override ??
170
+ computeMinForceWithdrawSharePrice({
171
+ withdrawnAssets: plan.withdrawnAssets,
172
+ sharesBurnt: sharesBurntForFloor,
173
+ slippageTolerance,
174
+ });
175
+ // The floor is deliberately *not* capped at `MAX_ABSOLUTE_SHARE_PRICE` (100 assets/share):
176
+ // lowering a lower bound weakens it, so any vault whose share price grew past that would be left
177
+ // with no real protection. Its two sibling `computeMin*SharePrice` helpers cap nothing either —
178
+ // only the `computeMax*` ones do, where capping relaxes an upper bound and is safe.
179
+ validateUint256Field("minSharePriceE27", minSharePriceE27);
180
+ // This is the minimum allowance needed for successful execution, not an exit cap: the bundle
181
+ // independently rejects a realized share price below `minSharePriceE27`. Include the fee
182
+ // shares minted by the first withdrawal and enough headroom for the configured tolerance.
183
+ const allowanceSharePriceE27 = MathLib.max(MathLib.min(MathLib.mulDivDown(minSharePriceE27, MathLib.WAD - slippageTolerance, MathLib.WAD), minSharePriceE27 - 1n), 1n);
184
+ const requiredShareAllowance = MathLib.min(MathLib.max(MathLib.mulDivUp(exitAssets, MathLib.RAY, allowanceSharePriceE27), MathLib.mulDivUp(exitAssets, MathLib.RAY, minSharePriceE27) + 1n) + feeSharesProjected, maxUint256);
185
+ return { deadline, adapter, minSharePriceE27, requiredShareAllowance };
186
+ }
@@ -0,0 +1,28 @@
1
+ import { type AccrualVaultV2, type MarketParams } from "@morpho-org/blue-sdk";
2
+ import { type Address } from "viem";
3
+ /**
4
+ * @internal Computes the fixed exit quote from a snapshot without reads or signing.
5
+ * @param params - Snapshot, caller intent and explicit quote timestamp.
6
+ * @returns Fixed action fields and the minimum share allowance.
7
+ */
8
+ export declare function computeVaultV2InKindRedeemQuote({ amount, marketParamsList, vaultData, adapter: adapterOverride, deadline: deadlineOverride, now, vault, }: {
9
+ readonly amount: bigint;
10
+ readonly marketParamsList: readonly MarketParams[];
11
+ readonly vaultData: AccrualVaultV2;
12
+ readonly adapter?: Address;
13
+ readonly deadline?: bigint;
14
+ readonly now: bigint;
15
+ readonly vault: Address;
16
+ }): {
17
+ deadline: bigint;
18
+ adapter: `0x${string}`;
19
+ marketParamsListSnapshot: {
20
+ loanToken: `0x${string}`;
21
+ collateralToken: `0x${string}`;
22
+ oracle: `0x${string}`;
23
+ irm: `0x${string}`;
24
+ lltv: bigint;
25
+ }[];
26
+ requiredShareAllowance: bigint;
27
+ peak: bigint;
28
+ };
@@ -0,0 +1,107 @@
1
+ import { AccrualVaultV2MorphoMarketV1AdapterV2, MarketUtils, MathLib, } from "@morpho-org/blue-sdk";
2
+ import { Time } from "@morpho-org/morpho-ts";
3
+ import { isAddressEqual } from "viem";
4
+ import { validateDeadline } from "../../helpers/validate.js";
5
+ import { AdapterNotPartOfVaultError, EmptyMarketParamsListError, ExpiredDeadlineError, InKindRedeemCoverageError, InKindRedeemZeroDeallocationError, NonPositiveInputError, VaultV2SingleAdapterRequiredError, VaultV2UnsupportedExitAdapterError, } from "../../types/index.js";
6
+ /**
7
+ * @internal Computes the fixed exit quote from a snapshot without reads or signing.
8
+ * @param params - Snapshot, caller intent and explicit quote timestamp.
9
+ * @returns Fixed action fields and the minimum share allowance.
10
+ */
11
+ export function computeVaultV2InKindRedeemQuote({ amount, marketParamsList, vaultData, adapter: adapterOverride, deadline: deadlineOverride, now, vault, }) {
12
+ if (amount <= 0n) {
13
+ throw new NonPositiveInputError("amount", amount);
14
+ }
15
+ const marketParamsListSnapshot = marketParamsList.map(({ loanToken, collateralToken, oracle, irm, lltv }) => ({
16
+ loanToken,
17
+ collateralToken,
18
+ oracle,
19
+ irm,
20
+ lltv,
21
+ }));
22
+ const marketIdListSnapshot = marketParamsListSnapshot.map((marketParams) => MarketUtils.getMarketId(marketParams));
23
+ const deadline = deadlineOverride ?? now + Time.s.from.h(2n);
24
+ // Reject the same bounds the action enforces, before `getRequirements()` can walk the caller
25
+ // through a vault-share approval or an EIP-712 permit for a deadline `buildTx()` cannot encode.
26
+ validateDeadline(deadline);
27
+ if (deadline <= now) {
28
+ throw new ExpiredDeadlineError(deadline, now);
29
+ }
30
+ if (vaultData.accrualAdapters.length !== 1) {
31
+ throw new VaultV2SingleAdapterRequiredError(vault, vaultData.accrualAdapters.length);
32
+ }
33
+ const soleAdapter = vaultData.accrualAdapters[0];
34
+ if (soleAdapter == null) {
35
+ throw new VaultV2SingleAdapterRequiredError(vault, 0);
36
+ }
37
+ const adapter = adapterOverride ?? soleAdapter.address;
38
+ if (!isAddressEqual(adapter, soleAdapter.address)) {
39
+ throw new AdapterNotPartOfVaultError(vault, adapter);
40
+ }
41
+ if (!(soleAdapter instanceof AccrualVaultV2MorphoMarketV1AdapterV2)) {
42
+ throw new VaultV2UnsupportedExitAdapterError(adapter);
43
+ }
44
+ const penalty = vaultData.forceDeallocatePenalties[soleAdapter.address] ?? 0n;
45
+ const idleAssets = MathLib.min(vaultData.assetBalance, amount);
46
+ const assetsToDeallocate = MathLib.wDivDown(amount - idleAssets, MathLib.WAD + penalty);
47
+ if (idleAssets === 0n && assetsToDeallocate === 0n) {
48
+ throw new InKindRedeemZeroDeallocationError({
49
+ vault: vault,
50
+ amount,
51
+ penalty,
52
+ });
53
+ }
54
+ if (assetsToDeallocate > 0n && marketParamsListSnapshot.length === 0) {
55
+ throw new EmptyMarketParamsListError();
56
+ }
57
+ const assetsByMarket = new Map(soleAdapter.markets
58
+ .filter((market) => (soleAdapter.supplyShares[market.id] ?? 0n) !== 0n)
59
+ .map((market) => [
60
+ market.id,
61
+ market
62
+ .accrueInterest(now)
63
+ .toSupplyAssets(soleAdapter.supplyShares[market.id] ?? 0n),
64
+ ]));
65
+ const uniqueMarketIds = new Set(marketIdListSnapshot);
66
+ let covered = 0n;
67
+ for (const id of uniqueMarketIds) {
68
+ covered += assetsByMarket.get(id) ?? 0n;
69
+ }
70
+ if (covered < assetsToDeallocate) {
71
+ const maxExitAssets = covered === 0n
72
+ ? idleAssets
73
+ : idleAssets + MathLib.wMulUp(covered + 1n, MathLib.WAD + penalty) - 1n;
74
+ throw new InKindRedeemCoverageError({
75
+ required: assetsToDeallocate,
76
+ covered,
77
+ maxExitAssets,
78
+ });
79
+ }
80
+ let remaining = assetsToDeallocate;
81
+ let peak = 0n;
82
+ const consumedMarketIds = new Set();
83
+ const { vault: allowanceVault } = vaultData.accrueInterest(deadline);
84
+ // Interest can lower the burn, while management fees can raise it; bound both endpoints.
85
+ const previewAllowance = (assets) => MathLib.max(vaultData.toShares(assets, "Up"), allowanceVault.toShares(assets, "Up"));
86
+ let requiredShareAllowance = previewAllowance(BigInt(marketParamsListSnapshot.length));
87
+ // Pre-burn previews upper-bound each separately rounded idle, penalty, and main burn.
88
+ requiredShareAllowance += previewAllowance(idleAssets);
89
+ for (const id of marketIdListSnapshot) {
90
+ const available = consumedMarketIds.has(id)
91
+ ? 0n
92
+ : (assetsByMarket.get(id) ?? 0n);
93
+ consumedMarketIds.add(id);
94
+ const chunk = MathLib.min(available, remaining);
95
+ peak = MathLib.max(peak, chunk);
96
+ requiredShareAllowance += previewAllowance(MathLib.wMulUp(chunk, penalty));
97
+ requiredShareAllowance += previewAllowance(chunk);
98
+ remaining -= chunk;
99
+ }
100
+ return {
101
+ deadline,
102
+ adapter,
103
+ marketParamsListSnapshot,
104
+ requiredShareAllowance,
105
+ peak,
106
+ };
107
+ }
@@ -65,9 +65,7 @@ export interface VaultV2Actions {
65
65
  * @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient.
66
66
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
67
67
  * @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a non-wNative vault.
68
- * @throws {InputExceedsMaxError} when funding or the deadline exceeds uint256, or when the vault's
69
- * liquidity adapter is a Midnight adapter (it cannot receive vault allocations, so no deposit
70
- * fits and `max` is `0n`).
68
+ * @throws {InputExceedsMaxError} when funding or the deadline exceeds uint256.
71
69
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
72
70
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
73
71
  * @throws {BundlesPermitMismatchError} from `buildTx()` when the signature's spender, amount or
@@ -149,9 +147,7 @@ export interface VaultV2Actions {
149
147
  * @throws {NonPositiveInputError} when `amount` or the computed required share amount is not positive.
150
148
  * @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
151
149
  * at any `getRequirements()` call.
152
- * @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256 at handle creation,
153
- * or when the vault's liquidity adapter is a Midnight adapter and `amount` exceeds the vault's
154
- * idle assets plus what the adapter can withdraw from the liquidity market.
150
+ * @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256 at handle creation.
155
151
  * @throws {NegativeInputError} when `referralFeePct` or `slippageTolerance` is negative.
156
152
  * @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
157
153
  * @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no nonzero recipient.
@@ -217,25 +213,7 @@ export interface VaultV2Actions {
217
213
  * @throws {NonPositiveInputError} when `shares` is not positive.
218
214
  * @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
219
215
  * requirement resolution.
220
- * @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256, or from
221
- * `getRequirements()` when the vault's liquidity adapter is a Midnight adapter and `shares`
222
- * are worth more than the vault's idle assets plus what the adapter can withdraw from the
223
- * liquidity market.
224
- * @throws {UnknownBlueFactory} from `getRequirements()` when the configured chain has no VaultV2 factory.
225
- * @throws {UnknownBlueOfFactory} from `getRequirements()` when the vault is not a VaultV2 from the
226
- * configured factory.
227
- * @throws {UnsupportedBlueVaultV2AdapterError} from `getRequirements()` when the vault or one of its
228
- * adapters uses an unsupported adapter class.
229
- * @throws {UnsupportedBlueMarketIrmError} from `getRequirements()` when the vault's liquidity adapter
230
- * is a Midnight adapter and accrual projects an underlying market with positive debt that uses an
231
- * unsupported IRM.
232
- * @throws {UnknownBlueMarketAllocationError} from `getRequirements()` when the vault's liquidity
233
- * adapter is a Midnight adapter and accrual meets a nested Vault V1 withdraw queue market without
234
- * allocation data.
235
- * @throws {InvalidMidnightPositionLossFactorError} from `getRequirements()` when the vault's liquidity
236
- * adapter is a Midnight adapter and accrual meets a market loss factor below a position's.
237
- * @throws {InvalidMidnightPositionAccrualStateError} from `getRequirements()` when the vault's
238
- * liquidity adapter is a Midnight adapter and accrual meets invalid Midnight position inputs.
216
+ * @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256.
239
217
  * @throws {NegativeInputError} when `referralFeePct` is negative.
240
218
  * @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD.
241
219
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no non-zero recipient.
@@ -243,7 +221,7 @@ export interface VaultV2Actions {
243
221
  * @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
244
222
  * @throws {MissingContractCodeError} from `getRequirements()` when a fixed bundles or protocol
245
223
  * contract has no code at its registered address.
246
- * @throws {viem.BaseError} from `getRequirements()` when a vault-state, allowance, nonce, `eth_chainId`, or
224
+ * @throws {viem.BaseError} from `getRequirements()` when an allowance, nonce, `eth_chainId`, or
247
225
  * `eth_getCode` read fails.
248
226
  * @throws {UnknownTokenError} from `getRequirements()` when the share token fetched by
249
227
  * `getData()` has unusable decimals.
@@ -321,11 +299,9 @@ export interface VaultV2Actions {
321
299
  * @throws {InputExceedsMaxError} when `deadline` exceeds `uint256`.
322
300
  * @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
323
301
  * requirement resolution.
324
- * @throws {VaultV2SingleAdapterRequiredError} when the vault does not have one adapter, including
325
- * a vault that mixes Blue and Midnight adapters.
302
+ * @throws {VaultV2SingleAdapterRequiredError} when the vault does not have one adapter.
326
303
  * @throws {AdapterNotPartOfVaultError} when `adapter` is not the vault's adapter.
327
- * @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2,
328
- * including a Midnight adapter.
304
+ * @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2.
329
305
  * @throws {InKindRedeemCoverageError} when the deduplicated list cannot cover the exit.
330
306
  * @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
331
307
  * @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
@@ -450,11 +426,9 @@ export interface VaultV2Actions {
450
426
  * @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
451
427
  * requirement resolution.
452
428
  * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds the SDK maximum.
453
- * @throws {VaultV2SingleAdapterRequiredError} when the vault does not have exactly one adapter,
454
- * including a vault that mixes Blue and Midnight adapters.
429
+ * @throws {VaultV2SingleAdapterRequiredError} when the vault does not have exactly one adapter.
455
430
  * @throws {AdapterNotPartOfVaultError} when `adapter` is not the vault's adapter.
456
- * @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2,
457
- * including a Midnight adapter.
431
+ * @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2.
458
432
  * @throws {VaultV2UnsupportedLiquidityAdapterError} when the vault routes liquidity through
459
433
  * another adapter.
460
434
  * @throws {VaultV2UndecodableLiquidityDataError} when the vault's `liquidityData` does not decode