@morpho-org/morpho-sdk 6.0.0-next.1 → 6.0.0-next.2

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 (174) hide show
  1. package/MIGRATION-v5-to-v6.md +127 -16
  2. package/README.md +17 -11
  3. package/lib/cjs/abis.d.ts +17 -2
  4. package/lib/cjs/abis.js +14 -1
  5. package/lib/cjs/actions/blue/common.js +5 -26
  6. package/lib/cjs/actions/blue/supply.js +2 -7
  7. package/lib/cjs/actions/bundles/common.d.ts +32 -2
  8. package/lib/cjs/actions/bundles/common.js +68 -30
  9. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -0
  10. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +6 -10
  11. package/lib/cjs/actions/requirements/blue/index.d.ts +0 -1
  12. package/lib/cjs/actions/requirements/blue/index.js +0 -1
  13. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
  14. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +20 -20
  15. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
  16. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +33 -27
  17. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
  18. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
  19. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +4 -2
  20. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +14 -9
  21. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +9 -6
  22. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +22 -17
  23. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +1 -0
  24. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
  25. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
  26. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +6 -0
  27. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +2 -0
  28. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +1 -0
  29. package/lib/cjs/actions/vaultV1/inKindRedeem.js +3 -2
  30. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +58 -39
  31. package/lib/cjs/actions/vaultV2/forceWithdraw.js +87 -60
  32. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +1 -0
  33. package/lib/cjs/actions/vaultV2/inKindRedeem.js +3 -2
  34. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
  35. package/lib/cjs/blue/abis.d.ts +5 -1
  36. package/lib/cjs/blue/abis.js +2 -0
  37. package/lib/cjs/blue/entities.d.ts +8 -2
  38. package/lib/cjs/blue/entities.js +1 -0
  39. package/lib/cjs/blue/errors.d.ts +1 -1
  40. package/lib/cjs/blue/errors.js +2 -1
  41. package/lib/cjs/blue/fetch.d.ts +3 -1
  42. package/lib/cjs/blue/fetch.js +1 -0
  43. package/lib/cjs/entities/blue/blue.d.ts +15 -6
  44. package/lib/cjs/entities/blue/blue.js +3 -0
  45. package/lib/cjs/entities/index.d.ts +8 -2
  46. package/lib/cjs/entities/index.js +1 -0
  47. package/lib/cjs/entities/midnight/midnight.js +20 -24
  48. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +7 -6
  49. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +19 -14
  50. package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +3 -3
  51. package/lib/cjs/entities/requirements/index.d.ts +1 -0
  52. package/lib/cjs/entities/requirements/index.js +1 -0
  53. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +10 -5
  54. package/lib/cjs/entities/vaultV1/vaultV1.js +13 -1
  55. package/lib/cjs/entities/vaultV1ReallocationData.d.ts +6 -0
  56. package/lib/cjs/entities/vaultV1ReallocationData.js +20 -5
  57. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +140 -34
  58. package/lib/cjs/entities/vaultV2/vaultV2.js +229 -16
  59. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +8 -1
  60. package/lib/cjs/entities/vaultV2BlueReallocationData.js +46 -13
  61. package/lib/cjs/errors.d.ts +1 -1
  62. package/lib/cjs/errors.js +3 -2
  63. package/lib/cjs/fetch.d.ts +3 -1
  64. package/lib/cjs/fetch.js +1 -0
  65. package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +2 -0
  66. package/lib/cjs/helpers/computeVaultV1Reallocations.js +2 -0
  67. package/lib/cjs/helpers/index.d.ts +3 -1
  68. package/lib/cjs/helpers/index.js +10 -1
  69. package/lib/cjs/helpers/metadata.d.ts +3 -5
  70. package/lib/cjs/helpers/metadata.js +4 -6
  71. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
  72. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +164 -0
  73. package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
  74. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +2 -0
  75. package/lib/cjs/helpers/slippage.d.ts +46 -0
  76. package/lib/cjs/helpers/slippage.js +65 -0
  77. package/lib/cjs/helpers/validate.d.ts +65 -8
  78. package/lib/cjs/helpers/validate.js +83 -9
  79. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
  80. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +369 -0
  81. package/lib/cjs/types/action.d.ts +95 -13
  82. package/lib/cjs/types/error.d.ts +290 -12
  83. package/lib/cjs/types/error.js +312 -24
  84. package/lib/cjs/types/sharedLiquidity.d.ts +2 -2
  85. package/lib/cjs/utils.d.ts +3 -1
  86. package/lib/cjs/utils.js +10 -1
  87. package/lib/esm/abis.d.ts +17 -2
  88. package/lib/esm/abis.js +17 -2
  89. package/lib/esm/actions/blue/common.js +7 -28
  90. package/lib/esm/actions/blue/supply.js +4 -9
  91. package/lib/esm/actions/bundles/common.d.ts +32 -2
  92. package/lib/esm/actions/bundles/common.js +68 -31
  93. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -0
  94. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +8 -12
  95. package/lib/esm/actions/requirements/blue/index.d.ts +0 -1
  96. package/lib/esm/actions/requirements/blue/index.js +0 -1
  97. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
  98. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +21 -21
  99. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
  100. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +34 -28
  101. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
  102. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
  103. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +4 -2
  104. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +14 -9
  105. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +9 -6
  106. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +22 -17
  107. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +1 -0
  108. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
  109. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
  110. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +6 -0
  111. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +2 -0
  112. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +1 -0
  113. package/lib/esm/actions/vaultV1/inKindRedeem.js +3 -2
  114. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +58 -39
  115. package/lib/esm/actions/vaultV2/forceWithdraw.js +89 -62
  116. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +1 -0
  117. package/lib/esm/actions/vaultV2/inKindRedeem.js +3 -2
  118. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
  119. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +3 -1
  120. package/lib/esm/blue/abis.d.ts +5 -1
  121. package/lib/esm/blue/abis.js +5 -1
  122. package/lib/esm/blue/entities.d.ts +8 -2
  123. package/lib/esm/blue/entities.js +3 -1
  124. package/lib/esm/blue/errors.d.ts +1 -1
  125. package/lib/esm/blue/errors.js +1 -1
  126. package/lib/esm/blue/fetch.d.ts +3 -1
  127. package/lib/esm/blue/fetch.js +3 -1
  128. package/lib/esm/entities/blue/blue.d.ts +15 -6
  129. package/lib/esm/entities/blue/blue.js +3 -0
  130. package/lib/esm/entities/index.d.ts +8 -2
  131. package/lib/esm/entities/index.js +3 -1
  132. package/lib/esm/entities/midnight/midnight.js +20 -24
  133. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +7 -6
  134. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +20 -15
  135. package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +3 -3
  136. package/lib/esm/entities/requirements/index.d.ts +1 -0
  137. package/lib/esm/entities/requirements/index.js +1 -0
  138. package/lib/esm/entities/vaultV1/vaultV1.d.ts +10 -5
  139. package/lib/esm/entities/vaultV1/vaultV1.js +14 -2
  140. package/lib/esm/entities/vaultV1ReallocationData.d.ts +6 -0
  141. package/lib/esm/entities/vaultV1ReallocationData.js +20 -5
  142. package/lib/esm/entities/vaultV2/vaultV2.d.ts +140 -34
  143. package/lib/esm/entities/vaultV2/vaultV2.js +234 -21
  144. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +8 -1
  145. package/lib/esm/entities/vaultV2BlueReallocationData.js +46 -13
  146. package/lib/esm/errors.d.ts +1 -1
  147. package/lib/esm/errors.js +1 -1
  148. package/lib/esm/fetch.d.ts +3 -1
  149. package/lib/esm/fetch.js +3 -1
  150. package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +2 -0
  151. package/lib/esm/helpers/computeVaultV1Reallocations.js +2 -0
  152. package/lib/esm/helpers/index.d.ts +3 -1
  153. package/lib/esm/helpers/index.js +3 -1
  154. package/lib/esm/helpers/metadata.d.ts +3 -5
  155. package/lib/esm/helpers/metadata.js +4 -6
  156. package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
  157. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +161 -0
  158. package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
  159. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +2 -0
  160. package/lib/esm/helpers/slippage.d.ts +46 -0
  161. package/lib/esm/helpers/slippage.js +65 -1
  162. package/lib/esm/helpers/validate.d.ts +65 -8
  163. package/lib/esm/helpers/validate.js +82 -10
  164. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
  165. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +362 -0
  166. package/lib/esm/types/action.d.ts +95 -13
  167. package/lib/esm/types/error.d.ts +290 -12
  168. package/lib/esm/types/error.js +301 -19
  169. package/lib/esm/types/sharedLiquidity.d.ts +2 -2
  170. package/lib/esm/utils.d.ts +3 -1
  171. package/lib/esm/utils.js +3 -1
  172. package/package.json +7 -7
  173. /package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.d.ts +0 -0
  174. /package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.d.ts +0 -0
