@morpho-org/morpho-sdk 5.8.0 → 6.0.0-next.0

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 (167) hide show
  1. package/MIGRATION-v5-to-v6.md +201 -0
  2. package/README.md +62 -40
  3. package/lib/cjs/abis.d.ts +543 -0
  4. package/lib/cjs/abis.js +738 -0
  5. package/lib/cjs/actions/blue/borrow.d.ts +62 -58
  6. package/lib/cjs/actions/blue/borrow.js +48 -80
  7. package/lib/cjs/actions/blue/common.d.ts +99 -0
  8. package/lib/cjs/actions/blue/common.js +318 -0
  9. package/lib/cjs/actions/blue/refinance.d.ts +72 -107
  10. package/lib/cjs/actions/blue/refinance.js +97 -197
  11. package/lib/cjs/actions/blue/repay.d.ts +72 -68
  12. package/lib/cjs/actions/blue/repay.js +56 -118
  13. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +85 -90
  14. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +148 -137
  15. package/lib/cjs/actions/blue/supply.d.ts +62 -45
  16. package/lib/cjs/actions/blue/supply.js +94 -70
  17. package/lib/cjs/actions/blue/supplyCollateral.d.ts +63 -40
  18. package/lib/cjs/actions/blue/supplyCollateral.js +52 -69
  19. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +82 -86
  20. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +133 -119
  21. package/lib/cjs/actions/blue/withdraw.d.ts +68 -78
  22. package/lib/cjs/actions/blue/withdraw.js +101 -97
  23. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +56 -28
  24. package/lib/cjs/actions/blue/withdrawCollateral.js +45 -50
  25. package/lib/cjs/actions/index.d.ts +1 -1
  26. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +29 -17
  27. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +60 -19
  28. package/lib/cjs/actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts +80 -0
  29. package/lib/cjs/actions/requirements/blue/getBlueBundlesV1TokenRequirements.js +207 -0
  30. package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
  31. package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.js +72 -0
  32. package/lib/cjs/actions/requirements/blue/index.d.ts +2 -0
  33. package/lib/cjs/actions/requirements/blue/index.js +2 -0
  34. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
  35. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +30 -5
  36. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
  37. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +7 -2
  38. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
  39. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +33 -6
  40. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts +61 -0
  41. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.js +123 -0
  42. package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
  43. package/lib/cjs/actions/requirements/encode/index.js +1 -0
  44. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
  45. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +5 -4
  46. package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -4
  47. package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +1 -0
  48. package/lib/cjs/actions/signatures/getTokenRequirementActions.js +4 -0
  49. package/lib/cjs/blue/types.d.ts +3 -1
  50. package/lib/cjs/blue/utils.d.ts +3 -1
  51. package/lib/cjs/blue/utils.js +1 -0
  52. package/lib/cjs/bundler/actions.d.ts +6 -4
  53. package/lib/cjs/bundler/actions.js +6 -4
  54. package/lib/cjs/bundler/types.d.ts +10 -1
  55. package/lib/cjs/client/morphoViemExtension.d.ts +2 -1
  56. package/lib/cjs/client/morphoViemExtension.js +2 -1
  57. package/lib/cjs/entities/blue/blue.d.ts +817 -360
  58. package/lib/cjs/entities/blue/blue.js +455 -698
  59. package/lib/cjs/entities/index.d.ts +1 -0
  60. package/lib/cjs/entities/vaultV1/vaultV1.js +4 -12
  61. package/lib/cjs/entities/vaultV1ReallocationData.d.ts +18 -3
  62. package/lib/cjs/entities/vaultV1ReallocationData.js +11 -1
  63. package/lib/cjs/entities/vaultV2/vaultV2.js +6 -18
  64. package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +7 -10
  65. package/lib/cjs/helpers/computeVaultV1Reallocations.js +7 -10
  66. package/lib/cjs/helpers/validate.d.ts +16 -23
  67. package/lib/cjs/helpers/validate.js +32 -48
  68. package/lib/cjs/helpers/validateRequirementSpender.d.ts +2 -1
  69. package/lib/cjs/helpers/validateRequirementSpender.js +2 -0
  70. package/lib/cjs/types/action.d.ts +146 -162
  71. package/lib/cjs/types/action.js +29 -2
  72. package/lib/cjs/types/client.d.ts +9 -0
  73. package/lib/cjs/types/error.d.ts +173 -18
  74. package/lib/cjs/types/error.js +230 -25
  75. package/lib/cjs/types/sharedLiquidity.d.ts +20 -4
  76. package/lib/cjs/types.d.ts +3 -1
  77. package/lib/cjs/utils.d.ts +3 -1
  78. package/lib/cjs/utils.js +1 -0
  79. package/lib/esm/abis.d.ts +543 -0
  80. package/lib/esm/abis.js +737 -0
  81. package/lib/esm/actions/blue/borrow.d.ts +62 -58
  82. package/lib/esm/actions/blue/borrow.js +48 -80
  83. package/lib/esm/actions/blue/common.d.ts +99 -0
  84. package/lib/esm/actions/blue/common.js +306 -0
  85. package/lib/esm/actions/blue/refinance.d.ts +72 -107
  86. package/lib/esm/actions/blue/refinance.js +98 -198
  87. package/lib/esm/actions/blue/repay.d.ts +72 -68
  88. package/lib/esm/actions/blue/repay.js +56 -118
  89. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +85 -90
  90. package/lib/esm/actions/blue/repayWithdrawCollateral.js +149 -138
  91. package/lib/esm/actions/blue/supply.d.ts +62 -45
  92. package/lib/esm/actions/blue/supply.js +94 -70
  93. package/lib/esm/actions/blue/supplyCollateral.d.ts +63 -40
  94. package/lib/esm/actions/blue/supplyCollateral.js +52 -69
  95. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +82 -86
  96. package/lib/esm/actions/blue/supplyCollateralBorrow.js +134 -120
  97. package/lib/esm/actions/blue/withdraw.d.ts +68 -78
  98. package/lib/esm/actions/blue/withdraw.js +100 -96
  99. package/lib/esm/actions/blue/withdrawCollateral.d.ts +56 -28
  100. package/lib/esm/actions/blue/withdrawCollateral.js +45 -50
  101. package/lib/esm/actions/index.d.ts +1 -1
  102. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +29 -17
  103. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +63 -22
  104. package/lib/esm/actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts +80 -0
  105. package/lib/esm/actions/requirements/blue/getBlueBundlesV1TokenRequirements.js +203 -0
  106. package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
  107. package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.js +68 -0
  108. package/lib/esm/actions/requirements/blue/index.d.ts +2 -0
  109. package/lib/esm/actions/requirements/blue/index.js +2 -0
  110. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
  111. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +31 -6
  112. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
  113. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +8 -3
  114. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
  115. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +34 -7
  116. package/lib/esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts +61 -0
  117. package/lib/esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.js +119 -0
  118. package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
  119. package/lib/esm/actions/requirements/encode/index.js +1 -0
  120. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
  121. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +5 -4
  122. package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -4
  123. package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +1 -0
  124. package/lib/esm/actions/signatures/getTokenRequirementActions.js +5 -1
  125. package/lib/esm/blue/types.d.ts +3 -1
  126. package/lib/esm/blue/utils.d.ts +3 -1
  127. package/lib/esm/blue/utils.js +3 -1
  128. package/lib/esm/bundler/actions.d.ts +6 -4
  129. package/lib/esm/bundler/actions.js +6 -4
  130. package/lib/esm/bundler/types.d.ts +10 -1
  131. package/lib/esm/client/morphoViemExtension.d.ts +2 -1
  132. package/lib/esm/client/morphoViemExtension.js +2 -1
  133. package/lib/esm/entities/blue/blue.d.ts +817 -360
  134. package/lib/esm/entities/blue/blue.js +461 -704
  135. package/lib/esm/entities/index.d.ts +1 -0
  136. package/lib/esm/entities/vaultV1/vaultV1.js +4 -12
  137. package/lib/esm/entities/vaultV1ReallocationData.d.ts +18 -3
  138. package/lib/esm/entities/vaultV1ReallocationData.js +13 -2
  139. package/lib/esm/entities/vaultV2/vaultV2.js +7 -19
  140. package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +7 -10
  141. package/lib/esm/helpers/computeVaultV1Reallocations.js +7 -10
  142. package/lib/esm/helpers/validate.d.ts +16 -23
  143. package/lib/esm/helpers/validate.js +32 -48
  144. package/lib/esm/helpers/validateRequirementSpender.d.ts +2 -1
  145. package/lib/esm/helpers/validateRequirementSpender.js +2 -0
  146. package/lib/esm/types/action.d.ts +146 -162
  147. package/lib/esm/types/action.js +28 -2
  148. package/lib/esm/types/client.d.ts +9 -0
  149. package/lib/esm/types/error.d.ts +173 -18
  150. package/lib/esm/types/error.js +216 -21
  151. package/lib/esm/types/sharedLiquidity.d.ts +20 -4
  152. package/lib/esm/types.d.ts +3 -1
  153. package/lib/esm/utils.d.ts +3 -1
  154. package/lib/esm/utils.js +3 -1
  155. package/package.json +7 -6
  156. package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +0 -47
  157. package/lib/cjs/actions/blue/buildAssetFundingActions.js +0 -63
  158. package/lib/cjs/actions/blue/buildReallocationActions.d.ts +0 -69
  159. package/lib/cjs/actions/blue/buildReallocationActions.js +0 -141
  160. package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +0 -66
  161. package/lib/cjs/actions/blue/resolveRepayFunding.js +0 -85
  162. package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +0 -47
  163. package/lib/esm/actions/blue/buildAssetFundingActions.js +0 -59
  164. package/lib/esm/actions/blue/buildReallocationActions.d.ts +0 -69
  165. package/lib/esm/actions/blue/buildReallocationActions.js +0 -135
  166. package/lib/esm/actions/blue/resolveRepayFunding.d.ts +0 -66
  167. package/lib/esm/actions/blue/resolveRepayFunding.js +0 -81
