@morpho-org/morpho-sdk 7.0.0 → 8.1.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 (192) hide show
  1. package/MIGRATION-v6-to-v7.md +6 -0
  2. package/MIGRATION-v7-to-v8.md +290 -0
  3. package/README.md +11 -6
  4. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +2 -0
  5. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +2 -0
  6. package/lib/cjs/actions/midnight/cancelAndMake.d.ts +17 -71
  7. package/lib/cjs/actions/midnight/cancelAndMake.js +41 -29
  8. package/lib/cjs/actions/midnight/redeem.d.ts +8 -1
  9. package/lib/cjs/actions/midnight/redeem.js +18 -1
  10. package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +19 -3
  11. package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +24 -2
  12. package/lib/cjs/actions/midnight/supplyCollateral.d.ts +1 -0
  13. package/lib/cjs/actions/midnight/supplyCollateral.js +3 -0
  14. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +21 -6
  15. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +49 -14
  16. package/lib/cjs/actions/midnight/takeBorrow.d.ts +18 -5
  17. package/lib/cjs/actions/midnight/takeBorrow.js +44 -12
  18. package/lib/cjs/actions/midnight/takeLend.d.ts +10 -5
  19. package/lib/cjs/actions/midnight/takeLend.js +27 -9
  20. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -7
  21. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +51 -27
  22. package/lib/cjs/actions/midnight/takeWithdraw.d.ts +14 -5
  23. package/lib/cjs/actions/midnight/takeWithdraw.js +40 -9
  24. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -2
  25. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +11 -6
  26. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +3 -0
  27. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +2 -1
  28. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +13 -2
  29. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +17 -6
  30. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +3 -0
  31. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +2 -1
  32. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +5 -0
  33. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +4 -1
  34. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +3 -1
  35. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +5 -1
  36. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +3 -1
  37. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -1
  38. package/lib/cjs/actions/requirements/validateClientChainId.d.ts +26 -0
  39. package/lib/cjs/actions/requirements/validateClientChainId.js +34 -0
  40. package/lib/cjs/blue/errors.d.ts +1 -1
  41. package/lib/cjs/blue/errors.js +3 -1
  42. package/lib/cjs/blue/types.d.ts +1 -1
  43. package/lib/cjs/blue/utils.d.ts +1 -1
  44. package/lib/cjs/blue/utils.js +5 -1
  45. package/lib/cjs/entities/blue/blue.d.ts +109 -27
  46. package/lib/cjs/entities/blue/blue.js +103 -28
  47. package/lib/cjs/entities/index.d.ts +1 -1
  48. package/lib/cjs/entities/midnight/deadline.d.ts +15 -0
  49. package/lib/cjs/entities/midnight/deadline.js +24 -0
  50. package/lib/cjs/entities/midnight/midnight.d.ts +432 -74
  51. package/lib/cjs/entities/midnight/midnight.js +869 -188
  52. package/lib/cjs/entities/midnight/publication.d.ts +134 -0
  53. package/lib/cjs/entities/midnight/publication.js +404 -0
  54. package/lib/cjs/entities/midnight/types.d.ts +26 -5
  55. package/lib/cjs/entities/requirements/assertContractCode.d.ts +49 -0
  56. package/lib/cjs/entities/requirements/assertContractCode.js +79 -0
  57. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +19 -4
  58. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +45 -18
  59. package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +3 -2
  60. package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +5 -2
  61. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -1
  62. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
  63. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +63 -11
  64. package/lib/cjs/entities/vaultV1/vaultV1.js +83 -49
  65. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +54 -12
  66. package/lib/cjs/entities/vaultV2/vaultV2.js +86 -55
  67. package/lib/cjs/errors.d.ts +1 -1
  68. package/lib/cjs/errors.js +4 -2
  69. package/lib/cjs/helpers/constant.d.ts +5 -0
  70. package/lib/cjs/helpers/constant.js +6 -1
  71. package/lib/cjs/helpers/index.d.ts +1 -1
  72. package/lib/cjs/helpers/index.js +2 -1
  73. package/lib/cjs/helpers/validate.d.ts +163 -8
  74. package/lib/cjs/helpers/validate.js +179 -8
  75. package/lib/cjs/helpers/validateMidnightBounds.d.ts +47 -0
  76. package/lib/cjs/helpers/validateMidnightBounds.js +79 -0
  77. package/lib/cjs/helpers/validateMidnightPublication.d.ts +12 -0
  78. package/lib/cjs/helpers/validateMidnightPublication.js +144 -0
  79. package/lib/cjs/helpers/validateMidnightReceiver.d.ts +29 -0
  80. package/lib/cjs/helpers/validateMidnightReceiver.js +84 -0
  81. package/lib/cjs/helpers/validateMidnightTakeFeasibility.d.ts +102 -0
  82. package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +231 -0
  83. package/lib/cjs/index.d.ts +1 -0
  84. package/lib/cjs/index.js +3 -0
  85. package/lib/cjs/types/action.d.ts +102 -1
  86. package/lib/cjs/types/action.js +102 -1
  87. package/lib/cjs/types/error.d.ts +197 -4
  88. package/lib/cjs/types/error.js +265 -5
  89. package/lib/cjs/types/index.d.ts +1 -0
  90. package/lib/cjs/types/index.js +1 -0
  91. package/lib/cjs/types/midnightCancelAndMake.d.ts +70 -0
  92. package/lib/cjs/types/midnightCancelAndMake.js +2 -0
  93. package/lib/cjs/types/midnightPublicationError.d.ts +332 -0
  94. package/lib/cjs/types/midnightPublicationError.js +376 -0
  95. package/lib/cjs/types.d.ts +1 -1
  96. package/lib/cjs/utils.d.ts +2 -1
  97. package/lib/cjs/utils.js +8 -2
  98. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +2 -0
  99. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +2 -0
  100. package/lib/esm/actions/midnight/cancelAndMake.d.ts +17 -71
  101. package/lib/esm/actions/midnight/cancelAndMake.js +42 -30
  102. package/lib/esm/actions/midnight/redeem.d.ts +8 -1
  103. package/lib/esm/actions/midnight/redeem.js +18 -1
  104. package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +19 -3
  105. package/lib/esm/actions/midnight/repayWithdrawCollateral.js +24 -2
  106. package/lib/esm/actions/midnight/supplyCollateral.d.ts +1 -0
  107. package/lib/esm/actions/midnight/supplyCollateral.js +3 -0
  108. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +21 -6
  109. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +52 -17
  110. package/lib/esm/actions/midnight/takeBorrow.d.ts +18 -5
  111. package/lib/esm/actions/midnight/takeBorrow.js +47 -15
  112. package/lib/esm/actions/midnight/takeLend.d.ts +10 -5
  113. package/lib/esm/actions/midnight/takeLend.js +27 -9
  114. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -7
  115. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +52 -28
  116. package/lib/esm/actions/midnight/takeWithdraw.d.ts +14 -5
  117. package/lib/esm/actions/midnight/takeWithdraw.js +41 -10
  118. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -2
  119. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +13 -8
  120. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +3 -0
  121. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +2 -1
  122. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +13 -2
  123. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +17 -6
  124. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +3 -0
  125. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +2 -1
  126. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +5 -0
  127. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +4 -1
  128. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +3 -1
  129. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +5 -1
  130. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +3 -1
  131. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -1
  132. package/lib/esm/actions/requirements/validateClientChainId.d.ts +26 -0
  133. package/lib/esm/actions/requirements/validateClientChainId.js +30 -0
  134. package/lib/esm/blue/errors.d.ts +1 -1
  135. package/lib/esm/blue/errors.js +1 -1
  136. package/lib/esm/blue/types.d.ts +1 -1
  137. package/lib/esm/blue/utils.d.ts +1 -1
  138. package/lib/esm/blue/utils.js +1 -1
  139. package/lib/esm/entities/blue/blue.d.ts +109 -27
  140. package/lib/esm/entities/blue/blue.js +104 -29
  141. package/lib/esm/entities/index.d.ts +1 -1
  142. package/lib/esm/entities/midnight/deadline.d.ts +15 -0
  143. package/lib/esm/entities/midnight/deadline.js +20 -0
  144. package/lib/esm/entities/midnight/midnight.d.ts +432 -74
  145. package/lib/esm/entities/midnight/midnight.js +870 -189
  146. package/lib/esm/entities/midnight/publication.d.ts +134 -0
  147. package/lib/esm/entities/midnight/publication.js +397 -0
  148. package/lib/esm/entities/midnight/types.d.ts +26 -5
  149. package/lib/esm/entities/requirements/assertContractCode.d.ts +49 -0
  150. package/lib/esm/entities/requirements/assertContractCode.js +74 -0
  151. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +19 -4
  152. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +47 -20
  153. package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +3 -2
  154. package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +5 -2
  155. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -1
  156. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
  157. package/lib/esm/entities/vaultV1/vaultV1.d.ts +63 -11
  158. package/lib/esm/entities/vaultV1/vaultV1.js +85 -51
  159. package/lib/esm/entities/vaultV2/vaultV2.d.ts +54 -12
  160. package/lib/esm/entities/vaultV2/vaultV2.js +88 -57
  161. package/lib/esm/errors.d.ts +1 -1
  162. package/lib/esm/errors.js +1 -1
  163. package/lib/esm/helpers/constant.d.ts +5 -0
  164. package/lib/esm/helpers/constant.js +5 -0
  165. package/lib/esm/helpers/index.d.ts +1 -1
  166. package/lib/esm/helpers/index.js +1 -1
  167. package/lib/esm/helpers/validate.d.ts +163 -8
  168. package/lib/esm/helpers/validate.js +177 -7
  169. package/lib/esm/helpers/validateMidnightBounds.d.ts +47 -0
  170. package/lib/esm/helpers/validateMidnightBounds.js +72 -0
  171. package/lib/esm/helpers/validateMidnightPublication.d.ts +12 -0
  172. package/lib/esm/helpers/validateMidnightPublication.js +139 -0
  173. package/lib/esm/helpers/validateMidnightReceiver.d.ts +29 -0
  174. package/lib/esm/helpers/validateMidnightReceiver.js +80 -0
  175. package/lib/esm/helpers/validateMidnightTakeFeasibility.d.ts +102 -0
  176. package/lib/esm/helpers/validateMidnightTakeFeasibility.js +226 -0
  177. package/lib/esm/index.d.ts +1 -0
  178. package/lib/esm/index.js +1 -0
  179. package/lib/esm/types/action.d.ts +102 -1
  180. package/lib/esm/types/action.js +102 -1
  181. package/lib/esm/types/error.d.ts +197 -4
  182. package/lib/esm/types/error.js +253 -2
  183. package/lib/esm/types/index.d.ts +1 -0
  184. package/lib/esm/types/index.js +1 -0
  185. package/lib/esm/types/midnightCancelAndMake.d.ts +70 -0
  186. package/lib/esm/types/midnightCancelAndMake.js +1 -0
  187. package/lib/esm/types/midnightPublicationError.d.ts +332 -0
  188. package/lib/esm/types/midnightPublicationError.js +359 -0
  189. package/lib/esm/types.d.ts +1 -1
  190. package/lib/esm/utils.d.ts +2 -1
  191. package/lib/esm/utils.js +2 -1
  192. package/package.json +10 -10
