@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
@@ -32,9 +32,7 @@ class MorphoVaultV1 {
32
32
  });
33
33
  }
34
34
  deposit({ amount = 0n, userAddress, vaultData, slippageTolerance = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, nativeAmount, }) {
35
- if (this.client.viemClient.chain?.id !== this.chainId) {
36
- throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
37
- }
35
+ (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
38
36
  if (!(0, viem_1.isAddressEqual)(vaultData.address, this.vault)) {
39
37
  throw new index_js_3.VaultAddressMismatchError(this.vault, vaultData.address);
40
38
  }
@@ -101,9 +99,7 @@ class MorphoVaultV1 {
101
99
  };
102
100
  }
103
101
  withdraw({ amount, userAddress }) {
104
- if (this.client.viemClient.chain?.id !== this.chainId) {
105
- throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
106
- }
102
+ (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
107
103
  return {
108
104
  buildTx: () => (0, index_js_1.vaultV1Withdraw)({
109
105
  vault: { address: this.vault },
@@ -117,9 +113,7 @@ class MorphoVaultV1 {
117
113
  };
118
114
  }
119
115
  redeem({ shares, userAddress }) {
120
- if (this.client.viemClient.chain?.id !== this.chainId) {
121
- throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
122
- }
116
+ (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
123
117
  return {
124
118
  buildTx: () => (0, index_js_1.vaultV1Redeem)({
125
119
  vault: { address: this.vault },
@@ -134,9 +128,7 @@ class MorphoVaultV1 {
134
128
  }
135
129
  /** {@inheritDoc VaultV1Actions.inKindRedeem} */
136
130
  inKindRedeem({ amount, marketParamsList, vaultData, userAddress, deadline: deadlineOverride, }) {
137
- if (this.client.viemClient.chain?.id !== this.chainId) {
138
- throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
139
- }
131
+ (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
140
132
  if (!(0, viem_1.isAddressEqual)(vaultData.address, this.vault)) {
141
133
  throw new index_js_3.VaultAddressMismatchError(this.vault, vaultData.address);
142
134
  }
@@ -295,6 +287,7 @@ class MorphoVaultV1 {
295
287
  },
296
288
  };
297
289
  }
290
+ /** {@inheritDoc VaultV1Actions.migrateToV2} */
298
291
  migrateToV2({ userAddress, sourceVault, targetVault, shares, slippageTolerance = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, }) {
299
292
  (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
300
293
  if (!(0, viem_1.isAddressEqual)(sourceVault.address, this.vault)) {
@@ -307,8 +300,12 @@ class MorphoVaultV1 {
307
300
  throw new index_js_3.NonPositiveInputError("shares", shares);
308
301
  }
309
302
  (0, index_js_2.validateSlippageTolerance)(slippageTolerance);
310
- // Compute minSharePriceVaultV1 for V1 redeem (slippage downward)
311
- const v1RefAssets = sourceVault.toAssets(shares);
303
+ // V1 redeem accrues pending market interest and performance fees before converting shares.
304
+ const sourceAccrualTimestamp = sourceVault.allocations
305
+ .values()
306
+ .reduce((timestamp, { position }) => blue_sdk_1.MathLib.max(timestamp, position.market.lastUpdate), morpho_ts_1.Time.timestamp());
307
+ const accruedSourceVault = sourceVault.accrueInterest(sourceAccrualTimestamp);
308
+ const v1RefAssets = accruedSourceVault.toAssets(shares);
312
309
  const minSharePriceVaultV1 = blue_sdk_1.MathLib.mulDivDown(v1RefAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - slippageTolerance), shares);
313
310
  // Compute maxSharePriceVaultV2 for V2 deposit (slippage upward).
314
311
  // 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 };
@@ -60,6 +60,9 @@ const cloneVaultMarketConfig = (config) => new blue_sdk_1.VaultMarketConfig({
60
60
  * `markets`, `vaults`, `positions`, and `vaultMarketConfigs` as a read
61
61
  * contract keyed by market id or address; use the getters for typed absence
62
62
  * errors and use simulation methods to produce updated state.
63
+ *
64
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
65
+ * `VaultV2BlueReallocationData`.
63
66
  */
64
67
  class VaultV1ReallocationData {
65
68
  /** Chain id associated with the fetched reallocation data. */
@@ -215,6 +218,8 @@ class VaultV1ReallocationData {
215
218
  * @param options - Optional allocator discovery options.
216
219
  * @returns Computed source-market withdrawals and the post-reallocation state.
217
220
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
221
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
222
+ * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
218
223
  * @example
219
224
  * ```ts
220
225
  * import { createPublicClient, http } from "viem";
@@ -310,7 +315,8 @@ class VaultV1ReallocationData {
310
315
  * @param options - Optional allocator discovery options.
311
316
  * @returns Computed source-market withdrawals and the post-reallocation state.
312
317
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
313
- * @deprecated Use {@link computeVaultV1Reallocations} instead.
318
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
319
+ * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
314
320
  */
315
321
  getMarketPublicReallocations(marketId, options = {}) {
316
322
  return this.computeVaultV1Reallocations(marketId, options);
@@ -328,6 +334,8 @@ class VaultV1ReallocationData {
328
334
  * @param options - Optional allocator discovery options.
329
335
  * @returns Total reallocatable assets in loan-token units; `0n` when none is available.
330
336
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
337
+ * @deprecated Vault V1 shared-liquidity metrics will be removed in the next major. Use
338
+ * `VaultV2BlueReallocationData.getPublicReallocationLiquidity`.
331
339
  * @example
332
340
  * ```ts
333
341
  * import { createPublicClient, http } from "viem";
@@ -382,6 +390,8 @@ class VaultV1ReallocationData {
382
390
  * @param options - Optional reallocation options (supply target utilization trigger, timestamp, withdrawal caps).
383
391
  * @returns Available liquidity to the given utilization in loan-token units; `0n` when none is available.
384
392
  * @throws {@link UnknownReallocationMarketError} when the target market is absent.
393
+ * @deprecated Vault V1 shared-liquidity metrics will be removed in the next major. Use
394
+ * `VaultV2BlueReallocationData.getAvailableLiquidityToUtilization`.
385
395
  * @example
386
396
  * ```ts
387
397
  * import { createPublicClient, http, parseEther } from "viem";
@@ -31,9 +31,7 @@ class MorphoVaultV2 {
31
31
  });
32
32
  }
33
33
  deposit({ amount = 0n, userAddress, vaultData, slippageTolerance = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, nativeAmount, }) {
34
- if (this.client.viemClient.chain?.id !== this.chainId) {
35
- throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
36
- }
34
+ (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
37
35
  if (!(0, viem_1.isAddressEqual)(vaultData.address, this.vault)) {
38
36
  throw new index_js_3.VaultAddressMismatchError(this.vault, vaultData.address);
39
37
  }
@@ -104,9 +102,7 @@ class MorphoVaultV2 {
104
102
  };
105
103
  }
106
104
  withdraw({ amount, userAddress }) {
107
- if (this.client.viemClient.chain?.id !== this.chainId) {
108
- throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
109
- }
105
+ (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
110
106
  return {
111
107
  buildTx: () => (0, index_js_1.vaultV2Withdraw)({
112
108
  vault: { address: this.vault },
@@ -120,9 +116,7 @@ class MorphoVaultV2 {
120
116
  };
121
117
  }
122
118
  redeem({ shares, userAddress }) {
123
- if (this.client.viemClient.chain?.id !== this.chainId) {
124
- throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
125
- }
119
+ (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
126
120
  return {
127
121
  buildTx: () => (0, index_js_1.vaultV2Redeem)({
128
122
  vault: { address: this.vault },
@@ -137,9 +131,7 @@ class MorphoVaultV2 {
137
131
  }
138
132
  /** {@inheritDoc VaultV2Actions.inKindRedeem} */
139
133
  inKindRedeem({ amount, marketParamsList, vaultData, userAddress, adapter: adapterOverride, deadline: deadlineOverride, }) {
140
- if (this.client.viemClient.chain?.id !== this.chainId) {
141
- throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
142
- }
134
+ (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
143
135
  if (!(0, viem_1.isAddressEqual)(vaultData.address, this.vault)) {
144
136
  throw new index_js_3.VaultAddressMismatchError(this.vault, vaultData.address);
145
137
  }
@@ -316,9 +308,7 @@ class MorphoVaultV2 {
316
308
  };
317
309
  }
318
310
  forceWithdraw({ deallocations, withdraw, userAddress, }) {
319
- if (this.client.viemClient.chain?.id !== this.chainId) {
320
- throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
321
- }
311
+ (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
322
312
  return {
323
313
  buildTx: () => (0, index_js_1.vaultV2ForceWithdraw)({
324
314
  vault: { address: this.vault },
@@ -335,9 +325,7 @@ class MorphoVaultV2 {
335
325
  };
336
326
  }
337
327
  forceRedeem({ deallocations, redeem, userAddress, }) {
338
- if (this.client.viemClient.chain?.id !== this.chainId) {
339
- throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
340
- }
328
+ (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
341
329
  return {
342
330
  buildTx: () => (0, index_js_1.vaultV2ForceRedeem)({
343
331
  vault: { address: this.vault },
@@ -107,7 +107,11 @@ const cloneAdapter = (adapter, markets) => {
107
107
  if (adapter instanceof blue_sdk_1.AccrualVaultV2MorphoMarketV1Adapter)
108
108
  return new blue_sdk_1.AccrualVaultV2MorphoMarketV1Adapter({ ...base, marketParamsList: [...adapter.marketParamsList] }, adapter.positions.map((position) => clonePosition(position, markets)));
109
109
  if (adapter instanceof blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter)
110
- return new blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter({ ...base, morphoVaultV1: adapter.morphoVaultV1 }, cloneAccrualVault(adapter.accrualVaultV1, markets), adapter.shares);
110
+ return new blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter({
111
+ ...base,
112
+ morphoVaultV1: adapter.morphoVaultV1,
113
+ parentAllocation: adapter.parentAllocation,
114
+ }, cloneAccrualVault(adapter.accrualVaultV1, markets), adapter.shares);
111
115
  throw new blue_sdk_1.UnsupportedVaultV2AdapterError(adapter.address);
112
116
  };
113
117
  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;
@@ -81,6 +81,8 @@ const capVaultWithdrawals = (withdrawals, assets) => {
81
81
  * @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.
82
82
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets` — the on-chain call would revert regardless of reallocations.
83
83
  * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
84
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
85
+ * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
84
86
  * @example
85
87
  * ```ts
86
88
  * import { createPublicClient, http, parseUnits } from "viem";
@@ -241,6 +243,7 @@ exports.computeVaultV1Reallocations = computeVaultV1Reallocations;
241
243
  /**
242
244
  * Deprecated name for the Vault V1 amount-aware reallocation planner.
243
245
  *
244
- * @deprecated Use {@link computeVaultV1Reallocations} instead.
246
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
247
+ * `VaultV2BlueReallocationData.computeVaultV2BlueReallocations`.
245
248
  */
246
249
  exports.computeReallocations = exports.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;
@@ -29,15 +29,13 @@ const viem_1 = require("viem");
29
29
  * @param {Metadata} metadata - An object containing optional metadata fields
30
30
  * such as `timestamp` and `origin`.
31
31
  *
32
- * @returns {Object} - A new transaction object with the modified `data` field
33
- * including the concatenated metadata.
34
- *
35
- * If no `data` is present in the original transaction, the function returns
36
- * the transaction unmodified.
32
+ * @returns The same `tx` object when `data` is missing, an empty string, or
33
+ * canonical empty calldata (`"0x"`); otherwise, a new transaction object
34
+ * with `data` containing any appended metadata. The input is never mutated.
37
35
  */
38
36
  function addTransactionMetadata(tx, metadata) {
39
37
  const { data, ..._tx } = tx;
40
- if (!data)
38
+ if (!data || data === "0x")
41
39
  return tx;
42
40
  const concatItems = [data];
43
41
  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";
@@ -241,6 +241,8 @@ exports.validateRepayShares = validateRepayShares;
241
241
  * @throws {NonPositiveInputError} when a withdrawal amount is non-positive.
242
242
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a withdrawal references the target market.
243
243
  * @throws {UnsortedReallocationWithdrawalsError} when withdrawals are not strictly market-id sorted.
244
+ * @deprecated Vault V1 PublicAllocator validation will be removed in the next major. Use Vault V2
245
+ * reallocations for new integrations.
244
246
  * @example
245
247
  * ```ts
246
248
  * 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;
@@ -631,7 +631,11 @@ class AccrualPositionUserMismatchError extends Error {
631
631
  }
632
632
  }
633
633
  exports.AccrualPositionUserMismatchError = AccrualPositionUserMismatchError;
634
- /** Thrown when a reallocation has no withdrawals. */
634
+ /**
635
+ * Thrown when a reallocation has no withdrawals.
636
+ *
637
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
638
+ */
635
639
  class EmptyReallocationWithdrawalsError extends Error {
636
640
  constructor(vault) {
637
641
  super(`Reallocation withdrawals list cannot be empty for vault: ${vault}`);
@@ -649,6 +653,8 @@ exports.ReallocationWithdrawalOnTargetMarketError = ReallocationWithdrawalOnTarg
649
653
  * Thrown when a Public Allocator reallocation does not match exactly one V1 or
650
654
  * V2 input shape.
651
655
  *
656
+ * @deprecated Vault V1/V2 reallocation-shape dispatch will be removed in the next major. Use Vault
657
+ * V2 reallocations.
652
658
  * @example
653
659
  * ```ts
654
660
  * import { InvalidReallocationShapeError } from "@morpho-org/morpho-sdk";
@@ -666,6 +672,8 @@ exports.InvalidReallocationShapeError = InvalidReallocationShapeError;
666
672
  /**
667
673
  * Thrown when one reallocation plan contains both Vault V1 and Vault V2 entries.
668
674
  *
675
+ * @deprecated Vault V1/V2 mixed-plan support will be removed in the next major. Use Vault V2
676
+ * reallocations.
669
677
  * @example
670
678
  * ```ts
671
679
  * import { MixedReallocationVersionsError } from "@morpho-org/morpho-sdk";
@@ -776,7 +784,11 @@ class InconsistentReallocationPenaltyError extends Error {
776
784
  }
777
785
  }
778
786
  exports.InconsistentReallocationPenaltyError = InconsistentReallocationPenaltyError;
779
- /** Thrown when reallocation withdrawals within a vault are not strictly sorted by market id. */
787
+ /**
788
+ * Thrown when reallocation withdrawals within a vault are not strictly sorted by market id.
789
+ *
790
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
791
+ */
780
792
  class UnsortedReallocationWithdrawalsError extends Error {
781
793
  constructor(vault, marketId) {
782
794
  super(`Reallocation withdrawals must be strictly sorted by market ID for vault ${vault}. Market ${marketId} is out of order.`);
@@ -843,14 +855,22 @@ class RepaySharesExceedDebtError extends Error {
843
855
  }
844
856
  }
845
857
  exports.RepaySharesExceedDebtError = RepaySharesExceedDebtError;
846
- /** Thrown when a vault selected for reallocation has no configured `PublicAllocator`. */
858
+ /**
859
+ * Thrown when a vault selected for reallocation has no configured `PublicAllocator`.
860
+ *
861
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
862
+ */
847
863
  class MissingPublicAllocatorConfigError extends Error {
848
864
  constructor(vault) {
849
865
  super(`Vault ${vault} has no public allocator configured but was selected for reallocation`);
850
866
  }
851
867
  }
852
868
  exports.MissingPublicAllocatorConfigError = MissingPublicAllocatorConfigError;
853
- /** Thrown when a reallocation attempts to use a disabled vault market. */
869
+ /**
870
+ * Thrown when a reallocation attempts to use a disabled vault market.
871
+ *
872
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
873
+ */
854
874
  class DisabledReallocationMarketError extends Error {
855
875
  vault;
856
876
  marketId;
@@ -900,7 +920,11 @@ class UnknownReallocationVaultError extends blue_sdk_1.UnknownDataError {
900
920
  }
901
921
  }
902
922
  exports.UnknownReallocationVaultError = UnknownReallocationVaultError;
903
- /** Thrown when reallocation state does not contain a requested vault-market config. */
923
+ /**
924
+ * Thrown when reallocation state does not contain a requested vault-market config.
925
+ *
926
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major.
927
+ */
904
928
  class UnknownReallocationVaultMarketConfigError extends blue_sdk_1.UnknownDataError {
905
929
  vault;
906
930
  marketId;
@@ -915,7 +939,11 @@ class UnknownReallocationVaultMarketConfigError extends blue_sdk_1.UnknownDataEr
915
939
  }
916
940
  }
917
941
  exports.UnknownReallocationVaultMarketConfigError = UnknownReallocationVaultMarketConfigError;
918
- /** Thrown when reallocation state does not contain a requested market position. */
942
+ /**
943
+ * Thrown when reallocation state does not contain a requested market position.
944
+ *
945
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major.
946
+ */
919
947
  class UnknownReallocationPositionError extends blue_sdk_1.UnknownDataError {
920
948
  user;
921
949
  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. */
@@ -8,7 +8,9 @@ MarketUtils, MathLib, SharesMath as BlueSharesMath,
8
8
  SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
9
9
  export { decodeBytes32String, getAuthorizationTypedData as getBlueAuthorizationTypedData,
10
10
  /** @deprecated Use getBlueAuthorizationTypedData or the raw protocol subpath. */
11
- getAuthorizationTypedData, getDaiPermitTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction as BlueMetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
11
+ getAuthorizationTypedData,
12
+ /** @deprecated DAI is routed through Permit2 internally; scheduled for removal in the next major. */
13
+ getDaiPermitTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction as BlueMetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
12
14
  export { EcrecoverRatifierUtils as MidnightEcrecoverRatifierUtils,
13
15
  /** @deprecated Use MidnightEcrecoverRatifierUtils or the raw protocol subpath. */
14
16
  EcrecoverRatifierUtils, eip712Digest, GroupUtils as MidnightGroupUtils,