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

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 (277) hide show
  1. package/MIGRATION-v5-to-v6.md +88 -32
  2. package/README.md +9 -7
  3. package/lib/cjs/abis.d.ts +7 -2844
  4. package/lib/cjs/abis.js +3 -1951
  5. package/lib/cjs/actions/blue/borrow.d.ts +3 -2
  6. package/lib/cjs/actions/blue/borrow.js +3 -2
  7. package/lib/cjs/actions/blue/common.js +1 -9
  8. package/lib/cjs/actions/blue/refinance.d.ts +2 -2
  9. package/lib/cjs/actions/blue/refinance.js +2 -2
  10. package/lib/cjs/actions/blue/repay.d.ts +1 -1
  11. package/lib/cjs/actions/blue/repay.js +1 -1
  12. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +2 -2
  13. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -2
  14. package/lib/cjs/actions/blue/supply.d.ts +2 -2
  15. package/lib/cjs/actions/blue/supply.js +2 -2
  16. package/lib/cjs/actions/blue/supplyCollateral.d.ts +2 -2
  17. package/lib/cjs/actions/blue/supplyCollateral.js +2 -2
  18. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -2
  19. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +3 -2
  20. package/lib/cjs/actions/blue/withdraw.d.ts +3 -3
  21. package/lib/cjs/actions/blue/withdraw.js +3 -3
  22. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +2 -2
  23. package/lib/cjs/actions/blue/withdrawCollateral.js +2 -2
  24. package/lib/cjs/actions/bundles/common.d.ts +6 -2
  25. package/lib/cjs/actions/bundles/common.js +31 -5
  26. package/lib/cjs/actions/index.d.ts +0 -1
  27. package/lib/cjs/actions/index.js +0 -1
  28. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -8
  29. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +11 -16
  30. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
  31. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
  32. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
  33. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +4 -5
  34. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +5 -5
  35. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +6 -11
  36. package/lib/cjs/actions/requirements/encode/index.d.ts +0 -1
  37. package/lib/cjs/actions/requirements/encode/index.js +0 -1
  38. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +5 -6
  39. package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -6
  40. package/lib/cjs/actions/requirements/index.d.ts +0 -1
  41. package/lib/cjs/actions/requirements/index.js +0 -1
  42. package/lib/cjs/actions/vaultV1/deposit.d.ts +1 -2
  43. package/lib/cjs/actions/vaultV1/deposit.js +1 -2
  44. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +7 -5
  45. package/lib/cjs/actions/vaultV1/inKindRedeem.js +11 -7
  46. package/lib/cjs/actions/vaultV2/deposit.d.ts +1 -2
  47. package/lib/cjs/actions/vaultV2/deposit.js +1 -2
  48. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
  49. package/lib/cjs/actions/vaultV2/forceWithdraw.js +3 -3
  50. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +7 -5
  51. package/lib/cjs/actions/vaultV2/inKindRedeem.js +11 -7
  52. package/lib/cjs/augment/AccrualPosition.d.ts +1 -0
  53. package/lib/cjs/augment.d.ts +0 -1
  54. package/lib/cjs/augment.js +0 -1
  55. package/lib/cjs/blue/abis.d.ts +5 -5
  56. package/lib/cjs/blue/abis.js +3 -7
  57. package/lib/cjs/blue/entities.d.ts +10 -8
  58. package/lib/cjs/blue/entities.js +3 -3
  59. package/lib/cjs/blue/errors.d.ts +4 -2
  60. package/lib/cjs/blue/errors.js +3 -1
  61. package/lib/cjs/blue/fetch.d.ts +5 -3
  62. package/lib/cjs/blue/fetch.js +3 -3
  63. package/lib/cjs/blue/types.d.ts +2 -4
  64. package/lib/cjs/blue/utils.d.ts +6 -4
  65. package/lib/cjs/blue/utils.js +3 -3
  66. package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
  67. package/lib/cjs/client/morphoViemExtension.js +1 -1
  68. package/lib/cjs/constants.d.ts +3 -37
  69. package/lib/cjs/constants.js +1 -39
  70. package/lib/cjs/entities/blue/blue.d.ts +30 -265
  71. package/lib/cjs/entities/blue/blue.js +1 -205
  72. package/lib/cjs/entities/index.d.ts +11 -66
  73. package/lib/cjs/entities/index.js +3 -21
  74. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -2
  75. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -3
  76. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +13 -5
  77. package/lib/cjs/entities/vaultV1/vaultV1.js +16 -10
  78. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +40 -19
  79. package/lib/cjs/entities/vaultV2/vaultV2.js +57 -26
  80. package/lib/cjs/entities/vaultV2BlueReallocationData.js +4 -21
  81. package/lib/cjs/errors.d.ts +5 -47
  82. package/lib/cjs/errors.js +4 -46
  83. package/lib/cjs/fetch.d.ts +5 -17
  84. package/lib/cjs/fetch.js +3 -17
  85. package/lib/cjs/helpers/constant.d.ts +0 -2
  86. package/lib/cjs/helpers/constant.js +0 -2
  87. package/lib/cjs/helpers/index.d.ts +2 -3
  88. package/lib/cjs/helpers/index.js +1 -9
  89. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +11 -5
  90. package/lib/cjs/helpers/slippage.d.ts +1 -103
  91. package/lib/cjs/helpers/slippage.js +0 -150
  92. package/lib/cjs/helpers/utilization.d.ts +12 -10
  93. package/lib/cjs/helpers/utilization.js +27 -12
  94. package/lib/cjs/helpers/validate.d.ts +1 -24
  95. package/lib/cjs/helpers/validate.js +2 -49
  96. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  97. package/lib/cjs/helpers/validateRequirementSpender.js +1 -3
  98. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +48 -15
  99. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +48 -15
  100. package/lib/cjs/midnight/errors.d.ts +1 -1
  101. package/lib/cjs/midnight/errors.js +2 -1
  102. package/lib/cjs/types/action.d.ts +17 -65
  103. package/lib/cjs/types/action.js +11 -4
  104. package/lib/cjs/types/error.d.ts +50 -381
  105. package/lib/cjs/types/error.js +64 -395
  106. package/lib/cjs/types/sharedLiquidity.d.ts +1 -117
  107. package/lib/cjs/types.d.ts +2 -18
  108. package/lib/cjs/utils.d.ts +10 -35
  109. package/lib/cjs/utils.js +4 -36
  110. package/lib/esm/abis.d.ts +7 -2844
  111. package/lib/esm/abis.js +7 -1950
  112. package/lib/esm/actions/blue/borrow.d.ts +3 -2
  113. package/lib/esm/actions/blue/borrow.js +3 -2
  114. package/lib/esm/actions/blue/common.js +1 -9
  115. package/lib/esm/actions/blue/refinance.d.ts +2 -2
  116. package/lib/esm/actions/blue/refinance.js +2 -2
  117. package/lib/esm/actions/blue/repay.d.ts +1 -1
  118. package/lib/esm/actions/blue/repay.js +1 -1
  119. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +2 -2
  120. package/lib/esm/actions/blue/repayWithdrawCollateral.js +2 -2
  121. package/lib/esm/actions/blue/supply.d.ts +2 -2
  122. package/lib/esm/actions/blue/supply.js +2 -2
  123. package/lib/esm/actions/blue/supplyCollateral.d.ts +2 -2
  124. package/lib/esm/actions/blue/supplyCollateral.js +2 -2
  125. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -2
  126. package/lib/esm/actions/blue/supplyCollateralBorrow.js +3 -2
  127. package/lib/esm/actions/blue/withdraw.d.ts +3 -3
  128. package/lib/esm/actions/blue/withdraw.js +3 -3
  129. package/lib/esm/actions/blue/withdrawCollateral.d.ts +2 -2
  130. package/lib/esm/actions/blue/withdrawCollateral.js +2 -2
  131. package/lib/esm/actions/bundles/common.d.ts +6 -2
  132. package/lib/esm/actions/bundles/common.js +32 -6
  133. package/lib/esm/actions/index.d.ts +0 -1
  134. package/lib/esm/actions/index.js +0 -1
  135. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -8
  136. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +12 -17
  137. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
  138. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
  139. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
  140. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +4 -5
  141. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +5 -5
  142. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +6 -11
  143. package/lib/esm/actions/requirements/encode/index.d.ts +0 -1
  144. package/lib/esm/actions/requirements/encode/index.js +0 -1
  145. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +5 -6
  146. package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -6
  147. package/lib/esm/actions/requirements/index.d.ts +0 -1
  148. package/lib/esm/actions/requirements/index.js +0 -1
  149. package/lib/esm/actions/vaultV1/deposit.d.ts +1 -2
  150. package/lib/esm/actions/vaultV1/deposit.js +1 -2
  151. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +7 -5
  152. package/lib/esm/actions/vaultV1/inKindRedeem.js +11 -7
  153. package/lib/esm/actions/vaultV2/deposit.d.ts +1 -2
  154. package/lib/esm/actions/vaultV2/deposit.js +1 -2
  155. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
  156. package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -3
  157. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +7 -5
  158. package/lib/esm/actions/vaultV2/inKindRedeem.js +11 -7
  159. package/lib/esm/augment/AccrualPosition.d.ts +1 -0
  160. package/lib/esm/augment.d.ts +0 -1
  161. package/lib/esm/augment.js +0 -1
  162. package/lib/esm/blue/abis.d.ts +5 -5
  163. package/lib/esm/blue/abis.js +5 -5
  164. package/lib/esm/blue/entities.d.ts +10 -8
  165. package/lib/esm/blue/entities.js +5 -3
  166. package/lib/esm/blue/errors.d.ts +4 -2
  167. package/lib/esm/blue/errors.js +4 -2
  168. package/lib/esm/blue/fetch.d.ts +5 -3
  169. package/lib/esm/blue/fetch.js +5 -3
  170. package/lib/esm/blue/types.d.ts +2 -4
  171. package/lib/esm/blue/utils.d.ts +6 -4
  172. package/lib/esm/blue/utils.js +6 -4
  173. package/lib/esm/client/morphoViemExtension.d.ts +1 -1
  174. package/lib/esm/client/morphoViemExtension.js +1 -1
  175. package/lib/esm/constants.d.ts +3 -37
  176. package/lib/esm/constants.js +3 -37
  177. package/lib/esm/entities/blue/blue.d.ts +30 -265
  178. package/lib/esm/entities/blue/blue.js +4 -208
  179. package/lib/esm/entities/index.d.ts +11 -66
  180. package/lib/esm/entities/index.js +5 -18
  181. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -2
  182. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -3
  183. package/lib/esm/entities/vaultV1/vaultV1.d.ts +13 -5
  184. package/lib/esm/entities/vaultV1/vaultV1.js +19 -13
  185. package/lib/esm/entities/vaultV2/vaultV2.d.ts +40 -19
  186. package/lib/esm/entities/vaultV2/vaultV2.js +61 -30
  187. package/lib/esm/entities/vaultV2BlueReallocationData.js +2 -19
  188. package/lib/esm/errors.d.ts +5 -47
  189. package/lib/esm/errors.js +5 -47
  190. package/lib/esm/fetch.d.ts +5 -17
  191. package/lib/esm/fetch.js +5 -17
  192. package/lib/esm/helpers/constant.d.ts +0 -2
  193. package/lib/esm/helpers/constant.js +0 -2
  194. package/lib/esm/helpers/index.d.ts +2 -3
  195. package/lib/esm/helpers/index.js +2 -3
  196. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +11 -5
  197. package/lib/esm/helpers/slippage.d.ts +1 -103
  198. package/lib/esm/helpers/slippage.js +1 -147
  199. package/lib/esm/helpers/utilization.d.ts +12 -10
  200. package/lib/esm/helpers/utilization.js +26 -11
  201. package/lib/esm/helpers/validate.d.ts +1 -24
  202. package/lib/esm/helpers/validate.js +2 -48
  203. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  204. package/lib/esm/helpers/validateRequirementSpender.js +1 -3
  205. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +48 -15
  206. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +48 -15
  207. package/lib/esm/midnight/errors.d.ts +1 -1
  208. package/lib/esm/midnight/errors.js +1 -1
  209. package/lib/esm/types/action.d.ts +17 -65
  210. package/lib/esm/types/action.js +12 -5
  211. package/lib/esm/types/error.d.ts +50 -381
  212. package/lib/esm/types/error.js +58 -377
  213. package/lib/esm/types/sharedLiquidity.d.ts +1 -117
  214. package/lib/esm/types.d.ts +2 -18
  215. package/lib/esm/utils.d.ts +10 -35
  216. package/lib/esm/utils.js +9 -34
  217. package/package.json +6 -17
  218. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
  219. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -88
  220. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
  221. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -152
  222. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
  223. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -53
  224. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
  225. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -74
  226. package/lib/cjs/actions/requirements/generalAdapter/index.d.ts +0 -3
  227. package/lib/cjs/actions/requirements/generalAdapter/index.js +0 -19
  228. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
  229. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.js +0 -48
  230. package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +0 -58
  231. package/lib/cjs/actions/signatures/getTokenRequirementActions.js +0 -119
  232. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -50
  233. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -45
  234. package/lib/cjs/actions/signatures/index.d.ts +0 -3
  235. package/lib/cjs/actions/signatures/index.js +0 -19
  236. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -11
  237. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.js +0 -8
  238. package/lib/cjs/bundler/actions.d.ts +0 -797
  239. package/lib/cjs/bundler/actions.js +0 -1371
  240. package/lib/cjs/bundler/index.d.ts +0 -2
  241. package/lib/cjs/bundler/index.js +0 -18
  242. package/lib/cjs/bundler/types.d.ts +0 -235
  243. package/lib/cjs/bundler/types.js +0 -2
  244. package/lib/cjs/entities/vaultV1ReallocationData.d.ts +0 -332
  245. package/lib/cjs/entities/vaultV1ReallocationData.js +0 -557
  246. package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +0 -80
  247. package/lib/cjs/helpers/computeVaultV1Reallocations.js +0 -245
  248. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
  249. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -84
  250. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
  251. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -148
  252. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
  253. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -49
  254. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
  255. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -70
  256. package/lib/esm/actions/requirements/generalAdapter/index.d.ts +0 -3
  257. package/lib/esm/actions/requirements/generalAdapter/index.js +0 -3
  258. package/lib/esm/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
  259. package/lib/esm/actions/signatures/getBlueAuthorizationAction.js +0 -44
  260. package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +0 -58
  261. package/lib/esm/actions/signatures/getTokenRequirementActions.js +0 -115
  262. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -50
  263. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -41
  264. package/lib/esm/actions/signatures/index.d.ts +0 -3
  265. package/lib/esm/actions/signatures/index.js +0 -3
  266. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -11
  267. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +0 -7
  268. package/lib/esm/bundler/actions.d.ts +0 -797
  269. package/lib/esm/bundler/actions.js +0 -1368
  270. package/lib/esm/bundler/index.d.ts +0 -2
  271. package/lib/esm/bundler/index.js +0 -2
  272. package/lib/esm/bundler/types.d.ts +0 -235
  273. package/lib/esm/bundler/types.js +0 -1
  274. package/lib/esm/entities/vaultV1ReallocationData.d.ts +0 -332
  275. package/lib/esm/entities/vaultV1ReallocationData.js +0 -559
  276. package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +0 -80
  277. package/lib/esm/helpers/computeVaultV1Reallocations.js +0 -241
