@morpho-org/morpho-sdk 3.2.0 → 4.1.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 (103) hide show
  1. package/README.md +19 -16
  2. package/lib/cjs/actions/{marketV1 → blue}/borrow.d.ts +8 -8
  3. package/lib/cjs/actions/{marketV1 → blue}/borrow.js +8 -8
  4. package/lib/{esm/actions/marketV1 → cjs/actions/blue}/buildReallocationActions.d.ts +1 -1
  5. package/lib/cjs/actions/{marketV1 → blue}/buildReallocationActions.js +1 -1
  6. package/lib/{esm/actions/marketV1 → cjs/actions/blue}/refinance.d.ts +8 -8
  7. package/lib/cjs/actions/{marketV1 → blue}/refinance.js +8 -8
  8. package/lib/{esm/actions/marketV1 → cjs/actions/blue}/repay.d.ts +8 -8
  9. package/lib/cjs/actions/{marketV1 → blue}/repay.js +8 -8
  10. package/lib/{esm/actions/marketV1 → cjs/actions/blue}/repayWithdrawCollateral.d.ts +8 -8
  11. package/lib/cjs/actions/{marketV1 → blue}/repayWithdrawCollateral.js +8 -8
  12. package/lib/cjs/actions/{marketV1 → blue}/supply.d.ts +8 -8
  13. package/lib/cjs/actions/{marketV1 → blue}/supply.js +8 -8
  14. package/lib/cjs/actions/{marketV1 → blue}/supplyCollateral.d.ts +8 -8
  15. package/lib/cjs/actions/{marketV1 → blue}/supplyCollateral.js +8 -8
  16. package/lib/{esm/actions/marketV1 → cjs/actions/blue}/supplyCollateralBorrow.d.ts +8 -8
  17. package/lib/cjs/actions/{marketV1 → blue}/supplyCollateralBorrow.js +8 -8
  18. package/lib/{esm/actions/marketV1 → cjs/actions/blue}/withdraw.d.ts +11 -11
  19. package/lib/cjs/actions/{marketV1 → blue}/withdraw.js +10 -10
  20. package/lib/{esm/actions/marketV1 → cjs/actions/blue}/withdrawCollateral.d.ts +8 -8
  21. package/lib/cjs/actions/{marketV1 → blue}/withdrawCollateral.js +8 -8
  22. package/lib/cjs/actions/index.d.ts +2 -2
  23. package/lib/cjs/actions/index.js +1 -1
  24. package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.d.ts +1 -1
  25. package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.js +1 -1
  26. package/lib/cjs/client/index.d.ts +0 -1
  27. package/lib/cjs/client/index.js +0 -1
  28. package/lib/cjs/client/morphoViemExtension.d.ts +17 -11
  29. package/lib/cjs/client/morphoViemExtension.js +55 -10
  30. package/lib/cjs/entities/{marketV1/marketV1.d.ts → blue/blue.d.ts} +22 -22
  31. package/lib/cjs/entities/{marketV1/marketV1.js → blue/blue.js} +12 -12
  32. package/lib/cjs/entities/blue/index.d.ts +1 -0
  33. package/lib/cjs/entities/{marketV1 → blue}/index.js +1 -1
  34. package/lib/cjs/entities/index.d.ts +1 -1
  35. package/lib/cjs/entities/index.js +3 -3
  36. package/lib/cjs/entities/reallocationData.d.ts +96 -2
  37. package/lib/cjs/entities/reallocationData.js +112 -1
  38. package/lib/cjs/entities/vaultV2/vaultV2.js +1 -1
  39. package/lib/cjs/helpers/computeReallocations.d.ts +1 -1
  40. package/lib/cjs/helpers/computeReallocations.js +3 -5
  41. package/lib/cjs/helpers/utilization.d.ts +12 -0
  42. package/lib/cjs/helpers/utilization.js +17 -0
  43. package/lib/cjs/helpers/validate.d.ts +2 -2
  44. package/lib/cjs/helpers/validate.js +2 -2
  45. package/lib/cjs/types/action.d.ts +10 -10
  46. package/lib/cjs/types/client.d.ts +5 -4
  47. package/lib/esm/actions/{marketV1 → blue}/borrow.d.ts +8 -8
  48. package/lib/esm/actions/{marketV1 → blue}/borrow.js +6 -6
  49. package/lib/{cjs/actions/marketV1 → esm/actions/blue}/buildReallocationActions.d.ts +1 -1
  50. package/lib/esm/actions/{marketV1 → blue}/buildReallocationActions.js +1 -1
  51. package/lib/{cjs/actions/marketV1 → esm/actions/blue}/refinance.d.ts +8 -8
  52. package/lib/esm/actions/{marketV1 → blue}/refinance.js +6 -6
  53. package/lib/{cjs/actions/marketV1 → esm/actions/blue}/repay.d.ts +8 -8
  54. package/lib/esm/actions/{marketV1 → blue}/repay.js +6 -6
  55. package/lib/{cjs/actions/marketV1 → esm/actions/blue}/repayWithdrawCollateral.d.ts +8 -8
  56. package/lib/esm/actions/{marketV1 → blue}/repayWithdrawCollateral.js +6 -6
  57. package/lib/esm/actions/{marketV1 → blue}/supply.d.ts +8 -8
  58. package/lib/esm/actions/{marketV1 → blue}/supply.js +6 -6
  59. package/lib/esm/actions/{marketV1 → blue}/supplyCollateral.d.ts +8 -8
  60. package/lib/esm/actions/{marketV1 → blue}/supplyCollateral.js +6 -6
  61. package/lib/{cjs/actions/marketV1 → esm/actions/blue}/supplyCollateralBorrow.d.ts +8 -8
  62. package/lib/esm/actions/{marketV1 → blue}/supplyCollateralBorrow.js +6 -6
  63. package/lib/{cjs/actions/marketV1 → esm/actions/blue}/withdraw.d.ts +11 -11
  64. package/lib/esm/actions/{marketV1 → blue}/withdraw.js +8 -8
  65. package/lib/{cjs/actions/marketV1 → esm/actions/blue}/withdrawCollateral.d.ts +8 -8
  66. package/lib/esm/actions/{marketV1 → blue}/withdrawCollateral.js +6 -6
  67. package/lib/esm/actions/index.d.ts +2 -2
  68. package/lib/esm/actions/index.js +1 -1
  69. package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.d.ts +1 -1
  70. package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.js +1 -1
  71. package/lib/esm/client/index.d.ts +0 -1
  72. package/lib/esm/client/index.js +0 -1
  73. package/lib/esm/client/morphoViemExtension.d.ts +17 -11
  74. package/lib/esm/client/morphoViemExtension.js +55 -10
  75. package/lib/esm/entities/{marketV1/marketV1.d.ts → blue/blue.d.ts} +22 -22
  76. package/lib/esm/entities/{marketV1/marketV1.js → blue/blue.js} +11 -11
  77. package/lib/esm/entities/blue/index.d.ts +1 -0
  78. package/lib/esm/entities/blue/index.js +1 -0
  79. package/lib/esm/entities/index.d.ts +1 -1
  80. package/lib/esm/entities/index.js +1 -1
  81. package/lib/esm/entities/reallocationData.d.ts +96 -2
  82. package/lib/esm/entities/reallocationData.js +114 -3
  83. package/lib/esm/entities/vaultV2/vaultV2.js +1 -1
  84. package/lib/esm/helpers/computeReallocations.d.ts +1 -1
  85. package/lib/esm/helpers/computeReallocations.js +3 -5
  86. package/lib/esm/helpers/utilization.d.ts +12 -0
  87. package/lib/esm/helpers/utilization.js +13 -0
  88. package/lib/esm/helpers/validate.d.ts +2 -2
  89. package/lib/esm/helpers/validate.js +2 -2
  90. package/lib/esm/types/action.d.ts +10 -10
  91. package/lib/esm/types/client.d.ts +5 -4
  92. package/package.json +5 -5
  93. package/lib/cjs/client/morphoClient.d.ts +0 -152
  94. package/lib/cjs/client/morphoClient.js +0 -162
  95. package/lib/cjs/entities/marketV1/index.d.ts +0 -1
  96. package/lib/esm/client/morphoClient.d.ts +0 -152
  97. package/lib/esm/client/morphoClient.js +0 -158
  98. package/lib/esm/entities/marketV1/index.d.ts +0 -1
  99. package/lib/esm/entities/marketV1/index.js +0 -1
  100. /package/lib/cjs/actions/{marketV1 → blue}/index.d.ts +0 -0
  101. /package/lib/cjs/actions/{marketV1 → blue}/index.js +0 -0
  102. /package/lib/esm/actions/{marketV1 → blue}/index.d.ts +0 -0
  103. /package/lib/esm/actions/{marketV1 → blue}/index.js +0 -0
