@lit-protocol/vincent-ability-morpho 0.1.0 → 0.1.1-mma
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.
- package/dist/package.json +7 -3
- package/dist/src/generated/lit-action.js +2 -2
- package/dist/src/generated/vincent-ability-metadata.json +1 -1
- package/dist/src/generated/vincent-bundled-ability.d.ts +0 -3
- package/dist/src/generated/vincent-bundled-ability.d.ts.map +1 -1
- package/dist/src/lib/helpers/index.d.ts +58 -80
- package/dist/src/lib/helpers/index.d.ts.map +1 -1
- package/dist/src/lib/helpers/index.js +195 -56
- package/dist/src/lib/helpers/index.js.map +1 -1
- package/dist/src/lib/schemas.d.ts +0 -3
- package/dist/src/lib/schemas.d.ts.map +1 -1
- package/dist/src/lib/schemas.js +1 -5
- package/dist/src/lib/schemas.js.map +1 -1
- package/dist/src/lib/vincent-ability.d.ts +0 -3
- package/dist/src/lib/vincent-ability.d.ts.map +1 -1
- package/dist/src/lib/vincent-ability.js +33 -29
- package/dist/src/lib/vincent-ability.js.map +1 -1
- package/package.json +7 -3
|
@@ -57,7 +57,6 @@ export declare const bundledVincentAbility: import("@lit-protocol/vincent-abilit
|
|
|
57
57
|
vaultValid: import("zod").ZodBoolean;
|
|
58
58
|
amountValid: import("zod").ZodBoolean;
|
|
59
59
|
userBalance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
60
|
-
allowance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
61
60
|
vaultShares: import("zod").ZodOptional<import("zod").ZodString>;
|
|
62
61
|
estimatedGas: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
63
62
|
}, "strip", import("zod").ZodTypeAny, {
|
|
@@ -65,7 +64,6 @@ export declare const bundledVincentAbility: import("@lit-protocol/vincent-abilit
|
|
|
65
64
|
vaultValid: boolean;
|
|
66
65
|
amountValid: boolean;
|
|
67
66
|
userBalance?: string | undefined;
|
|
68
|
-
allowance?: string | undefined;
|
|
69
67
|
vaultShares?: string | undefined;
|
|
70
68
|
estimatedGas?: number | undefined;
|
|
71
69
|
}, {
|
|
@@ -73,7 +71,6 @@ export declare const bundledVincentAbility: import("@lit-protocol/vincent-abilit
|
|
|
73
71
|
vaultValid: boolean;
|
|
74
72
|
amountValid: boolean;
|
|
75
73
|
userBalance?: string | undefined;
|
|
76
|
-
allowance?: string | undefined;
|
|
77
74
|
vaultShares?: string | undefined;
|
|
78
75
|
estimatedGas?: number | undefined;
|
|
79
76
|
}>, import("zod").ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vincent-bundled-ability.d.ts","sourceRoot":"","sources":["../../../src/generated/vincent-bundled-ability.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"vincent-bundled-ability.d.ts","sourceRoot":"","sources":["../../../src/generated/vincent-bundled-ability.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAA4D,CAAC"}
|
|
@@ -1,50 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Using official Circle USDC and canonical WETH addresses
|
|
4
|
-
*/
|
|
5
|
-
export declare const WELL_KNOWN_TOKENS: {
|
|
6
|
-
readonly 1: {
|
|
7
|
-
readonly USDC: "0xA0b86991c6218A36c1D19D4a2e9Eb0cE3606eB48";
|
|
8
|
-
readonly WETH: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
|
9
|
-
readonly USDT: "0xdAC17F958D2ee523a2206206994597C13D831ec7";
|
|
10
|
-
};
|
|
11
|
-
readonly 8453: {
|
|
12
|
-
readonly USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
13
|
-
readonly WETH: "0x4200000000000000000000000000000000000006";
|
|
14
|
-
readonly USDT: "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2";
|
|
15
|
-
};
|
|
16
|
-
readonly 42161: {
|
|
17
|
-
readonly USDC: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
|
|
18
|
-
readonly WETH: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
|
19
|
-
readonly USDT: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9";
|
|
20
|
-
};
|
|
21
|
-
readonly 10: {
|
|
22
|
-
readonly USDC: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85";
|
|
23
|
-
readonly WETH: "0x4200000000000000000000000000000000000006";
|
|
24
|
-
readonly USDT: "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58";
|
|
25
|
-
};
|
|
26
|
-
readonly 137: {
|
|
27
|
-
readonly USDC: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359";
|
|
28
|
-
readonly WETH: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619";
|
|
29
|
-
readonly USDT: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F";
|
|
30
|
-
};
|
|
31
|
-
readonly 11155111: {
|
|
32
|
-
readonly USDC: "0x94a9D9AC8a22534E3FaCa9F4e7F2E2cf85d5E4C8";
|
|
33
|
-
readonly WETH: "0xC558DBdd856501FCd9aaF1E62eae57A9F0629a3c";
|
|
34
|
-
readonly USDT: "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0";
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Supported chain IDs and their names
|
|
39
|
-
*/
|
|
40
|
-
export declare const SUPPORTED_CHAINS: {
|
|
41
|
-
readonly 1: "ethereum";
|
|
42
|
-
readonly 8453: "base";
|
|
43
|
-
readonly 42161: "arbitrum";
|
|
44
|
-
readonly 10: "optimism";
|
|
45
|
-
readonly 137: "polygon";
|
|
46
|
-
readonly 11155111: "sepolia";
|
|
47
|
-
};
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
type ValueOf<T> = T[keyof T];
|
|
48
3
|
/**
|
|
49
4
|
* Chain names to IDs mapping for backwards compatibility
|
|
50
5
|
*/
|
|
@@ -54,8 +9,16 @@ export declare const CHAIN_IDS: {
|
|
|
54
9
|
readonly arbitrum: 42161;
|
|
55
10
|
readonly optimism: 10;
|
|
56
11
|
readonly polygon: 137;
|
|
57
|
-
readonly sepolia: 11155111;
|
|
58
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Supported chain IDs and their names
|
|
15
|
+
*/
|
|
16
|
+
export declare const SUPPORTED_CHAINS: Record<ValueOf<typeof CHAIN_IDS>, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Well-known token addresses across different chains
|
|
19
|
+
* Using official Circle USDC and canonical WETH addresses
|
|
20
|
+
*/
|
|
21
|
+
export declare const WELL_KNOWN_TOKENS: Record<ValueOf<typeof CHAIN_IDS>, any>;
|
|
59
22
|
/**
|
|
60
23
|
* ERC4626 Vault ABI - Essential methods for Morpho vaults
|
|
61
24
|
*/
|
|
@@ -64,6 +27,14 @@ export declare const ERC4626_VAULT_ABI: any[];
|
|
|
64
27
|
* ERC20 Token ABI - Essential methods only
|
|
65
28
|
*/
|
|
66
29
|
export declare const ERC20_ABI: any[];
|
|
30
|
+
export declare const BUNDLER_ABI: any[];
|
|
31
|
+
export declare const BUNDLER_ADDRESSES: {
|
|
32
|
+
readonly 1: "0x6566194141eefa99Af43Bb5Aa71460Ca2Dc90245";
|
|
33
|
+
readonly 8453: "0x6BFd8137e702540E7A42B74178A4a49Ba43920C4";
|
|
34
|
+
readonly 42161: "0x1FA4431bC113D308beE1d46B0e98Cb805FB48C13";
|
|
35
|
+
readonly 10: "0xFBCd3C258feB131D8E038F2A3a670A7bE0507C05";
|
|
36
|
+
readonly 137: "0x2d9C3A9E67c966C711208cc78b34fB9E9f8db589";
|
|
37
|
+
};
|
|
67
38
|
/**
|
|
68
39
|
* Supported chain type
|
|
69
40
|
*/
|
|
@@ -103,31 +74,7 @@ export declare const VAULT_FILTER_PRESETS: VaultFilterPresets;
|
|
|
103
74
|
/**
|
|
104
75
|
* Get well-known token addresses for a specific chain
|
|
105
76
|
*/
|
|
106
|
-
export declare function getTokenAddresses(chainId: number):
|
|
107
|
-
readonly USDC: "0xA0b86991c6218A36c1D19D4a2e9Eb0cE3606eB48";
|
|
108
|
-
readonly WETH: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
|
109
|
-
readonly USDT: "0xdAC17F958D2ee523a2206206994597C13D831ec7";
|
|
110
|
-
} | {
|
|
111
|
-
readonly USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
112
|
-
readonly WETH: "0x4200000000000000000000000000000000000006";
|
|
113
|
-
readonly USDT: "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2";
|
|
114
|
-
} | {
|
|
115
|
-
readonly USDC: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
|
|
116
|
-
readonly WETH: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
|
117
|
-
readonly USDT: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9";
|
|
118
|
-
} | {
|
|
119
|
-
readonly USDC: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85";
|
|
120
|
-
readonly WETH: "0x4200000000000000000000000000000000000006";
|
|
121
|
-
readonly USDT: "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58";
|
|
122
|
-
} | {
|
|
123
|
-
readonly USDC: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359";
|
|
124
|
-
readonly WETH: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619";
|
|
125
|
-
readonly USDT: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F";
|
|
126
|
-
} | {
|
|
127
|
-
readonly USDC: "0x94a9D9AC8a22534E3FaCa9F4e7F2E2cf85d5E4C8";
|
|
128
|
-
readonly WETH: "0xC558DBdd856501FCd9aaF1E62eae57A9F0629a3c";
|
|
129
|
-
readonly USDT: "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0";
|
|
130
|
-
};
|
|
77
|
+
export declare function getTokenAddresses(chainId: number): any;
|
|
131
78
|
/**
|
|
132
79
|
* Get token address for a specific token symbol and chain
|
|
133
80
|
*/
|
|
@@ -159,7 +106,7 @@ export declare function formatAmount(amount: string, decimals?: number): string;
|
|
|
159
106
|
/**
|
|
160
107
|
* Validate operation-specific requirements for Morpho vaults
|
|
161
108
|
*/
|
|
162
|
-
export declare function validateOperationRequirements(operation: string, userBalance: string,
|
|
109
|
+
export declare function validateOperationRequirements(operation: string, userBalance: string, vaultShares: string, convertedAmount: string): Promise<{
|
|
163
110
|
valid: boolean;
|
|
164
111
|
error?: string;
|
|
165
112
|
}>;
|
|
@@ -463,18 +410,49 @@ export declare function getVaultDiscoverySummary(chainId: number): Promise<{
|
|
|
463
410
|
symbol: string;
|
|
464
411
|
}[];
|
|
465
412
|
}>;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
export declare function executeMorphoOperation({ provider, pkpPublicKey, vaultAddress, functionName, args, chainId, alchemyGasSponsor, alchemyGasSponsorApiKey, alchemyGasSponsorPolicyId, }: {
|
|
470
|
-
provider?: any;
|
|
413
|
+
export declare function buildDepositTxData({ amount, pkpAddress, pkpPublicKey, provider, tokenAddress, vaultAddress, }: {
|
|
414
|
+
amount: bigint;
|
|
415
|
+
pkpAddress: string;
|
|
471
416
|
pkpPublicKey: string;
|
|
417
|
+
provider: ethers.providers.Provider;
|
|
418
|
+
tokenAddress: string;
|
|
472
419
|
vaultAddress: string;
|
|
420
|
+
}): Promise<{
|
|
421
|
+
abi: any;
|
|
422
|
+
args: any[];
|
|
473
423
|
functionName: string;
|
|
424
|
+
data: string;
|
|
425
|
+
to: string;
|
|
426
|
+
value: string;
|
|
427
|
+
}>;
|
|
428
|
+
export declare function buildRedeemTxData({ amount, pkpAddress, provider, vaultAddress, }: {
|
|
429
|
+
amount: bigint;
|
|
430
|
+
pkpAddress: string;
|
|
431
|
+
provider: ethers.providers.Provider;
|
|
432
|
+
vaultAddress: string;
|
|
433
|
+
}): Promise<{
|
|
434
|
+
abi: any;
|
|
474
435
|
args: any[];
|
|
475
|
-
|
|
436
|
+
functionName: string;
|
|
437
|
+
data: string;
|
|
438
|
+
to: string;
|
|
439
|
+
value: string;
|
|
440
|
+
}>;
|
|
441
|
+
/**
|
|
442
|
+
* Generic function to execute any Morpho operation, with optional gas sponsorship
|
|
443
|
+
*/
|
|
444
|
+
export declare function executeChainOperation({ abi, provider, pkpEthAddress, pkpPublicKey, contractAddress, functionName, args, chainId, alchemyGasSponsor, alchemyGasSponsorApiKey, alchemyGasSponsorPolicyId, }: {
|
|
445
|
+
abi: any;
|
|
476
446
|
alchemyGasSponsor?: boolean;
|
|
477
447
|
alchemyGasSponsorApiKey?: string;
|
|
478
448
|
alchemyGasSponsorPolicyId?: string;
|
|
449
|
+
args: any[];
|
|
450
|
+
chainId: number;
|
|
451
|
+
contractAddress: string;
|
|
452
|
+
provider?: any;
|
|
453
|
+
pkpEthAddress: string;
|
|
454
|
+
pkpPublicKey: string;
|
|
455
|
+
functionName: string;
|
|
479
456
|
}): Promise<string>;
|
|
457
|
+
export {};
|
|
480
458
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/helpers/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE7B;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;CAMZ,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAA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iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,GAC1B,EAAE;IACD,GAAG,EAAE,GAAG,CAAC;IACT,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,MAAM,CAAC,CA4DlB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.morphoVaultClient = exports.MorphoVaultClient = exports.VAULT_FILTER_PRESETS = exports.ERC20_ABI = exports.ERC4626_VAULT_ABI = exports.
|
|
3
|
+
exports.morphoVaultClient = exports.MorphoVaultClient = exports.VAULT_FILTER_PRESETS = exports.BUNDLER_ADDRESSES = exports.BUNDLER_ABI = exports.ERC20_ABI = exports.ERC4626_VAULT_ABI = exports.WELL_KNOWN_TOKENS = exports.SUPPORTED_CHAINS = exports.CHAIN_IDS = void 0;
|
|
4
4
|
exports.getTokenAddresses = getTokenAddresses;
|
|
5
5
|
exports.getTokenAddress = getTokenAddress;
|
|
6
6
|
exports.isSupportedChain = isSupportedChain;
|
|
@@ -18,72 +18,62 @@ exports.getVaultsByPreset = getVaultsByPreset;
|
|
|
18
18
|
exports.getVaults = getVaults;
|
|
19
19
|
exports.getSupportedChainsWithVaults = getSupportedChainsWithVaults;
|
|
20
20
|
exports.getVaultDiscoverySummary = getVaultDiscoverySummary;
|
|
21
|
-
exports.
|
|
21
|
+
exports.buildDepositTxData = buildDepositTxData;
|
|
22
|
+
exports.buildRedeemTxData = buildRedeemTxData;
|
|
23
|
+
exports.executeChainOperation = executeChainOperation;
|
|
22
24
|
const vincent_scaffold_sdk_1 = require("@lit-protocol/vincent-scaffold-sdk");
|
|
25
|
+
const bundler_sdk_ethers_1 = require("@morpho-org/bundler-sdk-ethers");
|
|
23
26
|
const ethers_1 = require("ethers");
|
|
27
|
+
/**
|
|
28
|
+
* Chain names to IDs mapping for backwards compatibility
|
|
29
|
+
*/
|
|
30
|
+
exports.CHAIN_IDS = {
|
|
31
|
+
ethereum: 1,
|
|
32
|
+
base: 8453,
|
|
33
|
+
arbitrum: 42161,
|
|
34
|
+
optimism: 10,
|
|
35
|
+
polygon: 137,
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Supported chain IDs and their names
|
|
39
|
+
*/
|
|
40
|
+
exports.SUPPORTED_CHAINS = {
|
|
41
|
+
[exports.CHAIN_IDS.ethereum]: 'ethereum',
|
|
42
|
+
[exports.CHAIN_IDS.base]: 'base',
|
|
43
|
+
[exports.CHAIN_IDS.arbitrum]: 'arbitrum',
|
|
44
|
+
[exports.CHAIN_IDS.optimism]: 'optimism',
|
|
45
|
+
[exports.CHAIN_IDS.polygon]: 'polygon',
|
|
46
|
+
};
|
|
24
47
|
/**
|
|
25
48
|
* Well-known token addresses across different chains
|
|
26
49
|
* Using official Circle USDC and canonical WETH addresses
|
|
27
50
|
*/
|
|
28
51
|
exports.WELL_KNOWN_TOKENS = {
|
|
29
|
-
|
|
30
|
-
1: {
|
|
52
|
+
[exports.CHAIN_IDS.ethereum]: {
|
|
31
53
|
USDC: '0xA0b86991c6218A36c1D19D4a2e9Eb0cE3606eB48', // Circle USDC
|
|
32
54
|
WETH: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // Canonical WETH
|
|
33
55
|
USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7', // Tether USDT
|
|
34
56
|
},
|
|
35
|
-
|
|
36
|
-
8453: {
|
|
57
|
+
[exports.CHAIN_IDS.base]: {
|
|
37
58
|
USDC: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // Native USDC on Base
|
|
38
59
|
WETH: '0x4200000000000000000000000000000000000006', // WETH on Base
|
|
39
60
|
USDT: '0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2', // USDT on Base
|
|
40
61
|
},
|
|
41
|
-
|
|
42
|
-
42161: {
|
|
62
|
+
[exports.CHAIN_IDS.arbitrum]: {
|
|
43
63
|
USDC: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', // Native USDC on Arbitrum
|
|
44
64
|
WETH: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1', // WETH on Arbitrum
|
|
45
65
|
USDT: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9', // USDT on Arbitrum
|
|
46
66
|
},
|
|
47
|
-
|
|
48
|
-
10: {
|
|
67
|
+
[exports.CHAIN_IDS.optimism]: {
|
|
49
68
|
USDC: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85', // Native USDC on Optimism
|
|
50
69
|
WETH: '0x4200000000000000000000000000000000000006', // WETH on Optimism
|
|
51
70
|
USDT: '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58', // USDT on Optimism
|
|
52
71
|
},
|
|
53
|
-
|
|
54
|
-
137: {
|
|
72
|
+
[exports.CHAIN_IDS.polygon]: {
|
|
55
73
|
USDC: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359', // Native USDC on Polygon
|
|
56
74
|
WETH: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', // WETH on Polygon
|
|
57
75
|
USDT: '0xc2132D05D31c914a87C6611C10748AEb04B58e8F', // USDT on Polygon
|
|
58
76
|
},
|
|
59
|
-
// Sepolia testnet
|
|
60
|
-
11155111: {
|
|
61
|
-
USDC: '0x94a9D9AC8a22534E3FaCa9F4e7F2E2cf85d5E4C8', // Test USDC on Sepolia
|
|
62
|
-
WETH: '0xC558DBdd856501FCd9aaF1E62eae57A9F0629a3c', // Test WETH on Sepolia
|
|
63
|
-
USDT: '0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0', // Test USDT on Sepolia
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Supported chain IDs and their names
|
|
68
|
-
*/
|
|
69
|
-
exports.SUPPORTED_CHAINS = {
|
|
70
|
-
1: 'ethereum',
|
|
71
|
-
8453: 'base',
|
|
72
|
-
42161: 'arbitrum',
|
|
73
|
-
10: 'optimism',
|
|
74
|
-
137: 'polygon',
|
|
75
|
-
11155111: 'sepolia',
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Chain names to IDs mapping for backwards compatibility
|
|
79
|
-
*/
|
|
80
|
-
exports.CHAIN_IDS = {
|
|
81
|
-
ethereum: 1,
|
|
82
|
-
base: 8453,
|
|
83
|
-
arbitrum: 42161,
|
|
84
|
-
optimism: 10,
|
|
85
|
-
polygon: 137,
|
|
86
|
-
sepolia: 11155111,
|
|
87
77
|
};
|
|
88
78
|
/**
|
|
89
79
|
* ERC4626 Vault ABI - Essential methods for Morpho vaults
|
|
@@ -210,7 +200,57 @@ exports.ERC20_ABI = [
|
|
|
210
200
|
stateMutability: 'view',
|
|
211
201
|
type: 'function',
|
|
212
202
|
},
|
|
203
|
+
// EIP-2612 ERC20Permit extension
|
|
204
|
+
{
|
|
205
|
+
inputs: [],
|
|
206
|
+
name: 'name',
|
|
207
|
+
outputs: [{ internalType: 'string', name: '', type: 'string' }],
|
|
208
|
+
stateMutability: 'view',
|
|
209
|
+
type: 'function',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
inputs: [],
|
|
213
|
+
name: 'version',
|
|
214
|
+
outputs: [{ internalType: 'string', name: '', type: 'string' }],
|
|
215
|
+
stateMutability: 'view',
|
|
216
|
+
type: 'function',
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
|
|
220
|
+
name: 'nonces',
|
|
221
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
222
|
+
stateMutability: 'view',
|
|
223
|
+
type: 'function',
|
|
224
|
+
},
|
|
225
|
+
];
|
|
226
|
+
exports.BUNDLER_ABI = [
|
|
227
|
+
{
|
|
228
|
+
inputs: [
|
|
229
|
+
{
|
|
230
|
+
internalType: 'bytes[]',
|
|
231
|
+
name: 'data',
|
|
232
|
+
type: 'bytes[]',
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
name: 'multicall',
|
|
236
|
+
outputs: [
|
|
237
|
+
{
|
|
238
|
+
internalType: 'bytes[]',
|
|
239
|
+
name: 'results',
|
|
240
|
+
type: 'bytes[]',
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
stateMutability: 'payable',
|
|
244
|
+
type: 'function',
|
|
245
|
+
},
|
|
213
246
|
];
|
|
247
|
+
exports.BUNDLER_ADDRESSES = {
|
|
248
|
+
[exports.CHAIN_IDS.ethereum]: '0x6566194141eefa99Af43Bb5Aa71460Ca2Dc90245',
|
|
249
|
+
[exports.CHAIN_IDS.base]: '0x6BFd8137e702540E7A42B74178A4a49Ba43920C4',
|
|
250
|
+
[exports.CHAIN_IDS.arbitrum]: '0x1FA4431bC113D308beE1d46B0e98Cb805FB48C13',
|
|
251
|
+
[exports.CHAIN_IDS.optimism]: '0xFBCd3C258feB131D8E038F2A3a670A7bE0507C05',
|
|
252
|
+
[exports.CHAIN_IDS.polygon]: '0x2d9C3A9E67c966C711208cc78b34fB9E9f8db589',
|
|
253
|
+
};
|
|
214
254
|
/**
|
|
215
255
|
* Pre-configured filter presets for common use cases
|
|
216
256
|
*/
|
|
@@ -299,9 +339,8 @@ function formatAmount(amount, decimals = 18) {
|
|
|
299
339
|
/**
|
|
300
340
|
* Validate operation-specific requirements for Morpho vaults
|
|
301
341
|
*/
|
|
302
|
-
async function validateOperationRequirements(operation, userBalance,
|
|
342
|
+
async function validateOperationRequirements(operation, userBalance, vaultShares, convertedAmount) {
|
|
303
343
|
const userBalanceBN = BigInt(userBalance);
|
|
304
|
-
const allowanceBN = BigInt(allowance);
|
|
305
344
|
const vaultSharesBN = BigInt(vaultShares);
|
|
306
345
|
const convertedAmountBN = BigInt(convertedAmount);
|
|
307
346
|
switch (operation) {
|
|
@@ -313,13 +352,6 @@ async function validateOperationRequirements(operation, userBalance, allowance,
|
|
|
313
352
|
error: `Insufficient balance for deposit operation. You have ${userBalance} and need ${convertedAmount}`,
|
|
314
353
|
};
|
|
315
354
|
}
|
|
316
|
-
// Check if user has approved vault to spend tokens
|
|
317
|
-
if (allowanceBN < convertedAmountBN) {
|
|
318
|
-
return {
|
|
319
|
-
valid: false,
|
|
320
|
-
error: `Insufficient allowance for deposit operation. Please approve vault to spend your tokens first. You have ${allowance} and need ${convertedAmount}`,
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
355
|
break;
|
|
324
356
|
case 'withdraw':
|
|
325
357
|
// For withdraw, we need to check if user has enough vault shares
|
|
@@ -894,19 +926,126 @@ async function getVaultDiscoverySummary(chainId) {
|
|
|
894
926
|
throw error;
|
|
895
927
|
}
|
|
896
928
|
}
|
|
929
|
+
async function buildDepositTxData({
|
|
930
|
+
// signer,
|
|
931
|
+
amount, pkpAddress, pkpPublicKey, provider, tokenAddress, vaultAddress, }) {
|
|
932
|
+
const { chainId } = await provider.getNetwork();
|
|
933
|
+
const bundlerAddress = exports.BUNDLER_ADDRESSES[chainId];
|
|
934
|
+
if (!bundlerAddress) {
|
|
935
|
+
throw new Error(`No bundler address found for chain ${chainId}`);
|
|
936
|
+
}
|
|
937
|
+
// ----- 1) Build EIP-2612 permit signature for USDC -----
|
|
938
|
+
const tokenContract = new ethers_1.ethers.Contract(tokenAddress, exports.ERC20_ABI, provider);
|
|
939
|
+
const [name, nonce, version] = await Promise.all([
|
|
940
|
+
tokenContract.name(),
|
|
941
|
+
tokenContract.nonces(pkpAddress),
|
|
942
|
+
tokenContract.version(),
|
|
943
|
+
]);
|
|
944
|
+
const deadline = Math.floor(Date.now() / 1000) + 60 * 30; // 30 min
|
|
945
|
+
// EIP-2612 permit signature
|
|
946
|
+
const domain = {
|
|
947
|
+
name,
|
|
948
|
+
version,
|
|
949
|
+
chainId,
|
|
950
|
+
verifyingContract: tokenAddress,
|
|
951
|
+
};
|
|
952
|
+
const types = {
|
|
953
|
+
Permit: [
|
|
954
|
+
{ name: 'owner', type: 'address' },
|
|
955
|
+
{ name: 'spender', type: 'address' },
|
|
956
|
+
{ name: 'value', type: 'uint256' },
|
|
957
|
+
{ name: 'nonce', type: 'uint256' },
|
|
958
|
+
{ name: 'deadline', type: 'uint256' },
|
|
959
|
+
],
|
|
960
|
+
};
|
|
961
|
+
const message = {
|
|
962
|
+
owner: pkpAddress,
|
|
963
|
+
spender: bundlerAddress,
|
|
964
|
+
value: amount.toString(),
|
|
965
|
+
nonce: nonce.toString(),
|
|
966
|
+
deadline,
|
|
967
|
+
};
|
|
968
|
+
const digest = ethers_1.ethers.utils._TypedDataEncoder.hash(domain, types, message);
|
|
969
|
+
const toSign = ethers_1.ethers.utils.arrayify(digest);
|
|
970
|
+
const permitSignatureString = await Lit.Actions.signAndCombineEcdsa({
|
|
971
|
+
toSign,
|
|
972
|
+
publicKey: pkpPublicKey,
|
|
973
|
+
sigName: 'tokenPermit',
|
|
974
|
+
});
|
|
975
|
+
// const permitSignatureString = await signer.signMessage(toSign);
|
|
976
|
+
const permitSignature = ethers_1.ethers.utils.splitSignature(permitSignatureString);
|
|
977
|
+
const calls = [
|
|
978
|
+
bundler_sdk_ethers_1.BundlerAction.permit(tokenAddress, amount, deadline, permitSignature, false),
|
|
979
|
+
bundler_sdk_ethers_1.BundlerAction.erc20TransferFrom(tokenAddress, amount),
|
|
980
|
+
// Deposit into the ERC4626 vault (minShares = 0; set if you want protection)
|
|
981
|
+
bundler_sdk_ethers_1.BundlerAction.erc4626Deposit(vaultAddress, amount, 0, pkpAddress),
|
|
982
|
+
];
|
|
983
|
+
const iface = new ethers_1.ethers.utils.Interface(exports.BUNDLER_ABI);
|
|
984
|
+
const data = iface.encodeFunctionData('multicall', [calls]);
|
|
985
|
+
return {
|
|
986
|
+
data,
|
|
987
|
+
abi: exports.BUNDLER_ABI,
|
|
988
|
+
functionName: 'multicall',
|
|
989
|
+
args: [calls],
|
|
990
|
+
to: bundlerAddress,
|
|
991
|
+
value: '0x0',
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
// async function testBuildDepositTxData() {
|
|
995
|
+
// const privateKey = '8d6d6c3abfd291aa169861aea9b572307338260497fc5f1493ba808e21482a0b';
|
|
996
|
+
// const provider = new ethers.providers.JsonRpcProvider('https://mainnet.base.org');
|
|
997
|
+
// const signer = new ethers.Wallet(privateKey, provider);
|
|
998
|
+
//
|
|
999
|
+
// const txData = await buildDepositTxData({
|
|
1000
|
+
// provider,
|
|
1001
|
+
// signer,
|
|
1002
|
+
// amount: BigInt(1),
|
|
1003
|
+
// pkpAddress: await signer.getAddress(),
|
|
1004
|
+
// pkpPublicKey: 'notUsed',
|
|
1005
|
+
// tokenAddress: WELL_KNOWN_TOKENS[8453].USDC,
|
|
1006
|
+
// vaultAddress: '0x23479229e52Ab6aaD312D0B03DF9F33B46753B5e',
|
|
1007
|
+
// });
|
|
1008
|
+
//
|
|
1009
|
+
// const response = await signer.sendTransaction({
|
|
1010
|
+
// to: txData.to,
|
|
1011
|
+
// data: txData.data,
|
|
1012
|
+
// chainId: 8453,
|
|
1013
|
+
// });
|
|
1014
|
+
// const txHash = response.hash;
|
|
1015
|
+
// console.log('txHash', txHash);
|
|
1016
|
+
// }
|
|
1017
|
+
// testBuildDepositTxData();
|
|
1018
|
+
async function buildRedeemTxData({ amount, pkpAddress, provider, vaultAddress, }) {
|
|
1019
|
+
const { chainId } = await provider.getNetwork();
|
|
1020
|
+
const bundlerAddress = exports.BUNDLER_ADDRESSES[chainId];
|
|
1021
|
+
if (!bundlerAddress) {
|
|
1022
|
+
throw new Error(`No bundler address found for chain ${chainId}`);
|
|
1023
|
+
}
|
|
1024
|
+
const calls = [bundler_sdk_ethers_1.BundlerAction.erc4626Redeem(vaultAddress, amount, amount, pkpAddress, pkpAddress)];
|
|
1025
|
+
const iface = new ethers_1.ethers.utils.Interface(exports.BUNDLER_ABI);
|
|
1026
|
+
const data = iface.encodeFunctionData('multicall', [calls]);
|
|
1027
|
+
return {
|
|
1028
|
+
data,
|
|
1029
|
+
abi: exports.BUNDLER_ABI,
|
|
1030
|
+
functionName: 'multicall',
|
|
1031
|
+
args: [calls],
|
|
1032
|
+
to: bundlerAddress,
|
|
1033
|
+
value: '0x0',
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
897
1036
|
/**
|
|
898
1037
|
* Generic function to execute any Morpho operation, with optional gas sponsorship
|
|
899
1038
|
*/
|
|
900
|
-
async function
|
|
1039
|
+
async function executeChainOperation({ abi, provider, pkpEthAddress, pkpPublicKey, contractAddress, functionName, args, chainId, alchemyGasSponsor, alchemyGasSponsorApiKey, alchemyGasSponsorPolicyId, }) {
|
|
901
1040
|
console.log(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] Starting ${functionName} operation`, { sponsored: !!alchemyGasSponsor });
|
|
902
1041
|
// Use gas sponsorship if enabled and all required parameters are provided
|
|
903
1042
|
if (alchemyGasSponsor && alchemyGasSponsorApiKey && alchemyGasSponsorPolicyId) {
|
|
904
|
-
console.log(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] Using EIP-7702 gas sponsorship`, {
|
|
1043
|
+
console.log(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] Using EIP-7702 gas sponsorship`, { contractAddress, functionName, args, policyId: alchemyGasSponsorPolicyId });
|
|
905
1044
|
try {
|
|
906
1045
|
return await vincent_scaffold_sdk_1.laUtils.transaction.handler.sponsoredGasContractCall({
|
|
1046
|
+
abi,
|
|
907
1047
|
pkpPublicKey,
|
|
908
|
-
|
|
909
|
-
contractAddress: vaultAddress,
|
|
1048
|
+
contractAddress,
|
|
910
1049
|
functionName,
|
|
911
1050
|
args,
|
|
912
1051
|
chainId,
|
|
@@ -927,14 +1066,14 @@ async function executeMorphoOperation({ provider, pkpPublicKey, vaultAddress, fu
|
|
|
927
1066
|
}
|
|
928
1067
|
try {
|
|
929
1068
|
return await vincent_scaffold_sdk_1.laUtils.transaction.handler.contractCall({
|
|
1069
|
+
abi,
|
|
930
1070
|
provider,
|
|
931
1071
|
pkpPublicKey,
|
|
932
|
-
|
|
933
|
-
abi: exports.ERC4626_VAULT_ABI,
|
|
934
|
-
contractAddress: vaultAddress,
|
|
1072
|
+
contractAddress,
|
|
935
1073
|
functionName,
|
|
936
1074
|
args,
|
|
937
1075
|
chainId,
|
|
1076
|
+
callerAddress: pkpEthAddress,
|
|
938
1077
|
});
|
|
939
1078
|
}
|
|
940
1079
|
catch (error) {
|