@@ -262,23 +262,34 @@ export function computeVaultV2ForceWithdrawPlan(params) {
262
262
  * The result is the **denominator of {@link computeMinForceWithdrawSharePrice}** — the largest share
263
263
  * burn the realized exit price is measured against. It takes the max over the two supplied snapshots
264
264
  * because interest lowers the burn while management fees raise it, so neither snapshot alone bounds
265
- * execution. The entity passes both accrued to `now` (execution time): the raw `lastUpdate` snapshot
266
- * underestimates the burn a stale fee-bearing vault realizes — the first withdrawal accrues pending
267
- * management fees before burning shares — which lifts the floor above the faithful price and trips
268
- * `SlippageExceeded`. Accruing to `now`, not the caller-chosen `deadline`, tracks execution without
269
- * letting a long deadline silently weaken the guard; `slippageTolerance` absorbs the residual drift
270
- * until inclusion. Pass distinct snapshots to bound the burn across an accrual window.
265
+ * execution. The entity passes the raw `lastUpdate` snapshot and the same vault accrued to `now`
266
+ * (execution time): the raw snapshot underestimates the burn a stale fee-bearing vault realizes —
267
+ * the first withdrawal accrues pending management fees before burning shares — while the `now`
268
+ * accrual underestimates it when it projects interest the chain has not realized (a wall clock
269
+ * running ahead of the chain, or a capped `maxRate`); either alone would lift the floor above the
270
+ * faithful price and trip `SlippageExceeded`. Accruing to `now`, not the caller-chosen `deadline`,
271
+ * tracks execution without letting a long deadline silently weaken the guard; `slippageTolerance`
272
+ * absorbs the residual drift until inclusion.
271
273
  *
272
- * This is **not** the share allowance to authorize. The price floor's denominator is this bound
273
- * minus `computeVaultV2ForceWithdrawFeeSharesMinted({ vaultData, owner, timestamp: now })`: the
274
- * contract measures the *net* burn, which fee mints to `owner` shrink. The allowance is
275
- * `min(mulDivUp(exitAssets, RAY, minSharePriceE27) + computeVaultV2ForceWithdrawFeeSharesMinted({
276
- * vaultData, owner, timestamp: deadline }), maxUint256)`: the permit pays for the *gross* burn.
274
+ * This is **not** the share allowance to authorize. The contract measures the *net* burn, which
275
+ * fee mints to `owner` shrink, and the raw snapshot mints none while the `now` accrual mints
276
+ * `computeVaultV2ForceWithdrawFeeSharesMinted({ vaultData, owner, timestamp: now })`; so the
277
+ * entity nets each endpoint before taking the max (`max(burnRaw, burnNow - feeSharesNow)`) rather
278
+ * than subtracting the `now` fee from a gross max. The allowance is
279
+ * `min(max(mulDivUp(exitAssets, RAY, max(min(mulDivDown(minSharePriceE27, WAD - slippageTolerance,
280
+ * WAD), minSharePriceE27 - 1), 1)), mulDivUp(exitAssets, RAY, minSharePriceE27) + 1)
281
+ * + computeVaultV2ForceWithdrawFeeSharesMinted({ vaultData, owner, timestamp: deadline }),
282
+ * maxUint256)`: the permit pays for the *gross* burn, covering a burn at least one tolerance step
283
+ * below the floor whenever the floor exceeds one RAY unit and, in any case, at least one share
284
+ * above the burn at the floor, so a price within that headroom below the floor reverts on the
285
+ * contract's `minSharePriceE27` check rather than on the allowance; a deeper drop can still
286
+ * surface as an ERC-20 allowance underflow.
277
287
  *
278
288
  * @param params - Share-bound inputs.
279
289
  * @param params.vaultData - Pre-fetched Vault V2 accrual snapshot.
280
290
  * @param params.deadlineVaultData - The same vault accrued to a second timestamp; the max of the two
281
- * share burns is returned. The entity passes the `now`-accrued snapshot for both.
291
+ * share burns is returned. The entity calls this twice — the raw snapshot for both parameters,
292
+ * then the `now` accrual for both — and nets each result before taking the max.
282
293
  * @param params.plan - Plan from {@link computeVaultV2ForceWithdrawPlan}.
283
294
  * @returns An upper bound, in vault shares, of what the exit burns.
284
295
  * @example
@@ -290,7 +301,12 @@ export function computeVaultV2ForceWithdrawPlan(params) {
290
301
  * } from "@morpho-org/morpho-sdk";
291
302
  *
292
303
  * const { vault: nowVaultData } = vaultData.accrueInterest(now);
293
- * const sharesBurnt = computeVaultV2ForceWithdrawSharesBurnt({
304
+ * const sharesBurntRaw = computeVaultV2ForceWithdrawSharesBurnt({
305
+ * vaultData,
306
+ * deadlineVaultData: vaultData,
307
+ * plan,
308
+ * });
309
+ * const sharesBurntNow = computeVaultV2ForceWithdrawSharesBurnt({
294
310
  * vaultData: nowVaultData,
295
311
  * deadlineVaultData: nowVaultData,
296
312
  * plan,
@@ -300,9 +316,26 @@ export function computeVaultV2ForceWithdrawPlan(params) {
300
316
  * owner,
301
317
  * timestamp: now,
302
318
  * });
303
- * const sharesBurntForFloor = sharesBurnt - feeSharesNow;
319
+ * const sharesBurntForFloor = MathLib.max(
320
+ * sharesBurntRaw,
321
+ * sharesBurntNow - feeSharesNow,
322
+ * );
323
+ * const allowanceSharePriceE27 = MathLib.max(
324
+ * MathLib.min(
325
+ * MathLib.mulDivDown(
326
+ * minSharePriceE27,
327
+ * MathLib.WAD - slippageTolerance,
328
+ * MathLib.WAD,
329
+ * ),
330
+ * minSharePriceE27 - 1n,
331
+ * ),
332
+ * 1n,
333
+ * );
304
334
  * const requiredShareAllowance = MathLib.min(
305
- * MathLib.mulDivUp(exitAssets, MathLib.RAY, minSharePriceE27) +
335
+ * MathLib.max(
336
+ * MathLib.mulDivUp(exitAssets, MathLib.RAY, allowanceSharePriceE27),
337
+ * MathLib.mulDivUp(exitAssets, MathLib.RAY, minSharePriceE27) + 1n,
338
+ * ) +
306
339
  * computeVaultV2ForceWithdrawFeeSharesMinted({
307
340
  * vaultData,
308
341
  * owner,
@@ -1 +1 @@
1
- export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
1
+ export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
@@ -1 +1 @@
1
- export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
1
+ export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
@@ -417,20 +417,6 @@ export interface Transaction<TAction extends BaseAction = TransactionAction> {
417
417
  readonly data: Hex;
418
418
  readonly action: TAction;
419
419
  }
420
- /**
421
- * Enforces that at least one deposit amount source is provided.
422
- *
423
- * - `amount` alone: standard ERC20 deposit.
424
- * - `nativeAmount` alone: pure native-wrap deposit (vault asset must be wNative).
425
- * - Both: mixed deposit (ERC20 transfer + native wrap).
426
- */
427
- export type DepositAmountArgs = {
428
- amount: bigint;
429
- nativeAmount?: bigint;
430
- } | {
431
- nativeAmount: bigint;
432
- amount?: bigint;
433
- };
434
420
  /** Mutually exclusive ERC-20 or native funding accepted by fixed bundles entrypoints. */
435
421
  export type BundlesFundingArgs = {
436
422
  readonly amount: bigint;
@@ -458,8 +444,7 @@ export type VaultV1MigrateToV2AmountArgs = {
458
444
  * Holds the pre-resolved arguments for an ERC-2612 `permit`: the signed approval
459
445
  * of `amount` of `asset` from `owner` to the permitted spender, bounded by the
460
446
  * `deadline` timestamp and consuming the given `nonce`. The associated
461
- * {@link PermitAction} identifies the permitted spender, including fixed-bundle
462
- * contracts and the GeneralAdapter1 periphery.
447
+ * {@link PermitAction} identifies the permitted fixed-bundle contract.
463
448
  */
464
449
  export interface PermitArgs {
465
450
  readonly owner: Address;
@@ -469,25 +454,10 @@ export interface PermitArgs {
469
454
  readonly amount: bigint;
470
455
  readonly deadline: bigint;
471
456
  }
472
- /**
473
- * Holds the pre-resolved arguments for a Permit2 `permit` bundler call. It
474
- * mirrors {@link PermitArgs} but adds the Permit2 allowance `expiration` (when
475
- * the on-chain allowance lapses) alongside the signature `deadline` (by when the
476
- * signature must be submitted).
477
- */
478
- export interface Permit2Args {
479
- readonly owner: Address;
480
- readonly nonce: bigint;
481
- readonly asset: Address;
482
- readonly signature: Hex;
483
- readonly amount: bigint;
484
- readonly deadline: bigint;
485
- readonly expiration: bigint;
486
- }
487
457
  /**
488
458
  * Signed Morpho Blue authorization payload produced when an integrator opts into offchain
489
- * signatures (`supportSignature: true`). Bundler3 consumes it through `setAuthorizationWithSig`;
490
- * direct BlueBundlesV1 writes encode it into their signed-authorization struct.
459
+ * signatures (`supportSignature: true`). BlueBundlesV1 encodes it into its
460
+ * signed-authorization struct.
491
461
  */
492
462
  export interface AuthorizationSignatureArgs {
493
463
  /** Account granting the authorization (the position owner). */
@@ -527,15 +497,6 @@ export interface PermitAction extends BaseAction<"permit", {
527
497
  */
528
498
  readonly typedData?: RequirementTypedData;
529
499
  }
530
- export interface Permit2Action extends BaseAction<"permit2", {
531
- spender: Address;
532
- amount: bigint;
533
- deadline: bigint;
534
- expiration: bigint;
535
- }> {
536
- /** EIP-712 payload to sign for this Permit2 AllowanceTransfer. See {@link PermitAction.typedData}. */
537
- readonly typedData?: RequirementTypedData;
538
- }
539
500
  /** Signable Permit2 SignatureTransfer requirement for a fixed bundles token pull. */
540
501
  export interface Permit2SignatureTransferAction extends BaseAction<"permit2SignatureTransfer", {
541
502
  readonly spender: Address;
@@ -547,8 +508,7 @@ export interface Permit2SignatureTransferAction extends BaseAction<"permit2Signa
547
508
  readonly typedData?: RequirementTypedData;
548
509
  }
549
510
  /**
550
- * Signable Morpho authorization requirement. Its `authorized` operator is route-specific:
551
- * GeneralAdapter1 for Bundler3 flows or BlueBundlesV1 for direct Blue writes.
511
+ * Signable Morpho authorization requirement for direct BlueBundlesV1 writes.
552
512
  */
553
513
  export interface AuthorizationAction extends BaseAction<"authorization", {
554
514
  authorized: Address;
@@ -575,27 +535,22 @@ export interface MidnightOfferRootSignatureAction extends BaseAction<"midnightOf
575
535
  readonly typedData?: RequirementTypedData;
576
536
  }
577
537
  /** Action metadata supported by signature requirements. */
578
- export type SignatureRequirementAction = PermitAction | Permit2Action | Permit2SignatureTransferAction | AuthorizationAction | MidnightOfferRootSignatureAction;
538
+ export type SignatureRequirementAction = PermitAction | Permit2SignatureTransferAction | AuthorizationAction | MidnightOfferRootSignatureAction;
579
539
  /** Argument payloads returned by signature requirements. */
580
- export type RequirementSignatureArgs = PermitArgs | Permit2Args | AuthorizationSignatureArgs | MidnightOfferRootSignatureArgs;
540
+ export type RequirementSignatureArgs = PermitArgs | AuthorizationSignatureArgs | MidnightOfferRootSignatureArgs;
581
541
  /** A signed ERC-2612 permit requirement. */
582
542
  export interface Erc2612RequirementSignature {
583
543
  readonly args: Readonly<PermitArgs>;
584
544
  readonly action: PermitAction;
585
545
  }
586
- /** A signed Permit2 AllowanceTransfer requirement used by Bundler3. */
587
- export interface Permit2AllowanceRequirementSignature {
588
- readonly args: Readonly<Permit2Args>;
589
- readonly action: Permit2Action;
590
- }
591
- /** A signed ERC-2612 permit or Permit2 AllowanceTransfer requirement. */
592
- export type PermitRequirementSignature = Erc2612RequirementSignature | Permit2AllowanceRequirementSignature;
546
+ /** A signed ERC-2612 permit requirement accepted by vault-share bundle calls. */
547
+ export type PermitRequirementSignature = Erc2612RequirementSignature;
593
548
  /** A signed Permit2 SignatureTransfer requirement used by fixed bundles contracts. */
594
549
  export interface Permit2SignatureTransferRequirementSignature {
595
550
  readonly args: Readonly<PermitArgs>;
596
551
  readonly action: Permit2SignatureTransferAction;
597
552
  }
598
- /** A signed Morpho authorization consumed by Bundler3 or a direct BlueBundlesV1 call. */
553
+ /** A signed Morpho authorization consumed by a direct BlueBundlesV1 call. */
599
554
  export interface AuthorizationRequirementSignature {
600
555
  readonly args: AuthorizationSignatureArgs;
601
556
  readonly action: AuthorizationAction;
@@ -607,7 +562,7 @@ export interface MidnightOfferRootSignature {
607
562
  }
608
563
  /**
609
564
  * The deep-frozen output of `Requirement.sign()`. Discriminated on `action.type`:
610
- * `"permit"` / `"permit2"` carry token-approval args, `"permit2SignatureTransfer"` carries a
565
+ * `"permit"` carries token-approval args, `"permit2SignatureTransfer"` carries a
611
566
  * bundles SignatureTransfer, `"authorization"` carries the signed Morpho authorization,
612
567
  * and Midnight adds `"midnightOfferRootSignature"`.
613
568
  */
@@ -644,20 +599,16 @@ export interface Requirement<TSignatureOrAction extends RequirementSignature | S
644
599
  readonly typedData: RequirementTypedData;
645
600
  };
646
601
  }
647
- /** Bundler3 token signature requirement. */
648
- export type Bundler3TokenSignatureRequirement = Requirement<PermitRequirementSignature>;
649
602
  /** ERC-2612 or Permit2 SignatureTransfer requirement consumed by a fixed bundles contract. */
650
603
  export type BundlesTokenSignatureRequirement = Requirement<BundlesTokenRequirementSignature>;
651
604
  /** Midnight Ecrecover offer-root signature requirement. */
652
605
  export type MidnightOfferRootRequirement = Requirement<MidnightOfferRootSignatureAction, MidnightOfferRootSignatureArgs>;
653
606
  /** Any token signature requirement supported by an SDK transaction route. */
654
- export type TokenSignatureRequirement = Bundler3TokenSignatureRequirement | BundlesTokenSignatureRequirement;
655
- /** Bundler3 token signature result. */
656
- export type Bundler3TokenRequirementSignature = PermitRequirementSignature;
607
+ export type TokenSignatureRequirement = BundlesTokenSignatureRequirement;
657
608
  /** Token signature result consumed by a fixed bundles contract. */
658
609
  export type BundlesTokenRequirementSignature = Erc2612RequirementSignature | Permit2SignatureTransferRequirementSignature;
659
610
  /** Any token signature result supported by an SDK transaction route. */
660
- export type TokenRequirementSignature = Bundler3TokenRequirementSignature | BundlesTokenRequirementSignature;
611
+ export type TokenRequirementSignature = BundlesTokenRequirementSignature;
661
612
  /** Any signature result returned by an action-output signature requirement. */
662
613
  export type AnyRequirementSignature = TokenRequirementSignature | AuthorizationRequirementSignature | MidnightOfferRootSignature;
663
614
  /** Any signature requirement returned by an entity action output. */
@@ -689,10 +640,10 @@ export declare function isRequirementSignature<T extends RequirementSignature =
689
640
  export declare function isRequirementSignature(requirement: CallRequirement | Requirement | undefined): requirement is Requirement;
690
641
  export declare function isRequirementSignature(requirement: ActionRequirement | undefined): requirement is SignatureRequirement;
691
642
  /**
692
- * Narrows a {@link RequirementSignature} to a permit / Permit2 token-approval signature.
643
+ * Narrows a {@link RequirementSignature} to an ERC-2612 permit signature.
693
644
  *
694
645
  * @param signature - The signed requirement to test.
695
- * @returns `true` when `signature.action.type` is `"permit"` or `"permit2"`.
646
+ * @returns `true` when `signature.action.type` is `"permit"`.
696
647
  */
697
648
  export declare function isPermitSignature(signature: RequirementSignature): signature is PermitRequirementSignature;
698
649
  /**
@@ -728,7 +679,7 @@ export declare function isAuthorizationSignature(signature: RequirementSignature
728
679
  export declare function isMidnightOfferRootSignature(signature: RequirementSignature): signature is MidnightOfferRootSignature;
729
680
  /** The typed requirement-signature slots a transaction builder consumes, split from a `buildTx` array. */
730
681
  export interface SelectedRequirementSignatures {
731
- /** The single ERC-2612 or Permit2 AllowanceTransfer signature, when present. */
682
+ /** The single ERC-2612 signature, when present. */
732
683
  readonly permit?: PermitRequirementSignature;
733
684
  /** The single Permit2 SignatureTransfer signature, when present. */
734
685
  readonly permit2SignatureTransfer?: Permit2SignatureTransferRequirementSignature;
@@ -748,12 +699,13 @@ export interface SelectedRequirementSignatures {
748
699
  *
749
700
  * @param signatures - The signatures passed to `buildTx`.
750
701
  * @param accepts - Which signature kinds this operation consumes.
751
- * @param accepts.permit - Whether an ERC-2612 or Permit2 AllowanceTransfer signature is consumed.
702
+ * @param accepts.permit - Whether an ERC-2612 signature is consumed.
752
703
  * @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
753
704
  * @param accepts.authorization - Whether a Morpho authorization signature is consumed.
754
705
  * @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
755
706
  * @returns The accepted signature in each typed slot, when present.
756
707
  * @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
708
+ * @throws {UnsupportedRequirementSignatureError} when a signature has an unsupported action type.
757
709
  * @throws {UnexpectedRequirementSignatureError} when a signature of a kind the operation does not consume is present.
758
710
  * @example
759
711
  * ```ts
@@ -1,4 +1,4 @@
1
- import { AmbiguousRequirementSignaturesError, UnexpectedRequirementSignatureError, } from "./error.js";
1
+ import { AmbiguousRequirementSignaturesError, UnexpectedRequirementSignatureError, UnsupportedRequirementSignatureError, } from "./error.js";
2
2
  export function isRequirementApproval(requirement) {
3
3
  return (typeof requirement === "object" &&
4
4
  requirement !== null &&
@@ -32,13 +32,13 @@ export function isRequirementSignature(requirement) {
32
32
  typeof requirement.sign === "function");
33
33
  }
34
34
  /**
35
- * Narrows a {@link RequirementSignature} to a permit / Permit2 token-approval signature.
35
+ * Narrows a {@link RequirementSignature} to an ERC-2612 permit signature.
36
36
  *
37
37
  * @param signature - The signed requirement to test.
38
- * @returns `true` when `signature.action.type` is `"permit"` or `"permit2"`.
38
+ * @returns `true` when `signature.action.type` is `"permit"`.
39
39
  */
40
40
  export function isPermitSignature(signature) {
41
- return (signature.action.type === "permit" || signature.action.type === "permit2");
41
+ return signature.action.type === "permit";
42
42
  }
43
43
  /**
44
44
  * Narrows a {@link RequirementSignature} to a Permit2 SignatureTransfer result.
@@ -88,12 +88,13 @@ export function isMidnightOfferRootSignature(signature) {
88
88
  *
89
89
  * @param signatures - The signatures passed to `buildTx`.
90
90
  * @param accepts - Which signature kinds this operation consumes.
91
- * @param accepts.permit - Whether an ERC-2612 or Permit2 AllowanceTransfer signature is consumed.
91
+ * @param accepts.permit - Whether an ERC-2612 signature is consumed.
92
92
  * @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
93
93
  * @param accepts.authorization - Whether a Morpho authorization signature is consumed.
94
94
  * @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
95
95
  * @returns The accepted signature in each typed slot, when present.
96
96
  * @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
97
+ * @throws {UnsupportedRequirementSignatureError} when a signature has an unsupported action type.
97
98
  * @throws {UnexpectedRequirementSignatureError} when a signature of a kind the operation does not consume is present.
98
99
  * @example
99
100
  * ```ts
@@ -112,6 +113,12 @@ export function selectRequirementSignatures(signatures, accepts) {
112
113
  const permit2Transfers = signatures.filter(isPermit2SignatureTransferSignature);
113
114
  const authorizations = signatures.filter(isAuthorizationSignature);
114
115
  const midnightOfferRoots = signatures.filter(isMidnightOfferRootSignature);
116
+ const unsupported = signatures.find((signature) => !isPermitSignature(signature) &&
117
+ !isPermit2SignatureTransferSignature(signature) &&
118
+ !isAuthorizationSignature(signature) &&
119
+ !isMidnightOfferRootSignature(signature));
120
+ if (unsupported != null)
121
+ throw new UnsupportedRequirementSignatureError(unsupported.action.type);
115
122
  if (!accepts.permit && permits.length > 0)
116
123
  throw new UnexpectedRequirementSignatureError("permit");
117
124
  if (!accepts.permit2SignatureTransfer && permit2Transfers.length > 0)