@@ -1,8 +1,8 @@
1
1
  import { type MarketParams } from "@morpho-org/blue-sdk";
2
2
  import type { Address } from "viem";
3
- import { type DepositAmountArgs, type MarketV1SupplyCollateralAction, type Metadata, type RequirementSignature, type Transaction } from "../../types/index.js";
4
- /** Parameters for {@link marketV1SupplyCollateral}. */
5
- export interface MarketV1SupplyCollateralParams {
3
+ import { type BlueSupplyCollateralAction, type DepositAmountArgs, type Metadata, type RequirementSignature, type Transaction } from "../../types/index.js";
4
+ /** Parameters for {@link blueSupplyCollateral}. */
5
+ export interface BlueSupplyCollateralParams {
6
6
  market: {
7
7
  readonly chainId: number;
8
8
  readonly marketParams: MarketParams;
@@ -33,7 +33,7 @@ export interface MarketV1SupplyCollateralParams {
33
33
  * @param params.args.nativeAmount - Optional amount of native token to wrap into wNative for the
34
34
  * supply. Requires the collateral token to be the chain's wNative.
35
35
  * @param params.metadata - Optional analytics metadata attached to the bundle.
36
- * @returns A deep-frozen `Transaction<MarketV1SupplyCollateralAction>` with `to`, `value`, `data`,
36
+ * @returns A deep-frozen `Transaction<BlueSupplyCollateralAction>` with `to`, `value`, `data`,
37
37
  * and the typed `action` discriminator the simulation layer consumes.
38
38
  * @throws {NonPositiveAssetAmountError} when `amount < 0n`.
39
39
  * @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
@@ -49,13 +49,13 @@ export interface MarketV1SupplyCollateralParams {
49
49
  * signature is missing its expiration.
50
50
  * @example
51
51
  * ```ts
52
- * import { marketV1SupplyCollateral } from "@morpho-org/morpho-sdk";
52
+ * import { blueSupplyCollateral } from "@morpho-org/morpho-sdk";
53
53
  *
54
- * const tx = marketV1SupplyCollateral({
54
+ * const tx = blueSupplyCollateral({
55
55
  * market: { chainId: 1, marketParams },
56
56
  * args: { amount: 1_000_000_000_000_000_000n, onBehalf },
57
57
  * });
58
- * // tx satisfies Readonly<Transaction<MarketV1SupplyCollateralAction>>
58
+ * // tx satisfies Readonly<Transaction<BlueSupplyCollateralAction>>
59
59
  * ```
60
60
  */
61
- export declare const marketV1SupplyCollateral: ({ market: { chainId, marketParams }, args: { amount, onBehalf, requirementSignature, nativeAmount }, metadata, }: MarketV1SupplyCollateralParams) => Readonly<Transaction<MarketV1SupplyCollateralAction>>;
61
+ export declare const blueSupplyCollateral: ({ market: { chainId, marketParams }, args: { amount, onBehalf, requirementSignature, nativeAmount }, metadata, }: BlueSupplyCollateralParams) => Readonly<Transaction<BlueSupplyCollateralAction>>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.marketV1SupplyCollateral = void 0;
3
+ exports.blueSupplyCollateral = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
6
  const index_js_1 = require("../../bundler/index.js");
@@ -27,7 +27,7 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
27
27
  * @param params.args.nativeAmount - Optional amount of native token to wrap into wNative for the
28
28
  * supply. Requires the collateral token to be the chain's wNative.
29
29
  * @param params.metadata - Optional analytics metadata attached to the bundle.
30
- * @returns A deep-frozen `Transaction<MarketV1SupplyCollateralAction>` with `to`, `value`, `data`,
30
+ * @returns A deep-frozen `Transaction<BlueSupplyCollateralAction>` with `to`, `value`, `data`,
31
31
  * and the typed `action` discriminator the simulation layer consumes.
32
32
  * @throws {NonPositiveAssetAmountError} when `amount < 0n`.
33
33
  * @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
@@ -43,16 +43,16 @@ const getRequirementsAction_js_1 = require("../requirements/getRequirementsActio
43
43
  * signature is missing its expiration.
44
44
  * @example
45
45
  * ```ts
46
- * import { marketV1SupplyCollateral } from "@morpho-org/morpho-sdk";
46
+ * import { blueSupplyCollateral } from "@morpho-org/morpho-sdk";
47
47
  *
48
- * const tx = marketV1SupplyCollateral({
48
+ * const tx = blueSupplyCollateral({
49
49
  * market: { chainId: 1, marketParams },
50
50
  * args: { amount: 1_000_000_000_000_000_000n, onBehalf },
51
51
  * });
52
- * // tx satisfies Readonly<Transaction<MarketV1SupplyCollateralAction>>
52
+ * // tx satisfies Readonly<Transaction<BlueSupplyCollateralAction>>
53
53
  * ```
54
54
  */
55
- const marketV1SupplyCollateral = ({ market: { chainId, marketParams }, args: { amount = 0n, onBehalf, requirementSignature, nativeAmount }, metadata, }) => {
55
+ const blueSupplyCollateral = ({ market: { chainId, marketParams }, args: { amount = 0n, onBehalf, requirementSignature, nativeAmount }, metadata, }) => {
56
56
  if (amount < 0n) {
57
57
  throw new index_js_3.NonPositiveAssetAmountError(marketParams.collateralToken);
58
58
  }
@@ -102,7 +102,7 @@ const marketV1SupplyCollateral = ({ market: { chainId, marketParams }, args: { a
102
102
  return (0, morpho_ts_1.deepFreeze)({
103
103
  ...tx,
104
104
  action: {
105
- type: "marketV1SupplyCollateral",
105
+ type: "blueSupplyCollateral",
106
106
  args: {
107
107
  market: marketParams.id,
108
108
  amount: totalCollateral,
@@ -112,4 +112,4 @@ const marketV1SupplyCollateral = ({ market: { chainId, marketParams }, args: { a
112
112
  },
113
113
  });
114
114
  };
115
- exports.marketV1SupplyCollateral = marketV1SupplyCollateral;
115
+ exports.blueSupplyCollateral = blueSupplyCollateral;
@@ -1,8 +1,8 @@
1
1
  import { type MarketParams } from "@morpho-org/blue-sdk";
2
2
  import type { Address } from "viem";
3
- import { type DepositAmountArgs, type MarketV1SupplyCollateralBorrowAction, type Metadata, type RequirementSignature, type Transaction, type VaultReallocation } from "../../types/index.js";
4
- /** Parameters for {@link marketV1SupplyCollateralBorrow}. */
5
- export interface MarketV1SupplyCollateralBorrowParams {
3
+ import { type BlueSupplyCollateralBorrowAction, type DepositAmountArgs, type Metadata, type RequirementSignature, type Transaction, type VaultReallocation } from "../../types/index.js";
4
+ /** Parameters for {@link blueSupplyCollateralBorrow}. */
5
+ export interface BlueSupplyCollateralBorrowParams {
6
6
  market: {
7
7
  readonly chainId: number;
8
8
  readonly marketParams: MarketParams;
@@ -47,7 +47,7 @@ export interface MarketV1SupplyCollateralBorrowParams {
47
47
  * @param params.args.reallocations - Optional vault reallocations to execute between the supply
48
48
  * and borrow legs, computed by the entity layer.
49
49
  * @param params.metadata - Optional analytics metadata attached to the bundle.
50
- * @returns A deep-frozen `Transaction<MarketV1SupplyCollateralBorrowAction>` with `to`, `value`,
50
+ * @returns A deep-frozen `Transaction<BlueSupplyCollateralBorrowAction>` with `to`, `value`,
51
51
  * `data`, and the typed `action` discriminator the simulation layer consumes.
52
52
  * @throws {NonPositiveAssetAmountError} when `amount < 0n`.
53
53
  * @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
@@ -75,9 +75,9 @@ export interface MarketV1SupplyCollateralBorrowParams {
75
75
  * reallocation withdrawals are not strictly sorted by market id.
76
76
  * @example
77
77
  * ```ts
78
- * import { marketV1SupplyCollateralBorrow } from "@morpho-org/morpho-sdk";
78
+ * import { blueSupplyCollateralBorrow } from "@morpho-org/morpho-sdk";
79
79
  *
80
- * const tx = marketV1SupplyCollateralBorrow({
80
+ * const tx = blueSupplyCollateralBorrow({
81
81
  * market: { chainId: 1, marketParams },
82
82
  * args: {
83
83
  * amount: 1_000_000_000_000_000_000n,
@@ -87,7 +87,7 @@ export interface MarketV1SupplyCollateralBorrowParams {
87
87
  * minSharePrice: 0n, // disables slippage protection — production code should compute via `computeMinBorrowSharePrice` from market state + slippage tolerance
88
88
  * },
89
89
  * });
90
- * // tx satisfies Readonly<Transaction<MarketV1SupplyCollateralBorrowAction>>
90
+ * // tx satisfies Readonly<Transaction<BlueSupplyCollateralBorrowAction>>
91
91
  * ```
92
92
  */
93
- export declare const marketV1SupplyCollateralBorrow: ({ market: { chainId, marketParams }, args: { amount, borrowAmount, onBehalf, receiver, minSharePrice, requirementSignature, nativeAmount, reallocations, }, metadata, }: MarketV1SupplyCollateralBorrowParams) => Readonly<Transaction<MarketV1SupplyCollateralBorrowAction>>;
93
+ export declare const blueSupplyCollateralBorrow: ({ market: { chainId, marketParams }, args: { amount, borrowAmount, onBehalf, receiver, minSharePrice, requirementSignature, nativeAmount, reallocations, }, metadata, }: BlueSupplyCollateralBorrowParams) => Readonly<Transaction<BlueSupplyCollateralBorrowAction>>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.marketV1SupplyCollateralBorrow = void 0;
3
+ exports.blueSupplyCollateralBorrow = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
6
  const index_js_1 = require("../../bundler/index.js");
@@ -36,7 +36,7 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
36
36
  * @param params.args.reallocations - Optional vault reallocations to execute between the supply
37
37
  * and borrow legs, computed by the entity layer.
38
38
  * @param params.metadata - Optional analytics metadata attached to the bundle.
39
- * @returns A deep-frozen `Transaction<MarketV1SupplyCollateralBorrowAction>` with `to`, `value`,
39
+ * @returns A deep-frozen `Transaction<BlueSupplyCollateralBorrowAction>` with `to`, `value`,
40
40
  * `data`, and the typed `action` discriminator the simulation layer consumes.
41
41
  * @throws {NonPositiveAssetAmountError} when `amount < 0n`.
42
42
  * @throws {NegativeNativeAmountError} when `nativeAmount < 0n`.
@@ -64,9 +64,9 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
64
64
  * reallocation withdrawals are not strictly sorted by market id.
65
65
  * @example
66
66
  * ```ts
67
- * import { marketV1SupplyCollateralBorrow } from "@morpho-org/morpho-sdk";
67
+ * import { blueSupplyCollateralBorrow } from "@morpho-org/morpho-sdk";
68
68
  *
69
- * const tx = marketV1SupplyCollateralBorrow({
69
+ * const tx = blueSupplyCollateralBorrow({
70
70
  * market: { chainId: 1, marketParams },
71
71
  * args: {
72
72
  * amount: 1_000_000_000_000_000_000n,
@@ -76,10 +76,10 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
76
76
  * minSharePrice: 0n, // disables slippage protection — production code should compute via `computeMinBorrowSharePrice` from market state + slippage tolerance
77
77
  * },
78
78
  * });
79
- * // tx satisfies Readonly<Transaction<MarketV1SupplyCollateralBorrowAction>>
79
+ * // tx satisfies Readonly<Transaction<BlueSupplyCollateralBorrowAction>>
80
80
  * ```
81
81
  */
82
- const marketV1SupplyCollateralBorrow = ({ market: { chainId, marketParams }, args: { amount = 0n, borrowAmount, onBehalf, receiver, minSharePrice, requirementSignature, nativeAmount, reallocations, }, metadata, }) => {
82
+ const blueSupplyCollateralBorrow = ({ market: { chainId, marketParams }, args: { amount = 0n, borrowAmount, onBehalf, receiver, minSharePrice, requirementSignature, nativeAmount, reallocations, }, metadata, }) => {
83
83
  if (amount < 0n) {
84
84
  throw new index_js_3.NonPositiveAssetAmountError(marketParams.collateralToken);
85
85
  }
@@ -145,7 +145,7 @@ const marketV1SupplyCollateralBorrow = ({ market: { chainId, marketParams }, arg
145
145
  return (0, morpho_ts_1.deepFreeze)({
146
146
  ...tx,
147
147
  action: {
148
- type: "marketV1SupplyCollateralBorrow",
148
+ type: "blueSupplyCollateralBorrow",
149
149
  args: {
150
150
  market: marketParams.id,
151
151
  collateralAmount: totalCollateral,
@@ -159,4 +159,4 @@ const marketV1SupplyCollateralBorrow = ({ market: { chainId, marketParams }, arg
159
159
  },
160
160
  });
161
161
  };
162
- exports.marketV1SupplyCollateralBorrow = marketV1SupplyCollateralBorrow;
162
+ exports.blueSupplyCollateralBorrow = blueSupplyCollateralBorrow;
@@ -1,8 +1,8 @@
1
1
  import type { MarketParams } from "@morpho-org/blue-sdk";
2
2
  import type { Address } from "viem";
3
- import { type MarketV1WithdrawAction, type Metadata, type Transaction, type VaultReallocation } from "../../types/index.js";
4
- /** Parameters for {@link marketV1Withdraw}. */
5
- export interface MarketV1WithdrawParams {
3
+ import { type BlueWithdrawAction, type Metadata, type Transaction, type VaultReallocation } from "../../types/index.js";
4
+ /** Parameters for {@link blueWithdraw}. */
5
+ export interface BlueWithdrawParams {
6
6
  market: {
7
7
  readonly chainId: number;
8
8
  readonly marketParams: MarketParams;
@@ -18,7 +18,7 @@ export interface MarketV1WithdrawParams {
18
18
  minSharePrice: bigint;
19
19
  /**
20
20
  * Vault reallocations to execute before withdrawing. Compute via
21
- * `MorphoMarketV1.getReallocations({ operation: "withdraw", amount })` or directly via
21
+ * `MorphoBlue.getReallocations({ operation: "withdraw", amount })` or directly via
22
22
  * `computeReallocations({ operation: "withdraw", amount, ... })`.
23
23
  */
24
24
  reallocations?: readonly VaultReallocation[];
@@ -40,7 +40,7 @@ export interface MarketV1WithdrawParams {
40
40
  * computed on-chain directly to `receiver`; no skim is required.
41
41
  *
42
42
  * The withdraw is performed on behalf of the transaction initiator (signer) — there is no
43
- * separate `onBehalf` field; mirror `marketV1Borrow`. The entity layer keeps `receiver` aligned
43
+ * separate `onBehalf` field; mirror `blueBorrow`. The entity layer keeps `receiver` aligned
44
44
  * with the user when none is provided. Requires the user to have authorized `GeneralAdapter1`
45
45
  * on Morpho.
46
46
  *
@@ -54,21 +54,21 @@ export interface MarketV1WithdrawParams {
54
54
  * @param params.args.reallocations - Optional vault reallocations to execute before withdrawing,
55
55
  * computed by the entity layer.
56
56
  * @param params.metadata - Optional analytics metadata attached to the bundle.
57
- * @returns A deep-frozen `Transaction<MarketV1WithdrawAction>` with `to`, `value`, `data`, and
57
+ * @returns A deep-frozen `Transaction<BlueWithdrawAction>` with `to`, `value`, `data`, and
58
58
  * the typed `action` discriminator the simulation layer consumes.
59
59
  * @throws {NonPositiveWithdrawAmountError} when both `assets` and `shares` are zero, or either is negative.
60
60
  * @throws {MutuallyExclusiveWithdrawAmountsError} when both `assets` and `shares` are non-zero.
61
61
  * @throws {NegativeWithdrawMinSharePriceError} when `minSharePrice < 0n` (zero is allowed despite
62
- * the class name — pattern preserved for symmetry with `marketV1Borrow`).
62
+ * the class name — pattern preserved for symmetry with `blueBorrow`).
63
63
  * @throws Reallocation errors from `buildReallocationActions` when `reallocations` is malformed
64
64
  * (see its JSDoc: `NegativeReallocationFeeError`, `EmptyReallocationWithdrawalsError`,
65
65
  * `NonPositiveReallocationAmountError`, `ReallocationWithdrawalOnTargetMarketError`,
66
66
  * `UnsortedReallocationWithdrawalsError`).
67
67
  * @example
68
68
  * ```ts
69
- * import { marketV1Withdraw } from "@morpho-org/morpho-sdk";
69
+ * import { blueWithdraw } from "@morpho-org/morpho-sdk";
70
70
  *
71
- * const tx = marketV1Withdraw({
71
+ * const tx = blueWithdraw({
72
72
  * market: { chainId: 1, marketParams },
73
73
  * args: {
74
74
  * assets: 1_000_000_000n,
@@ -77,7 +77,7 @@ export interface MarketV1WithdrawParams {
77
77
  * minSharePrice: 0n, // disables slippage protection — production code should compute via `computeMinWithdrawSharePrice` from market state + slippage tolerance
78
78
  * },
79
79
  * });
80
- * // tx satisfies Readonly<Transaction<MarketV1WithdrawAction>>
80
+ * // tx satisfies Readonly<Transaction<BlueWithdrawAction>>
81
81
  * ```
82
82
  */
83
- export declare const marketV1Withdraw: ({ market: { chainId, marketParams }, args: { assets, shares, receiver, minSharePrice, reallocations }, metadata, }: MarketV1WithdrawParams) => Readonly<Transaction<MarketV1WithdrawAction>>;
83
+ export declare const blueWithdraw: ({ market: { chainId, marketParams }, args: { assets, shares, receiver, minSharePrice, reallocations }, metadata, }: BlueWithdrawParams) => Readonly<Transaction<BlueWithdrawAction>>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.marketV1Withdraw = void 0;
3
+ exports.blueWithdraw = void 0;
4
4
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
5
  const index_js_1 = require("../../bundler/index.js");
6
6
  const index_js_2 = require("../../helpers/index.js");
@@ -21,7 +21,7 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
21
21
  * computed on-chain directly to `receiver`; no skim is required.
22
22
  *
23
23
  * The withdraw is performed on behalf of the transaction initiator (signer) — there is no
24
- * separate `onBehalf` field; mirror `marketV1Borrow`. The entity layer keeps `receiver` aligned
24
+ * separate `onBehalf` field; mirror `blueBorrow`. The entity layer keeps `receiver` aligned
25
25
  * with the user when none is provided. Requires the user to have authorized `GeneralAdapter1`
26
26
  * on Morpho.
27
27
  *
@@ -35,21 +35,21 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
35
35
  * @param params.args.reallocations - Optional vault reallocations to execute before withdrawing,
36
36
  * computed by the entity layer.
37
37
  * @param params.metadata - Optional analytics metadata attached to the bundle.
38
- * @returns A deep-frozen `Transaction<MarketV1WithdrawAction>` with `to`, `value`, `data`, and
38
+ * @returns A deep-frozen `Transaction<BlueWithdrawAction>` with `to`, `value`, `data`, and
39
39
  * the typed `action` discriminator the simulation layer consumes.
40
40
  * @throws {NonPositiveWithdrawAmountError} when both `assets` and `shares` are zero, or either is negative.
41
41
  * @throws {MutuallyExclusiveWithdrawAmountsError} when both `assets` and `shares` are non-zero.
42
42
  * @throws {NegativeWithdrawMinSharePriceError} when `minSharePrice < 0n` (zero is allowed despite
43
- * the class name — pattern preserved for symmetry with `marketV1Borrow`).
43
+ * the class name — pattern preserved for symmetry with `blueBorrow`).
44
44
  * @throws Reallocation errors from `buildReallocationActions` when `reallocations` is malformed
45
45
  * (see its JSDoc: `NegativeReallocationFeeError`, `EmptyReallocationWithdrawalsError`,
46
46
  * `NonPositiveReallocationAmountError`, `ReallocationWithdrawalOnTargetMarketError`,
47
47
  * `UnsortedReallocationWithdrawalsError`).
48
48
  * @example
49
49
  * ```ts
50
- * import { marketV1Withdraw } from "@morpho-org/morpho-sdk";
50
+ * import { blueWithdraw } from "@morpho-org/morpho-sdk";
51
51
  *
52
- * const tx = marketV1Withdraw({
52
+ * const tx = blueWithdraw({
53
53
  * market: { chainId: 1, marketParams },
54
54
  * args: {
55
55
  * assets: 1_000_000_000n,
@@ -58,10 +58,10 @@ const buildReallocationActions_js_1 = require("./buildReallocationActions.js");
58
58
  * minSharePrice: 0n, // disables slippage protection — production code should compute via `computeMinWithdrawSharePrice` from market state + slippage tolerance
59
59
  * },
60
60
  * });
61
- * // tx satisfies Readonly<Transaction<MarketV1WithdrawAction>>
61
+ * // tx satisfies Readonly<Transaction<BlueWithdrawAction>>
62
62
  * ```
63
63
  */
64
- const marketV1Withdraw = ({ market: { chainId, marketParams }, args: { assets, shares, receiver, minSharePrice, reallocations }, metadata, }) => {
64
+ const blueWithdraw = ({ market: { chainId, marketParams }, args: { assets, shares, receiver, minSharePrice, reallocations }, metadata, }) => {
65
65
  // Mutual exclusion is detected on "both values present" (either non-zero),
66
66
  // before sign checks — otherwise `{ assets: -1n, shares: 5n }` would be
67
67
  // misreported as a positivity error rather than the actual mode conflict.
@@ -95,7 +95,7 @@ const marketV1Withdraw = ({ market: { chainId, marketParams }, args: { assets, s
95
95
  return (0, morpho_ts_1.deepFreeze)({
96
96
  ...tx,
97
97
  action: {
98
- type: "marketV1Withdraw",
98
+ type: "blueWithdraw",
99
99
  args: {
100
100
  market: marketParams.id,
101
101
  assets,
@@ -107,4 +107,4 @@ const marketV1Withdraw = ({ market: { chainId, marketParams }, args: { assets, s
107
107
  },
108
108
  });
109
109
  };
110
- exports.marketV1Withdraw = marketV1Withdraw;
110
+ exports.blueWithdraw = blueWithdraw;
@@ -1,8 +1,8 @@
1
1
  import { type MarketParams } from "@morpho-org/blue-sdk";
2
2
  import { type Address } from "viem";
3
- import { type MarketV1WithdrawCollateralAction, type Metadata, type Transaction } from "../../types/index.js";
4
- /** Parameters for {@link marketV1WithdrawCollateral}. */
5
- export interface MarketV1WithdrawCollateralParams {
3
+ import { type BlueWithdrawCollateralAction, type Metadata, type Transaction } from "../../types/index.js";
4
+ /** Parameters for {@link blueWithdrawCollateral}. */
5
+ export interface BlueWithdrawCollateralParams {
6
6
  market: {
7
7
  readonly chainId: number;
8
8
  readonly marketParams: MarketParams;
@@ -28,14 +28,14 @@ export interface MarketV1WithdrawCollateralParams {
28
28
  * @param params.args.onBehalf - Address whose Morpho position the collateral is withdrawn from.
29
29
  * @param params.args.receiver - Address that receives the withdrawn collateral.
30
30
  * @param params.metadata - Optional analytics metadata attached to the transaction.
31
- * @returns A deep-frozen `Transaction<MarketV1WithdrawCollateralAction>` with `to`, `value`,
31
+ * @returns A deep-frozen `Transaction<BlueWithdrawCollateralAction>` with `to`, `value`,
32
32
  * `data`, and the typed `action` discriminator the simulation layer consumes.
33
33
  * @throws {NonPositiveWithdrawCollateralAmountError} when `amount <= 0n`.
34
34
  * @example
35
35
  * ```ts
36
- * import { marketV1WithdrawCollateral } from "@morpho-org/morpho-sdk";
36
+ * import { blueWithdrawCollateral } from "@morpho-org/morpho-sdk";
37
37
  *
38
- * const tx = marketV1WithdrawCollateral({
38
+ * const tx = blueWithdrawCollateral({
39
39
  * market: { chainId: 1, marketParams },
40
40
  * args: {
41
41
  * amount: 1_000_000_000_000_000_000n,
@@ -43,7 +43,7 @@ export interface MarketV1WithdrawCollateralParams {
43
43
  * receiver: borrower,
44
44
  * },
45
45
  * });
46
- * // tx satisfies Readonly<Transaction<MarketV1WithdrawCollateralAction>>
46
+ * // tx satisfies Readonly<Transaction<BlueWithdrawCollateralAction>>
47
47
  * ```
48
48
  */
49
- export declare const marketV1WithdrawCollateral: ({ market: { chainId, marketParams }, args: { amount, onBehalf, receiver }, metadata, }: MarketV1WithdrawCollateralParams) => Readonly<Transaction<MarketV1WithdrawCollateralAction>>;
49
+ export declare const blueWithdrawCollateral: ({ market: { chainId, marketParams }, args: { amount, onBehalf, receiver }, metadata, }: BlueWithdrawCollateralParams) => Readonly<Transaction<BlueWithdrawCollateralAction>>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.marketV1WithdrawCollateral = void 0;
3
+ exports.blueWithdrawCollateral = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
6
6
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
@@ -21,14 +21,14 @@ const index_js_2 = require("../../types/index.js");
21
21
  * @param params.args.onBehalf - Address whose Morpho position the collateral is withdrawn from.
22
22
  * @param params.args.receiver - Address that receives the withdrawn collateral.
23
23
  * @param params.metadata - Optional analytics metadata attached to the transaction.
24
- * @returns A deep-frozen `Transaction<MarketV1WithdrawCollateralAction>` with `to`, `value`,
24
+ * @returns A deep-frozen `Transaction<BlueWithdrawCollateralAction>` with `to`, `value`,
25
25
  * `data`, and the typed `action` discriminator the simulation layer consumes.
26
26
  * @throws {NonPositiveWithdrawCollateralAmountError} when `amount <= 0n`.
27
27
  * @example
28
28
  * ```ts
29
- * import { marketV1WithdrawCollateral } from "@morpho-org/morpho-sdk";
29
+ * import { blueWithdrawCollateral } from "@morpho-org/morpho-sdk";
30
30
  *
31
- * const tx = marketV1WithdrawCollateral({
31
+ * const tx = blueWithdrawCollateral({
32
32
  * market: { chainId: 1, marketParams },
33
33
  * args: {
34
34
  * amount: 1_000_000_000_000_000_000n,
@@ -36,10 +36,10 @@ const index_js_2 = require("../../types/index.js");
36
36
  * receiver: borrower,
37
37
  * },
38
38
  * });
39
- * // tx satisfies Readonly<Transaction<MarketV1WithdrawCollateralAction>>
39
+ * // tx satisfies Readonly<Transaction<BlueWithdrawCollateralAction>>
40
40
  * ```
41
41
  */
42
- const marketV1WithdrawCollateral = ({ market: { chainId, marketParams }, args: { amount, onBehalf, receiver }, metadata, }) => {
42
+ const blueWithdrawCollateral = ({ market: { chainId, marketParams }, args: { amount, onBehalf, receiver }, metadata, }) => {
43
43
  if (amount <= 0n) {
44
44
  throw new index_js_2.NonPositiveWithdrawCollateralAmountError(marketParams.id);
45
45
  }
@@ -59,7 +59,7 @@ const marketV1WithdrawCollateral = ({ market: { chainId, marketParams }, args: {
59
59
  return (0, morpho_ts_1.deepFreeze)({
60
60
  ...tx,
61
61
  action: {
62
- type: "marketV1WithdrawCollateral",
62
+ type: "blueWithdrawCollateral",
63
63
  args: {
64
64
  market: marketParams.id,
65
65
  amount,
@@ -69,4 +69,4 @@ const marketV1WithdrawCollateral = ({ market: { chainId, marketParams }, args: {
69
69
  },
70
70
  });
71
71
  };
72
- exports.marketV1WithdrawCollateral = marketV1WithdrawCollateral;
72
+ exports.blueWithdrawCollateral = blueWithdrawCollateral;
@@ -1,7 +1,7 @@
1
- export type { MarketV1Actions } from "../entities/marketV1/index.js";
1
+ export type { BlueActions } from "../entities/blue/index.js";
2
2
  export type { VaultV1Actions } from "../entities/vaultV1/index.js";
3
3
  export type { VaultV2Actions } from "../entities/vaultV2/index.js";
4
- export * from "./marketV1/index.js";
4
+ export * from "./blue/index.js";
5
5
  export * from "./requirements/index.js";
6
6
  export * from "./vaultV1/index.js";
7
7
  export * from "./vaultV2/index.js";
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./marketV1/index.js"), exports);
17
+ __exportStar(require("./blue/index.js"), exports);
18
18
  __exportStar(require("./requirements/index.js"), exports);
19
19
  __exportStar(require("./vaultV1/index.js"), exports);
20
20
  __exportStar(require("./vaultV2/index.js"), exports);
@@ -6,7 +6,7 @@ import { type MorphoAuthorizationAction, type Transaction } from "../../types/in
6
6
  * the `setAuthorization(generalAdapter1, true)` transaction when it does.
7
7
  *
8
8
  * Reads `Morpho.isAuthorized(userAddress, generalAdapter1)` on the target chain. Required before
9
- * any bundled MarketV1 path that operates on behalf of the user (`borrow`,
9
+ * any bundled Blue path that operates on behalf of the user (`borrow`,
10
10
  * `supplyCollateralBorrow`, `repayWithdrawCollateral`).
11
11
  *
12
12
  * @param params.viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
@@ -11,7 +11,7 @@ const index_js_1 = require("../../types/index.js");
11
11
  * the `setAuthorization(generalAdapter1, true)` transaction when it does.
12
12
  *
13
13
  * Reads `Morpho.isAuthorized(userAddress, generalAdapter1)` on the target chain. Required before
14
- * any bundled MarketV1 path that operates on behalf of the user (`borrow`,
14
+ * any bundled Blue path that operates on behalf of the user (`borrow`,
15
15
  * `supplyCollateralBorrow`, `repayWithdrawCollateral`).
16
16
  *
17
17
  * @param params.viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
@@ -1,2 +1 @@
1
- export * from "./morphoClient.js";
2
1
  export * from "./morphoViemExtension.js";
@@ -14,5 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./morphoClient.js"), exports);
18
17
  __exportStar(require("./morphoViemExtension.js"), exports);
@@ -1,22 +1,24 @@
1
1
  import type { Client } from "viem";
2
- import type { Metadata } from "../types/index.js";
3
- import { MorphoClient } from "./morphoClient.js";
2
+ import { type Metadata, type MorphoClientType } from "../types/index.js";
4
3
  /**
5
- * Returns a viem `extend(...)` function that adds a `morpho` namespace to a viem client. The
6
- * namespace exposes a `MorphoClient` instance built from the same client and the supplied
7
- * options.
4
+ * Returns a viem `extend(...)` function that adds a stateless `morpho` namespace to a viem client.
5
+ * The namespace rides on top of the same client (one transport / chain / account) and exposes the
6
+ * protocol entity factories under `client.morpho`, so reads and writes share one client.
8
7
  *
9
- * @param _options - Optional SDK-wide options forwarded to the inner `MorphoClient`.
8
+ * Holds no state beyond configuration: no cache, no `init()`, no warm-up. Each factory call
9
+ * (`client.morpho.vaultV1`, `vaultV2`, `blue`) returns a fresh entity bound to the client.
10
+ *
11
+ * @param _options - Optional SDK-wide options forwarded to the `morpho` namespace.
10
12
  * @param _options.metadata - Optional analytics metadata applied to every transaction the
11
- * resulting `MorphoClient` builds.
13
+ * `morpho` namespace builds.
12
14
  * @param _options.supportSignature - Whether the integrator can collect EIP-712 signatures for
13
- * permit / permit2.
15
+ * permit / permit2. Defaults to `false` (classic approvals only).
14
16
  * @param _options.supportDeployless - Whether entity fetchers may use deployless multicall.
15
17
  * @returns A viem extension function — `client.extend(morphoViemExtension(...))` adds
16
18
  * `client.morpho`.
17
19
  * @example
18
20
  * ```ts
19
- * import { createWalletClient, http } from "viem";
21
+ * import { createWalletClient, http, publicActions } from "viem";
20
22
  * import { mainnet } from "viem/chains";
21
23
  * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
22
24
  *
@@ -24,8 +26,12 @@ import { MorphoClient } from "./morphoClient.js";
24
26
  * chain: mainnet,
25
27
  * transport: http(),
26
28
  * account: user,
27
- * }).extend(morphoViemExtension({ supportSignature: true }));
29
+ * })
30
+ * .extend(publicActions)
31
+ * .extend(morphoViemExtension({ supportSignature: true }));
28
32
  *
33
+ * // Native viem reads and Morpho factories share the same client:
34
+ * const block = await client.getBlockNumber();
29
35
  * const vault = client.morpho.vaultV1(vaultAddress, 1);
30
36
  * const vaultData = await vault.getData();
31
37
  * const { buildTx } = vault.deposit({
@@ -41,5 +47,5 @@ export declare function morphoViemExtension(_options?: {
41
47
  readonly supportSignature?: boolean;
42
48
  readonly supportDeployless?: boolean;
43
49
  }): <TClient extends Client>(client: TClient) => {
44
- morpho: MorphoClient;
50
+ morpho: MorphoClientType;
45
51
  };
@@ -1,23 +1,64 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.morphoViemExtension = morphoViemExtension;
4
- const morphoClient_js_1 = require("./morphoClient.js");
4
+ const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
+ const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
+ const index_js_1 = require("../entities/index.js");
7
+ const index_js_2 = require("../types/index.js");
5
8
  /**
6
- * Returns a viem `extend(...)` function that adds a `morpho` namespace to a viem client. The
7
- * namespace exposes a `MorphoClient` instance built from the same client and the supplied
8
- * options.
9
+ * Builds the stateless `morpho` namespace exposed on an extended viem client. Wraps the supplied
10
+ * viem `Client` plus a frozen options bag and exposes factory methods for the protocol entities.
9
11
  *
10
- * @param _options - Optional SDK-wide options forwarded to the inner `MorphoClient`.
12
+ * Holds no state beyond configuration: no cache, no `init()`, no warm-up. Each factory call
13
+ * (`vaultV1`, `vaultV2`, `blue`) returns a fresh entity bound to this client.
14
+ *
15
+ * @internal
16
+ */
17
+ function createMorphoNamespace(viemClient, options) {
18
+ const namespace = {
19
+ viemClient,
20
+ options: (0, morpho_ts_1.deepFreeze)({
21
+ ...options,
22
+ metadata: options?.metadata === undefined ? undefined : { ...options.metadata },
23
+ supportSignature: options?.supportSignature ?? false,
24
+ supportDeployless: options?.supportDeployless,
25
+ }),
26
+ vaultV1(vault, chainId) {
27
+ return new index_js_1.MorphoVaultV1(namespace, vault, chainId);
28
+ },
29
+ vaultV2(vault, chainId) {
30
+ return new index_js_1.MorphoVaultV2(namespace, vault, chainId);
31
+ },
32
+ blue(marketParams, chainId) {
33
+ const derivedId = blue_sdk_1.MarketUtils.getMarketId(marketParams);
34
+ // Can happen with one-time/hardcoded/agent-written possibly inconsistent input market params.
35
+ if (marketParams.id !== derivedId) {
36
+ throw new index_js_2.MarketIdMismatchError(marketParams.id, derivedId);
37
+ }
38
+ return new index_js_1.MorphoBlue(namespace, marketParams, chainId);
39
+ },
40
+ };
41
+ return namespace;
42
+ }
43
+ /**
44
+ * Returns a viem `extend(...)` function that adds a stateless `morpho` namespace to a viem client.
45
+ * The namespace rides on top of the same client (one transport / chain / account) and exposes the
46
+ * protocol entity factories under `client.morpho`, so reads and writes share one client.
47
+ *
48
+ * Holds no state beyond configuration: no cache, no `init()`, no warm-up. Each factory call
49
+ * (`client.morpho.vaultV1`, `vaultV2`, `blue`) returns a fresh entity bound to the client.
50
+ *
51
+ * @param _options - Optional SDK-wide options forwarded to the `morpho` namespace.
11
52
  * @param _options.metadata - Optional analytics metadata applied to every transaction the
12
- * resulting `MorphoClient` builds.
53
+ * `morpho` namespace builds.
13
54
  * @param _options.supportSignature - Whether the integrator can collect EIP-712 signatures for
14
- * permit / permit2.
55
+ * permit / permit2. Defaults to `false` (classic approvals only).
15
56
  * @param _options.supportDeployless - Whether entity fetchers may use deployless multicall.
16
57
  * @returns A viem extension function — `client.extend(morphoViemExtension(...))` adds
17
58
  * `client.morpho`.
18
59
  * @example
19
60
  * ```ts
20
- * import { createWalletClient, http } from "viem";
61
+ * import { createWalletClient, http, publicActions } from "viem";
21
62
  * import { mainnet } from "viem/chains";
22
63
  * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
23
64
  *
@@ -25,8 +66,12 @@ const morphoClient_js_1 = require("./morphoClient.js");
25
66
  * chain: mainnet,
26
67
  * transport: http(),
27
68
  * account: user,
28
- * }).extend(morphoViemExtension({ supportSignature: true }));
69
+ * })
70
+ * .extend(publicActions)
71
+ * .extend(morphoViemExtension({ supportSignature: true }));
29
72
  *
73
+ * // Native viem reads and Morpho factories share the same client:
74
+ * const block = await client.getBlockNumber();
30
75
  * const vault = client.morpho.vaultV1(vaultAddress, 1);
31
76
  * const vaultData = await vault.getData();
32
77
  * const { buildTx } = vault.deposit({
@@ -40,7 +85,7 @@ const morphoClient_js_1 = require("./morphoClient.js");
40
85
  function morphoViemExtension(_options) {
41
86
  return (client) => {
42
87
  return {
43
- morpho: new morphoClient_js_1.MorphoClient(client, _options),
88
+ morpho: createMorphoNamespace(client, _options),
44
89
  };
45
90
  };
46
91
  }