@morpho-org/morpho-sdk 8.2.0 → 9.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 (155) hide show
  1. package/MIGRATION-v8-to-v9.md +54 -0
  2. package/README.md +14 -8
  3. package/lib/cjs/actions/bundles/common.d.ts +4 -7
  4. package/lib/cjs/actions/bundles/common.js +8 -14
  5. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -5
  6. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +1 -8
  7. package/lib/cjs/actions/midnight/authorization.d.ts +3 -1
  8. package/lib/cjs/actions/midnight/authorization.js +11 -1
  9. package/lib/cjs/actions/midnight/cancelAndMake.d.ts +2 -0
  10. package/lib/cjs/actions/midnight/cancelAndMake.js +10 -2
  11. package/lib/cjs/actions/midnight/redeem.d.ts +4 -1
  12. package/lib/cjs/actions/midnight/redeem.js +13 -3
  13. package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +1 -0
  14. package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +7 -3
  15. package/lib/cjs/actions/midnight/supplyCollateral.d.ts +5 -1
  16. package/lib/cjs/actions/midnight/supplyCollateral.js +14 -3
  17. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +3 -1
  18. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +9 -3
  19. package/lib/cjs/actions/midnight/takeBorrow.d.ts +3 -1
  20. package/lib/cjs/actions/midnight/takeBorrow.js +9 -3
  21. package/lib/cjs/actions/midnight/takeLend.d.ts +1 -0
  22. package/lib/cjs/actions/midnight/takeLend.js +7 -2
  23. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
  24. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +8 -2
  25. package/lib/cjs/actions/midnight/takeWithdraw.d.ts +3 -1
  26. package/lib/cjs/actions/midnight/takeWithdraw.js +10 -3
  27. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -5
  28. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +5 -7
  29. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +7 -11
  30. package/lib/cjs/actions/requirements/getRequirementsApproval.js +8 -15
  31. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +5 -10
  32. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +11 -8
  33. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +2 -0
  34. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -0
  35. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +1 -1
  36. package/lib/cjs/actions/vaultV1/inKindRedeem.js +1 -1
  37. package/lib/cjs/actions/vaultV1/withdraw.d.ts +4 -4
  38. package/lib/cjs/actions/vaultV1/withdraw.js +4 -4
  39. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
  40. package/lib/cjs/actions/vaultV2/forceWithdraw.js +1 -1
  41. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +1 -1
  42. package/lib/cjs/actions/vaultV2/inKindRedeem.js +1 -1
  43. package/lib/cjs/actions/vaultV2/withdraw.d.ts +4 -4
  44. package/lib/cjs/actions/vaultV2/withdraw.js +4 -4
  45. package/lib/cjs/entities/blue/blue.d.ts +2 -12
  46. package/lib/cjs/entities/blue/blue.js +0 -4
  47. package/lib/cjs/entities/midnight/midnight.d.ts +58 -17
  48. package/lib/cjs/entities/midnight/midnight.js +133 -52
  49. package/lib/cjs/entities/midnight/types.d.ts +2 -9
  50. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +0 -4
  51. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +0 -7
  52. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -14
  53. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -20
  54. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +40 -37
  55. package/lib/cjs/entities/vaultV1/vaultV1.js +5 -34
  56. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +36 -34
  57. package/lib/cjs/entities/vaultV2/vaultV2.js +8 -34
  58. package/lib/cjs/helpers/encodeMidnightCalldata.d.ts +48 -0
  59. package/lib/cjs/helpers/encodeMidnightCalldata.js +74 -0
  60. package/lib/cjs/helpers/slippage.d.ts +9 -25
  61. package/lib/cjs/helpers/slippage.js +10 -27
  62. package/lib/cjs/helpers/validate.d.ts +1 -0
  63. package/lib/cjs/helpers/validate.js +5 -0
  64. package/lib/cjs/helpers/validateMidnightAccount.d.ts +34 -0
  65. package/lib/cjs/helpers/validateMidnightAccount.js +47 -0
  66. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +1 -0
  67. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +4 -0
  68. package/lib/cjs/helpers/validateMidnightMarket.d.ts +2 -0
  69. package/lib/cjs/helpers/validateMidnightMarket.js +5 -0
  70. package/lib/cjs/helpers/validateMidnightPublication.d.ts +11 -0
  71. package/lib/cjs/helpers/validateMidnightPublication.js +12 -1
  72. package/lib/cjs/helpers/validateMidnightReceiver.d.ts +1 -0
  73. package/lib/cjs/helpers/validateMidnightReceiver.js +8 -0
  74. package/lib/cjs/helpers/validateTakeableOffers.d.ts +2 -1
  75. package/lib/cjs/helpers/validateTakeableOffers.js +4 -3
  76. package/lib/cjs/types/action.d.ts +3 -1
  77. package/lib/cjs/types/error.d.ts +64 -5
  78. package/lib/cjs/types/error.js +152 -10
  79. package/lib/esm/actions/bundles/common.d.ts +4 -7
  80. package/lib/esm/actions/bundles/common.js +8 -14
  81. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -5
  82. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +2 -9
  83. package/lib/esm/actions/midnight/authorization.d.ts +3 -1
  84. package/lib/esm/actions/midnight/authorization.js +12 -2
  85. package/lib/esm/actions/midnight/cancelAndMake.d.ts +2 -0
  86. package/lib/esm/actions/midnight/cancelAndMake.js +11 -3
  87. package/lib/esm/actions/midnight/redeem.d.ts +4 -1
  88. package/lib/esm/actions/midnight/redeem.js +15 -5
  89. package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +1 -0
  90. package/lib/esm/actions/midnight/repayWithdrawCollateral.js +8 -4
  91. package/lib/esm/actions/midnight/supplyCollateral.d.ts +5 -1
  92. package/lib/esm/actions/midnight/supplyCollateral.js +16 -5
  93. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +3 -1
  94. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +10 -4
  95. package/lib/esm/actions/midnight/takeBorrow.d.ts +3 -1
  96. package/lib/esm/actions/midnight/takeBorrow.js +10 -4
  97. package/lib/esm/actions/midnight/takeLend.d.ts +1 -0
  98. package/lib/esm/actions/midnight/takeLend.js +8 -3
  99. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
  100. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +9 -3
  101. package/lib/esm/actions/midnight/takeWithdraw.d.ts +3 -1
  102. package/lib/esm/actions/midnight/takeWithdraw.js +11 -4
  103. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -5
  104. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +6 -8
  105. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +7 -11
  106. package/lib/esm/actions/requirements/getRequirementsApproval.js +9 -16
  107. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +5 -10
  108. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +12 -9
  109. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +2 -0
  110. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -0
  111. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +1 -1
  112. package/lib/esm/actions/vaultV1/inKindRedeem.js +1 -1
  113. package/lib/esm/actions/vaultV1/withdraw.d.ts +4 -4
  114. package/lib/esm/actions/vaultV1/withdraw.js +4 -4
  115. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
  116. package/lib/esm/actions/vaultV2/forceWithdraw.js +1 -1
  117. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +1 -1
  118. package/lib/esm/actions/vaultV2/inKindRedeem.js +1 -1
  119. package/lib/esm/actions/vaultV2/withdraw.d.ts +4 -4
  120. package/lib/esm/actions/vaultV2/withdraw.js +4 -4
  121. package/lib/esm/entities/blue/blue.d.ts +2 -12
  122. package/lib/esm/entities/blue/blue.js +0 -4
  123. package/lib/esm/entities/midnight/midnight.d.ts +58 -17
  124. package/lib/esm/entities/midnight/midnight.js +134 -53
  125. package/lib/esm/entities/midnight/types.d.ts +2 -9
  126. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +0 -4
  127. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +1 -8
  128. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -14
  129. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +9 -21
  130. package/lib/esm/entities/vaultV1/vaultV1.d.ts +40 -37
  131. package/lib/esm/entities/vaultV1/vaultV1.js +6 -35
  132. package/lib/esm/entities/vaultV2/vaultV2.d.ts +36 -34
  133. package/lib/esm/entities/vaultV2/vaultV2.js +8 -34
  134. package/lib/esm/helpers/encodeMidnightCalldata.d.ts +48 -0
  135. package/lib/esm/helpers/encodeMidnightCalldata.js +69 -0
  136. package/lib/esm/helpers/slippage.d.ts +9 -25
  137. package/lib/esm/helpers/slippage.js +9 -25
  138. package/lib/esm/helpers/validate.d.ts +1 -0
  139. package/lib/esm/helpers/validate.js +5 -0
  140. package/lib/esm/helpers/validateMidnightAccount.d.ts +34 -0
  141. package/lib/esm/helpers/validateMidnightAccount.js +43 -0
  142. package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +1 -0
  143. package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +4 -0
  144. package/lib/esm/helpers/validateMidnightMarket.d.ts +2 -0
  145. package/lib/esm/helpers/validateMidnightMarket.js +5 -0
  146. package/lib/esm/helpers/validateMidnightPublication.d.ts +11 -0
  147. package/lib/esm/helpers/validateMidnightPublication.js +10 -0
  148. package/lib/esm/helpers/validateMidnightReceiver.d.ts +1 -0
  149. package/lib/esm/helpers/validateMidnightReceiver.js +8 -0
  150. package/lib/esm/helpers/validateTakeableOffers.d.ts +2 -1
  151. package/lib/esm/helpers/validateTakeableOffers.js +4 -3
  152. package/lib/esm/types/action.d.ts +3 -1
  153. package/lib/esm/types/error.d.ts +64 -5
  154. package/lib/esm/types/error.js +146 -6
  155. package/package.json +6 -5
