@morpho-org/morpho-sdk 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/MIGRATION-v5-to-v6.md +1 -1
  2. package/README.md +1 -1
  3. package/lib/cjs/abis.d.ts +1 -1
  4. package/lib/cjs/abis.js +3 -1
  5. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +16 -5
  6. package/lib/cjs/actions/vaultV2/forceWithdraw.js +16 -5
  7. package/lib/cjs/constants.d.ts +1 -1
  8. package/lib/cjs/constants.js +4 -1
  9. package/lib/cjs/entities/blue/blue.d.ts +28 -0
  10. package/lib/cjs/entities/blue/blue.js +1 -0
  11. package/lib/cjs/entities/index.d.ts +1 -1
  12. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +9 -2
  13. package/lib/cjs/entities/vaultV1/vaultV1.js +1 -0
  14. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +35 -11
  15. package/lib/cjs/entities/vaultV2/vaultV2.js +1 -0
  16. package/lib/cjs/errors.d.ts +1 -1
  17. package/lib/cjs/errors.js +8 -1
  18. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +10 -6
  19. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +10 -6
  20. package/lib/cjs/helpers/slippage.d.ts +3 -2
  21. package/lib/cjs/helpers/slippage.js +3 -2
  22. package/lib/cjs/helpers/validate.d.ts +40 -0
  23. package/lib/cjs/helpers/validate.js +40 -0
  24. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +94 -59
  25. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +94 -59
  26. package/lib/cjs/midnight/abis.d.ts +1 -1
  27. package/lib/cjs/midnight/abis.js +3 -1
  28. package/lib/cjs/midnight/constants.d.ts +1 -1
  29. package/lib/cjs/midnight/constants.js +4 -1
  30. package/lib/cjs/midnight/entities.d.ts +1 -1
  31. package/lib/cjs/midnight/errors.d.ts +1 -1
  32. package/lib/cjs/midnight/errors.js +7 -1
  33. package/lib/cjs/midnight/types.d.ts +1 -1
  34. package/lib/cjs/midnight/utils.d.ts +11 -1
  35. package/lib/cjs/midnight/utils.js +13 -1
  36. package/lib/cjs/types/action.d.ts +34 -0
  37. package/lib/cjs/types/action.js +10 -0
  38. package/lib/cjs/types.d.ts +1 -1
  39. package/lib/cjs/utils.d.ts +11 -1
  40. package/lib/cjs/utils.js +14 -2
  41. package/lib/esm/abis.d.ts +1 -1
  42. package/lib/esm/abis.js +1 -1
  43. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +16 -5
  44. package/lib/esm/actions/vaultV2/forceWithdraw.js +16 -5
  45. package/lib/esm/constants.d.ts +1 -1
  46. package/lib/esm/constants.js +1 -1
  47. package/lib/esm/entities/blue/blue.d.ts +28 -0
  48. package/lib/esm/entities/blue/blue.js +1 -0
  49. package/lib/esm/entities/index.d.ts +1 -1
  50. package/lib/esm/entities/vaultV1/vaultV1.d.ts +9 -2
  51. package/lib/esm/entities/vaultV1/vaultV1.js +1 -0
  52. package/lib/esm/entities/vaultV2/vaultV2.d.ts +35 -11
  53. package/lib/esm/entities/vaultV2/vaultV2.js +1 -0
  54. package/lib/esm/errors.d.ts +1 -1
  55. package/lib/esm/errors.js +1 -1
  56. package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +10 -6
  57. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +10 -6
  58. package/lib/esm/helpers/slippage.d.ts +3 -2
  59. package/lib/esm/helpers/slippage.js +3 -2
  60. package/lib/esm/helpers/validate.d.ts +40 -0
  61. package/lib/esm/helpers/validate.js +40 -0
  62. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +94 -59
  63. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +94 -59
  64. package/lib/esm/midnight/abis.d.ts +1 -1
  65. package/lib/esm/midnight/abis.js +1 -1
  66. package/lib/esm/midnight/constants.d.ts +1 -1
  67. package/lib/esm/midnight/constants.js +1 -1
  68. package/lib/esm/midnight/entities.d.ts +1 -1
  69. package/lib/esm/midnight/errors.d.ts +1 -1
  70. package/lib/esm/midnight/errors.js +1 -1
  71. package/lib/esm/midnight/types.d.ts +1 -1
  72. package/lib/esm/midnight/utils.d.ts +11 -1
  73. package/lib/esm/midnight/utils.js +11 -1
  74. package/lib/esm/types/action.d.ts +34 -0
  75. package/lib/esm/types/action.js +10 -0
  76. package/lib/esm/types.d.ts +1 -1
  77. package/lib/esm/utils.d.ts +11 -1
  78. package/lib/esm/utils.js +11 -1
  79. package/package.json +4 -4
@@ -491,7 +491,7 @@ Migration steps:
491
491
  - Replace `InKindRedeemRequiresSingleAdapterError` and `UnsupportedInKindAdapterError` with
492
492
  `VaultV2SingleAdapterRequiredError` and `VaultV2UnsupportedExitAdapterError`.
493
493
 
