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

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 (257) hide show
  1. package/MIGRATION-v5-to-v6.md +83 -29
  2. package/README.md +9 -7
  3. package/lib/cjs/abis.d.ts +3 -2844
  4. package/lib/cjs/abis.js +1 -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 +23 -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 +6 -5
  45. package/lib/cjs/actions/vaultV1/inKindRedeem.js +10 -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 +6 -5
  51. package/lib/cjs/actions/vaultV2/inKindRedeem.js +10 -7
  52. package/lib/cjs/augment.d.ts +0 -1
  53. package/lib/cjs/augment.js +0 -1
  54. package/lib/cjs/blue/abis.d.ts +1 -5
  55. package/lib/cjs/blue/abis.js +1 -7
  56. package/lib/cjs/blue/entities.d.ts +2 -8
  57. package/lib/cjs/blue/entities.js +1 -3
  58. package/lib/cjs/blue/fetch.d.ts +1 -3
  59. package/lib/cjs/blue/fetch.js +1 -3
  60. package/lib/cjs/blue/types.d.ts +2 -4
  61. package/lib/cjs/blue/utils.d.ts +1 -3
  62. package/lib/cjs/blue/utils.js +1 -3
  63. package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
  64. package/lib/cjs/client/morphoViemExtension.js +1 -1
  65. package/lib/cjs/constants.d.ts +3 -37
  66. package/lib/cjs/constants.js +1 -39
  67. package/lib/cjs/entities/blue/blue.d.ts +30 -265
  68. package/lib/cjs/entities/blue/blue.js +1 -205
  69. package/lib/cjs/entities/index.d.ts +3 -66
  70. package/lib/cjs/entities/index.js +1 -21
  71. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +9 -2
  72. package/lib/cjs/entities/vaultV1/vaultV1.js +12 -7
  73. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +22 -9
  74. package/lib/cjs/entities/vaultV2/vaultV2.js +28 -15
  75. package/lib/cjs/entities/vaultV2BlueReallocationData.js +4 -21
  76. package/lib/cjs/errors.d.ts +2 -46
  77. package/lib/cjs/errors.js +1 -46
  78. package/lib/cjs/fetch.d.ts +1 -17
  79. package/lib/cjs/fetch.js +1 -17
  80. package/lib/cjs/helpers/constant.d.ts +0 -2
  81. package/lib/cjs/helpers/constant.js +0 -2
  82. package/lib/cjs/helpers/index.d.ts +2 -3
  83. package/lib/cjs/helpers/index.js +1 -9
  84. package/lib/cjs/helpers/slippage.d.ts +1 -103
  85. package/lib/cjs/helpers/slippage.js +0 -150
  86. package/lib/cjs/helpers/utilization.d.ts +12 -10
  87. package/lib/cjs/helpers/utilization.js +27 -12
  88. package/lib/cjs/helpers/validate.d.ts +1 -24
  89. package/lib/cjs/helpers/validate.js +2 -49
  90. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  91. package/lib/cjs/helpers/validateRequirementSpender.js +1 -3
  92. package/lib/cjs/types/action.d.ts +17 -65
  93. package/lib/cjs/types/action.js +11 -4
  94. package/lib/cjs/types/error.d.ts +50 -381
  95. package/lib/cjs/types/error.js +64 -395
  96. package/lib/cjs/types/sharedLiquidity.d.ts +1 -117
  97. package/lib/cjs/types.d.ts +2 -18
  98. package/lib/cjs/utils.d.ts +6 -35
  99. package/lib/cjs/utils.js +2 -36
  100. package/lib/esm/abis.d.ts +3 -2844
  101. package/lib/esm/abis.js +3 -1950
  102. package/lib/esm/actions/blue/borrow.d.ts +3 -2
  103. package/lib/esm/actions/blue/borrow.js +3 -2
  104. package/lib/esm/actions/blue/common.js +1 -9
  105. package/lib/esm/actions/blue/refinance.d.ts +2 -2
  106. package/lib/esm/actions/blue/refinance.js +2 -2
  107. package/lib/esm/actions/blue/repay.d.ts +1 -1
  108. package/lib/esm/actions/blue/repay.js +1 -1
  109. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +2 -2
  110. package/lib/esm/actions/blue/repayWithdrawCollateral.js +2 -2
  111. package/lib/esm/actions/blue/supply.d.ts +2 -2
  112. package/lib/esm/actions/blue/supply.js +2 -2
  113. package/lib/esm/actions/blue/supplyCollateral.d.ts +2 -2
  114. package/lib/esm/actions/blue/supplyCollateral.js +2 -2
  115. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -2
  116. package/lib/esm/actions/blue/supplyCollateralBorrow.js +3 -2
  117. package/lib/esm/actions/blue/withdraw.d.ts +3 -3
  118. package/lib/esm/actions/blue/withdraw.js +3 -3
  119. package/lib/esm/actions/blue/withdrawCollateral.d.ts +2 -2
  120. package/lib/esm/actions/blue/withdrawCollateral.js +2 -2
  121. package/lib/esm/actions/bundles/common.d.ts +6 -2
  122. package/lib/esm/actions/bundles/common.js +24 -6
  123. package/lib/esm/actions/index.d.ts +0 -1
  124. package/lib/esm/actions/index.js +0 -1
  125. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -8
  126. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +12 -17
  127. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
  128. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
  129. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
  130. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +4 -5
  131. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +5 -5
  132. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +6 -11
  133. package/lib/esm/actions/requirements/encode/index.d.ts +0 -1
  134. package/lib/esm/actions/requirements/encode/index.js +0 -1
  135. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +5 -6
  136. package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -6
  137. package/lib/esm/actions/requirements/index.d.ts +0 -1
  138. package/lib/esm/actions/requirements/index.js +0 -1
  139. package/lib/esm/actions/vaultV1/deposit.d.ts +1 -2
  140. package/lib/esm/actions/vaultV1/deposit.js +1 -2
  141. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +6 -5
  142. package/lib/esm/actions/vaultV1/inKindRedeem.js +10 -7
  143. package/lib/esm/actions/vaultV2/deposit.d.ts +1 -2
  144. package/lib/esm/actions/vaultV2/deposit.js +1 -2
  145. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
  146. package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -3
  147. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +6 -5
  148. package/lib/esm/actions/vaultV2/inKindRedeem.js +10 -7
  149. package/lib/esm/augment.d.ts +0 -1
  150. package/lib/esm/augment.js +0 -1
  151. package/lib/esm/blue/abis.d.ts +1 -5
  152. package/lib/esm/blue/abis.js +1 -5
  153. package/lib/esm/blue/entities.d.ts +2 -8
  154. package/lib/esm/blue/entities.js +1 -3
  155. package/lib/esm/blue/fetch.d.ts +1 -3
  156. package/lib/esm/blue/fetch.js +1 -3
  157. package/lib/esm/blue/types.d.ts +2 -4
  158. package/lib/esm/blue/utils.d.ts +1 -3
  159. package/lib/esm/blue/utils.js +1 -3
  160. package/lib/esm/client/morphoViemExtension.d.ts +1 -1
  161. package/lib/esm/client/morphoViemExtension.js +1 -1
  162. package/lib/esm/constants.d.ts +3 -37
  163. package/lib/esm/constants.js +3 -37
  164. package/lib/esm/entities/blue/blue.d.ts +30 -265
  165. package/lib/esm/entities/blue/blue.js +4 -208
  166. package/lib/esm/entities/index.d.ts +3 -66
  167. package/lib/esm/entities/index.js +1 -18
  168. package/lib/esm/entities/vaultV1/vaultV1.d.ts +9 -2
  169. package/lib/esm/entities/vaultV1/vaultV1.js +15 -10
  170. package/lib/esm/entities/vaultV2/vaultV2.d.ts +22 -9
  171. package/lib/esm/entities/vaultV2/vaultV2.js +32 -19
  172. package/lib/esm/entities/vaultV2BlueReallocationData.js +2 -19
  173. package/lib/esm/errors.d.ts +2 -46
  174. package/lib/esm/errors.js +2 -46
  175. package/lib/esm/fetch.d.ts +1 -17
  176. package/lib/esm/fetch.js +1 -17
  177. package/lib/esm/helpers/constant.d.ts +0 -2
  178. package/lib/esm/helpers/constant.js +0 -2
  179. package/lib/esm/helpers/index.d.ts +2 -3
  180. package/lib/esm/helpers/index.js +2 -3
  181. package/lib/esm/helpers/slippage.d.ts +1 -103
  182. package/lib/esm/helpers/slippage.js +1 -147
  183. package/lib/esm/helpers/utilization.d.ts +12 -10
  184. package/lib/esm/helpers/utilization.js +26 -11
  185. package/lib/esm/helpers/validate.d.ts +1 -24
  186. package/lib/esm/helpers/validate.js +2 -48
  187. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  188. package/lib/esm/helpers/validateRequirementSpender.js +1 -3
  189. package/lib/esm/types/action.d.ts +17 -65
  190. package/lib/esm/types/action.js +12 -5
  191. package/lib/esm/types/error.d.ts +50 -381
  192. package/lib/esm/types/error.js +58 -377
  193. package/lib/esm/types/sharedLiquidity.d.ts +1 -117
  194. package/lib/esm/types.d.ts +2 -18
  195. package/lib/esm/utils.d.ts +6 -35
  196. package/lib/esm/utils.js +5 -34
  197. package/package.json +5 -13
  198. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
  199. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -88
  200. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
  201. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -152
  202. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
  203. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -53
  204. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
  205. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -74
  206. package/lib/cjs/actions/requirements/generalAdapter/index.d.ts +0 -3
  207. package/lib/cjs/actions/requirements/generalAdapter/index.js +0 -19
  208. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
  209. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.js +0 -48
  210. package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +0 -58
  211. package/lib/cjs/actions/signatures/getTokenRequirementActions.js +0 -119
  212. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -50
  213. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -45
  214. package/lib/cjs/actions/signatures/index.d.ts +0 -3
  215. package/lib/cjs/actions/signatures/index.js +0 -19
  216. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -11
  217. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.js +0 -8
  218. package/lib/cjs/bundler/actions.d.ts +0 -797
  219. package/lib/cjs/bundler/actions.js +0 -1371
  220. package/lib/cjs/bundler/index.d.ts +0 -2
  221. package/lib/cjs/bundler/index.js +0 -18
  222. package/lib/cjs/bundler/types.d.ts +0 -235
  223. package/lib/cjs/bundler/types.js +0 -2
  224. package/lib/cjs/entities/vaultV1ReallocationData.d.ts +0 -332
  225. package/lib/cjs/entities/vaultV1ReallocationData.js +0 -557
  226. package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +0 -80
  227. package/lib/cjs/helpers/computeVaultV1Reallocations.js +0 -245
  228. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
  229. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -84
  230. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
  231. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -148
  232. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
  233. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -49
  234. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
  235. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -70
  236. package/lib/esm/actions/requirements/generalAdapter/index.d.ts +0 -3
  237. package/lib/esm/actions/requirements/generalAdapter/index.js +0 -3
  238. package/lib/esm/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
  239. package/lib/esm/actions/signatures/getBlueAuthorizationAction.js +0 -44
  240. package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +0 -58
  241. package/lib/esm/actions/signatures/getTokenRequirementActions.js +0 -115
  242. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -50
  243. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -41
  244. package/lib/esm/actions/signatures/index.d.ts +0 -3
  245. package/lib/esm/actions/signatures/index.js +0 -3
  246. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -11
  247. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +0 -7
  248. package/lib/esm/bundler/actions.d.ts +0 -797
  249. package/lib/esm/bundler/actions.js +0 -1368
  250. package/lib/esm/bundler/index.d.ts +0 -2
  251. package/lib/esm/bundler/index.js +0 -2
  252. package/lib/esm/bundler/types.d.ts +0 -235
  253. package/lib/esm/bundler/types.js +0 -1
  254. package/lib/esm/entities/vaultV1ReallocationData.d.ts +0 -332
  255. package/lib/esm/entities/vaultV1ReallocationData.js +0 -559
  256. package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +0 -80
  257. package/lib/esm/helpers/computeVaultV1Reallocations.js +0 -241
