@morpho-org/morpho-sdk 5.8.0 → 5.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +4 -0
  2. package/lib/cjs/abis.d.ts +543 -0
  3. package/lib/cjs/abis.js +738 -0
  4. package/lib/cjs/actions/blue/borrow.d.ts +5 -2
  5. package/lib/cjs/actions/blue/borrow.js +1 -1
  6. package/lib/cjs/actions/blue/refinance.d.ts +7 -2
  7. package/lib/cjs/actions/blue/refinance.js +3 -1
  8. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +6 -2
  9. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +2 -1
  10. package/lib/cjs/actions/blue/withdraw.d.ts +2 -1
  11. package/lib/cjs/actions/blue/withdraw.js +1 -1
  12. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
  13. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
  14. package/lib/cjs/actions/midnight/takeBorrow.d.ts +2 -2
  15. package/lib/cjs/actions/midnight/takeBorrow.js +2 -2
  16. package/lib/cjs/actions/midnight/takeLend.d.ts +2 -2
  17. package/lib/cjs/actions/midnight/takeLend.js +2 -2
  18. package/lib/cjs/blue/types.d.ts +3 -1
  19. package/lib/cjs/blue/utils.d.ts +3 -1
  20. package/lib/cjs/blue/utils.js +1 -0
  21. package/lib/cjs/bundler/actions.d.ts +2 -0
  22. package/lib/cjs/bundler/actions.js +2 -0
  23. package/lib/cjs/bundler/types.d.ts +10 -1
  24. package/lib/cjs/entities/blue/blue.d.ts +30 -5
  25. package/lib/cjs/entities/blue/blue.js +8 -2
  26. package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
  27. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +69 -12
  28. package/lib/cjs/entities/vaultV1/vaultV1.js +11 -14
  29. package/lib/cjs/entities/vaultV1ReallocationData.d.ts +18 -3
  30. package/lib/cjs/entities/vaultV1ReallocationData.js +11 -1
  31. package/lib/cjs/entities/vaultV2/vaultV2.js +6 -18
  32. package/lib/cjs/entities/vaultV2BlueReallocationData.js +5 -1
  33. package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +4 -1
  34. package/lib/cjs/helpers/computeVaultV1Reallocations.js +4 -1
  35. package/lib/cjs/helpers/metadata.d.ts +3 -5
  36. package/lib/cjs/helpers/metadata.js +4 -6
  37. package/lib/cjs/helpers/validate.d.ts +2 -0
  38. package/lib/cjs/helpers/validate.js +2 -0
  39. package/lib/cjs/types/error.d.ts +34 -6
  40. package/lib/cjs/types/error.js +34 -6
  41. package/lib/cjs/types/sharedLiquidity.d.ts +26 -3
  42. package/lib/cjs/types.d.ts +3 -1
  43. package/lib/cjs/utils.d.ts +3 -1
  44. package/lib/cjs/utils.js +1 -0
  45. package/lib/esm/abis.d.ts +543 -0
  46. package/lib/esm/abis.js +737 -0
  47. package/lib/esm/actions/blue/borrow.d.ts +5 -2
  48. package/lib/esm/actions/blue/borrow.js +1 -1
  49. package/lib/esm/actions/blue/refinance.d.ts +7 -2
  50. package/lib/esm/actions/blue/refinance.js +3 -1
  51. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +6 -2
  52. package/lib/esm/actions/blue/supplyCollateralBorrow.js +2 -1
  53. package/lib/esm/actions/blue/withdraw.d.ts +2 -1
  54. package/lib/esm/actions/blue/withdraw.js +1 -1
  55. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
  56. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
  57. package/lib/esm/actions/midnight/takeBorrow.d.ts +2 -2
  58. package/lib/esm/actions/midnight/takeBorrow.js +2 -2
  59. package/lib/esm/actions/midnight/takeLend.d.ts +2 -2
  60. package/lib/esm/actions/midnight/takeLend.js +2 -2
  61. package/lib/esm/blue/types.d.ts +3 -1
  62. package/lib/esm/blue/utils.d.ts +3 -1
  63. package/lib/esm/blue/utils.js +3 -1
  64. package/lib/esm/bundler/actions.d.ts +2 -0
  65. package/lib/esm/bundler/actions.js +2 -0
  66. package/lib/esm/bundler/types.d.ts +10 -1
  67. package/lib/esm/entities/blue/blue.d.ts +30 -5
  68. package/lib/esm/entities/blue/blue.js +8 -2
  69. package/lib/esm/entities/midnight/midnight.d.ts +2 -2
  70. package/lib/esm/entities/vaultV1/vaultV1.d.ts +69 -12
  71. package/lib/esm/entities/vaultV1/vaultV1.js +11 -14
  72. package/lib/esm/entities/vaultV1ReallocationData.d.ts +18 -3
  73. package/lib/esm/entities/vaultV1ReallocationData.js +13 -2
  74. package/lib/esm/entities/vaultV2/vaultV2.js +7 -19
  75. package/lib/esm/entities/vaultV2BlueReallocationData.js +5 -1
  76. package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +4 -1
  77. package/lib/esm/helpers/computeVaultV1Reallocations.js +4 -1
  78. package/lib/esm/helpers/metadata.d.ts +3 -5
  79. package/lib/esm/helpers/metadata.js +4 -6
  80. package/lib/esm/helpers/validate.d.ts +2 -0
  81. package/lib/esm/helpers/validate.js +2 -0
  82. package/lib/esm/types/error.d.ts +34 -6
  83. package/lib/esm/types/error.js +34 -6
  84. package/lib/esm/types/sharedLiquidity.d.ts +26 -3
  85. package/lib/esm/types.d.ts +3 -1
  86. package/lib/esm/utils.d.ts +3 -1
  87. package/lib/esm/utils.js +3 -1
  88. package/package.json +8 -8