@@ -8,10 +8,12 @@ const viem_1 = require("viem");
8
8
  const actions_1 = require("viem/actions");
9
9
  const common_js_1 = require("../../actions/bundles/common.js");
10
10
  const index_js_1 = require("../../actions/index.js");
11
+ const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
11
12
  const index_js_2 = require("../../helpers/index.js");
12
13
  const slippage_js_1 = require("../../helpers/slippage.js");
13
14
  const validate_js_1 = require("../../helpers/validate.js");
14
15
  const index_js_3 = require("../../types/index.js");
16
+ const assertContractCode_js_1 = require("../requirements/assertContractCode.js");
15
17
  const getVaultBundlesSharesRequirements_js_1 = require("../requirements/getVaultBundlesSharesRequirements.js");
16
18
  const index_js_4 = require("../requirements/index.js");
17
19
  /** Binds a viem client to a Vault V1 (MetaMorpho) vault's action builders. */
@@ -26,12 +28,33 @@ class MorphoVaultV1 {
26
28
  this.chainId = chainId;
27
29
  }
28
30
  async getData(parameters) {
29
- (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
31
+ await (0, validateClientChainId_js_1.validateClientChainId)(this.client.viemClient, this.chainId);
30
32
  return (0, blue_sdk_viem_1.fetchAccrualVault)(this.vault, this.client.viemClient, {
31
33
  ...parameters,
32
34
  deployless: this.client.options.supportDeployless,
33
35
  });
34
36
  }
37
+ /**
38
+ * Asserts that every registry contract this flow's transaction targets or names as
39
+ * spender/authorized operator holds code, with one `eth_getCode` per distinct address
40
+ * before any other requirement read. This VaultV1 `inKindRedeem` path validates the client chain
41
+ * before this code check.
42
+ *
43
+ * @param roles - Registry labels to resolve and check; `permit2` is skipped when the
44
+ * chain registers none.
45
+ */
46
+ async assertWriteTargets(roles) {
47
+ const targets = [];
48
+ for (const role of roles) {
49
+ const address = role === "permit2"
50
+ ? (0, morpho_ts_1.getChainAddresses)(this.chainId).permit2
51
+ : (0, morpho_ts_1.getChainAddress)(this.chainId, role);
52
+ if (address == null)
53
+ continue;
54
+ targets.push({ role, address });
55
+ }
56
+ await (0, assertContractCode_js_1.assertRegistryTargetsHaveCode)(this.client.viemClient, this.chainId, targets);
57
+ }
35
58
  /** {@inheritDoc VaultV1Actions.deposit} */
36
59
  deposit(params) {
37
60
  const { userAddress, vaultData } = params;
@@ -74,20 +97,26 @@ class MorphoVaultV1 {
74
97
  return await pendingRequirements;
75
98
  // Memoize the in-flight promise so concurrent callers share one round of
76
99
  // allowance/nonce reads.
77
- const pending = funding.value > 0n
78
- ? Promise.resolve([])
79
- : (0, index_js_4.getBundlesTokenRequirements)(this.client.viemClient, {
80
- token: vaultAsset,
81
- spender,
82
- amount: funding.assets,
83
- owner: userAddress,
84
- chainId: this.chainId,
85
- deadline,
86
- supportSignature: this.client.options.supportSignature,
87
- supportDeployless: this.client.options.supportDeployless,
88
- useSimplePermit: requirementOptions?.useSimplePermit,
89
- permit2Nonce: requirementOptions?.permit2Nonce,
90
- });
100
+ const pending = (async () => {
101
+ await this.assertWriteTargets(funding.value === 0n && this.client.options.supportSignature
102
+ ? ["bundles.vaultBundlesV1", "permit2"]
103
+ : ["bundles.vaultBundlesV1"]);
104
+ return funding.value > 0n
105
+ ? []
106
+ : (0, index_js_4.getBundlesTokenRequirements)(this.client.viemClient, {
107
+ token: vaultAsset,
108
+ spender,
109
+ amount: funding.assets,
110
+ owner: userAddress,
111
+ chainId: this.chainId,
112
+ deadline,
113
+ supportSignature: this.client.options.supportSignature,
114
+ supportDeployless: this.client.options.supportDeployless,
115
+ useSimplePermit: requirementOptions?.useSimplePermit,
116
+ permit2Nonce: requirementOptions?.permit2Nonce,
117
+ now,
118
+ });
119
+ })();
91
120
  pendingRequirements = pending;
92
121
  try {
93
122
  return await pending;
@@ -161,6 +190,7 @@ class MorphoVaultV1 {
161
190
  const now = morpho_ts_1.Time.timestamp();
162
191
  if (deadline <= now)
163
192
  throw new index_js_3.ExpiredDeadlineError(deadline, now);
193
+ await this.assertWriteTargets(["bundles.vaultBundlesV1"]);
164
194
  // Re-read the live share allowance on every call instead of caching the resolved
165
195
  // requirements: the allowance is the sole cap on the burn, so a caller that executed the
166
196
  // returned approval must see it satisfied on the next call, and an allowance revoked or
@@ -175,6 +205,7 @@ class MorphoVaultV1 {
175
205
  maxShareAllowance,
176
206
  deadline,
177
207
  supportSignature: this.client.options.supportSignature,
208
+ now,
178
209
  });
179
210
  },
180
211
  buildTx: (signatures) => {
@@ -220,6 +251,7 @@ class MorphoVaultV1 {
220
251
  const now = morpho_ts_1.Time.timestamp();
221
252
  if (deadline <= now)
222
253
  throw new index_js_3.ExpiredDeadlineError(deadline, now);
254
+ await this.assertWriteTargets(["bundles.vaultBundlesV1"]);
223
255
  return (0, getVaultBundlesSharesRequirements_js_1.getVaultBundlesSharesRequirements)(this.client.viemClient, {
224
256
  vaultData: await this.getData(),
225
257
  version: "vaultV1",
@@ -228,6 +260,7 @@ class MorphoVaultV1 {
228
260
  requiredShareAllowance: shares,
229
261
  deadline,
230
262
  supportSignature: this.client.options.supportSignature,
263
+ now,
231
264
  });
232
265
  },
233
266
  buildTx: (signatures) => {
@@ -321,40 +354,39 @@ class MorphoVaultV1 {
321
354
  if (deadline <= requirementsTimestamp) {
322
355
  throw new index_js_3.ExpiredDeadlineError(deadline, requirementsTimestamp);
323
356
  }
324
- const [allowance, nonce, blueBalance, morpho, blueFeeRecipient] = await (0, actions_1.multicall)(this.client.viemClient, {
325
- allowFailure: false,
326
- contracts: [
327
- {
328
- address: this.vault,
329
- abi: viem_1.erc20Abi,
330
- functionName: "allowance",
331
- args: [userAddress, vaultExitBundlesV1],
332
- },
333
- {
334
- address: this.vault,
335
- abi: blue_sdk_viem_1.erc2612Abi,
336
- functionName: "nonces",
337
- args: [userAddress],
338
- },
339
- {
340
- address: vaultData.asset,
341
- abi: viem_1.erc20Abi,
342
- functionName: "balanceOf",
343
- args: [blue],
344
- },
345
- {
346
- address: this.vault,
347
- abi: blue_sdk_viem_1.metaMorphoAbi,
348
- functionName: "MORPHO",
349
- },
350
- // feeRecipient() is trusted as returned by the RPC. See THREAT_MODEL.md, RPC.
351
- {
352
- address: blue,
353
- abi: blue_sdk_viem_1.blueAbi,
354
- functionName: "feeRecipient",
355
- },
356
- ],
357
- });
357
+ await (0, validateClientChainId_js_1.validateClientChainId)(this.client.viemClient, this.chainId);
358
+ await this.assertWriteTargets(["bundles.vaultExitBundlesV1", "blue"]);
359
+ const [allowance, nonce, blueBalance, morpho, blueFeeRecipient] = await Promise.all([
360
+ (0, actions_1.readContract)(this.client.viemClient, {
361
+ address: this.vault,
362
+ abi: viem_1.erc20Abi,
363
+ functionName: "allowance",
364
+ args: [userAddress, vaultExitBundlesV1],
365
+ }),
366
+ (0, actions_1.readContract)(this.client.viemClient, {
367
+ address: this.vault,
368
+ abi: blue_sdk_viem_1.erc2612Abi,
369
+ functionName: "nonces",
370
+ args: [userAddress],
371
+ }),
372
+ (0, actions_1.readContract)(this.client.viemClient, {
373
+ address: vaultData.asset,
374
+ abi: viem_1.erc20Abi,
375
+ functionName: "balanceOf",
376
+ args: [blue],
377
+ }),
378
+ (0, actions_1.readContract)(this.client.viemClient, {
379
+ address: this.vault,
380
+ abi: blue_sdk_viem_1.metaMorphoAbi,
381
+ functionName: "MORPHO",
382
+ }),
383
+ // feeRecipient() is trusted as returned by the RPC. See THREAT_MODEL.md, RPC.
384
+ (0, actions_1.readContract)(this.client.viemClient, {
385
+ address: blue,
386
+ abi: blue_sdk_viem_1.blueAbi,
387
+ functionName: "feeRecipient",
388
+ }),
389
+ ]);
358
390
  if (!(0, viem_1.isAddressEqual)(morpho, blue)) {
359
391
  throw new index_js_3.VaultMorphoMismatchError({
360
392
  vault: this.vault,
@@ -505,6 +537,7 @@ class MorphoVaultV1 {
505
537
  const now = morpho_ts_1.Time.timestamp();
506
538
  if (deadline <= now)
507
539
  throw new index_js_3.ExpiredDeadlineError(deadline, now);
540
+ await this.assertWriteTargets(["bundles.vaultBundlesV1"]);
508
541
  // Re-read the live share allowance on every call instead of caching the resolved
509
542
  // requirements: in assets mode the calldata carries no share limit, so the allowance is
510
543
  // the sole cap on the burn. A caller that executed the returned approval must see it
@@ -520,6 +553,7 @@ class MorphoVaultV1 {
520
553
  maxShareAllowance,
521
554
  deadline,
522
555
  supportSignature: this.client.options.supportSignature,
556
+ now,
523
557
  });
524
558
  },
525
559
  buildTx: (signatures) => {
@@ -15,12 +15,17 @@ export interface VaultV2Actions {
15
15
  *
16
16
  * @param parameters - Optional viem fetch parameters (block number, block tag, state override).
17
17
  * @returns The hydrated `AccrualVaultV2` snapshot.
18
- * @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
18
+ * @throws {ChainIdMismatchError} when the connected client declares another chain or none, or its RPC reports another chain via `eth_chainId`.
19
+ * @throws {viem.BaseError} when the `eth_chainId` request or a state read fails.
19
20
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
20
21
  * @throws {UnknownBlueFactory} when the configured chain has no VaultV2 factory.
21
22
  * @throws {UnknownBlueOfFactory} when the vault is not a VaultV2 from the configured factory.
22
23
  * @throws {UnsupportedBlueVaultV2AdapterError} when the vault or one of its adapters uses an
23
24
  * unsupported adapter class.
25
+ * @throws {UnknownTokenError} when the vault's share token has unusable decimals.
26
+ * @throws {MalformedTokenMetadataError} when the share token's `eip712Domain()` or
27
+ * `bytes32` `name`/`symbol` retry returns non-empty data that does not decode, or when the
28
+ * deployless query reports malformed `name()`/`symbol()`/`eip712Domain()` returndata (no fallback).
24
29
  */
25
30
  getData: (parameters?: FetchParameters) => Promise<Awaited<ReturnType<typeof fetchAccrualVaultV2>>>;
26
31
  /**
@@ -47,7 +52,8 @@ export interface VaultV2Actions {
47
52
  * two hours from handle creation.
48
53
  * @returns Lazy token prerequisite resolution and a synchronous deep-frozen VaultBundlesV1
49
54
  * transaction builder.
50
- * @throws {ChainIdMismatchError} when the connected client targets another chain.
55
+ * @throws {ChainIdMismatchError} when the connected client targets another chain, or from
56
+ * `getRequirements()` when the RPC reports another chain via `eth_chainId`.
51
57
  * @throws {UnsupportedBlueMarketIrmError} when an underlying market with positive debt uses an unsupported IRM.
52
58
  * @throws {VaultAddressMismatchError} when `vaultData` belongs to another vault.
53
59
  * @throws {ExpiredDeadlineError} when the deadline is stale at creation or requirement resolution.
@@ -75,7 +81,14 @@ export interface VaultV2Actions {
75
81
  * @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when signature metadata is malformed.
76
82
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
77
83
  * @throws {UnknownAddressError} when VaultBundlesV1 is not registered.
78
- * @throws {viem.BaseError} from `getRequirements()` when an allowance, nonce, or token metadata read fails.
84
+ * @throws {UnknownTokenError} from `getRequirements()` when the token's `decimals()` is unusable.
85
+ * @throws {MalformedTokenMetadataError} when the token's `eip712Domain()` or
86
+ * `bytes32` `name`/`symbol` retry returns non-empty data that does not decode, or when the
87
+ * deployless query reports malformed `name()`/`symbol()`/`eip712Domain()` returndata (no fallback).
88
+ * @throws {MissingContractCodeError} from `getRequirements()` when a fixed bundles or protocol
89
+ * contract has no code at its registered address.
90
+ * @throws {viem.BaseError} from `getRequirements()` when an allowance, nonce, token metadata
91
+ * read, or `eth_chainId` request fails.
79
92
  * @example
80
93
  * ```ts
81
94
  * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
@@ -135,7 +148,8 @@ export interface VaultV2Actions {
135
148
  * @remarks VaultBundlesV1 skips a share permit whose nonce was already consumed and proceeds
136
149
  * under the live allowance, so execute every requirement returned by the latest
137
150
  * `getRequirements()` — including the oversized-allowance reset — before submitting.
138
- * @throws {ChainIdMismatchError} when the connected client targets another chain.
151
+ * @throws {ChainIdMismatchError} when the connected client targets another chain, or from
152
+ * `getRequirements()` when the RPC reports another chain via `eth_chainId`.
139
153
  * @throws {NonPositiveInputError} when `amount` or the computed share cap is not positive.
140
154
  * @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
141
155
  * at any `getRequirements()` call.
@@ -152,7 +166,10 @@ export interface VaultV2Actions {
152
166
  * @throws {BundlesPermitMismatchError} from `buildTx()` when the share permit is malformed or
153
167
  * its spender or deadline differ from this operation's, or its amount is outside
154
168
  * `[cap, cap / (1 - slippageTolerance)]`.
155
- * @throws {viem.BaseError} when an allowance or nonce read or transaction encoding fails.
169
+ * @throws {MissingContractCodeError} from `getRequirements()` when a fixed bundles or protocol
170
+ * contract has no code at its registered address.
171
+ * @throws {viem.BaseError} from `getRequirements()` when an allowance, nonce, or `eth_chainId`
172
+ * read fails, or transaction encoding fails.
156
173
  * @example
157
174
  * ```ts
158
175
  * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
@@ -196,7 +213,8 @@ export interface VaultV2Actions {
196
213
  * @param [params.referralFeeRecipient] - Non-zero recipient required when `referralFeePct` is positive.
197
214
  * @param [params.deadline] - VaultBundlesV1 execution deadline; defaults to two hours from now.
198
215
  * @returns Lazy exact share-allowance requirements and a synchronous transaction builder.
199
- * @throws {ChainIdMismatchError} when the client and entity target different chains.
216
+ * @throws {ChainIdMismatchError} when the client and entity target different chains, or from
217
+ * `getRequirements()` when the RPC reports another chain via `eth_chainId`.
200
218
  * @throws {NonPositiveInputError} when `shares` is not positive.
201
219
  * @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
202
220
  * requirement resolution.
@@ -206,7 +224,15 @@ export interface VaultV2Actions {
206
224
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no non-zero recipient.
207
225
  * @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
208
226
  * @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
209
- * @throws {viem.BaseError} from `getRequirements()` when an allowance or nonce read fails.
227
+ * @throws {MissingContractCodeError} from `getRequirements()` when a fixed bundles or protocol
228
+ * contract has no code at its registered address.
229
+ * @throws {viem.BaseError} from `getRequirements()` when an allowance, nonce, `eth_chainId`, or
230
+ * `eth_getCode` read fails.
231
+ * @throws {UnknownTokenError} from `getRequirements()` when the share token fetched by
232
+ * `getData()` has unusable decimals.
233
+ * @throws {MalformedTokenMetadataError} when the share token's `eip712Domain()` or
234
+ * `bytes32` `name`/`symbol` retry returns non-empty data that does not decode, or when the
235
+ * deployless query reports malformed `name()`/`symbol()`/`eip712Domain()` returndata (no fallback).
210
236
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when more than one permit signature is supplied.
211
237
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-permit signature is supplied.
212
238
  * @throws {BundlesPermitMismatchError} from `buildTx()` when the signature's spender, amount or
@@ -266,7 +292,8 @@ export interface VaultV2Actions {
266
292
  * @param params.adapter - Optional adapter override; defaults to the vault's sole adapter.
267
293
  * @param params.deadline - Optional shared permit/bundle deadline; defaults to two hours from now.
268
294
  * @returns Lazy prerequisite resolution and a synchronous transaction builder.
269
- * @throws {ChainIdMismatchError} when the client and entity target different chains.
295
+ * @throws {ChainIdMismatchError} when the client and entity target different chains, or from
296
+ * `getRequirements()` when the RPC reports another chain via `eth_chainId`.
270
297
  * @throws {UnsupportedBlueMarketIrmError} when an adapter-listed market with positive debt uses an unsupported IRM.
271
298
  * @throws {VaultAddressMismatchError} when `vaultData` belongs to another vault.
272
299
  * @throws {NonPositiveInputError} when `amount` or `deadline` is not positive.
@@ -282,7 +309,9 @@ export interface VaultV2Actions {
282
309
  * @throws {InKindRedeemCoverageError} when the deduplicated list cannot cover the exit.
283
310
  * @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
284
311
  * @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
285
- * @throws {viem.BaseError} from `getRequirements()` when an RPC or multicall contract read fails.
312
+ * @throws {viem.BaseError} from `getRequirements()` when the `eth_chainId` request or an
313
+ * RPC contract read fails.
314
+ * @throws {MissingContractCodeError} from `getRequirements()` when a fixed bundles or protocol contract has no code at its registered address.
286
315
  * @throws {InsufficientBlueBalanceForInKindRedeemError} from `getRequirements()` when Blue cannot fund the largest callback.
287
316
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when more than one permit signature is supplied.
288
317
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-permit signature is supplied.
@@ -388,7 +417,8 @@ export interface VaultV2Actions {
388
417
  * @param params.referralFeeRecipient - Optional referral fee recipient, required when
389
418
  * `referralFeePct` is positive.
390
419
  * @returns Lazy prerequisite resolution and a synchronous transaction builder.
391
- * @throws {ChainIdMismatchError} when the client and entity target different chains.
420
+ * @throws {ChainIdMismatchError} when the client and entity target different chains, or from
421
+ * `getRequirements()` when the RPC reports another chain via `eth_chainId`.
392
422
  * @throws {VaultAddressMismatchError} when `vaultData` belongs to another vault.
393
423
  * @throws {NonPositiveInputError} when `exitAssets`, `deadline`, or a supplied
394
424
  * `minSharePriceE27` is not positive.
@@ -418,7 +448,9 @@ export interface VaultV2Actions {
418
448
  * @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
419
449
  * @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
420
450
  * @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
421
- * @throws {viem.BaseError} from `getRequirements()` when an RPC or multicall contract read fails.
451
+ * @throws {viem.BaseError} from `getRequirements()` when the `eth_chainId` request or an
452
+ * RPC contract read fails.
453
+ * @throws {MissingContractCodeError} from `getRequirements()` when a fixed bundles or protocol contract has no code at its registered address.
422
454
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when more than one permit signature is supplied.
423
455
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-permit signature is supplied.
424
456
  * @throws {BundlesPermitMismatchError} from `buildTx()` when the permit's spender, amount, or
@@ -479,7 +511,7 @@ export interface VaultV2Actions {
479
511
  * @param params.userAddress - Account that pays the deallocation penalties and receives the redeemed assets.
480
512
  * @returns An object whose `buildTx()` returns a deep-frozen `Transaction<VaultV2ForceRedeemAction>`
481
513
  * encoding the vault `multicall`.
482
- * @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
514
+ * @throws {ChainIdMismatchError} when the connected client declares another chain or none.
483
515
  * @throws {EmptyDeallocationsError} from `buildTx()` when `deallocations` is empty.
484
516
  * @throws {NonPositiveInputError} from `buildTx()` when `redeem.shares <= 0n` or any deallocation
485
517
  * amount is non-positive.
@@ -513,6 +545,16 @@ export declare class MorphoVaultV2 implements VaultV2Actions {
513
545
  private readonly chainId;
514
546
  constructor(client: MorphoClientType, vault: Address, chainId: number);
515
547
  getData(parameters?: FetchParameters): Promise<AccrualVaultV2>;
548
+ /**
549
+ * Asserts that every registry contract this flow's transaction targets or names as
550
+ * spender/authorized operator holds code, with one `eth_getCode` per distinct address
551
+ * before any other requirement read. The `inKindRedeem` and `forceWithdraw` paths validate the
552
+ * client chain before this code check.
553
+ *
554
+ * @param roles - Registry labels to resolve and check; `permit2` is skipped when the
555
+ * chain registers none.
556
+ */
557
+ private assertWriteTargets;
516
558
  /** {@inheritDoc VaultV2Actions.deposit} */
517
559
  deposit(params: {
518
560
  readonly userAddress: Address;
@@ -8,10 +8,12 @@ const viem_1 = require("viem");
8
8
  const actions_1 = require("viem/actions");
9
9
  const common_js_1 = require("../../actions/bundles/common.js");
10
10
  const index_js_1 = require("../../actions/index.js");
11
+ const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
11
12
  const index_js_2 = require("../../helpers/index.js");
12
13
  const slippage_js_1 = require("../../helpers/slippage.js");
13
14
  const validate_js_1 = require("../../helpers/validate.js");
14
15
  const index_js_3 = require("../../types/index.js");
16
+ const assertContractCode_js_1 = require("../requirements/assertContractCode.js");
15
17
  const getVaultBundlesSharesRequirements_js_1 = require("../requirements/getVaultBundlesSharesRequirements.js");
16
18
  const index_js_4 = require("../requirements/index.js");
17
19
  // Maximum accepted deadline horizon; the on-chain management fee is capped at 5%/yr so the
@@ -29,12 +31,33 @@ class MorphoVaultV2 {
29
31
  this.chainId = chainId;
30
32
  }
31
33
  async getData(parameters) {
32
- (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
34
+ await (0, validateClientChainId_js_1.validateClientChainId)(this.client.viemClient, this.chainId);
33
35
  return (0, blue_sdk_viem_1.fetchAccrualVaultV2)(this.vault, this.client.viemClient, {
34
36
  ...parameters,
35
37
  deployless: this.client.options.supportDeployless,
36
38
  });
37
39
  }
40
+ /**
41
+ * Asserts that every registry contract this flow's transaction targets or names as
42
+ * spender/authorized operator holds code, with one `eth_getCode` per distinct address
43
+ * before any other requirement read. The `inKindRedeem` and `forceWithdraw` paths validate the
44
+ * client chain before this code check.
45
+ *
46
+ * @param roles - Registry labels to resolve and check; `permit2` is skipped when the
47
+ * chain registers none.
48
+ */
49
+ async assertWriteTargets(roles) {
50
+ const targets = [];
51
+ for (const role of roles) {
52
+ const address = role === "permit2"
53
+ ? (0, morpho_ts_1.getChainAddresses)(this.chainId).permit2
54
+ : (0, morpho_ts_1.getChainAddress)(this.chainId, role);
55
+ if (address == null)
56
+ continue;
57
+ targets.push({ role, address });
58
+ }
59
+ await (0, assertContractCode_js_1.assertRegistryTargetsHaveCode)(this.client.viemClient, this.chainId, targets);
60
+ }
38
61
  /** {@inheritDoc VaultV2Actions.deposit} */
39
62
  deposit(params) {
40
63
  const { userAddress, vaultData } = params;
@@ -77,20 +100,26 @@ class MorphoVaultV2 {
77
100
  return await pendingRequirements;
78
101
  // Memoize the in-flight promise so concurrent callers share one round of
79
102
  // allowance/nonce reads.
80
- const pending = funding.value > 0n
81
- ? Promise.resolve([])
82
- : (0, index_js_4.getBundlesTokenRequirements)(this.client.viemClient, {
83
- token: vaultAsset,
84
- spender,
85
- amount: funding.assets,
86
- owner: userAddress,
87
- chainId: this.chainId,
88
- deadline,
89
- supportSignature: this.client.options.supportSignature,
90
- supportDeployless: this.client.options.supportDeployless,
91
- useSimplePermit: requirementOptions?.useSimplePermit,
92
- permit2Nonce: requirementOptions?.permit2Nonce,
93
- });
103
+ const pending = (async () => {
104
+ await this.assertWriteTargets(funding.value === 0n && this.client.options.supportSignature
105
+ ? ["bundles.vaultBundlesV1", "permit2"]
106
+ : ["bundles.vaultBundlesV1"]);
107
+ return funding.value > 0n
108
+ ? []
109
+ : (0, index_js_4.getBundlesTokenRequirements)(this.client.viemClient, {
110
+ token: vaultAsset,
111
+ spender,
112
+ amount: funding.assets,
113
+ owner: userAddress,
114
+ chainId: this.chainId,
115
+ deadline,
116
+ supportSignature: this.client.options.supportSignature,
117
+ supportDeployless: this.client.options.supportDeployless,
118
+ useSimplePermit: requirementOptions?.useSimplePermit,
119
+ permit2Nonce: requirementOptions?.permit2Nonce,
120
+ now,
121
+ });
122
+ })();
94
123
  pendingRequirements = pending;
95
124
  try {
96
125
  return await pending;
@@ -164,6 +193,7 @@ class MorphoVaultV2 {
164
193
  const now = morpho_ts_1.Time.timestamp();
165
194
  if (deadline <= now)
166
195
  throw new index_js_3.ExpiredDeadlineError(deadline, now);
196
+ await this.assertWriteTargets(["bundles.vaultBundlesV1"]);
167
197
  // Re-read the live share allowance on every call instead of caching the resolved
168
198
  // requirements: the allowance is the sole cap on the burn, so a caller that executed the
169
199
  // returned approval must see it satisfied on the next call, and an allowance revoked or
@@ -178,6 +208,7 @@ class MorphoVaultV2 {
178
208
  maxShareAllowance,
179
209
  deadline,
180
210
  supportSignature: this.client.options.supportSignature,
211
+ now,
181
212
  });
182
213
  },
183
214
  buildTx: (signatures) => {
@@ -223,6 +254,7 @@ class MorphoVaultV2 {
223
254
  const now = morpho_ts_1.Time.timestamp();
224
255
  if (deadline <= now)
225
256
  throw new index_js_3.ExpiredDeadlineError(deadline, now);
257
+ await this.assertWriteTargets(["bundles.vaultBundlesV1"]);
226
258
  return (0, getVaultBundlesSharesRequirements_js_1.getVaultBundlesSharesRequirements)(this.client.viemClient, {
227
259
  vaultData: await this.getData(),
228
260
  version: "vaultV2",
@@ -231,6 +263,7 @@ class MorphoVaultV2 {
231
263
  requiredShareAllowance: shares,
232
264
  deadline,
233
265
  supportSignature: this.client.options.supportSignature,
266
+ now,
234
267
  });
235
268
  },
236
269
  buildTx: (signatures) => {
@@ -356,35 +389,34 @@ class MorphoVaultV2 {
356
389
  if (deadline <= requirementsTimestamp) {
357
390
  throw new index_js_3.ExpiredDeadlineError(deadline, requirementsTimestamp);
358
391
  }
392
+ await (0, validateClientChainId_js_1.validateClientChainId)(this.client.viemClient, this.chainId);
393
+ await this.assertWriteTargets(["bundles.vaultExitBundlesV1", "blue"]);
359
394
  // Vault gates are intentionally left to the final transaction. A receive gate may inspect
360
395
  // VaultExitBundlesV1's transient `initiator`, which is populated only during the actual
361
396
  // periphery call. A send-share gate is arbitrary external code and is evaluated repeatedly
362
397
  // after intermediate penalty share burns, so one standalone read is not execution-equivalent
363
398
  // either. Simulate the finalized transaction after authorization when gate compatibility
364
399
  // must be checked before submission.
365
- const [allowance, nonce, blueBalance] = await (0, actions_1.multicall)(this.client.viemClient, {
366
- allowFailure: false,
367
- contracts: [
368
- {
369
- address: this.vault,
370
- abi: viem_1.erc20Abi,
371
- functionName: "allowance",
372
- args: [userAddress, vaultExitBundlesV1],
373
- },
374
- {
375
- address: this.vault,
376
- abi: blue_sdk_viem_1.erc2612Abi,
377
- functionName: "nonces",
378
- args: [userAddress],
379
- },
380
- {
381
- address: vaultData.asset,
382
- abi: viem_1.erc20Abi,
383
- functionName: "balanceOf",
384
- args: [blue],
385
- },
386
- ],
387
- });
400
+ const [allowance, nonce, blueBalance] = await Promise.all([
401
+ (0, actions_1.readContract)(this.client.viemClient, {
402
+ address: this.vault,
403
+ abi: viem_1.erc20Abi,
404
+ functionName: "allowance",
405
+ args: [userAddress, vaultExitBundlesV1],
406
+ }),
407
+ (0, actions_1.readContract)(this.client.viemClient, {
408
+ address: this.vault,
409
+ abi: blue_sdk_viem_1.erc2612Abi,
410
+ functionName: "nonces",
411
+ args: [userAddress],
412
+ }),
413
+ (0, actions_1.readContract)(this.client.viemClient, {
414
+ address: vaultData.asset,
415
+ abi: viem_1.erc20Abi,
416
+ functionName: "balanceOf",
417
+ args: [blue],
418
+ }),
419
+ ]);
388
420
  if (blueBalance < peak) {
389
421
  throw new index_js_3.InsufficientBlueBalanceForInKindRedeemError({
390
422
  asset: vaultData.asset,
@@ -621,28 +653,27 @@ class MorphoVaultV2 {
621
653
  if (deadline <= requirementsTimestamp) {
622
654
  throw new index_js_3.ExpiredDeadlineError(deadline, requirementsTimestamp);
623
655
  }
656
+ await (0, validateClientChainId_js_1.validateClientChainId)(this.client.viemClient, this.chainId);
657
+ await this.assertWriteTargets(["bundles.vaultExitBundlesV1"]);
624
658
  // Vault gates are intentionally left to the final transaction: the receive-assets gate may
625
659
  // inspect VaultExitBundlesV1's transient `initiator`, and a send-shares gate is arbitrary
626
660
  // external code re-evaluated after each intermediate penalty burn, so neither is
627
661
  // execution-equivalent from a standalone read. Unlike in-kind redemption, this exit never
628
662
  // supplies into Morpho Blue, so no Blue token-balance check is needed.
629
- const [allowance, nonce] = await (0, actions_1.multicall)(this.client.viemClient, {
630
- allowFailure: false,
631
- contracts: [
632
- {
633
- address: this.vault,
634
- abi: viem_1.erc20Abi,
635
- functionName: "allowance",
636
- args: [userAddress, vaultExitBundlesV1],
637
- },
638
- {
639
- address: this.vault,
640
- abi: blue_sdk_viem_1.erc2612Abi,
641
- functionName: "nonces",
642
- args: [userAddress],
643
- },
644
- ],
645
- });
663
+ const [allowance, nonce] = await Promise.all([
664
+ (0, actions_1.readContract)(this.client.viemClient, {
665
+ address: this.vault,
666
+ abi: viem_1.erc20Abi,
667
+ functionName: "allowance",
668
+ args: [userAddress, vaultExitBundlesV1],
669
+ }),
670
+ (0, actions_1.readContract)(this.client.viemClient, {
671
+ address: this.vault,
672
+ abi: blue_sdk_viem_1.erc2612Abi,
673
+ functionName: "nonces",
674
+ args: [userAddress],
675
+ }),
676
+ ]);
646
677
  if (allowance >= requiredShareAllowance)
647
678
  return [];
648
679
  if (this.client.options.supportSignature) {
@@ -1,7 +1,7 @@
1
1
  export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
4
- export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
4
+ export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
5
5
  export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, InvalidRateRatifierV1RateError as InvalidMidnightRateRatifierV1RateError, InvalidRateRatifierV1TickError as InvalidMidnightRateRatifierV1TickError, InvalidRateRatifierV1TimeError as InvalidMidnightRateRatifierV1TimeError, InvalidRatifierV1AddressError as InvalidMidnightRatifierV1AddressError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, RateRatifierV1BoundOverflowError as MidnightRateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError as MidnightRatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
6
6
  export type { ErrorClass } from "@morpho-org/morpho-ts";
7
7
  export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";