@morpho-org/morpho-sdk 4.2.0 → 5.1.1

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 (191) hide show
  1. package/README.md +16 -16
  2. package/lib/cjs/actions/blue/borrow.d.ts +12 -2
  3. package/lib/cjs/actions/blue/borrow.js +7 -1
  4. package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +47 -0
  5. package/lib/cjs/actions/blue/buildAssetFundingActions.js +63 -0
  6. package/lib/cjs/actions/blue/refinance.d.ts +13 -3
  7. package/lib/cjs/actions/blue/refinance.js +8 -2
  8. package/lib/cjs/actions/blue/repay.d.ts +44 -43
  9. package/lib/cjs/actions/blue/repay.js +70 -59
  10. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +50 -41
  11. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +75 -54
  12. package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +69 -0
  13. package/lib/cjs/actions/blue/resolveRepayFunding.js +82 -0
  14. package/lib/cjs/actions/blue/supply.d.ts +8 -8
  15. package/lib/cjs/actions/blue/supply.js +11 -35
  16. package/lib/cjs/actions/blue/supplyCollateral.d.ts +9 -9
  17. package/lib/cjs/actions/blue/supplyCollateral.js +12 -36
  18. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +19 -7
  19. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +17 -32
  20. package/lib/cjs/actions/blue/withdraw.d.ts +10 -2
  21. package/lib/cjs/actions/blue/withdraw.js +7 -1
  22. package/lib/cjs/actions/index.d.ts +1 -0
  23. package/lib/cjs/actions/index.js +1 -0
  24. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +49 -0
  25. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +111 -0
  26. package/lib/cjs/actions/requirements/blue/index.d.ts +1 -0
  27. package/lib/cjs/actions/requirements/blue/index.js +17 -0
  28. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +55 -0
  29. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +89 -0
  30. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +6 -5
  31. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +17 -5
  32. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +9 -7
  33. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +18 -4
  34. package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2.d.ts → encodeErc20Permit2Approve.d.ts} +11 -13
  35. package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2.js → encodeErc20Permit2Approve.js} +10 -14
  36. package/lib/cjs/actions/requirements/encode/index.d.ts +2 -1
  37. package/lib/cjs/actions/requirements/encode/index.js +2 -1
  38. package/lib/cjs/actions/requirements/{getRequirements.d.ts → generalAdapter/getGeneralAdapterRequirements.d.ts} +34 -20
  39. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +151 -0
  40. package/lib/{esm/actions/requirements/getRequirementsPermit.d.ts → cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts} +6 -14
  41. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +50 -0
  42. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +57 -0
  43. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +74 -0
  44. package/lib/cjs/actions/requirements/generalAdapter/index.d.ts +3 -0
  45. package/lib/cjs/actions/requirements/generalAdapter/index.js +19 -0
  46. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +3 -2
  47. package/lib/cjs/actions/requirements/getRequirementsApproval.js +3 -2
  48. package/lib/cjs/actions/requirements/index.d.ts +2 -5
  49. package/lib/cjs/actions/requirements/index.js +2 -5
  50. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.d.ts +29 -0
  51. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.js +48 -0
  52. package/lib/{esm/actions/requirements/getRequirementsAction.d.ts → cjs/actions/signatures/getTokenRequirementActions.d.ts} +17 -17
  53. package/lib/cjs/actions/{requirements/getRequirementsAction.js → signatures/getTokenRequirementActions.js} +26 -13
  54. package/lib/cjs/actions/signatures/index.d.ts +2 -0
  55. package/lib/cjs/actions/signatures/index.js +18 -0
  56. package/lib/cjs/actions/vaultV1/deposit.d.ts +6 -8
  57. package/lib/cjs/actions/vaultV1/deposit.js +11 -21
  58. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +6 -6
  59. package/lib/cjs/actions/vaultV1/migrateToV2.js +12 -20
  60. package/lib/cjs/actions/vaultV2/deposit.d.ts +6 -8
  61. package/lib/cjs/actions/vaultV2/deposit.js +11 -21
  62. package/lib/cjs/addresses.d.ts +2 -2
  63. package/lib/cjs/addresses.js +2 -1
  64. package/lib/cjs/bundler/actions.d.ts +44 -4
  65. package/lib/cjs/bundler/actions.js +75 -2
  66. package/lib/cjs/bundler/types.d.ts +6 -0
  67. package/lib/cjs/constants.d.ts +2 -2
  68. package/lib/cjs/constants.js +3 -3
  69. package/lib/cjs/entities/blue/blue.d.ts +58 -33
  70. package/lib/cjs/entities/blue/blue.js +309 -189
  71. package/lib/cjs/entities/reallocationData.d.ts +0 -44
  72. package/lib/cjs/entities/reallocationData.js +3 -50
  73. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +9 -9
  74. package/lib/cjs/entities/vaultV1/vaultV1.js +44 -34
  75. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +6 -6
  76. package/lib/cjs/entities/vaultV2/vaultV2.js +21 -16
  77. package/lib/cjs/errors.d.ts +3 -2
  78. package/lib/cjs/errors.js +5 -2
  79. package/lib/cjs/helpers/index.d.ts +1 -1
  80. package/lib/cjs/helpers/index.js +1 -2
  81. package/lib/cjs/helpers/validate.d.ts +2 -20
  82. package/lib/cjs/helpers/validate.js +2 -39
  83. package/lib/cjs/types/action.d.ts +164 -12
  84. package/lib/cjs/types/action.js +79 -5
  85. package/lib/cjs/types/error.d.ts +97 -2
  86. package/lib/cjs/types/error.js +113 -7
  87. package/lib/cjs/types.d.ts +2 -1
  88. package/lib/cjs/utils.d.ts +2 -2
  89. package/lib/cjs/utils.js +2 -4
  90. package/lib/esm/actions/blue/borrow.d.ts +12 -2
  91. package/lib/esm/actions/blue/borrow.js +7 -1
  92. package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +47 -0
  93. package/lib/esm/actions/blue/buildAssetFundingActions.js +59 -0
  94. package/lib/esm/actions/blue/refinance.d.ts +13 -3
  95. package/lib/esm/actions/blue/refinance.js +8 -2
  96. package/lib/esm/actions/blue/repay.d.ts +44 -43
  97. package/lib/esm/actions/blue/repay.js +71 -60
  98. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +50 -41
  99. package/lib/esm/actions/blue/repayWithdrawCollateral.js +76 -55
  100. package/lib/esm/actions/blue/resolveRepayFunding.d.ts +69 -0
  101. package/lib/esm/actions/blue/resolveRepayFunding.js +78 -0
  102. package/lib/esm/actions/blue/supply.d.ts +8 -8
  103. package/lib/esm/actions/blue/supply.js +12 -36
  104. package/lib/esm/actions/blue/supplyCollateral.d.ts +9 -9
  105. package/lib/esm/actions/blue/supplyCollateral.js +13 -37
  106. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +19 -7
  107. package/lib/esm/actions/blue/supplyCollateralBorrow.js +18 -33
  108. package/lib/esm/actions/blue/withdraw.d.ts +10 -2
  109. package/lib/esm/actions/blue/withdraw.js +7 -1
  110. package/lib/esm/actions/index.d.ts +1 -0
  111. package/lib/esm/actions/index.js +1 -0
  112. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +49 -0
  113. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +107 -0
  114. package/lib/esm/actions/requirements/blue/index.d.ts +1 -0
  115. package/lib/esm/actions/requirements/blue/index.js +1 -0
  116. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +55 -0
  117. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +85 -0
  118. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +6 -5
  119. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +19 -7
  120. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +9 -7
  121. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +20 -6
  122. package/lib/esm/actions/requirements/encode/{encodeErc20Permit2.d.ts → encodeErc20Permit2Approve.d.ts} +11 -13
  123. package/lib/esm/actions/requirements/encode/{encodeErc20Permit2.js → encodeErc20Permit2Approve.js} +8 -12
  124. package/lib/esm/actions/requirements/encode/index.d.ts +2 -1
  125. package/lib/esm/actions/requirements/encode/index.js +2 -1
  126. package/lib/esm/actions/requirements/{getRequirements.d.ts → generalAdapter/getGeneralAdapterRequirements.d.ts} +34 -20
  127. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +147 -0
  128. package/lib/{cjs/actions/requirements/getRequirementsPermit.d.ts → esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts} +6 -14
  129. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +46 -0
  130. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +57 -0
  131. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +70 -0
  132. package/lib/esm/actions/requirements/generalAdapter/index.d.ts +3 -0
  133. package/lib/esm/actions/requirements/generalAdapter/index.js +3 -0
  134. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +3 -2
  135. package/lib/esm/actions/requirements/getRequirementsApproval.js +3 -2
  136. package/lib/esm/actions/requirements/index.d.ts +2 -5
  137. package/lib/esm/actions/requirements/index.js +2 -5
  138. package/lib/esm/actions/signatures/getBlueAuthorizationAction.d.ts +29 -0
  139. package/lib/esm/actions/signatures/getBlueAuthorizationAction.js +44 -0
  140. package/lib/{cjs/actions/requirements/getRequirementsAction.d.ts → esm/actions/signatures/getTokenRequirementActions.d.ts} +17 -17
  141. package/lib/esm/actions/{requirements/getRequirementsAction.js → signatures/getTokenRequirementActions.js} +24 -11
  142. package/lib/esm/actions/signatures/index.d.ts +2 -0
  143. package/lib/esm/actions/signatures/index.js +2 -0
  144. package/lib/esm/actions/vaultV1/deposit.d.ts +6 -8
  145. package/lib/esm/actions/vaultV1/deposit.js +11 -21
  146. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +6 -6
  147. package/lib/esm/actions/vaultV1/migrateToV2.js +12 -20
  148. package/lib/esm/actions/vaultV2/deposit.d.ts +6 -8
  149. package/lib/esm/actions/vaultV2/deposit.js +11 -21
  150. package/lib/esm/addresses.d.ts +2 -2
  151. package/lib/esm/addresses.js +1 -1
  152. package/lib/esm/bundler/actions.d.ts +44 -4
  153. package/lib/esm/bundler/actions.js +77 -4
  154. package/lib/esm/bundler/types.d.ts +6 -0
  155. package/lib/esm/constants.d.ts +2 -2
  156. package/lib/esm/constants.js +2 -2
  157. package/lib/esm/entities/blue/blue.d.ts +58 -33
  158. package/lib/esm/entities/blue/blue.js +311 -191
  159. package/lib/esm/entities/reallocationData.d.ts +0 -44
  160. package/lib/esm/entities/reallocationData.js +2 -49
  161. package/lib/esm/entities/vaultV1/vaultV1.d.ts +9 -9
  162. package/lib/esm/entities/vaultV1/vaultV1.js +46 -36
  163. package/lib/esm/entities/vaultV2/vaultV2.d.ts +6 -6
  164. package/lib/esm/entities/vaultV2/vaultV2.js +23 -18
  165. package/lib/esm/errors.d.ts +3 -2
  166. package/lib/esm/errors.js +2 -1
  167. package/lib/esm/helpers/index.d.ts +1 -1
  168. package/lib/esm/helpers/index.js +1 -1
  169. package/lib/esm/helpers/validate.d.ts +2 -20
  170. package/lib/esm/helpers/validate.js +2 -38
  171. package/lib/esm/types/action.d.ts +164 -12
  172. package/lib/esm/types/action.js +75 -4
  173. package/lib/esm/types/error.d.ts +97 -2
  174. package/lib/esm/types/error.js +107 -5
  175. package/lib/esm/types.d.ts +2 -1
  176. package/lib/esm/utils.d.ts +2 -2
  177. package/lib/esm/utils.js +2 -2
  178. package/package.json +22 -21
  179. package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.d.ts +0 -37
  180. package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.js +0 -71
  181. package/lib/cjs/actions/requirements/getRequirements.js +0 -112
  182. package/lib/cjs/actions/requirements/getRequirementsPermit.js +0 -57
  183. package/lib/cjs/actions/requirements/getRequirementsPermit2.d.ts +0 -63
  184. package/lib/cjs/actions/requirements/getRequirementsPermit2.js +0 -85
  185. package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.d.ts +0 -37
  186. package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.js +0 -67
  187. package/lib/esm/actions/requirements/getRequirements.js +0 -108
  188. package/lib/esm/actions/requirements/getRequirementsPermit.js +0 -53
  189. package/lib/esm/actions/requirements/getRequirementsPermit2.d.ts +0 -63
  190. package/lib/esm/actions/requirements/getRequirementsPermit2.js +0 -81
  191. package/src/index.ts +0 -4
