@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
@@ -14,7 +14,10 @@ export interface BlueBorrowParams {
14
14
  receiver: Address;
15
15
  /** Minimum borrow share price (in ray). Protects against share price manipulation. */
16
16
  minSharePrice: bigint;
17
- /** Homogeneous Vault V1 or Vault V2 reallocations to execute before borrowing. */
17
+ /**
18
+ * Homogeneous Vault V1 or Vault V2 reallocations to execute before borrowing.
19
+ * Vault V1 inputs are deprecated for high-level Blue writes; use Vault V2 for new integrations.
20
+ */
18
21
  reallocations?: BlueReallocationPlan;
19
22
  /**
20
23
  * Optional signed Morpho authorization. When provided, a `setAuthorizationWithSig` call is
@@ -43,7 +46,7 @@ export interface BlueBorrowParams {
43
46
  * @param params.args.receiver - Address that receives the borrowed assets.
44
47
  * @param params.args.minSharePrice - Minimum borrow share price (in ray). Slippage protection.
45
48
  * @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
46
- * execute before borrowing.
49
+ * execute before borrowing. Vault V1 inputs are deprecated; use Vault V2 for new integrations.
47
50
  * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
48
51
  * a `setAuthorizationWithSig` call is prepended to the bundle.
49
52
  * @param params.metadata - Optional analytics metadata attached to the bundle.
@@ -22,7 +22,7 @@ import { buildBlueReallocationActions } from "./buildReallocationActions.js";
22
22
  * @param params.args.receiver - Address that receives the borrowed assets.
23
23
  * @param params.args.minSharePrice - Minimum borrow share price (in ray). Slippage protection.
24
24
  * @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
25
- * execute before borrowing.
25
+ * execute before borrowing. Vault V1 inputs are deprecated; use Vault V2 for new integrations.
26
26
  * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
27
27
  * a `setAuthorizationWithSig` call is prepended to the bundle.
28
28
  * @param params.metadata - Optional analytics metadata attached to the bundle.
@@ -27,7 +27,10 @@ export interface BlueRefinanceParams {
27
27
  minBorrowSharePrice: bigint;
28
28
  /** Maximum repay share price on the source market (in ray); must be > 0 when a repay leg exists. */
29
29
  maxRepaySharePrice: bigint;
30
- /** Homogeneous Vault V1 or Vault V2 reallocations into the target market. */
30
+ /**
31
+ * Homogeneous Vault V1 or Vault V2 reallocations into the target market.
32
+ * Vault V1 inputs are deprecated for high-level Blue writes; use Vault V2 for new integrations.
33
+ */
31
34
  targetReallocations?: BlueReallocationPlan;
32
35
  /**
33
36
  * Optional signed Morpho authorization. When provided, a `setAuthorizationWithSig` call is
@@ -85,7 +88,9 @@ export interface BlueRefinanceParams {
85
88
  * @param params.args.minBorrowSharePrice - Minimum borrow share price (ray) on the target.
86
89
  * @param params.args.maxRepaySharePrice - Maximum repay share price (ray) on the source.
87
90
  * @param params.args.targetReallocations - Homogeneous Vault V1 or Vault V2 reallocations into the
88
- * target, run before the supply leg. V1 fees add to `tx.value`; V2 penalties are paid in the target loan token.
91
+ * target, run before the supply leg. Vault V1 inputs are deprecated for high-level Blue writes;
92
+ * use Vault V2 for new integrations. V1 fees add to `tx.value`; V2 penalties are paid in the
93
+ * target loan token.
89
94
  * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
90
95
  * a `setAuthorizationWithSig` call is prepended to the bundle.
91
96
  * @param params.metadata - Optional analytics metadata appended to `tx.data`.
@@ -53,7 +53,9 @@ import { buildBlueReallocationActions } from "./buildReallocationActions.js";
53
53
  * @param params.args.minBorrowSharePrice - Minimum borrow share price (ray) on the target.
54
54
  * @param params.args.maxRepaySharePrice - Maximum repay share price (ray) on the source.
55
55
  * @param params.args.targetReallocations - Homogeneous Vault V1 or Vault V2 reallocations into the
56
- * target, run before the supply leg. V1 fees add to `tx.value`; V2 penalties are paid in the target loan token.
56
+ * target, run before the supply leg. Vault V1 inputs are deprecated for high-level Blue writes;
57
+ * use Vault V2 for new integrations. V1 fees add to `tx.value`; V2 penalties are paid in the
58
+ * target loan token.
57
59
  * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
58
60
  * a `setAuthorizationWithSig` call is prepended to the bundle.
59
61
  * @param params.metadata - Optional analytics metadata appended to `tx.data`.
@@ -18,7 +18,10 @@ export interface BlueSupplyCollateralBorrowParams {
18
18
  minSharePrice: bigint;
19
19
  /** Optional pre-signed permit/permit2 approval for the collateral transfer. */
20
20
  requirementSignature?: PermitRequirementSignature;
21
- /** Homogeneous Vault V1 or Vault V2 reallocations to execute before borrowing. */
21
+ /**
22
+ * Homogeneous Vault V1 or Vault V2 reallocations to execute before borrowing.
23
+ * Vault V1 inputs are deprecated for high-level Blue writes; use Vault V2 for new integrations.
24
+ */
22
25
  reallocations?: BlueReallocationPlan;
23
26
  /**
24
27
  * Optional signed Morpho authorization. When provided, a `setAuthorizationWithSig` call is
@@ -59,7 +62,8 @@ export interface BlueSupplyCollateralBorrowParams {
59
62
  * @param params.args.nativeAmount - Optional amount of native token to wrap into wNative for the
60
63
  * collateral supply. Requires the collateral token to be the chain's wNative.
61
64
  * @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
62
- * execute between the supply and borrow legs.
65
+ * execute between the supply and borrow legs. Vault V1 inputs are deprecated; use Vault V2 for
66
+ * new integrations.
63
67
  * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
64
68
  * a `setAuthorizationWithSig` call is prepended to the bundle.
65
69
  * @param params.metadata - Optional analytics metadata attached to the bundle.
@@ -36,7 +36,8 @@ import { buildBlueReallocationActions } from "./buildReallocationActions.js";
36
36
  * @param params.args.nativeAmount - Optional amount of native token to wrap into wNative for the
37
37
  * collateral supply. Requires the collateral token to be the chain's wNative.
38
38
  * @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
39
- * execute between the supply and borrow legs.
39
+ * execute between the supply and borrow legs. Vault V1 inputs are deprecated; use Vault V2 for
40
+ * new integrations.
40
41
  * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
41
42
  * a `setAuthorizationWithSig` call is prepended to the bundle.
42
43
  * @param params.metadata - Optional analytics metadata attached to the bundle.
@@ -20,6 +20,7 @@ export interface BlueWithdrawParams {
20
20
  * Homogeneous Vault V1 or Vault V2 reallocations to execute before withdrawing. V1 entries can be
21
21
  * computed via `MorphoBlue.getVaultV1Reallocations({ operation: "withdraw", amount })` or directly
22
22
  * via `computeVaultV1Reallocations({ operation: "withdraw", amount, ... })`.
23
+ * Vault V1 inputs are deprecated for high-level Blue writes; use Vault V2 for new integrations.
23
24
  */
24
25
  reallocations?: BlueReallocationPlan;
25
26
  /**
@@ -59,7 +60,7 @@ export interface BlueWithdrawParams {
59
60
  * @param params.args.minSharePrice - Minimum acceptable withdraw share price (in ray). Slippage
60
61
  * protection.
61
62
  * @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
62
- * execute before withdrawing.
63
+ * execute before withdrawing. Vault V1 inputs are deprecated; use Vault V2 for new integrations.
63
64
  * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
64
65
  * a `setAuthorizationWithSig` call is prepended to the bundle.
65
66
  * @param params.metadata - Optional analytics metadata attached to the bundle.
@@ -32,7 +32,7 @@ import { buildBlueReallocationActions } from "./buildReallocationActions.js";
32
32
  * @param params.args.minSharePrice - Minimum acceptable withdraw share price (in ray). Slippage
33
33
  * protection.
34
34
  * @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
35
- * execute before withdrawing.
35
+ * execute before withdrawing. Vault V1 inputs are deprecated; use Vault V2 for new integrations.
36
36
  * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
37
37
  * a `setAuthorizationWithSig` call is prepended to the bundle.
38
38
  * @param params.metadata - Optional analytics metadata attached to the bundle.
@@ -40,8 +40,8 @@ export interface MidnightSupplyCollateralTakeBorrowParams extends MidnightTakeBo
40
40
  * chainId: 8453,
41
41
  * market: marketData.params,
42
42
  * collateralAssets: 2_000_000n,
43
- * loanAssets: BigInt(quote.data.availableAssets),
44
- * maxUnits: BigInt(quote.data.availableUnits),
43
+ * loanAssets: 1_000_000n,
44
+ * maxUnits: 1_100_000n,
45
45
  * taker: borrower,
46
46
  * takeableOffers: quote.data.takeableOffers,
47
47
  * deadline: maxUint256,
@@ -41,8 +41,8 @@ import { PermitKind } from "./types.js";
41
41
  * chainId: 8453,
42
42
  * market: marketData.params,
43
43
  * collateralAssets: 2_000_000n,
44
- * loanAssets: BigInt(quote.data.availableAssets),
45
- * maxUnits: BigInt(quote.data.availableUnits),
44
+ * loanAssets: 1_000_000n,
45
+ * maxUnits: 1_100_000n,
46
46
  * taker: borrower,
47
47
  * takeableOffers: quote.data.takeableOffers,
48
48
  * deadline: maxUint256,
@@ -46,8 +46,8 @@ export interface MidnightTakeBorrowParams {
46
46
  * const tx = midnightTakeBorrow({
47
47
  * chainId: 8453,
48
48
  * market: marketData.params,
49
- * loanAssets: BigInt(quote.data.availableAssets),
50
- * maxUnits: BigInt(quote.data.availableUnits),
49
+ * loanAssets: 1_000_000n,
50
+ * maxUnits: 1_100_000n,
51
51
  * taker: borrower,
52
52
  * takeableOffers: quote.data.takeableOffers,
53
53
  * deadline: maxUint256,
@@ -37,8 +37,8 @@ import { NegativeInputError, NonPositiveInputError, } from "../../types/index.js
37
37
  * const tx = midnightTakeBorrow({
38
38
  * chainId: 8453,
39
39
  * market: marketData.params,
40
- * loanAssets: BigInt(quote.data.availableAssets),
41
- * maxUnits: BigInt(quote.data.availableUnits),
40
+ * loanAssets: 1_000_000n,
41
+ * maxUnits: 1_100_000n,
42
42
  * taker: borrower,
43
43
  * takeableOffers: quote.data.takeableOffers,
44
44
  * deadline: maxUint256,
@@ -46,8 +46,8 @@ export interface MidnightTakeLendParams {
46
46
  * const tx = midnightTakeLend({
47
47
  * chainId: 8453,
48
48
  * market: marketData.params,
49
- * assets: BigInt(quote.data.availableAssets),
50
- * minUnits: BigInt(quote.data.availableUnits),
49
+ * assets: 1_000_000n,
50
+ * minUnits: 900_000n,
51
51
  * taker: lender,
52
52
  * takeableOffers: quote.data.takeableOffers,
53
53
  * deadline: maxUint256,
@@ -38,8 +38,8 @@ import { PermitKind } from "./types.js";
38
38
  * const tx = midnightTakeLend({
39
39
  * chainId: 8453,
40
40
  * market: marketData.params,
41
- * assets: BigInt(quote.data.availableAssets),
42
- * minUnits: BigInt(quote.data.availableUnits),
41
+ * assets: 1_000_000n,
42
+ * minUnits: 900_000n,
43
43
  * taker: lender,
44
44
  * takeableOffers: quote.data.takeableOffers,
45
45
  * deadline: maxUint256,
@@ -1,2 +1,4 @@
1
1
  export type { BigIntish, CollateralAllocation, Eip712Field, Erc20AllowanceRecipient, Failable, Fetchable, InputMarketParams, IPermit2Allowance, Loadable, MarketId, MaxBorrowOptions, MaxPositionCapacities, MaxWithdrawCollateralOptions, Pending, Permit2Allowance, } from "@morpho-org/blue-sdk";
2
- export type { AuthorizationArgs, DaiPermitArgs, DeploylessFetchParameters, FetchParameters, InputAllocation, MetaMorphoCall, Permit2PermitArgs, Permit2TransferFromArgs, PermitArgs, } from "@morpho-org/blue-sdk-viem";
2
+ export type { AuthorizationArgs,
3
+ /** @deprecated Args for the deprecated getDaiPermitTypedData; scheduled for removal in the next major. */
4
+ DaiPermitArgs, DeploylessFetchParameters, FetchParameters, InputAllocation, MetaMorphoCall, Permit2PermitArgs, Permit2TransferFromArgs, PermitArgs, } from "@morpho-org/blue-sdk-viem";
@@ -1,3 +1,5 @@
1
1
  export type { CapacityLimit, RoundingDirection } from "@morpho-org/blue-sdk";