@@ -67,6 +67,52 @@ export declare function computeMaxSupplySharePrice(params: {
67
67
  market: Market;
68
68
  slippageTolerance: bigint;
69
69
  }): bigint;
70
+ /**
71
+ * Computes the minimum Vault V2 force-withdraw share price (in RAY, 1e27) for slippage protection.
72
+ *
73
+ * Mirrors the on-chain check in `VaultExitBundlesV1.vaultExitBundlesV1ForceWithdrawVaultV2`:
74
+ * ```solidity
75
+ * require(totalSharesBurnt == 0 || withdrawn.mulDivDown(1e27, totalSharesBurnt) >= minSharePriceE27)
76
+ * ```
77
+ *
78
+ * The realized price sits structurally *below* the vault's share price because the
79
+ * force-deallocation penalty is debited from the position but never withdrawn, so a bound derived
80
+ * from the raw share price would reject every penalised exit. Both inputs are therefore taken from
81
+ * the same plan: `withdrawnAssets` (a lower bound of what the contract pays out) over
82
+ * `sharesBurnt` (an upper bound of what it burns). The result is conservative on both sides, so a
83
+ * faithful snapshot never trips the check while a real price drop, a penalty increase, or liquidity
84
+ * shifting from the penalty-free leg to the penalised leg all do.
85
+ *
86
+ * The referral fee is deducted *after* this check, so it is outside the bound's protection.
87
+ *
88
+ * @param params - Computation parameters.
89
+ * @param params.withdrawnAssets - Assets the contract withdraws in total, before the referral fee.
90
+ * @param params.sharesBurnt - Upper bound of the vault shares the exit burns.
91
+ * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. `0.003e18` = 0.3%).
92
+ * @returns `minSharePriceE27` in RAY scale (1e27).
93
+ * @throws {NegativeInputError} when `slippageTolerance` is negative.
94
+ * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` is above
95
+ * `MAX_SLIPPAGE_TOLERANCE`.
96
+ * @throws {NonPositiveInputError} when `sharesBurnt` or `withdrawnAssets` is not positive, which
97
+ * would silently nullify the on-chain bound.
98
+ * @throws {VaultV2ForceWithdrawZeroSharePriceError} when the ratio itself rounds down to zero, which
99
+ * would nullify the bound just as a non-positive input would.
100
+ * @example
101
+ * ```ts
102
+ * import { computeMinForceWithdrawSharePrice } from "@morpho-org/morpho-sdk";
103
+ *
104
+ * const minSharePriceE27 = computeMinForceWithdrawSharePrice({
105
+ * withdrawnAssets: plan.withdrawnAssets,
106
+ * sharesBurnt,
107
+ * slippageTolerance: DEFAULT_SLIPPAGE_TOLERANCE,
108
+ * });
109
+ * ```
110
+ */
111
+ export declare function computeMinForceWithdrawSharePrice(params: {
112
+ readonly withdrawnAssets: bigint;
113
+ readonly sharesBurnt: bigint;
114
+ readonly slippageTolerance: bigint;
115
+ }): bigint;
70
116
  /**
71
117
  * Computes the minimum withdraw share price (in RAY, 1e27) for slippage protection.
72
118
  *
@@ -4,6 +4,7 @@ exports.computeVaultMaxShareAllowance = exports.computeVaultMaxSharePrice = void
4
4
  exports.computeMinBorrowSharePrice = computeMinBorrowSharePrice;
5
5
  exports.computeMaxRepaySharePrice = computeMaxRepaySharePrice;
6
6
  exports.computeMaxSupplySharePrice = computeMaxSupplySharePrice;
7
+ exports.computeMinForceWithdrawSharePrice = computeMinForceWithdrawSharePrice;
7
8
  exports.computeMinWithdrawSharePrice = computeMinWithdrawSharePrice;
8
9
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
9
10
  const index_js_1 = require("../types/index.js");
@@ -105,6 +106,70 @@ function computeMaxSupplySharePrice(params) {
105
106
  const maxSharePrice = blue_sdk_1.MathLib.mulDivUp(supplyAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippageTolerance), expectedShares);
106
107
  return blue_sdk_1.MathLib.min(maxSharePrice, constant_js_1.MAX_ABSOLUTE_SHARE_PRICE);
107
108
  }
109
+ /**
110
+ * Computes the minimum Vault V2 force-withdraw share price (in RAY, 1e27) for slippage protection.
111
+ *
112
+ * Mirrors the on-chain check in `VaultExitBundlesV1.vaultExitBundlesV1ForceWithdrawVaultV2`:
113
+ * ```solidity
114
+ * require(totalSharesBurnt == 0 || withdrawn.mulDivDown(1e27, totalSharesBurnt) >= minSharePriceE27)
115
+ * ```
116
+ *
117
+ * The realized price sits structurally *below* the vault's share price because the
118
+ * force-deallocation penalty is debited from the position but never withdrawn, so a bound derived
119
+ * from the raw share price would reject every penalised exit. Both inputs are therefore taken from
120
+ * the same plan: `withdrawnAssets` (a lower bound of what the contract pays out) over
121
+ * `sharesBurnt` (an upper bound of what it burns). The result is conservative on both sides, so a
122
+ * faithful snapshot never trips the check while a real price drop, a penalty increase, or liquidity
123
+ * shifting from the penalty-free leg to the penalised leg all do.
124
+ *
125
+ * The referral fee is deducted *after* this check, so it is outside the bound's protection.
126
+ *
127
+ * @param params - Computation parameters.
128
+ * @param params.withdrawnAssets - Assets the contract withdraws in total, before the referral fee.
129
+ * @param params.sharesBurnt - Upper bound of the vault shares the exit burns.
130
+ * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. `0.003e18` = 0.3%).
131
+ * @returns `minSharePriceE27` in RAY scale (1e27).
132
+ * @throws {NegativeInputError} when `slippageTolerance` is negative.
133
+ * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` is above
134
+ * `MAX_SLIPPAGE_TOLERANCE`.
135
+ * @throws {NonPositiveInputError} when `sharesBurnt` or `withdrawnAssets` is not positive, which
136
+ * would silently nullify the on-chain bound.
137
+ * @throws {VaultV2ForceWithdrawZeroSharePriceError} when the ratio itself rounds down to zero, which
138
+ * would nullify the bound just as a non-positive input would.
139
+ * @example
140
+ * ```ts
141
+ * import { computeMinForceWithdrawSharePrice } from "@morpho-org/morpho-sdk";
142
+ *
143
+ * const minSharePriceE27 = computeMinForceWithdrawSharePrice({
144
+ * withdrawnAssets: plan.withdrawnAssets,
145
+ * sharesBurnt,
146
+ * slippageTolerance: DEFAULT_SLIPPAGE_TOLERANCE,
147
+ * });
148
+ * ```
149
+ */
150
+ function computeMinForceWithdrawSharePrice(params) {
151
+ const { withdrawnAssets, sharesBurnt, slippageTolerance } = params;
152
+ (0, validate_js_1.validateSlippageTolerance)(slippageTolerance);
153
+ // A zero on either side would yield `minSharePriceE27 = 0`, i.e. no bound at all.
154
+ if (withdrawnAssets <= 0n) {
155
+ throw new index_js_1.NonPositiveInputError("withdrawnAssets", withdrawnAssets);
156
+ }
157
+ if (sharesBurnt <= 0n) {
158
+ throw new index_js_1.NonPositiveInputError("sharesBurnt", sharesBurnt);
159
+ }
160
+ const minSharePriceE27 = blue_sdk_1.MathLib.mulDivDown(withdrawnAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - slippageTolerance), sharesBurnt);
161
+ // Positive inputs are not enough: the ratio itself can round down to zero once the burn exceeds
162
+ // what the withdrawn assets can price at RAY scale, which would reintroduce the very opt-out the
163
+ // guards above exist to prevent.
164
+ if (minSharePriceE27 === 0n) {
165
+ throw new index_js_1.VaultV2ForceWithdrawZeroSharePriceError({
166
+ withdrawnAssets,
167
+ sharesBurnt,
168
+ slippageTolerance,
169
+ });
170
+ }
171
+ return minSharePriceE27;
172
+ }
108
173
  /**
109
174
  * Computes the minimum withdraw share price (in RAY, 1e27) for slippage protection.
110
175
  *
@@ -17,6 +17,41 @@ export declare const compareMarketIds: (idA: MarketId, idB: MarketId) => -1 | 0
17
17
  * @internal
18
18
  */
