@morpho-org/consumer-sdk 0.1.7 → 0.1.8

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.
@@ -7,6 +7,7 @@ interface EncodeErc20PermitParams {
7
7
  amount: bigint;
8
8
  chainId: number;
9
9
  nonce: bigint;
10
+ supportDeployless?: boolean;
10
11
  }
11
12
  export declare const encodeErc20Permit: (viemClient: Client, params: EncodeErc20PermitParams) => Promise<Requirement>;
12
13
  export {};
@@ -7,13 +7,15 @@ const viem_1 = require("viem");
7
7
  const actions_1 = require("viem/actions");
8
8
  const types_1 = require("../../../types");
9
9
  const encodeErc20Permit = async (viemClient, params) => {
10
- const { token, spender, amount, chainId, nonce } = params;
10
+ const { token, spender, amount, chainId, nonce, supportDeployless } = params;
11
11
  if (viemClient.chain?.id !== chainId) {
12
12
  throw new types_1.ChainIdMismatchError(viemClient.chain?.id, chainId);
13
13
  }
14
14
  const now = morpho_ts_1.Time.timestamp();
15
15
  const deadline = now + morpho_ts_1.Time.s.from.h(2n);
16
- const tokenData = await (0, blue_sdk_viem_1.fetchToken)(token, viemClient);
16
+ const tokenData = await (0, blue_sdk_viem_1.fetchToken)(token, viemClient, {
17
+ deployless: supportDeployless,
18
+ });
17
19
  const action = {
18
20
  type: "permit",
19
21
  args: {
@@ -4,6 +4,7 @@ import { type ERC20ApprovalAction, type Requirement, type Transaction } from "..
4
4
  type GetRequirementsBaseParams = {
5
5
  address: Address;
6
6
  chainId: number;
7
+ supportDeployless?: boolean;
7
8
  args: {
8
9
  amount: bigint;
9
10
  from: Address;
@@ -33,6 +34,7 @@ type GetRequirementsParams = (GetRequirementsBaseParams & {
33
34
  * @param params.args.amount - Required token amount.
34
35
  * @param params.args.from - The account that will grant approval.
35
36
  * @param params.supportSignature - Whether signature-based approvals are supported. If true, will try to use permit or permit2.
37
+ * @param params.supportDeployless - Whether to use deployless mode.
36
38
  * @param params.useSimplePermit - use simple permit if EIP-2612 is supported. Only available when `supportSignature` is `true`.
37
39
  * @returns Promise of array of approval transaction or requirement objects.
38
40
  */
@@ -23,6 +23,7 @@ const getRequirementsPermit2_1 = require("./getRequirementsPermit2");
23
23
  * @param params.args.amount - Required token amount.
24
24
  * @param params.args.from - The account that will grant approval.
25
25
  * @param params.supportSignature - Whether signature-based approvals are supported. If true, will try to use permit or permit2.
26
+ * @param params.supportDeployless - Whether to use deployless mode.
26
27
  * @param params.useSimplePermit - use simple permit if EIP-2612 is supported. Only available when `supportSignature` is `true`.
27
28
  * @returns Promise of array of approval transaction or requirement objects.
28
29
  */
@@ -32,7 +33,9 @@ const getRequirements = async (viemClient, params) => {
32
33
  throw new types_1.ChainIdMismatchError(viemClient.chain?.id, chainId);
33
34
  }
34
35
  const { permit2, dai, bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
35
- const { erc20Allowances, erc2612Nonce, permit2BundlerAllowance } = await (0, blue_sdk_viem_1.fetchHolding)(from, address, viemClient);
36
+ const { erc20Allowances, erc2612Nonce, permit2BundlerAllowance } = await (0, blue_sdk_viem_1.fetchHolding)(from, address, viemClient, {
37
+ deployless: params.supportDeployless,
38
+ });
36
39
  if (supportSignature) {
37
40
  const { useSimplePermit } = params;
38
41
  const supportSimplePermit = (0, morpho_ts_1.isDefined)(erc2612Nonce) && address !== dai;
@@ -43,6 +46,7 @@ const getRequirements = async (viemClient, params) => {
43
46
  args: { amount },
44
47
  allowancesGeneralAdapter: erc20Allowances["bundler3.generalAdapter1"],
45
48
  nonce: erc2612Nonce,
49
+ supportDeployless: params.supportDeployless,
46
50
  });
47
51
  }
48
52
  if (permit2) {
@@ -13,6 +13,7 @@ import type { Address, Client } from "viem";
13
13
  * @param params.args.amount - Required token amount.
14
14
  * @param params.allowancesGeneralAdapter - Allowance for general adapter from permit contract.
15
15
  * @param params.nonce - Nonce for permit (EIP-2612).
16
+ * @param params.supportDeployless - Whether to use deployless mode.
16
17
  * @returns An array of requirement signature object.
17
18
  */
18
19
  export declare const getRequirementsPermit: (viemClient: Client, params: {
@@ -23,4 +24,5 @@ export declare const getRequirementsPermit: (viemClient: Client, params: {
23
24
  };
24
25
  allowancesGeneralAdapter: bigint;
25
26
  nonce: bigint;
27
+ supportDeployless?: boolean;
26
28
  }) => Promise<import("../..").Requirement[]>;
@@ -17,10 +17,11 @@ const encode_1 = require("./encode");
17
17
  * @param params.args.amount - Required token amount.
18
18
  * @param params.allowancesGeneralAdapter - Allowance for general adapter from permit contract.
19
19
  * @param params.nonce - Nonce for permit (EIP-2612).
20
+ * @param params.supportDeployless - Whether to use deployless mode.
20
21
  * @returns An array of requirement signature object.
21
22
  */
22
23
  const getRequirementsPermit = async (viemClient, params) => {
23
- const { token, chainId, args: { amount }, allowancesGeneralAdapter, nonce, } = params;
24
+ const { token, chainId, args: { amount }, allowancesGeneralAdapter, nonce, supportDeployless, } = params;
24
25
  const { bundler3: { generalAdapter1 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
25
26
  if (allowancesGeneralAdapter < amount) {
26
27
  return [
@@ -30,6 +31,7 @@ const getRequirementsPermit = async (viemClient, params) => {
30
31
  amount,
31
32
  chainId,
32
33
  nonce,
34
+ supportDeployless,
33
35
  }),
34
36
  ];
35
37
  }
@@ -5,14 +5,17 @@ export declare class MorphoClient implements MorphoClientType {
5
5
  readonly viemClient: Client;
6
6
  readonly _options?: {
7
7
  readonly supportSignature?: boolean;
8
+ readonly supportDeployless?: boolean;
8
9
  readonly metadata?: Metadata;
9
10
  } | undefined;
10
11
  readonly options: {
11
12
  readonly supportSignature: boolean;
13
+ readonly supportDeployless?: boolean;
12
14
  readonly metadata?: Metadata;
13
15
  };
14
16
  constructor(viemClient: Client, _options?: {
15
17
  readonly supportSignature?: boolean;
18
+ readonly supportDeployless?: boolean;
16
19
  readonly metadata?: Metadata;
17
20
  } | undefined);
18
21
  vaultV2(vault: Address, chainId: number): MorphoVaultV2;
@@ -12,6 +12,7 @@ class MorphoClient {
12
12
  this.options = {
13
13
  ..._options,
14
14
  supportSignature: _options?.supportSignature ?? false,
15
+ supportDeployless: _options?.supportDeployless,
15
16
  };
16
17
  }
17
18
  vaultV2(vault, chainId) {
@@ -17,6 +17,7 @@ class MorphoVaultV2 {
17
17
  async getData() {
18
18
  return (0, blue_sdk_viem_1.fetchAccrualVaultV2)(this.vault, this.client.viemClient, {
19
19
  chainId: this.chainId,
20
+ deployless: this.client.options.supportDeployless,
20
21
  });
21
22
  }
22
23
  async deposit({ assets, userAddress, slippageTolerance = blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE, }) {
@@ -25,6 +26,7 @@ class MorphoVaultV2 {
25
26
  }
26
27
  const vaultData = await (0, blue_sdk_viem_1.fetchVaultV2)(this.vault, this.client.viemClient, {
27
28
  chainId: this.chainId,
29
+ deployless: this.client.options.supportDeployless,
28
30
  });
29
31
  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);
30
32
  return {
@@ -32,6 +34,7 @@ class MorphoVaultV2 {
32
34
  address: vaultData.asset,
33
35
  chainId: this.chainId,
34
36
  supportSignature: this.client.options.supportSignature,
37
+ supportDeployless: this.client.options.supportDeployless,
35
38
  useSimplePermit: params?.useSimplePermit,
36
39
  args: {
37
40
  amount: assets,
@@ -5,6 +5,7 @@ export interface MorphoClientType {
5
5
  readonly viemClient: Client;
6
6
  readonly options: {
7
7
  readonly supportSignature: boolean;
8
+ readonly supportDeployless?: boolean;
8
9
  readonly metadata?: Metadata;
9
10
  };
10
11
  vaultV2: (vault: Address, chainId: number) => VaultV2Actions;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@morpho-org/consumer-sdk",
3
3
  "description": "Abstraction layer for Morpho's complexity.",
4
- "version": "0.1.7",
4
+ "version": "0.1.8",
5
5
  "author": "Morpho Association <contact@morpho.org>",
6
6
  "contributors": [
7
7
  "Foulks-Plb <https://x.com/FoulkPlb>"