@@ -8,11 +8,6 @@ export interface GetMidnightApprovalRequirementsParams {
8
8
  readonly owner: Address;
9
9
  readonly spender: Address;
10
10
  readonly amount: bigint;
11
- /**
12
- * Allowance to set when an approval is needed. Defaults to `maxUint256`; must be
13
- * at least `amount`.
14
- */
15
- readonly approvalAmount?: bigint;
16
11
  }
17
12
  /**
18
13
  * Resolves classic ERC20 approval requirements for a Midnight spender.
@@ -24,7 +19,7 @@ export interface GetMidnightApprovalRequirementsParams {
24
19
  * The returned approval sets an unlimited allowance (`maxUint256`, capped per
25
20
  * token by `MAX_TOKEN_APPROVALS`) whenever the current allowance is below
26
21
  * `amount`, because all of an account's Midnight offers and bundle calls share
27
- * one allowance per token. Pass `approvalAmount` to set a different allowance.
22
+ * one allowance per token.
28
23
  *
29
24
  * @param params.viemClient - Viem client used to read ERC20 allowance.
30
25
  * @param params.chainId - Chain id expected by the viem client.
@@ -32,14 +27,14 @@ export interface GetMidnightApprovalRequirementsParams {
32
27
  * @param params.owner - Token owner.
33
28
  * @param params.spender - Midnight spender that will pull tokens.
34
29
  * @param params.amount - Minimum allowance the spender needs.
35
- * @param params.approvalAmount - Allowance to approve when one is needed; defaults to `maxUint256` and must be at least `amount`.
36
30
  * @returns Approval transactions required for `spender` to pull `amount`.
37
31
  * @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`,
38
32
  * another chain than `params.chainId`.
33
+ * @throws {MidnightCalldataEncodingError} when `owner`, `token` or `spender` is not a well-formed address.
34
+ * @throws {MidnightZeroAccountError} when `owner` is the zero address.
39
35
  * @throws {viem.BaseError} when the `eth_chainId` request or allowance read fails.
40
- * @throws {NegativeInputError} when `amount` or `approvalAmount` is negative.
41
- * @throws {InputExceedsMaxError} when `amount` or `approvalAmount` exceeds `maxUint256`.
42
- * @throws {ApprovalAmountLessThanSpendAmountError} when `approvalAmount < amount`.
36
+ * @throws {NegativeInputError} when `amount` is negative.
37
+ * @throws {InputExceedsMaxError} when `amount` exceeds `maxUint256`.
43
38
  * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not the chain's Midnight or MidnightBundlesV2 deployment.
44
39
  * @example
45
40
  * ```ts
@@ -5,6 +5,7 @@ const viem_1 = require("viem");
5
5
  const actions_1 = require("viem/actions");
6
6
  const index_js_1 = require("../../../helpers/index.js");
7
7
  const validate_js_1 = require("../../../helpers/validate.js");
8
+ const validateMidnightAccount_js_1 = require("../../../helpers/validateMidnightAccount.js");
8
9
  const getRequirementsApproval_js_1 = require("../getRequirementsApproval.js");
9
10
  const validateClientChainId_js_1 = require("../validateClientChainId.js");
10
11
  /**
@@ -17,7 +18,7 @@ const validateClientChainId_js_1 = require("../validateClientChainId.js");
17
18
  * The returned approval sets an unlimited allowance (`maxUint256`, capped per
18
19
  * token by `MAX_TOKEN_APPROVALS`) whenever the current allowance is below
19
20
  * `amount`, because all of an account's Midnight offers and bundle calls share
20
- * one allowance per token. Pass `approvalAmount` to set a different allowance.
21
+ * one allowance per token.
21
22
  *
22
23
  * @param params.viemClient - Viem client used to read ERC20 allowance.
23
24
  * @param params.chainId - Chain id expected by the viem client.
@@ -25,14 +26,14 @@ const validateClientChainId_js_1 = require("../validateClientChainId.js");
25
26
  * @param params.owner - Token owner.
26
27
  * @param params.spender - Midnight spender that will pull tokens.
27
28
  * @param params.amount - Minimum allowance the spender needs.
28
- * @param params.approvalAmount - Allowance to approve when one is needed; defaults to `maxUint256` and must be at least `amount`.
29
29
  * @returns Approval transactions required for `spender` to pull `amount`.
30
30
  * @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`,
31
31
  * another chain than `params.chainId`.
32
+ * @throws {MidnightCalldataEncodingError} when `owner`, `token` or `spender` is not a well-formed address.
33
+ * @throws {MidnightZeroAccountError} when `owner` is the zero address.
32
34
  * @throws {viem.BaseError} when the `eth_chainId` request or allowance read fails.
33
- * @throws {NegativeInputError} when `amount` or `approvalAmount` is negative.
34
- * @throws {InputExceedsMaxError} when `amount` or `approvalAmount` exceeds `maxUint256`.
35
- * @throws {ApprovalAmountLessThanSpendAmountError} when `approvalAmount < amount`.
35
+ * @throws {NegativeInputError} when `amount` is negative.
36
+ * @throws {InputExceedsMaxError} when `amount` exceeds `maxUint256`.
36
37
  * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not the chain's Midnight or MidnightBundlesV2 deployment.
37
38
  * @example
38
39
  * ```ts
@@ -58,10 +59,13 @@ const validateClientChainId_js_1 = require("../validateClientChainId.js");
58
59
  * ```
59
60
  */