19
19
  export declare const validateUint256Field: (field: string, value: bigint) => void;
20
+ /**
21
+ * Rejects a deadline that no periphery can honour: the contracts read `0` as "unset" and the ABI
22
+ * slot is a `uint256`. Callers that also need the deadline to be in the future layer their own
23
+ * `ExpiredDeadlineError` on top — this check stays clock-free so transaction builders can use it.
24
+ *
25
+ * @param deadline - Candidate deadline, in seconds.
26
+ * @returns Nothing when `deadline` is a positive `uint256`.
27
+ * @throws {NonPositiveInputError} when `deadline` is not positive.
28
+ * @throws {InputExceedsMaxError} when `deadline` exceeds `maxUint256`.
29
+ * @internal
30
+ */
31
+ export declare const validateDeadline: (deadline: bigint) => void;
32
+ /**
33
+ * Validates an optional referral fee and returns the pair every referral-fee-bearing periphery
34
+ * encodes. Shared by the direct BlueBundlesV1 writes and the VaultExitBundlesV1 force withdrawal,
35
+ * whose contracts apply the same `[0, WAD)` bound and both transfer the fee unconditionally.
36
+ *
37
+ * @param params - Referral fee inputs.
38
+ * @param params.referralFeePct - Optional WAD-scaled fee share. Defaults to `0n`.
39
+ * @param params.referralFeeRecipient - Optional fee recipient. Defaults to the zero address, which
40
+ * is only valid alongside a zero `referralFeePct`.
41
+ * @returns The normalized `{ referralFeePct, referralFeeRecipient }` pair.
42
+ * @throws {NegativeInputError} when `referralFeePct` is negative.
43
+ * @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD (the contracts reject
44
+ * it with `PctExceeded`); it extends `InputExceedsMaxError`, preserving that pattern-match.
45
+ * @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
46
+ * @internal
47
+ */
48
+ export declare const validateReferralFee: (params: {
49
+ readonly referralFeePct?: bigint;
50
+ readonly referralFeeRecipient?: Address;
51
+ }) => {
52
+ readonly referralFeePct: bigint;
53
+ readonly referralFeeRecipient: Address;
54
+ };
20
55
  /**
21
56
  * Validates that a raw or hydrated Midnight market belongs to the expected chain.
22
57
  *
@@ -36,22 +71,44 @@ export declare const validateMidnightMarketChainId: (market: MidnightMarketInput
36
71
  * Asserts that the client has a connected account AND that it matches
37
72
  * the provided user address.
38
73
  *
39
- * Used internally by the signature requirements (`encodeErc20Permit`,
40
- * `encodeErc20Permit2Approve`) to enforce builder = signer at `sign()` time:
41
- * the signing flow is the only path where an account/address mismatch
42
- * is a real security concern (rather than just an integrator footgun).
74
+ * Used at `sign()` time by the shared `signAndVerifyTypedData` helper (which
75
+ * backs the permit, Permit2, Blue authorization, and Midnight offer-root
76
+ * signature flows) and by `encodeVaultSharesPermit`, to enforce builder =
77
+ * signer: the signing flow is
78
+ * the only path where an account/address mismatch is a real security concern
79
+ * (rather than just an integrator footgun).
43
80
  *
44
81
  * Transaction builders no longer call this helper — callers are
45
82
  * responsible for keeping `userAddress` aligned with the signing account
46
83
  * at the builder layer.
47
84
  *
48
- * Throws {@link MissingClientPropertyError} if the client has no account.
49
- * Throws {@link AddressMismatchError} if the client account differs from
50
- * `userAddress`.
51
- *
52
85
  * @param clientAccountAddress - The client's account address; if undefined,
53
86
  * `MissingClientPropertyError` is thrown.
54
87
  * @param userAddress - The user address provided by the caller.
88
+ * @returns Nothing; narrows `clientAccountAddress` to a defined `Address` when
89
+ * it is present and equal to `userAddress`.
90
+ * @throws {MissingClientPropertyError} when the client has no connected account.
91
+ * @throws {AddressMismatchError} when the client account differs from
92
+ * `userAddress`.
93
+ * @example
94
+ * ```ts
95
+ * import { createWalletClient, http } from "viem";
96
+ * import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
97
+ * import { mainnet } from "viem/chains";
98
+ * import { validateUserAddress } from "@morpho-org/morpho-sdk";
99
+ *
100
+ * const account = privateKeyToAccount(generatePrivateKey());
101
+ * const walletClient = createWalletClient({
102
+ * account,
103
+ * chain: mainnet,
104
+ * transport: http(),
105
+ * });
106
+ *
107
+ * // Inside a `sign()` flow, before producing a typed-data signature:
108
+ * validateUserAddress(walletClient.account?.address, account.address);
109
+ * // Passes when the connected account equals the expected signer;
110
+ * // throws if the wallet has no account or signs for a different address.
111
+ * ```
55
112
  */
