@morpho-org/morpho-sdk 1.2.1 → 2.1.1

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 (66) hide show
  1. package/README.md +12 -11
  2. package/lib/cjs/actions/marketV1/repay.js +1 -1
  3. package/lib/cjs/actions/marketV1/repayWithdrawCollateral.js +1 -1
  4. package/lib/cjs/actions/marketV1/supplyCollateral.js +1 -1
  5. package/lib/cjs/actions/marketV1/supplyCollateralBorrow.js +1 -1
  6. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +4 -7
  7. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2.js +4 -7
  8. package/lib/cjs/actions/requirements/getRequirementsAction.d.ts +32 -8
  9. package/lib/cjs/actions/requirements/getRequirementsAction.js +34 -12
  10. package/lib/cjs/actions/requirements/index.d.ts +1 -0
  11. package/lib/cjs/actions/requirements/index.js +1 -0
  12. package/lib/cjs/actions/vaultV1/deposit.js +1 -1
  13. package/lib/cjs/actions/vaultV1/migrateToV2.js +1 -1
  14. package/lib/cjs/actions/vaultV2/deposit.js +1 -1
  15. package/lib/cjs/actions/vaultV2/forceWithdraw.js +5 -4
  16. package/lib/cjs/client/morphoClient.d.ts +48 -9
  17. package/lib/cjs/client/morphoClient.js +48 -9
  18. package/lib/cjs/client/morphoViemExtension.d.ts +2 -2
  19. package/lib/cjs/client/morphoViemExtension.js +2 -2
  20. package/lib/cjs/entities/marketV1/marketV1.js +18 -17
  21. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +6 -6
  22. package/lib/cjs/entities/vaultV1/vaultV1.js +14 -11
  23. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +5 -5
  24. package/lib/cjs/entities/vaultV2/vaultV2.js +13 -8
  25. package/lib/cjs/helpers/computeReallocations.d.ts +1 -0
  26. package/lib/cjs/helpers/computeReallocations.js +15 -0
  27. package/lib/cjs/helpers/metadata.d.ts +10 -0
  28. package/lib/cjs/helpers/metadata.js +20 -1
  29. package/lib/cjs/helpers/validate.d.ts +10 -6
  30. package/lib/cjs/helpers/validate.js +13 -9
  31. package/lib/cjs/types/action.d.ts +3 -3
  32. package/lib/cjs/types/error.d.ts +24 -0
  33. package/lib/cjs/types/error.js +23 -1
  34. package/lib/esm/actions/marketV1/repay.js +1 -1
  35. package/lib/esm/actions/marketV1/repayWithdrawCollateral.js +1 -1
  36. package/lib/esm/actions/marketV1/supplyCollateral.js +1 -1
  37. package/lib/esm/actions/marketV1/supplyCollateralBorrow.js +1 -1
  38. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +5 -8
  39. package/lib/esm/actions/requirements/encode/encodeErc20Permit2.js +5 -8
  40. package/lib/esm/actions/requirements/getRequirementsAction.d.ts +32 -8
  41. package/lib/esm/actions/requirements/getRequirementsAction.js +35 -13
  42. package/lib/esm/actions/requirements/index.d.ts +1 -0
  43. package/lib/esm/actions/requirements/index.js +1 -0
  44. package/lib/esm/actions/vaultV1/deposit.js +1 -1
  45. package/lib/esm/actions/vaultV1/migrateToV2.js +1 -1
  46. package/lib/esm/actions/vaultV2/deposit.js +1 -1
  47. package/lib/esm/actions/vaultV2/forceWithdraw.js +5 -4
  48. package/lib/esm/client/morphoClient.d.ts +48 -9
  49. package/lib/esm/client/morphoClient.js +48 -9
  50. package/lib/esm/client/morphoViemExtension.d.ts +2 -2
  51. package/lib/esm/client/morphoViemExtension.js +2 -2
  52. package/lib/esm/entities/marketV1/marketV1.js +19 -18
  53. package/lib/esm/entities/vaultV1/vaultV1.d.ts +6 -6
  54. package/lib/esm/entities/vaultV1/vaultV1.js +15 -12
  55. package/lib/esm/entities/vaultV2/vaultV2.d.ts +5 -5
  56. package/lib/esm/entities/vaultV2/vaultV2.js +13 -8
  57. package/lib/esm/helpers/computeReallocations.d.ts +1 -0
  58. package/lib/esm/helpers/computeReallocations.js +16 -1
  59. package/lib/esm/helpers/metadata.d.ts +10 -0
  60. package/lib/esm/helpers/metadata.js +20 -1
  61. package/lib/esm/helpers/validate.d.ts +10 -6
  62. package/lib/esm/helpers/validate.js +11 -7
  63. package/lib/esm/types/action.d.ts +3 -3
  64. package/lib/esm/types/error.d.ts +24 -0
  65. package/lib/esm/types/error.js +20 -0
  66. package/package.json +12 -12
