@morpho-org/consumer-sdk 0.3.0 → 0.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 (82) hide show
  1. package/README.md +301 -41
  2. package/lib/actions/index.d.ts +2 -0
  3. package/lib/actions/index.js +2 -0
  4. package/lib/actions/marketV1/borrow.d.ts +34 -0
  5. package/lib/actions/marketV1/borrow.js +62 -0
  6. package/lib/actions/marketV1/buildReallocationActions.d.ts +17 -0
  7. package/lib/actions/marketV1/buildReallocationActions.js +36 -0
  8. package/lib/actions/marketV1/index.d.ts +6 -0
  9. package/lib/actions/marketV1/index.js +22 -0
  10. package/lib/actions/marketV1/repay.d.ts +44 -0
  11. package/lib/actions/marketV1/repay.js +93 -0
  12. package/lib/actions/marketV1/repayWithdrawCollateral.d.ts +51 -0
  13. package/lib/actions/marketV1/repayWithdrawCollateral.js +108 -0
  14. package/lib/actions/marketV1/supplyCollateral.d.ts +28 -0
  15. package/lib/actions/marketV1/supplyCollateral.js +85 -0
  16. package/lib/actions/marketV1/supplyCollateralBorrow.d.ts +37 -0
  17. package/lib/actions/marketV1/supplyCollateralBorrow.js +109 -0
  18. package/lib/actions/marketV1/withdrawCollateral.d.ts +28 -0
  19. package/lib/actions/marketV1/withdrawCollateral.js +51 -0
  20. package/lib/actions/requirements/encode/encodeErc20Permit.js +4 -1
  21. package/lib/actions/requirements/encode/encodeErc20Permit2.js +4 -1
  22. package/lib/actions/requirements/getMorphoAuthorizationRequirement.d.ts +21 -0
  23. package/lib/actions/requirements/getMorphoAuthorizationRequirement.js +55 -0
  24. package/lib/actions/requirements/getRequirements.js +3 -0
  25. package/lib/actions/requirements/getRequirementsAction.d.ts +2 -2
  26. package/lib/actions/requirements/getRequirementsAction.js +7 -7
  27. package/lib/actions/requirements/index.d.ts +1 -0
  28. package/lib/actions/requirements/index.js +1 -0
  29. package/lib/actions/vaultV1/deposit.d.ts +41 -0
  30. package/lib/actions/vaultV1/deposit.js +116 -0
  31. package/lib/actions/vaultV1/index.d.ts +3 -0
  32. package/lib/actions/vaultV1/index.js +19 -0
  33. package/lib/actions/vaultV1/redeem.d.ts +29 -0
  34. package/lib/actions/vaultV1/redeem.js +48 -0
  35. package/lib/actions/vaultV1/withdraw.d.ts +29 -0
  36. package/lib/actions/vaultV1/withdraw.js +48 -0
  37. package/lib/actions/vaultV2/deposit.d.ts +20 -25
  38. package/lib/actions/vaultV2/deposit.js +78 -40
  39. package/lib/actions/vaultV2/forceRedeem.js +2 -2
  40. package/lib/actions/vaultV2/forceWithdraw.d.ts +2 -2
  41. package/lib/actions/vaultV2/forceWithdraw.js +12 -8
  42. package/lib/actions/vaultV2/redeem.js +2 -2
  43. package/lib/actions/vaultV2/withdraw.d.ts +3 -3
  44. package/lib/actions/vaultV2/withdraw.js +6 -6
  45. package/lib/client/morphoClient.d.ts +4 -1
  46. package/lib/client/morphoClient.js +6 -0
  47. package/lib/client/morphoViemExtension.d.ts +12 -9
  48. package/lib/client/morphoViemExtension.js +12 -9
  49. package/lib/entities/index.d.ts +2 -0
  50. package/lib/entities/index.js +2 -0
  51. package/lib/entities/marketV1/index.d.ts +1 -0
  52. package/lib/entities/marketV1/index.js +17 -0
  53. package/lib/entities/marketV1/marketV1.d.ts +290 -0
  54. package/lib/entities/marketV1/marketV1.js +528 -0
  55. package/lib/entities/vaultV1/index.d.ts +1 -0
  56. package/lib/entities/vaultV1/index.js +17 -0
  57. package/lib/entities/vaultV1/vaultV1.d.ts +95 -0
  58. package/lib/entities/vaultV1/vaultV1.js +129 -0
  59. package/lib/entities/vaultV2/vaultV2.d.ts +24 -21
  60. package/lib/entities/vaultV2/vaultV2.js +43 -16
  61. package/lib/helpers/computeReallocations.d.ts +23 -0
  62. package/lib/helpers/computeReallocations.js +98 -0
  63. package/lib/helpers/constant.d.ts +5 -0
  64. package/lib/helpers/constant.js +6 -1
  65. package/lib/helpers/encodeDeallocation.js +3 -3
  66. package/lib/helpers/index.d.ts +3 -0
  67. package/lib/helpers/index.js +18 -1
  68. package/lib/helpers/slippage.d.ts +46 -0
  69. package/lib/helpers/slippage.js +73 -0
  70. package/lib/helpers/validate.d.ts +150 -0
  71. package/lib/helpers/validate.js +279 -0
  72. package/lib/types/action.d.ts +113 -6
  73. package/lib/types/action.js +12 -1
  74. package/lib/types/client.d.ts +4 -1
  75. package/lib/types/deallocation.d.ts +1 -1
  76. package/lib/types/error.d.ts +127 -4
  77. package/lib/types/error.js +210 -12
  78. package/lib/types/index.d.ts +1 -0
  79. package/lib/types/index.js +1 -0
  80. package/lib/types/sharedLiquidity.d.ts +41 -0
  81. package/lib/types/sharedLiquidity.js +2 -0
  82. package/package.json +1 -1