@@ -68,7 +68,7 @@ export declare class InputExceedsMaxError extends Error {
68
68
  export declare class EmptyMarketParamsListError extends Error {
69
69
  constructor();
70
70
  }
71
- /** Thrown when an in-kind redemption deadline has already passed. */
71
+ /** Thrown when an SDK operation deadline has already passed. */
72
72
  export declare class ExpiredDeadlineError extends Error {
73
73
  readonly deadline: bigint;
74
74
  readonly timestamp: bigint;
@@ -203,6 +203,104 @@ export declare class VaultExitBundlesV1PermitMismatchError extends Error {
203
203
  readonly cause?: unknown;
204
204
  });
205
205
  }
206
+ /** Thrown when a signed requirement cannot be safely encoded for BlueBundlesV1. */
207
+ export declare class BlueBundlesV1RequirementSignatureMismatchError extends Error {
208
+ /** Field whose signed value or encoding is invalid for the direct BlueBundlesV1 call. */
209
+ readonly field: "type" | "authorized" | "isAuthorized" | "deadline" | "signature";
210
+ /** Value required by BlueBundlesV1. */
211
+ readonly expected: string;
212
+ /** Value supplied by the signed requirement. */
213
+ readonly actual: string;
214
+ /**
215
+ * @param params - Signature mismatch details.
216
+ * @param params.field - Field rejected by the converter.
217
+ * @param params.expected - Value required by the direct route.
218
+ * @param params.actual - Value supplied by the requirement.
219
+ * @param params.cause - Original signature parser failure, when applicable.
220
+ */
221
+ constructor(params: {
222
+ field: "type" | "authorized" | "isAuthorized" | "deadline" | "signature";
223
+ expected: string;
224
+ actual: string;
225
+ cause?: unknown;
226
+ });
227
+ }
228
+ /** Thrown when Permit2 SignatureTransfer is selected without an explicit unordered nonce. */
229
+ export declare class MissingPermit2TransferFromNonceError extends Error {
230
+ constructor();
231
+ }
232
+ /** Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed. */
233
+ export declare class Permit2TransferFromNonceAlreadyUsedError extends Error {
234
+ readonly owner: Address;
235
+ readonly nonce: bigint;
236
+ /**
237
+ * @param owner - Permit2 token owner whose nonce is unavailable.
238
+ * @param nonce - Explicit unordered nonce that has already been consumed.
239
+ */
240
+ constructor(owner: Address, nonce: bigint);
241
+ }
242
+ /** Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce. */
243
+ export declare class NoUnusedPermit2NonceError extends Error {
244
+ readonly owner: Address;
245
+ readonly startNonce: bigint;
246
+ /**
247
+ * @param owner - Permit2 token owner scanned for a free nonce.
248
+ * @param startNonce - Lowest nonce that was considered.
249
+ */
250
+ constructor(owner: Address, startNonce: bigint);
251
+ }
252
+ /** Thrown when native funding does not exactly match the contract's gross token pull. */
253
+ export declare class NativeFundingAmountMismatchError extends Error {
254
+ readonly nativeAmount: bigint;
255
+ readonly requiredAmount: bigint;
256
+ /**
257
+ * @param nativeAmount - Native value supplied with the transaction.
258
+ * @param requiredAmount - Gross amount the BlueBundlesV1 entrypoint funds.
259
+ */
260
+ constructor(nativeAmount: bigint, requiredAmount: bigint);
261
+ }
262
+ /** Thrown when a positive referral fee has no recipient. */
263
+ export declare class MissingReferralFeeRecipientError extends Error {
264
+ constructor();
265
+ }
266
+ /** Thrown when a BlueBundlesV1 reallocation source uses another loan token. */
267
+ export declare class ReallocationLoanTokenMismatchError extends Error {
268
+ readonly expected: Address;
269
+ readonly actual: Address;
270
+ /**
271
+ * @param expected - Loan token of the operation's target market.
272
+ * @param actual - Loan token found in the reallocation source market.
273
+ */
274
+ constructor(expected: Address, actual: Address);
275
+ }
276
+ /**
277
+ * Thrown when a Blue authorization operator is not one of the chain's registered Morpho operators
278
+ * (GeneralAdapter1 or BlueBundlesV1). Guards the exported authorization builder so a misconfigured
279
+ * `authorized` cannot grant an arbitrary address control over the user's Morpho positions.
280
+ */
281
+ export declare class UnsupportedAuthorizationOperatorError extends Error {
282
+ readonly authorized: Address;
283
+ readonly chainId: number;
284
+ /**
285
+ * @param authorized - The operator address rejected as unsupported.
286
+ * @param chainId - Chain whose registry was consulted for the supported operators.
287
+ */
288
+ constructor(authorized: Address, chainId: number);
289
+ }
290
+ /** Thrown when reallocations are attached to a combined call with no borrow leg. */
291
+ export declare class ReallocationsRequireBorrowError extends Error {
292
+ constructor();
293
+ }
294
+ /** Thrown when repay funding cannot cover the requested assets and referral fee. */
295
+ export declare class MaxRepayAssetsBelowRepayAssetsError extends Error {
296
+ readonly maxRepayAssets: bigint;
297
+ readonly repayAssets: bigint;
298
+ /**
299
+ * @param maxRepayAssets - Maximum loan-token funding supplied to the bundle.
300
+ * @param repayAssets - Minimum funding required for the repayment and referral fee.
301
+ */
302
+ constructor(maxRepayAssets: bigint, repayAssets: bigint);
303
+ }
206
304
  /** @deprecated Use {@link NonPositiveInputError}. */