@@ -253,50 +253,6 @@ export declare class ReallocationData implements InputReallocationData {
253
253
  * ```
254
254
  */
255
255
  getAvailableLiquidityToUtilization(marketId: MarketId, utilization?: bigint, options?: ReallocationComputeOptions): bigint;
256
- /**
257
- * Computes the liquidity available to bring `marketId` to `utilization`,
258
- * counting the public-allocator liquidity reallocatable into it.
259
- *
260
- * @deprecated Renamed to {@link getAvailableLiquidityToUtilization} — the
261
- * `target` wording wrongly implied a market's configured supply-target
262
- * utilization, whereas the argument is an arbitrary utilization ceiling.
263
- * Delegates to the new method; will be removed in the next major.
264
- *
265
- * @param marketId - Target market to borrow from.
266
- * @param targetUtilization - Utilization to bring the market to, scaled by WAD. Defaults to {@link DEFAULT_SUPPLY_TARGET_UTILIZATION}.
267
- * @param options - Optional reallocation options (supply target utilization trigger, timestamp, withdrawal caps).
268
- * @returns Available liquidity to the given utilization in loan-token units; `0n` when none is available.
269
- * @throws {@link UnknownReallocationMarketError} when the target market is absent.
270
- * @example
271
- * ```ts
272
- * import { createPublicClient, http, parseEther } from "viem";
273
- * import { mainnet } from "viem/chains";
274
- * import { markets, vaults } from "@morpho-org/morpho-test";
275
- * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
276
- *
277
- * const client = createPublicClient({
278
- * chain: mainnet,
279
- * transport: http(),
280
- * }).extend(morphoViemExtension());
281
- *
282
- * const marketParams = markets[mainnet.id].usdc_wbtc;
283
- * const market = client.morpho.blue(marketParams, mainnet.id);
284
- * const block = await client.getBlock();
285
- * const reallocationData = await market.getReallocationData({
286
- * vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
287
- * block: { number: block.number, timestamp: block.timestamp },
288
- * });
289
- *
290
- * // Deprecated: prefer reallocationData.getAvailableLiquidityToUtilization.
291
- * const available: bigint =
292
- * reallocationData.getAvailableLiquidityToTargetUtilization(
293
- * marketParams.id,
294
- * parseEther("0.9"),
295
- * { timestamp: block.timestamp },
296
- * );
297
- * ```
298
- */
299
- getAvailableLiquidityToTargetUtilization(marketId: MarketId, targetUtilization?: bigint, options?: ReallocationComputeOptions): bigint;
300
256
  /**
301
257
  * Gets the largest currently valid source-market withdrawal for a vault.
302
258
  *
@@ -1,5 +1,5 @@
1
- import { _try, AccrualPosition, Market, MarketUtils, MathLib, Position, UnknownDataError, Vault, VaultMarketConfig, VaultMarketPublicAllocatorConfig, } from "@morpho-org/blue-sdk";
2
- import { bigIntComparator } from "@morpho-org/morpho-ts";
1
+ import { AccrualPosition, Market, MarketUtils, MathLib, Position, UnknownDataError, Vault, VaultMarketConfig, VaultMarketPublicAllocatorConfig, } from "@morpho-org/blue-sdk";
2
+ import { _try, bigIntComparator } from "@morpho-org/morpho-ts";
3
3
  import { DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, } from "../helpers/constant.js";
4
4
  import { getSupplyTargetUtilization } from "../helpers/utilization.js";
5
5
  import { DisabledReallocationMarketError, MissingPublicAllocatorConfigError, UnknownReallocationMarketError, UnknownReallocationPositionError, UnknownReallocationVaultError, UnknownReallocationVaultMarketConfigError, } from "../types/index.js";
@@ -411,53 +411,6 @@ export class ReallocationData {
411
411
  totalBorrowAssets: market.totalBorrowAssets,
412
412
  }, utilization);
413
413
  }
414
- /**
415
- * Computes the liquidity available to bring `marketId` to `utilization`,
416
- * counting the public-allocator liquidity reallocatable into it.
417
- *
418
- * @deprecated Renamed to {@link getAvailableLiquidityToUtilization} — the
419
- * `target` wording wrongly implied a market's configured supply-target
420
- * utilization, whereas the argument is an arbitrary utilization ceiling.
421
- * Delegates to the new method; will be removed in the next major.
422
- *
423
- * @param marketId - Target market to borrow from.
424
- * @param targetUtilization - Utilization to bring the market to, scaled by WAD. Defaults to {@link DEFAULT_SUPPLY_TARGET_UTILIZATION}.
425
- * @param options - Optional reallocation options (supply target utilization trigger, timestamp, withdrawal caps).
426
- * @returns Available liquidity to the given utilization in loan-token units; `0n` when none is available.
427
- * @throws {@link UnknownReallocationMarketError} when the target market is absent.
428
- * @example
429
- * ```ts
430
- * import { createPublicClient, http, parseEther } from "viem";
431
- * import { mainnet } from "viem/chains";
432
- * import { markets, vaults } from "@morpho-org/morpho-test";
433
- * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
434
- *
435
- * const client = createPublicClient({
436
- * chain: mainnet,
437
- * transport: http(),
438
- * }).extend(morphoViemExtension());
439
- *
440
- * const marketParams = markets[mainnet.id].usdc_wbtc;
441
- * const market = client.morpho.blue(marketParams, mainnet.id);
442
- * const block = await client.getBlock();
443
- * const reallocationData = await market.getReallocationData({
444
- * vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
445
- * block: { number: block.number, timestamp: block.timestamp },
446
- * });
447
- *
448
- * // Deprecated: prefer reallocationData.getAvailableLiquidityToUtilization.
449
- * const available: bigint =
450
- * reallocationData.getAvailableLiquidityToTargetUtilization(
451
- * marketParams.id,
452
- * parseEther("0.9"),
453
- * { timestamp: block.timestamp },
454
- * );
455
- * ```
456
- */
457
- // biome-ignore lint/complexity/useMaxParams: (marketId, targetUtilization, options) is the metric's public API
458
- getAvailableLiquidityToTargetUtilization(marketId, targetUtilization = DEFAULT_SUPPLY_TARGET_UTILIZATION, options) {
459
- return this.getAvailableLiquidityToUtilization(marketId, targetUtilization, options);
460
- }
461
414
  /**
462
415
  * Gets the largest currently valid source-market withdrawal for a vault.
463
416
  *
@@ -2,7 +2,7 @@ import { type AccrualVault, type AccrualVaultV2 } from "@morpho-org/blue-sdk";
2
2
  import { fetchAccrualVault } from "@morpho-org/blue-sdk-viem";
3
3
  import { type Address } from "viem";
4
4
  import type { FetchParameters } from "../../types/data.js";
5
- import { type DepositAmountArgs, type ERC20ApprovalAction, type MorphoClientType, type Requirement, type RequirementSignature, type Transaction, type VaultV1DepositAction, type VaultV1MigrateToV2Action, type VaultV1RedeemAction, type VaultV1WithdrawAction } from "../../types/index.js";
5
+ import { type DepositAmountArgs, type ERC20ApprovalAction, type MorphoClientType, type PermitRequirementSignature, type Requirement, type RequirementSignature, type Transaction, type VaultV1DepositAction, type VaultV1MigrateToV2Action, type VaultV1RedeemAction, type VaultV1WithdrawAction } from "../../types/index.js";
6
6
  export interface VaultV1Actions {
7
7
  /**
8
8
  * Fetches the latest vault data with accrued interest.
@@ -30,10 +30,10 @@ export interface VaultV1Actions {
30
30
  vaultData: AccrualVault;
31
31
  slippageTolerance?: bigint;
32
32
  } & DepositAmountArgs) => {
33
- buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<VaultV1DepositAction>>;
33
+ buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<VaultV1DepositAction>>;
34
34
  getRequirements: (params?: {
35
35
  useSimplePermit?: boolean;
36
- }) => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement)[]>;
36
+ }) => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement<PermitRequirementSignature>)[]>;
37
37
  };
38
38
  /**
39
39
  * Prepares a withdraw from a VaultV1 (MetaMorpho) contract.
@@ -84,8 +84,8 @@ export interface VaultV1Actions {
84
84
  shares: bigint;
85
85
  slippageTolerance?: bigint;
86
86
  }) => {
87
- buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<VaultV1MigrateToV2Action>>;
88
- getRequirements: () => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement)[]>;
87
+ buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<VaultV1MigrateToV2Action>>;
88
+ getRequirements: () => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement<PermitRequirementSignature>)[]>;
89
89
  };
90
90
  }
91
91
  export declare class MorphoVaultV1 implements VaultV1Actions {
@@ -101,8 +101,8 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
101
101
  } & DepositAmountArgs): {
102
102
  getRequirements: (params?: {
103
103
  useSimplePermit?: boolean;
104
- }) => Promise<(Requirement | Readonly<Transaction<ERC20ApprovalAction>>)[]>;
105
- buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<VaultV1DepositAction>>;
104
+ }) => Promise<(import("../../types/action.js").Bundler3TokenSignatureRequirement | Readonly<Transaction<ERC20ApprovalAction>>)[]>;
105
+ buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<VaultV1DepositAction>>;
106
106
  };
107
107
  withdraw({ amount, userAddress }: {
108
108
  amount: bigint;
@@ -123,7 +123,7 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
123
123
  shares: bigint;
124
124
  slippageTolerance?: bigint;
125
125
  }): {
126
- getRequirements: () => Promise<(Requirement | Readonly<Transaction<ERC20ApprovalAction>>)[]>;
127
- buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<VaultV1MigrateToV2Action>>;
126
+ getRequirements: () => Promise<(import("../../types/action.js").Bundler3TokenSignatureRequirement | Readonly<Transaction<ERC20ApprovalAction>>)[]>;
127
+ buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<VaultV1MigrateToV2Action>>;
128
128
  };
129
129
  }
@@ -2,10 +2,10 @@ import { DEFAULT_SLIPPAGE_TOLERANCE, getChainAddresses, MathLib, } from "@morpho
2
2
  import { fetchAccrualVault } from "@morpho-org/blue-sdk-viem";
3
3
  import { Time } from "@morpho-org/morpho-ts";
4
4
  import { isAddressEqual } from "viem";
5
- import { getRequirements, vaultV1Deposit, vaultV1MigrateToV2, vaultV1Redeem, vaultV1Withdraw, } from "../../actions/index.js";
5
+ import { getGeneralAdapterRequirements, vaultV1Deposit, vaultV1MigrateToV2, vaultV1Redeem, vaultV1Withdraw, } from "../../actions/index.js";
6
6
  import { MAX_ABSOLUTE_SHARE_PRICE, MAX_SLIPPAGE_TOLERANCE, } from "../../helpers/constant.js";
7
7
  import { validateChainId } from "../../helpers/index.js";
8
- import { ChainIdMismatchError, ChainWNativeMissingError, ExcessiveSlippageToleranceError, NativeAmountOnNonWNativeVaultError, NegativeNativeAmountError, NegativeSlippageToleranceError, NonPositiveAssetAmountError, NonPositiveSharesAmountError, VaultAddressMismatchError, VaultAssetMismatchError, } from "../../types/index.js";
8
+ import { ChainIdMismatchError, ChainWNativeMissingError, ExcessiveSlippageToleranceError, NativeAmountOnNonWNativeVaultError, NegativeNativeAmountError, NegativeSlippageToleranceError, NonPositiveAssetAmountError, NonPositiveSharesAmountError, selectRequirementSignatures, VaultAddressMismatchError, VaultAssetMismatchError, } from "../../types/index.js";
9
9
  export class MorphoVaultV1 {
10
10
  client;
11
11
  vault;
@@ -65,7 +65,7 @@ export class MorphoVaultV1 {
65
65
  }
66
66
  const maxSharePrice = MathLib.min(MathLib.mulDivUp(totalAssets, MathLib.wToRay(MathLib.WAD + slippageTolerance), shares), MAX_ABSOLUTE_SHARE_PRICE);
67
67
  return {
68
- getRequirements: async (params) => await getRequirements(this.client.viemClient, {
68
+ getRequirements: (params) => getGeneralAdapterRequirements(this.client.viemClient, {
69
69
  address: vaultData.asset,
70
70
  chainId: this.chainId,
71
71
  supportSignature: this.client.options.supportSignature,
@@ -76,21 +76,26 @@ export class MorphoVaultV1 {
76
76
  from: userAddress,
77
77
  },
78
78
  }),
79
- buildTx: (requirementSignature) => vaultV1Deposit({
80
- vault: {
81
- chainId: this.chainId,
82
- address: this.vault,
83
- asset: vaultData.asset,
84
- },
85
- args: {
86
- amount,
87
- maxSharePrice,
88
- recipient: userAddress,
89
- requirementSignature,
90
- nativeAmount,
91
- },
92
- metadata: this.client.options.metadata,
93
- }),
79
+ buildTx: (signatures) => {
80
+ const { permit } = selectRequirementSignatures(signatures, {
81
+ permit: true,
82
+ });
83
+ return vaultV1Deposit({
84
+ vault: {
85
+ chainId: this.chainId,
86
+ address: this.vault,
87
+ asset: vaultData.asset,
88
+ },
89
+ args: {
90
+ amount,
91
+ maxSharePrice,
92
+ recipient: userAddress,
93
+ requirementSignature: permit,
94
+ nativeAmount,
95
+ },
96
+ metadata: this.client.options.metadata,
97
+ });
98
+ },
94
99
  };
95
100
  }
96
101
  withdraw({ amount, userAddress }) {
@@ -155,7 +160,7 @@ export class MorphoVaultV1 {
155
160
  }
156
161
  const maxSharePriceVaultV2 = MathLib.min(MathLib.mulDivUp(v1RefAssets, MathLib.wToRay(MathLib.WAD + slippageTolerance), v2RefShares), MAX_ABSOLUTE_SHARE_PRICE);
157
162
  return {
158
- getRequirements: async () => await getRequirements(this.client.viemClient, {
163
+ getRequirements: () => getGeneralAdapterRequirements(this.client.viemClient, {
159
164
  address: this.vault,
160
165
  chainId: this.chainId,
161
166
  supportSignature: this.client.options.supportSignature,
@@ -167,23 +172,28 @@ export class MorphoVaultV1 {
167
172
  from: userAddress,
168
173
  },
169
174
  }),
170
- buildTx: (requirementSignature) => vaultV1MigrateToV2({
171
- vault: {
172
- chainId: this.chainId,
173
- address: this.vault,
174
- asset: sourceVault.asset,
175
- },
176
- args: {
177
- targetVault: targetVault.address,
178
- targetAsset: targetVault.asset,
179
- shares,
180
- minSharePriceVaultV1,
181
- maxSharePriceVaultV2,
182
- recipient: userAddress,
183
- requirementSignature,
184
- },
185
- metadata: this.client.options.metadata,
186
- }),
175
+ buildTx: (signatures) => {
176
+ const { permit } = selectRequirementSignatures(signatures, {
177
+ permit: true,
178
+ });
179
+ return vaultV1MigrateToV2({
180
+ vault: {
181
+ chainId: this.chainId,
182
+ address: this.vault,
183
+ asset: sourceVault.asset,
184
+ },
185
+ args: {
186
+ targetVault: targetVault.address,
187
+ targetAsset: targetVault.asset,
188
+ shares,
189
+ minSharePriceVaultV1,
190
+ maxSharePriceVaultV2,
191
+ recipient: userAddress,
192
+ requirementSignature: permit,
193
+ },
194
+ metadata: this.client.options.metadata,
195
+ });
196
+ },
187
197
  };
188
198
  }
189
199
  }
@@ -2,7 +2,7 @@ import { type AccrualVaultV2 } from "@morpho-org/blue-sdk";
2
2
  import { fetchAccrualVaultV2 } from "@morpho-org/blue-sdk-viem";
3
3
  import { type Address } from "viem";
4
4
  import type { FetchParameters } from "../../types/data.js";
5
- import { type Deallocation, type DepositAmountArgs, type ERC20ApprovalAction, type MorphoClientType, type Requirement, type RequirementSignature, type Transaction, type VaultV2DepositAction, type VaultV2ForceRedeemAction, type VaultV2ForceWithdrawAction, type VaultV2RedeemAction, type VaultV2WithdrawAction } from "../../types/index.js";
5
+ import { type Deallocation, type DepositAmountArgs, type ERC20ApprovalAction, type MorphoClientType, type PermitRequirementSignature, type Requirement, type RequirementSignature, type Transaction, type VaultV2DepositAction, type VaultV2ForceRedeemAction, type VaultV2ForceWithdrawAction, type VaultV2RedeemAction, type VaultV2WithdrawAction } from "../../types/index.js";
6
6
  export interface VaultV2Actions {
7
7
  /**
8
8
  * Fetches the latest vault data.
@@ -29,17 +29,17 @@ export interface VaultV2Actions {
29
29
  * @param {bigint} [params.nativeAmount] - Amount of native token to wrap into wNative. Vault asset must be wNative.
30
30
  * @returns {Object} The result object.
31
31
  * @returns {Readonly<Transaction<VaultV2DepositAction>>} returns.tx The prepared deposit transaction.
32
- * @returns {Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement)[]>} returns.getRequirements The function for retrieving all required approval transactions.
32
+ * @returns {Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement<PermitRequirementSignature>)[]>} returns.getRequirements The function for retrieving all required approval transactions.
33
33
  */
34
34
  deposit: (params: {
35
35
  userAddress: Address;
36
36
  vaultData: AccrualVaultV2;
37
37
  slippageTolerance?: bigint;
38
38
  } & DepositAmountArgs) => {
39
- buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<VaultV2DepositAction>>;
39
+ buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<VaultV2DepositAction>>;
40
40
  getRequirements: (params?: {
41
41
  useSimplePermit?: boolean;
42
- }) => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement)[]>;
42
+ }) => Promise<(Readonly<Transaction<ERC20ApprovalAction>> | Requirement<PermitRequirementSignature>)[]>;
43
43
  };
44
44
  /**
45
45
  * Prepares a withdraw transaction for the VaultV2 contract.
@@ -144,8 +144,8 @@ export declare class MorphoVaultV2 implements VaultV2Actions {
144
144
  } & DepositAmountArgs): {
145
145
  getRequirements: (params?: {
146
146
  useSimplePermit?: boolean;
147
- }) => Promise<(Requirement | Readonly<Transaction<ERC20ApprovalAction>>)[]>;
148
- buildTx: (requirementSignature?: RequirementSignature) => Readonly<Transaction<VaultV2DepositAction>>;
147
+ }) => Promise<(import("../../types/action.js").Bundler3TokenSignatureRequirement | Readonly<Transaction<ERC20ApprovalAction>>)[]>;
148
+ buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<Transaction<VaultV2DepositAction>>;
149
149
  };
150
150
  withdraw({ amount, userAddress }: {
151
151
  amount: bigint;
@@ -2,9 +2,9 @@ import { DEFAULT_SLIPPAGE_TOLERANCE, getChainAddresses, MathLib, } from "@morpho
2
2
  import { fetchAccrualVaultV2 } from "@morpho-org/blue-sdk-viem";
3
3
  import { Time } from "@morpho-org/morpho-ts";
4
4
  import { isAddressEqual } from "viem";
5
- import { getRequirements, vaultV2Deposit, vaultV2ForceRedeem, vaultV2ForceWithdraw, vaultV2Redeem, vaultV2Withdraw, } from "../../actions/index.js";
5
+ import { getGeneralAdapterRequirements, vaultV2Deposit, vaultV2ForceRedeem, vaultV2ForceWithdraw, vaultV2Redeem, vaultV2Withdraw, } from "../../actions/index.js";
6
6
  import { MAX_SLIPPAGE_TOLERANCE } from "../../helpers/constant.js";
7
- import { ChainIdMismatchError, ChainWNativeMissingError, ExcessiveSlippageToleranceError, NativeAmountOnNonWNativeVaultError, NegativeNativeAmountError, NegativeSlippageToleranceError, NonPositiveAssetAmountError, NonPositiveSharesAmountError, VaultAddressMismatchError, } from "../../types/index.js";
7
+ import { ChainIdMismatchError, ChainWNativeMissingError, ExcessiveSlippageToleranceError, NativeAmountOnNonWNativeVaultError, NegativeNativeAmountError, NegativeSlippageToleranceError, NonPositiveAssetAmountError, NonPositiveSharesAmountError, selectRequirementSignatures, VaultAddressMismatchError, } from "../../types/index.js";
8
8
  export class MorphoVaultV2 {
9
9
  client;
10
10
  vault;
@@ -68,7 +68,7 @@ export class MorphoVaultV2 {
68
68
  }
69
69
  const maxSharePrice = MathLib.min(MathLib.mulDivUp(totalAssets, MathLib.wToRay(MathLib.WAD + slippageTolerance), shares), MathLib.RAY * 100n);
70
70
  return {
71
- getRequirements: async (params) => await getRequirements(this.client.viemClient, {
71
+ getRequirements: (params) => getGeneralAdapterRequirements(this.client.viemClient, {
72
72
  address: vaultData.asset,
73
73
  chainId: this.chainId,
74
74
  supportSignature: this.client.options.supportSignature,
@@ -79,21 +79,26 @@ export class MorphoVaultV2 {
79
79
  from: userAddress,
80
80
  },
81
81
  }),
82
- buildTx: (requirementSignature) => vaultV2Deposit({
83
- vault: {
84
- chainId: this.chainId,
85
- address: this.vault,
86
- asset: vaultData.asset,
87
- },
88
- args: {
89
- amount,
90
- maxSharePrice,
91
- recipient: userAddress,
92
- requirementSignature,
93
- nativeAmount,
94
- },
95
- metadata: this.client.options.metadata,
96
- }),
82
+ buildTx: (signatures) => {
83
+ const { permit } = selectRequirementSignatures(signatures, {
84
+ permit: true,
85
+ });
86
+ return vaultV2Deposit({
87
+ vault: {
88
+ chainId: this.chainId,
89
+ address: this.vault,
90
+ asset: vaultData.asset,
91
+ },
92
+ args: {
93
+ amount,
94
+ maxSharePrice,
95
+ recipient: userAddress,
96
+ requirementSignature: permit,
97
+ nativeAmount,
98
+ },
99
+ metadata: this.client.options.metadata,
100
+ });
101
+ },
97
102
  };
98
103
  }
99
104
  withdraw({ amount, userAddress }) {
@@ -1,2 +1,3 @@
1
- export type { ErrorClass } from "@morpho-org/blue-sdk";
2
- export { _try, BlueErrors, InvalidMarketParamsError, UnknownDataError, UnknownFactory, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
1
+ export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
2
+ export type { ErrorClass } from "@morpho-org/morpho-ts";
3
+ export { _try } from "@morpho-org/morpho-ts";
package/lib/esm/errors.js CHANGED
@@ -1 +1,2 @@
1
- export { _try, BlueErrors, InvalidMarketParamsError, UnknownDataError, UnknownFactory, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
1
+ export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
2
+ export { _try } from "@morpho-org/morpho-ts";
@@ -2,4 +2,4 @@ export { computeReallocations } from "./computeReallocations.js";
2
2
  export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./constant.js";
3
3
  export { addTransactionMetadata } from "./metadata.js";
4
4
  export { computeMaxRepaySharePrice, computeMaxSupplySharePrice, computeMinBorrowSharePrice, computeMinWithdrawSharePrice, } from "./slippage.js";
5
- export { validateAccrualPosition, validateChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateReallocations, validateRepayAmount, validateRepayParams, validateRepayShares, validateSlippageTolerance, validateUserAddress, validateWithdrawAmount, validateWithdrawShares, } from "./validate.js";
5
+ export { validateAccrualPosition, validateChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateReallocations, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, validateWithdrawAmount, validateWithdrawShares, } from "./validate.js";
@@ -2,4 +2,4 @@ export { computeReallocations } from "./computeReallocations.js";
2
2
  export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./constant.js";
3
3
  export { addTransactionMetadata } from "./metadata.js";
4
4
  export { computeMaxRepaySharePrice, computeMaxSupplySharePrice, computeMinBorrowSharePrice, computeMinWithdrawSharePrice, } from "./slippage.js";
5
- export { validateAccrualPosition, validateChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateReallocations, validateRepayAmount, validateRepayParams, validateRepayShares, validateSlippageTolerance, validateUserAddress, validateWithdrawAmount, validateWithdrawShares, } from "./validate.js";
5
+ export { validateAccrualPosition, validateChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateReallocations, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, validateWithdrawAmount, validateWithdrawShares, } from "./validate.js";
@@ -2,13 +2,13 @@ import { type AccrualPosition, type MarketId } from "@morpho-org/blue-sdk";
2
2
  import { type Address } from "viem";
3
3
  import { type VaultReallocation } from "../types/index.js";
4
4
  /** @internal */
5
- export declare const compareMarketIds: (idA: MarketId, idB: MarketId) => 0 | 1 | -1;
5
+ export declare const compareMarketIds: (idA: MarketId, idB: MarketId) => 1 | 0 | -1;
6
6
  /**
7
7
  * Asserts that the client has a connected account AND that it matches
8
8
  * the provided user address.
9
9
  *
10
10
  * Used internally by the signature requirements (`encodeErc20Permit`,
11
- * `encodeErc20Permit2`) to enforce builder = signer at `sign()` time:
11
+ * `encodeErc20Permit2Approve`) to enforce builder = signer at `sign()` time:
12
12
  * the signing flow is the only path where an account/address mismatch
13
13
  * is a real security concern (rather than just an integrator footgun).
14
14
  *
@@ -121,24 +121,6 @@ export declare const validateRepayShares: (params: {
121
121
  repayShares: bigint;
122
122
  marketId: MarketId;
123
123
  }) => void;
124
- /**
125
- * Validates the common repay input parameters shared by `blueRepay`
126
- * and `blueRepayWithdrawCollateral`.
127
- *
128
- * @param params - Validation parameters.
129
- * @param params.assets - Repay assets amount (0n when repaying by shares).
130
- * @param params.shares - Repay shares amount (0n when repaying by assets).
131
- * @param params.transferAmount - ERC20 amount to transfer to GeneralAdapter1.
132
- * @param params.maxSharePrice - Maximum repay share price (in ray). Must be positive.
133
- * @param params.marketId - The market identifier (for error messages).
134
- */
135
- export declare const validateRepayParams: (params: {
136
- assets: bigint;
137
- shares: bigint;
138
- transferAmount: bigint;
139
- maxSharePrice: bigint;
140
- marketId: MarketId;
141
- }) => void;
142
124
  /**
143
125
  * Validates that vault reallocations are well-formed.
144
126
  *
@@ -1,7 +1,7 @@
1
1
  import { getChainAddresses, MathLib, ORACLE_PRICE_SCALE, } from "@morpho-org/blue-sdk";
2
2
  import { isDefined } from "@morpho-org/morpho-ts";
3
3
  import { isAddressEqual } from "viem";
4
- import { AccrualPositionUserMismatchError, AddressMismatchError, BorrowExceedsSafeLtvError, ChainIdMismatchError, ChainWNativeMissingError, EmptyReallocationWithdrawalsError, ExcessiveSlippageToleranceError, MarketIdMismatchError, MissingClientPropertyError, MissingMarketPriceError, MutuallyExclusiveRepayAmountsError, NativeAmountOnNonWNativeAssetError, NegativeReallocationFeeError, NegativeSlippageToleranceError, NonPositiveReallocationAmountError, NonPositiveRepayAmountError, NonPositiveRepayMaxSharePriceError, NonPositiveTransferAmountError, ReallocationWithdrawalOnTargetMarketError, RepayExceedsDebtError, RepaySharesExceedDebtError, TransferAmountNotEqualToAssetsError, UnsortedReallocationWithdrawalsError, WithdrawExceedsCollateralError, WithdrawExceedsSupplyError, WithdrawMakesPositionUnhealthyError, WithdrawSharesExceedSupplyError, } from "../types/index.js";
4
+ import { AccrualPositionUserMismatchError, AddressMismatchError, BorrowExceedsSafeLtvError, ChainIdMismatchError, ChainWNativeMissingError, EmptyReallocationWithdrawalsError, ExcessiveSlippageToleranceError, MarketIdMismatchError, MissingClientPropertyError, MissingMarketPriceError, NativeAmountOnNonWNativeAssetError, NegativeReallocationFeeError, NegativeSlippageToleranceError, NonPositiveReallocationAmountError, ReallocationWithdrawalOnTargetMarketError, RepayExceedsDebtError, RepaySharesExceedDebtError, UnsortedReallocationWithdrawalsError, WithdrawExceedsCollateralError, WithdrawExceedsSupplyError, WithdrawMakesPositionUnhealthyError, WithdrawSharesExceedSupplyError, } from "../types/index.js";
5
5
  import { DEFAULT_LLTV_BUFFER, MAX_SLIPPAGE_TOLERANCE } from "./constant.js";
6
6
  /** @internal */
7
7
  export const compareMarketIds = (idA, idB) => {
@@ -18,7 +18,7 @@ export const compareMarketIds = (idA, idB) => {
18
18
  * the provided user address.
19
19
  *
20
20
  * Used internally by the signature requirements (`encodeErc20Permit`,
21
- * `encodeErc20Permit2`) to enforce builder = signer at `sign()` time:
21
+ * `encodeErc20Permit2Approve`) to enforce builder = signer at `sign()` time:
22
22
  * the signing flow is the only path where an account/address mismatch
23
23
  * is a real security concern (rather than just an integrator footgun).
24
24
  *
@@ -199,42 +199,6 @@ export const validateRepayShares = (params) => {
199
199
  });
200
200
  }
201
201
  };
202
- /**
203
- * Validates the common repay input parameters shared by `blueRepay`
204
- * and `blueRepayWithdrawCollateral`.
205
- *
206
- * @param params - Validation parameters.
207
- * @param params.assets - Repay assets amount (0n when repaying by shares).
208
- * @param params.shares - Repay shares amount (0n when repaying by assets).
209
- * @param params.transferAmount - ERC20 amount to transfer to GeneralAdapter1.
210
- * @param params.maxSharePrice - Maximum repay share price (in ray). Must be positive.
211
- * @param params.marketId - The market identifier (for error messages).
212
- */
213
- export const validateRepayParams = (params) => {
214
- const { assets, shares, transferAmount, maxSharePrice, marketId } = params;
215
- if (maxSharePrice <= 0n) {
216
- throw new NonPositiveRepayMaxSharePriceError(marketId);
217
- }
218
- if (assets < 0n || shares < 0n) {
219
- throw new NonPositiveRepayAmountError(marketId);
220
- }
221
- if (assets > 0n && shares > 0n) {
222
- throw new MutuallyExclusiveRepayAmountsError(marketId);
223
- }
224
- if (assets === 0n && shares === 0n) {
225
- throw new NonPositiveRepayAmountError(marketId);
226
- }
227
- if (transferAmount <= 0n) {
228
- throw new NonPositiveTransferAmountError(marketId);
229
- }
230
- if (assets > 0n && transferAmount !== assets) {
231
- throw new TransferAmountNotEqualToAssetsError({
232
- transferAmount,
233
- assets,
234
- market: marketId,
235
- });
236
- }
237
- };
238
202
  /**
239
203
  * Validates that vault reallocations are well-formed.
240
204
  *