@morpho-org/morpho-sdk 8.2.0-next.0 → 8.2.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 (67) hide show
  1. package/MIGRATION-v7-to-v8.md +7 -3
  2. package/README.md +10 -0
  3. package/lib/cjs/abis.d.ts +1 -1
  4. package/lib/cjs/abis.js +1 -5
  5. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +1 -0
  6. package/lib/cjs/actions/blue/supply.js +7 -5
  7. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +10 -8
  8. package/lib/cjs/actions/blue/withdraw.js +10 -6
  9. package/lib/cjs/blue/abis.d.ts +1 -1
  10. package/lib/cjs/blue/abis.js +1 -5
  11. package/lib/cjs/blue/entities.d.ts +4 -4
  12. package/lib/cjs/blue/entities.js +1 -3
  13. package/lib/cjs/blue/errors.d.ts +2 -2
  14. package/lib/cjs/blue/errors.js +1 -5
  15. package/lib/cjs/blue/fetch.d.ts +2 -2
  16. package/lib/cjs/blue/fetch.js +1 -3
  17. package/lib/cjs/blue/utils.d.ts +1 -1
  18. package/lib/cjs/blue/utils.js +1 -2
  19. package/lib/cjs/entities/index.d.ts +4 -4
  20. package/lib/cjs/entities/index.js +1 -3
  21. package/lib/cjs/entities/midnight/types.d.ts +4 -3
  22. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +9 -33
  23. package/lib/cjs/entities/vaultV2/vaultV2.js +1 -33
  24. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -5
  25. package/lib/cjs/entities/vaultV2BlueReallocationData.js +3 -9
  26. package/lib/cjs/errors.d.ts +4 -4
  27. package/lib/cjs/errors.js +5 -10
  28. package/lib/cjs/fetch.d.ts +2 -2
  29. package/lib/cjs/fetch.js +1 -3
  30. package/lib/cjs/midnight/errors.d.ts +1 -2
  31. package/lib/cjs/midnight/errors.js +4 -5
  32. package/lib/cjs/types/action.d.ts +22 -0
  33. package/lib/cjs/utils.d.ts +2 -2
  34. package/lib/cjs/utils.js +2 -4
  35. package/lib/esm/abis.d.ts +1 -1
  36. package/lib/esm/abis.js +1 -1
  37. package/lib/esm/actions/blue/repayWithdrawCollateral.js +1 -0
  38. package/lib/esm/actions/blue/supply.js +2 -0
  39. package/lib/esm/actions/blue/supplyCollateralBorrow.js +2 -0
  40. package/lib/esm/actions/blue/withdraw.js +4 -0
  41. package/lib/esm/blue/abis.d.ts +1 -1
  42. package/lib/esm/blue/abis.js +1 -1
  43. package/lib/esm/blue/entities.d.ts +4 -4
  44. package/lib/esm/blue/entities.js +2 -2
  45. package/lib/esm/blue/errors.d.ts +2 -2
  46. package/lib/esm/blue/errors.js +2 -2
  47. package/lib/esm/blue/fetch.d.ts +2 -2
  48. package/lib/esm/blue/fetch.js +2 -2
  49. package/lib/esm/blue/utils.d.ts +1 -1
  50. package/lib/esm/blue/utils.js +1 -1
  51. package/lib/esm/entities/index.d.ts +4 -4
  52. package/lib/esm/entities/index.js +2 -2
  53. package/lib/esm/entities/midnight/types.d.ts +4 -3
  54. package/lib/esm/entities/vaultV2/vaultV2.d.ts +9 -33
  55. package/lib/esm/entities/vaultV2/vaultV2.js +1 -33
  56. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -5
  57. package/lib/esm/entities/vaultV2BlueReallocationData.js +3 -9
  58. package/lib/esm/errors.d.ts +4 -4
  59. package/lib/esm/errors.js +4 -4
  60. package/lib/esm/fetch.d.ts +2 -2
  61. package/lib/esm/fetch.js +2 -2
  62. package/lib/esm/midnight/errors.d.ts +1 -2
  63. package/lib/esm/midnight/errors.js +1 -2
  64. package/lib/esm/types/action.d.ts +22 -0
  65. package/lib/esm/utils.d.ts +2 -2
  66. package/lib/esm/utils.js +2 -2
  67. package/package.json +6 -6