207
305
  export declare const NonPositiveAssetAmountError: typeof NonPositiveInputError;
208
306
  /** @deprecated Use {@link NonPositiveInputError}. */
@@ -375,7 +473,7 @@ export declare namespace BundlerErrors {
375
473
  }
376
474
  }
377
475
  /** Requirement signature kind accepted by action-output transaction builders. */
378
- export type RequirementSignatureKind = "permit" | "authorization" | "midnightOfferRootSignature";
476
+ export type RequirementSignatureKind = "permit" | "permit2TransferFrom" | "authorization" | "midnightOfferRootSignature";
379
477
  /**
380
478
  * Thrown when `buildTx` receives more than one requirement signature of the same kind.
381
479
  *
@@ -524,7 +622,11 @@ export declare class MarketIdMismatchError extends Error {
524
622
  export declare class AccrualPositionUserMismatchError extends Error {
525
623
  constructor(positionUser: string, expectedUser: string);
526
624
  }
527
- /** Thrown when a reallocation has no withdrawals. */
625
+ /**
626
+ * Thrown when a reallocation has no withdrawals.
627
+ *
628
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
629
+ */
528
630
  export declare class EmptyReallocationWithdrawalsError extends Error {
529
631
  constructor(vault: string);
530
632
  }
@@ -533,8 +635,9 @@ export declare class ReallocationWithdrawalOnTargetMarketError extends Error {
533
635
  constructor(vault: string, marketId: string);
534
636
  }
