@morpho-org/morpho-sdk 9.2.0 → 9.3.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 (44) hide show
  1. package/README.md +4 -4
  2. package/lib/cjs/actions/midnight/index.d.ts +1 -0
  3. package/lib/cjs/actions/midnight/index.js +1 -0
  4. package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +50 -0
  5. package/lib/cjs/actions/midnight/withdrawCollateral.js +105 -0
  6. package/lib/cjs/entities/blue/blue.d.ts +4 -7
  7. package/lib/cjs/entities/blue/blue.js +0 -3
  8. package/lib/cjs/entities/index.d.ts +1 -1
  9. package/lib/cjs/entities/midnight/midnight.d.ts +57 -12
  10. package/lib/cjs/entities/midnight/midnight.js +102 -12
  11. package/lib/cjs/entities/midnight/publication.d.ts +2 -1
  12. package/lib/cjs/entities/midnight/publication.js +44 -64
  13. package/lib/cjs/entities/midnight/types.d.ts +8 -0
  14. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +0 -8
  15. package/lib/cjs/entities/vaultV1/vaultV1.js +0 -4
  16. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +0 -4
  17. package/lib/cjs/entities/vaultV2/vaultV2.js +0 -3
  18. package/lib/cjs/helpers/deadShares.d.ts +5 -4
  19. package/lib/cjs/helpers/deadShares.js +5 -4
  20. package/lib/cjs/types/action.d.ts +10 -1
  21. package/lib/cjs/types/error.d.ts +1 -6
  22. package/lib/cjs/types/error.js +1 -6
  23. package/lib/esm/actions/midnight/index.d.ts +1 -0
  24. package/lib/esm/actions/midnight/index.js +1 -0
  25. package/lib/esm/actions/midnight/withdrawCollateral.d.ts +50 -0
  26. package/lib/esm/actions/midnight/withdrawCollateral.js +101 -0
  27. package/lib/esm/entities/blue/blue.d.ts +4 -7
  28. package/lib/esm/entities/blue/blue.js +0 -3
  29. package/lib/esm/entities/index.d.ts +1 -1
  30. package/lib/esm/entities/midnight/midnight.d.ts +57 -12
  31. package/lib/esm/entities/midnight/midnight.js +104 -14
  32. package/lib/esm/entities/midnight/publication.d.ts +2 -1
  33. package/lib/esm/entities/midnight/publication.js +45 -65
  34. package/lib/esm/entities/midnight/types.d.ts +8 -0
  35. package/lib/esm/entities/vaultV1/vaultV1.d.ts +0 -8
  36. package/lib/esm/entities/vaultV1/vaultV1.js +0 -4
  37. package/lib/esm/entities/vaultV2/vaultV2.d.ts +0 -4
  38. package/lib/esm/entities/vaultV2/vaultV2.js +0 -3
  39. package/lib/esm/helpers/deadShares.d.ts +5 -4
  40. package/lib/esm/helpers/deadShares.js +5 -4
  41. package/lib/esm/types/action.d.ts +10 -1
  42. package/lib/esm/types/error.d.ts +1 -6
  43. package/lib/esm/types/error.js +1 -6
  44. package/package.json +1 -1