@@ -1,13 +1,13 @@
1
- export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MidnightAdapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition,
1
+ export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  IPreLiquidationParams as IBluePreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MidnightAdapter, IVaultV2MidnightAdapterAccrualMarket, IVaultV2MidnightAdapterCollateralParams, IVaultV2MidnightAdapterMarket, IVaultV2MidnightAdapterMarketData, IVaultV2MidnightAdapterMarketState, IVaultV2MidnightAdapterPosition, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, VaultV2MidnightAdapterAccrualMarket, VaultV2MidnightAdapterMarketData, } from "@morpho-org/blue-sdk";
6
- export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MidnightAdapter, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
5
+ IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
6
+ export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
7
7
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
8
8
  PreLiquidationParams as BluePreLiquidationParams,
9
9
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
10
- PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MidnightAdapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
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
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";
@@ -1,8 +1,8 @@
1
- export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MidnightAdapter, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
1
+ export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  PreLiquidationParams as BluePreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MidnightAdapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
5
+ 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";
6
6
  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";
7
7
  export { MorphoBlue } from "./blue/index.js";
8
8
  export { MorphoMidnight, } from "./midnight/index.js";
@@ -155,9 +155,10 @@ export interface MidnightPositionHealthParams {
155
155
  /** Owner-bound snapshot returned by `getPositionData`. */
156
156
  readonly positionData: AccrualPosition;
157
157
  /** Values from `price()` on each `marketData.params.collateralParams[i].oracle`,
158
- * indexed like `positionData.collateral` and scaled by `ORACLE_PRICE_SCALE`. An empty array is
159
- * safe only when the SDK's conservative post-operation debt is zero, such as after a `full` repay,
160
- * a repayment units target covering `positionData.debt`, or `minUnits`/`repay.assets` covering it.
158
+ * indexed like `positionData.collateral` and scaled by `ORACLE_PRICE_SCALE`. Borrow methods always
159
+ * need prices. `takeRepayWithdrawCollateral` and `repayWithdrawCollateral` need them only when
160
+ * `collateralWithdrawals` is non-empty and the SDK's conservative post-operation debt is positive;
161
+ * otherwise an empty array is safe.
161
162
  */
162
163
  readonly collateralPrices: readonly bigint[];
163
164
  }