535
637
  /**
536
- * Thrown when a Public Allocator reallocation does not match exactly one V1 or
537
- * V2 input shape.
638
+ * Thrown when a reallocation entry passed to a high-level Blue write is not a valid
639
+ * {@link VaultV2BlueReallocation}: a non-object entry, or an entry carrying Vault V1
640
+ * `withdrawals`/`fee` fields that high-level Blue writes no longer accept.
538
641
  *
539
642
  * @example
540
643
  * ```ts
@@ -549,6 +652,8 @@ export declare class InvalidReallocationShapeError extends Error {
549
652
  /**
550
653
  * Thrown when one reallocation plan contains both Vault V1 and Vault V2 entries.
551
654
  *
655
+ * @deprecated Vault V1/V2 mixed-plan support will be removed in the next major. Use Vault V2
656
+ * reallocations.
552
657
  * @example
553
658
  * ```ts
554
659
  * import { MixedReallocationVersionsError } from "@morpho-org/morpho-sdk";
@@ -637,7 +742,11 @@ export declare class InconsistentReallocationPenaltyError extends Error {
637
742
  readonly actual: bigint;
638
743
  });
639
744
  }
640
- /** Thrown when reallocation withdrawals within a vault are not strictly sorted by market id. */
745
+ /**
746
+ * Thrown when reallocation withdrawals within a vault are not strictly sorted by market id.
747
+ *
748
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
749
+ */
641
750
  export declare class UnsortedReallocationWithdrawalsError extends Error {
642
751
  constructor(vault: string, marketId: string);
643
752
  }
@@ -697,11 +806,19 @@ export declare class RepaySharesExceedDebtError extends Error {
697
806
  market: string;
698
807
  });
699
808
  }
700
- /** Thrown when a vault selected for reallocation has no configured `PublicAllocator`. */
809
+ /**
810
+ * Thrown when a vault selected for reallocation has no configured `PublicAllocator`.
811
+ *
812
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
813
+ */
701
814
  export declare class MissingPublicAllocatorConfigError extends Error {
702
815
  constructor(vault: string);
703
816
  }