60
61
  const getMidnightApprovalRequirements = async (params) => {
62
+ // Reject the zero account before reading state for it.
63
+ (0, validateMidnightAccount_js_1.validateMidnightAccount)("owner", params.owner);
64
+ // Reject malformed addresses typed before the spender comparison and the allowance read.
65
+ (0, validateMidnightAccount_js_1.validateMidnightAddress)("token", params.token);
66
+ (0, validateMidnightAccount_js_1.validateMidnightAddress)("spender", params.spender);
61
67
  (0, index_js_1.validateChainId)(params.viemClient.chain?.id, params.chainId);
62
68
  (0, validate_js_1.validateUint256Field)("amount", params.amount);
63
- if (params.approvalAmount !== undefined)
64
- (0, validate_js_1.validateUint256Field)("approvalAmount", params.approvalAmount);
65
69
  // Validate the target even when no approval transaction needs to be encoded.
66
70
  (0, index_js_1.validateRequirementSpender)({
67
71
  chainId: params.chainId,
@@ -83,7 +87,6 @@ const getMidnightApprovalRequirements = async (params) => {
83
87
  args: {
84
88
  spender: params.spender,
85
89
  spendAmount: params.amount,
86
- approvalAmount: params.approvalAmount ?? viem_1.maxUint256,
87
90
  },
88
91
  allowances: allowance,
89
92
  });
@@ -23,6 +23,8 @@ export interface GetMidnightAuthorizationRequirementParams {
23
23
  * @returns Authorization transaction, or `null` when already authorized.
24
24
  * @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`,
25
25
  * another chain than `params.chainId`.
26
+ * @throws {MidnightCalldataEncodingError} when `owner` or `authorized` is not a well-formed address.
27
+ * @throws {MidnightZeroAccountError} when `owner` is the zero address.
26
28
  * @throws {viem.BaseError} when the `eth_chainId` request or authorization read fails.
27
29
  * @throws {UnsupportedMidnightAuthorizationTargetError} when `authorized` is not MidnightBundlesV2.
28
30
  * @example
@@ -6,6 +6,7 @@ const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
6
  const viem_1 = require("viem");
7
7
  const actions_1 = require("viem/actions");
8
8
  const index_js_1 = require("../../../helpers/index.js");
9
+ const validateMidnightAccount_js_1 = require("../../../helpers/validateMidnightAccount.js");
9
10
  const validateMidnightAuthorizationTarget_js_1 = require("../../../helpers/validateMidnightAuthorizationTarget.js");
10
11
  const validateClientChainId_js_1 = require("../validateClientChainId.js");
11
12
  /**
@@ -24,6 +25,8 @@ const validateClientChainId_js_1 = require("../validateClientChainId.js");
24
25
  * @returns Authorization transaction, or `null` when already authorized.
25
26
  * @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`,
26
27
  * another chain than `params.chainId`.
28
+ * @throws {MidnightCalldataEncodingError} when `owner` or `authorized` is not a well-formed address.
29
+ * @throws {MidnightZeroAccountError} when `owner` is the zero address.
27
30
  * @throws {viem.BaseError} when the `eth_chainId` request or authorization read fails.
28
31
  * @throws {UnsupportedMidnightAuthorizationTargetError} when `authorized` is not MidnightBundlesV2.
29
32
  * @example
@@ -49,6 +52,8 @@ const validateClientChainId_js_1 = require("../validateClientChainId.js");
49
52
  * ```
50
53
  */
51
54
  const getMidnightAuthorizationRequirement = async (params) => {
55
+ // Reject the zero account before reading state for it.
56
+ (0, validateMidnightAccount_js_1.validateMidnightAccount)("owner", params.owner);
52
57
  (0, index_js_1.validateChainId)(params.viemClient.chain?.id, params.chainId);
53
58
  // Reject unknown operators before reading authorization state.
54
59
  (0, validateMidnightAuthorizationTarget_js_1.validateMidnightAuthorizationTarget)({
@@ -31,7 +31,7 @@ export interface VaultV1InKindRedeemParams {
31
31
  * the expected owner of an optional `requirementSignature` permit. VaultExitBundlesV1 burns
32
32
  * `msg.sender`'s vault shares, so the submitting account must equal this address.
33
33
  * @param params.args.deadline - Permit and bundle deadline.
34
- * @param params.args.requirementSignature - Optional bounded Vault V1 shares permit.
34
+ * @param params.args.requirementSignature - Optional unlimited Vault V1 shares permit.
35
35
  * @param params.metadata - Optional analytics metadata.
36
36
  * @returns A deep-frozen `Readonly<Transaction<VaultV1InKindRedeemAction>>` with `to`, `value`,
37
37
  * `data`, and the typed action discriminator.
@@ -23,7 +23,7 @@ const common_js_1 = require("../bundles/common.js");
23
23
  * the expected owner of an optional `requirementSignature` permit. VaultExitBundlesV1 burns
24
24
  * `msg.sender`'s vault shares, so the submitting account must equal this address.
25
25
  * @param params.args.deadline - Permit and bundle deadline.
26
- * @param params.args.requirementSignature - Optional bounded Vault V1 shares permit.
26
+ * @param params.args.requirementSignature - Optional unlimited Vault V1 shares permit.
27
27
  * @param params.metadata - Optional analytics metadata.
28
28
  * @returns A deep-frozen `Readonly<Transaction<VaultV1InKindRedeemAction>>` with `to`, `value`,
29
29
  * `data`, and the typed action discriminator.
@@ -21,8 +21,8 @@ export interface VaultV1WithdrawParams {
21
21
  /**
22
22
  * Encodes an exact-assets Vault V1 withdrawal through VaultBundlesV1.
23
23
  *
24
- * This low-level builder does not bind `permit.value` to a share cap; use
25
- * `MorphoVaultV1.withdraw().buildTx()` to validate it against the share cap derived from the handle's `vaultData`.
24
+ * This low-level builder does not bind `permit.value` to the required share amount; use
25
+ * `MorphoVaultV1.withdraw().buildTx()` to validate it against the minimum derived from the handle's `vaultData`.
26
26
  *
27
27
  * @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
28
28
  * @param params.vault.address - Vault V1 whose shares are burned for the withdrawal.
@@ -31,7 +31,7 @@ export interface VaultV1WithdrawParams {
31
31
  * @param params.args.recipient - Unsupported; net assets are always paid to the transaction sender.
32
32
  * @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
33
33
  * @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
34
- * and the registered VaultBundlesV1 spender. Omit when the exact share allowance is already set.
34
+ * and the registered VaultBundlesV1 spender. Omit when the share allowance meets the required amount.
35
35
  * @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
36
36
  * The fee is rounded down and deducted from the gross withdrawn assets.
37
37
  * @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
@@ -60,7 +60,7 @@ export interface VaultV1WithdrawParams {
60
60
  *
61
61
  * export function buildUsdcWithdrawal(userAddress: Address, deadline: bigint) {
62
62
  * const vault = "0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB";
63
- * // Set the exact vault-share allowance before submitting; the entity API derives that cap.
63
+ * // Satisfy the required vault-share allowance before submitting; the entity API derives it.
64
64
  * const tx = vaultV1Withdraw({
65
65
  * vault: { chainId: mainnet.id, address: vault },
66
66
  * args: { amount: 1_000_000n, userAddress, deadline },
@@ -10,8 +10,8 @@ const common_js_1 = require("../bundles/common.js");
10
10
  /**
11
11
  * Encodes an exact-assets Vault V1 withdrawal through VaultBundlesV1.
12
12
  *
13
- * This low-level builder does not bind `permit.value` to a share cap; use
14
- * `MorphoVaultV1.withdraw().buildTx()` to validate it against the share cap derived from the handle's `vaultData`.
13
+ * This low-level builder does not bind `permit.value` to the required share amount; use
14
+ * `MorphoVaultV1.withdraw().buildTx()` to validate it against the minimum derived from the handle's `vaultData`.
15
15
  *
16
16
  * @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
17
17
  * @param params.vault.address - Vault V1 whose shares are burned for the withdrawal.
@@ -20,7 +20,7 @@ const common_js_1 = require("../bundles/common.js");
20
20
  * @param params.args.recipient - Unsupported; net assets are always paid to the transaction sender.
21
21
  * @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
22
22
  * @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
23
- * and the registered VaultBundlesV1 spender. Omit when the exact share allowance is already set.
23
+ * and the registered VaultBundlesV1 spender. Omit when the share allowance meets the required amount.
24
24
  * @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
25
25
  * The fee is rounded down and deducted from the gross withdrawn assets.
26
26
  * @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
@@ -49,7 +49,7 @@ const common_js_1 = require("../bundles/common.js");
49
49
  *
50
50
  * export function buildUsdcWithdrawal(userAddress: Address, deadline: bigint) {
51
51
  * const vault = "0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB";
52
- * // Set the exact vault-share allowance before submitting; the entity API derives that cap.
52
+ * // Satisfy the required vault-share allowance before submitting; the entity API derives it.
53
53
  * const tx = vaultV1Withdraw({
54
54
  * vault: { chainId: mainnet.id, address: vault },
55
55
  * args: { amount: 1_000_000n, userAddress, deadline },
@@ -50,7 +50,7 @@ export interface VaultV2ForceWithdrawParams {
50
50
  * is outside that bound's protection.
51
51
  * @param params.args.referralFeeRecipient - Optional referral fee recipient. Defaults to the zero
52
52
  * address, which is only valid alongside a zero `referralFeePct`.
53
- * @param params.args.requirementSignature - Optional bounded Vault V2 shares permit.
53
+ * @param params.args.requirementSignature - Optional unlimited Vault V2 shares permit.
54
54
  * @param params.metadata - Optional analytics metadata.
55
55
  * @returns A deep-frozen `Readonly<Transaction<VaultV2ForceWithdrawAction>>` with `to`, `value`,
56
56
  * `data`, and the typed action discriminator.
@@ -40,7 +40,7 @@ const common_js_1 = require("../bundles/common.js");
40
40
  * is outside that bound's protection.
41
41
  * @param params.args.referralFeeRecipient - Optional referral fee recipient. Defaults to the zero
42
42
  * address, which is only valid alongside a zero `referralFeePct`.
43
- * @param params.args.requirementSignature - Optional bounded Vault V2 shares permit.
43
+ * @param params.args.requirementSignature - Optional unlimited Vault V2 shares permit.
44
44
  * @param params.metadata - Optional analytics metadata.
45
45
  * @returns A deep-frozen `Readonly<Transaction<VaultV2ForceWithdrawAction>>` with `to`, `value`,
46
46
  * `data`, and the typed action discriminator.
@@ -34,7 +34,7 @@ export interface VaultV2InKindRedeemParams {
34
34
  * the expected owner of an optional `requirementSignature` permit. VaultExitBundlesV1 burns
35
35
  * `msg.sender`'s vault shares, so the submitting account must equal this address.
36
36
  * @param params.args.deadline - Permit and bundle deadline.
37
- * @param params.args.requirementSignature - Optional bounded Vault V2 shares permit.
37
+ * @param params.args.requirementSignature - Optional unlimited Vault V2 shares permit.
38
38
  * @param params.metadata - Optional analytics metadata.
39
39
  * @returns A deep-frozen `Readonly<Transaction<VaultV2InKindRedeemAction>>` with `to`, `value`,
40
40
  * `data`, and the typed action discriminator.
@@ -25,7 +25,7 @@ const common_js_1 = require("../bundles/common.js");
25
25
  * the expected owner of an optional `requirementSignature` permit. VaultExitBundlesV1 burns
26
26
  * `msg.sender`'s vault shares, so the submitting account must equal this address.
27
27
  * @param params.args.deadline - Permit and bundle deadline.
28
- * @param params.args.requirementSignature - Optional bounded Vault V2 shares permit.
28
+ * @param params.args.requirementSignature - Optional unlimited Vault V2 shares permit.
29
29
  * @param params.metadata - Optional analytics metadata.
30
30
  * @returns A deep-frozen `Readonly<Transaction<VaultV2InKindRedeemAction>>` with `to`, `value`,
31
31
  * `data`, and the typed action discriminator.
@@ -21,8 +21,8 @@ export interface VaultV2WithdrawParams {
21
21
  /**
22
22
  * Encodes an exact-assets Vault V2 withdrawal through VaultBundlesV1.
23
23
  *
24
- * This low-level builder does not bind `permit.value` to a share cap; use
25
- * `MorphoVaultV2.withdraw().buildTx()` to validate it against the share cap derived from the handle's `vaultData`.
24
+ * This low-level builder does not bind `permit.value` to the required share amount; use
25
+ * `MorphoVaultV2.withdraw().buildTx()` to validate it against the minimum derived from the handle's `vaultData`.
26
26
  *
27
27
  * @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
28
28
  * @param params.vault.address - Vault V2 whose shares are burned for the withdrawal.
@@ -31,7 +31,7 @@ export interface VaultV2WithdrawParams {
31
31
  * @param params.args.recipient - Unsupported; net assets are always paid to the transaction sender.
32
32
  * @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
33
33
  * @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
34
- * and the registered VaultBundlesV1 spender. Omit when the exact share allowance is already set.
34
+ * and the registered VaultBundlesV1 spender. Omit when the share allowance meets the required amount.
35
35
  * @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
36
36
  * The fee is rounded down and deducted from the gross withdrawn assets.
37
37
  * @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
@@ -60,7 +60,7 @@ export interface VaultV2WithdrawParams {
60
60
  *
61
61
  * export function buildUsdcWithdrawal(userAddress: Address, deadline: bigint) {
62
62
  * const vault = "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145";
63
- * // Set the exact vault-share allowance before submitting; the entity API derives that cap.
63
+ * // Satisfy the required vault-share allowance before submitting; the entity API derives it.
64
64
  * const tx = vaultV2Withdraw({
65
65
  * vault: { chainId: mainnet.id, address: vault },
66
66
  * args: { amount: 1_000_000n, userAddress, deadline },
@@ -10,8 +10,8 @@ const common_js_1 = require("../bundles/common.js");
10
10
  /**
11
11
  * Encodes an exact-assets Vault V2 withdrawal through VaultBundlesV1.
12
12
  *
13
- * This low-level builder does not bind `permit.value` to a share cap; use
14
- * `MorphoVaultV2.withdraw().buildTx()` to validate it against the share cap derived from the handle's `vaultData`.
13
+ * This low-level builder does not bind `permit.value` to the required share amount; use
14
+ * `MorphoVaultV2.withdraw().buildTx()` to validate it against the minimum derived from the handle's `vaultData`.
15
15
  *
16
16
  * @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
17
17
  * @param params.vault.address - Vault V2 whose shares are burned for the withdrawal.
@@ -20,7 +20,7 @@ const common_js_1 = require("../bundles/common.js");
20
20
  * @param params.args.recipient - Unsupported; net assets are always paid to the transaction sender.
21
21
  * @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
22
22
  * @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
23
- * and the registered VaultBundlesV1 spender. Omit when the exact share allowance is already set.
23
+ * and the registered VaultBundlesV1 spender. Omit when the share allowance meets the required amount.
24
24
  * @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
25
25
  * The fee is rounded down and deducted from the gross withdrawn assets.
26
26
  * @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
@@ -49,7 +49,7 @@ const common_js_1 = require("../bundles/common.js");
49
49
  *
50
50
  * export function buildUsdcWithdrawal(userAddress: Address, deadline: bigint) {
51
51
  * const vault = "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145";
52
- * // Set the exact vault-share allowance before submitting; the entity API derives that cap.
52
+ * // Satisfy the required vault-share allowance before submitting; the entity API derives it.
53
53
  * const tx = vaultV2Withdraw({
54
54
  * vault: { chainId: mainnet.id, address: vault },
55
55
  * args: { amount: 1_000_000n, userAddress, deadline },
@@ -18,11 +18,6 @@ export interface BlueTokenRequirementsParams {
18
18
  readonly useSimplePermit?: boolean;
19
19
  /** Explicit unused Permit2 SignatureTransfer unordered nonce; defaults to the lowest unused nonce. */
20
20
  readonly permit2Nonce?: bigint;
21
- /**
22
- * Classic ERC-20 allowance to set when an approval is needed, enabling a reusable approval (for
23
- * example `maxUint256`). Defaults to the exact pulled amount. Ignored by signature paths.
24
- */
25
- readonly approvalAmount?: bigint;
26
21
  }
27
22
  /** Action surface for Morpho Blue reads and writes; writes route through BlueBundlesV1. */
28
23
  export interface BlueActions {
@@ -169,7 +164,6 @@ export interface BlueActions {
169
164
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
170
165
  * @throws {NoUnusedPermit2NonceError} from `getRequirements()` when every Permit2 nonce for the owner is consumed and none was passed explicitly.
171
166
  * @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
172
- * @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when a classic `approvalAmount` is below the funded `assets`.
173
167
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
174
168
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when the route cannot consume a supplied signature.
175
169
  * @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
@@ -405,8 +399,6 @@ export interface BlueActions {
405
399
  * @throws {RepayExceedsDebtError} when an exact asset repay exceeds current debt.
406
400
  * @throws {RepaySharesExceedDebtError} when non-saturated shares exceed current debt shares.
407
401
  * @throws {InputExceedsMaxError} when a fee is out of bounds or a share quote deadline is too far away.
408
- * @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when a classic
409
- * `approvalAmount` is below the derived `maxRepayAssets`.
410
402
  * @throws {MaxRepayAssetsBelowRepayAssetsError} when a signed share cap no longer covers the fresh quote.
411
403
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
412
404
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
@@ -550,8 +542,8 @@ export interface BlueActions {
550
542
  * saturated full close; the entity derives `maxRepayAssets` from debt projected through the
551
543
  * requested deadline plus the referral fee, and the contract refunds unused funding. A
552
544
  * previously signed share-mode cap remains valid when it still covers the fresh derived minimum.
553
- * Full-repay requirements fund exactly the derived `maxRepayAssets`; pass `approvalAmount` to
554
- * request a reusable allowance instead. The transaction remains bounded by the derived cap.
545
+ * Full-repay requirements use unlimited classic approvals while the transaction remains bounded
546
+ * by the derived `maxRepayAssets` cap.
555
547
  * Share-mode deadlines cannot exceed the two-hour quote horizon. Blue authorization is required
556
548
  * only for collateral withdrawal. Pure repay uses `maxLtv = maxUint256`; withdrawals use buffered
557
549
  * LLTV. No share-price or `slippageTolerance` input exists.
@@ -582,8 +574,6 @@ export interface BlueActions {
582
574
  * @throws {WithdrawMakesPositionUnhealthyError} when the post-repay withdrawal exceeds buffered LLTV.
583
575
  * @throws {ExpiredDeadlineError} when the deadline is stale.
584
576
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD or a share-mode deadline exceeds the funding quote horizon.
585
- * @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when a classic
586
- * `approvalAmount` is below the derived `maxRepayAssets`.
587
577
  * @throws {MaxRepayAssetsBelowRepayAssetsError} from `buildTx()` when a previously signed share-mode cap no longer covers the fresh derived minimum.
588
578
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
589
579
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
@@ -87,7 +87,6 @@ class MorphoBlue {
87
87
  supportDeployless: this.client.options.supportDeployless,
88
88
  useSimplePermit: params.useSimplePermit,
89
89
  permit2Nonce: params.permit2Nonce,
90
- approvalAmount: params.approvalAmount,
91
90
  now: params.now,
92
91
  });
93
92
  }
@@ -147,7 +146,6 @@ class MorphoBlue {
147
146
  now,
148
147
  useSimplePermit: requirementsParams?.useSimplePermit,
149
148
  permit2Nonce: requirementsParams?.permit2Nonce,
150
- approvalAmount: requirementsParams?.approvalAmount,
151
149
  });
152
150
  });
153
151
  },
@@ -485,7 +483,6 @@ class MorphoBlue {
485
483
  ? this.getTokenRequirements({
486
484
  token: this.marketParams.loanToken,
487
485
  amount: maxRepayAssets,
488
- approvalAmount: requirementsParams?.approvalAmount,
489
486
  userAddress,
490
487
  deadline,
491
488
  now,
@@ -597,7 +594,6 @@ class MorphoBlue {
597
594
  ? this.getTokenRequirements({
598
595
  token: this.marketParams.collateralToken,
599
596
  amount: collateralAssets,
600
- approvalAmount: requirementsParams?.approvalAmount,
601
597
  userAddress,
602
598
  deadline,
603
599
  now,