494
- See the [`TIB-2026-08-28-vault-exit-force-withdraw`](https://github.com/morpho-org/sdks/blob/main/docs/tibs/TIB-2026-08-28-vault-exit-force-withdraw.md)
494
+ See the [`ADR-2026-08-28-vault-exit-force-withdraw`](https://github.com/morpho-org/sdks/blob/main/docs/adrs/ADR-2026-08-28-vault-exit-force-withdraw.md)
495
495
  decision record for the full rationale.
496
496
 
497
497
  ## Update Vault V1 and Vault V2 writes
package/README.md CHANGED
@@ -42,7 +42,7 @@ BlueBundlesV1, and the remaining rows identify their destination.
42
42
  | | `inKindRedeem` | VaultExitBundlesV1 |
43
43
  | **Blue** | `supply`, `withdraw`, `supplyCollateral`, `borrow`, `supplyCollateralBorrow`, `repay`, `withdrawCollateral`, `repayWithdrawCollateral`, `refinance` | BlueBundlesV1 |
44
44
  | **Midnight** | `takeLend`, `takeBorrow`, `supplyCollateralTakeBorrow`, `repayWithdrawCollateral` | Midnight Bundles |
45
- | | `makeLend`, `makeBorrow` | Midnight mempool |
45
+ | | `makeLend`, `makeBorrow`, `supplyCollateralMakeBorrow` | Midnight mempool |
46
46
  | | `supplyCollateral`, `redeem`, `cancelOffer` | Direct call |
47
47
 
48
48
  `VaultExitBundlesV1`, `VaultBundlesV1`, and `BlueBundlesV1` are registered on Ethereum, Base,
package/lib/cjs/abis.d.ts CHANGED
@@ -4,7 +4,7 @@ export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi,
4
4
  preLiquidationAbi as bluePreLiquidationAbi,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
6
6
  preLiquidationFactoryAbi as bluePreLiquidationFactoryAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
7
- export { ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
7
+ export { ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
8
8
  /** ABI for the VaultExitBundlesV1 periphery contract. */
9
9
  export declare const vaultExitBundlesV1Abi: readonly [{
10
10
  readonly type: "constructor";
package/lib/cjs/abis.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.blueBundlesV1Abi = exports.vaultBundlesV1Abi = exports.vaultExitBundlesV1Abi = exports.midnightSetterRatifierAbi = exports.midnightBundlesAbi = exports.midnightAbi = exports.midnightEcrecoverRatifierAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.bluePreLiquidationFactoryAbi = exports.bluePreLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.blueAdaptiveCurveIrmAbi = exports.blueMarketParamsAbi = void 0;
3
+ exports.blueBundlesV1Abi = exports.vaultBundlesV1Abi = exports.vaultExitBundlesV1Abi = exports.midnightSetterRatifierAbi = exports.midnightRateRatifierV1Abi = exports.midnightPriceRatifierV1Abi = exports.midnightBundlesAbi = exports.midnightAbi = exports.midnightEcrecoverRatifierAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.bluePreLiquidationFactoryAbi = exports.bluePreLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.blueAdaptiveCurveIrmAbi = exports.blueMarketParamsAbi = void 0;
4
4
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  Object.defineProperty(exports, "blueMarketParamsAbi", { enumerable: true, get: function () { return blue_sdk_1.marketParamsAbi; } });
6
6
  var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
@@ -33,6 +33,8 @@ var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
33
33
  Object.defineProperty(exports, "midnightEcrecoverRatifierAbi", { enumerable: true, get: function () { return midnight_sdk_1.ecrecoverRatifierAbi; } });
34
34
  Object.defineProperty(exports, "midnightAbi", { enumerable: true, get: function () { return midnight_sdk_1.midnightAbi; } });
35
35
  Object.defineProperty(exports, "midnightBundlesAbi", { enumerable: true, get: function () { return midnight_sdk_1.midnightBundlesAbi; } });
36
+ Object.defineProperty(exports, "midnightPriceRatifierV1Abi", { enumerable: true, get: function () { return midnight_sdk_1.priceRatifierV1Abi; } });
37
+ Object.defineProperty(exports, "midnightRateRatifierV1Abi", { enumerable: true, get: function () { return midnight_sdk_1.rateRatifierV1Abi; } });
36
38
  Object.defineProperty(exports, "midnightSetterRatifierAbi", { enumerable: true, get: function () { return midnight_sdk_1.setterRatifierAbi; } });
37
39
  /** ABI for the VaultExitBundlesV1 periphery contract. */
38
40
  exports.vaultExitBundlesV1Abi = [
@@ -67,12 +67,23 @@ export interface VaultV2ForceWithdrawParams {
67
67
  * @example
68
68
  * ```ts
69
69
  * import { vaultV2ForceWithdraw } from "@morpho-org/morpho-sdk";
70
+ * import type { Address } from "viem";
71
+ * import { mainnet } from "viem/chains";
70
72
  *
71
- * const tx = vaultV2ForceWithdraw({
72
- * vault: { chainId: 1, address: vault },
73
- * args: { adapter, exitAssets: 1_000_000n, minSharePriceE27, userAddress, deadline },
74
- * });
75
- * // tx satisfies Readonly<Transaction<VaultV2ForceWithdrawAction>>
73
+ * export function buildForceWithdraw(
74
+ * vault: Address,
75
+ * adapter: Address,
76
+ * minSharePriceE27: bigint,
77
+ * userAddress: Address,
78
+ * deadline: bigint,
79
+ * ) {
80
+ * const tx = vaultV2ForceWithdraw({
81
+ * vault: { chainId: mainnet.id, address: vault },
82
+ * args: { adapter, exitAssets: 1_000_000n, minSharePriceE27, userAddress, deadline },
83
+ * });
84
+ * // tx satisfies Readonly<Transaction<VaultV2ForceWithdrawAction>>
85
+ * return tx;
86
+ * }
76
87
  * ```
77
88
  */
78
89
  export declare const vaultV2ForceWithdraw: ({ vault, args, metadata, }: VaultV2ForceWithdrawParams) => Readonly<Transaction<VaultV2ForceWithdrawAction>>;
@@ -57,12 +57,23 @@ const common_js_1 = require("../bundles/common.js");
57
57
  * @example
58
58
  * ```ts
59
59
  * import { vaultV2ForceWithdraw } from "@morpho-org/morpho-sdk";
60
+ * import type { Address } from "viem";
61
+ * import { mainnet } from "viem/chains";
60
62
  *
61
- * const tx = vaultV2ForceWithdraw({
62
- * vault: { chainId: 1, address: vault },
63
- * args: { adapter, exitAssets: 1_000_000n, minSharePriceE27, userAddress, deadline },
64
- * });
65
- * // tx satisfies Readonly<Transaction<VaultV2ForceWithdrawAction>>
63
+ * export function buildForceWithdraw(
64
+ * vault: Address,
65
+ * adapter: Address,
66
+ * minSharePriceE27: bigint,
67
+ * userAddress: Address,
68
+ * deadline: bigint,
69
+ * ) {
70
+ * const tx = vaultV2ForceWithdraw({
71
+ * vault: { chainId: mainnet.id, address: vault },
72
+ * args: { adapter, exitAssets: 1_000_000n, minSharePriceE27, userAddress, deadline },
73
+ * });
74
+ * // tx satisfies Readonly<Transaction<VaultV2ForceWithdrawAction>>
75
+ * return tx;
76
+ * }
66
77
  * ```
67
78
  */
68
79
  const vaultV2ForceWithdraw = ({ vault, args, metadata, }) => {
@@ -1,4 +1,4 @@
1
1
  export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId as isBlueMarketId, LIQUIDATION_CURSOR as BLUE_LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR as BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType as BlueTransactionType, } from "@morpho-org/blue-sdk";
2
- export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
2
+ export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, MAX_TREE_HEIGHT as MIDNIGHT_MAX_TREE_HEIGHT, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, RATE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
3
3
  export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
4
4
  export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.APPROVE_ONLY_ONCE_TOKENS = exports.ZERO_ADDRESS = exports.REWARDS_BASE_URL = exports.MORPHO_DOMAIN = exports.DOCS_BASE_URL = exports.ChainUtils = exports.ChainId = exports.BLUE_API_GRAPHQL_URL = exports.BLUE_API_BASE_URL = exports.MIDNIGHT_TIME_TO_MAX_LIF = exports.MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS = exports.MIDNIGHT_PRICE_ROUNDING_STEP = exports.MIDNIGHT_OFFER_TYPEHASH = exports.MIDNIGHT_MAX_TICK = exports.MIDNIGHT_MAX_SETTLEMENT_FEES = exports.MIDNIGHT_MAX_OFFER_CAP = exports.MIDNIGHT_MAX_CONTINUOUS_FEE = exports.MIDNIGHT_MAX_COLLATERALS_PER_BORROWER = exports.MIDNIGHT_MAX_COLLATERALS = exports.MIDNIGHT_MARKET_TYPEHASH = exports.MIDNIGHT_EIP712_DOMAIN_TYPEHASH = exports.MIDNIGHT_DEFAULT_TICK_SPACING = exports.MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH = exports.MIDNIGHT_CBP = exports.BlueTransactionType = exports.SECONDS_PER_YEAR = exports.ORACLE_PRICE_SCALE = exports.BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR = exports.BLUE_LIQUIDATION_CURSOR = exports.isBlueMarketId = exports.ERC20_ALLOWANCE_RECIPIENTS = exports.EIP_712_FIELDS = exports.DEFAULT_SLIPPAGE_TOLERANCE = void 0;
3
+ exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.APPROVE_ONLY_ONCE_TOKENS = exports.ZERO_ADDRESS = exports.REWARDS_BASE_URL = exports.MORPHO_DOMAIN = exports.DOCS_BASE_URL = exports.ChainUtils = exports.ChainId = exports.BLUE_API_GRAPHQL_URL = exports.BLUE_API_BASE_URL = exports.MIDNIGHT_TIME_TO_MAX_LIF = exports.MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS = exports.MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH = exports.MIDNIGHT_PRICE_ROUNDING_STEP = exports.MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH = exports.MIDNIGHT_OFFER_TYPEHASH = exports.MIDNIGHT_MAX_TREE_HEIGHT = exports.MIDNIGHT_MAX_TICK = exports.MIDNIGHT_MAX_SETTLEMENT_FEES = exports.MIDNIGHT_MAX_OFFER_CAP = exports.MIDNIGHT_MAX_CONTINUOUS_FEE = exports.MIDNIGHT_MAX_COLLATERALS_PER_BORROWER = exports.MIDNIGHT_MAX_COLLATERALS = exports.MIDNIGHT_MARKET_TYPEHASH = exports.MIDNIGHT_EIP712_DOMAIN_TYPEHASH = exports.MIDNIGHT_DEFAULT_TICK_SPACING = exports.MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH = exports.MIDNIGHT_CBP = exports.BlueTransactionType = exports.SECONDS_PER_YEAR = exports.ORACLE_PRICE_SCALE = exports.BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR = exports.BLUE_LIQUIDATION_CURSOR = exports.isBlueMarketId = exports.ERC20_ALLOWANCE_RECIPIENTS = exports.EIP_712_FIELDS = exports.DEFAULT_SLIPPAGE_TOLERANCE = void 0;
4
4
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  Object.defineProperty(exports, "DEFAULT_SLIPPAGE_TOLERANCE", { enumerable: true, get: function () { return blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE; } });
6
6
  Object.defineProperty(exports, "EIP_712_FIELDS", { enumerable: true, get: function () { return blue_sdk_1.EIP_712_FIELDS; } });
@@ -23,8 +23,11 @@ Object.defineProperty(exports, "MIDNIGHT_MAX_CONTINUOUS_FEE", { enumerable: true
23
23
  Object.defineProperty(exports, "MIDNIGHT_MAX_OFFER_CAP", { enumerable: true, get: function () { return midnight_sdk_1.MAX_OFFER_CAP; } });
24
24
  Object.defineProperty(exports, "MIDNIGHT_MAX_SETTLEMENT_FEES", { enumerable: true, get: function () { return midnight_sdk_1.MAX_SETTLEMENT_FEES; } });
25
25
  Object.defineProperty(exports, "MIDNIGHT_MAX_TICK", { enumerable: true, get: function () { return midnight_sdk_1.MAX_TICK; } });
26
+ Object.defineProperty(exports, "MIDNIGHT_MAX_TREE_HEIGHT", { enumerable: true, get: function () { return midnight_sdk_1.MAX_TREE_HEIGHT; } });
26
27
  Object.defineProperty(exports, "MIDNIGHT_OFFER_TYPEHASH", { enumerable: true, get: function () { return midnight_sdk_1.OFFER_TYPEHASH; } });
28
+ Object.defineProperty(exports, "MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH", { enumerable: true, get: function () { return midnight_sdk_1.PRICE_RATIFIER_V1_OFFER_TYPEHASH; } });
27
29
  Object.defineProperty(exports, "MIDNIGHT_PRICE_ROUNDING_STEP", { enumerable: true, get: function () { return midnight_sdk_1.PRICE_ROUNDING_STEP; } });
30
+ Object.defineProperty(exports, "MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH", { enumerable: true, get: function () { return midnight_sdk_1.RATE_RATIFIER_V1_OFFER_TYPEHASH; } });
28
31
  Object.defineProperty(exports, "MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS", { enumerable: true, get: function () { return midnight_sdk_1.SETTLEMENT_FEE_BREAKPOINTS; } });
29
32
  Object.defineProperty(exports, "MIDNIGHT_TIME_TO_MAX_LIF", { enumerable: true, get: function () { return midnight_sdk_1.TIME_TO_MAX_LIF; } });
30
33
  var morpho_ts_1 = require("@morpho-org/morpho-ts");
@@ -24,12 +24,26 @@ export interface BlueTokenRequirementsParams {
24
24
  */
25
25
  readonly approvalAmount?: bigint;
26
26
  }
27
+ /** Action surface for Morpho Blue reads and writes; writes route through BlueBundlesV1. */
27
28
  export interface BlueActions {
28
29
  /**
29
30
  * Fetches the latest market data with accrued interest.
30
31
  *
31
32
  * @param parameters - Optional fetch parameters (block number, state overrides).
32
33
  * @returns Market state including total supply/borrow assets and shares.
34
+ * @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
35
+ * @example
36
+ * ```ts
37
+ * import { markets } from "@morpho-org/morpho-test";
38
+ * import { createPublicClient, http } from "viem";
39
+ * import { mainnet } from "viem/chains";
40
+ * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
41
+ *
42
+ * const client = createPublicClient({ chain: mainnet, transport: http() })
43
+ * .extend(morphoViemExtension());
44
+ * const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
45
+ * const marketData = await market.getMarketData();
46
+ * ```
33
47
  */
34
48
  getMarketData: (parameters?: FetchParameters) => Promise<Market>;
35
49
  /**
@@ -38,6 +52,19 @@ export interface BlueActions {
38
52
  * @param userAddress - The user whose position to fetch.
39
53
  * @param parameters - Optional fetch parameters (block number, state overrides).
40
54
  * @returns Accrual position with health metrics (maxBorrowAssets, ltv, isHealthy).
55
+ * @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
56
+ * @example
57
+ * ```ts
58
+ * import { markets } from "@morpho-org/morpho-test";
59
+ * import { createPublicClient, http, zeroAddress } from "viem";
60
+ * import { mainnet } from "viem/chains";
61
+ * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
62
+ *
63
+ * const client = createPublicClient({ chain: mainnet, transport: http() })
64
+ * .extend(morphoViemExtension());
65
+ * const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
66
+ * const position = await market.getPositionData(zeroAddress);
67
+ * ```
41
68
  */
42
69
  getPositionData: (userAddress: Address, parameters?: FetchParameters) => Promise<AccrualPosition>;
43
70
  /**
@@ -819,6 +846,7 @@ export interface BlueActions {
819
846
  readonly data: VaultV2BlueReallocationData;
820
847
  };
821
848
  }
849
+ /** Binds a viem client to a Morpho Blue market's action builders. */
822
850
  export declare class MorphoBlue implements BlueActions {
823
851
  private readonly client;
824
852
  readonly marketParams: MarketParams;
@@ -11,6 +11,7 @@ const index_js_2 = require("../../helpers/index.js");
11
11
  const index_js_3 = require("../../types/index.js");
12
12
  const index_js_4 = require("../requirements/index.js");
13
13
  const vaultV2BlueReallocationData_js_1 = require("../vaultV2BlueReallocationData.js");
14
+ /** Binds a viem client to a Morpho Blue market's action builders. */
14
15
  class MorphoBlue {
15
16
  client;
16
17
  marketParams;
@@ -8,7 +8,7 @@ export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, A
8
8
  PreLiquidationParams as BluePreLiquidationParams,
9
9
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
10
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";
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";
11
+ export type { AnyTree as MidnightAnyTree, AnyTreeSnapshot as MidnightAnyTreeSnapshot, BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, EcrecoverTreeCreateRequest as MidnightEcrecoverTreeCreateRequest, 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, PriceRatifierV1TreeCreateRequest as MidnightPriceRatifierV1TreeCreateRequest, RateRatifierV1TreeCreateRequest as MidnightRateRatifierV1TreeCreateRequest, RatifierKind as MidnightRatifierKind, RatifierTreeInput as MidnightRatifierTreeInput, RatifierTypes as MidnightRatifierTypes, SetterTreeCreateRequest as MidnightSetterTreeCreateRequest, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeCreateRequest as MidnightTreeCreateRequest, TreeData as MidnightTreeData, TreeDescriptor as MidnightTreeDescriptor, TreeEntry as MidnightTreeEntry, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, TreeSnapshot as MidnightTreeSnapshot, TypedRatifierTreeInput as MidnightTypedRatifierTreeInput, TypedTreeMempoolValidateParams as MidnightTypedTreeMempoolValidateParams, } from "@morpho-org/midnight-sdk";
12
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";
13
13
  export type { BlueActions, BlueTokenRequirementsParams, } from "./blue/index.js";
14
14
  export { MorphoBlue } from "./blue/index.js";
@@ -3,13 +3,19 @@ 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
5
  import { type ActionOutput, type ActionRequirement, type BundlesFundingArgs, type BundlesTokenRequirementsOptions, type MorphoClientType, type RequirementSignature, type VaultV1DepositAction, type VaultV1InKindRedeemAction, type VaultV1MigrateToV2Action, type VaultV1MigrateToV2AmountArgs, type VaultV1RedeemAction, type VaultV1WithdrawAction } from "../../types/index.js";
6
+ /** Action surface for Vault V1 reads and writes; writes route through VaultBundlesV1 and VaultExitBundlesV1. */
6
7
  export interface VaultV1Actions {
7
8
  /**
8
9
  * Fetches direct onchain vault and allocation state without applying virtual interest.
9
10
  *
10
- * @param {FetchParameters} [parameters] - Optional fetch parameters (block number, state overrides, etc.).
11
- * @returns {Promise<Awaited<ReturnType<typeof fetchAccrualVault>>>} The requested vault state.
11
+ * Reads the Vault V1 state through `fetchAccrualVault` on the entity's client.
12
+ *
13
+ * @param parameters - Optional viem fetch parameters (block number, block tag, state override).
14
+ * @returns The hydrated `AccrualVault` snapshot.
12
15
  * @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
16
+ * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
17
+ * @throws {UnknownBlueFactory} when the configured chain has no MetaMorpho factory.
18
+ * @throws {UnknownBlueOfFactory} when the vault is not a MetaMorpho vault from the configured factory.
13
19
  */
14
20
  getData: (parameters?: FetchParameters) => Promise<Awaited<ReturnType<typeof fetchAccrualVault>>>;
15
21
  /**
@@ -414,6 +420,7 @@ export interface VaultV1Actions {
414
420
  readonly deadline?: bigint;
415
421
  } & VaultV1MigrateToV2AmountArgs) => ActionOutput<VaultV1MigrateToV2Action, readonly RequirementSignature[], undefined>;
416
422
  }
423
+ /** Binds a viem client to a Vault V1 (MetaMorpho) vault's action builders. */
417
424
  export declare class MorphoVaultV1 implements VaultV1Actions {
418
425
  private readonly client;
419
426
  private readonly vault;
@@ -13,6 +13,7 @@ const validate_js_1 = require("../../helpers/validate.js");
13
13
  const index_js_3 = require("../../types/index.js");
14
14
  const getVaultBundlesSharesRequirements_js_1 = require("../requirements/getVaultBundlesSharesRequirements.js");
15
15
  const index_js_4 = require("../requirements/index.js");
16
+ /** Binds a viem client to a Vault V1 (MetaMorpho) vault's action builders. */
16
17
  class MorphoVaultV1 {
17
18
  client;
18
19
  vault;
@@ -3,15 +3,24 @@ 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
5
  import { type ActionOutput, type ActionRequirement, type BundlesFundingArgs, type BundlesTokenRequirementsOptions, type Deallocation, type MorphoClientType, type RequirementSignature, type Transaction, type VaultV2DepositAction, type VaultV2ForceRedeemAction, type VaultV2ForceWithdrawAction, type VaultV2InKindRedeemAction, type VaultV2RedeemAction, type VaultV2WithdrawAction } from "../../types/index.js";
6
+ /**
7
+ * Action surface for Vault V2 reads and writes; writes route through VaultBundlesV1 and
8
+ * VaultExitBundlesV1, except `forceRedeem`, which uses the vault's native multicall.
9
+ */
6
10
  export interface VaultV2Actions {
7
11
  /**
8
- * Fetches the latest vault data.
12
+ * Fetches the latest accrual snapshot of the vault.
9
13
  *
10
- * This function fetches the latest vault data from the blockchain.
11
- * @param {FetchParameters} [parameters] - The parameters for the fetch operation.
14
+ * Reads the Vault V2 state through `fetchAccrualVaultV2` on the entity's client.
12
15
  *
13
- * @returns {Promise<Awaited<ReturnType<typeof fetchAccrualVaultV2>>>} The latest vault data.
16
+ * @param parameters - Optional viem fetch parameters (block number, block tag, state override).
17
+ * @returns The hydrated `AccrualVaultV2` snapshot.
14
18
  * @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
19
+ * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
20
+ * @throws {UnknownBlueFactory} when the configured chain has no VaultV2 factory.
21
+ * @throws {UnknownBlueOfFactory} when the vault is not a VaultV2 from the configured factory.
22
+ * @throws {UnsupportedBlueVaultV2AdapterError} when the vault or one of its adapters uses an
23
+ * unsupported adapter class.
15
24
  */
16
25
  getData: (parameters?: FetchParameters) => Promise<Awaited<ReturnType<typeof fetchAccrualVaultV2>>>;
17
26
  /**
@@ -463,13 +472,27 @@ export interface VaultV2Actions {
463
472
  * asset-equivalent of the redeemed shares. The caller should apply a buffer on the deallocated
464
473
  * amounts to account for share-price drift between submission and execution.
465
474
  *
466
- * @param {Object} params - The force redeem parameters.
467
- * @param {readonly Deallocation[]} params.deallocations - The typed list of deallocations to perform.
468
- * @param {Object} params.redeem - The redeem parameters applied after deallocations.
469
- * @param {bigint} params.redeem.shares - The amount of shares to redeem.
470
- * @param {Address} params.userAddress - User address (penalty source and redeem recipient).
471
- * @returns {Object} The result object.
472
- * @returns {Readonly<Transaction<VaultV2ForceRedeemAction>>} returns.buildTx The prepared multicall transaction.
475
+ * @param params.deallocations - Typed list of `forceDeallocate` calls to perform before the redeem.
476
+ * @param params.redeem.shares - Amount of vault shares to redeem after the deallocations.
477
+ * @param params.userAddress - Account that pays the deallocation penalties and receives the redeemed assets.
478
+ * @returns An object whose `buildTx()` returns a deep-frozen `Transaction<VaultV2ForceRedeemAction>`
479
+ * encoding the vault `multicall`.
480
+ * @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
481
+ * @throws {EmptyDeallocationsError} from `buildTx()` when `deallocations` is empty.
482
+ * @throws {NonPositiveInputError} from `buildTx()` when `redeem.shares <= 0n` or any deallocation
483
+ * amount is non-positive.
484
+ * @example
485
+ * ```ts
486
+ * const vault = client.morpho.vaultV2(vaultAddress, 1);
487
+ * const tx = vault
488
+ * .forceRedeem({
489
+ * deallocations: [{ adapter, marketParams, amount: 1_000_000n }],
490
+ * redeem: { shares: 500_000n },
491
+ * userAddress,
492
+ * })
493
+ * .buildTx();
494
+ * // tx satisfies Readonly<Transaction<VaultV2ForceRedeemAction>>
495
+ * ```
473
496
  */
474
497
  forceRedeem: (params: {
475
498
  deallocations: readonly Deallocation[];
@@ -481,6 +504,7 @@ export interface VaultV2Actions {
481
504
  buildTx: () => Readonly<Transaction<VaultV2ForceRedeemAction>>;
482
505
  };
483
506
  }
507
+ /** Binds a viem client to a Vault V2 vault's action builders. */
484
508
  export declare class MorphoVaultV2 implements VaultV2Actions {
485
509
  private readonly client;
486
510
  private readonly vault;
@@ -16,6 +16,7 @@ const index_js_4 = require("../requirements/index.js");
16
16
  // Maximum accepted deadline horizon; the on-chain management fee is capped at 5%/yr so the
17
17
  // accrual model stays well-defined inside it.
18
18
  const VAULT_V2_FEE_PROJECTION_HORIZON = morpho_ts_1.Time.s.from.y(1n);
19
+ /** Binds a viem client to a Vault V2 vault's action builders. */
19
20
  class MorphoVaultV2 {
20
21
  client;
21
22
  vault;
@@ -2,6 +2,6 @@ export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as I
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
4
4
  export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
5
- export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
5
+ export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, InvalidRateRatifierV1RateError as InvalidMidnightRateRatifierV1RateError, InvalidRateRatifierV1TickError as InvalidMidnightRateRatifierV1TickError, InvalidRateRatifierV1TimeError as InvalidMidnightRateRatifierV1TimeError, InvalidRatifierV1AddressError as InvalidMidnightRatifierV1AddressError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, RateRatifierV1BoundOverflowError as MidnightRateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError as MidnightRatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
6
6
  export type { ErrorClass } from "@morpho-org/morpho-ts";
7
7
  export { _try, DivisionByZeroError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
package/lib/cjs/errors.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidBitLengthError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidMidnightOfferParameterError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownBlueVaultConfigError = exports.UnknownBlueTokenPriceError = exports.UnknownBlueTokenError = exports.UnknownBlueOfFactory = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownBlueFactory = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
3
+ exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightRatifierV1TakerNotAllowedError = exports.MidnightRateRatifierV1BoundOverflowError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightRatifierV1AddressError = exports.InvalidMidnightRateRatifierV1TimeError = exports.InvalidMidnightRateRatifierV1TickError = exports.InvalidMidnightRateRatifierV1RateError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidMidnightOfferParameterError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownBlueVaultConfigError = exports.UnknownBlueTokenPriceError = exports.UnknownBlueTokenError = exports.UnknownBlueOfFactory = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownBlueFactory = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
4
+ exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidBitLengthError = exports.DivisionByZeroError = exports._try = void 0;
4
5
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
5
6
  Object.defineProperty(exports, "BlueErrors", { enumerable: true, get: function () { return blue_sdk_1.BlueErrors; } });
6
7
  Object.defineProperty(exports, "IncompleteChainRegistryError", { enumerable: true, get: function () { return blue_sdk_1.IncompleteChainRegistryError; } });
@@ -38,6 +39,10 @@ Object.defineProperty(exports, "InvalidMidnightOfferParameterError", { enumerabl
38
39
  Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
39
40
  Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
40
41
  Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
42
+ Object.defineProperty(exports, "InvalidMidnightRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
43
+ Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
44
+ Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
45
+ Object.defineProperty(exports, "InvalidMidnightRatifierV1AddressError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRatifierV1AddressError; } });
41
46
  Object.defineProperty(exports, "InvalidMidnightTickSpacingError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidTickSpacingError; } });
42
47
  Object.defineProperty(exports, "InvalidMidnightTreeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidTreeError; } });
43
48
  Object.defineProperty(exports, "InvalidMidnightTreeHeightError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidTreeHeightError; } });
@@ -46,6 +51,8 @@ Object.defineProperty(exports, "MidnightApiError", { enumerable: true, get: func
46
51
  Object.defineProperty(exports, "MidnightMempoolValidationError", { enumerable: true, get: function () { return midnight_sdk_1.MidnightMempoolValidationError; } });
47
52
  Object.defineProperty(exports, "MidnightPayloadDecodeError", { enumerable: true, get: function () { return midnight_sdk_1.PayloadDecodeError; } });
48
53
  Object.defineProperty(exports, "MidnightPriceGreaterThanOneError", { enumerable: true, get: function () { return midnight_sdk_1.PriceGreaterThanOneError; } });
54
+ Object.defineProperty(exports, "MidnightRateRatifierV1BoundOverflowError", { enumerable: true, get: function () { return midnight_sdk_1.RateRatifierV1BoundOverflowError; } });
55
+ Object.defineProperty(exports, "MidnightRatifierV1TakerNotAllowedError", { enumerable: true, get: function () { return midnight_sdk_1.RatifierV1TakerNotAllowedError; } });
49
56
  Object.defineProperty(exports, "MidnightSettlementFeeExceedsPriceError", { enumerable: true, get: function () { return midnight_sdk_1.SettlementFeeExceedsPriceError; } });
50
57
  Object.defineProperty(exports, "MidnightTickOutOfRangeError", { enumerable: true, get: function () { return midnight_sdk_1.TickOutOfRangeError; } });
51
58
  Object.defineProperty(exports, "UnknownMidnightCollateralIndexError", { enumerable: true, get: function () { return midnight_sdk_1.UnknownCollateralIndexError; } });
@@ -94,14 +94,18 @@ export interface VaultV2ForceWithdrawPreview {
94
94
  * floor cannot fit `uint256`.
95
95
  * @example
96
96
  * ```ts
97
+ * import type { AccrualVaultV2 } from "@morpho-org/blue-sdk";
97
98
  * import { previewVaultV2ForceWithdraw } from "@morpho-org/morpho-sdk";
98
99
  *
99
- * const preview = previewVaultV2ForceWithdraw(vaultData, {
100
- * requestedExitAssets: 1_000_000n,
101
- * timestamp: block.timestamp,
102
- * });
103
- * // preview?.exitAssets is ready to pass to vault.forceWithdraw(...)
104
- * // preview?.netAssets is what the user receives
100
+ * export function preview(vaultData: AccrualVaultV2, timestamp: bigint) {
101
+ * const preview = previewVaultV2ForceWithdraw(vaultData, {
102
+ * requestedExitAssets: 1_000_000n,
103
+ * timestamp,
104
+ * });
105
+ * // preview?.exitAssets is ready to pass to vault.forceWithdraw(...)
106
+ * // preview?.netAssets is what the user receives
107
+ * return preview;
108
+ * }
105
109
  * ```
106
110
  */
107
111
  export declare function previewVaultV2ForceWithdraw(vaultData: AccrualVaultV2, params: PreviewVaultV2ForceWithdrawParams): VaultV2ForceWithdrawPreview | undefined;
@@ -43,14 +43,18 @@ const vaultV2ForceWithdrawPlan_js_1 = require("./vaultV2ForceWithdrawPlan.js");
43
43
  * floor cannot fit `uint256`.
44
44
  * @example
45
45
  * ```ts
46
+ * import type { AccrualVaultV2 } from "@morpho-org/blue-sdk";
46
47
  * import { previewVaultV2ForceWithdraw } from "@morpho-org/morpho-sdk";
47
48
  *
48
- * const preview = previewVaultV2ForceWithdraw(vaultData, {
49
- * requestedExitAssets: 1_000_000n,
50
- * timestamp: block.timestamp,
51
- * });
52
- * // preview?.exitAssets is ready to pass to vault.forceWithdraw(...)
53
- * // preview?.netAssets is what the user receives
49
+ * export function preview(vaultData: AccrualVaultV2, timestamp: bigint) {
50
+ * const preview = previewVaultV2ForceWithdraw(vaultData, {
51
+ * requestedExitAssets: 1_000_000n,
52
+ * timestamp,
53
+ * });
54
+ * // preview?.exitAssets is ready to pass to vault.forceWithdraw(...)
55
+ * // preview?.netAssets is what the user receives
56
+ * return preview;
57
+ * }
54
58
  * ```
55
59
  */
56
60
  function previewVaultV2ForceWithdraw(vaultData, params) {
@@ -32,10 +32,11 @@ import { type AccrualVault, AccrualVaultV2 } from "@morpho-org/blue-sdk";
32
32
  * @example
33
33
  * ```ts
34
34
  * import { computeMinForceWithdrawSharePrice } from "@morpho-org/morpho-sdk";
35
+ * import { DEFAULT_SLIPPAGE_TOLERANCE } from "@morpho-org/morpho-sdk/constants";
35
36
  *
36
37
  * const minSharePriceE27 = computeMinForceWithdrawSharePrice({
37
- * withdrawnAssets: plan.withdrawnAssets,
38
- * sharesBurnt,
38
+ * withdrawnAssets: 1_000_000n,
39
+ * sharesBurnt: 900_000n,
39
40
  * slippageTolerance: DEFAULT_SLIPPAGE_TOLERANCE,
40
41
  * });
41
42
  * ```
@@ -39,10 +39,11 @@ const validate_js_1 = require("./validate.js");
39
39
  * @example
40
40
  * ```ts
41
41
  * import { computeMinForceWithdrawSharePrice } from "@morpho-org/morpho-sdk";
42
+ * import { DEFAULT_SLIPPAGE_TOLERANCE } from "@morpho-org/morpho-sdk/constants";
42
43
  *
43
44
  * const minSharePriceE27 = computeMinForceWithdrawSharePrice({
44
- * withdrawnAssets: plan.withdrawnAssets,
45
- * sharesBurnt,
45
+ * withdrawnAssets: 1_000_000n,
46
+ * sharesBurnt: 900_000n,
46
47
  * slippageTolerance: DEFAULT_SLIPPAGE_TOLERANCE,
47
48
  * });
48
49
  * ```
@@ -176,6 +176,31 @@ export declare const validateNativeVaultAsset: (chainId: number, vaultAsset: Add
176
176
  * @param params.withdrawAmount - Amount of collateral being withdrawn.
177
177
  * @param params.lltv - The market's liquidation LTV.
178
178
  * @param params.marketId - The market identifier (for error messages).
179
+ * @returns `void` when the post-withdraw position stays within the safe LTV threshold.
180
+ * @throws {MarketIdMismatchError} when `positionData.marketId` differs from `marketId`.
181
+ * @throws {WithdrawExceedsCollateralError} when `withdrawAmount` exceeds the position's collateral.
182
+ * @throws {MissingMarketPriceError} when the position carries debt but the market has no oracle price.
183
+ * @throws {WithdrawMakesPositionUnhealthyError} when the remaining collateral cannot cover the debt
184
+ * at LLTV minus `DEFAULT_LLTV_BUFFER`.
185
+ * @example
186
+ * ```ts
187
+ * import type { AccrualPosition, MarketId } from "@morpho-org/blue-sdk";
188
+ * import { validatePositionHealthAfterWithdraw } from "@morpho-org/morpho-sdk";
189
+ *
190
+ * export function assertSafeWithdraw(
191
+ * positionData: AccrualPosition,
192
+ * withdrawAmount: bigint,
193
+ * lltv: bigint,
194
+ * marketId: MarketId,
195
+ * ): void {
196
+ * validatePositionHealthAfterWithdraw({
197
+ * positionData,
198
+ * withdrawAmount,
199
+ * lltv,
200
+ * marketId,
201
+ * });
202
+ * }
203
+ * ```
179
204
  */
180
205
  export declare const validatePositionHealthAfterWithdraw: (params: {
181
206
  positionData: AccrualPosition;
@@ -203,6 +228,21 @@ export declare const validateRepayAmount: (params: {
203
228
  * @param params.positionData - The current accrual position.
204
229
  * @param params.repayShares - The amount of shares to repay.
205
230
  * @param params.marketId - The market identifier (for error messages).
231
+ * @returns `void` when `repayShares` does not exceed the position's borrow shares.
232
+ * @throws {RepaySharesExceedDebtError} when `repayShares` exceeds the position's borrow shares.
233
+ * @example
234
+ * ```ts
235
+ * import type { AccrualPosition, MarketId } from "@morpho-org/blue-sdk";
236
+ * import { validateRepayShares } from "@morpho-org/morpho-sdk";
237
+ *
238
+ * export function assertRepayable(
239
+ * positionData: AccrualPosition,
240
+ * repayShares: bigint,
241
+ * marketId: MarketId,
242
+ * ): void {
243
+ * validateRepayShares({ positionData, repayShares, marketId });
244
+ * }
245
+ * ```
206
246
  */
207
247
  export declare const validateRepayShares: (params: {
208
248
  positionData: AccrualPosition;
@@ -263,6 +263,31 @@ exports.validateNativeVaultAsset = validateNativeVaultAsset;
263
263
  * @param params.withdrawAmount - Amount of collateral being withdrawn.
264
264
  * @param params.lltv - The market's liquidation LTV.
265
265
  * @param params.marketId - The market identifier (for error messages).
266
+ * @returns `void` when the post-withdraw position stays within the safe LTV threshold.
267
+ * @throws {MarketIdMismatchError} when `positionData.marketId` differs from `marketId`.
268
+ * @throws {WithdrawExceedsCollateralError} when `withdrawAmount` exceeds the position's collateral.
269
+ * @throws {MissingMarketPriceError} when the position carries debt but the market has no oracle price.
270
+ * @throws {WithdrawMakesPositionUnhealthyError} when the remaining collateral cannot cover the debt
271
+ * at LLTV minus `DEFAULT_LLTV_BUFFER`.
272
+ * @example
273
+ * ```ts
274
+ * import type { AccrualPosition, MarketId } from "@morpho-org/blue-sdk";
275
+ * import { validatePositionHealthAfterWithdraw } from "@morpho-org/morpho-sdk";
276
+ *
277
+ * export function assertSafeWithdraw(
278
+ * positionData: AccrualPosition,
279
+ * withdrawAmount: bigint,
280
+ * lltv: bigint,
281
+ * marketId: MarketId,
282
+ * ): void {
283
+ * validatePositionHealthAfterWithdraw({
284
+ * positionData,
285
+ * withdrawAmount,
286
+ * lltv,
287
+ * marketId,
288
+ * });
289
+ * }
290
+ * ```
266
291
  */
267
292
  const validatePositionHealthAfterWithdraw = (params) => {
268
293
  const { positionData, withdrawAmount, lltv, marketId } = params;
@@ -323,6 +348,21 @@ exports.validateRepayAmount = validateRepayAmount;
323
348
  * @param params.positionData - The current accrual position.
324
349
  * @param params.repayShares - The amount of shares to repay.
325
350
  * @param params.marketId - The market identifier (for error messages).
351
+ * @returns `void` when `repayShares` does not exceed the position's borrow shares.
352
+ * @throws {RepaySharesExceedDebtError} when `repayShares` exceeds the position's borrow shares.
353
+ * @example
354
+ * ```ts
355
+ * import type { AccrualPosition, MarketId } from "@morpho-org/blue-sdk";
356
+ * import { validateRepayShares } from "@morpho-org/morpho-sdk";
357
+ *
358
+ * export function assertRepayable(
359
+ * positionData: AccrualPosition,
360
+ * repayShares: bigint,
361
+ * marketId: MarketId,
362
+ * ): void {
363
+ * validateRepayShares({ positionData, repayShares, marketId });
364
+ * }
365
+ * ```
326
366
  */
327
367
  const validateRepayShares = (params) => {
328
368
  const { positionData, repayShares, marketId } = params;