@morpho-org/morpho-sdk 6.0.0-next.3 → 6.0.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 (123) hide show
  1. package/MIGRATION-v5-to-v6.md +24 -16
  2. package/README.md +6 -4
  3. package/lib/cjs/abis.d.ts +5 -1
  4. package/lib/cjs/abis.js +2 -0
  5. package/lib/cjs/actions/bundles/common.d.ts +20 -25
  6. package/lib/cjs/actions/bundles/common.js +46 -85
  7. package/lib/cjs/actions/bundles/index.d.ts +1 -1
  8. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +6 -2
  9. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +6 -2
  10. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +1 -0
  11. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -0
  12. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +11 -3
  13. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +19 -1
  14. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -1
  15. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +12 -0
  16. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +2 -1
  17. package/lib/cjs/actions/vaultV1/inKindRedeem.js +2 -1
  18. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +62 -17
  19. package/lib/cjs/actions/vaultV1/migrateToV2.js +48 -17
  20. package/lib/cjs/actions/vaultV1/redeem.d.ts +28 -1
  21. package/lib/cjs/actions/vaultV1/redeem.js +17 -1
  22. package/lib/cjs/actions/vaultV1/withdraw.d.ts +1 -1
  23. package/lib/cjs/actions/vaultV1/withdraw.js +1 -1
  24. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +3 -2
  25. package/lib/cjs/actions/vaultV2/forceWithdraw.js +3 -2
  26. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +2 -1
  27. package/lib/cjs/actions/vaultV2/inKindRedeem.js +2 -1
  28. package/lib/cjs/actions/vaultV2/redeem.d.ts +28 -1
  29. package/lib/cjs/actions/vaultV2/redeem.js +17 -1
  30. package/lib/cjs/actions/vaultV2/withdraw.d.ts +1 -1
  31. package/lib/cjs/actions/vaultV2/withdraw.js +1 -1
  32. package/lib/cjs/augment/AccrualPosition.d.ts +1 -0
  33. package/lib/cjs/blue/abis.d.ts +5 -1
  34. package/lib/cjs/blue/abis.js +2 -0
  35. package/lib/cjs/blue/entities.d.ts +10 -2
  36. package/lib/cjs/blue/entities.js +2 -0
  37. package/lib/cjs/blue/errors.d.ts +4 -2
  38. package/lib/cjs/blue/errors.js +3 -1
  39. package/lib/cjs/blue/fetch.d.ts +5 -1
  40. package/lib/cjs/blue/fetch.js +2 -0
  41. package/lib/cjs/blue/utils.d.ts +5 -1
  42. package/lib/cjs/blue/utils.js +2 -0
  43. package/lib/cjs/entities/index.d.ts +10 -2
  44. package/lib/cjs/entities/index.js +2 -0
  45. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -2
  46. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -3
  47. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +31 -21
  48. package/lib/cjs/entities/vaultV1/vaultV1.js +50 -83
  49. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +52 -35
  50. package/lib/cjs/entities/vaultV2/vaultV2.js +71 -81
  51. package/lib/cjs/errors.d.ts +5 -3
  52. package/lib/cjs/errors.js +4 -1
  53. package/lib/cjs/fetch.d.ts +5 -1
  54. package/lib/cjs/fetch.js +2 -0
  55. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +11 -5
  56. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +48 -15
  57. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +48 -15
  58. package/lib/cjs/midnight/errors.d.ts +1 -1
  59. package/lib/cjs/midnight/errors.js +2 -1
  60. package/lib/cjs/types/action.d.ts +1 -0
  61. package/lib/cjs/utils.d.ts +5 -1
  62. package/lib/cjs/utils.js +2 -0
  63. package/lib/esm/abis.d.ts +5 -1
  64. package/lib/esm/abis.js +5 -1
  65. package/lib/esm/actions/bundles/common.d.ts +20 -25
  66. package/lib/esm/actions/bundles/common.js +44 -82
  67. package/lib/esm/actions/bundles/index.d.ts +1 -1
  68. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +6 -2
  69. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +6 -2
  70. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +1 -0
  71. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -0
  72. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +11 -3
  73. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +21 -3
  74. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -1
  75. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +14 -2
  76. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +2 -1
  77. package/lib/esm/actions/vaultV1/inKindRedeem.js +2 -1
  78. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +62 -17
  79. package/lib/esm/actions/vaultV1/migrateToV2.js +48 -17
  80. package/lib/esm/actions/vaultV1/redeem.d.ts +28 -1
  81. package/lib/esm/actions/vaultV1/redeem.js +17 -1
  82. package/lib/esm/actions/vaultV1/withdraw.d.ts +1 -1
  83. package/lib/esm/actions/vaultV1/withdraw.js +1 -1
  84. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +3 -2
  85. package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -2
  86. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +2 -1
  87. package/lib/esm/actions/vaultV2/inKindRedeem.js +2 -1
  88. package/lib/esm/actions/vaultV2/redeem.d.ts +28 -1
  89. package/lib/esm/actions/vaultV2/redeem.js +17 -1
  90. package/lib/esm/actions/vaultV2/withdraw.d.ts +1 -1
  91. package/lib/esm/actions/vaultV2/withdraw.js +1 -1
  92. package/lib/esm/augment/AccrualPosition.d.ts +1 -0
  93. package/lib/esm/blue/abis.d.ts +5 -1
  94. package/lib/esm/blue/abis.js +5 -1
  95. package/lib/esm/blue/entities.d.ts +10 -2
  96. package/lib/esm/blue/entities.js +5 -1
  97. package/lib/esm/blue/errors.d.ts +4 -2
  98. package/lib/esm/blue/errors.js +4 -2
  99. package/lib/esm/blue/fetch.d.ts +5 -1
  100. package/lib/esm/blue/fetch.js +5 -1
  101. package/lib/esm/blue/utils.d.ts +5 -1
  102. package/lib/esm/blue/utils.js +5 -1
  103. package/lib/esm/entities/index.d.ts +10 -2
  104. package/lib/esm/entities/index.js +5 -1
  105. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -2
  106. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -3
  107. package/lib/esm/entities/vaultV1/vaultV1.d.ts +31 -21
  108. package/lib/esm/entities/vaultV1/vaultV1.js +52 -85
  109. package/lib/esm/entities/vaultV2/vaultV2.d.ts +52 -35
  110. package/lib/esm/entities/vaultV2/vaultV2.js +73 -83
  111. package/lib/esm/errors.d.ts +5 -3
  112. package/lib/esm/errors.js +5 -3
  113. package/lib/esm/fetch.d.ts +5 -1
  114. package/lib/esm/fetch.js +5 -1
  115. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +11 -5
  116. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +48 -15
  117. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +48 -15
  118. package/lib/esm/midnight/errors.d.ts +1 -1
  119. package/lib/esm/midnight/errors.js +1 -1
  120. package/lib/esm/types/action.d.ts +1 -0
  121. package/lib/esm/utils.d.ts +5 -1
  122. package/lib/esm/utils.js +5 -1
  123. package/package.json +6 -9
