@lit-protocol/vincent-ability-morpho 0.0.7-mma → 0.0.9-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/CONTRIBUTING.md +2 -8
- package/README.md +21 -31
- package/dist/CONTRIBUTING.md +2 -8
- package/dist/README.md +21 -31
- 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 +9 -21
- package/dist/src/generated/vincent-bundled-ability.d.ts.map +1 -1
- package/dist/src/lib/helpers/index.d.ts +6 -87
- package/dist/src/lib/helpers/index.d.ts.map +1 -1
- package/dist/src/lib/helpers/index.js +16 -193
- package/dist/src/lib/helpers/index.js.map +1 -1
- package/dist/src/lib/schemas.d.ts +13 -27
- package/dist/src/lib/schemas.d.ts.map +1 -1
- package/dist/src/lib/schemas.js +13 -36
- package/dist/src/lib/schemas.js.map +1 -1
- package/dist/src/lib/vincent-ability.d.ts +9 -21
- package/dist/src/lib/vincent-ability.d.ts.map +1 -1
- package/dist/src/lib/vincent-ability.js +82 -211
- package/dist/src/lib/vincent-ability.js.map +1 -1
- package/package.json +3 -3
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const bundledVincentAbility: import("@lit-protocol/vincent-ability-sdk").BundledVincentAbility<import("@lit-protocol/vincent-ability-sdk").VincentAbility<import("zod").ZodObject<{
|
|
5
5
|
operation: import("zod").ZodNativeEnum<typeof import("..").MorphoOperation>;
|
|
6
|
-
|
|
7
|
-
marketId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
6
|
+
vaultAddress: import("zod").ZodString;
|
|
8
7
|
amount: import("zod").ZodEffects<import("zod").ZodString, string, string>;
|
|
9
|
-
onBehalfOf: import("zod").ZodOptional<import("zod").ZodString>;
|
|
10
8
|
chain: import("zod").ZodString;
|
|
11
9
|
rpcUrl: import("zod").ZodOptional<import("zod").ZodString>;
|
|
12
10
|
alchemyGasSponsor: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
|
|
@@ -14,22 +12,18 @@ export declare const bundledVincentAbility: import("@lit-protocol/vincent-abilit
|
|
|
14
12
|
alchemyGasSponsorPolicyId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
15
13
|
}, "strip", import("zod").ZodTypeAny, {
|
|
16
14
|
operation: import("..").MorphoOperation;
|
|
17
|
-
|
|
15
|
+
vaultAddress: string;
|
|
18
16
|
amount: string;
|
|
19
17
|
chain: string;
|
|
20
18
|
alchemyGasSponsor: boolean;
|
|
21
|
-
marketId?: string | undefined;
|
|
22
|
-
onBehalfOf?: string | undefined;
|
|
23
19
|
rpcUrl?: string | undefined;
|
|
24
20
|
alchemyGasSponsorApiKey?: string | undefined;
|
|
25
21
|
alchemyGasSponsorPolicyId?: string | undefined;
|
|
26
22
|
}, {
|
|
27
23
|
operation: import("..").MorphoOperation;
|
|
28
|
-
|
|
24
|
+
vaultAddress: string;
|
|
29
25
|
amount: string;
|
|
30
26
|
chain: string;
|
|
31
|
-
marketId?: string | undefined;
|
|
32
|
-
onBehalfOf?: string | undefined;
|
|
33
27
|
rpcUrl?: string | undefined;
|
|
34
28
|
alchemyGasSponsor?: boolean | undefined;
|
|
35
29
|
alchemyGasSponsorApiKey?: string | undefined;
|
|
@@ -37,24 +31,21 @@ export declare const bundledVincentAbility: import("@lit-protocol/vincent-abilit
|
|
|
37
31
|
}>, string, import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/abilityCore/helpers").AbilityPolicyMap<readonly [], never>, {}, import("zod").ZodObject<{
|
|
38
32
|
txHash: import("zod").ZodString;
|
|
39
33
|
operation: import("zod").ZodNativeEnum<typeof import("..").MorphoOperation>;
|
|
40
|
-
|
|
41
|
-
marketId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
34
|
+
vaultAddress: import("zod").ZodString;
|
|
42
35
|
amount: import("zod").ZodString;
|
|
43
36
|
timestamp: import("zod").ZodNumber;
|
|
44
37
|
}, "strip", import("zod").ZodTypeAny, {
|
|
45
38
|
operation: import("..").MorphoOperation;
|
|
46
|
-
|
|
39
|
+
vaultAddress: string;
|
|
47
40
|
amount: string;
|
|
48
41
|
txHash: string;
|
|
49
42
|
timestamp: number;
|
|
50
|
-
marketId?: string | undefined;
|
|
51
43
|
}, {
|
|
52
44
|
operation: import("..").MorphoOperation;
|
|
53
|
-
|
|
45
|
+
vaultAddress: string;
|
|
54
46
|
amount: string;
|
|
55
47
|
txHash: string;
|
|
56
48
|
timestamp: number;
|
|
57
|
-
marketId?: string | undefined;
|
|
58
49
|
}>, import("zod").ZodObject<{
|
|
59
50
|
error: import("zod").ZodString;
|
|
60
51
|
}, "strip", import("zod").ZodTypeAny, {
|
|
@@ -63,30 +54,27 @@ export declare const bundledVincentAbility: import("@lit-protocol/vincent-abilit
|
|
|
63
54
|
error: string;
|
|
64
55
|
}>, import("zod").ZodObject<{
|
|
65
56
|
operationValid: import("zod").ZodBoolean;
|
|
66
|
-
|
|
57
|
+
vaultValid: import("zod").ZodBoolean;
|
|
67
58
|
amountValid: import("zod").ZodBoolean;
|
|
68
59
|
userBalance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
69
60
|
allowance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
70
61
|
vaultShares: import("zod").ZodOptional<import("zod").ZodString>;
|
|
71
|
-
collateralBalance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
72
62
|
estimatedGas: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
73
63
|
}, "strip", import("zod").ZodTypeAny, {
|
|
74
64
|
operationValid: boolean;
|
|
75
|
-
|
|
65
|
+
vaultValid: boolean;
|
|
76
66
|
amountValid: boolean;
|
|
77
67
|
userBalance?: string | undefined;
|
|
78
68
|
allowance?: string | undefined;
|
|
79
69
|
vaultShares?: string | undefined;
|
|
80
|
-
collateralBalance?: string | undefined;
|
|
81
70
|
estimatedGas?: number | undefined;
|
|
82
71
|
}, {
|
|
83
72
|
operationValid: boolean;
|
|
84
|
-
|
|
73
|
+
vaultValid: boolean;
|
|
85
74
|
amountValid: boolean;
|
|
86
75
|
userBalance?: string | undefined;
|
|
87
76
|
allowance?: string | undefined;
|
|
88
77
|
vaultShares?: string | undefined;
|
|
89
|
-
collateralBalance?: string | undefined;
|
|
90
78
|
estimatedGas?: number | undefined;
|
|
91
79
|
}>, import("zod").ZodObject<{
|
|
92
80
|
error: import("zod").ZodString;
|
|
@@ -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,5 +1,3 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
|
-
import { MorphoOperation } from '../schemas';
|
|
3
1
|
/**
|
|
4
2
|
* Well-known token addresses across different chains
|
|
5
3
|
* Using official Circle USDC and canonical WETH addresses
|
|
@@ -62,74 +60,10 @@ export declare const CHAIN_IDS: {
|
|
|
62
60
|
* ERC4626 Vault ABI - Essential methods for Morpho vaults
|
|
63
61
|
*/
|
|
64
62
|
export declare const ERC4626_VAULT_ABI: any[];
|
|
65
|
-
/**
|
|
66
|
-
* Morpho Market ABI - Essential methods for supply and withdraw operations
|
|
67
|
-
*/
|
|
68
|
-
export declare const MORPHO_MARKET_ABI: any[];
|
|
69
63
|
/**
|
|
70
64
|
* ERC20 Token ABI - Essential methods only
|
|
71
65
|
*/
|
|
72
|
-
export declare const ERC20_ABI:
|
|
73
|
-
readonly inputs: readonly [{
|
|
74
|
-
readonly internalType: "address";
|
|
75
|
-
readonly name: "account";
|
|
76
|
-
readonly type: "address";
|
|
77
|
-
}];
|
|
78
|
-
readonly name: "balanceOf";
|
|
79
|
-
readonly outputs: readonly [{
|
|
80
|
-
readonly internalType: "uint256";
|
|
81
|
-
readonly name: "";
|
|
82
|
-
readonly type: "uint256";
|
|
83
|
-
}];
|
|
84
|
-
readonly stateMutability: "view";
|
|
85
|
-
readonly type: "function";
|
|
86
|
-
}, {
|
|
87
|
-
readonly inputs: readonly [{
|
|
88
|
-
readonly internalType: "address";
|
|
89
|
-
readonly name: "owner";
|
|
90
|
-
readonly type: "address";
|
|
91
|
-
}, {
|
|
92
|
-
readonly internalType: "address";
|
|
93
|
-
readonly name: "spender";
|
|
94
|
-
readonly type: "address";
|
|
95
|
-
}];
|
|
96
|
-
readonly name: "allowance";
|
|
97
|
-
readonly outputs: readonly [{
|
|
98
|
-
readonly internalType: "uint256";
|
|
99
|
-
readonly name: "";
|
|
100
|
-
readonly type: "uint256";
|
|
101
|
-
}];
|
|
102
|
-
readonly stateMutability: "view";
|
|
103
|
-
readonly type: "function";
|
|
104
|
-
}, {
|
|
105
|
-
readonly inputs: readonly [{
|
|
106
|
-
readonly internalType: "address";
|
|
107
|
-
readonly name: "spender";
|
|
108
|
-
readonly type: "address";
|
|
109
|
-
}, {
|
|
110
|
-
readonly internalType: "uint256";
|
|
111
|
-
readonly name: "amount";
|
|
112
|
-
readonly type: "uint256";
|
|
113
|
-
}];
|
|
114
|
-
readonly name: "approve";
|
|
115
|
-
readonly outputs: readonly [{
|
|
116
|
-
readonly internalType: "bool";
|
|
117
|
-
readonly name: "";
|
|
118
|
-
readonly type: "bool";
|
|
119
|
-
}];
|
|
120
|
-
readonly stateMutability: "nonpayable";
|
|
121
|
-
readonly type: "function";
|
|
122
|
-
}, {
|
|
123
|
-
readonly inputs: readonly [];
|
|
124
|
-
readonly name: "decimals";
|
|
125
|
-
readonly outputs: readonly [{
|
|
126
|
-
readonly internalType: "uint8";
|
|
127
|
-
readonly name: "";
|
|
128
|
-
readonly type: "uint8";
|
|
129
|
-
}];
|
|
130
|
-
readonly stateMutability: "view";
|
|
131
|
-
readonly type: "function";
|
|
132
|
-
}];
|
|
66
|
+
export declare const ERC20_ABI: any[];
|
|
133
67
|
/**
|
|
134
68
|
* Supported chain type
|
|
135
69
|
*/
|
|
@@ -223,9 +157,9 @@ export declare function parseAmount(amount: string, decimals?: number): string;
|
|
|
223
157
|
*/
|
|
224
158
|
export declare function formatAmount(amount: string, decimals?: number): string;
|
|
225
159
|
/**
|
|
226
|
-
* Validate operation-specific requirements for Morpho vaults
|
|
160
|
+
* Validate operation-specific requirements for Morpho vaults
|
|
227
161
|
*/
|
|
228
|
-
export declare function validateOperationRequirements(operation:
|
|
162
|
+
export declare function validateOperationRequirements(operation: string, userBalance: string, allowance: string, vaultShares: string, convertedAmount: string): Promise<{
|
|
229
163
|
valid: boolean;
|
|
230
164
|
error?: string;
|
|
231
165
|
}>;
|
|
@@ -530,25 +464,10 @@ export declare function getVaultDiscoverySummary(chainId: number): Promise<{
|
|
|
530
464
|
}[];
|
|
531
465
|
}>;
|
|
532
466
|
/**
|
|
533
|
-
*
|
|
534
|
-
*/
|
|
535
|
-
export declare function executeMorphoMarketOperation({ provider, pkpPublicKey, marketAddress, marketId, functionName, args, chainId, alchemyGasSponsor, alchemyGasSponsorApiKey, alchemyGasSponsorPolicyId, }: {
|
|
536
|
-
provider?: ethers.providers.JsonRpcProvider;
|
|
537
|
-
pkpPublicKey: string;
|
|
538
|
-
marketAddress: string;
|
|
539
|
-
marketId: string;
|
|
540
|
-
functionName: string;
|
|
541
|
-
args: any[];
|
|
542
|
-
chainId: number;
|
|
543
|
-
alchemyGasSponsor?: boolean;
|
|
544
|
-
alchemyGasSponsorApiKey?: string;
|
|
545
|
-
alchemyGasSponsorPolicyId?: string;
|
|
546
|
-
}): Promise<string>;
|
|
547
|
-
/**
|
|
548
|
-
* Generic function to execute any Morpho Vault operation, with optional gas sponsorship
|
|
467
|
+
* Generic function to execute any Morpho operation, with optional gas sponsorship
|
|
549
468
|
*/
|
|
550
|
-
export declare function
|
|
551
|
-
provider?:
|
|
469
|
+
export declare function executeMorphoOperation({ provider, pkpPublicKey, vaultAddress, functionName, args, chainId, alchemyGasSponsor, alchemyGasSponsorApiKey, alchemyGasSponsorPolicyId, }: {
|
|
470
|
+
provider?: any;
|
|
552
471
|
pkpPublicKey: string;
|
|
553
472
|
vaultAddress: string;
|
|
554
473
|
functionName: string;
|
|
@@ -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":"AAGA;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCpB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;CAOnB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;CAOZ,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,GAAG,EA0FlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,GAAG,EAmC1B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAC9D,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,SAAS,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,aAAa,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAE5F;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,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});
|
|
3
|
-
exports.morphoVaultClient = exports.MorphoVaultClient = exports.VAULT_FILTER_PRESETS = exports.ERC20_ABI = exports.
|
|
3
|
+
exports.morphoVaultClient = exports.MorphoVaultClient = exports.VAULT_FILTER_PRESETS = exports.ERC20_ABI = exports.ERC4626_VAULT_ABI = exports.CHAIN_IDS = exports.SUPPORTED_CHAINS = exports.WELL_KNOWN_TOKENS = void 0;
|
|
4
4
|
exports.getTokenAddresses = getTokenAddresses;
|
|
5
5
|
exports.getTokenAddress = getTokenAddress;
|
|
6
6
|
exports.isSupportedChain = isSupportedChain;
|
|
@@ -18,8 +18,7 @@ exports.getVaultsByPreset = getVaultsByPreset;
|
|
|
18
18
|
exports.getVaults = getVaults;
|
|
19
19
|
exports.getSupportedChainsWithVaults = getSupportedChainsWithVaults;
|
|
20
20
|
exports.getVaultDiscoverySummary = getVaultDiscoverySummary;
|
|
21
|
-
exports.
|
|
22
|
-
exports.executeMorphoVaultOperation = executeMorphoVaultOperation;
|
|
21
|
+
exports.executeMorphoOperation = executeMorphoOperation;
|
|
23
22
|
const vincent_scaffold_sdk_1 = require("@lit-protocol/vincent-scaffold-sdk");
|
|
24
23
|
const ethers_1 = require("ethers");
|
|
25
24
|
/**
|
|
@@ -173,107 +172,6 @@ exports.ERC4626_VAULT_ABI = [
|
|
|
173
172
|
type: 'function',
|
|
174
173
|
},
|
|
175
174
|
];
|
|
176
|
-
/**
|
|
177
|
-
* Morpho Market ABI - Essential methods for supply and withdraw operations
|
|
178
|
-
*/
|
|
179
|
-
exports.MORPHO_MARKET_ABI = [
|
|
180
|
-
// Supply
|
|
181
|
-
{
|
|
182
|
-
inputs: [
|
|
183
|
-
{
|
|
184
|
-
components: [
|
|
185
|
-
{ internalType: 'address', name: 'loanToken', type: 'address' },
|
|
186
|
-
{ internalType: 'address', name: 'collateralToken', type: 'address' },
|
|
187
|
-
{ internalType: 'address', name: 'oracle', type: 'address' },
|
|
188
|
-
{ internalType: 'address', name: 'irm', type: 'address' },
|
|
189
|
-
{ internalType: 'uint256', name: 'lltv', type: 'uint256' },
|
|
190
|
-
],
|
|
191
|
-
internalType: 'struct MarketParams',
|
|
192
|
-
name: 'marketParams',
|
|
193
|
-
type: 'tuple',
|
|
194
|
-
},
|
|
195
|
-
{ internalType: 'uint256', name: 'assets', type: 'uint256' },
|
|
196
|
-
{ internalType: 'uint256', name: 'shares', type: 'uint256' },
|
|
197
|
-
{ internalType: 'address', name: 'onBehalf', type: 'address' },
|
|
198
|
-
{ internalType: 'bytes', name: 'data', type: 'bytes' },
|
|
199
|
-
],
|
|
200
|
-
name: 'supply',
|
|
201
|
-
outputs: [
|
|
202
|
-
{ internalType: 'uint256', name: 'assetsSupplied', type: 'uint256' },
|
|
203
|
-
{ internalType: 'uint256', name: 'sharesSupplied', type: 'uint256' },
|
|
204
|
-
],
|
|
205
|
-
stateMutability: 'nonpayable',
|
|
206
|
-
type: 'function',
|
|
207
|
-
},
|
|
208
|
-
// Withdraw Collateral
|
|
209
|
-
{
|
|
210
|
-
inputs: [
|
|
211
|
-
{
|
|
212
|
-
components: [
|
|
213
|
-
{ internalType: 'address', name: 'loanToken', type: 'address' },
|
|
214
|
-
{ internalType: 'address', name: 'collateralToken', type: 'address' },
|
|
215
|
-
{ internalType: 'address', name: 'oracle', type: 'address' },
|
|
216
|
-
{ internalType: 'address', name: 'irm', type: 'address' },
|
|
217
|
-
{ internalType: 'uint256', name: 'lltv', type: 'uint256' },
|
|
218
|
-
],
|
|
219
|
-
internalType: 'struct MarketParams',
|
|
220
|
-
name: 'marketParams',
|
|
221
|
-
type: 'tuple',
|
|
222
|
-
},
|
|
223
|
-
{ internalType: 'uint256', name: 'assets', type: 'uint256' },
|
|
224
|
-
{ internalType: 'address', name: 'onBehalf', type: 'address' },
|
|
225
|
-
{ internalType: 'address', name: 'receiver', type: 'address' },
|
|
226
|
-
],
|
|
227
|
-
name: 'withdrawCollateral',
|
|
228
|
-
outputs: [],
|
|
229
|
-
stateMutability: 'nonpayable',
|
|
230
|
-
type: 'function',
|
|
231
|
-
},
|
|
232
|
-
// Position (to check collateral balance)
|
|
233
|
-
{
|
|
234
|
-
inputs: [
|
|
235
|
-
{ internalType: 'bytes32', name: 'id', type: 'bytes32' },
|
|
236
|
-
{ internalType: 'address', name: 'user', type: 'address' },
|
|
237
|
-
],
|
|
238
|
-
name: 'position',
|
|
239
|
-
outputs: [
|
|
240
|
-
{ internalType: 'uint256', name: 'supplyShares', type: 'uint256' },
|
|
241
|
-
{ internalType: 'uint128', name: 'borrowShares', type: 'uint128' },
|
|
242
|
-
{ internalType: 'uint128', name: 'collateral', type: 'uint128' },
|
|
243
|
-
],
|
|
244
|
-
stateMutability: 'view',
|
|
245
|
-
type: 'function',
|
|
246
|
-
},
|
|
247
|
-
// Market (to check market info)
|
|
248
|
-
{
|
|
249
|
-
inputs: [{ internalType: 'bytes32', name: 'id', type: 'bytes32' }],
|
|
250
|
-
name: 'market',
|
|
251
|
-
outputs: [
|
|
252
|
-
{ internalType: 'uint128', name: 'totalSupplyAssets', type: 'uint128' },
|
|
253
|
-
{ internalType: 'uint128', name: 'totalSupplyShares', type: 'uint128' },
|
|
254
|
-
{ internalType: 'uint128', name: 'totalBorrowAssets', type: 'uint128' },
|
|
255
|
-
{ internalType: 'uint128', name: 'totalBorrowShares', type: 'uint128' },
|
|
256
|
-
{ internalType: 'uint128', name: 'lastUpdate', type: 'uint128' },
|
|
257
|
-
{ internalType: 'uint128', name: 'fee', type: 'uint128' },
|
|
258
|
-
],
|
|
259
|
-
stateMutability: 'view',
|
|
260
|
-
type: 'function',
|
|
261
|
-
},
|
|
262
|
-
// IdToMarketParams (to get market params from ID)
|
|
263
|
-
{
|
|
264
|
-
inputs: [{ internalType: 'bytes32', name: 'id', type: 'bytes32' }],
|
|
265
|
-
name: 'idToMarketParams',
|
|
266
|
-
outputs: [
|
|
267
|
-
{ internalType: 'address', name: 'loanToken', type: 'address' },
|
|
268
|
-
{ internalType: 'address', name: 'collateralToken', type: 'address' },
|
|
269
|
-
{ internalType: 'address', name: 'oracle', type: 'address' },
|
|
270
|
-
{ internalType: 'address', name: 'irm', type: 'address' },
|
|
271
|
-
{ internalType: 'uint256', name: 'lltv', type: 'uint256' },
|
|
272
|
-
],
|
|
273
|
-
stateMutability: 'view',
|
|
274
|
-
type: 'function',
|
|
275
|
-
},
|
|
276
|
-
];
|
|
277
175
|
/**
|
|
278
176
|
* ERC20 Token ABI - Essential methods only
|
|
279
177
|
*/
|
|
@@ -399,32 +297,31 @@ function formatAmount(amount, decimals = 18) {
|
|
|
399
297
|
return ethers_1.ethers.utils.formatUnits(amount, decimals);
|
|
400
298
|
}
|
|
401
299
|
/**
|
|
402
|
-
* Validate operation-specific requirements for Morpho vaults
|
|
300
|
+
* Validate operation-specific requirements for Morpho vaults
|
|
403
301
|
*/
|
|
404
|
-
async function validateOperationRequirements(operation, userBalance, allowance, vaultShares, convertedAmount
|
|
302
|
+
async function validateOperationRequirements(operation, userBalance, allowance, vaultShares, convertedAmount) {
|
|
405
303
|
const userBalanceBN = BigInt(userBalance);
|
|
406
304
|
const allowanceBN = BigInt(allowance);
|
|
407
305
|
const vaultSharesBN = BigInt(vaultShares);
|
|
408
306
|
const convertedAmountBN = BigInt(convertedAmount);
|
|
409
|
-
const collateralBalanceBN = collateralBalance ? BigInt(collateralBalance) : 0n;
|
|
410
307
|
switch (operation) {
|
|
411
|
-
case '
|
|
308
|
+
case 'deposit':
|
|
412
309
|
// Check if user has enough balance
|
|
413
310
|
if (userBalanceBN < convertedAmountBN) {
|
|
414
311
|
return {
|
|
415
312
|
valid: false,
|
|
416
|
-
error: `Insufficient balance for
|
|
313
|
+
error: `Insufficient balance for deposit operation. You have ${userBalance} and need ${convertedAmount}`,
|
|
417
314
|
};
|
|
418
315
|
}
|
|
419
316
|
// Check if user has approved vault to spend tokens
|
|
420
317
|
if (allowanceBN < convertedAmountBN) {
|
|
421
318
|
return {
|
|
422
319
|
valid: false,
|
|
423
|
-
error: `Insufficient allowance for
|
|
320
|
+
error: `Insufficient allowance for deposit operation. Please approve vault to spend your tokens first. You have ${allowance} and need ${convertedAmount}`,
|
|
424
321
|
};
|
|
425
322
|
}
|
|
426
323
|
break;
|
|
427
|
-
case '
|
|
324
|
+
case 'withdraw':
|
|
428
325
|
// For withdraw, we need to check if user has enough vault shares
|
|
429
326
|
if (vaultSharesBN === 0n) {
|
|
430
327
|
return {
|
|
@@ -434,7 +331,7 @@ async function validateOperationRequirements(operation, userBalance, allowance,
|
|
|
434
331
|
}
|
|
435
332
|
// Note: We'll need to convert the amount to shares in the actual implementation
|
|
436
333
|
break;
|
|
437
|
-
case '
|
|
334
|
+
case 'redeem':
|
|
438
335
|
// For redeem, we need to check if user has enough vault shares
|
|
439
336
|
if (vaultSharesBN === 0n) {
|
|
440
337
|
return {
|
|
@@ -450,31 +347,6 @@ async function validateOperationRequirements(operation, userBalance, allowance,
|
|
|
450
347
|
};
|
|
451
348
|
}
|
|
452
349
|
break;
|
|
453
|
-
case 'market_supply':
|
|
454
|
-
// Check if user has enough balance
|
|
455
|
-
if (userBalanceBN < convertedAmountBN) {
|
|
456
|
-
return {
|
|
457
|
-
valid: false,
|
|
458
|
-
error: `Insufficient balance for market supply operation. You have ${userBalance} and need ${convertedAmount}`,
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
// Check if user has approved market to spend tokens
|
|
462
|
-
if (allowanceBN < convertedAmountBN) {
|
|
463
|
-
return {
|
|
464
|
-
valid: false,
|
|
465
|
-
error: `Insufficient allowance for market supply operation. Please approve market to spend your tokens first. You have ${allowance} and need ${convertedAmount}`,
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
break;
|
|
469
|
-
case 'market_withdrawCollateral':
|
|
470
|
-
// Check if user has enough collateral balance
|
|
471
|
-
if (collateralBalanceBN < convertedAmountBN) {
|
|
472
|
-
return {
|
|
473
|
-
valid: false,
|
|
474
|
-
error: `Insufficient collateral balance for withdrawal. You have ${collateralBalance} and need ${convertedAmount}`,
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
break;
|
|
478
350
|
default:
|
|
479
351
|
return { valid: false, error: `Unsupported operation: ${operation}` };
|
|
480
352
|
}
|
|
@@ -1023,62 +895,13 @@ async function getVaultDiscoverySummary(chainId) {
|
|
|
1023
895
|
}
|
|
1024
896
|
}
|
|
1025
897
|
/**
|
|
1026
|
-
*
|
|
1027
|
-
*/
|
|
1028
|
-
async function executeMorphoMarketOperation({ provider, pkpPublicKey, marketAddress, marketId, functionName, args, chainId, alchemyGasSponsor, alchemyGasSponsorApiKey, alchemyGasSponsorPolicyId, }) {
|
|
1029
|
-
console.log(`[@lit-protocol/vincent-ability-morpho/executeMorphoMarketOperation] Starting ${functionName} operation`, { sponsored: !!alchemyGasSponsor, marketId });
|
|
1030
|
-
// Use gas sponsorship if enabled and all required parameters are provided
|
|
1031
|
-
if (alchemyGasSponsor && alchemyGasSponsorApiKey && alchemyGasSponsorPolicyId) {
|
|
1032
|
-
console.log(`[@lit-protocol/vincent-ability-morpho/executeMorphoMarketOperation] Using EIP-7702 gas sponsorship`, { marketAddress, functionName, args, policyId: alchemyGasSponsorPolicyId });
|
|
1033
|
-
try {
|
|
1034
|
-
return await vincent_scaffold_sdk_1.laUtils.transaction.handler.sponsoredGasContractCall({
|
|
1035
|
-
pkpPublicKey,
|
|
1036
|
-
abi: exports.MORPHO_MARKET_ABI,
|
|
1037
|
-
contractAddress: marketAddress,
|
|
1038
|
-
functionName,
|
|
1039
|
-
args,
|
|
1040
|
-
chainId,
|
|
1041
|
-
eip7702AlchemyApiKey: alchemyGasSponsorApiKey,
|
|
1042
|
-
eip7702AlchemyPolicyId: alchemyGasSponsorPolicyId,
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
catch (error) {
|
|
1046
|
-
console.error(`[@lit-protocol/vincent-ability-morpho/executeMorphoMarketOperation] EIP-7702 operation failed:`, error);
|
|
1047
|
-
throw error;
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
else {
|
|
1051
|
-
// Use regular transaction without gas sponsorship
|
|
1052
|
-
console.log(`[@lit-protocol/vincent-ability-morpho/executeMorphoMarketOperation] Using regular transaction`);
|
|
1053
|
-
if (!provider) {
|
|
1054
|
-
throw new Error('Provider is required for non-sponsored transactions');
|
|
1055
|
-
}
|
|
1056
|
-
try {
|
|
1057
|
-
return await vincent_scaffold_sdk_1.laUtils.transaction.handler.contractCall({
|
|
1058
|
-
provider,
|
|
1059
|
-
pkpPublicKey,
|
|
1060
|
-
callerAddress: ethers_1.ethers.utils.computeAddress(pkpPublicKey),
|
|
1061
|
-
abi: exports.MORPHO_MARKET_ABI,
|
|
1062
|
-
contractAddress: marketAddress,
|
|
1063
|
-
functionName,
|
|
1064
|
-
args,
|
|
1065
|
-
chainId,
|
|
1066
|
-
});
|
|
1067
|
-
}
|
|
1068
|
-
catch (error) {
|
|
1069
|
-
console.error(`[@lit-protocol/vincent-ability-morpho/executeMorphoMarketOperation] Regular transaction failed:`, error);
|
|
1070
|
-
throw error;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
/**
|
|
1075
|
-
* Generic function to execute any Morpho Vault operation, with optional gas sponsorship
|
|
898
|
+
* Generic function to execute any Morpho operation, with optional gas sponsorship
|
|
1076
899
|
*/
|
|
1077
|
-
async function
|
|
1078
|
-
console.log(`[@lit-protocol/vincent-ability-morpho/
|
|
900
|
+
async function executeMorphoOperation({ provider, pkpPublicKey, vaultAddress, functionName, args, chainId, alchemyGasSponsor, alchemyGasSponsorApiKey, alchemyGasSponsorPolicyId, }) {
|
|
901
|
+
console.log(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] Starting ${functionName} operation`, { sponsored: !!alchemyGasSponsor });
|
|
1079
902
|
// Use gas sponsorship if enabled and all required parameters are provided
|
|
1080
903
|
if (alchemyGasSponsor && alchemyGasSponsorApiKey && alchemyGasSponsorPolicyId) {
|
|
1081
|
-
console.log(`[@lit-protocol/vincent-ability-morpho/
|
|
904
|
+
console.log(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] Using EIP-7702 gas sponsorship`, { vaultAddress, functionName, args, policyId: alchemyGasSponsorPolicyId });
|
|
1082
905
|
try {
|
|
1083
906
|
return await vincent_scaffold_sdk_1.laUtils.transaction.handler.sponsoredGasContractCall({
|
|
1084
907
|
pkpPublicKey,
|
|
@@ -1092,13 +915,13 @@ async function executeMorphoVaultOperation({ provider, pkpPublicKey, vaultAddres
|
|
|
1092
915
|
});
|
|
1093
916
|
}
|
|
1094
917
|
catch (error) {
|
|
1095
|
-
console.error(`[@lit-protocol/vincent-ability-morpho/
|
|
918
|
+
console.error(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] EIP-7702 operation failed:`, error);
|
|
1096
919
|
throw error;
|
|
1097
920
|
}
|
|
1098
921
|
}
|
|
1099
922
|
else {
|
|
1100
923
|
// Use regular transaction without gas sponsorship
|
|
1101
|
-
console.log(`[@lit-protocol/vincent-ability-morpho/
|
|
924
|
+
console.log(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] Using regular transaction`);
|
|
1102
925
|
if (!provider) {
|
|
1103
926
|
throw new Error('Provider is required for non-sponsored transactions');
|
|
1104
927
|
}
|
|
@@ -1115,7 +938,7 @@ async function executeMorphoVaultOperation({ provider, pkpPublicKey, vaultAddres
|
|
|
1115
938
|
});
|
|
1116
939
|
}
|
|
1117
940
|
catch (error) {
|
|
1118
|
-
console.error(`[@lit-protocol/vincent-ability-morpho/
|
|
941
|
+
console.error(`[@lit-protocol/vincent-ability-morpho/executeMorphoOperation] Regular transaction failed:`, error);
|
|
1119
942
|
throw error;
|
|
1120
943
|
}
|
|
1121
944
|
}
|