@morpho-org/morpho-sdk 9.3.0 → 9.4.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 (40) hide show
  1. package/README.md +3 -1
  2. package/lib/cjs/abis.d.ts +2 -2
  3. package/lib/cjs/abis.js +4 -1
  4. package/lib/cjs/actions/blue/index.d.ts +1 -0
  5. package/lib/cjs/actions/blue/index.js +1 -0
  6. package/lib/cjs/actions/blue/withdrawBuyCallback.d.ts +60 -0
  7. package/lib/cjs/actions/blue/withdrawBuyCallback.js +79 -0
  8. package/lib/cjs/blue/abis.d.ts +1 -1
  9. package/lib/cjs/blue/abis.js +3 -1
  10. package/lib/cjs/entities/blue/blue.d.ts +81 -2
  11. package/lib/cjs/entities/blue/blue.js +85 -0
  12. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +5 -4
  13. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +15 -12
  14. package/lib/cjs/errors.d.ts +1 -1
  15. package/lib/cjs/errors.js +3 -1
  16. package/lib/cjs/midnight/abis.d.ts +1 -1
  17. package/lib/cjs/midnight/abis.js +2 -1
  18. package/lib/cjs/types/action.d.ts +15 -1
  19. package/lib/cjs/types/error.d.ts +34 -0
  20. package/lib/cjs/types/error.js +41 -1
  21. package/lib/esm/abis.d.ts +2 -2
  22. package/lib/esm/abis.js +2 -2
  23. package/lib/esm/actions/blue/index.d.ts +1 -0
  24. package/lib/esm/actions/blue/index.js +1 -0
  25. package/lib/esm/actions/blue/withdrawBuyCallback.d.ts +60 -0
  26. package/lib/esm/actions/blue/withdrawBuyCallback.js +75 -0
  27. package/lib/esm/blue/abis.d.ts +1 -1
  28. package/lib/esm/blue/abis.js +1 -1
  29. package/lib/esm/entities/blue/blue.d.ts +81 -2
  30. package/lib/esm/entities/blue/blue.js +87 -2
  31. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +5 -4
  32. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +15 -12
  33. package/lib/esm/errors.d.ts +1 -1
  34. package/lib/esm/errors.js +1 -1
  35. package/lib/esm/midnight/abis.d.ts +1 -1
  36. package/lib/esm/midnight/abis.js +1 -1
  37. package/lib/esm/types/action.d.ts +15 -1
  38. package/lib/esm/types/error.d.ts +34 -0
  39. package/lib/esm/types/error.js +35 -0
  40. package/package.json +5 -5
