@morpho-org/morpho-sdk 5.4.0 → 5.5.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 (84) hide show
  1. package/README.md +15 -1
  2. package/lib/cjs/abis.d.ts +313 -0
  3. package/lib/cjs/abis.js +167 -1
  4. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
  5. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +9 -2
  6. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
  7. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +131 -0
  8. package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
  9. package/lib/cjs/actions/requirements/encode/index.js +1 -0
  10. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +3 -2
  11. package/lib/cjs/actions/requirements/getRequirementsApproval.js +3 -2
  12. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
  13. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +91 -0
  14. package/lib/cjs/actions/signatures/index.d.ts +1 -0
  15. package/lib/cjs/actions/signatures/index.js +1 -0
  16. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +54 -0
  17. package/lib/cjs/actions/vaultV1/inKindRedeem.js +96 -0
  18. package/lib/cjs/actions/vaultV1/index.d.ts +1 -0
  19. package/lib/cjs/actions/vaultV1/index.js +1 -0
  20. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +56 -0
  21. package/lib/cjs/actions/vaultV2/inKindRedeem.js +97 -0
  22. package/lib/cjs/actions/vaultV2/index.d.ts +1 -0
  23. package/lib/cjs/actions/vaultV2/index.js +1 -0
  24. package/lib/cjs/bundler/actions.d.ts +1 -2
  25. package/lib/cjs/bundler/actions.js +1 -2
  26. package/lib/cjs/entities/blue/blue.d.ts +8 -8
  27. package/lib/cjs/entities/reallocationData.d.ts +1 -2
  28. package/lib/cjs/entities/reallocationData.js +1 -2
  29. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +82 -4
  30. package/lib/cjs/entities/vaultV1/vaultV1.js +164 -0
  31. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +89 -3
  32. package/lib/cjs/entities/vaultV2/vaultV2.js +181 -0
  33. package/lib/cjs/helpers/index.d.ts +1 -0
  34. package/lib/cjs/helpers/index.js +3 -1
  35. package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
  36. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +73 -0
  37. package/lib/cjs/helpers/validate.d.ts +1 -1
  38. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  39. package/lib/cjs/helpers/validateRequirementSpender.js +2 -1
  40. package/lib/cjs/types/action.d.ts +21 -1
  41. package/lib/cjs/types/error.d.ts +139 -0
  42. package/lib/cjs/types/error.js +189 -2
  43. package/lib/esm/abis.d.ts +313 -0
  44. package/lib/esm/abis.js +166 -0
  45. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
  46. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +9 -2
  47. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
  48. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +127 -0
  49. package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
  50. package/lib/esm/actions/requirements/encode/index.js +1 -0
  51. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +3 -2
  52. package/lib/esm/actions/requirements/getRequirementsApproval.js +3 -2
  53. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
  54. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +87 -0
  55. package/lib/esm/actions/signatures/index.d.ts +1 -0
  56. package/lib/esm/actions/signatures/index.js +1 -0
  57. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +54 -0
  58. package/lib/esm/actions/vaultV1/inKindRedeem.js +92 -0
  59. package/lib/esm/actions/vaultV1/index.d.ts +1 -0
  60. package/lib/esm/actions/vaultV1/index.js +1 -0
  61. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +56 -0
  62. package/lib/esm/actions/vaultV2/inKindRedeem.js +93 -0
  63. package/lib/esm/actions/vaultV2/index.d.ts +1 -0
  64. package/lib/esm/actions/vaultV2/index.js +1 -0
  65. package/lib/esm/bundler/actions.d.ts +1 -2
  66. package/lib/esm/bundler/actions.js +1 -2
  67. package/lib/esm/entities/blue/blue.d.ts +5 -5
  68. package/lib/esm/entities/reallocationData.d.ts +1 -2
  69. package/lib/esm/entities/reallocationData.js +1 -2
  70. package/lib/esm/entities/vaultV1/vaultV1.d.ts +80 -2
  71. package/lib/esm/entities/vaultV1/vaultV1.js +170 -6
  72. package/lib/esm/entities/vaultV2/vaultV2.d.ts +88 -2
  73. package/lib/esm/entities/vaultV2/vaultV2.js +187 -6
  74. package/lib/esm/helpers/index.d.ts +1 -0
  75. package/lib/esm/helpers/index.js +1 -0
  76. package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
  77. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +70 -0
  78. package/lib/esm/helpers/validate.d.ts +1 -1
  79. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  80. package/lib/esm/helpers/validateRequirementSpender.js +2 -1
  81. package/lib/esm/types/action.d.ts +21 -1
  82. package/lib/esm/types/error.d.ts +139 -0
  83. package/lib/esm/types/error.js +175 -0
  84. package/package.json +9 -11
