@morpho-org/morpho-sdk 5.4.1 → 5.6.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 (140) hide show
  1. package/README.md +23 -7
  2. package/lib/cjs/abis.d.ts +314 -1
  3. package/lib/cjs/abis.js +169 -1
  4. package/lib/cjs/actions/blue/borrow.d.ts +21 -15
  5. package/lib/cjs/actions/blue/borrow.js +25 -18
  6. package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +1 -1
  7. package/lib/cjs/actions/blue/buildAssetFundingActions.js +1 -1
  8. package/lib/cjs/actions/blue/buildReallocationActions.d.ts +62 -19
  9. package/lib/cjs/actions/blue/buildReallocationActions.js +123 -27
  10. package/lib/cjs/actions/blue/refinance.d.ts +14 -7
  11. package/lib/cjs/actions/blue/refinance.js +18 -10
  12. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +28 -19
  13. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +39 -23
  14. package/lib/cjs/actions/blue/withdraw.d.ts +20 -13
  15. package/lib/cjs/actions/blue/withdraw.js +23 -18
  16. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
  17. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +9 -2
  18. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
  19. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +131 -0
  20. package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
  21. package/lib/cjs/actions/requirements/encode/index.js +1 -0
  22. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +3 -2
  23. package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -3
  24. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
  25. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +91 -0
  26. package/lib/cjs/actions/signatures/index.d.ts +1 -0
  27. package/lib/cjs/actions/signatures/index.js +1 -0
  28. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +54 -0
  29. package/lib/cjs/actions/vaultV1/inKindRedeem.js +96 -0
  30. package/lib/cjs/actions/vaultV1/index.d.ts +1 -0
  31. package/lib/cjs/actions/vaultV1/index.js +1 -0
  32. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +56 -0
  33. package/lib/cjs/actions/vaultV2/inKindRedeem.js +97 -0
  34. package/lib/cjs/actions/vaultV2/index.d.ts +1 -0
  35. package/lib/cjs/actions/vaultV2/index.js +1 -0
  36. package/lib/cjs/bundler/actions.d.ts +118 -2
  37. package/lib/cjs/bundler/actions.js +212 -6
  38. package/lib/cjs/bundler/types.d.ts +20 -0
  39. package/lib/cjs/constants.d.ts +1 -1
  40. package/lib/cjs/constants.js +3 -1
  41. package/lib/cjs/entities/blue/blue.d.ts +365 -76
  42. package/lib/cjs/entities/blue/blue.js +285 -52
  43. package/lib/cjs/entities/index.d.ts +2 -1
  44. package/lib/cjs/entities/index.js +6 -3
  45. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +82 -4
  46. package/lib/cjs/entities/vaultV1/vaultV1.js +164 -0
  47. package/lib/cjs/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +41 -17
  48. package/lib/cjs/entities/{reallocationData.js → vaultV1ReallocationData.js} +30 -18
  49. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +89 -3
  50. package/lib/cjs/entities/vaultV2/vaultV2.js +181 -0
  51. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +511 -0
  52. package/lib/cjs/entities/vaultV2BlueReallocationData.js +1311 -0
  53. package/lib/{esm/helpers/computeReallocations.d.ts → cjs/helpers/computeVaultV1Reallocations.d.ts} +14 -8
  54. package/lib/cjs/helpers/{computeReallocations.js → computeVaultV1Reallocations.js} +27 -13
  55. package/lib/cjs/helpers/constant.d.ts +5 -3
  56. package/lib/cjs/helpers/constant.js +6 -4
  57. package/lib/cjs/helpers/index.d.ts +3 -2
  58. package/lib/cjs/helpers/index.js +8 -3
  59. package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
  60. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +73 -0
  61. package/lib/cjs/helpers/validate.d.ts +31 -15
  62. package/lib/cjs/helpers/validate.js +140 -27
  63. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  64. package/lib/cjs/helpers/validateRequirementSpender.js +2 -1
  65. package/lib/cjs/types/action.d.ts +33 -1
  66. package/lib/cjs/types/error.d.ts +363 -5
  67. package/lib/cjs/types/error.js +455 -6
  68. package/lib/cjs/types/sharedLiquidity.d.ts +72 -8
  69. package/lib/cjs/utils.d.ts +2 -2
  70. package/lib/cjs/utils.js +6 -4
  71. package/lib/esm/abis.d.ts +314 -1
  72. package/lib/esm/abis.js +167 -1
  73. package/lib/esm/actions/blue/borrow.d.ts +21 -15
  74. package/lib/esm/actions/blue/borrow.js +26 -19
  75. package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +1 -1
  76. package/lib/esm/actions/blue/buildAssetFundingActions.js +1 -1
  77. package/lib/esm/actions/blue/buildReallocationActions.d.ts +62 -19
  78. package/lib/esm/actions/blue/buildReallocationActions.js +119 -25
  79. package/lib/esm/actions/blue/refinance.d.ts +14 -7
  80. package/lib/esm/actions/blue/refinance.js +19 -11
  81. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +28 -19
  82. package/lib/esm/actions/blue/supplyCollateralBorrow.js +40 -24
  83. package/lib/esm/actions/blue/withdraw.d.ts +20 -13
  84. package/lib/esm/actions/blue/withdraw.js +24 -19
  85. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
  86. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +9 -2
  87. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
  88. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +127 -0
  89. package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
  90. package/lib/esm/actions/requirements/encode/index.js +1 -0
  91. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +3 -2
  92. package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -3
  93. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
  94. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +87 -0
  95. package/lib/esm/actions/signatures/index.d.ts +1 -0
  96. package/lib/esm/actions/signatures/index.js +1 -0
  97. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +54 -0
  98. package/lib/esm/actions/vaultV1/inKindRedeem.js +92 -0
  99. package/lib/esm/actions/vaultV1/index.d.ts +1 -0
  100. package/lib/esm/actions/vaultV1/index.js +1 -0
  101. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +56 -0
  102. package/lib/esm/actions/vaultV2/inKindRedeem.js +93 -0
  103. package/lib/esm/actions/vaultV2/index.d.ts +1 -0
  104. package/lib/esm/actions/vaultV2/index.js +1 -0
  105. package/lib/esm/bundler/actions.d.ts +118 -2
  106. package/lib/esm/bundler/actions.js +215 -9
  107. package/lib/esm/bundler/types.d.ts +20 -0
  108. package/lib/esm/constants.d.ts +1 -1
  109. package/lib/esm/constants.js +1 -1
  110. package/lib/esm/entities/blue/blue.d.ts +362 -73
  111. package/lib/esm/entities/blue/blue.js +288 -55
  112. package/lib/esm/entities/index.d.ts +2 -1
  113. package/lib/esm/entities/index.js +2 -1
  114. package/lib/esm/entities/vaultV1/vaultV1.d.ts +80 -2
  115. package/lib/esm/entities/vaultV1/vaultV1.js +170 -6
  116. package/lib/esm/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +41 -17
  117. package/lib/esm/entities/{reallocationData.js → vaultV1ReallocationData.js} +33 -16
  118. package/lib/esm/entities/vaultV2/vaultV2.d.ts +88 -2
  119. package/lib/esm/entities/vaultV2/vaultV2.js +187 -6
  120. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +511 -0
  121. package/lib/esm/entities/vaultV2BlueReallocationData.js +1307 -0
  122. package/lib/{cjs/helpers/computeReallocations.d.ts → esm/helpers/computeVaultV1Reallocations.d.ts} +14 -8
  123. package/lib/esm/helpers/{computeReallocations.js → computeVaultV1Reallocations.js} +25 -11
  124. package/lib/esm/helpers/constant.d.ts +5 -3
  125. package/lib/esm/helpers/constant.js +5 -3
  126. package/lib/esm/helpers/index.d.ts +3 -2
  127. package/lib/esm/helpers/index.js +3 -2
  128. package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
  129. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +70 -0
  130. package/lib/esm/helpers/validate.d.ts +31 -15
  131. package/lib/esm/helpers/validate.js +141 -30
  132. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  133. package/lib/esm/helpers/validateRequirementSpender.js +2 -1
  134. package/lib/esm/types/action.d.ts +33 -1
  135. package/lib/esm/types/error.d.ts +363 -5
  136. package/lib/esm/types/error.js +428 -4
  137. package/lib/esm/types/sharedLiquidity.d.ts +72 -8
  138. package/lib/esm/utils.d.ts +2 -2
  139. package/lib/esm/utils.js +2 -2
  140. package/package.json +9 -11
