@morpho-org/morpho-sdk 9.3.0 → 9.5.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 (75) hide show
  1. package/MIGRATION-v5-to-v6.md +7 -0
  2. package/MIGRATION-v7-to-v8.md +7 -0
  3. package/MIGRATION-v8-to-v9.md +7 -0
  4. package/README.md +9 -5
  5. package/lib/cjs/abis.d.ts +2 -2
  6. package/lib/cjs/abis.js +4 -1
  7. package/lib/cjs/actions/blue/index.d.ts +1 -0
  8. package/lib/cjs/actions/blue/index.js +1 -0
  9. package/lib/cjs/actions/blue/withdrawBuyCallback.d.ts +60 -0
  10. package/lib/cjs/actions/blue/withdrawBuyCallback.js +79 -0
  11. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -0
  12. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -1
  13. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +4 -1
  14. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -1
  15. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +1 -0
  16. package/lib/cjs/blue/abis.d.ts +1 -1
  17. package/lib/cjs/blue/abis.js +3 -1
  18. package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
  19. package/lib/cjs/client/morphoViemExtension.js +1 -1
  20. package/lib/cjs/entities/blue/blue.d.ts +88 -23
  21. package/lib/cjs/entities/blue/blue.js +89 -22
  22. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +21 -25
  23. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +50 -85
  24. package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +6 -3
  25. package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +2 -2
  26. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +5 -11
  27. package/lib/cjs/entities/vaultV1/vaultV1.js +3 -11
  28. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +5 -11
  29. package/lib/cjs/entities/vaultV2/vaultV2.js +3 -11
  30. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -0
  31. package/lib/cjs/entities/vaultV2BlueReallocationData.js +40 -4
  32. package/lib/cjs/errors.d.ts +1 -1
  33. package/lib/cjs/errors.js +3 -1
  34. package/lib/cjs/midnight/abis.d.ts +1 -1
  35. package/lib/cjs/midnight/abis.js +2 -1
  36. package/lib/cjs/types/action.d.ts +26 -5
  37. package/lib/cjs/types/action.js +1 -0
  38. package/lib/cjs/types/error.d.ts +42 -2
  39. package/lib/cjs/types/error.js +49 -3
  40. package/lib/esm/abis.d.ts +2 -2
  41. package/lib/esm/abis.js +2 -2
  42. package/lib/esm/actions/blue/index.d.ts +1 -0
  43. package/lib/esm/actions/blue/index.js +1 -0
  44. package/lib/esm/actions/blue/withdrawBuyCallback.d.ts +60 -0
  45. package/lib/esm/actions/blue/withdrawBuyCallback.js +75 -0
  46. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -0
  47. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -1
  48. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +4 -1
  49. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -1
  50. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +1 -0
  51. package/lib/esm/blue/abis.d.ts +1 -1
  52. package/lib/esm/blue/abis.js +1 -1
  53. package/lib/esm/client/morphoViemExtension.d.ts +1 -1
  54. package/lib/esm/client/morphoViemExtension.js +1 -1
  55. package/lib/esm/entities/blue/blue.d.ts +88 -23
  56. package/lib/esm/entities/blue/blue.js +91 -24
  57. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +21 -25
  58. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +52 -87
  59. package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +6 -3
  60. package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +2 -2
  61. package/lib/esm/entities/vaultV1/vaultV1.d.ts +5 -11
  62. package/lib/esm/entities/vaultV1/vaultV1.js +4 -12
  63. package/lib/esm/entities/vaultV2/vaultV2.d.ts +5 -11
  64. package/lib/esm/entities/vaultV2/vaultV2.js +4 -12
  65. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -0
  66. package/lib/esm/entities/vaultV2BlueReallocationData.js +40 -4
  67. package/lib/esm/errors.d.ts +1 -1
  68. package/lib/esm/errors.js +1 -1
  69. package/lib/esm/midnight/abis.d.ts +1 -1
  70. package/lib/esm/midnight/abis.js +1 -1
  71. package/lib/esm/types/action.d.ts +26 -5
  72. package/lib/esm/types/action.js +1 -0
  73. package/lib/esm/types/error.d.ts +42 -2
  74. package/lib/esm/types/error.js +43 -2
  75. package/package.json +5 -5
@@ -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
@@ -534,9 +548,9 @@ export type BundlesFundingArgs = {
534
548
  };
535
549
  /** Controls token requirements generated for a bundles-funded action. */
