@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
@@ -10,7 +10,6 @@ const index_js_1 = require("../../actions/index.js");
10
10
  const index_js_2 = require("../../helpers/index.js");
11
11
  const index_js_3 = require("../../types/index.js");
12
12
  const index_js_4 = require("../requirements/index.js");
13
- const vaultV1ReallocationData_js_1 = require("../vaultV1ReallocationData.js");
14
13
  const vaultV2BlueReallocationData_js_1 = require("../vaultV2BlueReallocationData.js");
15
14
  class MorphoBlue {
16
15
  client;
@@ -81,7 +80,6 @@ class MorphoBlue {
81
80
  (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
82
81
  return (0, blue_sdk_viem_1.fetchMarket)(this.marketParams.id, this.client.viemClient, {
83
82
  ...parameters,
84
- chainId: this.chainId,
85
83
  deployless: this.client.options.supportDeployless,
86
84
  });
87
85
  }
@@ -90,7 +88,6 @@ class MorphoBlue {
90
88
  return (0, blue_sdk_viem_1.fetchAccrualPosition)(userAddress, this.marketParams.id, this.client.viemClient, {
91
89
  ...parameters,
92
90
  deployless: this.client.options.supportDeployless,
93
- chainId: this.chainId,
94
91
  });
95
92
  }
96
93
  /** {@inheritDoc BlueActions.supply} */
@@ -441,14 +438,7 @@ class MorphoBlue {
441
438
  ? this.getTokenRequirements({
442
439
  token: this.marketParams.loanToken,
443
440
  amount: maxRepayAssets,
444
- // A caller-requested reusable approval wins; a full repay otherwise defaults to
445
- // the token's reusable cap. Checksum the key so a differently-cased loan token
446
- // (common from subgraphs/APIs) resolves that cap instead of falling back to
447
- // maxUint256, which UNI/ONDO/COMP/FLUID reject.
448
- approvalAmount: requirementsParams?.approvalAmount ??
449
- (saturatedRepay
450
- ? (index_js_2.MAX_TOKEN_APPROVALS[this.chainId]?.[(0, viem_1.getAddress)(this.marketParams.loanToken)] ?? viem_1.maxUint256)
451
- : undefined),
441
+ approvalAmount: requirementsParams?.approvalAmount,
452
442
  userAddress,
453
443
  deadline,
454
444
  useSimplePermit: requirementsParams?.useSimplePermit,
@@ -662,120 +652,6 @@ class MorphoBlue {
662
652
  },
663
653
  };
664
654
  }
665
- /**
666
- * Fetches all on-chain inputs needed to compute public allocator reallocations.
667
- *
668
- * @param params.vaultAddresses - Vaults to inspect for source-market liquidity.
669
- * @param params.block.number - Block number used for every RPC read.
670
- * @param params.block.timestamp - Timestamp corresponding to the fetched block.
671
- * @returns Reallocation data ready for {@link getVaultV1Reallocations}.
672
- * @throws {ChainIdMismatchError} when the client chain does not match this market.
673
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
674
- * {@link getVaultV2BlueReallocationData}.
675
- * @example
676
- * ```ts
677
- * import { markets, vaults } from "@morpho-org/morpho-test";
678
- * import { createPublicClient, http } from "viem";
679
- * import { mainnet } from "viem/chains";
680
- * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
681
- * import type { VaultV1ReallocationData } from "@morpho-org/morpho-sdk/entities";
682
- *
683
- * const client = createPublicClient({ chain: mainnet, transport: http() })
684
- * .extend(morphoViemExtension());
685
- * const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
686
- * const block = await client.getBlock();
687
- * const data: VaultV1ReallocationData = await market.getVaultV1ReallocationData({
688
- * vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
689
- * block,
690
- * });
691
- * ```
692
- */
693
- async getVaultV1ReallocationData({ vaultAddresses, block, }) {
694
- (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
695
- const client = this.client.viemClient;
696
- const fetchParams = {
697
- blockNumber: block.number,
698
- chainId: this.chainId,
699
- deployless: this.client.options.supportDeployless,
700
- };
701
- const targetMarketId = this.marketParams.id;
702
- // Phase 1: Fetch the target market and all vaults at `block.number` in
703
- // parallel so every row of the resulting state comes from the same epoch
704
- // and the planner never trusts a caller-owned target-market snapshot.
705
- const [targetMarket, vaults] = await Promise.all([
706
- (0, blue_sdk_viem_1.fetchMarket)(targetMarketId, client, fetchParams),
707
- Promise.all(vaultAddresses.map((addr) => (0, blue_sdk_viem_1.fetchVault)(addr, client, fetchParams))),
708
- ]);
709
- const allMarketIds = new Set([targetMarketId]);
710
- const vaultMarketPairs = [];
711
- for (const vault of vaults) {
712
- // Always include target market pair so its config/position is fetched
713
- // even when the target market is only in the vault's supplyQueue.
714
- vaultMarketPairs.push({ vault: vault.address, marketId: targetMarketId });
715
- for (const mid of vault.withdrawQueue) {
716
- allMarketIds.add(mid);
717
- if (mid !== targetMarketId) {
718
- vaultMarketPairs.push({ vault: vault.address, marketId: mid });
719
- }
720
- }
721
- }
722
- // Phase 2: Fetch all source markets, vault configs, and positions in parallel.
723
- const sourceMarketIds = [...allMarketIds].filter((mid) => mid !== targetMarketId);
724
- const [markets, configs, positions] = await Promise.all([
725
- Promise.all(sourceMarketIds.map((mid) => (0, blue_sdk_viem_1.fetchMarket)(mid, client, fetchParams))),
726
- Promise.all(vaultMarketPairs.map(({ vault, marketId: mid }) => (0, blue_sdk_viem_1.fetchVaultMarketConfig)(vault, mid, client, fetchParams).then((config) => ({ vault, mid, config })))),
727
- Promise.all(vaultMarketPairs.map(({ vault, marketId: mid }) => (0, blue_sdk_viem_1.fetchPosition)(vault, mid, client, fetchParams).then((position) => ({
728
- vault,
729
- mid,
730
- position,
731
- })))),
732
- ]);
733
- // Assemble records for VaultV1ReallocationData.
734
- const marketsRecord = {
735
- [targetMarketId]: targetMarket,
736
- };
737
- for (const m of markets) {
738
- marketsRecord[m.id] = m;
739
- }
740
- const vaultsRecord = {};
741
- for (const v of vaults) {
742
- vaultsRecord[v.address] = v;
743
- }
744
- const vaultMarketConfigsRecord = {};
745
- for (const { vault, mid, config } of configs) {
746
- (vaultMarketConfigsRecord[vault] ??= {})[mid] = config;
747
- }
748
- const positionsRecord = {};
749
- for (const { vault, mid, position } of positions) {
750
- (positionsRecord[vault] ??= {})[mid] = position;
751
- }
752
- return new vaultV1ReallocationData_js_1.VaultV1ReallocationData({
753
- chainId: this.chainId,
754
- markets: marketsRecord,
755
- vaults: vaultsRecord,
756
- vaultMarketConfigs: vaultMarketConfigsRecord,
757
- positions: positionsRecord,
758
- });
759
- }
760
- /**
761
- * Fetches Vault V1 PublicAllocator state using the deprecated unversioned name.
762
- *
763
- * @param params.vaultAddresses - Addresses of MetaMorpho vaults that allocate to this market.
764
- * @param params.block.number - Block number used for every RPC read.
765
- * @param params.block.timestamp - Timestamp corresponding to the fetched block.
766
- * @returns A `VaultV1ReallocationData` snapshot populated from one block.
767
- * @throws {ChainIdMismatchError} when the client chain does not match this market.
768
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
769
- * {@link getVaultV2BlueReallocationData}.
770
- * @example
771
- * ```ts
772
- * const data = await market.getReallocationData({ vaultAddresses, block });
773
- * // Equivalent to market.getVaultV1ReallocationData({ vaultAddresses, block }).
774
- * ```
775
- */
776
- getReallocationData(params) {
777
- return this.getVaultV1ReallocationData(params);
778
- }
779
655
  /**
780
656
  * Fetches Vault V2 BluePublicAllocator state for this target market.
781
657
  *
@@ -854,86 +730,6 @@ class MorphoBlue {
854
730
  ])),
855
731
  });
856
732
  }
857
- /**
858
- * Computes Vault V1 PublicAllocator reallocations for this market.
859
- *
860
- * Pass `{ borrowAmount }` for a borrow (legacy alias, equivalent to `{ operation: "borrow", amount }`)
861
- * or `{ operation, amount }` for a borrow or loan-asset withdraw.
862
- *
863
- * @param params - Reallocation computation parameters.
864
- * @param params.reallocationData - State returned by {@link getVaultV1ReallocationData}.
865
- * @param params.operation - The operation driving the reallocation (`"borrow"` or `"withdraw"`).
866
- * @param params.amount - The borrow or withdraw amount used to compute the post-state utilization.
867
- * @param params.borrowAmount - {@deprecated Pass `{ operation: "borrow", amount }` instead.}
868
- * @param params.options - Optional allocator and utilization options.
869
- * @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
870
- * @throws {ChainIdMismatchError} when `reallocationData` belongs to a different chain than this market.
871
- * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
872
- * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market.
873
- * @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets`.
874
- * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
875
- * @throws {UnknownReallocationMarketError} when the target market is absent from the reallocation data.
876
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
877
- * {@link getVaultV2BlueReallocations}.
878
- * @example
879
- * ```ts
880
- * const reallocations = market.getVaultV1Reallocations({
881
- * reallocationData,
882
- * operation: "borrow",
883
- * amount: 1_000_000n,
884
- * });
885
- * ```
886
- */
887
- getVaultV1Reallocations(params) {
888
- (0, index_js_2.validateChainId)(params.reallocationData.chainId, this.chainId);
889
- const marketId = this.marketParams.id;
890
- const options = { enabled: true, ...params.options };
891
- if (params.borrowAmount !== undefined) {
892
- return (0, index_js_2.computeVaultV1Reallocations)({
893
- reallocationData: params.reallocationData,
894
- marketId,
895
- operation: "borrow",
896
- amount: params.borrowAmount,
897
- options,
898
- });
899
- }
900
- return (0, index_js_2.computeVaultV1Reallocations)({
901
- reallocationData: params.reallocationData,
902
- marketId,
903
- operation: params.operation,
904
- amount: params.amount,
905
- options,
906
- });
907
- }
908
- /**
909
- * Computes Vault V1 PublicAllocator reallocations using the deprecated unversioned name.
910
- *
911
- * @param params.reallocationData - State returned by {@link getVaultV1ReallocationData}.
912
- * @param params.operation - The operation driving the reallocation (`"borrow"` or `"withdraw"`).
913
- * @param params.amount - The borrow or withdraw amount used to compute post-state utilization.
914
- * @param params.borrowAmount - Deprecated borrow amount alias.
915
- * @param params.options - Optional allocator and utilization options.
916
- * @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
917
- * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
918
- * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
919
- * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation.
920
- * @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
921
- * @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
922
- * @throws {UnknownReallocationMarketError} when the target market is absent.
923
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
924
- * {@link getVaultV2BlueReallocations}.
925
- * @example
926
- * ```ts
927
- * const reallocations = market.getReallocations({
928
- * reallocationData,
929
- * operation: "borrow",
930
- * amount: 1_000_000n,
931
- * });
932
- * ```
933
- */
934
- getReallocations(params) {
935
- return this.getVaultV1Reallocations(params);
936
- }
937
733
  /**
938
734
  * Computes Vault V2 BluePublicAllocator reallocations for this market.
939
735
  *
@@ -1,75 +1,12 @@
1
- export type { IAccrualPosition as IBlueAccrualPosition,
2
- /** @deprecated Use `IBlueAccrualPosition` or the raw Blue subpath. */
3
- IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket,
4
- /** @deprecated Use `IBlueMarket` or the raw Blue subpath. */
5
- IMarket, IMarketParams as IBlueMarketParams,
6
- /** @deprecated Use `IBlueMarketParams` or the raw Blue subpath. */
7
- IMarketParams, IPosition as IBluePosition,
8
- /** @deprecated Use `IBluePosition` or the raw Blue subpath. */
9
- IPosition, IPreLiquidationParams as IBluePreLiquidationParams,
10
- /** @deprecated Use `IBluePreLiquidationParams` or the raw Blue subpath. */
11
- IPreLiquidationParams, IPreLiquidationPosition as IBluePreLiquidationPosition,
12
- /** @deprecated Use `IBluePreLiquidationPosition` or the raw Blue subpath. */
13
- IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig,
14
- /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `IVaultV2BlueMarketPublicAllocatorConfig`. */
15
- IVaultMarketPublicAllocatorConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType,
16
- /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `IVaultV2BluePublicAllocatorConfig`. */
17
- VaultPublicAllocatorConfig, } from "@morpho-org/blue-sdk";
18
- export { AccrualPosition as BlueAccrualPosition,
19
- /** @deprecated Use `BlueAccrualPosition` or the raw Blue subpath. */
20
- AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket,
21
- /** @deprecated Use `BlueMarket` or the raw Blue subpath. */
22
- Market, MarketParams as BlueMarketParams,
23
- /** @deprecated Use `BlueMarketParams` or the raw Blue subpath. */
24
- MarketParams, Position as BluePosition,
25
- /** @deprecated Use `BluePosition` or the raw Blue subpath. */
26
- Position, PreLiquidationParams as BluePreLiquidationParams,
27
- /** @deprecated Use `BluePreLiquidationParams` or the raw Blue subpath. */
28
- PreLiquidationParams, PreLiquidationPosition as BluePreLiquidationPosition,
29
- /** @deprecated Use `BluePreLiquidationPosition` or the raw Blue subpath. */
30
- PreLiquidationPosition, Token, User as BlueUser,
31
- /** @deprecated Use `BlueUser` or the raw Blue subpath. */
32
- User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig,
33
- /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `VaultV2BlueMarketPublicAllocatorConfig`. */
34
- VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
1
+ export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition, IPreLiquidationParams as IBluePreLiquidationParams, IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
2
+ export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition, PreLiquidationParams as BluePreLiquidationParams, PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
35
3
  export type { BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, GroupInput as MidnightGroupInput, IAccrualPosition as IMidnightAccrualPosition, ICollateralParams as IMidnightCollateralParams, IGroup as IMidnightGroup, IMarket as IMidnightMarket, IMarketParams as IMidnightMarketParams, IOffer as IMidnightOffer, IPosition as IMidnightPosition, MarketInput as MidnightMarketInput, OfferStruct as MidnightOfferStruct, RatifierTreeInput as MidnightRatifierTreeInput, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeDescriptor as MidnightTreeDescriptor, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, } from "@morpho-org/midnight-sdk";
36
4
  export { AccrualPosition as MidnightAccrualPosition, Group as MidnightGroup, Market as MidnightMarket, MarketParams as MidnightMarketParams, Offer as MidnightOffer, Position as MidnightPosition, Tree as MidnightTree, } from "@morpho-org/midnight-sdk";
37
5
  export type { BlueActions, BlueTokenRequirementsParams, } from "./blue/index.js";
38
6
  export { MorphoBlue } from "./blue/index.js";
39
- export type { GetOffersDataParams as MidnightGetOffersDataParams,
40
- /** @deprecated Use `MidnightGetOffersDataParams`. */
41
- GetOffersDataParams, GetPositionDataParams as MidnightGetPositionDataParams,
42
- /** @deprecated Use `MidnightGetPositionDataParams`. */
43
- GetPositionDataParams, MakeLendParams as MidnightMakeLendParams,
44
- /** @deprecated Use `MidnightMakeLendParams`. */
45
- MakeLendParams, MakeOffersOutput as MidnightMakeOffersOutput,
46
- /** @deprecated Use `MidnightMakeOffersOutput`. */
47
- MakeOffersOutput, MakeOffersParams as MidnightMakeOffersParams,
48
- /** @deprecated Use `MidnightMakeOffersParams`. */
49
- MakeOffersParams, MarketActionParams as MidnightMarketActionParams,
50
- /** @deprecated Use `MidnightMarketActionParams`. */
51
- MarketActionParams, OffersData as MidnightOffersData,
52
- /** @deprecated Use `MidnightOffersData`. */
53
- OffersData, OfferValidationParams as MidnightOfferValidationParams,
54
- /** @deprecated Use `MidnightOfferValidationParams`. */
55
- OfferValidationParams, RedeemParams as MidnightRedeemParams,
56
- /** @deprecated Use `MidnightRedeemParams`. */
57
- RedeemParams, RepayWithdrawCollateralParams as MidnightRepayWithdrawCollateralParams,
58
- /** @deprecated Use `MidnightRepayWithdrawCollateralParams`. */
59
- RepayWithdrawCollateralParams, SupplyCollateralMakeBorrowParams as MidnightSupplyCollateralMakeBorrowParams,
60
- /** @deprecated Use `MidnightSupplyCollateralMakeBorrowParams`. */
61
- SupplyCollateralMakeBorrowParams, SupplyCollateralParams as MidnightSupplyCollateralParams,
62
- /** @deprecated Use `MidnightSupplyCollateralParams`. */
63
- SupplyCollateralParams, SupplyCollateralTakeBorrowParams as MidnightSupplyCollateralTakeBorrowParams,
64
- /** @deprecated Use `MidnightSupplyCollateralTakeBorrowParams`. */
65
- SupplyCollateralTakeBorrowParams, TakeBorrowParams as MidnightTakeBorrowParams,
66
- /** @deprecated Use `MidnightTakeBorrowParams`. */
67
- TakeBorrowParams, TakeLendParams as MidnightTakeLendParams,
68
- /** @deprecated Use `MidnightTakeLendParams`. */
69
- TakeLendParams, } from "./midnight/index.js";
7
+ export type { GetOffersDataParams as MidnightGetOffersDataParams, GetPositionDataParams as MidnightGetPositionDataParams, MakeLendParams as MidnightMakeLendParams, MakeOffersOutput as MidnightMakeOffersOutput, MakeOffersParams as MidnightMakeOffersParams, MarketActionParams as MidnightMarketActionParams, OffersData as MidnightOffersData, OfferValidationParams as MidnightOfferValidationParams, RedeemParams as MidnightRedeemParams, RepayWithdrawCollateralParams as MidnightRepayWithdrawCollateralParams, SupplyCollateralMakeBorrowParams as MidnightSupplyCollateralMakeBorrowParams, SupplyCollateralParams as MidnightSupplyCollateralParams, SupplyCollateralTakeBorrowParams as MidnightSupplyCollateralTakeBorrowParams, TakeBorrowParams as MidnightTakeBorrowParams, TakeLendParams as MidnightTakeLendParams, } from "./midnight/index.js";
70
8
  export { type MidnightActionOutput, type MidnightActionSignatures, type MidnightActions, MorphoMidnight, } from "./midnight/index.js";
71
9
  export * from "./requirements/index.js";
72
10
  export { MorphoVaultV1 } from "./vaultV1/index.js";
73
- export { type InputReallocationData, type InputVaultV1ReallocationData, ReallocationData, VaultV1ReallocationData, } from "./vaultV1ReallocationData.js";
74
11
  export { MorphoVaultV2 } from "./vaultV2/index.js";
75
12
  export { type InputVaultV2BlueReallocationData, VaultV2BlueReallocationData, } from "./vaultV2BlueReallocationData.js";
@@ -14,12 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.MorphoVaultV1 = exports.MorphoMidnight = exports.MorphoBlue = exports.MidnightTree = exports.MidnightPosition = exports.MidnightOffer = exports.MidnightMarketParams = exports.MidnightMarket = exports.MidnightGroup = exports.MidnightAccrualPosition = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketPublicAllocatorConfig = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.User = exports.BlueUser = exports.Token = exports.PreLiquidationPosition = exports.BluePreLiquidationPosition = exports.PreLiquidationParams = exports.BluePreLiquidationParams = exports.Position = exports.BluePosition = exports.MarketParams = exports.BlueMarketParams = exports.Market = exports.BlueMarket = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.AccrualPosition = exports.BlueAccrualPosition = void 0;
18
- exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = exports.VaultV1ReallocationData = exports.ReallocationData = void 0;
17
+ exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = exports.MorphoVaultV1 = exports.MorphoMidnight = exports.MorphoBlue = exports.MidnightTree = exports.MidnightPosition = exports.MidnightOffer = exports.MidnightMarketParams = exports.MidnightMarket = exports.MidnightGroup = exports.MidnightAccrualPosition = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.BlueUser = exports.Token = exports.BluePreLiquidationPosition = exports.BluePreLiquidationParams = exports.BluePosition = exports.BlueMarketParams = exports.BlueMarket = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.BlueAccrualPosition = void 0;
19
18
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
20
19
  Object.defineProperty(exports, "BlueAccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
21
- /** @deprecated Use `BlueAccrualPosition` or the raw Blue subpath. */
22
- Object.defineProperty(exports, "AccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
23
20
  Object.defineProperty(exports, "AccrualVault", { enumerable: true, get: function () { return blue_sdk_1.AccrualVault; } });
24
21
  Object.defineProperty(exports, "AccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2; } });
25
22
  Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1Adapter; } });
@@ -31,30 +28,16 @@ Object.defineProperty(exports, "Eip5267Domain", { enumerable: true, get: functio
31
28
  Object.defineProperty(exports, "ExchangeRateWrappedToken", { enumerable: true, get: function () { return blue_sdk_1.ExchangeRateWrappedToken; } });
32
29
  Object.defineProperty(exports, "Holding", { enumerable: true, get: function () { return blue_sdk_1.Holding; } });
33
30
  Object.defineProperty(exports, "BlueMarket", { enumerable: true, get: function () { return blue_sdk_1.Market; } });
34
- /** @deprecated Use `BlueMarket` or the raw Blue subpath. */
35
- Object.defineProperty(exports, "Market", { enumerable: true, get: function () { return blue_sdk_1.Market; } });
36
31
  Object.defineProperty(exports, "BlueMarketParams", { enumerable: true, get: function () { return blue_sdk_1.MarketParams; } });
37
- /** @deprecated Use `BlueMarketParams` or the raw Blue subpath. */
38
- Object.defineProperty(exports, "MarketParams", { enumerable: true, get: function () { return blue_sdk_1.MarketParams; } });
39
32
  Object.defineProperty(exports, "BluePosition", { enumerable: true, get: function () { return blue_sdk_1.Position; } });
40
- /** @deprecated Use `BluePosition` or the raw Blue subpath. */
41
- Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return blue_sdk_1.Position; } });
42
33
  Object.defineProperty(exports, "BluePreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationParams; } });
43
- /** @deprecated Use `BluePreLiquidationParams` or the raw Blue subpath. */
44
- Object.defineProperty(exports, "PreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationParams; } });
45
34
  Object.defineProperty(exports, "BluePreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationPosition; } });
46
- /** @deprecated Use `BluePreLiquidationPosition` or the raw Blue subpath. */
47
- Object.defineProperty(exports, "PreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationPosition; } });
48
35
  Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return blue_sdk_1.Token; } });
49
36
  Object.defineProperty(exports, "BlueUser", { enumerable: true, get: function () { return blue_sdk_1.User; } });
50
- /** @deprecated Use `BlueUser` or the raw Blue subpath. */
51
- Object.defineProperty(exports, "User", { enumerable: true, get: function () { return blue_sdk_1.User; } });
52
37
  Object.defineProperty(exports, "Vault", { enumerable: true, get: function () { return blue_sdk_1.Vault; } });
53
38
  Object.defineProperty(exports, "VaultConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultConfig; } });
54
39
  Object.defineProperty(exports, "VaultMarketAllocation", { enumerable: true, get: function () { return blue_sdk_1.VaultMarketAllocation; } });
55
40
  Object.defineProperty(exports, "VaultMarketConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultMarketConfig; } });
56
- /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `VaultV2BlueMarketPublicAllocatorConfig`. */
57
- Object.defineProperty(exports, "VaultMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultMarketPublicAllocatorConfig; } });
58
41
  Object.defineProperty(exports, "VaultToken", { enumerable: true, get: function () { return blue_sdk_1.VaultToken; } });
59
42
  Object.defineProperty(exports, "VaultUser", { enumerable: true, get: function () { return blue_sdk_1.VaultUser; } });
60
43
  Object.defineProperty(exports, "VaultV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2; } });
@@ -80,9 +63,6 @@ Object.defineProperty(exports, "MorphoMidnight", { enumerable: true, get: functi
80
63
  __exportStar(require("./requirements/index.js"), exports);
81
64
  var index_js_3 = require("./vaultV1/index.js");
82
65
  Object.defineProperty(exports, "MorphoVaultV1", { enumerable: true, get: function () { return index_js_3.MorphoVaultV1; } });
83
- var vaultV1ReallocationData_js_1 = require("./vaultV1ReallocationData.js");
84
- Object.defineProperty(exports, "ReallocationData", { enumerable: true, get: function () { return vaultV1ReallocationData_js_1.ReallocationData; } });
85
- Object.defineProperty(exports, "VaultV1ReallocationData", { enumerable: true, get: function () { return vaultV1ReallocationData_js_1.VaultV1ReallocationData; } });
86
66
  var index_js_4 = require("./vaultV2/index.js");
87
67
  Object.defineProperty(exports, "MorphoVaultV2", { enumerable: true, get: function () { return index_js_4.MorphoVaultV2; } });
88
68
  var vaultV2BlueReallocationData_js_1 = require("./vaultV2BlueReallocationData.js");
@@ -36,6 +36,7 @@ export interface VaultV1Actions {
36
36
  * @returns Lazy token prerequisite resolution and a synchronous deep-frozen VaultBundlesV1
37
37
  * transaction builder.
38
38
  * @throws {ChainIdMismatchError} when the connected client targets another chain.
39
+ * @throws {UnsupportedBlueMarketIrmError} when an allocated market with positive debt uses an unsupported IRM.
39
40
  * @throws {VaultAddressMismatchError} when `vaultData` belongs to another vault.
40
41
  * @throws {ExpiredDeadlineError} when the deadline is stale at creation or requirement resolution.
41
42
  * @throws {MixedBundlesFundingError} when ERC-20 and native funding are both supplied.
@@ -240,6 +241,10 @@ export interface VaultV1Actions {
240
241
  * Snapshot state can drift before inclusion, so a later reallocation may still make the on-chain
241
242
  * loop under-cover even after pre-flight succeeds.
242
243
  *
244
+ * In-kind exits require an exact vault-share allowance for the computed cap. An ERC-2612 permit
245
+ * is emitted only to raise an insufficient allowance; an oversized allowance is always reset
246
+ * with an onchain approval before the exit.
247
+ *
243
248
  * @param params - In-kind redemption parameters.
244
249
  * @param params.amount - Asset-denominated amount to exit.
245
250
  * @param params.marketParamsList - Ordered vault markets consumed greedily by the contract;
@@ -266,7 +271,9 @@ export interface VaultV1Actions {
266
271
  * @throws {InsufficientBlueBalanceForInKindRedeemError} from `getRequirements()` when Blue cannot fund the flash loan.
267
272
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when more than one permit signature is supplied.
268
273
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-permit signature is supplied.
269
- * @throws {VaultExitBundlesV1PermitMismatchError} from `buildTx()` when the requirement has the wrong permit kind, asset, or signature encoding.
274
+ * @throws {BundlesPermitMismatchError} from `buildTx()` when the supplied permit is not ERC-2612, has
275
+ * the wrong asset, owner, or signature encoding, or names another spender, amount, or deadline
276
+ * than the prepared cap.
270
277
  * @example
271
278
  * ```ts
272
279
  * import { isRequirementSignature } from "@morpho-org/morpho-sdk";
@@ -329,8 +336,8 @@ export interface VaultV1Actions {
329
336
  * satisfied between calls stops being reported, while the derived source share cap stays
330
337
  * pinned to the supplied snapshot.
331
338
  * @throws {UnknownBlueMarketAllocationError} when a source withdraw-queue market has no allocation snapshot.
332
- * @throws {UnsupportedBlueMarketIrmError} when required interest projection encounters an unsupported IRM.
333
339
  * @throws {ChainIdMismatchError} when the connected client targets another chain.
340
+ * @throws {UnsupportedBlueMarketIrmError} when an allocated source or target market with positive debt uses an unsupported IRM.
334
341
  * @throws {VaultAddressMismatchError} when `sourceVault` belongs to another vault.
335
342
  * @throws {VaultAssetMismatchError} when the source and destination vault assets differ.
336
343
  * @throws {SameVaultMigrationError} when the source and destination vault addresses are equal.
@@ -30,7 +30,6 @@ class MorphoVaultV1 {
30
30
  }
31
31
  return (0, blue_sdk_viem_1.fetchAccrualVault)(this.vault, this.client.viemClient, {
32
32
  ...parameters,
33
- chainId: this.chainId,
34
33
  deployless: this.client.options.supportDeployless,
35
34
  });
36
35
  }
@@ -296,8 +295,7 @@ class MorphoVaultV1 {
296
295
  if (deadline <= now)
297
296
  throw new index_js_3.ExpiredDeadlineError(deadline, now);
298
297
  const vaultExitBundlesV1 = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultExitBundlesV1");
299
- const addresses = (0, blue_sdk_1.getChainAddresses)(this.chainId);
300
- const blue = addresses.blue ?? addresses.morpho;
298
+ const blue = (0, morpho_ts_1.getChainAddress)(this.chainId, "blue");
301
299
  let covered = 0n;
302
300
  const assignedByMarket = new Map();
303
301
  for (const marketParams of marketParamsListSnapshot) {
@@ -395,9 +393,14 @@ class MorphoVaultV1 {
395
393
  required: amount,
396
394
  });
397
395
  }
398
- if (allowance >= requiredShareAllowance)
396
+ // In-kind withdrawals carry no onchain share cap, so the allowance itself is the cap. A
397
+ // larger leftover allowance would let a share-price loss burn past `requiredShareAllowance`.
398
+ if (allowance === requiredShareAllowance)
399
399
  return [];
400
- if (this.client.options.supportSignature) {
400
+ // A lowering permit can be skipped after its nonce is consumed, so oversized allowances
401
+ // must be reset with an onchain approval.
402
+ if (allowance < requiredShareAllowance &&
403
+ this.client.options.supportSignature) {
401
404
  return [
402
405
  (0, index_js_1.encodeVaultSharesPermit)({
403
406
  vault: vaultData,
@@ -421,8 +424,10 @@ class MorphoVaultV1 {
421
424
  ];
422
425
  },
423
426
  buildTx: (signatures) => {
424
- const { permit } = (0, index_js_3.selectRequirementSignatures)(signatures, {
425
- permit: true,
427
+ const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signatures, {
428
+ spender: vaultExitBundlesV1,
429
+ amount: requiredShareAllowance,
430
+ deadline,
426
431
  });
427
432
  return (0, index_js_1.vaultV1InKindRedeem)({
428
433
  vault: { chainId: this.chainId, address: this.vault },
@@ -37,8 +37,8 @@ export interface VaultV2Actions {
37
37
  * two hours from handle creation.
38
38
  * @returns Lazy token prerequisite resolution and a synchronous deep-frozen VaultBundlesV1
39
39
  * transaction builder.
40
- * @throws {UnsupportedBlueMarketIrmError} when required interest projection encounters an unsupported IRM.
41
40
  * @throws {ChainIdMismatchError} when the connected client targets another chain.
41
+ * @throws {UnsupportedBlueMarketIrmError} when an underlying market with positive debt uses an unsupported IRM.
42
42
  * @throws {VaultAddressMismatchError} when `vaultData` belongs to another vault.
43
43
  * @throws {ExpiredDeadlineError} when the deadline is stale at creation or requirement resolution.
44
44
  * @throws {MixedBundlesFundingError} when ERC-20 and native funding are both supplied.
@@ -233,6 +233,10 @@ export interface VaultV2Actions {
233
233
  * Idle balance, penalty, and adapter positions can drift after the snapshot, so an on-chain
234
234
  * under-coverage panic remains possible if vault state changes between preparation and inclusion.
235
235
  *
236
+ * In-kind exits require an exact vault-share allowance for the computed cap. An ERC-2612 permit
237
+ * is emitted only to raise an insufficient allowance; an oversized allowance is always reset
238
+ * with an onchain approval before the exit.
239
+ *
236
240
  * @param params - In-kind redemption parameters.
237
241
  * @param params.amount - Penalty-inclusive, asset-denominated amount to exit.
238
242
  * @param params.marketParamsList - Ordered adapter markets consumed greedily after idle assets;
@@ -262,7 +266,9 @@ export interface VaultV2Actions {
262
266
  * @throws {InsufficientBlueBalanceForInKindRedeemError} from `getRequirements()` when Blue cannot fund the largest callback.
263
267
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when more than one permit signature is supplied.
264
268
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-permit signature is supplied.
265
- * @throws {VaultExitBundlesV1PermitMismatchError} from `buildTx()` when the requirement has the wrong permit kind, asset, or signature encoding.
269
+ * @throws {BundlesPermitMismatchError} from `buildTx()` when the supplied permit is not ERC-2612, has
270
+ * the wrong asset, owner, or signature encoding, or names another spender, amount, or deadline
271
+ * than the prepared cap.
266
272
  * @example
267
273
  * ```ts
268
274
  * import { isRequirementSignature } from "@morpho-org/morpho-sdk";
@@ -313,10 +319,13 @@ export interface VaultV2Actions {
313
319
  * adapter or none at all. Call `getRequirements()` before `buildTx()` so the vault-share allowance
314
320
  * and permit nonce are read on-chain.
315
321
  *
316
- * Unless `minSharePriceE27` is overridden, the SDK derives a conservative lower bound on the
317
- * realized exit share price from the snapshot and `slippageTolerance`. The bound rejects a share
318
- * price drop, a penalty increase, and liquidity shifting from the penalty-free leg to the
319
- * penalised leg. It does **not** cover the referral fee, which the contract deducts afterwards.
322
+ * The SDK derives a conservative lower bound on the realized exit share price from the snapshot
323
+ * and `slippageTolerance`. A supplied `minSharePriceE27` replaces the tolerance-derived bound
324
+ * (it may be tighter or looser) but must be at least the floor derived at
325
+ * `MAX_SLIPPAGE_TOLERANCE`, so an override can never disable meaningful protection.
326
+ * The bound rejects a share price drop, a penalty increase, and liquidity shifting from the
327
+ * penalty-free leg to the penalised leg. It does **not** cover the referral fee, which the
328
+ * contract deducts afterwards.
320
329
  *
321
330
  * Vault gates are enforced by the final transaction and are not preflighted: the receive-assets
322
331
  * gate must allow VaultExitBundlesV1 and may depend on its transient initiator, while a
@@ -343,8 +352,10 @@ export interface VaultV2Actions {
343
352
  * Deadlines more than one year after handle creation are rejected.
344
353
  * @param params.slippageTolerance - Optional WAD-scaled tolerance applied to the derived share
345
354
  * price bound. Defaults to `DEFAULT_SLIPPAGE_TOLERANCE`, capped at `MAX_SLIPPAGE_TOLERANCE`.
346
- * @param params.minSharePriceE27 - Optional RAY-scaled override of the derived bound. Must be
347
- * positive: the contract reads `0` as "no bound", so it cannot be used to opt out.
355
+ * @param params.minSharePriceE27 - Optional RAY-scaled override of the derived bound. It replaces
356
+ * the tolerance-derived bound and may be tighter or looser, but must be at least the floor
357
+ * derived at `MAX_SLIPPAGE_TOLERANCE`. When that floor rounds down to zero (dust exits) it is
358
+ * clamped to `1`, so any positive override is accepted.
348
359
  * @param params.referralFeePct - Optional WAD-scaled share of the withdrawn assets routed to
349
360
  * `referralFeeRecipient`. Defaults to `0n`.
350
361
  * @param params.referralFeeRecipient - Optional referral fee recipient, required when
@@ -373,6 +384,8 @@ export interface VaultV2Actions {
373
384
  * which would overrun the contract's unbounded loop.
374
385
  * @throws {VaultV2ForceWithdrawZeroSharePriceError} when the derived share-price floor rounds down
375
386
  * to zero, which the contract would read as no bound at all.
387
+ * @throws {VaultV2ForceWithdrawSharePriceBelowFloorError} when a supplied `minSharePriceE27`
388
+ * is below the floor derived at `MAX_SLIPPAGE_TOLERANCE`.
376
389
  * @throws {VaultV2ForceWithdrawFeeSharesExceedBurnError} when fee shares are minted to a
377
390
  * fee-recipient `userAddress` and reach the lower-bound share burn at the deadline.
378
391
  * @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
@@ -384,7 +397,7 @@ export interface VaultV2Actions {
384
397
  * @throws {BundlesPermitMismatchError} from `buildTx()` when the permit's spender, amount, or
385
398
  * deadline differs from this operation. Any handle built from the same inputs accepts the
386
399
  * permit; the nonce is verified onchain by the vault's `permit`.
387
- * @throws {VaultExitBundlesV1PermitMismatchError} from `buildTx()` when the requirement has the wrong permit kind, asset, or signature encoding.
400
+ * @throws {BundlesPermitMismatchError} from `buildTx()` when the requirement has the wrong permit kind, asset, or signature encoding.
388
401
  * @example
389
402
  * ```ts
390
403
  * import { isRequirementSignature } from "@morpho-org/morpho-sdk";