@@ -33,7 +33,6 @@ class MorphoVaultV2 {
33
33
  }
34
34
  return (0, blue_sdk_viem_1.fetchAccrualVaultV2)(this.vault, this.client.viemClient, {
35
35
  ...parameters,
36
- chainId: this.chainId,
37
36
  deployless: this.client.options.supportDeployless,
38
37
  });
39
38
  }
@@ -369,8 +368,7 @@ class MorphoVaultV2 {
369
368
  remaining -= chunk;
370
369
  }
371
370
  const vaultExitBundlesV1 = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultExitBundlesV1");
372
- const addresses = (0, blue_sdk_1.getChainAddresses)(this.chainId);
373
- const blue = addresses.blue ?? addresses.morpho;
371
+ const blue = (0, morpho_ts_1.getChainAddress)(this.chainId, "blue");
374
372
  return {
375
373
  getRequirements: async () => {
376
374
  const requirementsTimestamp = morpho_ts_1.Time.timestamp();
@@ -413,9 +411,14 @@ class MorphoVaultV2 {
413
411
  required: peak,
414
412
  });
415
413
  }
416
- if (allowance >= requiredShareAllowance)
414
+ // In-kind withdrawals carry no onchain share cap, so the allowance itself is the cap. A
415
+ // larger leftover allowance would let a share-price loss burn past `requiredShareAllowance`.
416
+ if (allowance === requiredShareAllowance)
417
417
  return [];