@@ -4,66 +4,98 @@ exports.vaultV2Deposit = void 0;
4
4
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  const bundler_sdk_viem_1 = require("@morpho-org/bundler-sdk-viem");
6
6
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
7
+ const viem_1 = require("viem");
7
8
  const helpers_1 = require("../../helpers");
8
9
  const types_1 = require("../../types");
9
10
  const getRequirementsAction_1 = require("../requirements/getRequirementsAction");
10
11
  /**
11
12
  * Prepares a deposit transaction for the VaultV2 contract.
12
13
  *
13
- * This function constructs the transaction data required to deposit a specified amount of assets into the vault.
14
- * Bundler Integration: This flow uses the bundler to atomically execute the user's asset transfer and vault deposit in a single transaction for slippage protection.
14
+ * Routed through the bundler to atomically execute the asset transfer and vault deposit.
15
+ * The general adapter enforces `maxSharePrice` on-chain to prevent inflation attacks.
16
+ * Never bypass the general adapter.
15
17
  *
16
- * IMPORTANT FOR DEVELOPERS:
17
- * This deposit flow is routed through the general adapter in order to enforce a strict check on `maxSharePrice`.
18
- * This check is critical to prevent inflation attacks, especially for vaults where there is no "dead deposit" protection.
19
- * Do not bypass the general adapter or remove this check, as doing so would expose the flow to potential exploits.
20
- * The maxSharePrice constraint ensures that the user does not receive unfavorable share pricing due to malicious or sudden vault changes.
18
+ * When `nativeAmount` is provided, that amount of native ETH is sent as `msg.value`
19
+ * to the Bundler3 multicall and wrapped into WETH via `GeneralAdapter1.wrapNative()`.
20
+ * The vault's underlying asset must be the chain's wrapped native token (wNative).
21
21
  *
22
- *
23
- * @param {Object} params - The vault related parameters.
24
- * @param {Object} params.vault - The vault related parameters.
22
+ * @param {Object} params - The deposit parameters.
23
+ * @param {Object} params.vault - The vault identifiers.
25
24
  * @param {number} params.vault.chainId - The chain ID.
26
25
  * @param {Address} params.vault.address - The vault address.
27
- * @param {Address} params.vault.asset - The vault asset address.
28
- * @param {Object} params.args - The deposit related parameters.
29
- * @param {bigint} params.args.assets - The amount of assets to deposit.
30
- * @param {bigint} params.args.maxSharePrice - The maximum share price to accept for the deposit.
31
- * @param {Address} params.args.recipient - The recipient address.
32
- * @param {Object} params.args.requirementSignature - The requirement args and signature.
33
- * @param {Object} params.args.requirementSignature.args - The requirement signature arguments.
34
- * @param {Object} params.args.requirementSignature.action - The requirement signature action.
35
- * @param {Metadata} [params.metadata] - Optional the metadata.
36
- *
26
+ * @param {Address} params.vault.asset - The underlying ERC20 asset address.
27
+ * @param {Object} params.args - The deposit arguments.
28
+ * @param {bigint} [params.args.amount=0n] - Amount of ERC-20 assets to deposit. At least one of amount or nativeAmount must be provided.
29
+ * @param {bigint} params.args.maxSharePrice - Maximum acceptable share price (slippage protection).
30
+ * @param {Address} params.args.recipient - Receives the vault shares.
31
+ * @param {RequirementSignature} [params.args.requirementSignature] - Pre-signed permit/permit2 approval.
32
+ * @param {bigint} [params.args.nativeAmount] - Amount of native token to wrap into wNative for the deposit.
33
+ * @param {Metadata} [params.metadata] - Optional analytics metadata.
37
34
  * @returns {Readonly<Transaction<VaultV2DepositAction>>} The prepared deposit transaction.
38
35
  */