56
113
  export declare function validateUserAddress(clientAccountAddress: Address | undefined, userAddress: Address): asserts clientAccountAddress is Address;
57
114
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateSlippageTolerance = exports.validateVaultV2BlueReallocations = exports.validateReallocations = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validateNativeVaultAsset = exports.validateNativeAsset = exports.validateChainId = exports.validatePositionHealth = exports.validateAccrualPosition = exports.validateMidnightMarketChainId = exports.validateUint256Field = exports.compareMarketIds = void 0;
3
+ exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateSlippageTolerance = exports.validateVaultV2BlueReallocations = exports.validateReallocations = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validateNativeVaultAsset = exports.validateNativeAsset = exports.validateChainId = exports.validatePositionHealth = exports.validateAccrualPosition = exports.validateMidnightMarketChainId = exports.validateReferralFee = exports.validateDeadline = exports.validateUint256Field = exports.compareMarketIds = void 0;
4
4
  exports.validateUserAddress = validateUserAddress;
5
5
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
6
6
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
@@ -38,6 +38,58 @@ const validateUint256Field = (field, value) => {
38
38
  }
39
39
  };
40
40
  exports.validateUint256Field = validateUint256Field;
41
+ /**
42
+ * Rejects a deadline that no periphery can honour: the contracts read `0` as "unset" and the ABI
43
+ * slot is a `uint256`. Callers that also need the deadline to be in the future layer their own
44
+ * `ExpiredDeadlineError` on top — this check stays clock-free so transaction builders can use it.
45
+ *
46
+ * @param deadline - Candidate deadline, in seconds.
47
+ * @returns Nothing when `deadline` is a positive `uint256`.
48
+ * @throws {NonPositiveInputError} when `deadline` is not positive.
49
+ * @throws {InputExceedsMaxError} when `deadline` exceeds `maxUint256`.
50
+ * @internal
51
+ */
52
+ const validateDeadline = (deadline) => {
53
+ if (deadline <= 0n)
54
+ throw new index_js_1.NonPositiveInputError("deadline", deadline);
55
+ (0, exports.validateUint256Field)("deadline", deadline);
56
+ };
57
+ exports.validateDeadline = validateDeadline;
58
+ /**
59
+ * Validates an optional referral fee and returns the pair every referral-fee-bearing periphery
60
+ * encodes. Shared by the direct BlueBundlesV1 writes and the VaultExitBundlesV1 force withdrawal,
61
+ * whose contracts apply the same `[0, WAD)` bound and both transfer the fee unconditionally.
62
+ *
63
+ * @param params - Referral fee inputs.
64
+ * @param params.referralFeePct - Optional WAD-scaled fee share. Defaults to `0n`.
65
+ * @param params.referralFeeRecipient - Optional fee recipient. Defaults to the zero address, which
66
+ * is only valid alongside a zero `referralFeePct`.
67
+ * @returns The normalized `{ referralFeePct, referralFeeRecipient }` pair.
68
+ * @throws {NegativeInputError} when `referralFeePct` is negative.
69
+ * @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD (the contracts reject
70
+ * it with `PctExceeded`); it extends `InputExceedsMaxError`, preserving that pattern-match.
71
+ * @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
72
+ * @internal
73
+ */
74
+ const validateReferralFee = (params) => {
75
+ const referralFeePct = params.referralFeePct ?? 0n;
76
+ if (referralFeePct < 0n) {
77
+ throw new index_js_1.NegativeInputError("referralFeePct", referralFeePct);
78
+ }
79
+ if (referralFeePct >= blue_sdk_1.MathLib.WAD) {
80
+ throw new index_js_1.ReferralFeePctExceededError(referralFeePct);
81
+ }
82
+ if (referralFeePct > 0n &&
83
+ (params.referralFeeRecipient == null ||
84
+ (0, viem_1.isAddressEqual)(params.referralFeeRecipient, viem_1.zeroAddress))) {
85
+ throw new index_js_1.ReferralFeeRecipientMissingError();
86
+ }
87
+ return {
88
+ referralFeePct,
89
+ referralFeeRecipient: params.referralFeeRecipient ?? viem_1.zeroAddress,
90
+ };
91
+ };
92
+ exports.validateReferralFee = validateReferralFee;
41
93
  /**
42
94
  * Validates that a raw or hydrated Midnight market belongs to the expected chain.
43
95
  *
@@ -61,22 +113,44 @@ exports.validateMidnightMarketChainId = validateMidnightMarketChainId;
61
113
  * Asserts that the client has a connected account AND that it matches
62
114
  * the provided user address.
63
115
  *
64
- * Used internally by the signature requirements (`encodeErc20Permit`,
65
- * `encodeErc20Permit2Approve`) to enforce builder = signer at `sign()` time:
66
- * the signing flow is the only path where an account/address mismatch
67
- * is a real security concern (rather than just an integrator footgun).
116
+ * Used at `sign()` time by the shared `signAndVerifyTypedData` helper (which
117
+ * backs the permit, Permit2, Blue authorization, and Midnight offer-root
118
+ * signature flows) and by `encodeVaultSharesPermit`, to enforce builder =
119
+ * signer: the signing flow is
120
+ * the only path where an account/address mismatch is a real security concern
121
+ * (rather than just an integrator footgun).
68
122
  *
69
123
  * Transaction builders no longer call this helper — callers are
70
124
  * responsible for keeping `userAddress` aligned with the signing account
71
125
  * at the builder layer.
72
126
  *
73
- * Throws {@link MissingClientPropertyError} if the client has no account.
74
- * Throws {@link AddressMismatchError} if the client account differs from
75
- * `userAddress`.
76
- *
77
127
  * @param clientAccountAddress - The client's account address; if undefined,
78
128
  * `MissingClientPropertyError` is thrown.
79
129
  * @param userAddress - The user address provided by the caller.
130
+ * @returns Nothing; narrows `clientAccountAddress` to a defined `Address` when
131
+ * it is present and equal to `userAddress`.
132
+ * @throws {MissingClientPropertyError} when the client has no connected account.
133
+ * @throws {AddressMismatchError} when the client account differs from
134
+ * `userAddress`.
135
+ * @example
136
+ * ```ts
137
+ * import { createWalletClient, http } from "viem";
138
+ * import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
139
+ * import { mainnet } from "viem/chains";
140
+ * import { validateUserAddress } from "@morpho-org/morpho-sdk";
141
+ *
142
+ * const account = privateKeyToAccount(generatePrivateKey());
143
+ * const walletClient = createWalletClient({
144
+ * account,
145
+ * chain: mainnet,
146
+ * transport: http(),
147
+ * });
148
+ *
149
+ * // Inside a `sign()` flow, before producing a typed-data signature:
150
+ * validateUserAddress(walletClient.account?.address, account.address);
151
+ * // Passes when the connected account equals the expected signer;
152
+ * // throws if the wallet has no account or signs for a different address.
153
+ * ```
80
154
  */