@@ -84,15 +84,16 @@ export function validateVaultV1DeadShares(vault, path = []) {
84
84
  /**
85
85
  * Checks a Vault V2 against the dead-deposit rule: at least `MIN_DEAD_SHARES` shares at
86
86
  * `DEAD_ADDRESS` worth at least `MIN_VAULT_V2_DEAD_ASSETS` assets, a share price above
87
- * `1 / (10 * virtualShares)`, and every Blue market or Vault V1 it can allocate to (non-zero
88
- * absolute cap) passing its own rule. Zero-cap entries are skipped.
87
+ * `1 / (10 * virtualShares)`, and each currently allocated Blue market or Vault V1 with a non-zero
88
+ * absolute cap passing its own rule. A market with a positive cap but no current allocation is not
89
+ * checked; a later reallocation can reach it.
89
90
  *
90
91
  * @param vault - Fetched vault snapshot with its adapters and `absoluteCaps`.
91
92
  * @param path - Vaults leading to this vault, outermost first; empty for a direct deposit.
92
- * @returns Nothing; returns normally when the vault and everything it can allocate to pass.
93
+ * @returns Nothing; returns normally when the vault and its checked allocations pass.
93
94
  * @throws {MissingDeadSharesDataError} when a dead-share field, an adapter cap, or the data of an
94
95
  * adapter the SDK cannot hydrate is missing.
95
- * @throws {InsufficientDeadSharesError} when the vault or an allocatable market or Vault V1 fails the rule.
96
+ * @throws {InsufficientDeadSharesError} when the vault or a checked market or Vault V1 fails the rule.
96
97
  * @example
97
98
  * ```ts
98
99
  * import { validateVaultV2DeadShares } from "@morpho-org/morpho-sdk";
@@ -435,6 +435,15 @@ export interface MidnightSupplyCollateralAction extends BaseAction<"midnightSupp
435
435
  readonly onBehalf: Address;
436
436
  }> {
437
437
  }
438
+ /** Metadata for a direct Midnight collateral withdrawal transaction. */
439
+ export interface MidnightWithdrawCollateralAction extends BaseAction<"midnightWithdrawCollateral", {
440
+ readonly market: Hex;
441
+ readonly collateralIndex: bigint;
442
+ readonly assets: bigint;
443
+ readonly onBehalf: Address;
444
+ readonly receiver: Address;
445
+ }> {
446
+ }
438
447
  /** Metadata for a direct Midnight credit redemption transaction. */
439
448
  export interface MidnightRedeemAction extends BaseAction<"midnightRedeem", {
440
449
  readonly market: Hex;
@@ -501,7 +510,7 @@ export interface MidnightCancelAndMakeAction extends BaseAction<"midnightCancelA
501
510
  * VaultV2, Blue, and Midnight flows. The `type` tag discriminates the union so
502
511
  * consumers can `switch` exhaustively on it.
503
512
  */
504
- export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueWithdrawAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightTakeWithdrawAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MidnightRedeemAction | MidnightTakeRepayWithdrawCollateralAction | MidnightRepayWithdrawCollateralAction | MidnightCancelAndMakeAction;
513
+ export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueWithdrawAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightTakeWithdrawAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MidnightWithdrawCollateralAction | MidnightRedeemAction | MidnightTakeRepayWithdrawCollateralAction | MidnightRepayWithdrawCollateralAction | MidnightCancelAndMakeAction;
505
514
  /**
506
515
  * Describes a single, immutable, deep-frozen transaction to submit on-chain:
507
516
  * the target `to`, native `value`, encoded call `data`, and the originating
@@ -1321,12 +1321,7 @@ export declare class MidnightOfferCallbackDataMismatchError extends Error {
1321
1321
  readonly actualCallbackData: Hex;
1322
1322
  });
1323
1323
  }
1324
- /**
1325
- * Thrown when loan assets would be parked in a Morpho Blue market with no existing supply.
1326
- *
1327
- * @deprecated `supplyBlueMakeLend` now throws `InsufficientDeadSharesError` or
1328
- * `MissingDeadSharesDataError` instead; kept exported so existing `instanceof` checks compile.
1329
- */
1324
+ /** Thrown when loan assets would be parked in a Morpho Blue market with no existing supply. */
1330
1325
  export declare class EmptyBlueParkingMarketError extends Error {
1331
1326
  constructor(params: {
1332
1327
  readonly marketId: MarketId;
@@ -1585,12 +1585,7 @@ export class MidnightOfferCallbackDataMismatchError extends Error {
1585
1585
  this.name = "MidnightOfferCallbackDataMismatchError";
1586
1586
  }
1587
1587
  }
1588
- /**
1589
- * Thrown when loan assets would be parked in a Morpho Blue market with no existing supply.
1590
- *
1591
- * @deprecated `supplyBlueMakeLend` now throws `InsufficientDeadSharesError` or
1592
- * `MissingDeadSharesDataError` instead; kept exported so existing `instanceof` checks compile.
1593
- */
1588
+ /** Thrown when loan assets would be parked in a Morpho Blue market with no existing supply. */
1594
1589
  export class EmptyBlueParkingMarketError extends Error {
1595
1590
  constructor(params) {
1596
1591
  super(`Morpho Blue market "${params.marketId}" has no supply shares. Parking assets in an empty market is exposed to supply-share-price inflation; choose a market with existing supply.`);
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": "9.2.0",
4
+ "version": "9.3.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "repository": {
7
7
  "type": "git",