704
- /** Thrown when a reallocation attempts to use a disabled vault market. */
817
+ /**
818
+ * Thrown when a reallocation attempts to use a disabled vault market.
819
+ *
820
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
821
+ */
705
822
  export declare class DisabledReallocationMarketError extends Error {
706
823
  readonly vault: Address;
707
824
  readonly marketId: MarketId;
@@ -742,7 +859,11 @@ export declare class UnknownReallocationVaultError extends UnknownDataError {
742
859
  */
743
860
  constructor(vault: Address);
744
861
  }
745
- /** Thrown when reallocation state does not contain a requested vault-market config. */
862
+ /**
863
+ * Thrown when reallocation state does not contain a requested vault-market config.
864
+ *
865
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major.
866
+ */
746
867
  export declare class UnknownReallocationVaultMarketConfigError extends UnknownDataError {
747
868
  readonly vault: Address;
748
869
  readonly marketId: MarketId;
@@ -752,7 +873,11 @@ export declare class UnknownReallocationVaultMarketConfigError extends UnknownDa
752
873
  */
753
874
  constructor(vault: Address, marketId: MarketId);
754
875
  }
755
- /** 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
+ */
756
881
  export declare class UnknownReallocationPositionError extends UnknownDataError {
757
882
  readonly user: Address;
758
883
  readonly marketId: MarketId;
@@ -1010,10 +1135,6 @@ export declare class ReallocationWithdrawExceedsMarketSupplyError extends Error
1010
1135
  export declare class VaultAssetMismatchError extends Error {
1011
1136
  constructor(sourceAsset: Address, targetAsset: Address);
1012
1137
  }
1013
- /** Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive). */
1014
- export declare class BorrowAmountAndSharesExclusiveError extends Error {
1015
- constructor(market: string);
1016
- }
1017
1138
  /** Thrown when a refinance has identical source and target market ids (a refinance to the same market is a costly no-op). */
1018
1139
  export declare class RefinanceSameMarketError extends Error {
1019
1140
  constructor(market: string);
@@ -1022,7 +1143,23 @@ export declare class RefinanceSameMarketError extends Error {
1022
1143
  export declare class RefinanceTokenMismatchError extends Error {
1023
1144
  constructor(sourceMarket: string, targetMarket: string);
1024
1145
  }
1025
- /** Thrown when a refinance's `collateralAmount` exceeds the source position's available collateral. */
1146
+ /**
1147
+ * Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive).
1148
+ *
1149
+ * @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
1150
+ * partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
1151
+ * compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
1152
+ */
1153
+ export declare class BorrowAmountAndSharesExclusiveError extends Error {
1154
+ constructor(market: string);
1155
+ }
1156
+ /**
1157
+ * Thrown when a refinance's `collateralAmount` exceeds the source position's available collateral.
1158
+ *
1159
+ * @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
1160
+ * partial collateral inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
1161
+ * compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
1162
+ */
1026
1163
  export declare class RefinanceExceedsCollateralError extends Error {
1027
1164
  readonly market: string;
1028
1165
  readonly requested: bigint;
@@ -1033,7 +1170,13 @@ export declare class RefinanceExceedsCollateralError extends Error {
1033
1170
  available: bigint;
1034
1171
  });
1035
1172
  }
1036
- /** Thrown when a refinance's `borrowShares` exceeds the source position's outstanding borrow shares. */
1173
+ /**
1174
+ * Thrown when a refinance's `borrowShares` exceeds the source position's outstanding borrow shares.
1175
+ *
1176
+ * @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
1177
+ * partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
1178
+ * compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
1179
+ */
1037
1180
  export declare class RefinanceExceedsBorrowSharesError extends Error {
1038
1181
  readonly market: string;
1039
1182
  readonly requested: bigint;
@@ -1044,7 +1187,13 @@ export declare class RefinanceExceedsBorrowSharesError extends Error {
1044
1187
  available: bigint;
1045
1188
  });
1046
1189
  }
1047
- /** Thrown when a refinance's `borrowAssets` exceeds the source position's outstanding debt assets. */
1190
+ /**
1191
+ * Thrown when a refinance's `borrowAssets` exceeds the source position's outstanding debt assets.
1192
+ *
1193
+ * @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
1194
+ * partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
1195
+ * compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
1196
+ */
1048
1197
  export declare class RefinanceExceedsBorrowAssetsError extends Error {
1049
1198
  readonly market: string;
1050
1199
  readonly requested: bigint;
@@ -1055,7 +1204,13 @@ export declare class RefinanceExceedsBorrowAssetsError extends Error {
1055
1204
  available: bigint;
1056
1205
  });
1057
1206
  }
1058
- /** Thrown when a refinance in shares mode (`borrowShares > 0n`) omits the `borrowAssets` overshoot for the target borrow leg. */
1207
+ /**
1208
+ * Thrown when a refinance in shares mode (`borrowShares > 0n`) omits the `borrowAssets` overshoot for the target borrow leg.
1209
+ *
1210
+ * @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
1211
+ * partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
1212
+ * compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
1213
+ */
1059
1214
  export declare class RefinanceSharesMissingBorrowAssetsError extends Error {
1060
1215
  constructor(market: string);
1061
1216
  }
@@ -82,7 +82,7 @@ export class EmptyMarketParamsListError extends Error {
82
82
  this.name = "EmptyMarketParamsListError";
83
83
  }
84
84
  }