39
- const vaultV2Deposit = ({ vault: { chainId, address: vaultAddress, asset }, args: { assets, maxSharePrice, recipient, requirementSignature }, metadata, }) => {
40
- if (assets === 0n) {
41
- throw new types_1.ZeroAssetAmountError(asset);
36
+ const vaultV2Deposit = ({ vault: { chainId, address: vaultAddress, asset }, args: { amount = 0n, maxSharePrice, recipient, requirementSignature, nativeAmount, }, metadata, }) => {
37
+ if (amount < 0n) {
38
+ throw new types_1.NonPositiveAssetAmountError(asset);
42
39
  }
43
- if (maxSharePrice === 0n) {
44
- throw new types_1.ZeroMaxSharePriceError(vaultAddress);
40
+ if (maxSharePrice <= 0n) {
41
+ throw new types_1.NonPositiveMaxSharePriceError(vaultAddress);
45
42
  }
46
43
  const actions = [];
47
- if (requirementSignature) {
48
- actions.push(...(0, getRequirementsAction_1.getRequirementsAction)({
49
- chainId,
50
- asset,
51
- assets,
52
- requirementSignature,
53
- }));
54
- }
55
- else {
56
- const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
57
- actions.push({
58
- type: "erc20TransferFrom",
59
- args: [asset, assets, generalAdapter1, false],
44
+ const { bundler3: { generalAdapter1, bundler3 }, wNative, } = (0, blue_sdk_1.getChainAddresses)(chainId);
45
+ if (nativeAmount) {
46
+ if (nativeAmount < 0n) {
47
+ throw new types_1.NegativeNativeAmountError(nativeAmount);
48
+ }
49
+ if (!(0, morpho_ts_1.isDefined)(wNative)) {
50
+ throw new types_1.ChainWNativeMissingError(chainId);
51
+ }
52
+ if (!(0, viem_1.isAddressEqual)(asset, wNative)) {
53
+ throw new types_1.NativeAmountOnNonWNativeVaultError(asset, wNative);
54
+ }
55
+ actions.push(
56
+ // Transfers native token from Bundler3 to GeneralAdapter1 for wrapping.
57
+ {
58
+ type: "nativeTransfer",
59
+ args: [bundler3, generalAdapter1, nativeAmount, false /* skipRevert */],
60
+ }, {
61
+ type: "wrapNative",
62
+ args: [nativeAmount, generalAdapter1, false /* skipRevert */],
60
63
  });
61
64
  }
65
+ if (amount > 0n) {
66
+ if (requirementSignature) {
67
+ actions.push(...(0, getRequirementsAction_1.getRequirementsAction)({
68
+ chainId,
69
+ asset,
70
+ amount,
71
+ requirementSignature,
72
+ }));
73
+ }
74
+ else {
75
+ actions.push({
76
+ type: "erc20TransferFrom",
77
+ args: [asset, amount, generalAdapter1, false /* skipRevert */],
78
+ });
79
+ }
80
+ }
81
+ const totalAssets = amount + (nativeAmount ?? 0n);
82
+ if (totalAssets === 0n) {
83
+ throw new types_1.ZeroDepositAmountError(vaultAddress);
84
+ }
62
85
  actions.push({
63
86
  type: "erc4626Deposit",
64
- args: [vaultAddress, assets, maxSharePrice, recipient, false],
87
+ args: [
88
+ vaultAddress,
89
+ totalAssets,
90
+ maxSharePrice,
91
+ recipient,
92
+ false /* skipRevert */,
93
+ ],
65
94
  });
66
95
  let tx = bundler_sdk_viem_1.BundlerAction.encodeBundle(chainId, actions);
96
+ if (nativeAmount) {
97
+ tx = { ...tx, value: nativeAmount };
98
+ }
67
99
  if (metadata) {
68
100
  tx = (0, helpers_1.addTransactionMetadata)(tx, metadata);
69
101
  }
@@ -71,7 +103,13 @@ const vaultV2Deposit = ({ vault: { chainId, address: vaultAddress, asset }, args
71
103
  ...tx,
72
104
  action: {
73
105
  type: "vaultV2Deposit",
74
- args: { vault: vaultAddress, assets, maxSharePrice, recipient },
106
+ args: {
107
+ vault: vaultAddress,
108
+ amount,
109
+ maxSharePrice,
110
+ recipient,
111
+ nativeAmount,
112
+ },
75
113
  },
76
114
  });
77
115
  };
@@ -42,8 +42,8 @@ const vaultV2ForceRedeem = ({ vault: { address: vaultAddress }, args: { dealloca
42
42
  if (deallocations.length === 0) {
43
43
  throw new types_1.EmptyDeallocationsError(vaultAddress);
44
44
  }
45
- if (redeem.shares === 0n) {
46
- throw new types_1.ZeroSharesAmountError(vaultAddress);
45
+ if (redeem.shares <= 0n) {
46
+ throw new types_1.NonPositiveSharesAmountError(vaultAddress);
47
47
  }
48
48
  const calls = [];
49
49
  for (const deallocation of deallocations) {
@@ -7,7 +7,7 @@ export interface VaultV2ForceWithdrawParams {
7
7
  args: {
8
8
  deallocations: readonly Deallocation[];
9
9
  withdraw: {
10
- assets: bigint;
10
+ amount: bigint;
11
11
  recipient: Address;
12
12
  };
13
13
  onBehalf: Address;
@@ -31,7 +31,7 @@ export interface VaultV2ForceWithdrawParams {
31
31
  * @param {Object} params.args - The force withdraw related parameters.
32
32
  * @param {readonly Deallocation[]} params.args.deallocations - The list of deallocations to perform.
33
33
  * @param {Object} params.args.withdraw - The withdraw parameters applied after deallocations.
34
- * @param {bigint} params.args.withdraw.assets - The amount of assets to withdraw.
34
+ * @param {bigint} params.args.withdraw.amount - The amount of assets to withdraw.
35
35
  * @param {Address} params.args.withdraw.recipient - The recipient of the withdrawn assets.
36
36
  * @param {Address} params.args.onBehalf - The address from which the penalty is taken (share owner).
37
37
  * @param {Metadata} [params.metadata] - Optional analytics metadata to append.
@@ -24,7 +24,7 @@ const types_1 = require("../../types");
24
24
  * @param {Object} params.args - The force withdraw related parameters.
25
25
  * @param {readonly Deallocation[]} params.args.deallocations - The list of deallocations to perform.
26
26
  * @param {Object} params.args.withdraw - The withdraw parameters applied after deallocations.
27
- * @param {bigint} params.args.withdraw.assets - The amount of assets to withdraw.
27
+ * @param {bigint} params.args.withdraw.amount - The amount of assets to withdraw.
28
28
  * @param {Address} params.args.withdraw.recipient - The recipient of the withdrawn assets.
29
29
  * @param {Address} params.args.onBehalf - The address from which the penalty is taken (share owner).
30
30
  * @param {Metadata} [params.metadata] - Optional analytics metadata to append.
@@ -34,12 +34,16 @@ const vaultV2ForceWithdraw = ({ vault: { address: vaultAddress }, args: { deallo
34
34
  if (deallocations.length === 0) {
35
35
  throw new types_1.EmptyDeallocationsError(vaultAddress);
36
36
  }
37
- if (withdraw.assets === 0n) {
38
- throw new types_1.ZeroAssetAmountError(vaultAddress);
37
+ if (withdraw.amount <= 0n) {
38
+ throw new types_1.NonPositiveAssetAmountError(vaultAddress);
39
39
  }
40
- const totalDeallocated = deallocations.reduce((sum, d) => sum + d.assets, 0n);
41
- if (withdraw.assets < totalDeallocated) {
42
- throw new types_1.DeallocationsExceedWithdrawError(vaultAddress, withdraw.assets, totalDeallocated);
40
+ const totalDeallocated = deallocations.reduce((sum, d) => sum + d.amount, 0n);
41
+ if (withdraw.amount < totalDeallocated) {
42
+ throw new types_1.DeallocationsExceedWithdrawError({
43
+ vault: vaultAddress,
44
+ withdrawAmount: withdraw.amount,
45
+ totalDeallocated,
46
+ });
43
47
  }
44
48
  const calls = [];
45
49
  for (const deallocation of deallocations) {
@@ -48,7 +52,7 @@ const vaultV2ForceWithdraw = ({ vault: { address: vaultAddress }, args: { deallo
48
52
  calls.push((0, viem_1.encodeFunctionData)({
49
53
  abi: blue_sdk_viem_1.vaultV2Abi,
50
54
  functionName: "withdraw",
51
- args: [withdraw.assets, withdraw.recipient, onBehalf],
55
+ args: [withdraw.amount, withdraw.recipient, onBehalf],
52
56
  }));
53
57
  let tx = {
54
58
  to: vaultAddress,
@@ -70,7 +74,7 @@ const vaultV2ForceWithdraw = ({ vault: { address: vaultAddress }, args: { deallo
70
74
  vault: vaultAddress,
71
75
  deallocations: deallocations.map((d) => ({ ...d })),
72
76
  withdraw: {
73
- assets: withdraw.assets,
77
+ amount: withdraw.amount,
74
78
  recipient: withdraw.recipient,
75
79
  },
76
80
  onBehalf,
@@ -25,8 +25,8 @@ const types_1 = require("../../types");
25
25
  * @returns {Readonly<Transaction<VaultV2RedeemAction>>} The prepared redeem transaction.
26
26
  */
27
27
  const vaultV2Redeem = ({ vault: { address: vaultAddress }, args: { shares, recipient, onBehalf }, metadata, }) => {
28
- if (shares === 0n) {
29
- throw new types_1.ZeroSharesAmountError(vaultAddress);
28
+ if (shares <= 0n) {
29
+ throw new types_1.NonPositiveSharesAmountError(vaultAddress);
30
30
  }
31
31
  let tx = {
32
32
  to: vaultAddress,
@@ -5,7 +5,7 @@ export interface VaultV2WithdrawParams {
5
5
  address: Address;
6
6
  };
7
7
  args: {
8
- assets: bigint;
8
+ amount: bigint;
9
9
  recipient: Address;
10
10
  onBehalf: Address;
11
11
  };
@@ -23,10 +23,10 @@ export interface VaultV2WithdrawParams {
23
23
  * @param {Object} params.vault - The vault related parameters.
24
24
  * @param {Address} params.vault.address - The vault address.
25
25
  * @param {Object} params.args - The withdraw related parameters.
26
- * @param {bigint} params.args.assets - The amount of assets to withdraw.
26
+ * @param {bigint} params.args.amount - The amount of assets to withdraw.
27
27
  * @param {Address} params.args.recipient - The recipient address.
28
28
  * @param {Address} params.args.onBehalf - The address on behalf of which the withdraw is made.
29
29
  * @param {Metadata} [params.metadata] - Optional the metadata.
30
30
  * @returns {Readonly<Transaction<VaultV2WithdrawAction>>} The prepared withdraw transaction.
31
31
  */
32
- export declare const vaultV2Withdraw: ({ vault: { address: vaultAddress }, args: { assets, recipient, onBehalf }, metadata, }: VaultV2WithdrawParams) => Readonly<Transaction<VaultV2WithdrawAction>>;
32
+ export declare const vaultV2Withdraw: ({ vault: { address: vaultAddress }, args: { amount, recipient, onBehalf }, metadata, }: VaultV2WithdrawParams) => Readonly<Transaction<VaultV2WithdrawAction>>;
@@ -18,22 +18,22 @@ const types_1 = require("../../types");
18
18
  * @param {Object} params.vault - The vault related parameters.
19
19
  * @param {Address} params.vault.address - The vault address.
20
20
  * @param {Object} params.args - The withdraw related parameters.
21
- * @param {bigint} params.args.assets - The amount of assets to withdraw.
21
+ * @param {bigint} params.args.amount - The amount of assets to withdraw.
22
22
  * @param {Address} params.args.recipient - The recipient address.
23
23
  * @param {Address} params.args.onBehalf - The address on behalf of which the withdraw is made.
24
24
  * @param {Metadata} [params.metadata] - Optional the metadata.
25
25
  * @returns {Readonly<Transaction<VaultV2WithdrawAction>>} The prepared withdraw transaction.
26
26
  */
27
- const vaultV2Withdraw = ({ vault: { address: vaultAddress }, args: { assets, recipient, onBehalf }, metadata, }) => {
28
- if (assets === 0n) {
29
- throw new types_1.ZeroAssetAmountError(vaultAddress);
27
+ const vaultV2Withdraw = ({ vault: { address: vaultAddress }, args: { amount, recipient, onBehalf }, metadata, }) => {
28
+ if (amount <= 0n) {
29
+ throw new types_1.NonPositiveAssetAmountError(vaultAddress);
30
30
  }
31
31
  let tx = {
32
32
  to: vaultAddress,
33
33
  data: (0, viem_1.encodeFunctionData)({
34
34
  abi: blue_sdk_viem_1.vaultV2Abi,
35
35
  functionName: "withdraw",
36
- args: [assets, recipient, onBehalf],
36
+ args: [amount, recipient, onBehalf],
37
37
  }),
38
38
  value: 0n,
39
39
  };
@@ -44,7 +44,7 @@ const vaultV2Withdraw = ({ vault: { address: vaultAddress }, args: { assets, rec
44
44
  ...tx,
45
45
  action: {
46
46
  type: "vaultV2Withdraw",
47
- args: { vault: vaultAddress, assets, recipient },
47
+ args: { vault: vaultAddress, amount, recipient },
48
48
  },
49
49
  });
50
50
  };
@@ -1,5 +1,6 @@
1
+ import type { MarketParams } from "@morpho-org/blue-sdk";
1
2
  import type { Address, Client } from "viem";
2
- import { MorphoVaultV2 } from "../entities";
3
+ import { MorphoMarketV1, MorphoVaultV1, MorphoVaultV2 } from "../entities";
3
4
  import type { Metadata, MorphoClientType } from "../types";
4
5
  export declare class MorphoClient implements MorphoClientType {
5
6
  readonly viemClient: Client;
@@ -18,5 +19,7 @@ export declare class MorphoClient implements MorphoClientType {
18
19
  readonly supportDeployless?: boolean;
19
20
  readonly metadata?: Metadata;
20
21
  } | undefined);
22
+ vaultV1(vault: Address, chainId: number): MorphoVaultV1;
21
23
  vaultV2(vault: Address, chainId: number): MorphoVaultV2;
24
+ marketV1(marketParams: MarketParams, chainId: number): MorphoMarketV1;
22
25
  }
@@ -15,8 +15,14 @@ class MorphoClient {
15
15
  supportDeployless: _options?.supportDeployless,
16
16
  };
17
17
  }
18
+ vaultV1(vault, chainId) {
19
+ return new entities_1.MorphoVaultV1(this, vault, chainId);
20
+ }
18
21
  vaultV2(vault, chainId) {
19
22
  return new entities_1.MorphoVaultV2(this, vault, chainId);
20
23
  }
24
+ marketV1(marketParams, chainId) {
25
+ return new entities_1.MorphoMarketV1(this, marketParams, chainId);
26
+ }
21
27
  }
22
28
  exports.MorphoClient = MorphoClient;
@@ -3,18 +3,18 @@ import type { Metadata } from "../types";
3
3
  import { MorphoClient } from "./morphoClient";
4
4
  /**
5
5
  * Morpho extension for viem clients.
6
- * Adds `morpho` namespace to viem clients with vaultV2 actions.
6
+ * Adds `morpho` namespace with `vaultV1` and `vaultV2` accessors.
7
7
  *
8
- * @param metadata - (Optional) Metadata object that will be passed to all morpho actions. If provided, this metadata can be used for analytics, logging, or to carry additional information with each action.
9
- * @param supportSignature - (Optional) Whether to support off-chain signature requirements. If true, the SDK will try to use permit or permit2 if the token supports it.
10
- * @param supportDeployless - (Optional) Whether to support deployless mode. If true, the SDK will use the deployless mode to fetch data.
11
- * @returns Extension function that adds morpho namespace to viem clients
8
+ * @param metadata - (Optional) Metadata appended to all transactions for analytics.
9
+ * @param supportSignature - (Optional) Enable off-chain permit/permit2 approvals.
10
+ * @param supportDeployless - (Optional) Enable deployless reads for on-chain data fetching.
11
+ * @returns Extension function that adds morpho namespace to viem clients.
12
12
  *
13
13
  * @example
14
14
  * ```ts
15
15
  * import { createWalletClient, http } from 'viem';
16
16
  * import { mainnet } from 'viem/chains';
17
- * import { morpho } from '@morpho-org/consumer-sdk';
17
+ * import { morphoViemExtension } from '@morpho-org/consumer-sdk';
18
18
  *
19
19
  * const client = createWalletClient({
20
20
  * chain: mainnet,
@@ -22,9 +22,12 @@ import { MorphoClient } from "./morphoClient";
22
22
  * account: '0x...',
23
23
  * }).extend(morphoViemExtension());
24
24
  *
25
- * // Use morpho actions
26
- * const vault = client.morpho.vaultV2('0x...');
27
- * const deposit = await vault.deposit({ assets: 1000000000000000000n });
25
+ * // VaultV1 (MetaMorpho)
26
+ * const vaultV1 = client.morpho.vaultV1('0x...', 1);
27
+ * const depositV1 = await vaultV1.deposit({ amount: 1000000000000000000n, userAddress: '0x...' });
28
+ *
29
+ * // VaultV2
30
+ * const vaultV2 = client.morpho.vaultV2('0x...', 1);
28
31
  * ```
29
32
  */
30
33
  export declare function morphoViemExtension(_options?: {
@@ -4,18 +4,18 @@ exports.morphoViemExtension = morphoViemExtension;
4
4
  const morphoClient_1 = require("./morphoClient");
5
5
  /**
6
6
  * Morpho extension for viem clients.
7
- * Adds `morpho` namespace to viem clients with vaultV2 actions.
7
+ * Adds `morpho` namespace with `vaultV1` and `vaultV2` accessors.
8
8
  *
9
- * @param metadata - (Optional) Metadata object that will be passed to all morpho actions. If provided, this metadata can be used for analytics, logging, or to carry additional information with each action.
10
- * @param supportSignature - (Optional) Whether to support off-chain signature requirements. If true, the SDK will try to use permit or permit2 if the token supports it.
11
- * @param supportDeployless - (Optional) Whether to support deployless mode. If true, the SDK will use the deployless mode to fetch data.
12
- * @returns Extension function that adds morpho namespace to viem clients
9
+ * @param metadata - (Optional) Metadata appended to all transactions for analytics.
10
+ * @param supportSignature - (Optional) Enable off-chain permit/permit2 approvals.
11
+ * @param supportDeployless - (Optional) Enable deployless reads for on-chain data fetching.
12
+ * @returns Extension function that adds morpho namespace to viem clients.
13
13
  *
14
14
  * @example
15
15
  * ```ts
16
16
  * import { createWalletClient, http } from 'viem';
17
17
  * import { mainnet } from 'viem/chains';
18
- * import { morpho } from '@morpho-org/consumer-sdk';
18
+ * import { morphoViemExtension } from '@morpho-org/consumer-sdk';
19
19
  *
20
20
  * const client = createWalletClient({
21
21
  * chain: mainnet,
@@ -23,9 +23,12 @@ const morphoClient_1 = require("./morphoClient");
23
23
  * account: '0x...',
24
24
  * }).extend(morphoViemExtension());
25
25
  *
26
- * // Use morpho actions
27
- * const vault = client.morpho.vaultV2('0x...');
28
- * const deposit = await vault.deposit({ assets: 1000000000000000000n });
26
+ * // VaultV1 (MetaMorpho)
27
+ * const vaultV1 = client.morpho.vaultV1('0x...', 1);
28
+ * const depositV1 = await vaultV1.deposit({ amount: 1000000000000000000n, userAddress: '0x...' });
29
+ *
30
+ * // VaultV2
31
+ * const vaultV2 = client.morpho.vaultV2('0x...', 1);
29
32
  * ```
30
33
  */
31
34
  function morphoViemExtension(_options) {
@@ -1 +1,3 @@
1
+ export * from "./marketV1";
2
+ export * from "./vaultV1";
1
3
  export * from "./vaultV2";
@@ -14,4 +14,6 @@ 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"), exports);
18
+ __exportStar(require("./vaultV1"), exports);
17
19
  __exportStar(require("./vaultV2"), exports);
@@ -0,0 +1 @@
1
+ export * from "./marketV1";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./marketV1"), exports);