@@ -76,6 +76,12 @@ export class DepositAssetMismatchError extends Error {
76
76
  super(`Deposit asset ${depositAsset} does not match requirement signature asset ${signatureAsset}`);
77
77
  }
78
78
  }
79
+ /** Thrown when a `permit2` requirement signature is missing the `expiration` field. */
80
+ export class Permit2ExpirationMissingError extends Error {
81
+ constructor() {
82
+ super('Requirement signature with action.type === "permit2" must include args.expiration. Re-sign using the permit2 flow.');
83
+ }
84
+ }
79
85
  /** Thrown when a vault deposit uses `nativeAmount` but the vault asset is not the chain's wNative. */
80
86
  export class NativeAmountOnNonWNativeVaultError extends Error {
81
87
  constructor(vaultAsset, wNative) {
@@ -256,6 +262,20 @@ export class MissingPublicAllocatorConfigError extends Error {
256
262
  super(`Vault ${vault} has no public allocator configured but was selected for reallocation`);
257
263
  }
258
264
  }
265
+ /**
266
+ * Thrown when shared liquidity selected by `computeReallocations` cannot cover
267
+ * the absolute borrow shortfall on the target market — the resulting
268
+ * `morphoBorrow` would still revert onchain.
269
+ *
270
+ * Pattern-match on the class and inspect `params` to surface the gap to users.
271
+ */
272
+ export class InsufficientSharedLiquidityError extends Error {
273
+ params;
274
+ constructor(params) {
275
+ super(`Shared liquidity is insufficient to cover the borrow on market ${params.marketId}: shortfall "${params.shortfall}", available "${params.available}". Reduce the borrow amount or wait for additional vault liquidity.`);
276
+ this.params = params;
277
+ }
278
+ }
259
279
  /** Thrown when a market borrow's `minSharePrice` slippage bound is negative. */
260
280
  export class NonPositiveMinBorrowSharePriceError extends Error {
261
281
  constructor(market) {
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": "1.2.1",
4
+ "version": "2.1.1",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Foulks-Plb <https://x.com/FoulkPlb>"
@@ -19,22 +19,22 @@
19
19
  "lib"
20
20
  ],
21
21
  "dependencies": {
22
- "zod": "^4.1.12",
23
- "@morpho-org/blue-sdk": "^5.23.2",
24
- "@morpho-org/blue-sdk-viem": "^4.6.5",
25
- "@morpho-org/bundler-sdk-viem": "^4.3.3",
26
- "@morpho-org/simulation-sdk": "^3.4.3",
27
- "@morpho-org/morpho-ts": "^2.5.1"
22
+ "zod": "^4.4.3",
23
+ "@morpho-org/blue-sdk": "^6.0.0",
24
+ "@morpho-org/blue-sdk-viem": "^5.0.0",
25
+ "@morpho-org/bundler-sdk-viem": "^5.0.0",
26
+ "@morpho-org/morpho-ts": "^2.5.1",
27
+ "@morpho-org/simulation-sdk": "^4.0.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "viem": "^2.0.0"
31
31
  },
32
32
  "devDependencies": {
33
- "dotenv": "^16.4.5",
34
- "typescript": "^5.9.3",
35
- "viem": "^2.41.2",
36
- "vitest": "^4.1.4",
37
- "@morpho-org/test": "^2.7.2"
33
+ "dotenv": "^17.4.2",
34
+ "typescript": "^6.0.3",
35
+ "viem": "^2.49.3",
36
+ "vitest": "^4.1.6",
37
+ "@morpho-org/test": "^2.8.0"
38
38
  },
39
39
  "scripts": {
40
40
  "prepublish": "$npm_execpath build",