536
550
  export interface BundlesTokenRequirementsOptions {
537
- /** Prefer ERC-2612 when the funded token exposes a compatible nonce. */
551
+ /** Prefer ERC-2612 when the funded token exposes a compatible nonce; defaults to true when signatures are supported. */
538
552
  readonly useSimplePermit?: boolean;
539
- /** Explicit unused Permit2 SignatureTransfer unordered nonce; defaults to the lowest unused nonce. */
553
+ /** @deprecated Ignored. The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals. */
540
554
  readonly permit2Nonce?: bigint;
541
555
  }
542
556
  /** Mutually exclusive source amount accepted by a Vault V1 to Vault V2 migration. */
@@ -598,7 +612,10 @@ export interface PermitAction extends BaseAction<"permit", {
598
612
  */
599
613
  readonly typedData?: RequirementTypedData;
600
614
  }
601
- /** Signable Permit2 SignatureTransfer requirement for a fixed bundles token pull. */
615
+ /**
616
+ * Signable Permit2 SignatureTransfer requirement for a fixed bundles token pull.
617
+ * @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
618
+ */
602
619
  export interface Permit2SignatureTransferAction extends BaseAction<"permit2SignatureTransfer", {
603
620
  readonly spender: Address;
604
621
  readonly amount: bigint;
@@ -630,7 +647,10 @@ export interface Erc2612RequirementSignature {
630
647
  }
631
648
  /** A signed ERC-2612 permit requirement accepted by vault-share bundle calls. */
632
649
  export type PermitRequirementSignature = Erc2612RequirementSignature;
633
- /** A signed Permit2 SignatureTransfer requirement used by fixed bundles contracts. */
650
+ /**
651
+ * A signed Permit2 SignatureTransfer requirement used by fixed bundles contracts.
652
+ * @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
653
+ */
634
654
  export interface Permit2SignatureTransferRequirementSignature {
635
655
  readonly args: Readonly<PermitArgs>;
636
656
  readonly action: Permit2SignatureTransferAction;
@@ -860,6 +880,7 @@ export declare function isPermitSignature(signature: RequirementSignature): sign
860
880
  * const getPermit2Nonce = (signature: RequirementSignature): bigint | undefined =>
861
881
  * isPermit2SignatureTransferSignature(signature) ? signature.args.nonce : undefined;
862
882
  * ```
883
+ * @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
863
884
  */
864
885
  export declare function isPermit2SignatureTransferSignature(signature: RequirementSignature): signature is Permit2SignatureTransferRequirementSignature;
865
886
  /**
@@ -156,6 +156,7 @@ export function isPermitSignature(signature) {
156
156
  * const getPermit2Nonce = (signature: RequirementSignature): bigint | undefined =>
157
157
  * isPermit2SignatureTransferSignature(signature) ? signature.args.nonce : undefined;
158
158
  * ```
159
+ * @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
159
160
  */
160
161
  export function isPermit2SignatureTransferSignature(signature) {
161
162
  return signature.action.type === "permit2SignatureTransfer";
@@ -538,7 +538,10 @@ export declare class BundlesRequirementSignatureMismatchError extends Error {
538
538
  cause?: unknown;
539
539
  });
540
540
  }
541
- /** Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed. */
541
+ /**
542
+ * Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed.
543
+ * @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
544
+ */
542
545
  export declare class Permit2SignatureTransferNonceAlreadyUsedError extends Error {
543
546
  readonly owner: Address;
544
547
  readonly nonce: bigint;
@@ -548,7 +551,10 @@ export declare class Permit2SignatureTransferNonceAlreadyUsedError extends Error
548
551
  */
549
552
  constructor(owner: Address, nonce: bigint);
550
553
  }
551
- /** Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce. */
554
+ /**
555
+ * Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce.
556
+ * @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
557
+ */
552
558
  export declare class NoUnusedPermit2NonceError extends Error {
553
559
  readonly owner: Address;
554
560
  readonly startNonce: bigint;
@@ -1475,6 +1481,40 @@ export declare class WithdrawSharesExceedSupplyError extends Error {
1475
1481
  market: string;
1476
1482
  });
1477
1483
  }