81
155
  function validateUserAddress(clientAccountAddress, userAddress) {
82
156
  if (clientAccountAddress === undefined) {
@@ -0,0 +1,274 @@
1
+ import { type AccrualVaultV2, AccrualVaultV2MorphoMarketV1AdapterV2, type Address, type MarketId } from "@morpho-org/blue-sdk";
2
+ import { type Hex } from "viem";
3
+ /**
4
+ * Outcome of resolving a Vault V2 snapshot against VaultExitBundlesV1's force-withdraw
5
+ * preconditions.
6
+ *
7
+ * Discriminated on `type`. Callers that must fail loudly map each non-`"eligible"` tag to a typed
8
+ * error; callers that only frame a UI treat every non-`"eligible"` tag as "no exit available".
9
+ */
10
+ export type VaultV2ForceWithdrawEligibility = {
11
+ readonly type: "eligible";
12
+ /** The vault's sole MorphoMarketV1AdapterV2. */
13
+ readonly adapter: AccrualVaultV2MorphoMarketV1AdapterV2;
14
+ /** Market the vault routes penalty-free liquidity through, or `undefined` when unset. */
15
+ readonly liquidityMarketId: MarketId | undefined;
16
+ } | {
17
+ readonly type: "adapterCount";
18
+ readonly adapters: number;
19
+ } | {
20
+ readonly type: "adapterMismatch";
21
+ readonly adapter: Address;
22
+ } | {
23
+ readonly type: "unsupportedAdapter";
24
+ readonly adapter: Address;
25
+ } | {
26
+ readonly type: "unsupportedLiquidityAdapter";
27
+ readonly liquidityAdapter: Address;
28
+ readonly adapter: Address;
29
+ } | {
30
+ readonly type: "undecodableLiquidityData";
31
+ readonly liquidityAdapter: Address;
32
+ /** Raw `liquidityData` that failed to decode as `MarketParams`. */
33
+ readonly liquidityData: Hex;
34
+ /** The underlying decode failure, preserved for the caller to wrap as `cause`. */
35
+ readonly cause: unknown;
36
+ };
37
+ /**
38
+ * Resolves whether a Vault V2 snapshot can be force-withdrawn through VaultExitBundlesV1.
39
+ *
40
+ * Mirrors the contract's four preconditions: `adaptersLength() == 1`, `isAdapter(adapter)`,
41
+ * `adapter.morpho() == BLUE` (implied by the adapter type, whose factory pins Blue), and a
42
+ * `liquidityAdapter` the contract can cast to `IMorphoMarketV1AdapterV2` and whose `liquidityData`
43
+ * decodes as `MarketParams`. Because the exit already requires a single adapter, the only
44
+ * resolvable liquidity configurations are unset or that same adapter.
45
+ *
46
+ * Pure: reads only the supplied snapshot and never throws.
47
+ *
48
+ * @param vaultData - Pre-fetched Vault V2 accrual snapshot.
49
+ * @param adapterOverride - Optional adapter the caller expects; defaults to the vault's sole adapter.
50
+ * @returns The `"eligible"` variant with the resolved adapter and liquidity market, or the tag
51
+ * describing which precondition failed.
52
+ * @example
53
+ * ```ts
54
+ * import { resolveVaultV2ForceWithdrawEligibility } from "@morpho-org/morpho-sdk";
55
+ *
56
+ * const eligibility = resolveVaultV2ForceWithdrawEligibility(vaultData);
57
+ * if (eligibility.type === "eligible") {
58
+ * console.log(eligibility.adapter.address, eligibility.liquidityMarketId);
59
+ * }
60
+ * ```
61
+ */
62
+ export declare function resolveVaultV2ForceWithdrawEligibility(vaultData: AccrualVaultV2, adapterOverride?: Address): VaultV2ForceWithdrawEligibility;
63
+ /**
64
+ * Computes the Vault V2 shares that accruing a vault snapshot mints to its owner as management
65
+ * and/or performance fees.
66
+ *
67
+ * Fee shares are minted to the matching recipient during the first withdrawal after accrual.
68
+ * When the owner is both recipients, both fee-share amounts are included. Timestamps before the
69
+ * snapshot's last update are clamped because Vault V2 cannot accrue backwards.
70
+ *
71
+ * @param params - Vault fee-share accrual inputs.
72
+ * @param params.vaultData - Pre-fetched Vault V2 accrual snapshot.
73
+ * @param params.owner - Account whose fee-recipient share mints are measured.
74
+ * @param params.timestamp - Target accrual timestamp, clamped to `vaultData.lastUpdate`.
75
+ * @returns Shares minted to `owner` by the management and/or performance fees, or `0n` when the
76
+ * owner is not a fee recipient.
77
+ * @example
78
+ * ```ts
79
+ * import { computeVaultV2ForceWithdrawFeeSharesMinted } from "@morpho-org/morpho-sdk";
80
+ *
81
+ * const feeShares = computeVaultV2ForceWithdrawFeeSharesMinted({
82
+ * vaultData,
83
+ * owner,
84
+ * timestamp,
85
+ * });
86
+ * ```
87
+ */
88
+ export declare function computeVaultV2ForceWithdrawFeeSharesMinted(params: {
89
+ readonly vaultData: AccrualVaultV2;
90
+ readonly owner: Address;
91
+ readonly timestamp: bigint;
92
+ }): bigint;
93
+ /** Vault V2 force-withdraw amounts derived from a vault snapshot. */
94
+ export interface VaultV2ForceWithdrawPlan {
95
+ /** WAD-scaled force-deallocation penalty the vault charges on this adapter. */
96
+ readonly penalty: bigint;
97
+ /** Penalty-inclusive amount requested from the vault. */
98
+ readonly exitAssets: bigint;
99
+ /** Penalty-free leg, withdrawn before any force deallocation. */
100
+ readonly assetsToWithdraw: bigint;
101
+ /** Penalised leg, force-deallocated from the adapter's markets. */
102
+ readonly assetsToDeallocate: bigint;
103
+ /** Upper bound of the assets burned as force-deallocation penalty. */
104
+ readonly penaltyAssets: bigint;
105
+ /** Assets the contract withdraws in total, before the referral fee. */
106
+ readonly withdrawnAssets: bigint;
107
+ /** Assets the adapter's markets can release for *this* `exitAssets`, summed across markets. */
108
+ readonly coveredAssets: bigint;
109
+ /**
110
+ * Largest penalty-inclusive `exitAssets` the snapshot supports.
111
+ *
112
+ * Independent of the requested `exitAssets`, so it is safe to use as an input ceiling. Always an
113
+ * amount the exit actually accepts: `0n` when nothing is exitable, and saturated at `maxUint256`
114
+ * rather than grossing up past the ABI slot.
115
+ */
116
+ readonly maxExitAssets: bigint;
117
+ /** Upper bound of the `forceDeallocate` calls the contract's loop performs. */
118
+ readonly penaltyLegs: number;
119
+ }
120
+ /**
121
+ * Computes every Vault V2 force-withdraw amount from a vault snapshot, without any RPC.
122
+ *
123
+ * Reproduces `vaultExitBundlesV1ForceWithdrawVaultV2` arithmetic:
124
+ *
125
+ * ```solidity
126
+ * withdrawableAssets = idle + min(liquidityAdapterAssets, liquidityMarketLiquidity);
127
+ * assetsToWithdraw = min(exitAssets, withdrawableAssets);
128
+ * assetsToDeallocate = mulDivDown(exitAssets - assetsToWithdraw, WAD, WAD + penalty);
129
+ * ```
130
+ *
131
+ * `coveredAssets` sums `min(adapterPosition, marketLiquidity)` over the adapter's markets, minus
132
+ * whatever the penalty-free leg already drained from the liquidity market. The sum is deliberately
133
+ * order-independent: the contract's loop visits every market taking `min(available, remaining)`, so
134
+ * total capacity does not depend on the adapter's storage order — which matters because a drained
135
+ * market is removed from that list mid-loop.
136
+ *
137
+ * That order-independence assumes `VaultExitBundlesV1` copies `adapter.marketIds` into memory
138
+ * *before* the loop. If it instead re-read adapter storage each iteration,
139
+ * `MorphoMarketV1AdapterV2.deallocate`'s swap-and-pop removal of a drained market would make the
140
+ * loop skip markets, and this sum would overstate real capacity — letting an exit through that
141
+ * panics on-chain. The claim is load-bearing for the coverage guard and is verified only by the
142
+ * fork suite, not by any in-repo contract source.
143
+ *
144
+ * @param params - Plan inputs.
145
+ * @param params.vaultData - Pre-fetched Vault V2 accrual snapshot.
146
+ * @param params.adapter - The vault's sole MorphoMarketV1AdapterV2, from
147
+ * {@link resolveVaultV2ForceWithdrawEligibility}.
148
+ * @param params.liquidityMarketId - Market the vault routes penalty-free liquidity through, or
149
+ * `undefined` when the vault has no liquidity adapter.
150
+ * @param params.exitAssets - Penalty-inclusive amount to exit.
151
+ * @param params.timestamp - Timestamp used to accrue every Morpho Blue market before converting
152
+ * adapter shares.
153
+ * @returns The resolved plan. `coveredAssets < assetsToDeallocate` means the exit would overrun the
154
+ * contract's unbounded loop; the caller decides how to report that.
155
+ * @throws {NonPositiveInputError} when `exitAssets` is not positive.
156
+ * @example
157
+ * ```ts
158
+ * import {
159
+ * computeVaultV2ForceWithdrawPlan,
160
+ * resolveVaultV2ForceWithdrawEligibility,
161
+ * } from "@morpho-org/morpho-sdk";
162
+ *
163
+ * const eligibility = resolveVaultV2ForceWithdrawEligibility(vaultData);
164
+ * if (eligibility.type === "eligible") {
165
+ * const plan = computeVaultV2ForceWithdrawPlan({
166
+ * vaultData,
167
+ * adapter: eligibility.adapter,
168
+ * liquidityMarketId: eligibility.liquidityMarketId,
169
+ * exitAssets: 1_000_000n,
170
+ * timestamp: 1_800_000_000n,
171
+ * });
172
+ * // plan.withdrawnAssets is what the user receives before the referral fee
173
+ * }
174
+ * ```
175
+ */
176
+ export declare function computeVaultV2ForceWithdrawPlan(params: {
177
+ readonly vaultData: AccrualVaultV2;
178
+ readonly adapter: AccrualVaultV2MorphoMarketV1AdapterV2;
179
+ readonly liquidityMarketId: MarketId | undefined;
180
+ readonly exitAssets: bigint;
181
+ readonly timestamp: bigint;
182
+ }): VaultV2ForceWithdrawPlan;
183
+ /**
184
+ * Upper-bounds the vault shares a Vault V2 force withdrawal burns.
185
+ *
186
+ * The contract splits the burn across up to `penaltyLegs + 2` separate `VaultV2.withdraw` calls (the
187
+ * penalty-free leg, one per `forceDeallocate`, and the final deallocated leg), each rounding its own
188
+ * share burn up. Converting the aggregate already spends one ceiling, so the bound adds one share
189
+ * per *additional* leg that moves a positive amount — a zero-amount leg burns `toShares(0, "Up")`
190
+ * and rounds nothing.
191
+ *
192
+ * The result is the **denominator of {@link computeMinForceWithdrawSharePrice}** — the largest share
193
+ * burn the realized exit price is measured against. It takes the max over the two supplied snapshots
194
+ * because interest lowers the burn while management fees raise it, so neither snapshot alone bounds
195
+ * execution. The entity passes both accrued to `now` (execution time): the raw `lastUpdate` snapshot
196
+ * underestimates the burn a stale fee-bearing vault realizes — the first withdrawal accrues pending
197
+ * management fees before burning shares — which lifts the floor above the faithful price and trips
198
+ * `SlippageExceeded`. Accruing to `now`, not the caller-chosen `deadline`, tracks execution without
199
+ * letting a long deadline silently weaken the guard; `slippageTolerance` absorbs the residual drift
200
+ * until inclusion. Pass distinct snapshots to bound the burn across an accrual window.
201
+ *
202
+ * This is **not** the share allowance to authorize. The price floor's denominator is this bound
203
+ * minus `computeVaultV2ForceWithdrawFeeSharesMinted({ vaultData, owner, timestamp: now })`: the
204
+ * contract measures the *net* burn, which fee mints to `owner` shrink. The allowance is
205
+ * `min(mulDivUp(exitAssets, RAY, minSharePriceE27) + computeVaultV2ForceWithdrawFeeSharesMinted({
206
+ * vaultData, owner, timestamp: deadline }), maxUint256)`: the permit pays for the *gross* burn.
207
+ *
208
+ * @param params - Share-bound inputs.
209
+ * @param params.vaultData - Pre-fetched Vault V2 accrual snapshot.
210
+ * @param params.deadlineVaultData - The same vault accrued to a second timestamp; the max of the two
211
+ * share burns is returned. The entity passes the `now`-accrued snapshot for both.
212
+ * @param params.plan - Plan from {@link computeVaultV2ForceWithdrawPlan}.
213
+ * @returns An upper bound, in vault shares, of what the exit burns.
214
+ * @example
215
+ * ```ts
216
+ * import { MathLib } from "@morpho-org/blue-sdk";
217
+ * import {
218
+ * computeVaultV2ForceWithdrawFeeSharesMinted,
219
+ * computeVaultV2ForceWithdrawSharesBurnt,
220
+ * } from "@morpho-org/morpho-sdk";
221
+ *
222
+ * const { vault: nowVaultData } = vaultData.accrueInterest(now);
223
+ * const sharesBurnt = computeVaultV2ForceWithdrawSharesBurnt({
224
+ * vaultData: nowVaultData,
225
+ * deadlineVaultData: nowVaultData,
226
+ * plan,
227
+ * });
228
+ * const feeSharesNow = computeVaultV2ForceWithdrawFeeSharesMinted({
229
+ * vaultData,
230
+ * owner,
231
+ * timestamp: now,
232
+ * });
233
+ * const sharesBurntForFloor = sharesBurnt - feeSharesNow;
234
+ * const requiredShareAllowance = MathLib.min(
235
+ * MathLib.mulDivUp(exitAssets, MathLib.RAY, minSharePriceE27) +
236
+ * computeVaultV2ForceWithdrawFeeSharesMinted({
237
+ * vaultData,
238
+ * owner,
239
+ * timestamp: deadline,
240
+ * }),
241
+ * maxUint256,
242
+ * );
243
+ * ```
244
+ */
245
+ export declare function computeVaultV2ForceWithdrawSharesBurnt(params: {
246
+ readonly vaultData: AccrualVaultV2;
247
+ readonly deadlineVaultData: AccrualVaultV2;
248
+ readonly plan: VaultV2ForceWithdrawPlan;
249
+ }): bigint;
250
+ /**
251
+ * Computes a lower bound of the Vault V2 shares that a force withdrawal burns.
252
+ *
253
+ * The penalty-free/penalised split can move as liquidity accrues between planning and inclusion.
254
+ * This lower bound is used to reject fee-recipient exits whose fee mints could reach the burn
255
+ * measured by VaultExitBundlesV1, independently of that split.
256
+ *
257
+ * @param params - Lower-bound inputs.
258
+ * @param params.vaultData - Vault V2 snapshot already accrued to the execution timestamp.
259
+ * @param params.plan - Plan from {@link computeVaultV2ForceWithdrawPlan}.
260
+ * @returns A lower bound, in vault shares, of the burn measured by the contract.
261
+ * @example
262
+ * ```ts
263
+ * import { computeVaultV2ForceWithdrawMinSharesBurnt } from "@morpho-org/morpho-sdk";
264
+ *
265
+ * const minSharesBurnt = computeVaultV2ForceWithdrawMinSharesBurnt({
266
+ * vaultData,
267
+ * plan,
268
+ * });
269
+ * ```
270
+ */
271
+ export declare function computeVaultV2ForceWithdrawMinSharesBurnt(params: {
272
+ readonly vaultData: AccrualVaultV2;
273
+ readonly plan: VaultV2ForceWithdrawPlan;
274
+ }): bigint;