@coinbase/agentkit 0.10.2 → 0.10.4
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/README.md +89 -10
- package/dist/action-providers/across/acrossActionProvider.js +2 -4
- package/dist/action-providers/across/acrossActionProvider.test.js +10 -5
- package/dist/action-providers/baseAccount/baseAccountActionProvider.js +5 -7
- package/dist/action-providers/cdp/cdpApiActionProvider.js +7 -30
- package/dist/action-providers/cdp/cdpApiActionProvider.test.js +2 -8
- package/dist/action-providers/cdp/faucetUtils.d.ts +38 -0
- package/dist/action-providers/cdp/faucetUtils.js +81 -0
- package/dist/action-providers/clanker/schemas.d.ts +4 -4
- package/dist/action-providers/clanker/utils.d.ts +2 -1
- package/dist/action-providers/clanker/utils.js +2 -2
- package/dist/action-providers/enso/constants.d.ts +4 -0
- package/dist/action-providers/enso/constants.js +10 -0
- package/dist/action-providers/enso/ensoActionProvider.d.ts +34 -0
- package/dist/action-providers/enso/ensoActionProvider.js +125 -0
- package/dist/action-providers/enso/ensoActionProvider.test.d.ts +1 -0
- package/dist/action-providers/enso/ensoActionProvider.test.js +141 -0
- package/dist/action-providers/enso/index.d.ts +1 -0
- package/dist/action-providers/enso/index.js +17 -0
- package/dist/action-providers/enso/schemas.d.ts +23 -0
- package/dist/action-providers/enso/schemas.js +22 -0
- package/dist/action-providers/erc20/constants.d.ts +2 -0
- package/dist/action-providers/erc20/constants.js +2 -0
- package/dist/action-providers/erc20/erc20ActionProvider.d.ts +17 -1
- package/dist/action-providers/erc20/erc20ActionProvider.js +103 -1
- package/dist/action-providers/erc20/erc20ActionProvider.test.js +201 -0
- package/dist/action-providers/erc20/schemas.d.ts +29 -0
- package/dist/action-providers/erc20/schemas.js +34 -1
- package/dist/action-providers/index.d.ts +4 -1
- package/dist/action-providers/index.js +4 -1
- package/dist/action-providers/jupiter/jupiterActionProvider.js +2 -2
- package/dist/action-providers/spl/splActionProvider.js +12 -13
- package/dist/action-providers/superfluid/graphQueries/superfluidGraphQueries.js +2 -2
- package/dist/action-providers/sushi/constants.d.ts +35 -0
- package/dist/action-providers/sushi/constants.js +7 -0
- package/dist/action-providers/sushi/index.d.ts +4 -0
- package/dist/action-providers/sushi/index.js +20 -0
- package/dist/action-providers/sushi/sushiDataActionProvider.d.ts +32 -0
- package/dist/action-providers/sushi/sushiDataActionProvider.js +113 -0
- package/dist/action-providers/sushi/sushiDataSchemas.d.ts +11 -0
- package/dist/action-providers/sushi/sushiDataSchemas.js +16 -0
- package/dist/action-providers/sushi/sushiRouterActionProvider.d.ts +40 -0
- package/dist/action-providers/sushi/sushiRouterActionProvider.js +386 -0
- package/dist/action-providers/sushi/sushiRouterActionProvider.test.d.ts +1 -0
- package/dist/action-providers/sushi/sushiRouterActionProvider.test.js +392 -0
- package/dist/action-providers/sushi/sushiRouterSchemas.d.ts +36 -0
- package/dist/action-providers/sushi/sushiRouterSchemas.js +55 -0
- package/dist/action-providers/vaultsfyi/constants.d.ts +8 -12
- package/dist/action-providers/vaultsfyi/constants.js +47 -13
- package/dist/action-providers/vaultsfyi/schemas.d.ts +120 -65
- package/dist/action-providers/vaultsfyi/schemas.js +72 -38
- package/dist/action-providers/vaultsfyi/sdk.d.ts +8 -0
- package/dist/action-providers/vaultsfyi/sdk.js +15 -0
- package/dist/action-providers/vaultsfyi/utils.d.ts +151 -55
- package/dist/action-providers/vaultsfyi/utils.js +29 -75
- package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.d.ts +55 -16
- package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.js +413 -217
- package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.test.js +509 -316
- package/dist/action-providers/wallet/walletActionProvider.js +1 -1
- package/dist/action-providers/weth/constants.d.ts +0 -1
- package/dist/action-providers/weth/constants.js +1 -2
- package/dist/action-providers/weth/schemas.js +6 -2
- package/dist/action-providers/weth/wethActionProvider.d.ts +7 -0
- package/dist/action-providers/weth/wethActionProvider.js +57 -32
- package/dist/action-providers/weth/wethActionProvider.test.js +60 -11
- package/dist/action-providers/x402/constants.d.ts +67 -0
- package/dist/action-providers/x402/constants.js +37 -0
- package/dist/action-providers/x402/schemas.d.ts +45 -5
- package/dist/action-providers/x402/schemas.js +81 -11
- package/dist/action-providers/x402/utils.d.ts +89 -14
- package/dist/action-providers/x402/utils.js +335 -31
- package/dist/action-providers/x402/x402ActionProvider.d.ts +21 -7
- package/dist/action-providers/x402/x402ActionProvider.js +250 -184
- package/dist/action-providers/x402/x402ActionProvider.test.js +240 -236
- package/dist/action-providers/yelay/constants.d.ts +64 -0
- package/dist/action-providers/yelay/constants.js +137 -0
- package/dist/action-providers/yelay/index.d.ts +2 -0
- package/dist/action-providers/yelay/index.js +18 -0
- package/dist/action-providers/yelay/schemas.d.ts +47 -0
- package/dist/action-providers/yelay/schemas.js +59 -0
- package/dist/action-providers/yelay/types.d.ts +24 -0
- package/dist/action-providers/yelay/yelayActionProvider.d.ts +70 -0
- package/dist/action-providers/yelay/yelayActionProvider.js +329 -0
- package/dist/action-providers/yelay/yelayActionProvider.test.d.ts +1 -0
- package/dist/action-providers/yelay/yelayActionProvider.test.js +302 -0
- package/dist/action-providers/zora/zoraActionProvider.js +4 -5
- package/dist/wallet-providers/cdpSmartWalletProvider.js +1 -3
- package/dist/wallet-providers/cdpSolanaWalletProvider.d.ts +14 -0
- package/dist/wallet-providers/cdpSolanaWalletProvider.js +39 -3
- package/dist/wallet-providers/cdpSolanaWalletProvider.test.js +16 -0
- package/dist/wallet-providers/privySvmWalletProvider.d.ts +14 -0
- package/dist/wallet-providers/privySvmWalletProvider.js +17 -0
- package/dist/wallet-providers/privySvmWalletProvider.test.js +10 -0
- package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +14 -0
- package/dist/wallet-providers/solanaKeypairWalletProvider.js +17 -0
- package/dist/wallet-providers/svmWalletProvider.d.ts +34 -0
- package/dist/wallet-providers/svmWalletProvider.js +43 -0
- package/dist/wallet-providers/svmWalletProvider.test.js +10 -0
- package/package.json +11 -6
- package/dist/action-providers/vaultsfyi/api/actions.d.ts +0 -41
- package/dist/action-providers/vaultsfyi/api/actions.js +0 -28
- package/dist/action-providers/vaultsfyi/api/historicalData.d.ts +0 -31
- package/dist/action-providers/vaultsfyi/api/historicalData.js +0 -44
- package/dist/action-providers/vaultsfyi/api/types.d.ts +0 -34
- package/dist/action-providers/vaultsfyi/api/vaults.d.ts +0 -66
- package/dist/action-providers/vaultsfyi/api/vaults.js +0 -57
- /package/dist/action-providers/{vaultsfyi/api → yelay}/types.js +0 -0
|
@@ -7,6 +7,7 @@ const MOCK_DECIMALS = 6;
|
|
|
7
7
|
const MOCK_CONTRACT_ADDRESS = "0x1234567890123456789012345678901234567890";
|
|
8
8
|
const MOCK_DESTINATION = "0x9876543210987654321098765432109876543210";
|
|
9
9
|
const MOCK_ADDRESS = "0x1234567890123456789012345678901234567890";
|
|
10
|
+
const MOCK_SPENDER = "0xabcdef1234567890123456789012345678901234";
|
|
10
11
|
describe("Transfer Schema", () => {
|
|
11
12
|
it("should successfully parse valid input", () => {
|
|
12
13
|
const validInput = {
|
|
@@ -142,6 +143,206 @@ describe("GetTokenAddress Schema", () => {
|
|
|
142
143
|
expect(result.success).toBe(false);
|
|
143
144
|
});
|
|
144
145
|
});
|
|
146
|
+
describe("Approve Schema", () => {
|
|
147
|
+
it("should successfully parse valid input", () => {
|
|
148
|
+
const validInput = {
|
|
149
|
+
amount: MOCK_AMOUNT.toString(),
|
|
150
|
+
tokenAddress: MOCK_CONTRACT_ADDRESS,
|
|
151
|
+
spenderAddress: MOCK_SPENDER,
|
|
152
|
+
};
|
|
153
|
+
const result = schemas_1.ApproveSchema.safeParse(validInput);
|
|
154
|
+
expect(result.success).toBe(true);
|
|
155
|
+
expect(result.data).toEqual(validInput);
|
|
156
|
+
});
|
|
157
|
+
it("should fail parsing empty input", () => {
|
|
158
|
+
const emptyInput = {};
|
|
159
|
+
const result = schemas_1.ApproveSchema.safeParse(emptyInput);
|
|
160
|
+
expect(result.success).toBe(false);
|
|
161
|
+
});
|
|
162
|
+
it("should fail parsing invalid token address", () => {
|
|
163
|
+
const invalidInput = {
|
|
164
|
+
amount: MOCK_AMOUNT.toString(),
|
|
165
|
+
tokenAddress: "invalid-address",
|
|
166
|
+
spenderAddress: MOCK_SPENDER,
|
|
167
|
+
};
|
|
168
|
+
const result = schemas_1.ApproveSchema.safeParse(invalidInput);
|
|
169
|
+
expect(result.success).toBe(false);
|
|
170
|
+
});
|
|
171
|
+
it("should fail parsing invalid spender address", () => {
|
|
172
|
+
const invalidInput = {
|
|
173
|
+
amount: MOCK_AMOUNT.toString(),
|
|
174
|
+
tokenAddress: MOCK_CONTRACT_ADDRESS,
|
|
175
|
+
spenderAddress: "invalid-address",
|
|
176
|
+
};
|
|
177
|
+
const result = schemas_1.ApproveSchema.safeParse(invalidInput);
|
|
178
|
+
expect(result.success).toBe(false);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
describe("Allowance Schema", () => {
|
|
182
|
+
it("should successfully parse valid input", () => {
|
|
183
|
+
const validInput = {
|
|
184
|
+
tokenAddress: MOCK_CONTRACT_ADDRESS,
|
|
185
|
+
spenderAddress: MOCK_SPENDER,
|
|
186
|
+
};
|
|
187
|
+
const result = schemas_1.AllowanceSchema.safeParse(validInput);
|
|
188
|
+
expect(result.success).toBe(true);
|
|
189
|
+
expect(result.data).toEqual(validInput);
|
|
190
|
+
});
|
|
191
|
+
it("should fail parsing empty input", () => {
|
|
192
|
+
const emptyInput = {};
|
|
193
|
+
const result = schemas_1.AllowanceSchema.safeParse(emptyInput);
|
|
194
|
+
expect(result.success).toBe(false);
|
|
195
|
+
});
|
|
196
|
+
it("should fail parsing invalid token address", () => {
|
|
197
|
+
const invalidInput = {
|
|
198
|
+
tokenAddress: "invalid-address",
|
|
199
|
+
spenderAddress: MOCK_SPENDER,
|
|
200
|
+
};
|
|
201
|
+
const result = schemas_1.AllowanceSchema.safeParse(invalidInput);
|
|
202
|
+
expect(result.success).toBe(false);
|
|
203
|
+
});
|
|
204
|
+
it("should fail parsing invalid spender address", () => {
|
|
205
|
+
const invalidInput = {
|
|
206
|
+
tokenAddress: MOCK_CONTRACT_ADDRESS,
|
|
207
|
+
spenderAddress: "invalid-address",
|
|
208
|
+
};
|
|
209
|
+
const result = schemas_1.AllowanceSchema.safeParse(invalidInput);
|
|
210
|
+
expect(result.success).toBe(false);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
describe("Approve Action", () => {
|
|
214
|
+
const TRANSACTION_HASH = "0xapprove123456789";
|
|
215
|
+
let mockWallet;
|
|
216
|
+
let mockMulticall;
|
|
217
|
+
const actionProvider = (0, erc20ActionProvider_1.erc20ActionProvider)();
|
|
218
|
+
beforeEach(async () => {
|
|
219
|
+
mockMulticall = jest.fn();
|
|
220
|
+
const mockPublicClient = {
|
|
221
|
+
multicall: mockMulticall,
|
|
222
|
+
getCode: jest.fn().mockResolvedValue("0x"),
|
|
223
|
+
};
|
|
224
|
+
mockWallet = {
|
|
225
|
+
sendTransaction: jest.fn(),
|
|
226
|
+
waitForTransactionReceipt: jest.fn(),
|
|
227
|
+
getName: jest.fn().mockReturnValue("evm_wallet_provider"),
|
|
228
|
+
getNetwork: jest.fn().mockReturnValue({
|
|
229
|
+
networkId: "base-mainnet",
|
|
230
|
+
}),
|
|
231
|
+
getPublicClient: jest.fn().mockReturnValue(mockPublicClient),
|
|
232
|
+
getAddress: jest.fn().mockReturnValue(MOCK_ADDRESS),
|
|
233
|
+
};
|
|
234
|
+
mockWallet.sendTransaction.mockResolvedValue(TRANSACTION_HASH);
|
|
235
|
+
mockWallet.waitForTransactionReceipt.mockResolvedValue({});
|
|
236
|
+
});
|
|
237
|
+
it("should successfully approve tokens", async () => {
|
|
238
|
+
mockMulticall.mockResolvedValueOnce([
|
|
239
|
+
{ result: "MockToken" }, // name
|
|
240
|
+
{ result: MOCK_DECIMALS }, // decimals
|
|
241
|
+
{ result: BigInt(100000 * 10 ** MOCK_DECIMALS) }, // balance
|
|
242
|
+
]);
|
|
243
|
+
const args = {
|
|
244
|
+
amount: MOCK_AMOUNT.toString(),
|
|
245
|
+
tokenAddress: MOCK_CONTRACT_ADDRESS,
|
|
246
|
+
spenderAddress: MOCK_SPENDER,
|
|
247
|
+
};
|
|
248
|
+
const response = await actionProvider.approve(mockWallet, args);
|
|
249
|
+
expect(mockMulticall).toHaveBeenCalled();
|
|
250
|
+
expect(mockWallet.sendTransaction).toHaveBeenCalled();
|
|
251
|
+
expect(mockWallet.waitForTransactionReceipt).toHaveBeenCalledWith(TRANSACTION_HASH);
|
|
252
|
+
expect(response).toContain(`Approved ${MOCK_AMOUNT} MockToken (${MOCK_CONTRACT_ADDRESS}) for spender ${MOCK_SPENDER}`);
|
|
253
|
+
expect(response).toContain(`Transaction hash: ${TRANSACTION_HASH}`);
|
|
254
|
+
});
|
|
255
|
+
it("should fail with an error when token details cannot be fetched", async () => {
|
|
256
|
+
mockMulticall.mockRejectedValue(new Error("Failed to get token details"));
|
|
257
|
+
const args = {
|
|
258
|
+
amount: MOCK_AMOUNT.toString(),
|
|
259
|
+
tokenAddress: MOCK_CONTRACT_ADDRESS,
|
|
260
|
+
spenderAddress: MOCK_SPENDER,
|
|
261
|
+
};
|
|
262
|
+
const response = await actionProvider.approve(mockWallet, args);
|
|
263
|
+
expect(mockMulticall).toHaveBeenCalled();
|
|
264
|
+
expect(response).toContain("Error: Could not fetch token details");
|
|
265
|
+
});
|
|
266
|
+
it("should fail with an error when transaction fails", async () => {
|
|
267
|
+
mockMulticall.mockResolvedValueOnce([
|
|
268
|
+
{ result: "MockToken" }, // name
|
|
269
|
+
{ result: MOCK_DECIMALS }, // decimals
|
|
270
|
+
{ result: BigInt(100000 * 10 ** MOCK_DECIMALS) }, // balance
|
|
271
|
+
]);
|
|
272
|
+
mockWallet.sendTransaction.mockRejectedValue(new Error("Transaction failed"));
|
|
273
|
+
const args = {
|
|
274
|
+
amount: MOCK_AMOUNT.toString(),
|
|
275
|
+
tokenAddress: MOCK_CONTRACT_ADDRESS,
|
|
276
|
+
spenderAddress: MOCK_SPENDER,
|
|
277
|
+
};
|
|
278
|
+
const response = await actionProvider.approve(mockWallet, args);
|
|
279
|
+
expect(response).toContain("Error approving tokens: Error: Transaction failed");
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
describe("Get Allowance Action", () => {
|
|
283
|
+
let mockWallet;
|
|
284
|
+
let mockMulticall;
|
|
285
|
+
let mockReadContract;
|
|
286
|
+
const actionProvider = (0, erc20ActionProvider_1.erc20ActionProvider)();
|
|
287
|
+
beforeEach(async () => {
|
|
288
|
+
mockMulticall = jest.fn();
|
|
289
|
+
mockReadContract = jest.fn();
|
|
290
|
+
const mockPublicClient = {
|
|
291
|
+
multicall: mockMulticall,
|
|
292
|
+
getCode: jest.fn().mockResolvedValue("0x"),
|
|
293
|
+
};
|
|
294
|
+
mockWallet = {
|
|
295
|
+
readContract: mockReadContract,
|
|
296
|
+
getName: jest.fn().mockReturnValue("evm_wallet_provider"),
|
|
297
|
+
getNetwork: jest.fn().mockReturnValue({
|
|
298
|
+
networkId: "base-mainnet",
|
|
299
|
+
}),
|
|
300
|
+
getPublicClient: jest.fn().mockReturnValue(mockPublicClient),
|
|
301
|
+
getAddress: jest.fn().mockReturnValue(MOCK_ADDRESS),
|
|
302
|
+
};
|
|
303
|
+
});
|
|
304
|
+
it("should successfully get allowance", async () => {
|
|
305
|
+
const allowanceAmount = BigInt(MOCK_AMOUNT * 10 ** MOCK_DECIMALS);
|
|
306
|
+
mockMulticall.mockResolvedValueOnce([
|
|
307
|
+
{ result: "MockToken" }, // name
|
|
308
|
+
{ result: MOCK_DECIMALS }, // decimals
|
|
309
|
+
{ result: BigInt(100000 * 10 ** MOCK_DECIMALS) }, // balance
|
|
310
|
+
]);
|
|
311
|
+
mockReadContract.mockResolvedValue(allowanceAmount);
|
|
312
|
+
const args = {
|
|
313
|
+
tokenAddress: MOCK_CONTRACT_ADDRESS,
|
|
314
|
+
spenderAddress: MOCK_SPENDER,
|
|
315
|
+
};
|
|
316
|
+
const response = await actionProvider.getAllowance(mockWallet, args);
|
|
317
|
+
expect(mockMulticall).toHaveBeenCalled();
|
|
318
|
+
expect(mockReadContract).toHaveBeenCalled();
|
|
319
|
+
expect(response).toContain(`Allowance for ${MOCK_SPENDER} to spend MockToken (${MOCK_CONTRACT_ADDRESS}) is ${MOCK_AMOUNT}`);
|
|
320
|
+
});
|
|
321
|
+
it("should fail with an error when token details cannot be fetched", async () => {
|
|
322
|
+
mockMulticall.mockRejectedValue(new Error("Failed to get token details"));
|
|
323
|
+
const args = {
|
|
324
|
+
tokenAddress: MOCK_CONTRACT_ADDRESS,
|
|
325
|
+
spenderAddress: MOCK_SPENDER,
|
|
326
|
+
};
|
|
327
|
+
const response = await actionProvider.getAllowance(mockWallet, args);
|
|
328
|
+
expect(mockMulticall).toHaveBeenCalled();
|
|
329
|
+
expect(response).toContain("Error: Could not fetch token details");
|
|
330
|
+
});
|
|
331
|
+
it("should fail with an error when allowance read fails", async () => {
|
|
332
|
+
mockMulticall.mockResolvedValueOnce([
|
|
333
|
+
{ result: "MockToken" }, // name
|
|
334
|
+
{ result: MOCK_DECIMALS }, // decimals
|
|
335
|
+
{ result: BigInt(100000 * 10 ** MOCK_DECIMALS) }, // balance
|
|
336
|
+
]);
|
|
337
|
+
mockReadContract.mockRejectedValue(new Error("Allowance read failed"));
|
|
338
|
+
const args = {
|
|
339
|
+
tokenAddress: MOCK_CONTRACT_ADDRESS,
|
|
340
|
+
spenderAddress: MOCK_SPENDER,
|
|
341
|
+
};
|
|
342
|
+
const response = await actionProvider.getAllowance(mockWallet, args);
|
|
343
|
+
expect(response).toContain("Error checking allowance: Error: Allowance read failed");
|
|
344
|
+
});
|
|
345
|
+
});
|
|
145
346
|
describe("Get Token Address Action", () => {
|
|
146
347
|
let mockWallet;
|
|
147
348
|
const actionProvider = (0, erc20ActionProvider_1.erc20ActionProvider)();
|
|
@@ -28,6 +28,35 @@ export declare const GetBalanceSchema: z.ZodObject<{
|
|
|
28
28
|
tokenAddress: string;
|
|
29
29
|
address?: string | undefined;
|
|
30
30
|
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Input schema for approve action.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ApproveSchema: z.ZodObject<{
|
|
35
|
+
amount: z.ZodString;
|
|
36
|
+
tokenAddress: z.ZodString;
|
|
37
|
+
spenderAddress: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
amount: string;
|
|
40
|
+
tokenAddress: string;
|
|
41
|
+
spenderAddress: string;
|
|
42
|
+
}, {
|
|
43
|
+
amount: string;
|
|
44
|
+
tokenAddress: string;
|
|
45
|
+
spenderAddress: string;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Input schema for allowance action.
|
|
49
|
+
*/
|
|
50
|
+
export declare const AllowanceSchema: z.ZodObject<{
|
|
51
|
+
tokenAddress: z.ZodString;
|
|
52
|
+
spenderAddress: z.ZodString;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
tokenAddress: string;
|
|
55
|
+
spenderAddress: string;
|
|
56
|
+
}, {
|
|
57
|
+
tokenAddress: string;
|
|
58
|
+
spenderAddress: string;
|
|
59
|
+
}>;
|
|
31
60
|
/**
|
|
32
61
|
* Input schema for get token address action.
|
|
33
62
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GetTokenAddressSchema = exports.GetBalanceSchema = exports.TransferSchema = void 0;
|
|
3
|
+
exports.GetTokenAddressSchema = exports.AllowanceSchema = exports.ApproveSchema = exports.GetBalanceSchema = exports.TransferSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
/**
|
|
6
6
|
* Input schema for transfer action.
|
|
@@ -38,6 +38,39 @@ exports.GetBalanceSchema = zod_1.z
|
|
|
38
38
|
})
|
|
39
39
|
.strip()
|
|
40
40
|
.describe("Instructions for getting wallet balance");
|
|
41
|
+
/**
|
|
42
|
+
* Input schema for approve action.
|
|
43
|
+
*/
|
|
44
|
+
exports.ApproveSchema = zod_1.z
|
|
45
|
+
.object({
|
|
46
|
+
amount: zod_1.z.string().describe("The amount to approve in whole units (e.g. 100 for 100 USDC)"),
|
|
47
|
+
tokenAddress: zod_1.z
|
|
48
|
+
.string()
|
|
49
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
|
|
50
|
+
.describe("The contract address of the token"),
|
|
51
|
+
spenderAddress: zod_1.z
|
|
52
|
+
.string()
|
|
53
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
|
|
54
|
+
.describe("The address to approve for spending tokens"),
|
|
55
|
+
})
|
|
56
|
+
.strip()
|
|
57
|
+
.describe("Instructions for approving token spending");
|
|
58
|
+
/**
|
|
59
|
+
* Input schema for allowance action.
|
|
60
|
+
*/
|
|
61
|
+
exports.AllowanceSchema = zod_1.z
|
|
62
|
+
.object({
|
|
63
|
+
tokenAddress: zod_1.z
|
|
64
|
+
.string()
|
|
65
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
|
|
66
|
+
.describe("The contract address of the token"),
|
|
67
|
+
spenderAddress: zod_1.z
|
|
68
|
+
.string()
|
|
69
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
|
|
70
|
+
.describe("The address to check allowance for"),
|
|
71
|
+
})
|
|
72
|
+
.strip()
|
|
73
|
+
.describe("Instructions for checking token allowance");
|
|
41
74
|
/**
|
|
42
75
|
* Input schema for get token address action.
|
|
43
76
|
*/
|
|
@@ -7,8 +7,10 @@ export * from "./baseAccount";
|
|
|
7
7
|
export * from "./basename";
|
|
8
8
|
export * from "./cdp-legacy";
|
|
9
9
|
export * from "./cdp";
|
|
10
|
+
export * from "./clanker";
|
|
10
11
|
export * from "./compound";
|
|
11
12
|
export * from "./defillama";
|
|
13
|
+
export * from "./enso";
|
|
12
14
|
export * from "./erc20";
|
|
13
15
|
export * from "./erc721";
|
|
14
16
|
export * from "./farcaster";
|
|
@@ -20,6 +22,7 @@ export * from "./morpho";
|
|
|
20
22
|
export * from "./opensea";
|
|
21
23
|
export * from "./spl";
|
|
22
24
|
export * from "./superfluid";
|
|
25
|
+
export * from "./sushi";
|
|
23
26
|
export * from "./truemarkets";
|
|
24
27
|
export * from "./twitter";
|
|
25
28
|
export * from "./wallet";
|
|
@@ -30,8 +33,8 @@ export * from "./flaunch";
|
|
|
30
33
|
export * from "./onramp";
|
|
31
34
|
export * from "./vaultsfyi";
|
|
32
35
|
export * from "./x402";
|
|
36
|
+
export * from "./yelay";
|
|
33
37
|
export * from "./zerion";
|
|
34
38
|
export * from "./zerodev";
|
|
35
39
|
export * from "./zeroX";
|
|
36
40
|
export * from "./zora";
|
|
37
|
-
export * from "./clanker";
|
|
@@ -23,8 +23,10 @@ __exportStar(require("./baseAccount"), exports);
|
|
|
23
23
|
__exportStar(require("./basename"), exports);
|
|
24
24
|
__exportStar(require("./cdp-legacy"), exports);
|
|
25
25
|
__exportStar(require("./cdp"), exports);
|
|
26
|
+
__exportStar(require("./clanker"), exports);
|
|
26
27
|
__exportStar(require("./compound"), exports);
|
|
27
28
|
__exportStar(require("./defillama"), exports);
|
|
29
|
+
__exportStar(require("./enso"), exports);
|
|
28
30
|
__exportStar(require("./erc20"), exports);
|
|
29
31
|
__exportStar(require("./erc721"), exports);
|
|
30
32
|
__exportStar(require("./farcaster"), exports);
|
|
@@ -36,6 +38,7 @@ __exportStar(require("./morpho"), exports);
|
|
|
36
38
|
__exportStar(require("./opensea"), exports);
|
|
37
39
|
__exportStar(require("./spl"), exports);
|
|
38
40
|
__exportStar(require("./superfluid"), exports);
|
|
41
|
+
__exportStar(require("./sushi"), exports);
|
|
39
42
|
__exportStar(require("./truemarkets"), exports);
|
|
40
43
|
__exportStar(require("./twitter"), exports);
|
|
41
44
|
__exportStar(require("./wallet"), exports);
|
|
@@ -46,8 +49,8 @@ __exportStar(require("./flaunch"), exports);
|
|
|
46
49
|
__exportStar(require("./onramp"), exports);
|
|
47
50
|
__exportStar(require("./vaultsfyi"), exports);
|
|
48
51
|
__exportStar(require("./x402"), exports);
|
|
52
|
+
__exportStar(require("./yelay"), exports);
|
|
49
53
|
__exportStar(require("./zerion"), exports);
|
|
50
54
|
__exportStar(require("./zerodev"), exports);
|
|
51
55
|
__exportStar(require("./zeroX"), exports);
|
|
52
56
|
__exportStar(require("./zora"), exports);
|
|
53
|
-
__exportStar(require("./clanker"), exports);
|
|
@@ -17,6 +17,7 @@ const actionDecorator_1 = require("../actionDecorator");
|
|
|
17
17
|
const schemas_1 = require("./schemas");
|
|
18
18
|
const web3_js_1 = require("@solana/web3.js");
|
|
19
19
|
const api_1 = require("@jup-ag/api");
|
|
20
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
20
21
|
/**
|
|
21
22
|
* JupiterActionProvider handles token swaps using Jupiter's API.
|
|
22
23
|
*/
|
|
@@ -40,10 +41,9 @@ class JupiterActionProvider extends actionProvider_1.ActionProvider {
|
|
|
40
41
|
const userPublicKey = walletProvider.getPublicKey();
|
|
41
42
|
const inputMint = new web3_js_1.PublicKey(args.inputMint);
|
|
42
43
|
const outputMint = new web3_js_1.PublicKey(args.outputMint);
|
|
43
|
-
const { getMint } = await import("@solana/spl-token");
|
|
44
44
|
let mintInfo;
|
|
45
45
|
try {
|
|
46
|
-
mintInfo = await getMint(walletProvider.getConnection(), inputMint);
|
|
46
|
+
mintInfo = await (0, spl_token_1.getMint)(walletProvider.getConnection(), inputMint);
|
|
47
47
|
}
|
|
48
48
|
catch (error) {
|
|
49
49
|
return `Failed to fetch mint info for mint address ${args.inputMint}. Error: ${error}`;
|
|
@@ -16,6 +16,7 @@ const zod_1 = require("zod");
|
|
|
16
16
|
const actionDecorator_1 = require("../actionDecorator");
|
|
17
17
|
const schemas_1 = require("./schemas");
|
|
18
18
|
const web3_js_1 = require("@solana/web3.js");
|
|
19
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
19
20
|
/**
|
|
20
21
|
* SplActionProvider serves as a provider for SPL token actions.
|
|
21
22
|
* It provides SPL token transfer functionality.
|
|
@@ -42,22 +43,21 @@ class SplActionProvider extends actionProvider_1.ActionProvider {
|
|
|
42
43
|
const connection = walletProvider.getConnection();
|
|
43
44
|
const mintPubkey = new web3_js_1.PublicKey(args.mintAddress);
|
|
44
45
|
const ownerPubkey = new web3_js_1.PublicKey(args.address);
|
|
45
|
-
const { getMint, getAssociatedTokenAddress, getAccount, TokenAccountNotFoundError } = await import("@solana/spl-token");
|
|
46
46
|
let mintInfo;
|
|
47
47
|
try {
|
|
48
|
-
mintInfo = await getMint(connection, mintPubkey);
|
|
48
|
+
mintInfo = await (0, spl_token_1.getMint)(connection, mintPubkey);
|
|
49
49
|
}
|
|
50
50
|
catch (error) {
|
|
51
51
|
return `Failed to fetch mint info for mint address ${args.mintAddress}. Error: ${error}`;
|
|
52
52
|
}
|
|
53
53
|
try {
|
|
54
|
-
const ata = await getAssociatedTokenAddress(mintPubkey, ownerPubkey);
|
|
55
|
-
const account = await getAccount(connection, ata);
|
|
54
|
+
const ata = await (0, spl_token_1.getAssociatedTokenAddress)(mintPubkey, ownerPubkey);
|
|
55
|
+
const account = await (0, spl_token_1.getAccount)(connection, ata);
|
|
56
56
|
const balance = Number(account.amount) / Math.pow(10, mintInfo.decimals);
|
|
57
57
|
return `Balance for ${args.address} is ${balance} tokens`;
|
|
58
58
|
}
|
|
59
59
|
catch (error) {
|
|
60
|
-
if (error instanceof TokenAccountNotFoundError) {
|
|
60
|
+
if (error instanceof spl_token_1.TokenAccountNotFoundError) {
|
|
61
61
|
return `Balance for ${args.address} is 0 tokens`;
|
|
62
62
|
}
|
|
63
63
|
throw error;
|
|
@@ -80,29 +80,28 @@ class SplActionProvider extends actionProvider_1.ActionProvider {
|
|
|
80
80
|
const fromPubkey = walletProvider.getPublicKey();
|
|
81
81
|
const toPubkey = new web3_js_1.PublicKey(args.recipient);
|
|
82
82
|
const mintPubkey = new web3_js_1.PublicKey(args.mintAddress);
|
|
83
|
-
const { getMint, getAssociatedTokenAddress, getAccount, createAssociatedTokenAccountInstruction, createTransferCheckedInstruction, } = await import("@solana/spl-token");
|
|
84
83
|
let mintInfo;
|
|
85
84
|
try {
|
|
86
|
-
mintInfo = await getMint(connection, mintPubkey);
|
|
85
|
+
mintInfo = await (0, spl_token_1.getMint)(connection, mintPubkey);
|
|
87
86
|
}
|
|
88
87
|
catch (error) {
|
|
89
88
|
return `Failed to fetch mint info for mint address ${args.mintAddress}. Error: ${error}`;
|
|
90
89
|
}
|
|
91
90
|
const adjustedAmount = args.amount * Math.pow(10, mintInfo.decimals);
|
|
92
|
-
const sourceAta = await getAssociatedTokenAddress(mintPubkey, fromPubkey);
|
|
93
|
-
const destinationAta = await getAssociatedTokenAddress(mintPubkey, toPubkey);
|
|
91
|
+
const sourceAta = await (0, spl_token_1.getAssociatedTokenAddress)(mintPubkey, fromPubkey);
|
|
92
|
+
const destinationAta = await (0, spl_token_1.getAssociatedTokenAddress)(mintPubkey, toPubkey);
|
|
94
93
|
const instructions = [];
|
|
95
|
-
const sourceAccount = await getAccount(connection, sourceAta);
|
|
94
|
+
const sourceAccount = await (0, spl_token_1.getAccount)(connection, sourceAta);
|
|
96
95
|
if (sourceAccount.amount < BigInt(adjustedAmount)) {
|
|
97
96
|
throw new Error(`Insufficient token balance. Have ${sourceAccount.amount}, need ${adjustedAmount}`);
|
|
98
97
|
}
|
|
99
98
|
try {
|
|
100
|
-
await getAccount(connection, destinationAta);
|
|
99
|
+
await (0, spl_token_1.getAccount)(connection, destinationAta);
|
|
101
100
|
}
|
|
102
101
|
catch {
|
|
103
|
-
instructions.push(createAssociatedTokenAccountInstruction(fromPubkey, destinationAta, toPubkey, mintPubkey));
|
|
102
|
+
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(fromPubkey, destinationAta, toPubkey, mintPubkey));
|
|
104
103
|
}
|
|
105
|
-
instructions.push(createTransferCheckedInstruction(sourceAta, mintPubkey, destinationAta, fromPubkey, adjustedAmount, mintInfo.decimals));
|
|
104
|
+
instructions.push((0, spl_token_1.createTransferCheckedInstruction)(sourceAta, mintPubkey, destinationAta, fromPubkey, adjustedAmount, mintInfo.decimals));
|
|
106
105
|
const tx = new web3_js_1.VersionedTransaction(web3_js_1.MessageV0.compile({
|
|
107
106
|
payerKey: fromPubkey,
|
|
108
107
|
instructions: instructions,
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getAccountOutflow = getAccountOutflow;
|
|
4
4
|
const queries_1 = require("./queries");
|
|
5
5
|
const endpoints_1 = require("./endpoints");
|
|
6
|
+
const graphql_request_1 = require("graphql-request");
|
|
6
7
|
/**
|
|
7
8
|
* Gets the current account outflows for the user
|
|
8
9
|
*
|
|
@@ -11,8 +12,7 @@ const endpoints_1 = require("./endpoints");
|
|
|
11
12
|
*/
|
|
12
13
|
async function getAccountOutflow(userId) {
|
|
13
14
|
try {
|
|
14
|
-
const
|
|
15
|
-
const client = new GraphQLClient(endpoints_1.BASE_GRAPH_ENDPOINT);
|
|
15
|
+
const client = new graphql_request_1.GraphQLClient(endpoints_1.BASE_GRAPH_ENDPOINT);
|
|
16
16
|
const variables = { id: userId.toLowerCase() };
|
|
17
17
|
const data = await client.request(queries_1.getAccountOutflowQuery, variables);
|
|
18
18
|
return data;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const routeProcessor9Abi_Route: readonly [{
|
|
2
|
+
readonly name: "Route";
|
|
3
|
+
readonly type: "event";
|
|
4
|
+
readonly inputs: readonly [{
|
|
5
|
+
readonly type: "address";
|
|
6
|
+
readonly name: "from";
|
|
7
|
+
readonly indexed: true;
|
|
8
|
+
}, {
|
|
9
|
+
readonly type: "address";
|
|
10
|
+
readonly name: "to";
|
|
11
|
+
}, {
|
|
12
|
+
readonly type: "address";
|
|
13
|
+
readonly name: "tokenIn";
|
|
14
|
+
readonly indexed: true;
|
|
15
|
+
}, {
|
|
16
|
+
readonly type: "address";
|
|
17
|
+
readonly name: "tokenOut";
|
|
18
|
+
}, {
|
|
19
|
+
readonly type: "uint256";
|
|
20
|
+
readonly name: "amountIn";
|
|
21
|
+
}, {
|
|
22
|
+
readonly type: "uint256";
|
|
23
|
+
readonly name: "amountOut";
|
|
24
|
+
}, {
|
|
25
|
+
readonly type: "int256";
|
|
26
|
+
readonly name: "slippage";
|
|
27
|
+
}, {
|
|
28
|
+
readonly type: "uint32";
|
|
29
|
+
readonly name: "referralCode";
|
|
30
|
+
readonly indexed: true;
|
|
31
|
+
}, {
|
|
32
|
+
readonly type: "bytes32";
|
|
33
|
+
readonly name: "diagnosticsFirst32";
|
|
34
|
+
}];
|
|
35
|
+
}];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.routeProcessor9Abi_Route = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
exports.routeProcessor9Abi_Route = (0, viem_1.parseAbi)([
|
|
6
|
+
"event Route(address indexed from, address to, address indexed tokenIn, address tokenOut, uint256 amountIn, uint256 amountOut, int256 slippage, uint32 indexed referralCode, bytes32 diagnosticsFirst32)",
|
|
7
|
+
]);
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./sushiDataSchemas"), exports);
|
|
18
|
+
__exportStar(require("./sushiDataActionProvider"), exports);
|
|
19
|
+
__exportStar(require("./sushiRouterSchemas"), exports);
|
|
20
|
+
__exportStar(require("./sushiRouterActionProvider"), exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { EvmWalletProvider } from "../../wallet-providers";
|
|
3
|
+
import { ActionProvider } from "../actionProvider";
|
|
4
|
+
import { Network } from "../../network";
|
|
5
|
+
import { FindTokenSchema } from "./sushiDataSchemas";
|
|
6
|
+
/**
|
|
7
|
+
* SushiDataActionProvider is an action provider for Sushi.
|
|
8
|
+
*
|
|
9
|
+
* This provider is used for any action that uses the Sushi Data API.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SushiDataActionProvider extends ActionProvider<EvmWalletProvider> {
|
|
12
|
+
/**
|
|
13
|
+
* Constructor for the SushiDataActionProvider class.
|
|
14
|
+
*/
|
|
15
|
+
constructor();
|
|
16
|
+
/**
|
|
17
|
+
* Swaps a specified amount of a from token to a to token for the wallet.
|
|
18
|
+
*
|
|
19
|
+
* @param walletProvider - The wallet provider to swap the tokens from.
|
|
20
|
+
* @param args - The input arguments for the action.
|
|
21
|
+
* @returns A message containing the swap details.
|
|
22
|
+
*/
|
|
23
|
+
findToken(walletProvider: EvmWalletProvider, args: z.infer<typeof FindTokenSchema>): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Custom action providers are supported on all networks
|
|
26
|
+
*
|
|
27
|
+
* @param network - The network to checkpointSaver
|
|
28
|
+
* @returns True if the network is supported, false otherwise
|
|
29
|
+
*/
|
|
30
|
+
supportsNetwork(network: Network): boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare const sushiDataActionProvider: () => SushiDataActionProvider;
|