@@ -1,16 +1,21 @@
1
1
  import { deepFreeze } from "@morpho-org/morpho-ts";
2
+ import { isAddressEqual } from "viem";
2
3
  import { BundlerAction } from "../../bundler/index.js";
3
4
  import { addTransactionMetadata } from "../../helpers/index.js";
4
5
  import { NegativeInputError, NonPositiveInputError, } from "../../types/index.js";
5
6
  import { getBlueAuthorizationAction } from "../signatures/getBlueAuthorizationAction.js";
6
7
  import { buildAssetFundingActions } from "./buildAssetFundingActions.js";
7
- import { buildReallocationActions } from "./buildReallocationActions.js";
8
+ import { buildBlueReallocationActions } from "./buildReallocationActions.js";
8
9
  /**
9
10
  * Prepares an atomic supply-collateral-and-borrow transaction for a Morpho Blue market.
10
11
  *
11
- * Routed through bundler3: collateral transfer → `morphoSupplyCollateral` → optional
12
- * `reallocateTo` calls → `morphoBorrow`. When `nativeAmount > 0`, native ETH is wrapped via
13
- * `GeneralAdapter1.wrapNative()` before the supply leg.
12
+ * Routed through bundler3: collateral funding → `morphoSupplyCollateral` → optional Public
13
+ * Allocator calls → `morphoBorrow`. Each plan contains either V1 or V2 entries,
14
+ * never both. When `nativeAmount > 0`, native ETH is wrapped via
15
+ * `GeneralAdapter1.wrapNative()` before the supply leg. V1 fees add to
16
+ * `tx.value`; V2 penalties are paid in the target loan token and donated to the vaults. When the
17
+ * collateral and loan tokens match, one combined pull funds both collateral and penalties through
18
+ * `GeneralAdapter1`.
14
19
  *
15
20
  * Prerequisite: `GeneralAdapter1` must be authorized on Morpho to borrow on behalf of the user.
16
21
  * Use `getRequirements()` on the entity to check and obtain the authorization transaction.
@@ -27,35 +32,40 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
27
32
  * @param params.args.receiver - Address that receives the borrowed assets.
28
33
  * @param params.args.minSharePrice - Minimum borrow share price (in ray). Slippage protection.
29
34
  * @param params.args.requirementSignature - Optional pre-signed permit/permit2 approval for the
30
- * collateral transfer.
35
+ * collateral funding. When collateral and loan tokens match, its amount includes V2 penalties.
31
36
  * @param params.args.nativeAmount - Optional amount of native token to wrap into wNative for the
32
37
  * collateral supply. Requires the collateral token to be the chain's wNative.
33
- * @param params.args.reallocations - Optional vault reallocations to execute between the supply
34
- * and borrow legs, computed by the entity layer.
38
+ * @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
39
+ * execute between the supply and borrow legs.
35
40
  * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
36
41
  * a `setAuthorizationWithSig` call is prepended to the bundle.
37
42
  * @param params.metadata - Optional analytics metadata attached to the bundle.
38
43
  * @returns A deep-frozen `Transaction<BlueSupplyCollateralBorrowAction>` with `to`, `value`,
39
44
  * `data`, and the typed `action` discriminator the simulation layer consumes.
40
- * @throws {NegativeInputError} when `amount`, `nativeAmount`, `minSharePrice`, or any reallocation
41
- * fee is negative.
45
+ * @throws {NegativeInputError} when `amount`, `nativeAmount`, `minSharePrice`, a V1 fee, or a V2
46
+ * penalty is negative.
42
47
  * @throws {NonPositiveInputError} when `borrowAmount <= 0n`, both collateral amounts resolve to
43
48
  * zero, or any reallocation withdrawal amount is non-positive.
49
+ * @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
50
+ * @throws {InconsistentReallocationPenaltyError} when V2 entries for one vault use different penalties.
51
+ * @throws {InvalidReallocationAddressError} when a V2 vault or adapter address is malformed.
52
+ * @throws {InvalidReallocationSourceTypeError} when a V2 source is absent, incomplete, or has an unknown discriminator.
53
+ * @throws {InvalidReallocationShapeError} when an entry matches both or neither V1/V2 shape.
54
+ * @throws {MixedReallocationVersionsError} when one plan contains both V1 and V2 entries.
44
55
  * @throws {ChainWNativeMissingError} when `nativeAmount > 0n` but the chain has no configured wNative.
45
56
  * @throws {NativeAmountOnNonWNativeAssetError} when `nativeAmount > 0n` but the collateral
46
57
  * token is not the chain's wNative.
47
58
  * @throws {DepositAssetMismatchError} from `getTokenRequirementActions` when `requirementSignature`
48
59
  * is provided and the signed asset differs from `marketParams.collateralToken`.
49
60
  * @throws {DepositAmountMismatchError} from `getTokenRequirementActions` when `requirementSignature`
50
- * is provided and the signed amount differs from `args.amount`.
61
+ * is provided and the signed amount differs from the total ERC-20 funding amount.
51
62
  * @throws {Permit2ExpirationMissingError} from `getTokenRequirementActions` when a Permit2 requirement
52
63
  * signature is missing its expiration.
53
- * @throws {EmptyReallocationWithdrawalsError} from `buildReallocationActions` when any
54
- * `reallocation.withdrawals` is empty.
55
- * @throws {ReallocationWithdrawalOnTargetMarketError} from `buildReallocationActions` when any
56
- * reallocation withdrawal references the target market.
57
- * @throws {UnsortedReallocationWithdrawalsError} from `buildReallocationActions` when
58
- * reallocation withdrawals are not strictly sorted by market id.
64
+ * @throws {EmptyReallocationWithdrawalsError} when any `reallocation.withdrawals` is empty.
65
+ * @throws {ReallocationWithdrawalOnTargetMarketError} when any reallocation withdrawal references
66
+ * the target market.
67
+ * @throws {UnsortedReallocationWithdrawalsError} when reallocation withdrawals are not strictly
68
+ * sorted by market id.
59
69
  * @example
60
70
  * ```ts
61
71
  * import { blueSupplyCollateralBorrow } from "@morpho-org/morpho-sdk";
@@ -90,6 +100,16 @@ export const blueSupplyCollateralBorrow = ({ market: { chainId, marketParams },
90
100
  if (totalCollateral === 0n) {
91
101
  throw new NonPositiveInputError("totalCollateral", totalCollateral);
92
102
  }
103
+ const usesSharedFundingToken = isAddressEqual(marketParams.collateralToken, marketParams.loanToken);
104
+ const reallocationResult = buildBlueReallocationActions({
105
+ chainId,
106
+ reallocations,
107
+ targetMarketParams: marketParams,
108
+ penaltyFundingSource: usesSharedFundingToken
109
+ ? "generalAdapter1"
110
+ : "initiator",
111
+ });
112
+ const erc20FundingAmount = amount + (usesSharedFundingToken ? reallocationResult.penaltyAssets : 0n);
93
113
  const actions = [];
94
114
  if (authorizationSignature) {
95
115
  actions.push(getBlueAuthorizationAction(chainId, authorizationSignature));
@@ -97,7 +117,7 @@ export const blueSupplyCollateralBorrow = ({ market: { chainId, marketParams },
97
117
  actions.push(...buildAssetFundingActions({
98
118
  chainId,
99
119
  asset: marketParams.collateralToken,
100
- erc20Amount: amount,
120
+ erc20Amount: erc20FundingAmount,
101
121
  nativeAmount: nativeAmount ?? 0n,
102
122
  requirementSignature,
103
123
  }));
@@ -105,12 +125,7 @@ export const blueSupplyCollateralBorrow = ({ market: { chainId, marketParams },
105
125
  type: "morphoSupplyCollateral",
106
126
  args: [marketParams, totalCollateral, onBehalf, [], false],
107
127
  });
108
- let reallocationFee = 0n;
109
- if (reallocations && reallocations.length > 0) {
110
- const result = buildReallocationActions(reallocations, marketParams);
111
- actions.push(...result.actions);
112
- reallocationFee = result.fee;
113
- }
128
+ actions.push(...reallocationResult.actions);
114
129
  actions.push({
115
130
  type: "morphoBorrow",
116
131
  args: [marketParams, borrowAmount, 0n, minSharePrice, receiver, false],
@@ -131,7 +146,8 @@ export const blueSupplyCollateralBorrow = ({ market: { chainId, marketParams },
131
146
  onBehalf,
132
147
  receiver,
133
148
  nativeAmount,
134
- reallocationFee,
149
+ reallocationFee: reallocationResult.fee,
150
+ reallocationPenaltyAssets: reallocationResult.penaltyAssets,
135
151
  },
136
152
  },
137
153
  });
@@ -1,6 +1,6 @@
1
1
  import type { MarketParams } from "@morpho-org/blue-sdk";
2
2
  import type { Address } from "viem";
3
- import { type AuthorizationRequirementSignature, type BlueWithdrawAction, type Metadata, type Transaction, type VaultReallocation } from "../../types/index.js";
3
+ import { type AuthorizationRequirementSignature, type BlueReallocationPlan, type BlueWithdrawAction, type Metadata, type Transaction } from "../../types/index.js";
4
4
  /** Parameters for {@link blueWithdraw}. */