package/README.md CHANGED
@@ -23,18 +23,28 @@ Each entity exposes a set of actions. Bundled actions route through bundler3 (vi
23
23
  | --- | --- | --- |
24
24
  | **VaultV1** (MetaMorpho) | `deposit`, `migrateToV2` | Bundler |
25
25
  | | `withdraw`, `redeem` | Direct call |
26
+ | | `inKindRedeem` | VaultExitBundlesV1 |
26
27
  | **VaultV2** | `deposit` | Bundler |
27
28
  | | `withdraw`, `redeem` | Direct call |
28
29
  | | `forceWithdraw`, `forceRedeem` | Vault multicall |
30
+ | | `inKindRedeem` | VaultExitBundlesV1 |
29
31
  | **Blue** | `supply`, `supplyCollateral`, `borrow`, `supplyCollateralBorrow`, `repay`, `withdraw`, `repayWithdrawCollateral`, `refinance` | Bundler |
30
32
  | | `withdrawCollateral` | Direct call |
31
33
  | **Midnight** | `takeLend`, `takeBorrow`, `supplyCollateralTakeBorrow`, `repayWithdrawCollateral` | Midnight Bundles |
32
34
  | | `makeLend`, `makeBorrow` | Midnight mempool |
33
35
  | | `supplyCollateral`, `redeem`, `cancelOffer` | Direct call |
34
36
 
37
+ `VaultExitBundlesV1` is registered on Ethereum, Base, Arbitrum, Optimism, Polygon, World Chain,
38
+ Unichain, HyperEVM, Katana, Monad, Stable, Tempo, and Robinhood Chain. Custom deployments can still
39
+ be configured with `registerCustomAddresses`.
40
+
35
41
  ## How it works
36
42
 
37
- Actions that pull tokens or touch a position return `{ buildTx, getRequirements }`. Direct calls — vault `withdraw` / `redeem`, `forceWithdraw` / `forceRedeem`, and Blue `withdrawCollateral` — have no prerequisites and return only `{ buildTx }`.
43
+ Actions that pull tokens or touch a position return `{ buildTx, getRequirements }`. Vault
44
+ `inKindRedeem` uses this shape so callers can await `getRequirements()` to check live Blue liquidity
45
+ and share authorization before invoking `buildTx()`. Calling `buildTx()` directly skips those
46
+ RPC-backed pre-flight checks. Other direct calls — vault `withdraw` / `redeem`, `forceWithdraw` /
47
+ `forceRedeem`, and Blue `withdrawCollateral` — have no prerequisites and return only `{ buildTx }`.
38
48
 
39
49
  - **`getRequirements()`** — async; the on-chain prerequisites to satisfy first: ERC-20 approvals, permit / Permit2 signatures, Morpho authorization, or (for Midnight) operator authorization and offer-root signatures.
40
50
  - **`buildTx(signatures?)`** — synchronous; the final, deep-frozen viem transaction. Pass any signatures collected from the requirements.
@@ -186,11 +196,13 @@ graph LR
186
196
  MV1 --> V1D[vaultV1Deposit]
187
197
  MV1 --> V1W[vaultV1Withdraw]
188
198
  MV1 --> V1R[vaultV1Redeem]
199
+ MV1 --> V1IKR[vaultV1InKindRedeem]
189
200
  MV1 --> V1M[vaultV1MigrateToV2]
190
201
 
191
202
  V1D -->|nativeTransfer + wrapNative + erc4626Deposit| B1[Bundler3]
192
203
  V1W -->|direct call| MM[MetaMorpho]
193
204
  V1R -->|direct call| MM
205
+ V1IKR -->|direct call| VEB[VaultExitBundlesV1]
194
206
  V1M -->|erc20TransferFrom + erc4626Redeem + erc4626Deposit| B1
195
207
  end
196
208
 
@@ -199,12 +211,14 @@ graph LR
199
211
  MV2 --> V2D[vaultV2Deposit]
200
212
  MV2 --> V2W[vaultV2Withdraw]
201
213
  MV2 --> V2R[vaultV2Redeem]
214
+ MV2 --> V2IKR[vaultV2InKindRedeem]
202
215
  MV2 --> V2FW[vaultV2ForceWithdraw]
203
216
  MV2 --> V2FR[vaultV2ForceRedeem]
204
217
 
205
218
  V2D -->|nativeTransfer + wrapNative + erc4626Deposit| B2[Bundler3]
206
219
  V2W -->|direct call| V2C[VaultV2 Contract]
207
220
  V2R -->|direct call| V2C
221
+ V2IKR -->|direct call| VEB
208
222
  V2FW -->|multicall| V2C
209
223
  V2FR -->|multicall| V2C
210
224
  end
package/lib/cjs/abis.d.ts CHANGED
@@ -1,6 +1,319 @@
1
1
  export { marketParamsAbi } from "@morpho-org/blue-sdk";
2
2
  export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi, preLiquidationFactoryAbi, publicAllocatorAbi, vaultV1AdapterAbi, vaultV1AdapterFactoryAbi, vaultV2Abi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
3
3
  export { ecrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
4
+ /** ABI for the VaultExitBundlesV1 periphery contract. */
5
+ export declare const vaultExitBundlesV1Abi: readonly [{
6
+ readonly type: "constructor";
7
+ readonly inputs: readonly [{
8
+ readonly name: "_blue";
9
+ readonly type: "address";
10
+ readonly internalType: "address";
11
+ }];
12
+ readonly stateMutability: "nonpayable";
13
+ }, {
14
+ readonly type: "error";
15
+ readonly name: "AdapterNotPartOfVault";
16
+ readonly inputs: readonly [];
17
+ }, {
18
+ readonly type: "error";
19
+ readonly name: "AlreadyInitiated";
20
+ readonly inputs: readonly [];
21
+ }, {
22
+ readonly type: "error";
23
+ readonly name: "ApproveReturnedFalse";
24
+ readonly inputs: readonly [];
25
+ }, {
26
+ readonly type: "error";
27
+ readonly name: "DeadlinePassed";
28
+ readonly inputs: readonly [];
29
+ }, {
30
+ readonly type: "error";
31
+ readonly name: "InvalidAdaptersLength";
32
+ readonly inputs: readonly [];
33
+ }, {
34
+ readonly type: "error";
35
+ readonly name: "MorphoMismatch";
36
+ readonly inputs: readonly [];
37
+ }, {
38
+ readonly type: "error";
39
+ readonly name: "NoCode";
40
+ readonly inputs: readonly [];
41
+ }, {
42
+ readonly type: "error";
43
+ readonly name: "PctExceeded";
44
+ readonly inputs: readonly [];
45
+ }, {
46
+ readonly type: "error";
47
+ readonly name: "SlippageExceeded";
48
+ readonly inputs: readonly [];
49
+ }, {
50
+ readonly type: "error";
51
+ readonly name: "TransferReturnedFalse";
52
+ readonly inputs: readonly [];
53
+ }, {
54
+ readonly type: "error";
55
+ readonly name: "UnauthorizedCallback";
56
+ readonly inputs: readonly [];
57
+ }, {
58
+ readonly type: "function";
59
+ readonly name: "BLUE";
60
+ readonly inputs: readonly [];
61
+ readonly outputs: readonly [{
62
+ readonly name: "";
63
+ readonly type: "address";
64
+ readonly internalType: "address";
65
+ }];
66
+ readonly stateMutability: "view";
67
+ }, {
68
+ readonly type: "function";
69
+ readonly name: "initiator";
70
+ readonly inputs: readonly [];
71
+ readonly outputs: readonly [{
72
+ readonly name: "";
73
+ readonly type: "address";
74
+ readonly internalType: "address";
75
+ }];
76
+ readonly stateMutability: "view";
77
+ }, {
78
+ readonly type: "function";
79
+ readonly name: "onMorphoFlashLoan";
80
+ readonly inputs: readonly [{
81
+ readonly name: "exitAssets";
82
+ readonly type: "uint256";
83
+ readonly internalType: "uint256";
84
+ }, {
85
+ readonly name: "data";
86
+ readonly type: "bytes";
87
+ readonly internalType: "bytes";
88
+ }];
89
+ readonly outputs: readonly [];
90
+ readonly stateMutability: "nonpayable";
91
+ }, {
92
+ readonly type: "function";
93
+ readonly name: "onMorphoSupply";
94
+ readonly inputs: readonly [{
95
+ readonly name: "assets";
96
+ readonly type: "uint256";
97
+ readonly internalType: "uint256";
98
+ }, {
99
+ readonly name: "data";
100
+ readonly type: "bytes";
101
+ readonly internalType: "bytes";
102
+ }];
103
+ readonly outputs: readonly [];
104
+ readonly stateMutability: "nonpayable";
105
+ }, {
106
+ readonly type: "function";
107
+ readonly name: "vaultExitBundlesV1ForceWithdrawVaultV2";
108
+ readonly inputs: readonly [{
109
+ readonly name: "vault";
110
+ readonly type: "address";
111
+ readonly internalType: "address";
112
+ }, {
113
+ readonly name: "adapter";
114
+ readonly type: "address";
115
+ readonly internalType: "address";
116
+ }, {
117
+ readonly name: "exitAssets";
118
+ readonly type: "uint256";
119
+ readonly internalType: "uint256";
120
+ }, {
121
+ readonly name: "minSharePriceE27";
122
+ readonly type: "uint256";
123
+ readonly internalType: "uint256";
124
+ }, {
125
+ readonly name: "sharesPermit";
126
+ readonly type: "tuple";
127
+ readonly internalType: "struct Permit";
128
+ readonly components: readonly [{
129
+ readonly name: "value";
130
+ readonly type: "uint256";
131
+ readonly internalType: "uint256";
132
+ }, {
133
+ readonly name: "nonce";
134
+ readonly type: "uint256";
135
+ readonly internalType: "uint256";
136
+ }, {
137
+ readonly name: "deadline";
138
+ readonly type: "uint256";
139
+ readonly internalType: "uint256";
140
+ }, {
141
+ readonly name: "v";
142
+ readonly type: "uint8";
143
+ readonly internalType: "uint8";
144
+ }, {
145
+ readonly name: "r";
146
+ readonly type: "bytes32";
147
+ readonly internalType: "bytes32";
148
+ }, {
149
+ readonly name: "s";
150
+ readonly type: "bytes32";
151
+ readonly internalType: "bytes32";
152
+ }];
153
+ }, {
154
+ readonly name: "referralFeePct";
155
+ readonly type: "uint256";
156
+ readonly internalType: "uint256";
157
+ }, {
158
+ readonly name: "referralFeeRecipient";
159
+ readonly type: "address";
160
+ readonly internalType: "address";
161
+ }, {
162
+ readonly name: "deadline";
163
+ readonly type: "uint256";
164
+ readonly internalType: "uint256";
165
+ }];
166
+ readonly outputs: readonly [];
167
+ readonly stateMutability: "nonpayable";
168
+ }, {
169
+ readonly type: "function";
170
+ readonly name: "vaultExitBundlesV1InKindRedemptionVaultV1";
171
+ readonly inputs: readonly [{
172
+ readonly name: "vault";
173
+ readonly type: "address";
174
+ readonly internalType: "address";
175
+ }, {
176
+ readonly name: "marketParamsList";
177
+ readonly type: "tuple[]";
178
+ readonly internalType: "struct MarketParams[]";
179
+ readonly components: readonly [{
180
+ readonly name: "loanToken";
181
+ readonly type: "address";
182
+ readonly internalType: "address";
183
+ }, {
184
+ readonly name: "collateralToken";
185
+ readonly type: "address";
186
+ readonly internalType: "address";
187
+ }, {
188
+ readonly name: "oracle";
189
+ readonly type: "address";
190
+ readonly internalType: "address";
191
+ }, {
192
+ readonly name: "irm";
193
+ readonly type: "address";
194
+ readonly internalType: "address";
195
+ }, {
196
+ readonly name: "lltv";
197
+ readonly type: "uint256";
198
+ readonly internalType: "uint256";
199
+ }];
200
+ }, {
201
+ readonly name: "exitAssets";
202
+ readonly type: "uint256";
203
+ readonly internalType: "uint256";
204
+ }, {
205
+ readonly name: "sharesPermit";
206
+ readonly type: "tuple";
207
+ readonly internalType: "struct Permit";
208
+ readonly components: readonly [{
209
+ readonly name: "value";
210
+ readonly type: "uint256";
211
+ readonly internalType: "uint256";
212
+ }, {
213
+ readonly name: "nonce";
214
+ readonly type: "uint256";
215
+ readonly internalType: "uint256";
216
+ }, {
217
+ readonly name: "deadline";
218
+ readonly type: "uint256";
219
+ readonly internalType: "uint256";
220
+ }, {
221
+ readonly name: "v";
222
+ readonly type: "uint8";
223
+ readonly internalType: "uint8";
224
+ }, {
225
+ readonly name: "r";
226
+ readonly type: "bytes32";
227
+ readonly internalType: "bytes32";
228
+ }, {
229
+ readonly name: "s";
230
+ readonly type: "bytes32";
231
+ readonly internalType: "bytes32";
232
+ }];
233
+ }, {
234
+ readonly name: "deadline";
235
+ readonly type: "uint256";
236
+ readonly internalType: "uint256";
237
+ }];
238
+ readonly outputs: readonly [];
239
+ readonly stateMutability: "nonpayable";
240
+ }, {
241
+ readonly type: "function";
242
+ readonly name: "vaultExitBundlesV1InKindRedemptionVaultV2";
243
+ readonly inputs: readonly [{
244
+ readonly name: "vault";
245
+ readonly type: "address";
246
+ readonly internalType: "address";
247
+ }, {
248
+ readonly name: "adapter";
249
+ readonly type: "address";
250
+ readonly internalType: "address";
251
+ }, {
252
+ readonly name: "marketParamsList";
253
+ readonly type: "tuple[]";
254
+ readonly internalType: "struct MarketParams[]";
255
+ readonly components: readonly [{
256
+ readonly name: "loanToken";
257
+ readonly type: "address";
258
+ readonly internalType: "address";
259
+ }, {
260
+ readonly name: "collateralToken";
261
+ readonly type: "address";
262
+ readonly internalType: "address";
263
+ }, {
264
+ readonly name: "oracle";
265
+ readonly type: "address";
266
+ readonly internalType: "address";
267
+ }, {
268
+ readonly name: "irm";
269
+ readonly type: "address";
270
+ readonly internalType: "address";
271
+ }, {
272
+ readonly name: "lltv";
273
+ readonly type: "uint256";
274
+ readonly internalType: "uint256";
275
+ }];
276
+ }, {
277
+ readonly name: "exitAssets";
278
+ readonly type: "uint256";
279
+ readonly internalType: "uint256";
280
+ }, {
281
+ readonly name: "sharesPermit";
282
+ readonly type: "tuple";
283
+ readonly internalType: "struct Permit";
284
+ readonly components: readonly [{
285
+ readonly name: "value";
286
+ readonly type: "uint256";
287
+ readonly internalType: "uint256";
288
+ }, {
289
+ readonly name: "nonce";
290
+ readonly type: "uint256";
291
+ readonly internalType: "uint256";
292
+ }, {
293
+ readonly name: "deadline";
294
+ readonly type: "uint256";
295
+ readonly internalType: "uint256";
296
+ }, {
297
+ readonly name: "v";
298
+ readonly type: "uint8";
299
+ readonly internalType: "uint8";
300
+ }, {
301
+ readonly name: "r";
302
+ readonly type: "bytes32";
303
+ readonly internalType: "bytes32";
304
+ }, {
305
+ readonly name: "s";
306
+ readonly type: "bytes32";
307
+ readonly internalType: "bytes32";
308
+ }];
309
+ }, {
310
+ readonly name: "deadline";
311
+ readonly type: "uint256";
312
+ readonly internalType: "uint256";
313
+ }];
314
+ readonly outputs: readonly [];
315
+ readonly stateMutability: "nonpayable";
316
+ }];
4
317
  /** ABI for the Bundler3 multicall contract. */
5
318
  export declare const bundler3Abi: readonly [{
6
319
  readonly type: "function";
package/lib/cjs/abis.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compoundV3MigrationAdapterAbi = exports.compoundV2MigrationAdapterAbi = exports.aaveV3OptimizerMigrationAdapterAbi = exports.aaveV3MigrationAdapterAbi = exports.aaveV2MigrationAdapterAbi = exports.erc20WrapperAdapterAbi = exports.paraswapAdapterAbi = exports.ethereumGeneralAdapter1Abi = exports.generalAdapter1Abi = exports.coreAdapterAbi = exports.bundler3Abi = exports.setterRatifierAbi = exports.midnightBundlesAbi = exports.midnightAbi = exports.ecrecoverRatifierAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2Abi = exports.vaultV1AdapterFactoryAbi = exports.vaultV1AdapterAbi = exports.publicAllocatorAbi = exports.preLiquidationFactoryAbi = exports.preLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.adaptiveCurveIrmAbi = exports.marketParamsAbi = void 0;
3
+ exports.compoundV3MigrationAdapterAbi = exports.compoundV2MigrationAdapterAbi = exports.aaveV3OptimizerMigrationAdapterAbi = exports.aaveV3MigrationAdapterAbi = exports.aaveV2MigrationAdapterAbi = exports.erc20WrapperAdapterAbi = exports.paraswapAdapterAbi = exports.ethereumGeneralAdapter1Abi = exports.generalAdapter1Abi = exports.coreAdapterAbi = exports.bundler3Abi = exports.vaultExitBundlesV1Abi = exports.setterRatifierAbi = exports.midnightBundlesAbi = exports.midnightAbi = exports.ecrecoverRatifierAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2Abi = exports.vaultV1AdapterFactoryAbi = exports.vaultV1AdapterAbi = exports.publicAllocatorAbi = exports.preLiquidationFactoryAbi = exports.preLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.adaptiveCurveIrmAbi = exports.marketParamsAbi = void 0;
4
4
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  Object.defineProperty(exports, "marketParamsAbi", { enumerable: true, get: function () { return blue_sdk_1.marketParamsAbi; } });
6
6
  var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
@@ -34,6 +34,172 @@ Object.defineProperty(exports, "ecrecoverRatifierAbi", { enumerable: true, get:
34
34
  Object.defineProperty(exports, "midnightAbi", { enumerable: true, get: function () { return midnight_sdk_1.midnightAbi; } });
35
35
  Object.defineProperty(exports, "midnightBundlesAbi", { enumerable: true, get: function () { return midnight_sdk_1.midnightBundlesAbi; } });
36
36
  Object.defineProperty(exports, "setterRatifierAbi", { enumerable: true, get: function () { return midnight_sdk_1.setterRatifierAbi; } });
37
+ /** ABI for the VaultExitBundlesV1 periphery contract. */
38
+ exports.vaultExitBundlesV1Abi = [
39
+ {
40
+ type: "constructor",
41
+ inputs: [{ name: "_blue", type: "address", internalType: "address" }],
42
+ stateMutability: "nonpayable",
43
+ },
44
+ { type: "error", name: "AdapterNotPartOfVault", inputs: [] },
45
+ { type: "error", name: "AlreadyInitiated", inputs: [] },
46
+ { type: "error", name: "ApproveReturnedFalse", inputs: [] },
47
+ { type: "error", name: "DeadlinePassed", inputs: [] },
48
+ { type: "error", name: "InvalidAdaptersLength", inputs: [] },
49
+ { type: "error", name: "MorphoMismatch", inputs: [] },
50
+ { type: "error", name: "NoCode", inputs: [] },
51
+ { type: "error", name: "PctExceeded", inputs: [] },
52
+ { type: "error", name: "SlippageExceeded", inputs: [] },
53
+ { type: "error", name: "TransferReturnedFalse", inputs: [] },
54
+ { type: "error", name: "UnauthorizedCallback", inputs: [] },
55
+ {
56
+ type: "function",
57
+ name: "BLUE",
58
+ inputs: [],
59
+ outputs: [{ name: "", type: "address", internalType: "address" }],
60
+ stateMutability: "view",
61
+ },
62
+ {
63
+ type: "function",
64
+ name: "initiator",
65
+ inputs: [],
66
+ outputs: [{ name: "", type: "address", internalType: "address" }],
67
+ stateMutability: "view",
68
+ },
69
+ {
70
+ type: "function",
71
+ name: "onMorphoFlashLoan",
72
+ inputs: [
73
+ { name: "exitAssets", type: "uint256", internalType: "uint256" },
74
+ { name: "data", type: "bytes", internalType: "bytes" },
75
+ ],
76
+ outputs: [],
77
+ stateMutability: "nonpayable",
78
+ },
79
+ {
80
+ type: "function",
81
+ name: "onMorphoSupply",
82
+ inputs: [
83
+ { name: "assets", type: "uint256", internalType: "uint256" },
84
+ { name: "data", type: "bytes", internalType: "bytes" },
85
+ ],
86
+ outputs: [],
87
+ stateMutability: "nonpayable",
88
+ },
89
+ {
90
+ type: "function",
91
+ name: "vaultExitBundlesV1ForceWithdrawVaultV2",
92
+ inputs: [
93
+ { name: "vault", type: "address", internalType: "address" },
94
+ { name: "adapter", type: "address", internalType: "address" },
95
+ { name: "exitAssets", type: "uint256", internalType: "uint256" },
96
+ { name: "minSharePriceE27", type: "uint256", internalType: "uint256" },
97
+ {
98
+ name: "sharesPermit",
99
+ type: "tuple",
100
+ internalType: "struct Permit",
101
+ components: [
102
+ { name: "value", type: "uint256", internalType: "uint256" },
103
+ { name: "nonce", type: "uint256", internalType: "uint256" },
104
+ { name: "deadline", type: "uint256", internalType: "uint256" },
105
+ { name: "v", type: "uint8", internalType: "uint8" },
106
+ { name: "r", type: "bytes32", internalType: "bytes32" },
107
+ { name: "s", type: "bytes32", internalType: "bytes32" },
108
+ ],
109
+ },
110
+ { name: "referralFeePct", type: "uint256", internalType: "uint256" },
111
+ {
112
+ name: "referralFeeRecipient",
113
+ type: "address",
114
+ internalType: "address",
115
+ },
116
+ { name: "deadline", type: "uint256", internalType: "uint256" },
117
+ ],
118
+ outputs: [],
119
+ stateMutability: "nonpayable",
120
+ },
121
+ {
122
+ type: "function",
123
+ name: "vaultExitBundlesV1InKindRedemptionVaultV1",
124
+ inputs: [
125
+ { name: "vault", type: "address", internalType: "address" },
126
+ {
127
+ name: "marketParamsList",
128
+ type: "tuple[]",
129
+ internalType: "struct MarketParams[]",
130
+ components: [
131
+ { name: "loanToken", type: "address", internalType: "address" },
132
+ {
133
+ name: "collateralToken",
134
+ type: "address",
135
+ internalType: "address",
136
+ },
137
+ { name: "oracle", type: "address", internalType: "address" },
138
+ { name: "irm", type: "address", internalType: "address" },
139
+ { name: "lltv", type: "uint256", internalType: "uint256" },
140
+ ],
141
+ },
142
+ { name: "exitAssets", type: "uint256", internalType: "uint256" },
143
+ {
144
+ name: "sharesPermit",
145
+ type: "tuple",
146
+ internalType: "struct Permit",
147
+ components: [
148
+ { name: "value", type: "uint256", internalType: "uint256" },
149
+ { name: "nonce", type: "uint256", internalType: "uint256" },
150
+ { name: "deadline", type: "uint256", internalType: "uint256" },
151
+ { name: "v", type: "uint8", internalType: "uint8" },
152
+ { name: "r", type: "bytes32", internalType: "bytes32" },
153
+ { name: "s", type: "bytes32", internalType: "bytes32" },
154
+ ],
155
+ },
156
+ { name: "deadline", type: "uint256", internalType: "uint256" },
157
+ ],
158
+ outputs: [],
159
+ stateMutability: "nonpayable",
160
+ },
161
+ {
162
+ type: "function",
163
+ name: "vaultExitBundlesV1InKindRedemptionVaultV2",
164
+ inputs: [
165
+ { name: "vault", type: "address", internalType: "address" },
166
+ { name: "adapter", type: "address", internalType: "address" },
167
+ {
168
+ name: "marketParamsList",
169
+ type: "tuple[]",
170
+ internalType: "struct MarketParams[]",
171
+ components: [
172
+ { name: "loanToken", type: "address", internalType: "address" },
173
+ {
174
+ name: "collateralToken",
175
+ type: "address",
176
+ internalType: "address",
177
+ },
178
+ { name: "oracle", type: "address", internalType: "address" },
179
+ { name: "irm", type: "address", internalType: "address" },
180
+ { name: "lltv", type: "uint256", internalType: "uint256" },
181
+ ],
182
+ },
183
+ { name: "exitAssets", type: "uint256", internalType: "uint256" },
184
+ {
185
+ name: "sharesPermit",
186
+ type: "tuple",
187
+ internalType: "struct Permit",
188
+ components: [
189
+ { name: "value", type: "uint256", internalType: "uint256" },
190
+ { name: "nonce", type: "uint256", internalType: "uint256" },
191
+ { name: "deadline", type: "uint256", internalType: "uint256" },
192
+ { name: "v", type: "uint8", internalType: "uint8" },
193
+ { name: "r", type: "bytes32", internalType: "bytes32" },
194
+ { name: "s", type: "bytes32", internalType: "bytes32" },
195
+ ],
196
+ },
197
+ { name: "deadline", type: "uint256", internalType: "uint256" },
198
+ ],
199
+ outputs: [],
200
+ stateMutability: "nonpayable",
201
+ },
202
+ ];
37
203
  /** ABI for the Bundler3 multicall contract. */
38
204
  exports.bundler3Abi = [
39
205
  {
@@ -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.
@@ -15,7 +15,7 @@ const validateRequirementSpender_js_1 = require("../../../helpers/validateRequir
15
15
  * @param params - Encoding parameters.
16
16
  * @param params.token - ERC-20 token address to approve.
17
17
  * @param params.spender - Address granted the allowance. Must be GeneralAdapter1, Permit2,
18
- * Midnight, or MidnightBundles for the chain.
18
+ * Midnight, MidnightBundles, or VaultExitBundlesV1 for the chain.
19
19
  * @param params.amount - Allowance amount before per-token cap.
20
20
  * @param params.chainId - The chain the transaction targets (used to resolve supported spenders and the per-token cap).
21
21
  * @returns A deep-frozen `Transaction<ERC20ApprovalAction>` with the capped approval amount.
@@ -35,10 +35,17 @@ const validateRequirementSpender_js_1 = require("../../../helpers/validateRequir
35
35
  */
36
36
  const encodeErc20Approval = (params) => {
37
37
  const { token, spender, amount, chainId } = params;
38
+ // Reject approval targets outside the SDK's registered protocol spenders.
38
39
  (0, validateRequirementSpender_js_1.validateRequirementSpender)({
39
40
  chainId,
40
41
  spender,
41
- allowed: ["generalAdapter1", "permit2", "midnight", "midnightBundles"],
42
+ allowed: [
43
+ "generalAdapter1",
44
+ "permit2",
45
+ "midnight",
46
+ "midnightBundles",
47
+ "vaultExitBundlesV1",
48
+ ],
42
49
  });
43
50
  const amountValue = blue_sdk_1.MathLib.min(amount, constant_js_1.MAX_TOKEN_APPROVALS[chainId]?.[token] ?? viem_1.maxUint256);
44
51
  return (0, morpho_ts_1.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>;