@morpho-org/consumer-sdk 0.0.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 (50) hide show
  1. package/README.md +83 -0
  2. package/lib/actions/index.d.ts +2 -0
  3. package/lib/actions/index.js +18 -0
  4. package/lib/actions/requirements/encodeErc20Approval.d.ts +10 -0
  5. package/lib/actions/requirements/encodeErc20Approval.js +25 -0
  6. package/lib/actions/requirements/getRequirements.d.ts +11 -0
  7. package/lib/actions/requirements/getRequirements.js +37 -0
  8. package/lib/actions/requirements/index.d.ts +2 -0
  9. package/lib/actions/requirements/index.js +18 -0
  10. package/lib/actions/vaultV2/deposit.d.ts +42 -0
  11. package/lib/actions/vaultV2/deposit.js +65 -0
  12. package/lib/actions/vaultV2/index.d.ts +3 -0
  13. package/lib/actions/vaultV2/index.js +19 -0
  14. package/lib/actions/vaultV2/redeem.d.ts +32 -0
  15. package/lib/actions/vaultV2/redeem.js +51 -0
  16. package/lib/actions/vaultV2/withdraw.d.ts +32 -0
  17. package/lib/actions/vaultV2/withdraw.js +51 -0
  18. package/lib/client/index.d.ts +2 -0
  19. package/lib/client/index.js +18 -0
  20. package/lib/client/morphoClient.d.ts +9 -0
  21. package/lib/client/morphoClient.js +16 -0
  22. package/lib/client/morphoViemExtension.d.ts +30 -0
  23. package/lib/client/morphoViemExtension.js +35 -0
  24. package/lib/entities/index.d.ts +1 -0
  25. package/lib/entities/index.js +17 -0
  26. package/lib/entities/vaultV2/index.d.ts +1 -0
  27. package/lib/entities/vaultV2/index.js +17 -0
  28. package/lib/entities/vaultV2/vaultV2.d.ts +98 -0
  29. package/lib/entities/vaultV2/vaultV2.js +79 -0
  30. package/lib/helpers/index.d.ts +1 -0
  31. package/lib/helpers/index.js +5 -0
  32. package/lib/helpers/metadata.d.ts +33 -0
  33. package/lib/helpers/metadata.js +49 -0
  34. package/lib/index.d.ts +6 -0
  35. package/lib/index.js +24 -0
  36. package/lib/sdk/index.d.ts +10 -0
  37. package/lib/sdk/index.js +26 -0
  38. package/lib/types/action.d.ts +36 -0
  39. package/lib/types/action.js +2 -0
  40. package/lib/types/client.d.ts +8 -0
  41. package/lib/types/client.js +2 -0
  42. package/lib/types/entity.d.ts +5 -0
  43. package/lib/types/entity.js +2 -0
  44. package/lib/types/error.d.ts +19 -0
  45. package/lib/types/error.js +39 -0
  46. package/lib/types/index.d.ts +5 -0
  47. package/lib/types/index.js +21 -0
  48. package/lib/types/metadata.d.ts +4 -0
  49. package/lib/types/metadata.js +2 -0
  50. package/package.json +58 -0