@@ -29,9 +29,7 @@ export class MorphoVaultV1 {
29
29
  });
30
30
  }
31
31
  deposit({ amount = 0n, userAddress, vaultData, slippageTolerance = DEFAULT_SLIPPAGE_TOLERANCE, nativeAmount, }) {
32
- if (this.client.viemClient.chain?.id !== this.chainId) {
33
- throw new ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
34
- }
32
+ validateChainId(this.client.viemClient.chain?.id, this.chainId);
35
33
  if (!isAddressEqual(vaultData.address, this.vault)) {
36
34
  throw new VaultAddressMismatchError(this.vault, vaultData.address);
37
35
  }
@@ -98,9 +96,7 @@ export class MorphoVaultV1 {
98
96
  };
99
97
  }
100
98
  withdraw({ amount, userAddress }) {
101
- if (this.client.viemClient.chain?.id !== this.chainId) {
102
- throw new ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
103
- }
99
+ validateChainId(this.client.viemClient.chain?.id, this.chainId);
104
100
  return {
105
101
  buildTx: () => vaultV1Withdraw({
106
102
  vault: { address: this.vault },
@@ -114,9 +110,7 @@ export class MorphoVaultV1 {
114
110
  };
115
111
  }
116
112
  redeem({ shares, userAddress }) {
117
- if (this.client.viemClient.chain?.id !== this.chainId) {
118
- throw new ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
119
- }
113
+ validateChainId(this.client.viemClient.chain?.id, this.chainId);
120
114
  return {
121
115
  buildTx: () => vaultV1Redeem({
122
116
  vault: { address: this.vault },
@@ -131,9 +125,7 @@ export class MorphoVaultV1 {
131
125
  }
132
126
  /** {@inheritDoc VaultV1Actions.inKindRedeem} */
133
127
  inKindRedeem({ amount, marketParamsList, vaultData, userAddress, deadline: deadlineOverride, }) {
134
- if (this.client.viemClient.chain?.id !== this.chainId) {
135
- throw new ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
136
- }
128
+ validateChainId(this.client.viemClient.chain?.id, this.chainId);
137
129
  if (!isAddressEqual(vaultData.address, this.vault)) {
138
130
  throw new VaultAddressMismatchError(this.vault, vaultData.address);
139
131
  }
@@ -292,6 +284,7 @@ export class MorphoVaultV1 {
292
284
  },
293
285
  };
294
286
  }
287
+ /** {@inheritDoc VaultV1Actions.migrateToV2} */
295
288
  migrateToV2({ userAddress, sourceVault, targetVault, shares, slippageTolerance = DEFAULT_SLIPPAGE_TOLERANCE, }) {
296
289
  validateChainId(this.client.viemClient.chain?.id, this.chainId);
297
290
  if (!isAddressEqual(sourceVault.address, this.vault)) {
@@ -304,8 +297,12 @@ export class MorphoVaultV1 {
304
297
  throw new NonPositiveInputError("shares", shares);
305
298
  }
306
299
  validateSlippageTolerance(slippageTolerance);
307
- // Compute minSharePriceVaultV1 for V1 redeem (slippage downward)
308
- const v1RefAssets = sourceVault.toAssets(shares);
300
+ // V1 redeem accrues pending market interest and performance fees before converting shares.
301
+ const sourceAccrualTimestamp = sourceVault.allocations
302
+ .values()
303
+ .reduce((timestamp, { position }) => MathLib.max(timestamp, position.market.lastUpdate), Time.timestamp());
304
+ const accruedSourceVault = sourceVault.accrueInterest(sourceAccrualTimestamp);
305
+ const v1RefAssets = accruedSourceVault.toAssets(shares);
309
306
  const minSharePriceVaultV1 = MathLib.mulDivDown(v1RefAssets, MathLib.wToRay(MathLib.WAD - slippageTolerance), shares);
310
307
  // Compute maxSharePriceVaultV2 for V2 deposit (slippage upward).
311
308
  // Accrue VaultV2 interest forward to bound the on-chain share price at execution.
@@ -3,6 +3,9 @@ import type { Address } from "viem";
3
3
  import type { PublicAllocatorOptions, PublicReallocation, ReallocationComputeOptions } from "../types/index.js";
4
4
  /**
5
5
  * Input state required to construct {@link VaultV1ReallocationData}.
6
+ *
7
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
8
+ * `InputVaultV2BlueReallocationData`.
6
9
  */
7
10
  export interface InputVaultV1ReallocationData {
8
11
  /** Chain id associated with the fetched state. */
@@ -19,7 +22,8 @@ export interface InputVaultV1ReallocationData {
19
22
  /**
20
23
  * Deprecated input name for Vault V1 reallocation data.
21
24
  *
22
- * @deprecated Use {@link InputVaultV1ReallocationData} instead.
25
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
26
+ * `InputVaultV2BlueReallocationData`.
23
27
  */
24
28
  export type InputReallocationData = InputVaultV1ReallocationData;
25
29
  /**
@@ -35,6 +39,9 @@ export type InputReallocationData = InputVaultV1ReallocationData;
35
39
  * `markets`, `vaults`, `positions`, and `vaultMarketConfigs` as a read
36
40
  * contract keyed by market id or address; use the getters for typed absence
37
41
  * errors and use simulation methods to produce updated state.
42
+ *
43
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
44
+ * `VaultV2BlueReallocationData`.
38
45
  */
39
46
  export declare class VaultV1ReallocationData implements InputVaultV1ReallocationData {
40
47
  /** Chain id associated with the fetched reallocation data. */
@@ -128,6 +135,8 @@ export declare class VaultV1ReallocationData implements InputVaultV1Reallocation
128
135
  * @param options - Optional allocator discovery options.
129
136
  * @returns Computed source-market withdrawals and the post-reallocation state.
130
137
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
138
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
139
+ * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
131
140
  * @example
132
141
  * ```ts
133
142
  * import { createPublicClient, http } from "viem";
@@ -171,7 +180,8 @@ export declare class VaultV1ReallocationData implements InputVaultV1Reallocation
171
180
  * @param options - Optional allocator discovery options.
172
181
  * @returns Computed source-market withdrawals and the post-reallocation state.
173
182
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
174
- * @deprecated Use {@link computeVaultV1Reallocations} instead.
183
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
184
+ * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
175
185
  */
176
186
  getMarketPublicReallocations(marketId: MarketId, options?: PublicAllocatorOptions): {
177
187
  readonly withdrawals: readonly PublicReallocation[];
@@ -190,6 +200,8 @@ export declare class VaultV1ReallocationData implements InputVaultV1Reallocation
190
200
  * @param options - Optional allocator discovery options.
191
201
  * @returns Total reallocatable assets in loan-token units; `0n` when none is available.
192
202
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
203
+ * @deprecated Vault V1 shared-liquidity metrics will be removed in the next major. Use
204
+ * `VaultV2BlueReallocationData.getPublicReallocationLiquidity`.
193
205
  * @example
194
206
  * ```ts
195
207
  * import { createPublicClient, http } from "viem";
@@ -241,6 +253,8 @@ export declare class VaultV1ReallocationData implements InputVaultV1Reallocation
241
253
  * @param options - Optional reallocation options (supply target utilization trigger, timestamp, withdrawal caps).
242
254
  * @returns Available liquidity to the given utilization in loan-token units; `0n` when none is available.
243
255
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
256
+ * @deprecated Vault V1 shared-liquidity metrics will be removed in the next major. Use
257
+ * `VaultV2BlueReallocationData.getAvailableLiquidityToUtilization`.
244
258
  * @example
245
259
  * ```ts
246
260
  * import { createPublicClient, http, parseEther } from "viem";
@@ -306,6 +320,7 @@ export declare class VaultV1ReallocationData implements InputVaultV1Reallocation
306
320
  /**
307
321
  * Deprecated class name for Vault V1 reallocation data.
308
322
  *
309
- * @deprecated Use {@link VaultV1ReallocationData} instead.
323
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
324
+ * `VaultV2BlueReallocationData`.
310
325
  */
311
326
  export { VaultV1ReallocationData as ReallocationData };
@@ -57,6 +57,9 @@ const cloneVaultMarketConfig = (config) => new VaultMarketConfig({
57
57
  * `markets`, `vaults`, `positions`, and `vaultMarketConfigs` as a read
58
58
  * contract keyed by market id or address; use the getters for typed absence
59
59
  * errors and use simulation methods to produce updated state.
60
+ *
61
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
62
+ * `VaultV2BlueReallocationData`.
60
63
  */
61
64
  export class VaultV1ReallocationData {
62
65
  /** Chain id associated with the fetched reallocation data. */
@@ -212,6 +215,8 @@ export class VaultV1ReallocationData {
212
215
  * @param options - Optional allocator discovery options.
213
216
  * @returns Computed source-market withdrawals and the post-reallocation state.
214
217
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
218
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
219
+ * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
215
220
  * @example
216
221
  * ```ts
217
222
  * import { createPublicClient, http } from "viem";
@@ -307,7 +312,8 @@ export class VaultV1ReallocationData {
307
312
  * @param options - Optional allocator discovery options.
308
313
  * @returns Computed source-market withdrawals and the post-reallocation state.
309
314
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
310
- * @deprecated Use {@link computeVaultV1Reallocations} instead.
315
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
316
+ * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
311
317
  */
312
318
  getMarketPublicReallocations(marketId, options = {}) {
313
319
  return this.computeVaultV1Reallocations(marketId, options);
@@ -325,6 +331,8 @@ export class VaultV1ReallocationData {
325
331
  * @param options - Optional allocator discovery options.
326
332
  * @returns Total reallocatable assets in loan-token units; `0n` when none is available.
327
333
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
334
+ * @deprecated Vault V1 shared-liquidity metrics will be removed in the next major. Use
335
+ * `VaultV2BlueReallocationData.getPublicReallocationLiquidity`.
328
336
  * @example
329
337
  * ```ts
330
338
  * import { createPublicClient, http } from "viem";
@@ -379,6 +387,8 @@ export class VaultV1ReallocationData {
379
387
  * @param options - Optional reallocation options (supply target utilization trigger, timestamp, withdrawal caps).
380
388
  * @returns Available liquidity to the given utilization in loan-token units; `0n` when none is available.
381
389
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
390
+ * @deprecated Vault V1 shared-liquidity metrics will be removed in the next major. Use
391
+ * `VaultV2BlueReallocationData.getAvailableLiquidityToUtilization`.
382
392
  * @example
383
393
  * ```ts
384
394
  * import { createPublicClient, http, parseEther } from "viem";
@@ -528,6 +538,7 @@ export class VaultV1ReallocationData {
528
538
  /**
529
539
  * Deprecated class name for Vault V1 reallocation data.
530
540
  *
531
- * @deprecated Use {@link VaultV1ReallocationData} instead.
541
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
542
+ * `VaultV2BlueReallocationData`.
532
543
  */
533
544
  export { VaultV1ReallocationData as ReallocationData };
@@ -4,7 +4,7 @@ import { getChainAddress, Time } from "@morpho-org/morpho-ts";
4
4
  import { erc20Abi, isAddressEqual } from "viem";
5
5
  import { multicall } from "viem/actions";
6
6
  import { encodeErc20Approval, encodeVaultSharesPermit, getGeneralAdapterRequirements, vaultV2Deposit, vaultV2ForceRedeem, vaultV2ForceWithdraw, vaultV2InKindRedeem, vaultV2Redeem, vaultV2Withdraw, } from "../../actions/index.js";
7
- import { validateSlippageTolerance } from "../../helpers/index.js";
7
+ import { validateChainId, validateSlippageTolerance, } from "../../helpers/index.js";
8
8
  import { AdapterNotPartOfVaultError, ChainIdMismatchError, ChainWNativeMissingError, EmptyMarketParamsListError, ExpiredDeadlineError, InKindRedeemCoverageError, InKindRedeemRequiresSingleAdapterError, InKindRedeemZeroDeallocationError, InsufficientBlueBalanceForInKindRedeemError, NativeAmountOnNonWNativeVaultError, NegativeInputError, NonPositiveInputError, selectRequirementSignatures, UnsupportedInKindAdapterError, VaultAddressMismatchError, } from "../../types/index.js";
9
9
  export class MorphoVaultV2 {
10
10
  client;
@@ -28,9 +28,7 @@ export class MorphoVaultV2 {
28
28
  });
29
29
  }
30
30
  deposit({ amount = 0n, userAddress, vaultData, slippageTolerance = DEFAULT_SLIPPAGE_TOLERANCE, nativeAmount, }) {
31
- if (this.client.viemClient.chain?.id !== this.chainId) {
32
- throw new ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
33
- }
31
+ validateChainId(this.client.viemClient.chain?.id, this.chainId);
34
32
  if (!isAddressEqual(vaultData.address, this.vault)) {
35
33
  throw new VaultAddressMismatchError(this.vault, vaultData.address);
36
34
  }
@@ -101,9 +99,7 @@ export class MorphoVaultV2 {
101
99
  };
102
100
  }
103
101
  withdraw({ amount, userAddress }) {
104
- if (this.client.viemClient.chain?.id !== this.chainId) {
105
- throw new ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
106
- }
102
+ validateChainId(this.client.viemClient.chain?.id, this.chainId);
107
103
  return {
108
104
  buildTx: () => vaultV2Withdraw({
109
105
  vault: { address: this.vault },
@@ -117,9 +113,7 @@ export class MorphoVaultV2 {
117
113
  };
118
114
  }
119
115
  redeem({ shares, userAddress }) {
120
- if (this.client.viemClient.chain?.id !== this.chainId) {
121
- throw new ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
122
- }
116
+ validateChainId(this.client.viemClient.chain?.id, this.chainId);
123
117
  return {
124
118
  buildTx: () => vaultV2Redeem({
125
119
  vault: { address: this.vault },
@@ -134,9 +128,7 @@ export class MorphoVaultV2 {
134
128
  }
135
129
  /** {@inheritDoc VaultV2Actions.inKindRedeem} */
136
130
  inKindRedeem({ amount, marketParamsList, vaultData, userAddress, adapter: adapterOverride, deadline: deadlineOverride, }) {
137
- if (this.client.viemClient.chain?.id !== this.chainId) {
138
- throw new ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
139
- }
131
+ validateChainId(this.client.viemClient.chain?.id, this.chainId);
140
132
  if (!isAddressEqual(vaultData.address, this.vault)) {
141
133
  throw new VaultAddressMismatchError(this.vault, vaultData.address);
142
134
  }
@@ -313,9 +305,7 @@ export class MorphoVaultV2 {
313
305
  };
314
306
  }
315
307
  forceWithdraw({ deallocations, withdraw, userAddress, }) {
316
- if (this.client.viemClient.chain?.id !== this.chainId) {
317
- throw new ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
318
- }
308
+ validateChainId(this.client.viemClient.chain?.id, this.chainId);
319
309
  return {
320
310
  buildTx: () => vaultV2ForceWithdraw({
321
311
  vault: { address: this.vault },
@@ -332,9 +322,7 @@ export class MorphoVaultV2 {
332
322
  };
333
323
  }
334
324
  forceRedeem({ deallocations, redeem, userAddress, }) {
335
- if (this.client.viemClient.chain?.id !== this.chainId) {
336
- throw new ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
337
- }
325
+ validateChainId(this.client.viemClient.chain?.id, this.chainId);
338
326
  return {
339
327
  buildTx: () => vaultV2ForceRedeem({
340
328
  vault: { address: this.vault },
@@ -104,7 +104,11 @@ const cloneAdapter = (adapter, markets) => {
104
104
  if (adapter instanceof AccrualVaultV2MorphoMarketV1Adapter)
105
105
  return new AccrualVaultV2MorphoMarketV1Adapter({ ...base, marketParamsList: [...adapter.marketParamsList] }, adapter.positions.map((position) => clonePosition(position, markets)));
106
106
  if (adapter instanceof AccrualVaultV2MorphoVaultV1Adapter)
107
- return new AccrualVaultV2MorphoVaultV1Adapter({ ...base, morphoVaultV1: adapter.morphoVaultV1 }, cloneAccrualVault(adapter.accrualVaultV1, markets), adapter.shares);
107
+ return new AccrualVaultV2MorphoVaultV1Adapter({
108
+ ...base,
109
+ morphoVaultV1: adapter.morphoVaultV1,
110
+ parentAllocation: adapter.parentAllocation,
111
+ }, cloneAccrualVault(adapter.accrualVaultV1, markets), adapter.shares);
108
112
  throw new UnsupportedVaultV2AdapterError(adapter.address);
109
113
  };
110
114
  const cloneVault = (vault, { markets, adapterKeysToClone, }) => {
@@ -25,6 +25,8 @@ import { type ReallocationComputeOptions, type VaultV1Reallocation } from "../ty
25
25
  * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market — preventing fee-bearing reallocations from being attached to a call that would still revert onchain.
26
26
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets` — the on-chain call would revert regardless of reallocations.
27
27
  * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
28
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
29
+ * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
28
30
  * @example
29
31
  * ```ts
30
32
  * import { createPublicClient, http, parseUnits } from "viem";
@@ -76,6 +78,7 @@ export declare const computeVaultV1Reallocations: ({ reallocationData: data, mar
76
78
  /**
77
79
  * Deprecated name for the Vault V1 amount-aware reallocation planner.
78
80
  *
79
- * @deprecated Use {@link computeVaultV1Reallocations} instead.
81
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
82
+ * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
80
83
  */
81
84
  export declare const computeReallocations: typeof computeVaultV1Reallocations;
@@ -78,6 +78,8 @@ const capVaultWithdrawals = (withdrawals, assets) => {
78
78
  * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market — preventing fee-bearing reallocations from being attached to a call that would still revert onchain.
79
79
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets` — the on-chain call would revert regardless of reallocations.
80
80
  * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
81
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
82
+ * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
81
83
  * @example
82
84
  * ```ts
83
85
  * import { createPublicClient, http, parseUnits } from "viem";
@@ -237,6 +239,7 @@ export const computeVaultV1Reallocations = ({ reallocationData: data, marketId,
237
239
  /**
238
240
  * Deprecated name for the Vault V1 amount-aware reallocation planner.
239
241
  *
240
- * @deprecated Use {@link computeVaultV1Reallocations} instead.
242
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
243
+ * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
241
244
  */
242
245
  export const computeReallocations = computeVaultV1Reallocations;
@@ -26,11 +26,9 @@ import type { Metadata } from "../types/index.js";
26
26
  * @param {Metadata} metadata - An object containing optional metadata fields
27
27
  * such as `timestamp` and `origin`.
28
28
  *
29
- * @returns {Object} - A new transaction object with the modified `data` field
30
- * including the concatenated metadata.
31
- *
32
- * If no `data` is present in the original transaction, the function returns
33
- * the transaction unmodified.
29
+ * @returns The same `tx` object when `data` is missing, an empty string, or
30
+ * canonical empty calldata (`"0x"`); otherwise, a new transaction object
31
+ * with `data` containing any appended metadata. The input is never mutated.
34
32
  */
35
33
  export declare function addTransactionMetadata(tx: {
36
34
  data: Hex;
@@ -26,15 +26,13 @@ import { concatHex, isHex, numberToHex } from "viem";
26
26
  * @param {Metadata} metadata - An object containing optional metadata fields
27
27
  * such as `timestamp` and `origin`.
28
28
  *
29
- * @returns {Object} - A new transaction object with the modified `data` field
30
- * including the concatenated metadata.
31
- *
32
- * If no `data` is present in the original transaction, the function returns
33
- * the transaction unmodified.
29
+ * @returns The same `tx` object when `data` is missing, an empty string, or
30
+ * canonical empty calldata (`"0x"`); otherwise, a new transaction object
31
+ * with `data` containing any appended metadata. The input is never mutated.
34
32
  */
35
33
  export function addTransactionMetadata(tx, metadata) {
36
34
  const { data, ..._tx } = tx;
37
- if (!data)
35
+ if (!data || data === "0x")
38
36
  return tx;
39
37
  const concatItems = [data];
40
38
  if (metadata.timestamp) {
@@ -148,6 +148,8 @@ export declare const validateRepayShares: (params: {
148
148
  * @throws {NonPositiveInputError} when a withdrawal amount is non-positive.
149
149
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a withdrawal references the target market.
150
150
  * @throws {UnsortedReallocationWithdrawalsError} when withdrawals are not strictly market-id sorted.
151
+ * @deprecated Vault V1 PublicAllocator validation will be removed in the next major. Use Vault V2
152
+ * reallocations for new integrations.
151
153
  * @example
152
154
  * ```ts
153
155
  * import type { BlueMarketId } from "@morpho-org/morpho-sdk/types";
@@ -228,6 +228,8 @@ export const validateRepayShares = (params) => {
228
228
  * @throws {NonPositiveInputError} when a withdrawal amount is non-positive.
229
229
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a withdrawal references the target market.
230
230
  * @throws {UnsortedReallocationWithdrawalsError} when withdrawals are not strictly market-id sorted.
231
+ * @deprecated Vault V1 PublicAllocator validation will be removed in the next major. Use Vault V2
232
+ * reallocations for new integrations.
231
233
  * @example
232
234
  * ```ts
233
235
  * import type { BlueMarketId } from "@morpho-org/morpho-sdk/types";
@@ -524,7 +524,11 @@ export declare class MarketIdMismatchError extends Error {
524
524
  export declare class AccrualPositionUserMismatchError extends Error {
525
525
  constructor(positionUser: string, expectedUser: string);
526
526
  }
527
- /** Thrown when a reallocation has no withdrawals. */
527
+ /**
528
+ * Thrown when a reallocation has no withdrawals.
529
+ *
530
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
531
+ */
528
532
  export declare class EmptyReallocationWithdrawalsError extends Error {
529
533
  constructor(vault: string);
530
534
  }
@@ -536,6 +540,8 @@ export declare class ReallocationWithdrawalOnTargetMarketError extends Error {
536
540
  * Thrown when a Public Allocator reallocation does not match exactly one V1 or
537
541
  * V2 input shape.
538
542
  *
543
+ * @deprecated Vault V1/V2 reallocation-shape dispatch will be removed in the next major. Use Vault
544
+ * V2 reallocations.
539
545
  * @example
540
546
  * ```ts
541
547
  * import { InvalidReallocationShapeError } from "@morpho-org/morpho-sdk";
@@ -549,6 +555,8 @@ export declare class InvalidReallocationShapeError extends Error {
549
555
  /**
550
556
  * Thrown when one reallocation plan contains both Vault V1 and Vault V2 entries.
551
557
  *
558
+ * @deprecated Vault V1/V2 mixed-plan support will be removed in the next major. Use Vault V2
559
+ * reallocations.
552
560
  * @example
553
561
  * ```ts
554
562
  * import { MixedReallocationVersionsError } from "@morpho-org/morpho-sdk";
@@ -637,7 +645,11 @@ export declare class InconsistentReallocationPenaltyError extends Error {
637
645
  readonly actual: bigint;
638
646
  });
639
647
  }
640
- /** Thrown when reallocation withdrawals within a vault are not strictly sorted by market id. */
648
+ /**
649
+ * Thrown when reallocation withdrawals within a vault are not strictly sorted by market id.
650
+ *
651
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
652
+ */
641
653
  export declare class UnsortedReallocationWithdrawalsError extends Error {
642
654
  constructor(vault: string, marketId: string);
643
655
  }
@@ -697,11 +709,19 @@ export declare class RepaySharesExceedDebtError extends Error {
697
709
  market: string;
698
710
  });
699
711
  }
700
- /** Thrown when a vault selected for reallocation has no configured `PublicAllocator`. */
712
+ /**
713
+ * Thrown when a vault selected for reallocation has no configured `PublicAllocator`.
714
+ *
715
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
716
+ */
701
717
  export declare class MissingPublicAllocatorConfigError extends Error {
702
718
  constructor(vault: string);
703
719
  }
704
- /** Thrown when a reallocation attempts to use a disabled vault market. */
720
+ /**
721
+ * Thrown when a reallocation attempts to use a disabled vault market.
722
+ *
723
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
724
+ */
705
725
  export declare class DisabledReallocationMarketError extends Error {
706
726
  readonly vault: Address;
707
727
  readonly marketId: MarketId;
@@ -742,7 +762,11 @@ export declare class UnknownReallocationVaultError extends UnknownDataError {
742
762
  */
743
763
  constructor(vault: Address);
744
764
  }
745
- /** Thrown when reallocation state does not contain a requested vault-market config. */
765
+ /**
766
+ * Thrown when reallocation state does not contain a requested vault-market config.
767
+ *
768
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major.
769
+ */
746
770
  export declare class UnknownReallocationVaultMarketConfigError extends UnknownDataError {
747
771
  readonly vault: Address;
748
772
  readonly marketId: MarketId;
@@ -752,7 +776,11 @@ export declare class UnknownReallocationVaultMarketConfigError extends UnknownDa
752
776
  */
753
777
  constructor(vault: Address, marketId: MarketId);
754
778
  }
755
- /** Thrown when reallocation state does not contain a requested market position. */
779
+ /**
780
+ * Thrown when reallocation state does not contain a requested market position.
781
+ *
782
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major.
783
+ */
756
784
  export declare class UnknownReallocationPositionError extends UnknownDataError {
757
785
  readonly user: Address;
758
786
  readonly marketId: MarketId;
@@ -587,7 +587,11 @@ export class AccrualPositionUserMismatchError extends Error {
587
587
  super(`Accrual position user ${positionUser} does not match expected user ${expectedUser}`);
588
588
  }
589
589
  }
590
- /** Thrown when a reallocation has no withdrawals. */
590
+ /**
591
+ * Thrown when a reallocation has no withdrawals.
592
+ *
593
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
594
+ */
591
595
  export class EmptyReallocationWithdrawalsError extends Error {
592
596
  constructor(vault) {
593
597
  super(`Reallocation withdrawals list cannot be empty for vault: ${vault}`);
@@ -603,6 +607,8 @@ export class ReallocationWithdrawalOnTargetMarketError extends Error {
603
607
  * Thrown when a Public Allocator reallocation does not match exactly one V1 or
604
608
  * V2 input shape.
605
609
  *
610
+ * @deprecated Vault V1/V2 reallocation-shape dispatch will be removed in the next major. Use Vault
611
+ * V2 reallocations.
606
612
  * @example
607
613
  * ```ts
608
614
  * import { InvalidReallocationShapeError } from "@morpho-org/morpho-sdk";
@@ -619,6 +625,8 @@ export class InvalidReallocationShapeError extends Error {
619
625
  /**
620
626
  * Thrown when one reallocation plan contains both Vault V1 and Vault V2 entries.
621
627
  *
628
+ * @deprecated Vault V1/V2 mixed-plan support will be removed in the next major. Use Vault V2
629
+ * reallocations.
622
630
  * @example
623
631
  * ```ts
624
632
  * import { MixedReallocationVersionsError } from "@morpho-org/morpho-sdk";
@@ -725,7 +733,11 @@ export class InconsistentReallocationPenaltyError extends Error {
725
733
  this.name = "InconsistentReallocationPenaltyError";
726
734
  }
727
735
  }
728
- /** Thrown when reallocation withdrawals within a vault are not strictly sorted by market id. */
736
+ /**
737
+ * Thrown when reallocation withdrawals within a vault are not strictly sorted by market id.
738
+ *
739
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
740
+ */
729
741
  export class UnsortedReallocationWithdrawalsError extends Error {
730
742
  constructor(vault, marketId) {
731
743
  super(`Reallocation withdrawals must be strictly sorted by market ID for vault ${vault}. Market ${marketId} is out of order.`);
@@ -783,13 +795,21 @@ export class RepaySharesExceedDebtError extends Error {
783
795
  super(`Repay shares ${params.repayShares} exceed outstanding borrow shares ${params.borrowShares} for market: ${params.market}`);
784
796
  }
785
797
  }
786
- /** Thrown when a vault selected for reallocation has no configured `PublicAllocator`. */
798
+ /**
799
+ * Thrown when a vault selected for reallocation has no configured `PublicAllocator`.
800
+ *
801
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
802
+ */
787
803
  export class MissingPublicAllocatorConfigError extends Error {
788
804
  constructor(vault) {
789
805
  super(`Vault ${vault} has no public allocator configured but was selected for reallocation`);
790
806
  }
791
807
  }
792
- /** Thrown when a reallocation attempts to use a disabled vault market. */
808
+ /**
809
+ * Thrown when a reallocation attempts to use a disabled vault market.
810
+ *
811
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
812
+ */
793
813
  export class DisabledReallocationMarketError extends Error {
794
814
  vault;
795
815
  marketId;
@@ -835,7 +855,11 @@ export class UnknownReallocationVaultError extends UnknownDataError {
835
855
  this.vault = vault;
836
856
  }
837
857
  }
838
- /** Thrown when reallocation state does not contain a requested vault-market config. */
858
+ /**
859
+ * Thrown when reallocation state does not contain a requested vault-market config.
860
+ *
861
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major.
862
+ */
839
863
  export class UnknownReallocationVaultMarketConfigError extends UnknownDataError {
840
864
  vault;
841
865
  marketId;
@@ -849,7 +873,11 @@ export class UnknownReallocationVaultMarketConfigError extends UnknownDataError
849
873
  this.marketId = marketId;
850
874
  }
851
875
  }
852
- /** Thrown when reallocation state does not contain a requested market position. */
876
+ /**
877
+ * Thrown when reallocation state does not contain a requested market position.
878
+ *
879
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major.
880
+ */
853
881
  export class UnknownReallocationPositionError extends UnknownDataError {
854
882
  user;
855
883
  marketId;
@@ -2,6 +2,9 @@ import type { BigIntish, MarketId, MarketParams } from "@morpho-org/blue-sdk";
2
2
  import type { Address } from "viem";
3
3
  /**
4
4
  * Options controlling public allocator withdrawal discovery.
5
+ *
6
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
7
+ * {@link VaultV2BluePublicAllocatorOptions}.
5
8
  */
6
9
  export interface PublicAllocatorOptions {
7
10
  /** Whether public allocator reallocation discovery is enabled. */
@@ -63,6 +66,9 @@ export interface VaultV2BluePublicAllocatorOptions {
63
66
  }
64
67
  /**
65
68
  * A computed source-market withdrawal before it is grouped by vault.
69
+ *
70
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
71
+ * {@link VaultV2BlueReallocation}.
66
72
  */
67
73
  export interface PublicReallocation {
68
74
  /** Source market id to withdraw from. */
@@ -72,7 +78,12 @@ export interface PublicReallocation {
72
78
  /** Assets to withdraw from the source market. */
73
79
  readonly assets: bigint;
74
80
  }
75
- /** A single withdrawal from a source market within a vault reallocation. */
81
+ /**
82
+ * A single withdrawal from a source market within a vault reallocation.
83
+ *
84
+ * @deprecated Vault V1 shared-liquidity support will be removed in the next major. Use
85
+ * {@link VaultV2BlueReallocation}.
86
+ */
76
87
  export interface ReallocationWithdrawal {
77
88
  /** Source market parameters to pass to the public allocator. */
78
89
  readonly marketParams: MarketParams;
@@ -84,6 +95,9 @@ export interface ReallocationWithdrawal {
84
95
  *
85
96
  * Maps 1:1 to a `PublicAllocator.reallocateTo()` call.
86
97
  * Withdraws from source markets and supplies to the target market.
98
+ *
99
+ * @deprecated Vault V1 shared-liquidity support will be removed in the next major. Use
100
+ * {@link VaultV2BlueReallocation}.
87
101
  */
88
102
  export interface VaultV1Reallocation {
89
103
  readonly vault: Address;
@@ -123,12 +137,18 @@ export interface VaultV2BlueReallocation {
123
137
  /** Vault-configured WAD-scaled penalty rate passed to the allocator. */
124
138
  readonly penalty: bigint;
125
139
  }
126
- /** A homogeneous Blue action plan containing only Vault V1 or only Vault V2 reallocations. */
140
+ /**
141
+ * A homogeneous Blue action plan containing only Vault V1 or only Vault V2 reallocations.
142
+ *
143
+ * Vault V1 members are deprecated for high-level Blue writes and will stop being accepted in the
144
+ * next major. Use Vault V2 members for new high-level integrations.
145
+ */
127
146
  export type BlueReallocationPlan = Iterable<VaultV1Reallocation> | Iterable<VaultV2BlueReallocation>;
128
147
  /**
129
148
  * Deprecated name for a Vault V1 reallocation.
130
149
  *
131
- * @deprecated Use {@link VaultV1Reallocation} instead.
150
+ * @deprecated Vault V1 shared-liquidity support will be removed in the next major. Use
151
+ * {@link VaultV2BlueReallocation}.
132
152
  */
133
153
  export type VaultReallocation = VaultV1Reallocation;
134
154
  /**
@@ -136,6 +156,9 @@ export type VaultReallocation = VaultV1Reallocation;
136
156
  *
137
157
  * Extends {@link PublicAllocatorOptions} with supply-side utilization targets
138
158
  * that determine when reallocation is triggered.
159
+ *
160
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
161
+ * {@link VaultV2BluePublicAllocatorOptions}.
139
162
  */
140
163
  export interface ReallocationComputeOptions extends PublicAllocatorOptions {
141
164
  /**
@@ -9,7 +9,9 @@ MaxBorrowOptions, MaxPositionCapacities as BlueMaxPositionCapacities,
9
9
  MaxPositionCapacities, MaxWithdrawCollateralOptions as BlueMaxWithdrawCollateralOptions,
10
10
  /** @deprecated Use `BlueMaxWithdrawCollateralOptions` or the raw `/blue/types` subpath. */
11
11
  MaxWithdrawCollateralOptions, Pending, Permit2Allowance, } from "@morpho-org/blue-sdk";
12
- export type { AuthorizationArgs as BlueAuthorizationTypedDataArgs, DaiPermitArgs, DeploylessFetchParameters as BlueDeploylessFetchParameters,
12
+ export type { AuthorizationArgs as BlueAuthorizationTypedDataArgs,
13
+ /** @deprecated Args for the deprecated getDaiPermitTypedData; scheduled for removal in the next major. */
14
+ DaiPermitArgs, DeploylessFetchParameters as BlueDeploylessFetchParameters,
13
15
  /** @deprecated Use `BlueDeploylessFetchParameters` or the raw `/blue/types` subpath. */
14
16
  DeploylessFetchParameters, FetchParameters as BlueFetchParameters,
15
17
  /** @deprecated Use `BlueFetchParameters` or the raw `/blue/types` subpath. */