@@ -69,9 +69,8 @@ export interface VaultV2Actions {
69
69
  * owner is consumed and none was passed explicitly.
70
70
  * @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the
71
71
  * explicit Permit2 nonce is consumed.
72
- * @throws {InputExceedsMaxError} when funding or the deadline exceeds uint256, when the vault's
73
- * liquidity adapter is a Midnight adapter (it cannot receive vault allocations, so no deposit
74
- * fits and `max` is `0n`), or from `getRequirements()` when the Permit2 nonce exceeds uint256.
72
+ * @throws {InputExceedsMaxError} when funding or the deadline exceeds uint256, or from
73
+ * `getRequirements()` when the Permit2 nonce exceeds uint256.
75
74
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
76
75
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
77
76
  * @throws {BundlesPermitMismatchError} from `buildTx()` when the signature's spender, amount or
@@ -154,9 +153,7 @@ export interface VaultV2Actions {
154
153
  * @throws {NonPositiveInputError} when `amount` or the computed share cap is not positive.
155
154
  * @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
156
155
  * at any `getRequirements()` call.
157
- * @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256 at handle creation,
158
- * or when the vault's liquidity adapter is a Midnight adapter and `amount` exceeds the vault's
159
- * idle assets.
156
+ * @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256 at handle creation.
160
157
  * @throws {NegativeInputError} when `referralFeePct` or `slippageTolerance` is negative.
161
158
  * @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
162
159
  * @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no nonzero recipient.
@@ -221,24 +218,7 @@ export interface VaultV2Actions {
221
218
  * @throws {NonPositiveInputError} when `shares` is not positive.
222
219
  * @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
223
220
  * requirement resolution.
224
- * @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256, or from
225
- * `getRequirements()` when the vault's liquidity adapter is a Midnight adapter and `shares`
226
- * are worth more than the vault's idle assets.
227
- * @throws {UnknownBlueFactory} from `getRequirements()` when the configured chain has no VaultV2 factory.
228
- * @throws {UnknownBlueOfFactory} from `getRequirements()` when the vault is not a VaultV2 from the
229
- * configured factory.
230
- * @throws {UnsupportedBlueVaultV2AdapterError} from `getRequirements()` when the vault or one of its
231
- * adapters uses an unsupported adapter class.
232
- * @throws {UnsupportedBlueMarketIrmError} from `getRequirements()` when the vault's liquidity adapter
233
- * is a Midnight adapter and accrual projects an underlying market with positive debt that uses an
234
- * unsupported IRM.
235
- * @throws {UnknownBlueMarketAllocationError} from `getRequirements()` when the vault's liquidity
236
- * adapter is a Midnight adapter and accrual meets a nested Vault V1 withdraw queue market without
237
- * allocation data.
238
- * @throws {InvalidMidnightPositionLossFactorError} from `getRequirements()` when the vault's liquidity
239
- * adapter is a Midnight adapter and accrual meets a market loss factor below a position's.
240
- * @throws {InvalidMidnightPositionAccrualStateError} from `getRequirements()` when the vault's
241
- * liquidity adapter is a Midnight adapter and accrual meets invalid Midnight position inputs.
221
+ * @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256.
242
222
  * @throws {NegativeInputError} when `referralFeePct` is negative.
243
223
  * @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD.
244
224
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no non-zero recipient.
@@ -246,7 +226,7 @@ export interface VaultV2Actions {
246
226
  * @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
247
227
  * @throws {MissingContractCodeError} from `getRequirements()` when a fixed bundles or protocol
248
228
  * contract has no code at its registered address.
249
- * @throws {viem.BaseError} from `getRequirements()` when a vault-state, allowance, nonce, `eth_chainId`, or
229
+ * @throws {viem.BaseError} from `getRequirements()` when an allowance, nonce, `eth_chainId`, or
250
230
  * `eth_getCode` read fails.
251
231
  * @throws {UnknownTokenError} from `getRequirements()` when the share token fetched by
252
232
  * `getData()` has unusable decimals.
@@ -323,11 +303,9 @@ export interface VaultV2Actions {
323
303
  * @throws {InputExceedsMaxError} when `deadline` exceeds `uint256`.
324
304
  * @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
325
305
  * requirement resolution.
326
- * @throws {VaultV2SingleAdapterRequiredError} when the vault does not have one adapter, including
327
- * a vault that mixes Blue and Midnight adapters.
306
+ * @throws {VaultV2SingleAdapterRequiredError} when the vault does not have one adapter.
328
307
  * @throws {AdapterNotPartOfVaultError} when `adapter` is not the vault's adapter.
329
- * @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2,
330
- * including a Midnight adapter.
308
+ * @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2.
331
309
  * @throws {InKindRedeemCoverageError} when the deduplicated list cannot cover the exit.
332
310
  * @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
333
311
  * @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
@@ -451,11 +429,9 @@ export interface VaultV2Actions {
451
429
  * @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
452
430
  * requirement resolution.
453
431
  * @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds the SDK maximum.
454
- * @throws {VaultV2SingleAdapterRequiredError} when the vault does not have exactly one adapter,
455
- * including a vault that mixes Blue and Midnight adapters.
432
+ * @throws {VaultV2SingleAdapterRequiredError} when the vault does not have exactly one adapter.
456
433
  * @throws {AdapterNotPartOfVaultError} when `adapter` is not the vault's adapter.
457
- * @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2,
458
- * including a Midnight adapter.
434
+ * @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2.
459
435
  * @throws {VaultV2UnsupportedLiquidityAdapterError} when the vault routes liquidity through
460
436
  * another adapter.
461
437
  * @throws {VaultV2UndecodableLiquidityDataError} when the vault's `liquidityData` does not decode
@@ -16,11 +16,6 @@ import { getBundlesTokenRequirements } from "../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 = Time.s.from.y(1n);
19
- /**
20
- * Midnight adapters revert vault-initiated `allocate` and `deallocate` (`SelfAllocationOnly`), so a
21
- * vault routing liquidity through one accepts no deposit and serves exits from idle assets only.
22
- */
23
- const isMidnightLiquidityAdapter = (vaultData) => vaultData.accrualLiquidityAdapter?.type === "VaultV2MidnightAdapter";
24
19
  /** Binds a viem client to a Vault V2 vault's action builders. */
25
20
  export class MorphoVaultV2 {
26
21
  client;
@@ -84,13 +79,6 @@ export class MorphoVaultV2 {
84
79
  // The native path must target the chain's registered wrapped-native asset.
85
80
  validateNativeVaultAsset(this.chainId, vaultAsset);
86
81
  }
87
- if (isMidnightLiquidityAdapter(vaultData)) {
88
- throw new InputExceedsMaxError({
89
- field: funding.value > 0n ? "nativeAmount" : "amount",
90
- value: funding.assets,
91
- max: 0n,
92
- });
93
- }
94
82
  const referralFeeAssets = getBundlesReferralFeeAssets(funding.assets, common.referralFeePct);
95
83
  const maxSharePrice = computeVaultMaxSharePrice({
96
84
  vaultData,
@@ -174,14 +162,6 @@ export class MorphoVaultV2 {
174
162
  throw new NonPositiveInputError("amount", amount);
175
163
  // Reject values outside the ABI range before resolving any requirements.
176
164
  validateUint256Field("amount", amount);
177
- if (isMidnightLiquidityAdapter(vaultData) &&
178
- amount > vaultData.assetBalance) {
179
- throw new InputExceedsMaxError({
180
- field: "amount",
181
- value: amount,
182
- max: vaultData.assetBalance,
183
- });
184
- }
185
165
  const createdAt = Time.timestamp();
186
166
  const deadline = params.deadline ?? createdAt + Time.s.from.h(2n);
187
167
  if (deadline <= createdAt)
@@ -272,20 +252,8 @@ export class MorphoVaultV2 {
272
252
  if (deadline <= now)
273
253
  throw new ExpiredDeadlineError(deadline, now);
274
254
  await this.assertWriteTargets(["bundles.vaultBundlesV1"]);
275
- const vaultData = await this.getData();
276
- if (isMidnightLiquidityAdapter(vaultData)) {
277
- // Onchain redeem accrues interest before converting shares to assets.
278
- const { vault: accrued } = vaultData.accrueInterest(now);
279
- if (accrued.toAssets(shares) > accrued.assetBalance) {
280
- throw new InputExceedsMaxError({
281
- field: "shares",
282
- value: shares,
283
- max: accrued.toShares(accrued.assetBalance),
284
- });
285
- }
286
- }
287
255
  return getVaultBundlesSharesRequirements(this.client.viemClient, {
288
- vaultData,
256
+ vaultData: await this.getData(),
289
257
  version: "vaultV2",
290
258
  owner: userAddress,
291
259
  chainId: this.chainId,
@@ -39,9 +39,8 @@ export interface InputVaultV2BlueReallocationData {
39
39
  /**
40
40
  * Immutable-by-convention state container for Vault V2 BluePublicAllocator simulations.
41
41
  *
42
- * Constructor inputs are cloned, except Midnight adapter snapshots: those are
43
- * shared by reference and must be treated as read-only. Every simulated
44
- * reallocation returns a new instance. Planning keeps the transaction-scoped `firstTotalAssets`
42
+ * Constructor inputs are cloned. Every simulated reallocation returns a new
43
+ * instance. Planning keeps the transaction-scoped `firstTotalAssets`
45
44
  * denominator outside the durable snapshot while applying reallocations in
46
45
  * contract order. Penalty donations update simulated vault accounting but are
47
46
  * excluded from same-plan idle liquidity so round-up dust cannot create
@@ -101,8 +100,7 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
101
100
  /**
102
101
  * Clones the complete simulation snapshot.
103
102
  *
104
- * @returns A deep clone of this simulation state. Midnight adapter snapshots are
105
- * shared by reference and must be treated as read-only.
103
+ * @returns A deep clone of this simulation state.
106
104
  * @example
107
105
  * ```ts
108
106
  * import { markets } from "@morpho-org/morpho-test";
@@ -75,10 +75,6 @@ const cloneAccrualVault = (vault, markets) => new AccrualVault({
75
75
  position: clonePosition(position, markets),
76
76
  })));
77
77
  const cloneAdapter = (adapter, markets) => {
78
- // BluePublicAllocator never moves Midnight liquidity, and reallocation never mutates a Midnight
79
- // adapter, so its read-only snapshot is shared as-is.
80
- if (adapter.type === "VaultV2MidnightAdapter")
81
- return adapter;
82
78
  const base = {
83
79
  address: adapter.address,
84
80
  parentVault: adapter.parentVault,
@@ -126,9 +122,8 @@ const cloneVault = (vault, { markets, adapterKeysToClone, }) => {
126
122
  /**
127
123
  * Immutable-by-convention state container for Vault V2 BluePublicAllocator simulations.
128
124
  *
129
- * Constructor inputs are cloned, except Midnight adapter snapshots: those are
130
- * shared by reference and must be treated as read-only. Every simulated
131
- * reallocation returns a new instance. Planning keeps the transaction-scoped `firstTotalAssets`
125
+ * Constructor inputs are cloned. Every simulated reallocation returns a new
126
+ * instance. Planning keeps the transaction-scoped `firstTotalAssets`
132
127
  * denominator outside the durable snapshot while applying reallocations in
133
128
  * contract order. Penalty donations update simulated vault accounting but are
134
129
  * excluded from same-plan idle liquidity so round-up dust cannot create
@@ -250,8 +245,7 @@ export class VaultV2BlueReallocationData {
250
245
  /**
251
246
  * Clones the complete simulation snapshot.
252
247
  *
253
- * @returns A deep clone of this simulation state. Midnight adapter snapshots are
254
- * shared by reference and must be treated as read-only.
248
+ * @returns A deep clone of this simulation state.
255
249
  * @example
256
250
  * ```ts
257
251
  * import { markets } from "@morpho-org/morpho-test";
@@ -1,7 +1,7 @@
1
- export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, InvalidVaultV2MidnightAdapterMarketsError as InvalidBlueVaultV2MidnightAdapterMarketsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
1
+ export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
4
- export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnresolvedBlockNumberError as BlueUnresolvedBlockNumberError, 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, 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";
4
+ export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
5
+ 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
- export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, InvalidPositionAccrualStateError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
7
+ export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
package/lib/esm/errors.js CHANGED
@@ -1,6 +1,6 @@
1
- export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, InvalidVaultV2MidnightAdapterMarketsError as InvalidBlueVaultV2MidnightAdapterMarketsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
1
+ export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
4
- export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnresolvedBlockNumberError as BlueUnresolvedBlockNumberError, 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, 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
- export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, InvalidPositionAccrualStateError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
4
+ export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
5
+ 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
+ export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
@@ -1,6 +1,6 @@
1
- export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MidnightAdapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
1
+ export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  fetchPreLiquidationParams as fetchBluePreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MidnightAdapter, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
5
+ fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
6
6
  export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
package/lib/esm/fetch.js CHANGED
@@ -1,6 +1,6 @@
1
- export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MidnightAdapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
1
+ export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  fetchPreLiquidationParams as fetchBluePreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MidnightAdapter, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
5
+ fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
6
6
  export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
@@ -1,2 +1 @@
1
- export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
2
- export { InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, } from "@morpho-org/morpho-ts";
1
+ export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
@@ -1,2 +1 @@
1
- export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
2
- export { InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, } from "@morpho-org/morpho-ts";
1
+ export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
@@ -258,6 +258,8 @@ export interface BlueSupplyAction extends BaseAction<"blueSupply", {
258
258
  readonly nativeAmount?: bigint;
259
259
  readonly referralFeePct: bigint;
260
260
  readonly referralFeeRecipient: Address;
261
+ /** Fee deducted from `assets` before supplying: floor(assets * referralFeePct / WAD). */
262
+ readonly referralFeeAssets: bigint;
261
263
  readonly deadline: bigint;
262
264
  }> {
263
265
  }
@@ -271,6 +273,12 @@ export interface BlueWithdrawAction extends BaseAction<"blueWithdraw", {
271
273
  readonly reallocationPenaltyAssets: bigint;
272
274
  readonly referralFeePct: bigint;
273
275
  readonly referralFeeRecipient: Address;
276
+ /**
277
+ * Fee deducted from net withdrawal proceeds:
278
+ * floor((withdrawAssets - reallocationPenaltyAssets) * referralFeePct / WAD); omitted in
279
+ * exact-shares mode, where the received amount is resolved at execution.
280
+ */
281
+ readonly referralFeeAssets?: bigint;
274
282
  readonly deadline: bigint;
275
283
  }> {
276
284
  }
@@ -285,6 +293,12 @@ type BlueSupplyCollateralBorrowActionArgs = {
285
293
  readonly reallocationPenaltyAssets: bigint;
286
294
  readonly referralFeePct: bigint;
287
295
  readonly referralFeeRecipient: Address;
296
+ /**
297
+ * Fee deducted from the borrow leg's net proceeds:
298
+ * floor((borrowAssets - reallocationPenaltyAssets) * referralFeePct / WAD); zero when
299
+ * `borrowAssets` is zero. The collateral-supply leg carries no fee.
300
+ */
301
+ readonly referralFeeAssets: bigint;
288
302
  readonly deadline: bigint;
289
303
  };
290
304
  /** Metadata for a direct BlueBundlesV1 collateral supply. */
@@ -307,6 +321,14 @@ type BlueRepayWithdrawCollateralActionArgs = {
307
321
  readonly nativeAmount?: bigint;
308
322
  readonly referralFeePct: bigint;
309
323
  readonly referralFeeRecipient: Address;
324
+ /**
325
+ * Fee charged on top of the repaid assets, inside `maxRepayAssets`:
326
+ * floor(repayAssets * referralFeePct / (WAD - referralFeePct)); set only for an
327
+ * exact-assets repay (`repayAssets > 0n`), and omitted in exact-shares mode or
328
+ * when there is no repay leg, where the repaid amount is resolved at execution
329
+ * or never repaid.
330
+ */
331
+ readonly referralFeeAssets?: bigint;
310
332
  readonly deadline: bigint;
311
333
  };
312
334
  /** Metadata for a direct BlueBundlesV1 repayment. */
@@ -3,7 +3,7 @@ export { AdaptiveCurveIrmLib as BlueAdaptiveCurveIrmLib, CapacityLimitReason,
3
3
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
4
  defaultPreLiquidationParamsRegistry as blueDefaultPreLiquidationParamsRegistry,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
6
- getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2MidnightAdapterUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
6
+ getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
7
7
  export { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData as getBlueAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, MetaMorphoAction as BlueMetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
8
8
  export { EcrecoverRatifier as MidnightEcrecoverRatifier,
9
9
  /** @deprecated Use MidnightEcrecoverRatifier with a tagged tree. */
@@ -17,7 +17,7 @@ RatifierUtils as MidnightRatifierUtils, SetterRatifier as MidnightSetterRatifier
17
17
  /** @deprecated Use MidnightSetterRatifier with a tagged tree. */
18
18
  SetterRatifierUtils as MidnightSetterRatifierUtils, TakeAmountsLib as MidnightTakeAmountsLib, TickLib as MidnightTickLib, TreeUtils as MidnightTreeUtils, } from "@morpho-org/midnight-sdk";
19
19
  export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, } from "@morpho-org/morpho-ts";
20
- export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, MidnightPositionLib, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
20
+ export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
21
21
  export { validateClientChainId } from "./actions/requirements/validateClientChainId.js";
22
22
  export { addTransactionMetadata } from "./helpers/metadata.js";
23
23
  export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./helpers/previewVaultV2ForceWithdraw.js";
package/lib/esm/utils.js CHANGED
@@ -2,7 +2,7 @@ export { AdaptiveCurveIrmLib as BlueAdaptiveCurveIrmLib, CapacityLimitReason,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  defaultPreLiquidationParamsRegistry as blueDefaultPreLiquidationParamsRegistry,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2MidnightAdapterUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
5
+ getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
6
6
  export { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData as getBlueAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, MetaMorphoAction as BlueMetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
7
7
  export { EcrecoverRatifier as MidnightEcrecoverRatifier,
8
8
  /** @deprecated Use MidnightEcrecoverRatifier with a tagged tree. */
@@ -15,7 +15,7 @@ RateRatifierV1Utils as MidnightRateRatifierV1Utils, Ratifier as MidnightRatifier
15
15
  RatifierUtils as MidnightRatifierUtils, SetterRatifier as MidnightSetterRatifier,
16
16
  /** @deprecated Use MidnightSetterRatifier with a tagged tree. */
17
17
  SetterRatifierUtils as MidnightSetterRatifierUtils, TakeAmountsLib as MidnightTakeAmountsLib, TickLib as MidnightTickLib, TreeUtils as MidnightTreeUtils, } from "@morpho-org/midnight-sdk";
18
- export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, MidnightPositionLib, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
18
+ export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
19
19
  export { validateClientChainId } from "./actions/requirements/validateClientChainId.js";
20
20
  export { addTransactionMetadata } from "./helpers/metadata.js";
21
21
  export { previewVaultV2ForceWithdraw, } from "./helpers/previewVaultV2ForceWithdraw.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/morpho-sdk",
3
3
  "description": "Abstraction layer for Morpho's complexity.",
4
- "version": "8.2.0-next.0",
4
+ "version": "8.2.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -152,17 +152,17 @@
152
152
  "MIGRATION-v7-to-v8.md"
153
153
  ],
154
154
  "dependencies": {
155
- "@morpho-org/blue-sdk": "^8.1.0-next.0",
156
- "@morpho-org/blue-sdk-viem": "^7.1.0-next.0",
157
- "@morpho-org/midnight-sdk": "^2.2.0-next.0",
158
- "@morpho-org/morpho-ts": "^4.1.0-next.0"
155
+ "@morpho-org/blue-sdk": "^8.0.1",
156
+ "@morpho-org/blue-sdk-viem": "^7.0.0",
157
+ "@morpho-org/midnight-sdk": "^2.1.0",
158
+ "@morpho-org/morpho-ts": "^4.0.1"
159
159
  },
160
160
  "peerDependencies": {
161
161
  "viem": "^2.0.0"
162
162
  },
163
163
  "devDependencies": {
164
164
  "@morpho-org/morpho-test": "^4.1.0",
165
- "@morpho-org/test": "^2.12.0-next.0",
165
+ "@morpho-org/test": "^2.11.0",
166
166
  "fast-check": "^4.9.0",
167
167
  "typescript": "7.0.2",
168
168
  "viem": "^2.55.10",