85
- /** Thrown when an in-kind redemption deadline has already passed. */
85
+ /** Thrown when an SDK operation deadline has already passed. */
86
86
  export class ExpiredDeadlineError extends Error {
87
87
  deadline;
88
88
  timestamp;
@@ -91,7 +91,7 @@ export class ExpiredDeadlineError extends Error {
91
91
  * @param timestamp - Current timestamp used for validation.
92
92
  */
93
93
  constructor(deadline, timestamp) {
94
- super(`Deadline "${deadline}" has expired at timestamp "${timestamp}". Choose a future deadline and rebuild the exit.`);
94
+ super(`Deadline "${deadline}" has expired at timestamp "${timestamp}". Choose a future deadline and rebuild the operation.`);
95
95
  this.deadline = deadline;
96
96
  this.timestamp = timestamp;
97
97
  this.name = "ExpiredDeadlineError";
@@ -250,6 +250,144 @@ export class VaultExitBundlesV1PermitMismatchError extends Error {
250
250
  this.name = "VaultExitBundlesV1PermitMismatchError";
251
251
  }
252
252
  }
253
+ /** Thrown when a signed requirement cannot be safely encoded for BlueBundlesV1. */
254
+ export class BlueBundlesV1RequirementSignatureMismatchError extends Error {
255
+ /** Field whose signed value or encoding is invalid for the direct BlueBundlesV1 call. */
256
+ field;
257
+ /** Value required by BlueBundlesV1. */
258
+ expected;
259
+ /** Value supplied by the signed requirement. */
260
+ actual;
261
+ /**
262
+ * @param params - Signature mismatch details.
263
+ * @param params.field - Field rejected by the converter.
264
+ * @param params.expected - Value required by the direct route.
265
+ * @param params.actual - Value supplied by the requirement.
266
+ * @param params.cause - Original signature parser failure, when applicable.
267
+ */
268
+ constructor(params) {
269
+ super(`BlueBundlesV1 requirement ${params.field} mismatch: expected "${params.expected}", got "${params.actual}". Resolve and sign the requirements returned by this Blue action.`, { cause: params.cause });
270
+ this.field = params.field;
271
+ this.expected = params.expected;
272
+ this.actual = params.actual;
273
+ this.name = "BlueBundlesV1RequirementSignatureMismatchError";
274
+ }
275
+ }
276
+ /** Thrown when Permit2 SignatureTransfer is selected without an explicit unordered nonce. */
277
+ export class MissingPermit2TransferFromNonceError extends Error {
278
+ constructor() {
279
+ super("Permit2 SignatureTransfer requires an explicit unused permit2Nonce. Generate a unique uint256 nonce, pass it to getRequirements(), and resolve the requirements again.");
280
+ this.name = "MissingPermit2TransferFromNonceError";
281
+ }
282
+ }
283
+ /** Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed. */
284
+ export class Permit2TransferFromNonceAlreadyUsedError extends Error {
285
+ owner;
286
+ nonce;
287
+ /**
288
+ * @param owner - Permit2 token owner whose nonce is unavailable.
289
+ * @param nonce - Explicit unordered nonce that has already been consumed.
290
+ */
291
+ constructor(owner, nonce) {
292
+ super(`Permit2 nonce "${nonce}" is already used for owner "${owner}". Generate a different uint256 permit2Nonce and resolve the requirements again.`);
293
+ this.owner = owner;
294
+ this.nonce = nonce;
295
+ this.name = "Permit2TransferFromNonceAlreadyUsedError";
296
+ }
297
+ }
298
+ /** Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce. */
299
+ export class NoUnusedPermit2NonceError extends Error {
300
+ owner;
301
+ startNonce;
302
+ /**
303
+ * @param owner - Permit2 token owner scanned for a free nonce.
304
+ * @param startNonce - Lowest nonce that was considered.
305
+ */
306
+ constructor(owner, startNonce) {
307
+ super(`No unused Permit2 nonce found for owner "${owner}" at or after "${startNonce}". Pass a lower startNonce.`);
308
+ this.owner = owner;
309
+ this.startNonce = startNonce;
310
+ this.name = "NoUnusedPermit2NonceError";
311
+ }
312
+ }
313
+ /** Thrown when native funding does not exactly match the contract's gross token pull. */
314
+ export class NativeFundingAmountMismatchError extends Error {
315
+ nativeAmount;
316
+ requiredAmount;
317
+ /**
318
+ * @param nativeAmount - Native value supplied with the transaction.
319
+ * @param requiredAmount - Gross amount the BlueBundlesV1 entrypoint funds.
320
+ */
321
+ constructor(nativeAmount, requiredAmount) {
322
+ super(`Native funding must equal the full funded amount: expected "${requiredAmount}", got "${nativeAmount}". Use either native funding or ERC-20 funding, not both.`);
323
+ this.nativeAmount = nativeAmount;
324
+ this.requiredAmount = requiredAmount;
325
+ this.name = "NativeFundingAmountMismatchError";
326
+ }
327
+ }
328
+ /** Thrown when a positive referral fee has no recipient. */
329
+ export class MissingReferralFeeRecipientError extends Error {
330
+ constructor() {
331
+ super("A positive referralFeePct requires referralFeeRecipient. Provide the recipient or set referralFeePct to zero.");
332
+ this.name = "MissingReferralFeeRecipientError";
333
+ }
334
+ }
335
+ /** Thrown when a BlueBundlesV1 reallocation source uses another loan token. */
336
+ export class ReallocationLoanTokenMismatchError extends Error {
337
+ expected;
338
+ actual;
339
+ /**
340
+ * @param expected - Loan token of the operation's target market.
341
+ * @param actual - Loan token found in the reallocation source market.
342
+ */
343
+ constructor(expected, actual) {
344
+ super(`Reallocation source loan token "${actual}" does not match target loan token "${expected}". Recompute reallocations for the target market.`);
345
+ this.expected = expected;
346
+ this.actual = actual;
347
+ this.name = "ReallocationLoanTokenMismatchError";
348
+ }
349
+ }
350
+ /**
351
+ * Thrown when a Blue authorization operator is not one of the chain's registered Morpho operators
352
+ * (GeneralAdapter1 or BlueBundlesV1). Guards the exported authorization builder so a misconfigured
353
+ * `authorized` cannot grant an arbitrary address control over the user's Morpho positions.
354
+ */
355
+ export class UnsupportedAuthorizationOperatorError extends Error {
356
+ authorized;
357
+ chainId;
358
+ /**
359
+ * @param authorized - The operator address rejected as unsupported.
360
+ * @param chainId - Chain whose registry was consulted for the supported operators.
361
+ */
362
+ constructor(authorized, chainId) {
363
+ super(`Authorization operator "${authorized}" is not a supported Morpho operator on chain ${chainId}. Pass the chain's registered GeneralAdapter1 or BlueBundlesV1 address, or omit \`authorized\` to default to GeneralAdapter1.`);
364
+ this.authorized = authorized;
365
+ this.chainId = chainId;
366
+ this.name = "UnsupportedAuthorizationOperatorError";
367
+ }
368
+ }
369
+ /** Thrown when reallocations are attached to a combined call with no borrow leg. */
370
+ export class ReallocationsRequireBorrowError extends Error {
371
+ constructor() {
372
+ super("BlueBundlesV1 reallocations require a positive borrowAssets value. Remove the reallocations or add a borrow leg.");
373
+ this.name = "ReallocationsRequireBorrowError";
374
+ }
375
+ }
376
+ /** Thrown when repay funding cannot cover the requested assets and referral fee. */
377
+ export class MaxRepayAssetsBelowRepayAssetsError extends Error {
378
+ maxRepayAssets;
379
+ repayAssets;
380
+ /**
381
+ * @param maxRepayAssets - Maximum loan-token funding supplied to the bundle.
382
+ * @param repayAssets - Minimum funding required for the repayment and referral fee.
383
+ */
384
+ constructor(maxRepayAssets, repayAssets) {
385
+ super(`maxRepayAssets "${maxRepayAssets}" cannot cover required repay funding "${repayAssets}". Increase maxRepayAssets to include the repayment and referral fee.`);
386
+ this.maxRepayAssets = maxRepayAssets;
387
+ this.repayAssets = repayAssets;
388
+ this.name = "MaxRepayAssetsBelowRepayAssetsError";
389
+ }
390
+ }
253
391
  /** @deprecated Use {@link NonPositiveInputError}. */
254
392
  export const NonPositiveAssetAmountError = NonPositiveInputError;
255
393
  /** @deprecated Use {@link NonPositiveInputError}. */
@@ -587,7 +725,11 @@ export class AccrualPositionUserMismatchError extends Error {
587
725
  super(`Accrual position user ${positionUser} does not match expected user ${expectedUser}`);
588
726
  }
589
727
  }
590
- /** Thrown when a reallocation has no withdrawals. */
728
+ /**
729
+ * Thrown when a reallocation has no withdrawals.
730
+ *
731
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
732
+ */
591
733
  export class EmptyReallocationWithdrawalsError extends Error {
592
734
  constructor(vault) {
593
735
  super(`Reallocation withdrawals list cannot be empty for vault: ${vault}`);
@@ -600,8 +742,9 @@ export class ReallocationWithdrawalOnTargetMarketError extends Error {
600
742
  }
601
743
  }
602
744
  /**
603
- * Thrown when a Public Allocator reallocation does not match exactly one V1 or
604
- * V2 input shape.
745
+ * Thrown when a reallocation entry passed to a high-level Blue write is not a valid
746
+ * {@link VaultV2BlueReallocation}: a non-object entry, or an entry carrying Vault V1
747
+ * `withdrawals`/`fee` fields that high-level Blue writes no longer accept.
605
748
  *
606
749
  * @example
607
750
  * ```ts
@@ -612,13 +755,15 @@ export class ReallocationWithdrawalOnTargetMarketError extends Error {
612
755
  */
613
756
  export class InvalidReallocationShapeError extends Error {
614
757
  constructor() {
615
- super('Reallocation must contain either V1 "withdrawals" or V2 "from", but not both.');
758
+ super("Reallocation entry is not a valid Vault V2 reallocation. High-level Blue writes accept only VaultV2BlueReallocation entries (e.g. from getVaultV2BlueReallocations()); compose Vault V1 reallocations via low-level Bundler3 actions.");
616
759
  this.name = "InvalidReallocationShapeError";
617
760
  }
618
761
  }
619
762
  /**
620
763
  * Thrown when one reallocation plan contains both Vault V1 and Vault V2 entries.
621
764
  *
765
+ * @deprecated Vault V1/V2 mixed-plan support will be removed in the next major. Use Vault V2
766
+ * reallocations.
622
767
  * @example
623
768
  * ```ts
624
769
  * import { MixedReallocationVersionsError } from "@morpho-org/morpho-sdk";
@@ -725,7 +870,11 @@ export class InconsistentReallocationPenaltyError extends Error {
725
870
  this.name = "InconsistentReallocationPenaltyError";
726
871
  }
727
872
  }
728
- /** Thrown when reallocation withdrawals within a vault are not strictly sorted by market id. */
873
+ /**
874
+ * Thrown when reallocation withdrawals within a vault are not strictly sorted by market id.
875
+ *
876
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
877
+ */
729
878
  export class UnsortedReallocationWithdrawalsError extends Error {
730
879
  constructor(vault, marketId) {
731
880
  super(`Reallocation withdrawals must be strictly sorted by market ID for vault ${vault}. Market ${marketId} is out of order.`);
@@ -783,13 +932,21 @@ export class RepaySharesExceedDebtError extends Error {
783
932
  super(`Repay shares ${params.repayShares} exceed outstanding borrow shares ${params.borrowShares} for market: ${params.market}`);
784
933
  }
785
934
  }
786
- /** Thrown when a vault selected for reallocation has no configured `PublicAllocator`. */
935
+ /**
936
+ * Thrown when a vault selected for reallocation has no configured `PublicAllocator`.
937
+ *
938
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
939
+ */
787
940
  export class MissingPublicAllocatorConfigError extends Error {
788
941
  constructor(vault) {
789
942
  super(`Vault ${vault} has no public allocator configured but was selected for reallocation`);
790
943
  }
791
944
  }
792
- /** Thrown when a reallocation attempts to use a disabled vault market. */
945
+ /**
946
+ * Thrown when a reallocation attempts to use a disabled vault market.
947
+ *
948
+ * @deprecated Vault V1 PublicAllocator support will be removed in the next major.
949
+ */
793
950
  export class DisabledReallocationMarketError extends Error {
794
951
  vault;
795
952
  marketId;
@@ -835,7 +992,11 @@ export class UnknownReallocationVaultError extends UnknownDataError {
835
992
  this.vault = vault;
836
993
  }
837
994
  }
838
- /** Thrown when reallocation state does not contain a requested vault-market config. */
995
+ /**
996
+ * Thrown when reallocation state does not contain a requested vault-market config.
997
+ *
998
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major.
999
+ */
839
1000
  export class UnknownReallocationVaultMarketConfigError extends UnknownDataError {
840
1001
  vault;
841
1002
  marketId;
@@ -849,7 +1010,11 @@ export class UnknownReallocationVaultMarketConfigError extends UnknownDataError
849
1010
  this.marketId = marketId;
850
1011
  }
851
1012
  }
852
- /** Thrown when reallocation state does not contain a requested market position. */
1013
+ /**
1014
+ * Thrown when reallocation state does not contain a requested market position.
1015
+ *
1016
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major.
1017
+ */
853
1018
  export class UnknownReallocationPositionError extends UnknownDataError {
854
1019
  user;
855
1020
  marketId;
@@ -1091,12 +1256,6 @@ export class VaultAssetMismatchError extends Error {
1091
1256
  super(`Source vault asset ${sourceAsset} does not match target vault asset ${targetAsset}`);
1092
1257
  }
1093
1258
  }
1094
- /** Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive). */
1095
- export class BorrowAmountAndSharesExclusiveError extends Error {
1096
- constructor(market) {
1097
- super(`Exactly one of borrowAssets or borrowShares must be non-zero for market: ${market}. Both were provided.`);
1098
- }
1099
- }
1100
1259
  /** Thrown when a refinance has identical source and target market ids (a refinance to the same market is a costly no-op). */
1101
1260
  export class RefinanceSameMarketError extends Error {
1102
1261
  constructor(market) {
@@ -1109,7 +1268,25 @@ export class RefinanceTokenMismatchError extends Error {
1109
1268
  super(`Refinance source market ${sourceMarket} and target market ${targetMarket} must share the same loanToken and collateralToken.`);
1110
1269
  }
1111
1270
  }
1112
- /** Thrown when a refinance's `collateralAmount` exceeds the source position's available collateral. */
1271
+ /**
1272
+ * Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive).
1273
+ *
1274
+ * @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
1275
+ * partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
1276
+ * compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
1277
+ */
1278
+ export class BorrowAmountAndSharesExclusiveError extends Error {
1279
+ constructor(market) {
1280
+ super(`Exactly one of borrowAssets or borrowShares must be non-zero for market: ${market}. Both were provided.`);
1281
+ }
1282
+ }
1283
+ /**
1284
+ * Thrown when a refinance's `collateralAmount` exceeds the source position's available collateral.
1285
+ *
1286
+ * @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
1287
+ * partial collateral inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
1288
+ * compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
1289
+ */
1113
1290
  export class RefinanceExceedsCollateralError extends Error {
1114
1291
  market;
1115
1292
  requested;
@@ -1121,7 +1298,13 @@ export class RefinanceExceedsCollateralError extends Error {
1121
1298
  this.available = params.available;
1122
1299
  }
1123
1300
  }
1124
- /** Thrown when a refinance's `borrowShares` exceeds the source position's outstanding borrow shares. */
1301
+ /**
1302
+ * Thrown when a refinance's `borrowShares` exceeds the source position's outstanding borrow shares.
1303
+ *
1304
+ * @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
1305
+ * partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
1306
+ * compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
1307
+ */
1125
1308
  export class RefinanceExceedsBorrowSharesError extends Error {
1126
1309
  market;
1127
1310
  requested;
@@ -1133,7 +1316,13 @@ export class RefinanceExceedsBorrowSharesError extends Error {
1133
1316
  this.available = params.available;
1134
1317
  }
1135
1318
  }
1136
- /** Thrown when a refinance's `borrowAssets` exceeds the source position's outstanding debt assets. */
1319
+ /**
1320
+ * Thrown when a refinance's `borrowAssets` exceeds the source position's outstanding debt assets.
1321
+ *
1322
+ * @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
1323
+ * partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
1324
+ * compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
1325
+ */
1137
1326
  export class RefinanceExceedsBorrowAssetsError extends Error {
1138
1327
  market;
1139
1328
  requested;
@@ -1145,7 +1334,13 @@ export class RefinanceExceedsBorrowAssetsError extends Error {
1145
1334
  this.available = params.available;
1146
1335
  }
1147
1336
  }
1148
- /** Thrown when a refinance in shares mode (`borrowShares > 0n`) omits the `borrowAssets` overshoot for the target borrow leg. */
1337
+ /**
1338
+ * Thrown when a refinance in shares mode (`borrowShares > 0n`) omits the `borrowAssets` overshoot for the target borrow leg.
1339
+ *
1340
+ * @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
1341
+ * partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
1342
+ * compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
1343
+ */
1149
1344
  export class RefinanceSharesMissingBorrowAssetsError extends Error {
1150
1345
  constructor(market) {
1151
1346
  super(`Refinance shares mode requires a positive borrowAssets overshoot for the target borrow leg (market: ${market}).`);