418
- if (this.client.options.supportSignature) {
418
+ // A lowering permit can be skipped after its nonce is consumed, so oversized allowances
419
+ // must be reset with an onchain approval.
420
+ if (allowance < requiredShareAllowance &&
421
+ this.client.options.supportSignature) {
419
422
  return [
420
423
  (0, index_js_1.encodeVaultSharesPermit)({
421
424
  vault: vaultData,
@@ -439,8 +442,10 @@ class MorphoVaultV2 {
439
442
  ];
440
443
  },
441
444
  buildTx: (signatures) => {
442
- const { permit } = (0, index_js_3.selectRequirementSignatures)(signatures, {
443
- permit: true,
445
+ const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signatures, {
446
+ spender: vaultExitBundlesV1,
447
+ amount: requiredShareAllowance,
448
+ deadline,
444
449
  });
445
450
  return (0, index_js_1.vaultV2InKindRedeem)({
446
451
  vault: { chainId: this.chainId, address: this.vault },
@@ -580,6 +585,21 @@ class MorphoVaultV2 {
580
585
  }
581
586
  // sharesBurntNow ≥ minSharesBurntNow ≥ minSharesBurntProjected > feeSharesProjected ≥ feeSharesNow
582
587
  const netSharesBurntNow = sharesBurntNow - feeSharesNow;
588
+ if (minSharePriceE27Override != null) {
589
+ // The maximum-slippage threshold only bounds the override; unlike the transaction floor it
590
+ // may round to zero, in which case every positive override is acceptable.
591
+ const minAllowedSharePriceE27 = (0, morpho_ts_1._try)(() => (0, index_js_2.computeMinForceWithdrawSharePrice)({
592
+ withdrawnAssets: plan.withdrawnAssets,
593
+ sharesBurnt: netSharesBurntNow,
594
+ slippageTolerance: index_js_2.MAX_SLIPPAGE_TOLERANCE,
595
+ }), index_js_3.VaultV2ForceWithdrawZeroSharePriceError) ?? 1n;
596
+ if (minSharePriceE27Override < minAllowedSharePriceE27) {
597
+ throw new index_js_3.VaultV2ForceWithdrawSharePriceBelowFloorError({
598
+ minSharePriceE27: minSharePriceE27Override,
599
+ floorE27: minAllowedSharePriceE27,
600
+ });
601
+ }
602
+ }
583
603
  const minSharePriceE27 = minSharePriceE27Override ??
584
604
  (0, index_js_2.computeMinForceWithdrawSharePrice)({
585
605
  withdrawnAssets: plan.withdrawnAssets,
@@ -590,17 +610,10 @@ class MorphoVaultV2 {
590
610
  // lowering a lower bound weakens it, so any vault whose share price grew past that would be left
591
611
  // with no real protection. Its two sibling `computeMin*SharePrice` helpers cap nothing either —
592
612
  // only the `computeMax*` ones do, where capping relaxes an upper bound and is safe.
593
- //
594
- // It still has to fit the ABI slot though. Defense-in-depth rather than a reachable input error:
595
- // with `exitAssets` bounded above, the derived floor only exceeds `uint256` on a vault whose
596
- // share price passed ~1e50 assets/share, which no fixture here can construct.
597
613
  (0, validate_js_1.validateUint256Field)("minSharePriceE27", minSharePriceE27);
598
614
  // VaultExitBundlesV1's burn bound includes fee shares minted by the first withdrawal. Add the
599
615
  // projected fee shares to the price-floor ceiling so the approval covers that mint.
600
- // Saturated at `maxUint256`: a tiny accepted floor scales this above the ABI slot, and the
601
- // approval encoder clamps what it emits — so an uncapped requirement would sit permanently above
602
- // any allowance the user can actually grant and `getRequirements()` would return the same
603
- // approval forever. No account can hold or burn more shares than that anyway.
616
+ // Saturated at `maxUint256` as an ABI-slot guard for an otherwise valid extreme share burn.
604
617
  const requiredShareAllowance = blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.mulDivUp(exitAssets, blue_sdk_1.MathLib.RAY, minSharePriceE27) +
605
618
  feeSharesProjected, viem_1.maxUint256);
606
619
  const vaultExitBundlesV1 = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultExitBundlesV1");
@@ -5,6 +5,7 @@ const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
6
  const viem_1 = require("viem");
7
7
  const constant_js_1 = require("../helpers/constant.js");
8
+ const utilization_js_1 = require("../helpers/utilization.js");
8
9
  const index_js_1 = require("../types/index.js");
9
10
  const MAX_SHARED_CAP_SEARCH_STEPS = 1024n;
10
11
  /** Creates isolated transaction-scoped state for one simulation. @internal */
@@ -44,18 +45,6 @@ const getAdapterIds = (cache, adapter, market) => {
44
45
  cache.set(key, ids);
45
46
  return ids;
46
47
  };
47
- const resolveMaxWithdrawalUtilization = (value) => {
48
- const utilization = value ?? constant_js_1.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION;
49
- if (utilization < 0n)
50
- throw new index_js_1.NegativeInputError("maxWithdrawalUtilization", utilization);
51
- if (utilization > blue_sdk_1.MathLib.WAD)
52
- throw new index_js_1.InputExceedsMaxError({
53
- field: "maxWithdrawalUtilization",
54
- value: utilization,
55
- max: blue_sdk_1.MathLib.WAD,
56
- });
57
- return utilization;
58
- };
59
48
  const resolveMaxPenalty = (value) => {
60
49
  const penalty = value ?? constant_js_1.DEFAULT_MAX_REALLOCATION_PENALTY;
61
50
  if (penalty < 0n)
@@ -75,16 +64,10 @@ const cloneAccrualVault = (vault, markets) => new blue_sdk_1.AccrualVault({
75
64
  pendingTimelock: { ...vault.pendingTimelock },
76
65
  pendingGuardian: { ...vault.pendingGuardian },
77
66
  supplyQueue: [...vault.supplyQueue],
78
- publicAllocatorConfig: vault.publicAllocatorConfig == null
79
- ? undefined
80
- : { ...vault.publicAllocatorConfig },
81
67
  }, [...vault.allocations.values()].map(({ config, position }) => ({
82
68
  config: {
83
69
  ...config,
84
70
  pendingCap: { ...config.pendingCap },
85
- publicAllocatorConfig: config.publicAllocatorConfig == null
86
- ? undefined
87
- : { ...config.publicAllocatorConfig },
88
71
  },
89
72
  position: clonePosition(position, markets),
90
73
  })));
@@ -634,7 +617,7 @@ class VaultV2BlueReallocationData {
634
617
  computeVaultV2BlueReallocations(marketId, options = {}) {
635
618
  if (options.enabled === false)
636
619
  return { reallocations: [], data: this };
637
- const maxWithdrawalUtilization = resolveMaxWithdrawalUtilization(options.maxWithdrawalUtilization);
620
+ const maxWithdrawalUtilization = (0, utilization_js_1.resolveMaxWithdrawalUtilization)(options.maxWithdrawalUtilization);
638
621
  const maxPenalty = resolveMaxPenalty(options.maxPenalty);
639
622
  const resolvedOptions = { ...options, maxPenalty };
640
623
  const operation = options.operation;
@@ -1025,7 +1008,7 @@ class VaultV2BlueReallocationData {
1025
1008
  .computeVaultV2BlueReallocationsAtUtilizationInPlace({
1026
1009
  context: createSimulationContext(),
1027
1010
  marketId,
1028
- maxWithdrawalUtilization: resolveMaxWithdrawalUtilization(options?.maxWithdrawalUtilization),
1011
+ maxWithdrawalUtilization: (0, utilization_js_1.resolveMaxWithdrawalUtilization)(options?.maxWithdrawalUtilization),
1029
1012
  options: { ...options, maxPenalty },
1030
1013
  })
1031
1014
  .reallocations.reduce((total, { assets }) => total + assets, 0n);
@@ -1084,7 +1067,7 @@ class VaultV2BlueReallocationData {
1084
1067
  .computeVaultV2BlueReallocationsAtUtilizationInPlace({
1085
1068
  context: createSimulationContext(),
1086
1069
  marketId,
1087
- maxWithdrawalUtilization: resolveMaxWithdrawalUtilization(options?.maxWithdrawalUtilization),
1070
+ maxWithdrawalUtilization: (0, utilization_js_1.resolveMaxWithdrawalUtilization)(options?.maxWithdrawalUtilization),
1088
1071
  options: {
1089
1072
  ...options,
1090
1073
  timestamp,
@@ -1,49 +1,5 @@
1
- export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError,
2
- /** @deprecated Use InvalidBlueMarketParamsError or the raw protocol subpath. */
3
- InvalidMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError,
4
- /** @deprecated Use UnknownBlueDataError or the raw protocol subpath. */
5
- UnknownDataError, UnknownFactory as UnknownBlueFactory,
6
- /** @deprecated Use UnknownBlueFactory or the raw protocol subpath. */
7
- UnknownFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError,
8
- /** @deprecated Use UnknownBlueMarketParamsError or the raw protocol subpath. */
9
- UnknownMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory,
10
- /** @deprecated Use UnknownBlueOfFactory or the raw protocol subpath. */
11
- UnknownOfFactory, UnknownTokenError as UnknownBlueTokenError,
12
- /** @deprecated Use UnknownBlueTokenError or the raw protocol subpath. */
13
- UnknownTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError,
14
- /** @deprecated Use UnknownBlueTokenPriceError or the raw protocol subpath. */
15
- UnknownTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError,
16
- /** @deprecated Use UnknownBlueVaultConfigError or the raw protocol subpath. */
17
- UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError, UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError,
18
- /** @deprecated Use UnsupportedBluePreLiquidationParamsError or the raw protocol subpath. */
19
- UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError,
20
- /** @deprecated Use UnsupportedBlueVaultV2AdapterError or the raw protocol subpath. */
21
- UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
1
+ export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError, UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
22
2
  export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
23
- export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError,
24
- /** @deprecated Use InvalidMidnightOfferGroupError or the raw protocol subpath. */
25
- InvalidOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError,
26
- /** @deprecated Use InvalidMidnightOfferParameterError or the raw protocol subpath. */
27
- InvalidOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError,
28
- /** @deprecated Use InvalidMidnightPositionAccrualStateError or the raw protocol subpath. */
29
- InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError,
30
- /** @deprecated Use InvalidMidnightPositionAccrualTimestampError or the raw protocol subpath. */
31
- InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError,
32
- /** @deprecated Use InvalidMidnightPositionLossFactorError or the raw protocol subpath. */
33
- InvalidPositionLossFactorError, InvalidTickSpacingError as InvalidMidnightTickSpacingError,
34
- /** @deprecated Use InvalidMidnightTickSpacingError or the raw protocol subpath. */
35
- InvalidTickSpacingError, InvalidTreeError as InvalidMidnightTreeError,
36
- /** @deprecated Use InvalidMidnightTreeError or the raw protocol subpath. */
37
- InvalidTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError,
38
- /** @deprecated Use InvalidMidnightTreeHeightError or the raw protocol subpath. */
39
- InvalidTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError,
40
- /** @deprecated Use MidnightPriceGreaterThanOneError or the raw protocol subpath. */
41
- PriceGreaterThanOneError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError,
42
- /** @deprecated Use MidnightSettlementFeeExceedsPriceError or the raw protocol subpath. */
43
- SettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError,
44
- /** @deprecated Use MidnightTickOutOfRangeError or the raw protocol subpath. */
45
- TickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError,
46
- /** @deprecated Use UnknownMidnightCollateralIndexError or the raw protocol subpath. */
47
- UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
3
+ export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
48
4
  export type { ErrorClass } from "@morpho-org/morpho-ts";
49
5
  export { _try, DivisionByZeroError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
package/lib/cjs/errors.js CHANGED
@@ -1,44 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidTreeError = exports.InvalidMidnightTreeError = exports.InvalidTickSpacingError = exports.InvalidMidnightTickSpacingError = exports.InvalidPositionLossFactorError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidPositionAccrualStateError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidOfferParameterError = exports.InvalidMidnightOfferParameterError = exports.InvalidOfferGroupError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedVaultV2AdapterError = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownBlueVaultConfigError = exports.UnknownTokenPriceError = exports.UnknownBlueTokenPriceError = exports.UnknownTokenError = exports.UnknownBlueTokenError = exports.UnknownOfFactory = exports.UnknownBlueOfFactory = exports.UnknownMarketParamsError = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownFactory = exports.UnknownBlueFactory = exports.UnknownDataError = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidMarketParamsError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
4
- exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidBitLengthError = exports.DivisionByZeroError = exports._try = exports.UnknownCollateralIndexError = exports.UnknownMidnightCollateralIndexError = exports.TickOutOfRangeError = exports.MidnightTickOutOfRangeError = exports.SettlementFeeExceedsPriceError = exports.MidnightSettlementFeeExceedsPriceError = exports.PriceGreaterThanOneError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidTreeHeightError = exports.InvalidMidnightTreeHeightError = void 0;
3
+ exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidBitLengthError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidMidnightOfferParameterError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownBlueVaultConfigError = exports.UnknownBlueTokenPriceError = exports.UnknownBlueTokenError = exports.UnknownBlueOfFactory = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownBlueFactory = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
5
4
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
6
5
  Object.defineProperty(exports, "BlueErrors", { enumerable: true, get: function () { return blue_sdk_1.BlueErrors; } });
7
6
  Object.defineProperty(exports, "IncompleteChainRegistryError", { enumerable: true, get: function () { return blue_sdk_1.IncompleteChainRegistryError; } });
8
7
  Object.defineProperty(exports, "InvalidBlueMarketParamsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidMarketParamsError; } });
9
- /** @deprecated Use InvalidBlueMarketParamsError or the raw protocol subpath. */
10
- Object.defineProperty(exports, "InvalidMarketParamsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidMarketParamsError; } });
11
8
  Object.defineProperty(exports, "UnknownAddressError", { enumerable: true, get: function () { return blue_sdk_1.UnknownAddressError; } });
12
9
  Object.defineProperty(exports, "UnknownBlueDataError", { enumerable: true, get: function () { return blue_sdk_1.UnknownDataError; } });
13
- /** @deprecated Use UnknownBlueDataError or the raw protocol subpath. */
14
- Object.defineProperty(exports, "UnknownDataError", { enumerable: true, get: function () { return blue_sdk_1.UnknownDataError; } });
15
10
  Object.defineProperty(exports, "UnknownBlueFactory", { enumerable: true, get: function () { return blue_sdk_1.UnknownFactory; } });
16
- /** @deprecated Use UnknownBlueFactory or the raw protocol subpath. */
17
- Object.defineProperty(exports, "UnknownFactory", { enumerable: true, get: function () { return blue_sdk_1.UnknownFactory; } });
18
11
  Object.defineProperty(exports, "UnknownBlueMarketAllocationError", { enumerable: true, get: function () { return blue_sdk_1.UnknownMarketAllocationError; } });
19
12
  Object.defineProperty(exports, "UnknownBlueMarketParamsError", { enumerable: true, get: function () { return blue_sdk_1.UnknownMarketParamsError; } });
20
- /** @deprecated Use UnknownBlueMarketParamsError or the raw protocol subpath. */
21
- Object.defineProperty(exports, "UnknownMarketParamsError", { enumerable: true, get: function () { return blue_sdk_1.UnknownMarketParamsError; } });
22
13
  Object.defineProperty(exports, "UnknownBlueOfFactory", { enumerable: true, get: function () { return blue_sdk_1.UnknownOfFactory; } });
23
- /** @deprecated Use UnknownBlueOfFactory or the raw protocol subpath. */
24
- Object.defineProperty(exports, "UnknownOfFactory", { enumerable: true, get: function () { return blue_sdk_1.UnknownOfFactory; } });
25
14
  Object.defineProperty(exports, "UnknownBlueTokenError", { enumerable: true, get: function () { return blue_sdk_1.UnknownTokenError; } });
26
- /** @deprecated Use UnknownBlueTokenError or the raw protocol subpath. */
27
- Object.defineProperty(exports, "UnknownTokenError", { enumerable: true, get: function () { return blue_sdk_1.UnknownTokenError; } });
28
15
  Object.defineProperty(exports, "UnknownBlueTokenPriceError", { enumerable: true, get: function () { return blue_sdk_1.UnknownTokenPriceError; } });
29
- /** @deprecated Use UnknownBlueTokenPriceError or the raw protocol subpath. */
30
- Object.defineProperty(exports, "UnknownTokenPriceError", { enumerable: true, get: function () { return blue_sdk_1.UnknownTokenPriceError; } });
31
16
  Object.defineProperty(exports, "UnknownBlueVaultConfigError", { enumerable: true, get: function () { return blue_sdk_1.UnknownVaultConfigError; } });
32
- /** @deprecated Use UnknownBlueVaultConfigError or the raw protocol subpath. */
33
- Object.defineProperty(exports, "UnknownVaultConfigError", { enumerable: true, get: function () { return blue_sdk_1.UnknownVaultConfigError; } });
34
17
  Object.defineProperty(exports, "UnsupportedChainIdError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedChainIdError; } });
35
18
  Object.defineProperty(exports, "UnsupportedBlueMarketIrmError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedMarketIrmError; } });
36
19
  Object.defineProperty(exports, "UnsupportedBluePreLiquidationParamsError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedPreLiquidationParamsError; } });
37
- /** @deprecated Use UnsupportedBluePreLiquidationParamsError or the raw protocol subpath. */
38
- Object.defineProperty(exports, "UnsupportedPreLiquidationParamsError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedPreLiquidationParamsError; } });
39
20
  Object.defineProperty(exports, "UnsupportedBlueVaultV2AdapterError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedVaultV2AdapterError; } });
40
- /** @deprecated Use UnsupportedBlueVaultV2AdapterError or the raw protocol subpath. */
41
- Object.defineProperty(exports, "UnsupportedVaultV2AdapterError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedVaultV2AdapterError; } });
42
21
  Object.defineProperty(exports, "VaultV2Errors", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Errors; } });
43
22
  var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
44
23
  Object.defineProperty(exports, "getBlueUnsupportedVaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.getUnsupportedVaultV2Adapter; } });
@@ -52,45 +31,21 @@ Object.defineProperty(exports, "InvalidMidnightEcrecoverSignatureVError", { enum
52
31
  Object.defineProperty(exports, "InvalidMidnightMarketParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMarketParameterError; } });
53
32
  Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
54
33
  Object.defineProperty(exports, "InvalidMidnightOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
55
- /** @deprecated Use InvalidMidnightOfferGroupError or the raw protocol subpath. */
56
- Object.defineProperty(exports, "InvalidOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
57
34
  Object.defineProperty(exports, "InvalidMidnightOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
58
- /** @deprecated Use InvalidMidnightOfferParameterError or the raw protocol subpath. */
59
- Object.defineProperty(exports, "InvalidOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
60
35
  Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
61
- /** @deprecated Use InvalidMidnightPositionAccrualStateError or the raw protocol subpath. */
62
- Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
63
36
  Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
64
- /** @deprecated Use InvalidMidnightPositionAccrualTimestampError or the raw protocol subpath. */
65
- Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
66
37
  Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
67
- /** @deprecated Use InvalidMidnightPositionLossFactorError or the raw protocol subpath. */
68
- Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
69
38
  Object.defineProperty(exports, "InvalidMidnightTickSpacingError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidTickSpacingError; } });
70
- /** @deprecated Use InvalidMidnightTickSpacingError or the raw protocol subpath. */
71
- Object.defineProperty(exports, "InvalidTickSpacingError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidTickSpacingError; } });
72
39
  Object.defineProperty(exports, "InvalidMidnightTreeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidTreeError; } });
73
- /** @deprecated Use InvalidMidnightTreeError or the raw protocol subpath. */
74
- Object.defineProperty(exports, "InvalidTreeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidTreeError; } });
75
40
  Object.defineProperty(exports, "InvalidMidnightTreeHeightError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidTreeHeightError; } });
76
- /** @deprecated Use InvalidMidnightTreeHeightError or the raw protocol subpath. */
77
- Object.defineProperty(exports, "InvalidTreeHeightError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidTreeHeightError; } });
78
41
  Object.defineProperty(exports, "InvalidMidnightTypedDataSignatureError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidTypedDataSignatureError; } });
79
42
  Object.defineProperty(exports, "MidnightApiError", { enumerable: true, get: function () { return midnight_sdk_1.MidnightApiError; } });
80
43
  Object.defineProperty(exports, "MidnightMempoolValidationError", { enumerable: true, get: function () { return midnight_sdk_1.MidnightMempoolValidationError; } });
81
44
  Object.defineProperty(exports, "MidnightPayloadDecodeError", { enumerable: true, get: function () { return midnight_sdk_1.PayloadDecodeError; } });
82
45
  Object.defineProperty(exports, "MidnightPriceGreaterThanOneError", { enumerable: true, get: function () { return midnight_sdk_1.PriceGreaterThanOneError; } });
83
- /** @deprecated Use MidnightPriceGreaterThanOneError or the raw protocol subpath. */
84
- Object.defineProperty(exports, "PriceGreaterThanOneError", { enumerable: true, get: function () { return midnight_sdk_1.PriceGreaterThanOneError; } });
85
46
  Object.defineProperty(exports, "MidnightSettlementFeeExceedsPriceError", { enumerable: true, get: function () { return midnight_sdk_1.SettlementFeeExceedsPriceError; } });
86
- /** @deprecated Use MidnightSettlementFeeExceedsPriceError or the raw protocol subpath. */
87
- Object.defineProperty(exports, "SettlementFeeExceedsPriceError", { enumerable: true, get: function () { return midnight_sdk_1.SettlementFeeExceedsPriceError; } });
88
47
  Object.defineProperty(exports, "MidnightTickOutOfRangeError", { enumerable: true, get: function () { return midnight_sdk_1.TickOutOfRangeError; } });
89
- /** @deprecated Use MidnightTickOutOfRangeError or the raw protocol subpath. */
90
- Object.defineProperty(exports, "TickOutOfRangeError", { enumerable: true, get: function () { return midnight_sdk_1.TickOutOfRangeError; } });
91
48
  Object.defineProperty(exports, "UnknownMidnightCollateralIndexError", { enumerable: true, get: function () { return midnight_sdk_1.UnknownCollateralIndexError; } });
92
- /** @deprecated Use UnknownMidnightCollateralIndexError or the raw protocol subpath. */
93
- Object.defineProperty(exports, "UnknownCollateralIndexError", { enumerable: true, get: function () { return midnight_sdk_1.UnknownCollateralIndexError; } });
94
49
  var morpho_ts_1 = require("@morpho-org/morpho-ts");
95
50
  Object.defineProperty(exports, "_try", { enumerable: true, get: function () { return morpho_ts_1._try; } });
96
51
  Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return morpho_ts_1.DivisionByZeroError; } });
@@ -1,18 +1,2 @@
1
- export { fetchAccrualPosition as fetchBlueAccrualPosition,
2
- /** @deprecated Use `fetchBlueAccrualPosition` or the raw `/blue/fetch` subpath. */
3
- fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket,
4
- /** @deprecated Use `fetchBlueMarket` or the raw `/blue/fetch` subpath. */
5
- fetchMarket, fetchMarketParams as fetchBlueMarketParams,
6
- /** @deprecated Use `fetchBlueMarketParams` or the raw `/blue/fetch` subpath. */
7
- fetchMarketParams, fetchPosition as fetchBluePosition,
8
- /** @deprecated Use `fetchBluePosition` or the raw `/blue/fetch` subpath. */
9
- fetchPosition, fetchPreLiquidationParams as fetchBluePreLiquidationParams,
10
- /** @deprecated Use `fetchBluePreLiquidationParams` or the raw `/blue/fetch` subpath. */
11
- fetchPreLiquidationParams, fetchPreLiquidationPosition as fetchBluePreLiquidationPosition,
12
- /** @deprecated Use `fetchBluePreLiquidationPosition` or the raw `/blue/fetch` subpath. */
13
- fetchPreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser,
14
- /** @deprecated Use `fetchBlueUser` or the raw `/blue/fetch` subpath. */
15
- fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig,
16
- /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `fetchVaultV2BlueMarketPublicAllocatorConfig`. */
17
- fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
1
+ export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition, fetchPreLiquidationParams as fetchBluePreLiquidationParams, fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
18
2
  export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
package/lib/cjs/fetch.js CHANGED
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchMidnightRatifierInfo = exports.fetchMidnightPosition = exports.fetchMidnightMarketParams = exports.fetchMidnightMarket = exports.fetchMidnightAccrualPosition = exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.fetchVaultV2BluePublicAllocatorData = exports.fetchVaultV2BluePublicAllocatorConfig = exports.fetchVaultV2BlueMarketPublicAllocatorConfig = exports.fetchVaultV2Adapter = exports.fetchVaultV2 = exports.fetchVaultUser = exports.fetchVaultMarketPublicAllocatorConfig = exports.fetchVaultMarketConfig = exports.fetchVaultMarketAllocation = exports.fetchVaultConfig = exports.fetchVault = exports.fetchUser = exports.fetchBlueUser = exports.fetchToken = exports.fetchPreLiquidationPosition = exports.fetchBluePreLiquidationPosition = exports.fetchPreLiquidationParams = exports.fetchBluePreLiquidationParams = exports.fetchPosition = exports.fetchBluePosition = exports.fetchMarketParams = exports.fetchBlueMarketParams = exports.fetchMarket = exports.fetchBlueMarket = exports.fetchHolding = exports.fetchAccrualVaultV2MorphoVaultV1Adapter = exports.fetchAccrualVaultV2MorphoMarketV1AdapterV2 = exports.fetchAccrualVaultV2MorphoMarketV1Adapter = exports.fetchAccrualVaultV2Adapter = exports.fetchAccrualVaultV2 = exports.fetchAccrualVault = exports.fetchAccrualPosition = exports.fetchBlueAccrualPosition = void 0;
3
+ exports.fetchMidnightRatifierInfo = exports.fetchMidnightPosition = exports.fetchMidnightMarketParams = exports.fetchMidnightMarket = exports.fetchMidnightAccrualPosition = exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.fetchVaultV2BluePublicAllocatorData = exports.fetchVaultV2BluePublicAllocatorConfig = exports.fetchVaultV2BlueMarketPublicAllocatorConfig = exports.fetchVaultV2Adapter = exports.fetchVaultV2 = exports.fetchVaultUser = exports.fetchVaultMarketConfig = exports.fetchVaultMarketAllocation = exports.fetchVaultConfig = exports.fetchVault = exports.fetchBlueUser = exports.fetchToken = exports.fetchBluePreLiquidationPosition = exports.fetchBluePreLiquidationParams = exports.fetchBluePosition = exports.fetchBlueMarketParams = exports.fetchBlueMarket = exports.fetchHolding = exports.fetchAccrualVaultV2MorphoVaultV1Adapter = exports.fetchAccrualVaultV2MorphoMarketV1AdapterV2 = exports.fetchAccrualVaultV2MorphoMarketV1Adapter = exports.fetchAccrualVaultV2Adapter = exports.fetchAccrualVaultV2 = exports.fetchAccrualVault = exports.fetchBlueAccrualPosition = void 0;
4
4
  var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
5
5
  Object.defineProperty(exports, "fetchBlueAccrualPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualPosition; } });
6
- /** @deprecated Use `fetchBlueAccrualPosition` or the raw `/blue/fetch` subpath. */
7
- Object.defineProperty(exports, "fetchAccrualPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualPosition; } });
8
6
  Object.defineProperty(exports, "fetchAccrualVault", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVault; } });
9
7
  Object.defineProperty(exports, "fetchAccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2; } });
10
8
  Object.defineProperty(exports, "fetchAccrualVaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2Adapter; } });
@@ -13,30 +11,16 @@ Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1AdapterV2", { e
13
11
  Object.defineProperty(exports, "fetchAccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoVaultV1Adapter; } });
14
12
  Object.defineProperty(exports, "fetchHolding", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchHolding; } });
15
13
  Object.defineProperty(exports, "fetchBlueMarket", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchMarket; } });
16
- /** @deprecated Use `fetchBlueMarket` or the raw `/blue/fetch` subpath. */
17
- Object.defineProperty(exports, "fetchMarket", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchMarket; } });
18
14
  Object.defineProperty(exports, "fetchBlueMarketParams", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchMarketParams; } });
19
- /** @deprecated Use `fetchBlueMarketParams` or the raw `/blue/fetch` subpath. */
20
- Object.defineProperty(exports, "fetchMarketParams", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchMarketParams; } });
21
15
  Object.defineProperty(exports, "fetchBluePosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchPosition; } });
22
- /** @deprecated Use `fetchBluePosition` or the raw `/blue/fetch` subpath. */
23
- Object.defineProperty(exports, "fetchPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchPosition; } });
24
16
  Object.defineProperty(exports, "fetchBluePreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchPreLiquidationParams; } });
25
- /** @deprecated Use `fetchBluePreLiquidationParams` or the raw `/blue/fetch` subpath. */
26
- Object.defineProperty(exports, "fetchPreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchPreLiquidationParams; } });
27
17
  Object.defineProperty(exports, "fetchBluePreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchPreLiquidationPosition; } });
28
- /** @deprecated Use `fetchBluePreLiquidationPosition` or the raw `/blue/fetch` subpath. */
29
- Object.defineProperty(exports, "fetchPreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchPreLiquidationPosition; } });
30
18
  Object.defineProperty(exports, "fetchToken", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchToken; } });
31
19
  Object.defineProperty(exports, "fetchBlueUser", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchUser; } });
32
- /** @deprecated Use `fetchBlueUser` or the raw `/blue/fetch` subpath. */
33
- Object.defineProperty(exports, "fetchUser", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchUser; } });
34
20
  Object.defineProperty(exports, "fetchVault", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVault; } });
35
21
  Object.defineProperty(exports, "fetchVaultConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultConfig; } });
36
22
  Object.defineProperty(exports, "fetchVaultMarketAllocation", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultMarketAllocation; } });
37
23
  Object.defineProperty(exports, "fetchVaultMarketConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultMarketConfig; } });
38
- /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `fetchVaultV2BlueMarketPublicAllocatorConfig`. */
39
- Object.defineProperty(exports, "fetchVaultMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultMarketPublicAllocatorConfig; } });
40
24
  Object.defineProperty(exports, "fetchVaultUser", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultUser; } });
41
25
  Object.defineProperty(exports, "fetchVaultV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2; } });
42
26
  Object.defineProperty(exports, "fetchVaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2Adapter; } });
@@ -17,8 +17,6 @@ export declare const DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = 900000000000000000n
17
17
  /**
18
18
  * The default target utilization above which shared liquidity reallocations are
19
19
  * triggered (and the level the target market is brought back to), scaled by WAD.
20
- * Still overridable through the deprecated `supplyTargetUtilization` /
21
- * `defaultSupplyTargetUtilization` options until the next major.
22
20
  */
23
21
  export declare const DEFAULT_SUPPLY_TARGET_UTILIZATION = 900000000000000000n;
24
22
  /**
@@ -21,8 +21,6 @@ exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = 900000000000000000n;
21
21
  /**
22
22
  * The default target utilization above which shared liquidity reallocations are
23
23
  * triggered (and the level the target market is brought back to), scaled by WAD.
24
- * Still overridable through the deprecated `supplyTargetUtilization` /
25
- * `defaultSupplyTargetUtilization` options until the next major.
26
24
  */
27
25
  exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = 900000000000000000n;
28
26
  /**
@@ -1,12 +1,11 @@
1
- export { computeReallocations, computeVaultV1Reallocations, } from "./computeVaultV1Reallocations.js";
2
1
  export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./constant.js";
3
2
  export { addTransactionMetadata } from "./metadata.js";
4
3
  export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./previewVaultV2ForceWithdraw.js";
5
4
  export { type PreviewVaultV2InKindRedeemParams, previewVaultV2InKindRedeem, type VaultV2InKindRedeemMarketPreview, } from "./previewVaultV2InKindRedeem.js";
6
5
  export { grossFromNetAssets } from "./referralFee.js";
7
6
  export { signAndVerifyTypedData } from "./signAndVerifyTypedData.js";
8
- export { computeMaxRepaySharePrice, computeMaxSupplySharePrice, computeMinBorrowSharePrice, computeMinForceWithdrawSharePrice, computeMinWithdrawSharePrice, computeVaultMaxShareAllowance, computeVaultMaxSharePrice, } from "./slippage.js";
9
- export { validateAccrualPosition, validateChainId, validateMidnightMarketChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateReallocations, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, validateWithdrawAmount, validateWithdrawShares, } from "./validate.js";
7
+ export { computeMinForceWithdrawSharePrice, computeVaultMaxShareAllowance, computeVaultMaxSharePrice, } from "./slippage.js";
8
+ export { validateAccrualPosition, validateChainId, validateMidnightMarketChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, validateWithdrawAmount, validateWithdrawShares, } from "./validate.js";
10
9
  export { validateOfferSides } from "./validateOfferSides.js";
11
10
  export { type RequirementSpenderKey, validateRequirementSpender, } from "./validateRequirementSpender.js";
12
11
  export { computeVaultV2ForceWithdrawFeeSharesMinted, computeVaultV2ForceWithdrawMinSharesBurnt, computeVaultV2ForceWithdrawPlan, computeVaultV2ForceWithdrawSharesBurnt, resolveVaultV2ForceWithdrawEligibility, type VaultV2ForceWithdrawEligibility, type VaultV2ForceWithdrawPlan, } from "./vaultV2ForceWithdrawPlan.js";
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateRequirementSpender = exports.validateOfferSides = exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validateReallocations = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateMidnightMarketChainId = exports.validateChainId = exports.validateAccrualPosition = exports.computeVaultMaxSharePrice = exports.computeVaultMaxShareAllowance = exports.computeMinWithdrawSharePrice = exports.computeMinForceWithdrawSharePrice = exports.computeMinBorrowSharePrice = exports.computeMaxSupplySharePrice = exports.computeMaxRepaySharePrice = exports.signAndVerifyTypedData = exports.grossFromNetAssets = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.APPROVE_ONLY_ONCE_TOKENS = exports.computeVaultV1Reallocations = exports.computeReallocations = void 0;
4
- var computeVaultV1Reallocations_js_1 = require("./computeVaultV1Reallocations.js");
5
- Object.defineProperty(exports, "computeReallocations", { enumerable: true, get: function () { return computeVaultV1Reallocations_js_1.computeReallocations; } });
6
- Object.defineProperty(exports, "computeVaultV1Reallocations", { enumerable: true, get: function () { return computeVaultV1Reallocations_js_1.computeVaultV1Reallocations; } });
3
+ exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateRequirementSpender = exports.validateOfferSides = exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateMidnightMarketChainId = exports.validateChainId = exports.validateAccrualPosition = exports.computeVaultMaxSharePrice = exports.computeVaultMaxShareAllowance = exports.computeMinForceWithdrawSharePrice = exports.signAndVerifyTypedData = exports.grossFromNetAssets = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.APPROVE_ONLY_ONCE_TOKENS = void 0;
7
4
  var constant_js_1 = require("./constant.js");
8
5
  Object.defineProperty(exports, "APPROVE_ONLY_ONCE_TOKENS", { enumerable: true, get: function () { return constant_js_1.APPROVE_ONLY_ONCE_TOKENS; } });
9
6
  Object.defineProperty(exports, "DEFAULT_LLTV_BUFFER", { enumerable: true, get: function () { return constant_js_1.DEFAULT_LLTV_BUFFER; } });
@@ -25,11 +22,7 @@ Object.defineProperty(exports, "grossFromNetAssets", { enumerable: true, get: fu
25
22
  var signAndVerifyTypedData_js_1 = require("./signAndVerifyTypedData.js");
26
23
  Object.defineProperty(exports, "signAndVerifyTypedData", { enumerable: true, get: function () { return signAndVerifyTypedData_js_1.signAndVerifyTypedData; } });
27
24
  var slippage_js_1 = require("./slippage.js");
28
- Object.defineProperty(exports, "computeMaxRepaySharePrice", { enumerable: true, get: function () { return slippage_js_1.computeMaxRepaySharePrice; } });
29
- Object.defineProperty(exports, "computeMaxSupplySharePrice", { enumerable: true, get: function () { return slippage_js_1.computeMaxSupplySharePrice; } });
30
- Object.defineProperty(exports, "computeMinBorrowSharePrice", { enumerable: true, get: function () { return slippage_js_1.computeMinBorrowSharePrice; } });
31
25
  Object.defineProperty(exports, "computeMinForceWithdrawSharePrice", { enumerable: true, get: function () { return slippage_js_1.computeMinForceWithdrawSharePrice; } });
32
- Object.defineProperty(exports, "computeMinWithdrawSharePrice", { enumerable: true, get: function () { return slippage_js_1.computeMinWithdrawSharePrice; } });
33
26
  Object.defineProperty(exports, "computeVaultMaxShareAllowance", { enumerable: true, get: function () { return slippage_js_1.computeVaultMaxShareAllowance; } });
34
27
  Object.defineProperty(exports, "computeVaultMaxSharePrice", { enumerable: true, get: function () { return slippage_js_1.computeVaultMaxSharePrice; } });
35
28
  var validate_js_1 = require("./validate.js");
@@ -39,7 +32,6 @@ Object.defineProperty(exports, "validateMidnightMarketChainId", { enumerable: tr
39
32
  Object.defineProperty(exports, "validateNativeAsset", { enumerable: true, get: function () { return validate_js_1.validateNativeAsset; } });
40
33
  Object.defineProperty(exports, "validatePositionHealth", { enumerable: true, get: function () { return validate_js_1.validatePositionHealth; } });
41
34
  Object.defineProperty(exports, "validatePositionHealthAfterWithdraw", { enumerable: true, get: function () { return validate_js_1.validatePositionHealthAfterWithdraw; } });
42
- Object.defineProperty(exports, "validateReallocations", { enumerable: true, get: function () { return validate_js_1.validateReallocations; } });
43
35
  Object.defineProperty(exports, "validateRepayAmount", { enumerable: true, get: function () { return validate_js_1.validateRepayAmount; } });
44
36
  Object.defineProperty(exports, "validateRepayShares", { enumerable: true, get: function () { return validate_js_1.validateRepayShares; } });
45
37
  Object.defineProperty(exports, "validateSlippageTolerance", { enumerable: true, get: function () { return validate_js_1.validateSlippageTolerance; } });
@@ -1,72 +1,4 @@
1
- import { type AccrualVault, AccrualVaultV2, type Market } from "@morpho-org/blue-sdk";
2
- /**
3
- * Computes the minimum borrow share price (in RAY, 1e27) for slippage protection.
4
- *
5
- * Mirrors the on-chain check in GeneralAdapter1's `morphoBorrow`:
6
- * ```solidity
7
- * require(borrowedAssets.rDivDown(borrowedShares) >= minSharePriceE27)
8
- * ```
9
- *
10
- * @param params - Computation parameters.
11
- * @param params.borrowAmount - The amount of assets to borrow.
12
- * @param params.market - The market to compute the minimum borrow share price for.
13
- * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. 0.003e18 = 0.3%).
14
- * @returns minSharePriceE27 in RAY scale (1e27).
15
- */
16
- export declare function computeMinBorrowSharePrice(params: {
17
- borrowAmount: bigint;
18
- market: Market;
19
- slippageTolerance: bigint;
20
- }): bigint;
21
- /**
22
- * Computes the maximum repay share price (in RAY, 1e27) for slippage protection.
23
- *
24
- * Supports both repay-by-assets and repay-by-shares paths:
25
- * - By assets: derives expected shares from the repay amount via `toBorrowShares("Down")`.
26
- * - By shares: derives expected assets from the shares via `toBorrowAssets("Up")`.
27
- *
28
- * Direction is opposite of borrow's `minSharePrice`:
29
- * - Borrow uses `(WAD - slippage)` → lower bound (protects borrower from getting fewer assets per share).
30
- * - Repay uses `(WAD + slippage)` → upper bound (protects repayer from paying too many assets per share).
31
- *
32
- * Capped at {@link MAX_ABSOLUTE_SHARE_PRICE} to prevent absurd values.
33
- *
34
- * @param params - Computation parameters.
35
- * @param params.repayAssets - The amount of assets to repay (0n when repaying by shares).
36
- * @param params.repayShares - The amount of shares to repay (0n when repaying by assets).
37
- * @param params.market - The market to compute the maximum repay share price for.
38
- * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. 0.003e18 = 0.3%).
39
- * @returns maxSharePriceE27 in RAY scale (1e27).
40
- */
41
- export declare function computeMaxRepaySharePrice(params: {
42
- repayAssets: bigint;
43
- repayShares: bigint;
44
- market: Market;
45
- slippageTolerance: bigint;
46
- }): bigint;
47
- /**
48
- * Computes the maximum supply share price (in RAY, 1e27) for slippage protection.
49
- *
50
- * Mirrors the on-chain check in GeneralAdapter1's `morphoSupply`:
51
- * ```solidity
52
- * require(suppliedAssets.rDivUp(suppliedShares) <= maxSharePriceE27)
53
- * ```
54
- *
55
- * Caps at {@link MAX_ABSOLUTE_SHARE_PRICE} to prevent absurd values on extreme markets.
56
- *
57
- * @param params - Computation parameters.
58
- * @param params.supplyAssets - The amount of loan assets to supply.
59
- * @param params.market - The market to compute the maximum supply share price for.
60
- * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. `0.003e18` = 0.3%).
61
- * @returns `maxSharePriceE27` in RAY scale (1e27).
62
- * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance >= WAD`.
63
- * @throws {ShareDivideByZeroError} when expected shares round down to zero.
64
- */
65
- export declare function computeMaxSupplySharePrice(params: {
66
- supplyAssets: bigint;
67
- market: Market;
68
- slippageTolerance: bigint;
69
- }): bigint;
1
+ import { type AccrualVault, AccrualVaultV2 } from "@morpho-org/blue-sdk";
70
2
  /**
71
3
  * Computes the minimum Vault V2 force-withdraw share price (in RAY, 1e27) for slippage protection.
72
4
  *
@@ -113,40 +45,6 @@ export declare function computeMinForceWithdrawSharePrice(params: {
113
45
  readonly sharesBurnt: bigint;
114
46
  readonly slippageTolerance: bigint;
115
47
  }): bigint;
116
- /**
117
- * Computes the minimum withdraw share price (in RAY, 1e27) for slippage protection.
118
- *
119
- * Mirrors the on-chain check in GeneralAdapter1's `morphoWithdraw`:
120
- * ```solidity
121
- * require(withdrawnAssets.rDivDown(withdrawnShares) >= minSharePriceE27)
122
- * ```
123
- *
124
- * Supports both assets and shares modes:
125
- * - By assets: derives expected shares via `toSupplyShares("Up")` (upper bound, protects the
126
- * withdrawer against over-burning shares).
127
- * - By shares: derives expected assets via `toSupplyAssets("Down")` (lower bound, the on-chain
128
- * amount paid out).
129
- *
130
- * Direction is opposite of supply's `maxSharePrice`:
131
- * - Supply uses `(WAD + slippage)` → upper bound (anti-inflation).
132
- * - Withdraw uses `(WAD − slippage)` → lower bound (protects withdrawer from receiving too few
133
- * assets per share burned).
134
- *
135
- * @param params - Computation parameters.
136
- * @param params.withdrawAssets - The amount of assets to withdraw (`0n` when withdrawing by shares).
137
- * @param params.withdrawShares - The amount of shares to withdraw (`0n` when withdrawing by assets).
138
- * @param params.market - The market to compute the minimum withdraw share price for.
139
- * @param params.slippageTolerance - Slippage tolerance in WAD (e.g. `0.003e18` = 0.3%).
140
- * @returns `minSharePriceE27` in RAY scale (1e27).
141
- * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance >= WAD`.
142
- * @throws {ShareDivideByZeroError} when expected shares round down to zero.
143
- */
144
- export declare function computeMinWithdrawSharePrice(params: {
145
- withdrawAssets: bigint;
146
- withdrawShares: bigint;
147
- market: Market;
148
- slippageTolerance: bigint;
149
- }): bigint;
150
48
  /**
151
49
  * Computes the RAY-scaled maximum share price for a VaultBundlesV1 deposit leg.
152
50
  *