@@ -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("./vaultV2"), exports);
@@ -0,0 +1 @@
1
+ export * from "./vaultV2";
@@ -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("./vaultV2"), exports);
@@ -0,0 +1,98 @@
1
+ import { fetchAccrualVaultV2 } from "@morpho-org/blue-sdk-viem";
2
+ import type { Address } from "viem";
3
+ import { type ERC20ApprovalAction, type MorphoClientType, type Transaction, type VaultV2DepositAction, type VaultV2RedeemAction, type VaultV2WithdrawAction } from "../../types";
4
+ export interface VaultV2Actions {
5
+ /**
6
+ * Fetches the latest vault data.
7
+ *
8
+ * This function fetches the latest vault data from the blockchain.
9
+ *
10
+ * @returns {Promise<Awaited<ReturnType<typeof fetchAccrualVaultV2>>>} The latest vault data.
11
+ */
12
+ getData: () => Promise<Awaited<ReturnType<typeof fetchAccrualVaultV2>>>;
13
+ /**
14
+ * Prepares a deposit transaction for the VaultV2 contract.
15
+ *
16
+ * This function constructs the transaction data required to deposit a specified amount of assets into the vault.
17
+ * The function asynchronously fetches the latest vault data to ensure accurate calculations for slippage and asset address,
18
+ * then returns the prepared deposit transaction and a function for retrieving all required approval transactions.
19
+ * 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.
20
+ *
21
+ * @param {Object} params - The deposit parameters.
22
+ * @param {bigint} params.assets - The amount of assets to deposit.
23
+ * @param {Address} [params.userAddress] - Optional user address initiating the deposit. Default is the client's user address is used.
24
+ * @param {bigint} [params.slippageTolerance=DEFAULT_SLIPPAGE_TOLERANCE] - Optional slippage tolerance value. Default is 0.03%.
25
+ * @returns {Object} The result object.
26
+ * @returns {Readonly<Transaction<VaultV2DepositAction>>} returns.tx The prepared deposit transaction.
27
+ * @returns {Promise<Readonly<Transaction<ERC20ApprovalAction>[]>>} returns.getRequirements The function for retrieving all required approval transactions.
28
+ */
29
+ deposit: (params: {
30
+ assets: bigint;
31
+ userAddress: Address;
32
+ slippageTolerance?: bigint;
33
+ }) => Promise<{
34
+ buildTx: () => Readonly<Transaction<VaultV2DepositAction>>;
35
+ getRequirements: () => Promise<Readonly<Transaction<ERC20ApprovalAction>[]>>;
36
+ }>;
37
+ /**
38
+ * Prepares a withdraw transaction for the VaultV2 contract.
39
+ *
40
+ * This function constructs the transaction data required to withdraw a specified amount of assets from the vault.
41
+ *
42
+ * @param {Object} params - The withdraw parameters.
43
+ * @param {bigint} params.assets - The amount of assets to withdraw.
44
+ * @param {Address} [params.userAddress] - Optional user address initiating the withdraw.
45
+ * @returns {Object} The result object.
46
+ * @returns {Readonly<Transaction<VaultV2WithdrawAction>>} returns.tx The prepared withdraw transaction.
47
+ */
48
+ withdraw: (params: {
49
+ assets: bigint;
50
+ userAddress: Address;
51
+ }) => {
52
+ buildTx: () => Readonly<Transaction<VaultV2WithdrawAction>>;
53
+ };
54
+ /**
55
+ * Prepares a redeem transaction for the VaultV2 contract.
56
+ *
57
+ * This function constructs the transaction data required to redeem a specified amount of shares from the vault.
58
+ *
59
+ * @param {Object} params - The redeem parameters.
60
+ * @param {bigint} params.shares - The amount of shares to redeem.
61
+ * @param {Address} [params.userAddress] - Optional user address initiating the redeem.
62
+ * @returns {Object} The result object.
63
+ * @returns {Readonly<Transaction<VaultV2RedeemAction>>} returns.tx The prepared redeem transaction.
64
+ */
65
+ redeem: (params: {
66
+ shares: bigint;
67
+ userAddress: Address;
68
+ }) => {
69
+ buildTx: () => Readonly<Transaction<VaultV2RedeemAction>>;
70
+ };
71
+ }
72
+ export declare class MorphoVaultV2 implements VaultV2Actions {
73
+ private readonly client;
74
+ private readonly vault;
75
+ private readonly chainId;
76
+ constructor(client: MorphoClientType, vault: Address, chainId: number);
77
+ getData(): Promise<import("@morpho-org/blue-sdk").AccrualVaultV2>;
78
+ deposit({ assets, userAddress, slippageTolerance, }: {
79
+ assets: bigint;
80
+ userAddress: Address;
81
+ slippageTolerance?: bigint;
82
+ }): Promise<{
83
+ buildTx: () => Readonly<Transaction<VaultV2DepositAction>>;
84
+ getRequirements: () => Promise<readonly Transaction<ERC20ApprovalAction>[]>;
85
+ }>;
86
+ withdraw({ assets, userAddress }: {
87
+ assets: bigint;
88
+ userAddress: Address;
89
+ }): {
90
+ buildTx: () => Readonly<Transaction<VaultV2WithdrawAction>>;
91
+ };
92
+ redeem({ shares, userAddress }: {
93
+ shares: bigint;
94
+ userAddress: Address;
95
+ }): {
96
+ buildTx: () => Readonly<Transaction<VaultV2RedeemAction>>;
97
+ };
98
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MorphoVaultV2 = void 0;
4
+ const blue_sdk_1 = require("@morpho-org/blue-sdk");
5
+ const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
6
+ const actions_1 = require("../../actions");
7
+ const types_1 = require("../../types");
8
+ class MorphoVaultV2 {
9
+ client;
10
+ vault;
11
+ chainId;
12
+ constructor(client, vault, chainId) {
13
+ this.client = client;
14
+ this.vault = vault;
15
+ this.chainId = chainId;
16
+ }
17
+ async getData() {
18
+ return (0, blue_sdk_viem_1.fetchAccrualVaultV2)(this.vault, this.client.viemClient);
19
+ }
20
+ async deposit({ assets, userAddress, slippageTolerance = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, }) {
21
+ if (this.client.viemClient.chain?.id !== this.chainId) {
22
+ throw new types_1.ChainIdMismatchError(this.client.viemClient.chain?.id, this.chainId);
23
+ }
24
+ const vaultData = await (0, blue_sdk_viem_1.fetchVaultV2)(this.vault, this.client.viemClient);
25
+ const maxSharePrice = blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.mulDivUp(assets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD + slippageTolerance), vaultData.toShares(assets)), blue_sdk_1.MathLib.RAY * 100n);
26
+ return {
27
+ buildTx: () => (0, actions_1.vaultV2Deposit)({
28
+ vault: {
29
+ chainId: this.chainId,
30
+ address: this.vault,
31
+ asset: vaultData.asset,
32
+ },
33
+ args: {
34
+ assets,
35
+ maxSharePrice,
36
+ recipient: userAddress,
37
+ },
38
+ metadata: this.client.metadata,
39
+ }),
40
+ getRequirements: async () => {
41
+ return (0, actions_1.getRequirements)(this.client.viemClient, {
42
+ address: vaultData.asset,
43
+ chainId: this.chainId,
44
+ args: {
45
+ amount: assets,
46
+ from: userAddress,
47
+ },
48
+ });
49
+ },
50
+ };
51
+ }
52
+ withdraw({ assets, userAddress }) {
53
+ return {
54
+ buildTx: () => (0, actions_1.vaultV2Withdraw)({
55
+ vault: { address: this.vault },
56
+ args: {
57
+ assets,
58
+ recipient: userAddress,
59
+ onBehalf: userAddress,
60
+ },
61
+ metadata: this.client.metadata,
62
+ }),
63
+ };
64
+ }
65
+ redeem({ shares, userAddress }) {
66
+ return {
67
+ buildTx: () => (0, actions_1.vaultV2Redeem)({
68
+ vault: { address: this.vault },
69
+ args: {
70
+ shares,
71
+ recipient: userAddress,
72
+ onBehalf: userAddress,
73
+ },
74
+ metadata: this.client.metadata,
75
+ }),
76
+ };
77
+ }
78
+ }
79
+ exports.MorphoVaultV2 = MorphoVaultV2;
@@ -0,0 +1 @@
1
+ export { addTransactionMetadata } from "./metadata";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addTransactionMetadata = void 0;
4
+ var metadata_1 = require("./metadata");
5
+ Object.defineProperty(exports, "addTransactionMetadata", { enumerable: true, get: function () { return metadata_1.addTransactionMetadata; } });
@@ -0,0 +1,33 @@
1
+ import { type Address, type Hex } from "viem";
2
+ import type { Metadata } from "../types";
3
+ /**
4
+ * Adds metadata to a transaction object by concatenating additional
5
+ * hex-encoded data to the transaction's `data` field. The additional
6
+ * data may include a timestamp and an origin identifier derived
7
+ * from the metadata.
8
+ *
9
+ * The function ensures that the transaction data is correctly formatted
10
+ * and includes optional metadata elements if provided.
11
+ *
12
+ * @param {Object} tx - The original transaction object.
13
+ * @param {Hex} tx.data - The existing hex-encoded data for the transaction.
14
+ * @param {bigint} tx.value - The value to be sent with the transaction.
15
+ * @param {Address} tx.to - The recipient address of the transaction.
16
+ * @param {Metadata} metadata - An object containing optional metadata fields
17
+ * such as `timestamp` and `origin`.
18
+ *
19
+ * @returns {Object} - A new transaction object with the modified `data` field
20
+ * including the concatenated metadata.
21
+ *
22
+ * If no `data` is present in the original transaction, the function returns
23
+ * the transaction unmodified.
24
+ */
25
+ export declare function addTransactionMetadata(tx: {
26
+ data: Hex;
27
+ value: bigint;
28
+ to: Address;
29
+ }, metadata: Metadata): {
30
+ data: Hex;
31
+ value: bigint;
32
+ to: Address;
33
+ };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addTransactionMetadata = addTransactionMetadata;
4
+ const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
+ const viem_1 = require("viem");
6
+ /**
7
+ * Adds metadata to a transaction object by concatenating additional
8
+ * hex-encoded data to the transaction's `data` field. The additional
9
+ * data may include a timestamp and an origin identifier derived
10
+ * from the metadata.
11
+ *
12
+ * The function ensures that the transaction data is correctly formatted
13
+ * and includes optional metadata elements if provided.
14
+ *
15
+ * @param {Object} tx - The original transaction object.
16
+ * @param {Hex} tx.data - The existing hex-encoded data for the transaction.
17
+ * @param {bigint} tx.value - The value to be sent with the transaction.
18
+ * @param {Address} tx.to - The recipient address of the transaction.
19
+ * @param {Metadata} metadata - An object containing optional metadata fields
20
+ * such as `timestamp` and `origin`.
21
+ *
22
+ * @returns {Object} - A new transaction object with the modified `data` field
23
+ * including the concatenated metadata.
24
+ *
25
+ * If no `data` is present in the original transaction, the function returns
26
+ * the transaction unmodified.
27
+ */
28
+ function addTransactionMetadata(tx, metadata) {
29
+ const { data, ..._tx } = tx;
30
+ if (!data)
31
+ return tx;
32
+ const concatItems = [data];
33
+ if (metadata.timestamp) {
34
+ concatItems.push((0, viem_1.numberToHex)(morpho_ts_1.Time.timestamp(), { size: 4 }));
35
+ }
36
+ try {
37
+ const origin = metadata.origin.replace(/^(?!0x)/, "");
38
+ if (!(0, viem_1.isHex)(`0x${origin}`))
39
+ throw Error("Calldata origin must consists of only hex characters");
40
+ if (origin.length > 8)
41
+ throw Error("Calldata origin must be at most 8 characters long");
42
+ concatItems.push(`0x${origin}`);
43
+ }
44
+ catch (error) {
45
+ // eslint-disable-next-line no-console
46
+ console.warn("Invalid calldata origin:\n", error);
47
+ }
48
+ return { data: (0, viem_1.concatHex)(concatItems), ..._tx };
49
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./actions";
2
+ export * from "./client";
3
+ export * from "./entities";
4
+ export * from "./helpers";
5
+ export * from "./sdk";
6
+ export * from "./types";
package/lib/index.js ADDED
@@ -0,0 +1,24 @@
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("./actions"), exports);
18
+ __exportStar(require("./client"), exports);
19
+ __exportStar(require("./entities"), exports);
20
+ __exportStar(require("./helpers"), exports);
21
+ // Unified Morpho SDK exports
22
+ // All Morpho packages are available through this single import
23
+ __exportStar(require("./sdk"), exports);
24
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Morpho SDK Unified Exports
3
+ *
4
+ * This module provides a unified interface to all Morpho packages.
5
+ * Users can import any functionality from any Morpho package through this single entry point.
6
+ */
7
+ export * from "@morpho-org/blue-sdk";
8
+ export * from "@morpho-org/blue-sdk-viem";
9
+ export * from "@morpho-org/bundler-sdk-viem";
10
+ export * from "@morpho-org/morpho-ts";
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /**
3
+ * Morpho SDK Unified Exports
4
+ *
5
+ * This module provides a unified interface to all Morpho packages.
6
+ * Users can import any functionality from any Morpho package through this single entry point.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ __exportStar(require("@morpho-org/blue-sdk"), exports);
24
+ __exportStar(require("@morpho-org/blue-sdk-viem"), exports);
25
+ __exportStar(require("@morpho-org/bundler-sdk-viem"), exports);
26
+ __exportStar(require("@morpho-org/morpho-ts"), exports);
@@ -0,0 +1,36 @@
1
+ import type { Address, Hex } from "viem";
2
+ export interface BaseAction<TType extends string = string, TArgs extends Record<string, unknown> = Record<string, unknown>> {
3
+ readonly type: TType;
4
+ readonly args: TArgs;
5
+ }
6
+ export interface ERC20ApprovalAction extends BaseAction<"erc20Approval", {
7
+ spender: Address;
8
+ amount: bigint;
9
+ }> {
10
+ }
11
+ export interface VaultV2DepositAction extends BaseAction<"vaultV2Deposit", {
12
+ vault: Address;
13
+ assets: bigint;
14
+ maxSharePrice: bigint;
15
+ recipient: Address;
16
+ }> {
17
+ }
18
+ export interface VaultV2WithdrawAction extends BaseAction<"vaultV2Withdraw", {
19
+ vault: Address;
20
+ assets: bigint;
21
+ recipient: Address;
22
+ }> {
23
+ }
24
+ export interface VaultV2RedeemAction extends BaseAction<"vaultV2Redeem", {
25
+ vault: Address;
26
+ shares: bigint;
27
+ recipient: Address;
28
+ }> {
29
+ }
30
+ export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction;
31
+ export interface Transaction<TAction extends BaseAction = TransactionAction> {
32
+ readonly to: Address;
33
+ readonly value: bigint;
34
+ readonly data: Hex;
35
+ readonly action: TAction;
36
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import type { Address, Client } from "viem";
2
+ import type { VaultV2Actions } from "../entities";
3
+ import type { Metadata } from "./index";
4
+ export interface MorphoClientType {
5
+ readonly viemClient: Client;
6
+ readonly metadata?: Metadata;
7
+ vaultV2: (vault: Address, chainId: number) => VaultV2Actions;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import type { Address } from "viem";
2
+ export interface VaultParams {
3
+ vault: Address;
4
+ asset: Address;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ import type { Address } from "viem";
2
+ export declare class MissingAddressError extends Error {
3
+ constructor();
4
+ }
5
+ export declare class MissingChainIdError extends Error {
6
+ constructor();
7
+ }
8
+ export declare class ZeroAssetAmountError extends Error {
9
+ constructor(asset: Address);
10
+ }
11
+ export declare class ZeroSharesAmountError extends Error {
12
+ constructor(vault: Address);
13
+ }
14
+ export declare class ZeroMaxSharePriceError extends Error {
15
+ constructor(vault: Address);
16
+ }
17
+ export declare class ChainIdMismatchError extends Error {
18
+ constructor(clientChainId: number | undefined, argsChainId: number);
19
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChainIdMismatchError = exports.ZeroMaxSharePriceError = exports.ZeroSharesAmountError = exports.ZeroAssetAmountError = exports.MissingChainIdError = exports.MissingAddressError = void 0;
4
+ class MissingAddressError extends Error {
5
+ constructor() {
6
+ super("User address not found.");
7
+ }
8
+ }
9
+ exports.MissingAddressError = MissingAddressError;
10
+ class MissingChainIdError extends Error {
11
+ constructor() {
12
+ super("Chain ID not found.");
13
+ }
14
+ }
15
+ exports.MissingChainIdError = MissingChainIdError;
16
+ class ZeroAssetAmountError extends Error {
17
+ constructor(asset) {
18
+ super(`Asset amount cannot be zero for address: ${asset}`);
19
+ }
20
+ }
21
+ exports.ZeroAssetAmountError = ZeroAssetAmountError;
22
+ class ZeroSharesAmountError extends Error {
23
+ constructor(vault) {
24
+ super(`Shares amount cannot be zero for address: ${vault}`);
25
+ }
26
+ }
27
+ exports.ZeroSharesAmountError = ZeroSharesAmountError;
28
+ class ZeroMaxSharePriceError extends Error {
29
+ constructor(vault) {
30
+ super(`Max share price cannot be zero for vault: ${vault}`);
31
+ }
32
+ }
33
+ exports.ZeroMaxSharePriceError = ZeroMaxSharePriceError;
34
+ class ChainIdMismatchError extends Error {
35
+ constructor(clientChainId, argsChainId) {
36
+ super(`Chain ID mismatch between client: ${clientChainId} and args: ${argsChainId}`);
37
+ }
38
+ }
39
+ exports.ChainIdMismatchError = ChainIdMismatchError;
@@ -0,0 +1,5 @@
1
+ export * from "./action";
2
+ export * from "./client";
3
+ export * from "./entity";
4
+ export * from "./error";
5
+ export * from "./metadata";
@@ -0,0 +1,21 @@
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("./action"), exports);
18
+ __exportStar(require("./client"), exports);
19
+ __exportStar(require("./entity"), exports);
20
+ __exportStar(require("./error"), exports);
21
+ __exportStar(require("./metadata"), exports);
@@ -0,0 +1,4 @@
1
+ export interface Metadata {
2
+ origin: string;
3
+ timestamp?: boolean;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@morpho-org/consumer-sdk",
3
+ "description": "Abstraction layer for Morpho's complexity.",
4
+ "version": "0.0.1",
5
+ "author": "Morpho Association <contact@morpho.org>",
6
+ "contributors": [
7
+ "Foulks-Plb <https://x.com/FoulkPlb>"
8
+ ],
9
+ "repository": "github:morpho-org/consumer-sdk",
10
+ "homepage": "https://github.com/morpho-org/consumer-sdk",
11
+ "bugs": {
12
+ "url": "https://github.com/morpho-org/consumer-sdk/issues",
13
+ "email": "contact@morpho.org"
14
+ },
15
+ "license": "MIT",
16
+ "main": "lib/index.js",
17
+ "files": [
18
+ "lib"
19
+ ],
20
+ "devDependencies": {
21
+ "@actions/core": "^1.11.1",
22
+ "@biomejs/biome": "2.3.3",
23
+ "@conventional-changelog/git-client": "^2.5.1",
24
+ "@morpho-org/test": "2.6.3",
25
+ "@types/node": "^24.9.1",
26
+ "@vitest/coverage-v8": "3.2.4",
27
+ "@vitest/ui": "3.2.4",
28
+ "conventional-changelog-conventionalcommits": "^9.1.0",
29
+ "conventional-changelog-writer": "^8.2.0",
30
+ "conventional-recommended-bump": "^11.2.0",
31
+ "dotenv": "^17.2.3",
32
+ "husky": "^9.1.7",
33
+ "typescript": "^5.7.2",
34
+ "viem": "^2.28.0",
35
+ "vitest": "^3.0.5"
36
+ },
37
+ "dependencies": {
38
+ "@morpho-org/blue-sdk": "5.7.0",
39
+ "@morpho-org/blue-sdk-viem": "4.1.2",
40
+ "@morpho-org/bundler-sdk-viem": "4.1.2",
41
+ "@morpho-org/morpho-ts": "^2.4.5",
42
+ "@morpho-org/simulation-sdk": "3.2.2",
43
+ "semver": "^7.7.3",
44
+ "zod": "^4.1.12"
45
+ },
46
+ "scripts": {
47
+ "prepublish": "$npm_execpath build",
48
+ "lint": "biome check",
49
+ "build": "tsc --noEmit && tsc --build tsconfig.build.json",
50
+ "link": "pnpm link --global",
51
+ "unlink": "pnpm unlink --global",
52
+ "build:link": "pnpm run build && pnpm link --global",
53
+ "test": "vitest",
54
+ "test:ui": "vitest --ui",
55
+ "test:coverage": "vitest --coverage"
56
+ },
57
+ "types": "lib/index.d.ts"
58
+ }