@@ -1 +1 @@
1
- export { blueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi, ecrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi, rateRatifierV1Abi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
1
+ export { blueBuyCallbackAbi, blueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi, ecrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi, rateRatifierV1Abi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
@@ -1 +1 @@
1
- export { blueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi, ecrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi, rateRatifierV1Abi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
1
+ export { blueBuyCallbackAbi, blueBuyCallbackFactoryAbi, ecrecoverAuthorizerAbi, ecrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, midnightEventsAbi, priceRatifierV1Abi, rateRatifierV1Abi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
@@ -282,6 +282,20 @@ export interface BlueWithdrawAction extends BaseAction<"blueWithdraw", {
282
282
  readonly deadline: bigint;
283
283
  }> {
284
284
  }
285
+ /**
286
+ * Metadata for a direct Morpho Blue withdrawal of a BlueBuyCallback's whole supply position,
287
+ * sent by the callback's owner.
288
+ */
289
+ export interface BlueWithdrawBuyCallbackAction extends BaseAction<"blueWithdrawBuyCallback", {
290
+ readonly market: Hex;
291
+ /** Supply shares burned: the callback's whole position. */
292
+ readonly shares: bigint;
293
+ /** BlueBuyCallback whose supply position is withdrawn. */
294
+ readonly onBehalf: Address;
295
+ /** Account receiving the withdrawn loan assets: the callback's owner. */
296
+ readonly receiver: Address;
297
+ }> {
298
+ }
285
299
  type BlueSupplyCollateralBorrowActionArgs = {
286
300
  readonly market: Hex;
287
301
  readonly collateralAssets: bigint;
@@ -510,7 +524,7 @@ export interface MidnightCancelAndMakeAction extends BaseAction<"midnightCancelA
510
524
  * VaultV2, Blue, and Midnight flows. The `type` tag discriminates the union so
511
525
  * consumers can `switch` exhaustively on it.
512
526
  */
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;
527
+ export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueWithdrawAction | BlueWithdrawBuyCallbackAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightTakeWithdrawAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MidnightWithdrawCollateralAction | MidnightRedeemAction | MidnightTakeRepayWithdrawCollateralAction | MidnightRepayWithdrawCollateralAction | MidnightCancelAndMakeAction;
514
528
  /**
515
529
  * Describes a single, immutable, deep-frozen transaction to submit on-chain:
516
530
  * the target `to`, native `value`, encoded call `data`, and the originating
@@ -1475,6 +1475,40 @@ export declare class WithdrawSharesExceedSupplyError extends Error {
1475
1475
  market: string;
1476
1476
  });
1477
1477
  }
1478
+ /** Thrown when a Blue withdrawal finds no supply shares to withdraw for the position owner. */
1479
+ export declare class EmptyBlueSupplyPositionError extends Error {
1480
+ constructor(params: {
1481
+ market: string;
1482
+ user: string;
1483
+ });
1484
+ }
1485
+ /** Thrown when a Blue withdrawal needs more assets than the market's available liquidity. */
1486
+ export declare class InsufficientBlueLiquidityError extends Error {
1487
+ constructor(params: {
1488
+ market: string;
1489
+ assets: bigint;
1490
+ liquidity: bigint;
1491
+ });
1492
+ }
1493
+ /** Thrown when an address is not a BlueBuyCallback created by the chain's registered factory. */
1494
+ export declare class NotBlueBuyCallbackError extends Error {
1495
+ constructor(callback: string);
1496
+ }
1497
+ /** Thrown when a BlueBuyCallback's `OWNER()` is not the account withdrawing its Blue position. */
1498
+ export declare class BlueBuyCallbackOwnerMismatchError extends Error {
1499
+ constructor(params: {
1500
+ callback: string;
1501
+ owner: string;
1502
+ userAddress: string;
1503
+ });
1504
+ }
1505
+ /** Thrown when Morpho Blue does not authorize an account to withdraw a BlueBuyCallback's position. */
1506
+ export declare class BlueBuyCallbackUnauthorizedError extends Error {
1507
+ constructor(params: {
1508
+ callback: string;
1509
+ userAddress: string;
1510
+ });
1511
+ }
1478
1512
  /**
1479
1513
  * Thrown when a Vault V2 reallocation planner receives a withdraw `amount` greater
1480
1514
  * than the target market's current `totalSupplyAssets` — the post-withdraw
@@ -1771,6 +1771,41 @@ export class WithdrawSharesExceedSupplyError extends Error {
1771
1771
  this.name = "WithdrawSharesExceedSupplyError";
1772
1772
  }
1773
1773
  }
1774
+ /** Thrown when a Blue withdrawal finds no supply shares to withdraw for the position owner. */
1775
+ export class EmptyBlueSupplyPositionError extends Error {
1776
+ constructor(params) {
1777
+ super(`Supply position of "${params.user}" is empty on market "${params.market}". Refresh the position data or skip the withdrawal.`);
1778
+ this.name = "EmptyBlueSupplyPositionError";
1779
+ }
1780
+ }
1781
+ /** Thrown when a Blue withdrawal needs more assets than the market's available liquidity. */
1782
+ export class InsufficientBlueLiquidityError extends Error {
1783
+ constructor(params) {
1784
+ super(`Blue liquidity is insufficient on market "${params.market}": assets "${params.assets}", liquidity "${params.liquidity}". Try again when liquidity returns.`);
1785
+ this.name = "InsufficientBlueLiquidityError";
1786
+ }
1787
+ }
1788
+ /** Thrown when an address is not a BlueBuyCallback created by the chain's registered factory. */
1789
+ export class NotBlueBuyCallbackError extends Error {
1790
+ constructor(callback) {
1791
+ super(`Address "${callback}" is not a BlueBuyCallback created by the registered factory. Pass a callback created by midnightBlueBuyCallbackFactory.`);
1792
+ this.name = "NotBlueBuyCallbackError";
1793
+ }
1794
+ }
1795
+ /** Thrown when a BlueBuyCallback's `OWNER()` is not the account withdrawing its Blue position. */
1796
+ export class BlueBuyCallbackOwnerMismatchError extends Error {
1797
+ constructor(params) {
1798
+ super(`BlueBuyCallback "${params.callback}" is owned by "${params.owner}", not "${params.userAddress}". Withdraw from the owner's account.`);
1799
+ this.name = "BlueBuyCallbackOwnerMismatchError";
1800
+ }
1801
+ }
1802
+ /** Thrown when Morpho Blue does not authorize an account to withdraw a BlueBuyCallback's position. */
1803
+ export class BlueBuyCallbackUnauthorizedError extends Error {
1804
+ constructor(params) {
1805
+ super(`"${params.userAddress}" is not authorized on Morpho Blue to withdraw for BlueBuyCallback "${params.callback}". Call setAuthorization on the callback from its owner, then retry.`);
1806
+ this.name = "BlueBuyCallbackUnauthorizedError";
1807
+ }
1808
+ }
1774
1809
  /**
1775
1810
  * Thrown when a Vault V2 reallocation planner receives a withdraw `amount` greater
1776
1811
  * than the target market's current `totalSupplyAssets` — the post-withdraw
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.3.0",
4
+ "version": "9.4.0",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -154,10 +154,10 @@
154
154
  "DEAD-SHARE-PROTECTION.md"
155
155
  ],
156
156
  "dependencies": {
157
- "@morpho-org/blue-sdk": "^8.1.0",
158
- "@morpho-org/blue-sdk-viem": "^7.2.0",
159
- "@morpho-org/midnight-sdk": "^2.3.0",
160
- "@morpho-org/morpho-ts": "^4.1.0"
157
+ "@morpho-org/blue-sdk": "^8.2.0",
158
+ "@morpho-org/blue-sdk-viem": "^7.3.0",
159
+ "@morpho-org/midnight-sdk": "^2.4.0",
160
+ "@morpho-org/morpho-ts": "^4.2.0"
161
161
  },
162
162
  "peerDependencies": {
163
163
  "viem": "^2.0.0"