@@ -1 +1,5 @@
1
- export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition, fetchPreLiquidationParams, fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
1
+ export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
2
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
+ fetchPreLiquidationParams,
4
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
+ fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
@@ -13,7 +13,9 @@ Object.defineProperty(exports, "fetchHolding", { enumerable: true, get: function
13
13
  Object.defineProperty(exports, "fetchMarket", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchMarket; } });
14
14
  Object.defineProperty(exports, "fetchMarketParams", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchMarketParams; } });
15
15
  Object.defineProperty(exports, "fetchPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchPosition; } });
16
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
16
17
  Object.defineProperty(exports, "fetchPreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchPreLiquidationParams; } });
18
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
17
19
  Object.defineProperty(exports, "fetchPreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchPreLiquidationPosition; } });
18
20
  Object.defineProperty(exports, "fetchToken", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchToken; } });
19
21
  Object.defineProperty(exports, "fetchUser", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchUser; } });
@@ -1,3 +1,7 @@
1
1
  export type { CapacityLimit, RoundingDirection } from "@morpho-org/blue-sdk";
2
- export { AdaptiveCurveIrmLib, CapacityLimitReason, defaultPreLiquidationParamsRegistry, getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
2
+ export { AdaptiveCurveIrmLib, CapacityLimitReason,
3
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
+ defaultPreLiquidationParamsRegistry,
5
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
6
+ getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
3
7
  export { decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
@@ -4,7 +4,9 @@ exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = expo
4
4
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  Object.defineProperty(exports, "AdaptiveCurveIrmLib", { enumerable: true, get: function () { return blue_sdk_1.AdaptiveCurveIrmLib; } });
6
6
  Object.defineProperty(exports, "CapacityLimitReason", { enumerable: true, get: function () { return blue_sdk_1.CapacityLimitReason; } });
7
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
7
8
  Object.defineProperty(exports, "defaultPreLiquidationParamsRegistry", { enumerable: true, get: function () { return blue_sdk_1.defaultPreLiquidationParamsRegistry; } });
9
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
8
10
  Object.defineProperty(exports, "getDefaultPreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.getDefaultPreLiquidationParams; } });
9
11
  Object.defineProperty(exports, "MarketUtils", { enumerable: true, get: function () { return blue_sdk_1.MarketUtils; } });
10
12
  Object.defineProperty(exports, "MathLib", { enumerable: true, get: function () { return blue_sdk_1.MathLib; } });
@@ -1,5 +1,13 @@
1
- export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition, IPreLiquidationParams as IBluePreLiquidationParams, IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
2
- export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition, PreLiquidationParams as BluePreLiquidationParams, PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
1
+ export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition,
2
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
+ IPreLiquidationParams as IBluePreLiquidationParams,
4
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
+ IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
6
+ export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
7
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
8
+ PreLiquidationParams as BluePreLiquidationParams,
9
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
10
+ PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
3
11
  export type { BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, GroupInput as MidnightGroupInput, IAccrualPosition as IMidnightAccrualPosition, ICollateralParams as IMidnightCollateralParams, IGroup as IMidnightGroup, IMarket as IMidnightMarket, IMarketParams as IMidnightMarketParams, IOffer as IMidnightOffer, IPosition as IMidnightPosition, MarketInput as MidnightMarketInput, OfferStruct as MidnightOfferStruct, RatifierTreeInput as MidnightRatifierTreeInput, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeDescriptor as MidnightTreeDescriptor, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, } from "@morpho-org/midnight-sdk";
4
12
  export { AccrualPosition as MidnightAccrualPosition, Group as MidnightGroup, Market as MidnightMarket, MarketParams as MidnightMarketParams, Offer as MidnightOffer, Position as MidnightPosition, Tree as MidnightTree, } from "@morpho-org/midnight-sdk";
5
13
  export type { BlueActions, BlueTokenRequirementsParams, } from "./blue/index.js";
@@ -30,7 +30,9 @@ Object.defineProperty(exports, "Holding", { enumerable: true, get: function () {
30
30
  Object.defineProperty(exports, "BlueMarket", { enumerable: true, get: function () { return blue_sdk_1.Market; } });
31
31
  Object.defineProperty(exports, "BlueMarketParams", { enumerable: true, get: function () { return blue_sdk_1.MarketParams; } });
32
32
  Object.defineProperty(exports, "BluePosition", { enumerable: true, get: function () { return blue_sdk_1.Position; } });
33
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
33
34
  Object.defineProperty(exports, "BluePreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationParams; } });
35
+ /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
34
36
  Object.defineProperty(exports, "BluePreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationPosition; } });
35
37
  Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return blue_sdk_1.Token; } });
36
38
  Object.defineProperty(exports, "BlueUser", { enumerable: true, get: function () { return blue_sdk_1.User; } });
@@ -6,14 +6,17 @@ import { type ActionRequirement } from "../../types/index.js";
6
6
  *
7
7
  * The exit burns however many shares the vault prices at execution time, so the share allowance is
8
8
  * the only cap on that burn. A leftover allowance above `requiredShareAllowance` therefore does not
9
- * satisfy the requirement: it is replaced by an approval or permit for exactly the computed cap.
9
+ * satisfy the requirement: it is replaced by an onchain approval for exactly the computed cap. Only
10
+ * an insufficient allowance may be raised through an ERC-2612 permit, because VaultBundlesV1 skips a
11
+ * permit whose nonce was already consumed and the leftover allowance would then stay in force.
10
12
  *
11
13
  * @internal
12
14
  *
13
15
  * @param viemClient - Client used to read the current share allowance and permit nonce.
14
16
  * @param params - Vault snapshot, owner, exact allowance, and deadline values.
15
17
  * @returns No requirement when the allowance already equals `requiredShareAllowance`, otherwise one
16
- * permit or approval that sets it to exactly that cap.
18
+ * approval that sets it to exactly that cap, or one permit when the allowance is below the cap
19
+ * and signatures are supported.
17
20
  * @throws {ExpiredDeadlineError} when the bundles deadline has elapsed.
18
21
  * @throws {viem.BaseError} when an allowance or nonce read fails.
19
22
  */
@@ -13,14 +13,17 @@ const index_js_3 = require("../../types/index.js");
13
13
  *
14
14
  * The exit burns however many shares the vault prices at execution time, so the share allowance is
15
15
  * the only cap on that burn. A leftover allowance above `requiredShareAllowance` therefore does not
16
- * satisfy the requirement: it is replaced by an approval or permit for exactly the computed cap.
16
+ * satisfy the requirement: it is replaced by an onchain approval for exactly the computed cap. Only
17
+ * an insufficient allowance may be raised through an ERC-2612 permit, because VaultBundlesV1 skips a
18
+ * permit whose nonce was already consumed and the leftover allowance would then stay in force.
17
19
  *
18
20
  * @internal
19
21
  *
20
22
  * @param viemClient - Client used to read the current share allowance and permit nonce.
21
23
  * @param params - Vault snapshot, owner, exact allowance, and deadline values.
22
24
  * @returns No requirement when the allowance already equals `requiredShareAllowance`, otherwise one
23
- * permit or approval that sets it to exactly that cap.
25
+ * approval that sets it to exactly that cap, or one permit when the allowance is below the cap
26
+ * and signatures are supported.
24
27
  * @throws {ExpiredDeadlineError} when the bundles deadline has elapsed.
25
28
  * @throws {viem.BaseError} when an allowance or nonce read fails.
26
29
  */
@@ -42,7 +45,9 @@ const getVaultBundlesSharesRequirements = async (viemClient, params) => {
42
45
  // so only an exact match skips the approval or permit that resets it to the computed cap.
43
46
  if (allowance === params.requiredShareAllowance)
44
47
  return [];
45
- if (params.supportSignature) {
48
+ // An oversized allowance is only ever lowered onchain: `TokenLib.submitPermit` skips a permit
49
+ // whose nonce was already consumed, which would silently leave the stale cap in force.
50
+ if (allowance < params.requiredShareAllowance && params.supportSignature) {
46
51
  const nonce = await (0, actions_1.readContract)(viemClient, {
47
52
  address: params.vaultData.address,
48
53
  abi: blue_sdk_viem_1.erc2612Abi,
@@ -9,6 +9,7 @@ export interface VaultV1Actions {
9
9
  *
10
10
  * @param {FetchParameters} [parameters] - Optional fetch parameters (block number, state overrides, etc.).
11
11
  * @returns {Promise<Awaited<ReturnType<typeof fetchAccrualVault>>>} The requested vault state.
12
+ * @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
12
13
  */
13
14
  getData: (parameters?: FetchParameters) => Promise<Awaited<ReturnType<typeof fetchAccrualVault>>>;
14
15
  /**
@@ -19,7 +20,7 @@ export interface VaultV1Actions {
19
20
  * Permit2 nonce state. Native funding is exclusive and skips token requirements. Shares are
20
21
  * always minted to the transaction sender, which must be `userAddress`.
21
22
  * Concurrent requirement reads share the first caller's options; later calls refresh on-chain
22
- * state using their own options. `buildTx()` accepts signatures from the latest completed read.
23
+ * state using their own options.
23
24
  *
24
25
  * @param params.userAddress - Account that funds, signs, submits, and receives the vault shares.
25
26
  * @param params.vaultData - Pre-fetched Vault V1 snapshot used for asset and share conversion.
@@ -55,8 +56,9 @@ export interface VaultV1Actions {
55
56
  * `getRequirements()` when the Permit2 nonce exceeds uint256.
56
57
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
57
58
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
58
- * @throws {BundlesPermitMismatchError} from `buildTx()` when the signature was not produced for
59
- * this prepared handle.
59
+ * @throws {BundlesPermitMismatchError} from `buildTx()` when the signature's spender, amount or
60
+ * deadline differ from this operation's, or when the signature's carried action nonce is
61
+ * inconsistent with its signed nonce.
60
62
  * @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
61
63
  * @throws {DepositAssetMismatchError} from `buildTx()` when the signed asset differs from the vault asset.
62
64
  * @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when signature metadata is malformed.
@@ -95,13 +97,14 @@ export interface VaultV1Actions {
95
97
  /**
96
98
  * Prepares an exact-assets Vault V1 withdrawal through VaultBundlesV1.
97
99
  *
98
- * Reads the vault accrual state on the first `getRequirements()` call, then reads the live
99
- * vault-share allowance and, when a signature is needed, the permit nonce on each call.
100
- * Captures the requested amount and owner at creation, so later changes to `params` do not
101
- * change this handle's requirements or transaction.
100
+ * Derives the share-burn cap from the supplied `vaultData` snapshot at handle creation, then
101
+ * reads the live vault-share allowance and, when a signature is needed, the permit nonce on
102
+ * each `getRequirements()` call. Captures the requested amount and owner at creation, so later
103
+ * changes to `params` do not change this handle's requirements or transaction.
102
104
  *
103
105
  * @param params.amount - Positive gross withdrawal in underlying asset base units, before fees.
104
106
  * @param params.userAddress - Share owner that must sign and submit; receives the net assets.
107
+ * @param params.vaultData - Pre-fetched Vault V1 snapshot used to derive the share cap.
105
108
  * @param params.slippageTolerance - Optional WAD-scaled share-price loss tolerance applied to
106
109
  * the share cap for MetaMorpho 1.0; MetaMorpho 1.1 retains its lost-assets clamp.
107
110
  * Defaults to 0.03% and cannot exceed 10%.
@@ -112,9 +115,13 @@ export interface VaultV1Actions {
112
115
  * defaults to two hours from handle creation.
113
116
  * @returns A frozen handle with lazy `getRequirements()` and synchronous `buildTx(signatures?)`,
114
117
  * which returns a deep-frozen `Transaction<VaultV1WithdrawAction>`. Requirements are empty
115
- * when the allowance equals the cap; otherwise they contain an exact approval or, with
116
- * signature support, an ERC-2612 request. The cap stays pinned to the first resolution while
117
- * each call re-reads the allowance. Confirm the approval or pass its signed permit to `buildTx`.
118
+ * when the allowance equals the cap; an oversized allowance is always reset with an exact
119
+ * onchain approval, and an insufficient one is raised by an approval or, with signature
120
+ * support, an ERC-2612 request. The cap is fixed at handle creation while each call re-reads
121
+ * the allowance. Confirm the approval or pass its signed permit to `buildTx`.
122
+ * @remarks VaultBundlesV1 skips a share permit whose nonce was already consumed and proceeds
123
+ * under the live allowance, so execute every requirement returned by the latest
124
+ * `getRequirements()` — including the oversized-allowance reset — before submitting.
118
125
  * @throws {ChainIdMismatchError} when the connected client targets another chain.
119
126
  * @throws {NonPositiveInputError} when `amount` or the computed share cap is not positive.
120
127
  * @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
@@ -124,14 +131,14 @@ export interface VaultV1Actions {
124
131
  * @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
125
132
  * @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no nonzero recipient.
126
133
  * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds 10%.
134
+ * @throws {VaultAddressMismatchError} when `vaultData` belongs to another vault.
127
135
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
128
136
  * @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
129
137
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
130
138
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple permits are supplied.
131
- * @throws {BundlesPermitMismatchError} from `buildTx()` when the share permit is malformed,
132
- * was not resolved for this handle, or has incompatible vault, owner, spender, amount,
133
- * deadline, or nonce values.
134
- * @throws {viem.BaseError} when a vault, allowance, or nonce read or transaction encoding fails.
139
+ * @throws {BundlesPermitMismatchError} from `buildTx()` when the share permit is malformed or
140
+ * its spender, amount or deadline differ from this operation's.
141
+ * @throws {viem.BaseError} when an allowance or nonce read or transaction encoding fails.
135
142
  * @example
136
143
  * ```ts
137
144
  * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
@@ -143,7 +150,8 @@ export interface VaultV1Actions {
143
150
  * const client = createPublicClient({ chain: mainnet, transport: http() })
144
151
  * .extend(morphoViemExtension({ supportSignature: false }));
145
152
  * const vault = client.morpho.vaultV1(vaultAddress, mainnet.id);
146
- * const action = vault.withdraw({ amount: 1_000_000n, userAddress });
153
+ * const vaultData = await vault.getData();
154
+ * const action = vault.withdraw({ amount: 1_000_000n, userAddress, vaultData });
147
155
  * const requirements = await action.getRequirements();
148
156
  * // Send and confirm each approval before calling action.buildTx().
149
157
  * // action.buildTx() returns Readonly<Transaction<VaultV1WithdrawAction>>.
@@ -154,6 +162,7 @@ export interface VaultV1Actions {
154
162
  withdraw: (params: {
155
163
  readonly amount: bigint;
156
164
  readonly userAddress: Address;
165
+ readonly vaultData: AccrualVault;
157
166
  readonly slippageTolerance?: bigint;
158
167
  readonly referralFeePct?: bigint;
159
168
  readonly referralFeeRecipient?: Address;
@@ -165,7 +174,6 @@ export interface VaultV1Actions {
165
174
  * Captures `shares` and `userAddress` at handle creation for both requirements and `buildTx()`.
166
175
  * The caller must satisfy the exact vault-share allowance returned by `getRequirements()` before
167
176
  * `buildTx()`; every requirement resolution re-reads the live allowance and checks the deadline.
168
- * `buildTx()` accepts permits from the latest completed requirement resolution.
169
177
  *
170
178
  * @param params.shares - Exact vault shares to burn.
171
179
  * @param params.userAddress - Account that signs and submits the transaction; VaultBundlesV1
@@ -179,6 +187,7 @@ export interface VaultV1Actions {
179
187
  * @throws {ChainIdMismatchError} when the connected client targets another chain.
180
188
  * @throws {NonPositiveInputError} when `shares` is not positive.
181
189
  * @throws {ExpiredDeadlineError} when the deadline is stale at creation or requirement resolution.
190
+ * @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256.
182
191
  * @throws {NegativeInputError} when `referralFeePct` is negative.
183
192
  * @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
184
193
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no non-zero recipient.
@@ -187,8 +196,8 @@ export interface VaultV1Actions {
187
196
  * @throws {viem.BaseError} from `getRequirements()` when an allowance or permit-nonce read fails.
188
197
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple permit signatures are supplied.
189
198
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-permit signature is supplied.
190
- * @throws {BundlesPermitMismatchError} from `buildTx()` when the supplied permit does not match
191
- * the resolved share amount, spender, owner, nonce, or deadline.
199
+ * @throws {BundlesPermitMismatchError} from `buildTx()` when the signature's spender, amount or
200
+ * deadline differ from this operation's.
192
201
  * @example
193
202
  * ```ts
194
203
  * import { vaults } from "@morpho-org/morpho-test";
@@ -313,7 +322,6 @@ export interface VaultV1Actions {
313
322
  * VaultBundlesV1. Only the destination deposit has an onchain share-price bound. The caller must
314
323
  * satisfy the exact source-vault share requirement before building the transaction.
315
324
  * Captures vault identities, permit-domain metadata, and the owner at handle creation.
316
- * `buildTx()` accepts permits from the latest completed requirement resolution.
317
325
  *
318
326
  * @param params.userAddress - Account that signs and submits the transaction; VaultBundlesV1
319
327
  * burns and mints shares for `msg.sender`.
@@ -346,6 +354,7 @@ export interface VaultV1Actions {
346
354
  * @throws {NegativeInputError} when slippage tolerance or `referralFeePct` is negative.
347
355
  * @throws {ExcessiveSlippageToleranceError} when slippage tolerance exceeds the SDK maximum.
348
356
  * @throws {ExpiredDeadlineError} when the deadline is stale at creation or requirement resolution.
357
+ * @throws {InputExceedsMaxError} when the selected amount, `maxSharePriceVaultV2`, or `deadline` exceeds uint256.
349
358
  * @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
350
359
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no non-zero recipient.
351
360
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
@@ -353,8 +362,8 @@ export interface VaultV1Actions {
353
362
  * @throws {viem.BaseError} from `getRequirements()` when an allowance or permit-nonce read fails.
354
363
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple permit signatures are supplied.
355
364
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-permit signature is supplied.
356
- * @throws {BundlesPermitMismatchError} from `buildTx()` when the supplied permit does not match
357
- * the prepared source share cap, spender, owner, nonce, or deadline.
365
+ * @throws {BundlesPermitMismatchError} from `buildTx()` when the signature's spender, amount or
366
+ * deadline differ from this operation's.
358
367
  * @example
359
368
  * ```ts
360
369
  * import { vaults } from "@morpho-org/morpho-test";
@@ -426,6 +435,7 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
426
435
  withdraw(params: {
427
436
  readonly amount: bigint;
428
437
  readonly userAddress: Address;
438
+ readonly vaultData: AccrualVault;
429
439
  readonly slippageTolerance?: bigint;
430
440
  readonly referralFeePct?: bigint;
431
441
  readonly referralFeeRecipient?: Address;
@@ -24,10 +24,7 @@ class MorphoVaultV1 {
24
24
  this.chainId = chainId;
25
25
  }
26
26
  async getData(parameters) {
27
- if (this.client.viemClient.chain?.id &&
28
- this.client.viemClient.chain?.id !== this.chainId) {
29
- throw new index_js_3.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
30
- }
27
+ (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
31
28
  return (0, blue_sdk_viem_1.fetchAccrualVault)(this.vault, this.client.viemClient, {
32
29
  ...parameters,
33
30
  deployless: this.client.options.supportDeployless,
@@ -66,7 +63,6 @@ class MorphoVaultV1 {
66
63
  });
67
64
  const spender = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultBundlesV1");
68
65
  let pendingRequirements;
69
- let expectedRequirement;
70
66
  return Object.freeze({
71
67
  getRequirements: async (requirementOptions) => {
72
68
  const now = morpho_ts_1.Time.timestamp();
@@ -74,33 +70,22 @@ class MorphoVaultV1 {
74
70
  throw new index_js_3.ExpiredDeadlineError(deadline, now);
75
71
  if (pendingRequirements != null)
76
72
  return await pendingRequirements;
77
- // Memoize the in-flight promise, not just its result: concurrent callers
78
- // requesting different routes would otherwise both resolve requirements and
79
- // the slower one would overwrite `expectedRequirement`, making `buildTx()`
80
- // reject the signature returned by the other call.
81
- const pending = (async () => {
82
- const requirements = funding.value > 0n
83
- ? []
84
- : await (0, index_js_4.getBundlesTokenRequirements)(this.client.viemClient, {
85
- token: vaultAsset,
86
- spender,
87
- amount: funding.assets,
88
- owner: userAddress,
89
- chainId: this.chainId,
90
- deadline,
91
- supportSignature: this.client.options.supportSignature,
92
- supportDeployless: this.client.options.supportDeployless,
93
- useSimplePermit: requirementOptions?.useSimplePermit,
94
- permit2Nonce: requirementOptions?.permit2Nonce,
95
- });
96
- const signatureRequirement = requirements.find(index_js_3.isRequirementSignature);
97
- expectedRequirement =
98
- signatureRequirement?.action.type === "permit" ||
99
- signatureRequirement?.action.type === "permit2SignatureTransfer"
100
- ? signatureRequirement.action
101
- : undefined;
102
- return requirements;
103
- })();
73
+ // Memoize the in-flight promise so concurrent callers share one round of
74
+ // allowance/nonce reads.
75
+ const pending = funding.value > 0n
76
+ ? Promise.resolve([])
77
+ : (0, index_js_4.getBundlesTokenRequirements)(this.client.viemClient, {
78
+ token: vaultAsset,
79
+ spender,
80
+ amount: funding.assets,
81
+ owner: userAddress,
82
+ chainId: this.chainId,
83
+ deadline,
84
+ supportSignature: this.client.options.supportSignature,
85
+ supportDeployless: this.client.options.supportDeployless,
86
+ useSimplePermit: requirementOptions?.useSimplePermit,
87
+ permit2Nonce: requirementOptions?.permit2Nonce,
88
+ });
104
89
  pendingRequirements = pending;
105
90
  try {
106
91
  return await pending;
@@ -112,7 +97,8 @@ class MorphoVaultV1 {
112
97
  }
113
98
  },
114
99
  buildTx: (signatures) => {
115
- const requirementSignature = (0, common_js_1.selectBundlesTokenRequirementSignature)(signatures, expectedRequirement);
100
+ // The pure deposit action rejects a token signature supplied alongside native funding.
101
+ const requirementSignature = (0, common_js_1.selectBundlesTokenRequirementSignature)(signatures, { spender, amount: funding.assets, deadline });
116
102
  return (0, index_js_1.vaultV1Deposit)({
117
103
  vault: {
118
104
  chainId: this.chainId,
@@ -136,8 +122,11 @@ class MorphoVaultV1 {
136
122
  });
137
123
  }
138
124
  withdraw(params) {
139
- const { amount, userAddress } = params;
125
+ const { amount, userAddress, vaultData } = params;
140
126
  (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
127
+ if (!(0, viem_1.isAddressEqual)(vaultData.address, this.vault)) {
128
+ throw new index_js_3.VaultAddressMismatchError(this.vault, vaultData.address);
129
+ }
141
130
  if (amount <= 0n)
142
131
  throw new index_js_3.NonPositiveInputError("amount", amount);
143
132
  // Reject values outside the ABI range before resolving any requirements.
@@ -153,11 +142,14 @@ class MorphoVaultV1 {
153
142
  });
154
143
  const slippageTolerance = params.slippageTolerance ?? blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE;
155
144
  (0, index_js_2.validateSlippageTolerance)(slippageTolerance);
156
- // Fail eagerly if VaultBundlesV1 is unavailable; only validation is needed here.
157
- (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultBundlesV1");
158
- let requiredShareAllowance;
159
- let vaultSnapshot;
160
- let expectedRequirement;
145
+ // Resolve the spender eagerly so an unregistered VaultBundlesV1 fails at handle creation.
146
+ const spender = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultBundlesV1");
147
+ const requiredShareAllowance = (0, index_js_2.computeVaultMaxShareAllowance)({
148
+ vaultData,
149
+ deadline,
150
+ assets: amount,
151
+ slippageTolerance,
152
+ });
161
153
  return Object.freeze({
162
154
  getRequirements: async () => {
163
155
  const now = morpho_ts_1.Time.timestamp();
@@ -166,18 +158,9 @@ class MorphoVaultV1 {
166
158
  // Re-read the live share allowance on every call instead of caching the resolved
167
159
  // requirements: the allowance is the sole cap on the burn, so a caller that executed the
168
160
  // returned approval must see it satisfied on the next call, and an allowance revoked or
169
- // raised afterwards must resurface as an outstanding requirement. Only the vault snapshot
170
- // and the cap derived from it are pinned, so re-reading cannot move the cap this handle
171
- // already committed to; the snapshot is used for immutable identity and permit-domain
172
- // fields only.
173
- const vaultData = (vaultSnapshot ??= await this.getData());
174
- requiredShareAllowance ??= (0, index_js_2.computeVaultMaxShareAllowance)({
175
- vaultData,
176
- deadline,
177
- assets: amount,
178
- slippageTolerance,
179
- });
180
- const requirements = await (0, getVaultBundlesSharesRequirements_js_1.getVaultBundlesSharesRequirements)(this.client.viemClient, {
161
+ // raised afterwards must resurface as an outstanding requirement. The cap derived from
162
+ // `vaultData` is pinned at handle creation, so re-reading cannot move it.
163
+ return (0, getVaultBundlesSharesRequirements_js_1.getVaultBundlesSharesRequirements)(this.client.viemClient, {
181
164
  vaultData,
182
165
  version: "vaultV1",
183
166
  owner: userAddress,
@@ -186,16 +169,12 @@ class MorphoVaultV1 {
186
169
  deadline,
187
170
  supportSignature: this.client.options.supportSignature,
188
171
  });
189
- const signatureRequirement = requirements.find(index_js_3.isRequirementSignature);
190
- if (signatureRequirement?.action.type === "permit") {
191
- expectedRequirement = signatureRequirement.action;
192
- }
193
- return requirements;
194
172
  },
195
173
  buildTx: (signatures) => {
196
- const permit = (0, common_js_1.selectBundlesSharesRequirementSignature)(signatures, {
197
- requiredShareAllowance,
198
- expectedRequirement,
174
+ const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signatures, {
175
+ spender,
176
+ amount: requiredShareAllowance,
177
+ deadline,
199
178
  });
200
179
  return (0, index_js_1.vaultV1Withdraw)({
201
180
  vault: { chainId: this.chainId, address: this.vault },
@@ -227,14 +206,13 @@ class MorphoVaultV1 {
227
206
  referralFeePct: params.referralFeePct,
228
207
  referralFeeRecipient: params.referralFeeRecipient,
229
208
  });
230
- (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultBundlesV1");
231
- let expectedRequirement;
209
+ const spender = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultBundlesV1");
232
210
  return Object.freeze({
233
211
  getRequirements: async () => {
234
212
  const now = morpho_ts_1.Time.timestamp();
235
213
  if (deadline <= now)
236
214
  throw new index_js_3.ExpiredDeadlineError(deadline, now);
237
- const requirements = await (0, getVaultBundlesSharesRequirements_js_1.getVaultBundlesSharesRequirements)(this.client.viemClient, {
215
+ return (0, getVaultBundlesSharesRequirements_js_1.getVaultBundlesSharesRequirements)(this.client.viemClient, {
238
216
  vaultData: await this.getData(),
239
217
  version: "vaultV1",
240
218
  owner: userAddress,
@@ -243,17 +221,12 @@ class MorphoVaultV1 {
243
221
  deadline,
244
222
  supportSignature: this.client.options.supportSignature,
245
223
  });
246
- const signatureRequirement = requirements.find(index_js_3.isRequirementSignature);
247
- expectedRequirement =
248
- signatureRequirement?.action.type === "permit"
249
- ? signatureRequirement.action
250
- : undefined;
251
- return requirements;
252
224
  },
253
225
  buildTx: (signatures) => {
254
- const permit = (0, common_js_1.selectBundlesSharesRequirementSignature)(signatures, {
255
- requiredShareAllowance: shares,
256
- expectedRequirement,
226
+ const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signatures, {
227
+ spender,
228
+ amount: shares,
229
+ deadline,
257
230
  });
258
231
  return (0, index_js_1.vaultV1Redeem)({
259
232
  vault: { chainId: this.chainId, address: this.vault },
@@ -496,7 +469,7 @@ class MorphoVaultV1 {
496
469
  assets: assets ?? 0n,
497
470
  slippageTolerance,
498
471
  });
499
- (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultBundlesV1");
472
+ const spender = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultBundlesV1");
500
473
  const { userAddress } = params;
501
474
  const sourceAsset = params.sourceVault.asset;
502
475
  const targetAddress = params.targetVault.address;
@@ -512,7 +485,6 @@ class MorphoVaultV1 {
512
485
  extensions: [...domain.extensions],
513
486
  }),
514
487
  });
515
- let expectedRequirement;
516
488
  return Object.freeze({
517
489
  getRequirements: async () => {
518
490
  const now = morpho_ts_1.Time.timestamp();
@@ -524,7 +496,7 @@ class MorphoVaultV1 {
524
496
  // satisfied on the next call, and an allowance revoked or raised afterwards must resurface
525
497
  // as an outstanding requirement. The pinned snapshot and the cap derived from it stay
526
498
  // fixed, so re-reading cannot move the cap this handle already committed to.
527
- const requirements = await (0, getVaultBundlesSharesRequirements_js_1.getVaultBundlesSharesRequirements)(this.client.viemClient, {
499
+ return (0, getVaultBundlesSharesRequirements_js_1.getVaultBundlesSharesRequirements)(this.client.viemClient, {
528
500
  vaultData: sourceToken,
529
501
  version: "vaultV1",
530
502
  owner: userAddress,
@@ -533,17 +505,12 @@ class MorphoVaultV1 {
533
505
  deadline,
534
506
  supportSignature: this.client.options.supportSignature,
535
507
  });
536
- const signatureRequirement = requirements.find(index_js_3.isRequirementSignature);
537
- expectedRequirement =
538
- signatureRequirement?.action.type === "permit"
539
- ? signatureRequirement.action
540
- : undefined;
541
- return requirements;
542
508
  },
543
509
  buildTx: (signatures) => {
544
- const permit = (0, common_js_1.selectBundlesSharesRequirementSignature)(signatures, {
545
- requiredShareAllowance,
546
- expectedRequirement,
510
+ const permit = (0, common_js_1.selectBundlesSharesPermitSignature)(signatures, {
511
+ spender,
512
+ amount: requiredShareAllowance,
513
+ deadline,
547
514
  });
548
515
  return (0, index_js_1.vaultV1MigrateToV2)({
549
516
  vault: {