1484
+ /** Thrown when a Blue withdrawal finds no supply shares to withdraw for the position owner. */
1485
+ export declare class EmptyBlueSupplyPositionError extends Error {
1486
+ constructor(params: {
1487
+ market: string;
1488
+ user: string;
1489
+ });
1490
+ }
1491
+ /** Thrown when a Blue withdrawal needs more assets than the market's available liquidity. */
1492
+ export declare class InsufficientBlueLiquidityError extends Error {
1493
+ constructor(params: {
1494
+ market: string;
1495
+ assets: bigint;
1496
+ liquidity: bigint;
1497
+ });
1498
+ }
1499
+ /** Thrown when an address is not a BlueBuyCallback created by the chain's registered factory. */
1500
+ export declare class NotBlueBuyCallbackError extends Error {
1501
+ constructor(callback: string);
1502
+ }
1503
+ /** Thrown when a BlueBuyCallback's `OWNER()` is not the account withdrawing its Blue position. */
1504
+ export declare class BlueBuyCallbackOwnerMismatchError extends Error {
1505
+ constructor(params: {
1506
+ callback: string;
1507
+ owner: string;
1508
+ userAddress: string;
1509
+ });
1510
+ }
1511
+ /** Thrown when Morpho Blue does not authorize an account to withdraw a BlueBuyCallback's position. */
1512
+ export declare class BlueBuyCallbackUnauthorizedError extends Error {
1513
+ constructor(params: {
1514
+ callback: string;
1515
+ userAddress: string;
1516
+ });
1517
+ }
1478
1518
  /**
1479
1519
  * Thrown when a Vault V2 reallocation planner receives a withdraw `amount` greater
1480
1520
  * than the target market's current `totalSupplyAssets` — the post-withdraw
@@ -600,7 +600,10 @@ export class BundlesRequirementSignatureMismatchError extends Error {
600
600
  this.name = "BundlesRequirementSignatureMismatchError";
601
601
  }
602
602
  }
603
- /** Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed. */
603
+ /**
604
+ * Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed.
605
+ * @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
606
+ */
604
607
  export class Permit2SignatureTransferNonceAlreadyUsedError extends Error {
605
608
  owner;
606
609
  nonce;
@@ -615,7 +618,10 @@ export class Permit2SignatureTransferNonceAlreadyUsedError extends Error {
615
618
  this.name = "Permit2SignatureTransferNonceAlreadyUsedError";
616
619
  }
617
620
  }
618
- /** Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce. */
621
+ /**
622
+ * Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce.
623
+ * @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
624
+ */
619
625
  export class NoUnusedPermit2NonceError extends Error {
620
626
  owner;
621
627
  startNonce;
@@ -1771,6 +1777,41 @@ export class WithdrawSharesExceedSupplyError extends Error {
1771
1777
  this.name = "WithdrawSharesExceedSupplyError";
1772
1778
  }
1773
1779
  }
1780
+ /** Thrown when a Blue withdrawal finds no supply shares to withdraw for the position owner. */
1781
+ export class EmptyBlueSupplyPositionError extends Error {
1782
+ constructor(params) {
1783
+ super(`Supply position of "${params.user}" is empty on market "${params.market}". Refresh the position data or skip the withdrawal.`);
1784
+ this.name = "EmptyBlueSupplyPositionError";
1785
+ }
1786
+ }
1787
+ /** Thrown when a Blue withdrawal needs more assets than the market's available liquidity. */
1788
+ export class InsufficientBlueLiquidityError extends Error {
1789
+ constructor(params) {
1790
+ super(`Blue liquidity is insufficient on market "${params.market}": assets "${params.assets}", liquidity "${params.liquidity}". Try again when liquidity returns.`);
1791
+ this.name = "InsufficientBlueLiquidityError";
1792
+ }
1793
+ }
1794
+ /** Thrown when an address is not a BlueBuyCallback created by the chain's registered factory. */
1795
+ export class NotBlueBuyCallbackError extends Error {
1796
+ constructor(callback) {
1797
+ super(`Address "${callback}" is not a BlueBuyCallback created by the registered factory. Pass a callback created by midnightBlueBuyCallbackFactory.`);
1798
+ this.name = "NotBlueBuyCallbackError";
1799
+ }
1800
+ }
1801
+ /** Thrown when a BlueBuyCallback's `OWNER()` is not the account withdrawing its Blue position. */
1802
+ export class BlueBuyCallbackOwnerMismatchError extends Error {
1803
+ constructor(params) {
1804
+ super(`BlueBuyCallback "${params.callback}" is owned by "${params.owner}", not "${params.userAddress}". Withdraw from the owner's account.`);
1805
+ this.name = "BlueBuyCallbackOwnerMismatchError";
1806
+ }
1807
+ }
1808
+ /** Thrown when Morpho Blue does not authorize an account to withdraw a BlueBuyCallback's position. */
1809
+ export class BlueBuyCallbackUnauthorizedError extends Error {
1810
+ constructor(params) {
1811
+ 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.`);
1812
+ this.name = "BlueBuyCallbackUnauthorizedError";
1813
+ }
1814
+ }
1774
1815
  /**
1775
1816
  * Thrown when a Vault V2 reallocation planner receives a withdraw `amount` greater
1776
1817
  * 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.5.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.1",
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"