2
2
  export { AdaptiveCurveIrmLib, CapacityLimitReason, defaultPreLiquidationParamsRegistry, getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
3
- export { decodeBytes32String, getAuthorizationTypedData, getDaiPermitTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
3
+ export { decodeBytes32String, getAuthorizationTypedData,
4
+ /** @deprecated DAI is routed through Permit2 internally; scheduled for removal in the next major. */
5
+ getDaiPermitTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
@@ -1,2 +1,4 @@
1
1
  export { AdaptiveCurveIrmLib, CapacityLimitReason, defaultPreLiquidationParamsRegistry, getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
2
- export { decodeBytes32String, getAuthorizationTypedData, getDaiPermitTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
2
+ export { decodeBytes32String, getAuthorizationTypedData,
3
+ /** @deprecated DAI is routed through Permit2 internally; scheduled for removal in the next major. */
4
+ getDaiPermitTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
@@ -622,6 +622,8 @@ export declare namespace BundlerAction {
622
622
  * @param skipRevert - Whether Bundler3 should tolerate a revert.
623
623
  * @returns Encoded Bundler3 calls.
624
624
  * @throws {BundlerErrors.UnexpectedAction} when the PublicAllocator is unavailable on the chain.
625
+ * @deprecated Vault V1 PublicAllocator composition will be removed in the next major. Use
626
+ * `vaultV2BluePublicAllocatorReallocate` or `vaultV2BluePublicAllocatorAllocateFromIdle`.
625
627
  *
626
628
  * @example
627
629
  * ```ts
@@ -1072,6 +1072,8 @@ export var BundlerAction;
1072
1072
  * @param skipRevert - Whether Bundler3 should tolerate a revert.
1073
1073
  * @returns Encoded Bundler3 calls.
1074
1074
  * @throws {BundlerErrors.UnexpectedAction} when the PublicAllocator is unavailable on the chain.
1075
+ * @deprecated Vault V1 PublicAllocator composition will be removed in the next major. Use
1076
+ * `vaultV2BluePublicAllocatorReallocate` or `vaultV2BluePublicAllocatorAllocateFromIdle`.
1075
1077
  *
1076
1078
  * @example
1077
1079
  * ```ts
@@ -18,6 +18,9 @@ export interface Authorization {
18
18
  }
19
19
  /**
20
20
  * Public allocator withdrawal input used by a `reallocateTo` Bundler3 action.
21
+ *
22
+ * @deprecated Vault V1 PublicAllocator composition will be removed in the next major. Use Vault V2
23
+ * BluePublicAllocator actions.
21
24
  */
22
25
  export interface InputReallocation {
23
26
  /** Market to withdraw liquidity from. */
@@ -172,7 +175,13 @@ export interface ActionArgs {
172
175
  receiver: Address,
173
176
  skipRevert?: boolean
174
177
  ];
175
- /** PublicAllocator reallocation to `supplyMarket` from `vault` withdrawals while paying `fee`; `skipRevert` controls Bundler3 revert handling. */
178
+ /**
179
+ * PublicAllocator reallocation to `supplyMarket` from `vault` withdrawals while paying `fee`;
180
+ * `skipRevert` controls Bundler3 revert handling.
181
+ *
182
+ * @deprecated Vault V1 PublicAllocator composition will be removed in the next major. Use Vault V2
183
+ * BluePublicAllocator actions.
184
+ */
176
185
  readonly reallocateTo: [
177
186
  vault: Address,
178
187
  fee: bigint,
@@ -106,6 +106,8 @@ export interface BlueActions {
106
106
  * When `reallocations` is provided, its homogeneous V1 or V2 actions are
107
107
  * prepended to move liquidity before withdrawing. V1 fees add
108
108
  * to the transaction value; V2 penalties are paid in the loan token.
109
+ * Vault V1 inputs are deprecated for high-level Blue writes; use Vault V2
110
+ * reallocations for new integrations.
109
111
  *
110
112
  * `getRequirements` returns the loan-token approval needed for V2 penalties
111
113
  * and `morpho.setAuthorization(generalAdapter1, true)` when GA1 is not yet
@@ -128,6 +130,7 @@ export interface BlueActions {
128
130
  receiver?: Address;
129
131
  positionData: AccrualPosition;
130
132
  slippageTolerance?: bigint;
133
+ /** Vault V1 inputs are deprecated for high-level Blue writes; prefer Vault V2. */
131
134
  reallocations?: BlueReallocationPlan;
132
135
  } & AssetsOrSharesArgs) => {
133
136
  buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<BlueWithdrawAction>>;
@@ -143,6 +146,8 @@ export interface BlueActions {
143
146
  * When `reallocations` is provided, its homogeneous V1 or V2 actions are
144
147
  * prepended before borrowing. V1 fees add to the transaction
145
148
  * value; V2 penalties are paid in the loan token.
149
+ * Vault V1 inputs are deprecated for high-level Blue writes; use Vault V2
150
+ * reallocations for new integrations.
146
151
  *
147
152
  * `getRequirements` returns the loan-token approval needed for V2 penalties
148
153
  * and Morpho authorization for GeneralAdapter1 when needed.
@@ -164,6 +169,7 @@ export interface BlueActions {
164
169
  amount: bigint;
165
170
  positionData: AccrualPosition;
166
171
  slippageTolerance?: bigint;
172
+ /** Vault V1 inputs are deprecated for high-level Blue writes; prefer Vault V2. */
167
173
  reallocations?: BlueReallocationPlan;
168
174
  }) => {
169
175
  buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<BlueBorrowAction>>;
@@ -265,6 +271,8 @@ export interface BlueActions {
265
271
  * When `reallocations` is provided, its homogeneous V1 or V2 actions run
266
272
  * between the collateral supply and `morphoBorrow`. V1 fees add
267
273
  * to the transaction value; V2 penalties are paid in the loan token.
274
+ * Vault V1 inputs are deprecated for high-level Blue writes; use Vault V2
275
+ * reallocations for new integrations.
268
276
  *
269
277
  * `getRequirements` returns in parallel:
270
278
  * - ERC20 approval or permit for collateral token (to GeneralAdapter1).
@@ -288,6 +296,7 @@ export interface BlueActions {
288
296
  positionData: AccrualPosition;
289
297
  borrowAmount: bigint;
290
298
  slippageTolerance?: bigint;
299
+ /** Vault V1 inputs are deprecated for high-level Blue writes; prefer Vault V2. */
291
300
  reallocations?: BlueReallocationPlan;
292
301
  } & DepositAmountArgs) => {
293
302
  buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<BlueSupplyCollateralBorrowAction>>;
@@ -311,6 +320,8 @@ export interface BlueActions {
311
320
  * A homogeneous V1 or V2 target reallocation plan runs first; V1 fees add
312
321
  * to the transaction value and V2 penalties are paid
313
322
  * in the loan token.
323
+ * Vault V1 inputs are deprecated for high-level Blue writes; use Vault V2
324
+ * reallocations for new integrations.
314
325
  *
315
326
  * `getRequirements` returns the loan-token approval needed for V2 penalties
316
327
  * and Morpho authorization for GeneralAdapter1 when needed.
@@ -323,7 +334,8 @@ export interface BlueActions {
323
334
  * @param params.borrowAssets - Loan assets to repay on source; exclusive with `borrowShares`.
324
335
  * @param params.borrowShares - Borrow shares to repay on source; exclusive with `borrowAssets`.
325
336
  * @param params.slippageTolerance - WAD slippage tolerance. Defaults to `DEFAULT_SLIPPAGE_TOLERANCE`.
326
- * @param params.targetReallocations - Homogeneous Vault V1 or Vault V2 reallocations into the target market.
337
+ * @param params.targetReallocations - Homogeneous Vault V1 or Vault V2 reallocations into the
338
+ * target market. Vault V1 inputs are deprecated; prefer Vault V2.
327
339
  * @returns Object with `buildTx` and `getRequirements`.
328
340
  * @throws {BundlerErrors.UnexpectedAction} when a V2 plan is unsupported on the chain.
329
341
  * @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
@@ -344,6 +356,7 @@ export interface BlueActions {
344
356
  borrowAssets?: bigint;
345
357
  borrowShares?: bigint;
346
358
  slippageTolerance?: bigint;
359
+ /** Vault V1 inputs are deprecated for high-level Blue writes; prefer Vault V2. */
347
360
  targetReallocations?: BlueReallocationPlan;
348
361
  }) => {
349
362
  buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<BlueRefinanceAction>>;
@@ -369,6 +382,8 @@ export interface BlueActions {
369
382
  * @param params.block - The block to fetch data at (number and timestamp).
370
383
  * @returns A VaultV1ReallocationData instance populated with all required data.
371
384
  * @throws {ChainIdMismatchError} when the client chain does not match this market.
385
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
386
+ * {@link getVaultV2BlueReallocationData}.
372
387
  */
373
388
  getVaultV1ReallocationData: (params: {
374
389
  vaultAddresses: readonly Address[];
@@ -385,7 +400,8 @@ export interface BlueActions {
385
400
  * @param params.block.timestamp - Timestamp corresponding to the fetched block.
386
401
  * @returns A `VaultV1ReallocationData` snapshot populated from one block.
387
402
  * @throws {ChainIdMismatchError} when the client chain does not match this market.
388
- * @deprecated Use {@link getVaultV1ReallocationData} instead.
403
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
404
+ * {@link getVaultV2BlueReallocationData}.
389
405
  */
390
406
  getReallocationData: (params: {
391
407
  vaultAddresses: readonly Address[];
@@ -444,6 +460,8 @@ export interface BlueActions {
444
460
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds the target market supply.
445
461
  * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
446
462
  * @throws {UnknownReallocationMarketError} when the target market is absent from the reallocation data.
463
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
464
+ * {@link getVaultV2BlueReallocations}.
447
465
  * @example
448
466
  * ```ts
449
467
  * const reallocations = market.getVaultV1Reallocations({
@@ -468,7 +486,8 @@ export interface BlueActions {
468
486
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
469
487
  * @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
470
488
  * @throws {UnknownReallocationMarketError} when the target market is absent.
471
- * @deprecated Use {@link getVaultV1Reallocations} instead.
489
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
490
+ * {@link getVaultV2BlueReallocations}.
472
491
  * @example
473
492
  * ```ts
474
493
  * const reallocations = market.getReallocations({
@@ -622,6 +641,8 @@ export declare class MorphoBlue implements BlueActions {
622
641
  * @param params.block.timestamp - Timestamp corresponding to the fetched block.
623
642
  * @returns Reallocation data ready for {@link getVaultV1Reallocations}.
624
643
  * @throws {ChainIdMismatchError} when the client chain does not match this market.
644
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
645
+ * {@link getVaultV2BlueReallocationData}.
625
646
  * @example
626
647
  * ```ts
627
648
  * import { markets, vaults } from "@morpho-org/morpho-test";
@@ -655,7 +676,8 @@ export declare class MorphoBlue implements BlueActions {
655
676
  * @param params.block.timestamp - Timestamp corresponding to the fetched block.
656
677
  * @returns A `VaultV1ReallocationData` snapshot populated from one block.
657
678
  * @throws {ChainIdMismatchError} when the client chain does not match this market.
658
- * @deprecated Use {@link getVaultV1ReallocationData} instead.
679
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
680
+ * {@link getVaultV2BlueReallocationData}.
659
681
  * @example
660
682
  * ```ts
661
683
  * const data = await market.getReallocationData({ vaultAddresses, block });
@@ -731,6 +753,8 @@ export declare class MorphoBlue implements BlueActions {
731
753
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets`.
732
754
  * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
733
755
  * @throws {UnknownReallocationMarketError} when the target market is absent from the reallocation data.
756
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
757
+ * {@link getVaultV2BlueReallocations}.
734
758
  * @example
735
759
  * ```ts
736
760
  * const reallocations = market.getVaultV1Reallocations({
@@ -755,7 +779,8 @@ export declare class MorphoBlue implements BlueActions {
755
779
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
756
780
  * @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
757
781
  * @throws {UnknownReallocationMarketError} when the target market is absent.
758
- * @deprecated Use {@link getVaultV1Reallocations} instead.
782
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
783
+ * {@link getVaultV2BlueReallocations}.
759
784
  * @example
760
785
  * ```ts
761
786
  * const reallocations = market.getReallocations({
@@ -914,6 +914,8 @@ export class MorphoBlue {
914
914
  * @param params.block.timestamp - Timestamp corresponding to the fetched block.
915
915
  * @returns Reallocation data ready for {@link getVaultV1Reallocations}.
916
916
  * @throws {ChainIdMismatchError} when the client chain does not match this market.
917
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
918
+ * {@link getVaultV2BlueReallocationData}.
917
919
  * @example
918
920
  * ```ts
919
921
  * import { markets, vaults } from "@morpho-org/morpho-test";
@@ -1007,7 +1009,8 @@ export class MorphoBlue {
1007
1009
  * @param params.block.timestamp - Timestamp corresponding to the fetched block.
1008
1010
  * @returns A `VaultV1ReallocationData` snapshot populated from one block.
1009
1011
  * @throws {ChainIdMismatchError} when the client chain does not match this market.
1010
- * @deprecated Use {@link getVaultV1ReallocationData} instead.
1012
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
1013
+ * {@link getVaultV2BlueReallocationData}.
1011
1014
  * @example
1012
1015
  * ```ts
1013
1016
  * const data = await market.getReallocationData({ vaultAddresses, block });
@@ -1113,6 +1116,8 @@ export class MorphoBlue {
1113
1116
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets`.
1114
1117
  * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
1115
1118
  * @throws {UnknownReallocationMarketError} when the target market is absent from the reallocation data.
1119
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
1120
+ * {@link getVaultV2BlueReallocations}.
1116
1121
  * @example
1117
1122
  * ```ts
1118
1123
  * const reallocations = market.getVaultV1Reallocations({
@@ -1157,7 +1162,8 @@ export class MorphoBlue {
1157
1162
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
1158
1163
  * @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
1159
1164
  * @throws {UnknownReallocationMarketError} when the target market is absent.
1160
- * @deprecated Use {@link getVaultV1Reallocations} instead.
1165
+ * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
1166
+ * {@link getVaultV2BlueReallocations}.
1161
1167
  * @example
1162
1168
  * ```ts
1163
1169
  * const reallocations = market.getReallocations({
@@ -20,8 +20,8 @@ import type { GetOffersDataParams, GetPositionDataParams, MakeLendParams, MakeOf
20
20
  * const output = midnight.takeLend({
21
21
  * accountAddress: lender,
22
22
  * marketData,
23
- * assets: BigInt(quote.data.availableAssets),
24
- * minUnits: BigInt(quote.data.availableUnits),
23
+ * assets: 1_000_000n,
24
+ * minUnits: 900_000n,
25
25
  * takeableOffers: quote.data.takeableOffers,
26
26
  * deadline: maxUint256,
27
27
  * });
@@ -5,10 +5,10 @@ import type { FetchParameters } from "../../types/data.js";
5
5
  import { type ActionOutput, type DepositAmountArgs, type ERC20ApprovalAction, type MorphoClientType, type PermitRequirementSignature, type Requirement, type RequirementSignature, type Transaction, type VaultV1DepositAction, type VaultV1InKindRedeemAction, type VaultV1MigrateToV2Action, type VaultV1RedeemAction, type VaultV1WithdrawAction } from "../../types/index.js";
6
6
  export interface VaultV1Actions {
7
7
  /**
8
- * Fetches the latest vault data with accrued interest.
8
+ * Fetches direct onchain vault and allocation state without applying virtual interest.
9
9
  *
10
10
  * @param {FetchParameters} [parameters] - Optional fetch parameters (block number, state overrides, etc.).
11
- * @returns {Promise<Awaited<ReturnType<typeof fetchAccrualVault>>>} The latest vault data.
11
+ * @returns {Promise<Awaited<ReturnType<typeof fetchAccrualVault>>>} The requested vault state.
12
12
  */
13
13
  getData: (parameters?: FetchParameters) => Promise<Awaited<ReturnType<typeof fetchAccrualVault>>>;
14
14
  /**
@@ -134,18 +134,74 @@ export interface VaultV1Actions {
134
134
  readonly deadline?: bigint;
135
135
  }) => ActionOutput<VaultV1InKindRedeemAction, readonly RequirementSignature[], undefined>;
136
136
  /**
137
- * Prepares a full migration from VaultV1 to VaultV2.
137
+ * Prepares an atomic migration of Vault V1 shares to Vault V2 through bundler3.
138
138
  *
139
- * Redeems all V1 shares and atomically deposits the resulting assets into V2
140
- * via bundler3. Computes slippage-protected share prices for both legs.
139
+ * Accrues the source snapshot before converting V1 shares to assets so pending Vault V1
140
+ * performance-fee shares are reflected in both migration bounds. Projects the target Vault V2
141
+ * two hours forward when computing the deposit-leg maximum share price.
141
142
  *
142
- * @param {Object} params - The migration parameters.
143
- * @param {Address} params.userAddress - User address initiating the migration.
144
- * @param {AccrualVault} params.sourceVault - Pre-fetched V1 vault data.
145
- * @param {AccrualVaultV2} params.targetVault - Pre-fetched V2 vault data.
146
- * @param {bigint} params.shares - User's V1 share balance to migrate.
147
- * @param {bigint} [params.slippageTolerance=DEFAULT_SLIPPAGE_TOLERANCE] - Slippage tolerance (default 0.03%, max 10%).
148
- * @returns {Object} Object with `buildTx` and `getRequirements`.
143
+ * @param params - Migration parameters.
144
+ * @param params.userAddress - Account whose Vault V1 shares are migrated and that receives Vault
145
+ * V2 shares.
146
+ * @param params.sourceVault - Pre-fetched Vault V1 state with market allocations for local accrual.
147
+ * @param params.targetVault - Pre-fetched Vault V2 accrual snapshot with the same underlying
148
+ * asset.
149
+ * @param params.shares - Positive number of Vault V1 shares to migrate.
150
+ * @param params.slippageTolerance - Optional WAD-scaled tolerance; defaults to
151
+ * `DEFAULT_SLIPPAGE_TOLERANCE` and cannot exceed 10%.
152
+ * @returns Lazy approval or permit resolution through `getRequirements()` and a synchronous
153
+ * `buildTx()` returning a deep-frozen `Transaction<VaultV1MigrateToV2Action>`.
154
+ * @throws {ChainIdMismatchError} when the client and entity target different chains.
155
+ * @throws {VaultAddressMismatchError} when `sourceVault` belongs to another vault.
156
+ * @throws {VaultAssetMismatchError} when the source and target assets differ.
157
+ * @throws {NonPositiveInputError} when `shares` is not positive or the target projection yields
158
+ * no shares.
159
+ * @throws {NegativeInputError} when `slippageTolerance` is negative.
160
+ * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds the SDK maximum.
161
+ * @throws {UnknownBlueMarketAllocationError} when `sourceVault.withdrawQueue` references a market
162
+ * absent from `sourceVault.allocations`.
163
+ * @throws {UnsupportedChainIdError} from `getRequirements()` or `buildTx()` when the chain has no
164
+ * address registry.
165
+ * @throws {viem.BaseError} from `getRequirements()` when an RPC contract read fails.
166
+ * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-permit signature is
167
+ * supplied.
168
+ * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when several permit signatures
169
+ * are supplied.
170
+ * @throws {DepositAssetMismatchError} from `buildTx()` when a supplied permit targets another
171
+ * token.
172
+ * @throws {DepositAmountMismatchError} from `buildTx()` when a supplied permit covers another
173
+ * amount.
174
+ * @throws {Permit2ExpirationMissingError} from `buildTx()` when a Permit2 signature lacks an
175
+ * expiration.
176
+ * @example
177
+ * ```ts
178
+ * import {
179
+ * morphoViemExtension,
180
+ * type Transaction,
181
+ * type VaultV1MigrateToV2Action,
182
+ * } from "@morpho-org/morpho-sdk";
183
+ * import { createPublicClient, http } from "viem";
184
+ * import { mainnet } from "viem/chains";
185
+ *
186
+ * const client = createPublicClient({ chain: mainnet, transport: http() }).extend(
187
+ * morphoViemExtension(),
188
+ * );
189
+ * const sourceVaultAddress = "0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB";
190
+ * const targetVaultAddress = "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145";
191
+ * const userAddress = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
192
+ * const source = client.morpho.vaultV1(sourceVaultAddress, mainnet.id);
193
+ * const [sourceVault, targetVault] = await Promise.all([
194
+ * source.getData(),
195
+ * client.morpho.vaultV2(targetVaultAddress, mainnet.id).getData(),
196
+ * ]);
197
+ * const { buildTx } = source.migrateToV2({
198
+ * userAddress,
199
+ * sourceVault,
200
+ * targetVault,
201
+ * shares: 1_000_000n,
202
+ * });
203
+ * const tx: Readonly<Transaction<VaultV1MigrateToV2Action>> = buildTx();
204
+ * ```
149
205
  */
150
206
  migrateToV2: (params: {
151
207
  userAddress: Address;
@@ -194,6 +250,7 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
194
250
  readonly userAddress: Address;
195
251
  readonly deadline?: bigint;
196
252
  }): ActionOutput<VaultV1InKindRedeemAction, readonly RequirementSignature[], undefined>;
253
+ /** {@inheritDoc VaultV1Actions.migrateToV2} */
197
254
  migrateToV2({ userAddress, sourceVault, targetVault, shares, slippageTolerance, }: {
198
255
  userAddress: Address;
199
256
  sourceVault: AccrualVault;