5
5
  export interface BlueWithdrawParams {
6
6
  market: {
@@ -17,11 +17,11 @@ export interface BlueWithdrawParams {
17
17
  /** Minimum withdraw share price (in ray). Slippage protection. */
18
18
  minSharePrice: bigint;
19
19
  /**
20
- * Vault reallocations to execute before withdrawing. Compute via
21
- * `MorphoBlue.getReallocations({ operation: "withdraw", amount })` or directly via
22
- * `computeReallocations({ operation: "withdraw", amount, ... })`.
20
+ * Homogeneous Vault V1 or Vault V2 reallocations to execute before withdrawing. V1 entries can be
21
+ * computed via `MorphoBlue.getVaultV1Reallocations({ operation: "withdraw", amount })` or directly
22
+ * via `computeVaultV1Reallocations({ operation: "withdraw", amount, ... })`.
23
23
  */
24
- reallocations?: readonly VaultReallocation[];
24
+ reallocations?: BlueReallocationPlan;
25
25
  /**
26
26
  * Optional signed Morpho authorization. When provided, a `setAuthorizationWithSig` call is
27
27
  * prepended to the bundle so GeneralAdapter1 is authorized in-bundle instead of via a
@@ -40,10 +40,11 @@ export interface BlueWithdrawParams {
40
40
  * - **By shares** (`assets = 0, shares > 0`): burns an exact share count (typical for a full
41
41
  * supplier position close; immune to interest accrual between tx construction and execution).
42
42
  *
43
- * When `reallocations` are provided, `reallocateTo` actions are prepended to the bundle, moving
44
- * liquidity from other markets into this one via the PublicAllocator before withdrawing.
45
- * Reallocation fees accumulate in `tx.value`. The on-chain `morphoWithdraw` sends the assets
46
- * computed on-chain directly to `receiver`; no skim is required.
43
+ * A `reallocations` plan contains either V1 entries or V2 market/idle entries,
44
+ * never both. The calls run before the withdraw. V1
45
+ * fees accumulate in `tx.value`; V2 penalties are paid in the target loan
46
+ * token and donated to the vaults. The on-chain `morphoWithdraw` sends the
47
+ * assets computed on-chain directly to `receiver`; no skim is required.
47
48
  *
48
49
  * The withdraw is performed on behalf of the transaction initiator (signer) — there is no
49
50
  * separate `onBehalf` field; mirror `blueBorrow`. The entity layer keeps `receiver` aligned
@@ -57,17 +58,23 @@ export interface BlueWithdrawParams {
57
58
  * @param params.args.receiver - Address that receives the withdrawn assets.
58
59
  * @param params.args.minSharePrice - Minimum acceptable withdraw share price (in ray). Slippage
59
60
  * protection.
60
- * @param params.args.reallocations - Optional vault reallocations to execute before withdrawing,
61
- * computed by the entity layer.
61
+ * @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
62
+ * execute before withdrawing.
62
63
  * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
63
64
  * a `setAuthorizationWithSig` call is prepended to the bundle.
64
65
  * @param params.metadata - Optional analytics metadata attached to the bundle.
65
66
  * @returns A deep-frozen `Transaction<BlueWithdrawAction>` with `to`, `value`, `data`, and
66
67
  * the typed `action` discriminator the simulation layer consumes.
67
- * @throws {NegativeInputError} when `assets`, `shares`, `minSharePrice`, or any reallocation fee
68
- * is negative.
68
+ * @throws {NegativeInputError} when `assets`, `shares`, `minSharePrice`, a V1 fee, or a V2
69
+ * penalty is negative.
69
70
  * @throws {NonPositiveInputError} when both `assets` and `shares` are zero or any reallocation
70
71
  * withdrawal amount is non-positive.
72
+ * @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
73
+ * @throws {InconsistentReallocationPenaltyError} when V2 entries for one vault use different penalties.
74
+ * @throws {InvalidReallocationAddressError} when a V2 vault or adapter address is malformed.
75
+ * @throws {InvalidReallocationSourceTypeError} when a V2 source is absent, incomplete, or has an unknown discriminator.
76
+ * @throws {InvalidReallocationShapeError} when an entry matches both or neither V1/V2 shape.
77
+ * @throws {MixedReallocationVersionsError} when one plan contains both V1 and V2 entries.
71
78
  * @throws {MutuallyExclusiveWithdrawAmountsError} when both `assets` and `shares` are non-zero.
72
79
  * @throws {EmptyReallocationWithdrawalsError} when any reallocation has no withdrawals.
73
80
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a reallocation withdrawal references
@@ -3,7 +3,7 @@ import { BundlerAction } from "../../bundler/index.js";
3
3
  import { addTransactionMetadata } from "../../helpers/index.js";
4
4
  import { MutuallyExclusiveWithdrawAmountsError, NegativeInputError, NonPositiveInputError, } from "../../types/index.js";
5
5
  import { getBlueAuthorizationAction } from "../signatures/getBlueAuthorizationAction.js";
6
- import { buildReallocationActions } from "./buildReallocationActions.js";
6
+ import { buildBlueReallocationActions } from "./buildReallocationActions.js";
7
7
  /**
8
8
  * Prepares a loan-asset withdraw transaction for a Morpho Blue market.
9
9
  *
@@ -13,10 +13,11 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
13
13
  * - **By shares** (`assets = 0, shares > 0`): burns an exact share count (typical for a full
14
14
  * supplier position close; immune to interest accrual between tx construction and execution).
15
15
  *
16
- * When `reallocations` are provided, `reallocateTo` actions are prepended to the bundle, moving
17
- * liquidity from other markets into this one via the PublicAllocator before withdrawing.
18
- * Reallocation fees accumulate in `tx.value`. The on-chain `morphoWithdraw` sends the assets
19
- * computed on-chain directly to `receiver`; no skim is required.
16
+ * A `reallocations` plan contains either V1 entries or V2 market/idle entries,
17
+ * never both. The calls run before the withdraw. V1
18
+ * fees accumulate in `tx.value`; V2 penalties are paid in the target loan
19
+ * token and donated to the vaults. The on-chain `morphoWithdraw` sends the
20
+ * assets computed on-chain directly to `receiver`; no skim is required.
20
21
  *
21
22
  * The withdraw is performed on behalf of the transaction initiator (signer) — there is no
22
23
  * separate `onBehalf` field; mirror `blueBorrow`. The entity layer keeps `receiver` aligned
@@ -30,17 +31,23 @@ import { buildReallocationActions } from "./buildReallocationActions.js";
30
31
  * @param params.args.receiver - Address that receives the withdrawn assets.
31
32
  * @param params.args.minSharePrice - Minimum acceptable withdraw share price (in ray). Slippage
32
33
  * protection.
33
- * @param params.args.reallocations - Optional vault reallocations to execute before withdrawing,
34
- * computed by the entity layer.
34
+ * @param params.args.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocations to
35
+ * execute before withdrawing.
35
36
  * @param params.args.authorizationSignature - Optional signed Morpho authorization; when present,
36
37
  * a `setAuthorizationWithSig` call is prepended to the bundle.
37
38
  * @param params.metadata - Optional analytics metadata attached to the bundle.
38
39
  * @returns A deep-frozen `Transaction<BlueWithdrawAction>` with `to`, `value`, `data`, and
39
40
  * the typed `action` discriminator the simulation layer consumes.
40
- * @throws {NegativeInputError} when `assets`, `shares`, `minSharePrice`, or any reallocation fee
41
- * is negative.
41
+ * @throws {NegativeInputError} when `assets`, `shares`, `minSharePrice`, a V1 fee, or a V2
42
+ * penalty is negative.
42
43
  * @throws {NonPositiveInputError} when both `assets` and `shares` are zero or any reallocation
43
44
  * withdrawal amount is non-positive.
45
+ * @throws {InputExceedsMaxError} when a V2 reallocation asset amount exceeds `uint128` or its penalty exceeds WAD.
46
+ * @throws {InconsistentReallocationPenaltyError} when V2 entries for one vault use different penalties.
47
+ * @throws {InvalidReallocationAddressError} when a V2 vault or adapter address is malformed.
48
+ * @throws {InvalidReallocationSourceTypeError} when a V2 source is absent, incomplete, or has an unknown discriminator.
49
+ * @throws {InvalidReallocationShapeError} when an entry matches both or neither V1/V2 shape.
50
+ * @throws {MixedReallocationVersionsError} when one plan contains both V1 and V2 entries.
44
51
  * @throws {MutuallyExclusiveWithdrawAmountsError} when both `assets` and `shares` are non-zero.
45
52
  * @throws {EmptyReallocationWithdrawalsError} when any reallocation has no withdrawals.
46
53
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a reallocation withdrawal references
@@ -83,23 +90,20 @@ export const blueWithdraw = ({ market: { chainId, marketParams }, args: { assets
83
90
  throw new NegativeInputError("minSharePrice", minSharePrice);
84
91
  }
85
92
  const actions = [];
86
- let reallocationFee = 0n;
87
93
  if (authorizationSignature) {
88
94
  actions.push(getBlueAuthorizationAction(chainId, authorizationSignature));
89
95
  }
90
- if (reallocations && reallocations.length > 0) {
91
- const result = buildReallocationActions(reallocations, marketParams);
92
- actions.push(...result.actions);
93
- reallocationFee = result.fee;
94
- }
96
+ const { actions: reallocationActions, fee: reallocationFee, penaltyAssets: reallocationPenaltyAssets, } = buildBlueReallocationActions({
97
+ chainId,
98
+ reallocations,
99
+ targetMarketParams: marketParams,
100
+ });
101
+ actions.push(...reallocationActions);
95
102
  actions.push({
96
103
  type: "morphoWithdraw",
97
104
  args: [marketParams, assets, shares, minSharePrice, receiver, false],
98
105
  });
99
- let tx = {
100
- ...BundlerAction.encodeBundle(chainId, actions),
101
- value: reallocationFee,
102
- };
106
+ let tx = BundlerAction.encodeBundle(chainId, actions);
103
107
  if (metadata) {
104
108
  tx = addTransactionMetadata(tx, metadata);
105
109
  }
@@ -114,6 +118,7 @@ export const blueWithdraw = ({ market: { chainId, marketParams }, args: { assets
114
118
  receiver,
115
119
  minSharePrice,
116
120
  reallocationFee,
121
+ reallocationPenaltyAssets,
117
122
  },
118
123
  },
119
124
  });
@@ -16,7 +16,7 @@ interface EncodeErc20ApprovalParams {
16
16
  * @param params - Encoding parameters.
17
17
  * @param params.token - ERC-20 token address to approve.
18
18
  * @param params.spender - Address granted the allowance. Must be GeneralAdapter1, Permit2,
19
- * Midnight, or MidnightBundles for the chain.
19
+ * Midnight, MidnightBundles, or VaultExitBundlesV1 for the chain.
20
20
  * @param params.amount - Allowance amount before per-token cap.
21
21
  * @param params.chainId - The chain the transaction targets (used to resolve supported spenders and the per-token cap).
22
22
  * @returns A deep-frozen `Transaction<ERC20ApprovalAction>` with the capped approval amount.
@@ -12,7 +12,7 @@ import { validateRequirementSpender } from "../../../helpers/validateRequirement
12
12
  * @param params - Encoding parameters.
13
13
  * @param params.token - ERC-20 token address to approve.
14
14
  * @param params.spender - Address granted the allowance. Must be GeneralAdapter1, Permit2,
15
- * Midnight, or MidnightBundles for the chain.
15
+ * Midnight, MidnightBundles, or VaultExitBundlesV1 for the chain.
16
16
  * @param params.amount - Allowance amount before per-token cap.
17
17
  * @param params.chainId - The chain the transaction targets (used to resolve supported spenders and the per-token cap).
18
18
  * @returns A deep-frozen `Transaction<ERC20ApprovalAction>` with the capped approval amount.
@@ -32,10 +32,17 @@ import { validateRequirementSpender } from "../../../helpers/validateRequirement
32
32
  */
33
33
  export const encodeErc20Approval = (params) => {
34
34
  const { token, spender, amount, chainId } = params;
35
+ // Reject approval targets outside the SDK's registered protocol spenders.
35
36
  validateRequirementSpender({
36
37
  chainId,
37
38
  spender,
38
- allowed: ["generalAdapter1", "permit2", "midnight", "midnightBundles"],
39
+ allowed: [
40
+ "generalAdapter1",
41
+ "permit2",
42
+ "midnight",
43
+ "midnightBundles",
44
+ "vaultExitBundlesV1",
45
+ ],
39
46
  });
40
47
  const amountValue = MathLib.min(amount, MAX_TOKEN_APPROVALS[chainId]?.[token] ?? maxUint256);
41
48
  return deepFreeze({
@@ -0,0 +1,64 @@
1
+ import { type Address, Token } from "@morpho-org/blue-sdk";
2
+ import type { PermitRequirementSignature, Requirement } from "../../../types/index.js";
3
+ /** Parameters for {@link encodeVaultSharesPermit}. */
4
+ export interface EncodeVaultSharesPermitParams {
5
+ /** Vault share token, including V1 permit-domain metadata when available. */
6
+ readonly vault: Token;
7
+ /** Vault generation, which selects the standard V1 or two-field V2 domain. */
8
+ readonly version: "vaultV1" | "vaultV2";
9
+ /** VaultExitBundlesV1 spender. */
10
+ readonly spender: Address;
11
+ /** Account that owns the vault shares. */
12
+ readonly owner: Address;
13
+ /** Target chain. */
14
+ readonly chainId: number;
15
+ /** Current vault permit nonce for the owner. */
16
+ readonly nonce: bigint;
17
+ /** Vault-share allowance to authorize. */
18
+ readonly amount: bigint;
19
+ /** Shared permit and bundle deadline. */
20
+ readonly deadline: bigint;
21
+ }
22
+ /**
23
+ * Builds the bounded ERC-2612 shares-permit requirement used by an in-kind vault exit.
24
+ *
25
+ * Vault V1 uses the standard token permit domain. Vault V2 uses its protocol-specific domain with
26
+ * only `chainId` and `verifyingContract`.
27
+ *
28
+ * @param params.vault - Vault share token, including V1 permit-domain metadata when available.
29
+ * @param params.version - Vault generation selecting the standard V1 or two-field V2 domain.
30
+ * @param params.spender - Registered VaultExitBundlesV1 spender.
31
+ * @param params.owner - Account that owns and authorizes spending of the vault shares.
32
+ * @param params.chainId - Chain on which the vault and spender are deployed.
33
+ * @param params.nonce - Current vault permit nonce for the owner.
34
+ * @param params.amount - Vault-share allowance to authorize.
35
+ * @param params.deadline - Shared permit and bundle deadline.
36
+ * @returns A requirement whose `sign()` result can be embedded in VaultExitBundlesV1 calldata.
37
+ * @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
38
+ * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not the registered VaultExitBundlesV1.
39
+ * @throws {MissingClientPropertyError} from `sign()` when the wallet has no account.
40
+ * @throws {AddressMismatchError} from `sign()` when the wallet account differs from `owner`.
41
+ * @throws {ChainIdMismatchError} from `sign()` when the wallet targets another chain.
42
+ * @throws {InvalidSignatureError} from `sign()` when signature recovery fails.
43
+ * @throws {InvalidPermitDomainChainIdError} from `sign()` when a Vault V1 permit domain targets another chain or omits `chainId`.
44
+ * @throws {InvalidPermitDomainVerifyingContractError} from `sign()` when a Vault V1 permit domain targets another token or omits `verifyingContract`.
45
+ * @throws {UnsupportedPermitDomainExtensionsError} from `sign()` when a Vault V1 permit domain advertises unsupported extensions.
46
+ * @example
47
+ * ```ts
48
+ * import { encodeVaultSharesPermit } from "@morpho-org/morpho-sdk";
49
+ *
50
+ * const requirement = encodeVaultSharesPermit({
51
+ * vault: vaultData,
52
+ * version: "vaultV2",
53
+ * spender: vaultExitBundlesV1,
54
+ * owner,
55
+ * chainId: 1,
56
+ * nonce: 0n,
57
+ * amount: 1_000_000n,
58
+ * deadline,
59
+ * });
60
+ * const signature = await requirement.sign(walletClient, owner);
61
+ * // signature satisfies PermitRequirementSignature
62
+ * ```
63
+ */
64
+ export declare const encodeVaultSharesPermit: (params: EncodeVaultSharesPermitParams) => Requirement<PermitRequirementSignature>;
@@ -0,0 +1,127 @@
1
+ import { Eip5267Domain, Token } from "@morpho-org/blue-sdk";
2
+ import { getPermitTypedData } from "@morpho-org/blue-sdk-viem";
3
+ import { deepFreeze } from "@morpho-org/morpho-ts";
4
+ import { zeroHash } from "viem";
5
+ import { signAndVerifyTypedData } from "../../../helpers/signAndVerifyTypedData.js";
6
+ import { validateUserAddress } from "../../../helpers/validate.js";
7
+ import { validateRequirementSpender } from "../../../helpers/validateRequirementSpender.js";
8
+ /**
9
+ * Builds the bounded ERC-2612 shares-permit requirement used by an in-kind vault exit.
10
+ *
11
+ * Vault V1 uses the standard token permit domain. Vault V2 uses its protocol-specific domain with
12
+ * only `chainId` and `verifyingContract`.
13
+ *
14
+ * @param params.vault - Vault share token, including V1 permit-domain metadata when available.
15
+ * @param params.version - Vault generation selecting the standard V1 or two-field V2 domain.
16
+ * @param params.spender - Registered VaultExitBundlesV1 spender.
17
+ * @param params.owner - Account that owns and authorizes spending of the vault shares.
18
+ * @param params.chainId - Chain on which the vault and spender are deployed.
19
+ * @param params.nonce - Current vault permit nonce for the owner.
20
+ * @param params.amount - Vault-share allowance to authorize.
21
+ * @param params.deadline - Shared permit and bundle deadline.
22
+ * @returns A requirement whose `sign()` result can be embedded in VaultExitBundlesV1 calldata.
23
+ * @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
24
+ * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not the registered VaultExitBundlesV1.
25
+ * @throws {MissingClientPropertyError} from `sign()` when the wallet has no account.
26
+ * @throws {AddressMismatchError} from `sign()` when the wallet account differs from `owner`.
27
+ * @throws {ChainIdMismatchError} from `sign()` when the wallet targets another chain.
28
+ * @throws {InvalidSignatureError} from `sign()` when signature recovery fails.
29
+ * @throws {InvalidPermitDomainChainIdError} from `sign()` when a Vault V1 permit domain targets another chain or omits `chainId`.
30
+ * @throws {InvalidPermitDomainVerifyingContractError} from `sign()` when a Vault V1 permit domain targets another token or omits `verifyingContract`.
31
+ * @throws {UnsupportedPermitDomainExtensionsError} from `sign()` when a Vault V1 permit domain advertises unsupported extensions.
32
+ * @example
33
+ * ```ts
34
+ * import { encodeVaultSharesPermit } from "@morpho-org/morpho-sdk";
35
+ *
36
+ * const requirement = encodeVaultSharesPermit({
37
+ * vault: vaultData,
38
+ * version: "vaultV2",
39
+ * spender: vaultExitBundlesV1,
40
+ * owner,
41
+ * chainId: 1,
42
+ * nonce: 0n,
43
+ * amount: 1_000_000n,
44
+ * deadline,
45
+ * });
46
+ * const signature = await requirement.sign(walletClient, owner);
47
+ * // signature satisfies PermitRequirementSignature
48
+ * ```
49
+ */
50
+ export const encodeVaultSharesPermit = (params) => {
51
+ const { vault: inputVault, version, spender, owner, chainId, nonce, amount, deadline, } = params;
52
+ const inputDomain = inputVault.eip5267Domain;
53
+ const vault = new Token({
54
+ address: inputVault.address,
55
+ name: inputVault.name,
56
+ eip5267Domain: version === "vaultV2"
57
+ ? new Eip5267Domain({
58
+ // Only the bitmap-selected fields enter Vault V2's domain separator.
59
+ fields: "0x0c",
60
+ name: "",
61
+ version: "",
62
+ chainId: BigInt(chainId),
63
+ verifyingContract: inputVault.address,
64
+ salt: zeroHash,
65
+ extensions: [],
66
+ })
67
+ : inputDomain == null
68
+ ? undefined
69
+ : new Eip5267Domain({
70
+ fields: inputDomain.fields,
71
+ name: inputDomain.name,
72
+ version: inputDomain.version,
73
+ chainId: inputDomain.chainId,
74
+ verifyingContract: inputDomain.verifyingContract,
75
+ salt: inputDomain.salt,
76
+ extensions: [...inputDomain.extensions],
77
+ }),
78
+ });
79
+ // Bind the permit to the standalone vault-exit deployment for this chain.
80
+ validateRequirementSpender({
81
+ chainId,
82
+ spender,
83
+ allowed: ["vaultExitBundlesV1"],
84
+ });
85
+ const action = {
86
+ type: "permit",
87
+ args: {
88
+ spender,
89
+ amount,
90
+ deadline,
91
+ },
92
+ };
93
+ return {
94
+ action,
95
+ async sign(client, userAddress) {
96
+ // The bundle spends msg.sender's shares, so another signer cannot authorize this exit.
97
+ validateUserAddress(userAddress, owner);
98
+ const permit = {
99
+ owner,
100
+ spender,
101
+ allowance: amount,
102
+ nonce,
103
+ deadline,
104
+ };
105
+ const typedData = getPermitTypedData({
106
+ ...permit,
107
+ erc20: vault,
108
+ }, chainId);
109
+ const signature = await signAndVerifyTypedData({
110
+ client,
111
+ userAddress,
112
+ typedData,
113
+ });
114
+ return deepFreeze({
115
+ args: {
116
+ owner,
117
+ signature,
118
+ deadline,
119
+ amount,
120
+ asset: vault.address,
121
+ nonce,
122
+ },
123
+ action,
124
+ });
125
+ },
126
+ };
127
+ };
@@ -2,3 +2,4 @@ export * from "./encodeBlueSignatureAuthorization.js";
2
2
  export * from "./encodeErc20Approval.js";
3
3
  export * from "./encodeErc20Permit.js";
4
4
  export * from "./encodeErc20Permit2Approve.js";
5
+ export * from "./encodeVaultSharesPermit.js";
@@ -2,3 +2,4 @@ export * from "./encodeBlueSignatureAuthorization.js";
2
2
  export * from "./encodeErc20Approval.js";
3
3
  export * from "./encodeErc20Permit.js";
4
4
  export * from "./encodeErc20Permit2Approve.js";
5
+ export * from "./encodeVaultSharesPermit.js";
@@ -5,7 +5,8 @@ import { type ERC20ApprovalAction, type Transaction } from "../../types/index.js
5
5
  * allowance.
6
6
  *
7
7
  * The spender is validated by {@link encodeErc20Approval}. Supported spenders are the chain's
8
- * GeneralAdapter1, Permit2, Midnight, and MidnightBundles addresses when configured.
8
+ * GeneralAdapter1, Permit2, Midnight, MidnightBundles, and VaultExitBundlesV1 addresses when
9
+ * configured.
9
10
  *
10
11
  * Returns an empty array when the allowance already covers `spendAmount`. When the token is in
11
12
  * `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) and the existing allowance is non-zero, prepends a
@@ -19,7 +20,7 @@ import { type ERC20ApprovalAction, type Transaction } from "../../types/index.js
19
20
  * @param params.args.approvalAmount - The amount to approve (often equal to `spendAmount`, but
20
21
  * may be `MAX_UINT_160` for Permit2 prerequisites).
21
22
  * @param params.args.spender - Address that will be granted the approval. Must be GeneralAdapter1,
22
- * Permit2, Midnight, or MidnightBundles for `chainId`.
23
+ * Permit2, Midnight, MidnightBundles, or VaultExitBundlesV1 for `chainId`.
23
24
  * @param params.allowances - The user's current allowance of `address` for `spender`.
24
25
  * @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
25
26
  * followed by the new approval. Empty when no approval is needed.
@@ -1,3 +1,4 @@
1
+ import { isAddressEqual } from "viem";
1
2
  import { APPROVE_ONLY_ONCE_TOKENS } from "../../helpers/constant.js";
2
3
  import { ApprovalAmountLessThanSpendAmountError, } from "../../types/index.js";
3
4
  import { encodeErc20Approval } from "./encode/encodeErc20Approval.js";
@@ -6,7 +7,8 @@ import { encodeErc20Approval } from "./encode/encodeErc20Approval.js";
6
7
  * allowance.
7
8
  *
8
9
  * The spender is validated by {@link encodeErc20Approval}. Supported spenders are the chain's
9
- * GeneralAdapter1, Permit2, Midnight, and MidnightBundles addresses when configured.
10
+ * GeneralAdapter1, Permit2, Midnight, MidnightBundles, and VaultExitBundlesV1 addresses when
11
+ * configured.
10
12
  *
11
13
  * Returns an empty array when the allowance already covers `spendAmount`. When the token is in
12
14
  * `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) and the existing allowance is non-zero, prepends a
@@ -20,7 +22,7 @@ import { encodeErc20Approval } from "./encode/encodeErc20Approval.js";
20
22
  * @param params.args.approvalAmount - The amount to approve (often equal to `spendAmount`, but
21
23
  * may be `MAX_UINT_160` for Permit2 prerequisites).
22
24
  * @param params.args.spender - Address that will be granted the approval. Must be GeneralAdapter1,
23
- * Permit2, Midnight, or MidnightBundles for `chainId`.
25
+ * Permit2, Midnight, MidnightBundles, or VaultExitBundlesV1 for `chainId`.
24
26
  * @param params.allowances - The user's current allowance of `address` for `spender`.
25
27
  * @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
26
28
  * followed by the new approval. Empty when no approval is needed.
@@ -46,7 +48,7 @@ export const getRequirementsApproval = (params) => {
46
48
  }
47
49
  const approvals = [];
48
50
  if (allowances < spendAmount) {
49
- if (APPROVE_ONLY_ONCE_TOKENS[chainId]?.includes(address) &&
51
+ if (APPROVE_ONLY_ONCE_TOKENS[chainId]?.some((token) => isAddressEqual(token, address)) &&
50
52
  allowances > 0n) {
51
53
  approvals.push(encodeErc20Approval({
52
54
  token: address,
@@ -0,0 +1,52 @@
1
+ import { type Address, type Hex } from "viem";
2
+ import { type PermitRequirementSignature } from "../../types/index.js";
3
+ /** Permit tuple consumed by VaultExitBundlesV1. */
4
+ export interface VaultExitBundlesV1PermitStruct {
5
+ /** Vault-share allowance authorized by the permit. */
6
+ readonly value: bigint;
7
+ /** Vault permit nonce signed by the owner. */
8
+ readonly nonce: bigint;
9
+ /** Timestamp after which the permit is invalid. */
10
+ readonly deadline: bigint;
11
+ /** ECDSA recovery identifier, or zero for the empty-permit sentinel. */
12
+ readonly v: number;
13
+ /** ECDSA signature `r`, or zero for the empty-permit sentinel. */
14
+ readonly r: Hex;
15
+ /** ECDSA signature `s`, or zero for the empty-permit sentinel. */
16
+ readonly s: Hex;
17
+ }
18
+ /** Parameters for {@link getVaultExitBundlesV1PermitStruct}. */
19
+ export interface GetVaultExitBundlesV1PermitStructParams {
20
+ /** Vault share token authorized by the permit. */
21
+ readonly vault: Address;
22
+ /** Bundle deadline used by the empty-permit sentinel. */
23
+ readonly deadline: bigint;
24
+ /** Optional signed bounded ERC-2612 requirement. */
25
+ readonly requirementSignature?: PermitRequirementSignature;
26
+ }
27
+ /**
28
+ * Returns the permit struct consumed by VaultExitBundlesV1 from an optional vault-share
29
+ * requirement signature.
30
+ *
31
+ * Without a signature, returns the contract's empty-permit sentinel. With a signature, validates
32
+ * the ERC-2612 kind and vault asset before splitting the serialized signature.
33
+ * Owner, spender, deadline, nonce, and cryptographic validity are verified onchain by the vault.
34
+ *
35
+ * @param params.vault - Vault share token authorized by the permit.
36
+ * @param params.deadline - Bundle deadline used by the empty-permit sentinel.
37
+ * @param params.requirementSignature - Optional signed bounded ERC-2612 requirement.
38
+ * @returns The VaultExitBundlesV1 permit tuple.
39
+ * @throws {VaultExitBundlesV1PermitMismatchError} when the requirement has the wrong permit kind, asset, or signature encoding.
40
+ * @example
41
+ * ```ts
42
+ * import { getVaultExitBundlesV1PermitStruct } from "@morpho-org/morpho-sdk";
43
+ *
44
+ * const permit = getVaultExitBundlesV1PermitStruct({
45
+ * vault,
46
+ * deadline,
47
+ * requirementSignature,
48
+ * });
49
+ * // permit satisfies VaultExitBundlesV1PermitStruct
50
+ * ```
51
+ */
52
+ export declare const getVaultExitBundlesV1PermitStruct: (params: GetVaultExitBundlesV1PermitStructParams) => VaultExitBundlesV1PermitStruct;