@coinbase/agentkit 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +234 -0
  2. package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.d.ts +37 -0
  3. package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.js +91 -0
  4. package/dist/action-providers/cdp-v2/index.d.ts +2 -0
  5. package/dist/action-providers/cdp-v2/index.js +18 -0
  6. package/dist/action-providers/cdp-v2/schemas.d.ts +11 -0
  7. package/dist/action-providers/cdp-v2/schemas.js +13 -0
  8. package/dist/action-providers/compound/schemas.d.ts +8 -8
  9. package/dist/action-providers/index.d.ts +3 -0
  10. package/dist/action-providers/index.js +3 -0
  11. package/dist/action-providers/vaultsfyi/api/actions.d.ts +41 -0
  12. package/dist/action-providers/vaultsfyi/api/actions.js +28 -0
  13. package/dist/action-providers/vaultsfyi/api/types.d.ts +34 -0
  14. package/dist/action-providers/vaultsfyi/api/types.js +2 -0
  15. package/dist/action-providers/vaultsfyi/api/vaults.d.ts +38 -0
  16. package/dist/action-providers/vaultsfyi/api/vaults.js +39 -0
  17. package/dist/action-providers/vaultsfyi/constants.d.ts +12 -0
  18. package/dist/action-providers/vaultsfyi/constants.js +15 -0
  19. package/dist/action-providers/vaultsfyi/index.d.ts +7 -0
  20. package/dist/action-providers/vaultsfyi/index.js +23 -0
  21. package/dist/action-providers/vaultsfyi/schemas.d.ts +94 -0
  22. package/dist/action-providers/vaultsfyi/schemas.js +49 -0
  23. package/dist/action-providers/vaultsfyi/utils.d.ts +34 -0
  24. package/dist/action-providers/vaultsfyi/utils.js +69 -0
  25. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.d.ts +98 -0
  26. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.js +383 -0
  27. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.test.d.ts +1 -0
  28. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.test.js +438 -0
  29. package/dist/action-providers/zerodev/index.d.ts +1 -0
  30. package/dist/action-providers/zerodev/index.js +17 -0
  31. package/dist/action-providers/zerodev/schemas.d.ts +29 -0
  32. package/dist/action-providers/zerodev/schemas.js +21 -0
  33. package/dist/action-providers/zerodev/zeroDevWalletActionProvider.d.ts +32 -0
  34. package/dist/action-providers/zerodev/zeroDevWalletActionProvider.js +66 -0
  35. package/dist/action-providers/zerodev/zeroDevWalletActionProvider.test.d.ts +1 -0
  36. package/dist/action-providers/zerodev/zeroDevWalletActionProvider.test.js +112 -0
  37. package/dist/network/svm.d.ts +1 -0
  38. package/dist/network/svm.js +6 -1
  39. package/dist/wallet-providers/cdpV2EvmWalletProvider.d.ts +105 -0
  40. package/dist/wallet-providers/cdpV2EvmWalletProvider.js +212 -0
  41. package/dist/wallet-providers/cdpV2EvmWalletProvider.test.d.ts +1 -0
  42. package/dist/wallet-providers/cdpV2EvmWalletProvider.test.js +343 -0
  43. package/dist/wallet-providers/cdpV2Shared.d.ts +41 -0
  44. package/dist/wallet-providers/cdpV2Shared.js +2 -0
  45. package/dist/wallet-providers/cdpV2SolanaWalletProvider.d.ts +111 -0
  46. package/dist/wallet-providers/cdpV2SolanaWalletProvider.js +247 -0
  47. package/dist/wallet-providers/cdpV2SolanaWalletProvider.test.d.ts +1 -0
  48. package/dist/wallet-providers/cdpV2SolanaWalletProvider.test.js +307 -0
  49. package/dist/wallet-providers/cdpV2WalletProvider.d.ts +35 -0
  50. package/dist/wallet-providers/cdpV2WalletProvider.js +42 -0
  51. package/dist/wallet-providers/cdpWalletProvider.js +1 -1
  52. package/dist/wallet-providers/cdpWalletProvider.test.js +1 -0
  53. package/dist/wallet-providers/evmWalletProvider.d.ts +7 -1
  54. package/dist/wallet-providers/evmWalletProvider.js +20 -0
  55. package/dist/wallet-providers/index.d.ts +5 -0
  56. package/dist/wallet-providers/index.js +5 -0
  57. package/dist/wallet-providers/walletProvider.test.js +22 -0
  58. package/dist/wallet-providers/zeroDevWalletProvider.d.ts +147 -0
  59. package/dist/wallet-providers/zeroDevWalletProvider.js +301 -0
  60. package/dist/wallet-providers/zeroDevWalletProvider.test.d.ts +1 -0
  61. package/dist/wallet-providers/zeroDevWalletProvider.test.js +435 -0
  62. package/package.json +5 -1
@@ -0,0 +1,438 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vaultsfyiActionProvider_1 = require("./vaultsfyiActionProvider");
4
+ const constants_1 = require("./constants");
5
+ const mockFetchResult = (status, data) => {
6
+ return {
7
+ json: async () => data,
8
+ status,
9
+ ok: status >= 200 && status < 300,
10
+ };
11
+ };
12
+ const mockVault = (num) => ({
13
+ apiResult: {
14
+ address: `0x${num.toString(16).padStart(40, "0")}`,
15
+ network: `network-${num}`,
16
+ name: `vault-${num}`,
17
+ protocol: `protocol-${num}`,
18
+ token: {
19
+ name: `token-${num}`,
20
+ assetAddress: `0x${num.toString(16).padStart(40, "0")}`,
21
+ symbol: `T${num}`,
22
+ decimals: 18,
23
+ },
24
+ tvlDetails: {
25
+ tvlUsd: num.toString(),
26
+ },
27
+ apy: {
28
+ base: {
29
+ "7day": num * 100,
30
+ },
31
+ rewards: {
32
+ "7day": num * 100,
33
+ },
34
+ total: {
35
+ "7day": num * 100,
36
+ },
37
+ },
38
+ isTransactional: true,
39
+ },
40
+ transformedResult: {
41
+ name: `vault-${num}`,
42
+ address: `0x${num.toString(16).padStart(40, "0")}`,
43
+ network: `network-${num}`,
44
+ protocol: `protocol-${num}`,
45
+ tvlInUsd: num,
46
+ token: {
47
+ name: `token-${num}`,
48
+ address: `0x${num.toString(16).padStart(40, "0")}`,
49
+ symbol: `T${num}`,
50
+ },
51
+ apy: {
52
+ base: num,
53
+ rewards: num,
54
+ total: num,
55
+ },
56
+ link: `https://app.vaults.fyi/opportunity/network-${num}/0x${num.toString(16).padStart(40, "0")}`,
57
+ },
58
+ });
59
+ const MOCK_TX_HASH = "0xmock-hash";
60
+ describe("VaultsfyiActionProvider", () => {
61
+ const provider = new vaultsfyiActionProvider_1.VaultsfyiActionProvider({ apiKey: "test-api-key" });
62
+ let mockWalletProvider;
63
+ let mockedFetch;
64
+ const originalFetch = global.fetch;
65
+ beforeAll(() => {
66
+ global.fetch = mockedFetch = jest.fn();
67
+ });
68
+ afterAll(() => {
69
+ global.fetch = originalFetch;
70
+ });
71
+ beforeEach(() => {
72
+ mockWalletProvider = {
73
+ getAddress: jest.fn(),
74
+ getBalance: jest.fn(),
75
+ getName: jest.fn(),
76
+ getNetwork: jest.fn().mockReturnValue({
77
+ protocolFamily: "evm",
78
+ networkId: "test-network",
79
+ }),
80
+ nativeTransfer: jest.fn(),
81
+ readContract: jest.fn(() => Promise.resolve(18)), // token decimals
82
+ sendTransaction: jest.fn(() => Promise.resolve(MOCK_TX_HASH)),
83
+ waitForTransactionReceipt: jest.fn(),
84
+ };
85
+ });
86
+ describe("network support", () => {
87
+ it("should support all vaultsfyi networks", () => {
88
+ Object.keys(constants_1.VAULTSFYI_SUPPORTED_CHAINS).forEach(network => {
89
+ expect(provider.supportsNetwork({
90
+ protocolFamily: "evm",
91
+ chainId: network,
92
+ })).toBe(true);
93
+ });
94
+ });
95
+ it("should not support other protocol families", () => {
96
+ expect(provider.supportsNetwork({
97
+ protocolFamily: "evm",
98
+ chainId: "some-other-chain",
99
+ })).toBe(false);
100
+ });
101
+ it("should handle invalid network objects", () => {
102
+ expect(provider.supportsNetwork({})).toBe(false);
103
+ });
104
+ });
105
+ describe("vaults action", () => {
106
+ it("should return a transformed vault", async () => {
107
+ const mockedVault = mockVault(1);
108
+ mockedFetch.mockResolvedValue(mockFetchResult(200, { data: [mockedVault.apiResult] }));
109
+ const args = {};
110
+ const result = await provider.vaults(mockWalletProvider, args);
111
+ expect(JSON.parse(result)).toStrictEqual({
112
+ totalResults: 1,
113
+ nextPage: false,
114
+ results: [mockedVault.transformedResult],
115
+ });
116
+ });
117
+ it("should filter by protocol", async () => {
118
+ const mockedVaults = [mockVault(1), mockVault(2)];
119
+ mockedFetch.mockResolvedValue(mockFetchResult(200, { data: mockedVaults.map(v => v.apiResult) }));
120
+ const args = { protocol: "protocol-1" };
121
+ const result = await provider.vaults(mockWalletProvider, args);
122
+ expect(JSON.parse(result)).toStrictEqual({
123
+ totalResults: 1,
124
+ nextPage: false,
125
+ results: [mockedVaults[0].transformedResult],
126
+ });
127
+ });
128
+ it("should take a limit", async () => {
129
+ const mockedVaults = [mockVault(1), mockVault(2)];
130
+ mockedFetch.mockResolvedValue(mockFetchResult(200, { data: mockedVaults.map(v => v.apiResult) }));
131
+ const args = { take: 1 };
132
+ const result = await provider.vaults(mockWalletProvider, args);
133
+ expect(JSON.parse(result)).toStrictEqual({
134
+ totalResults: 2,
135
+ nextPage: true,
136
+ results: [mockedVaults[0].transformedResult],
137
+ });
138
+ });
139
+ describe("sorting", () => {
140
+ it("should sort by TVL", async () => {
141
+ const mockedVaults = [mockVault(2), mockVault(1)];
142
+ mockedFetch.mockResolvedValue(mockFetchResult(200, { data: mockedVaults.map(v => v.apiResult) }));
143
+ const args = { sort: { field: "tvl", direction: "asc" } };
144
+ const result = await provider.vaults(mockWalletProvider, args);
145
+ expect(JSON.parse(result)).toStrictEqual({
146
+ totalResults: 2,
147
+ nextPage: false,
148
+ results: [mockedVaults[1].transformedResult, mockedVaults[0].transformedResult],
149
+ });
150
+ });
151
+ it("should sort by APY", async () => {
152
+ const mockedVaults = [mockVault(2), mockVault(1)];
153
+ mockedFetch.mockResolvedValue(mockFetchResult(200, { data: mockedVaults.map(v => v.apiResult) }));
154
+ const args = { sort: { field: "apy", direction: "asc" } };
155
+ const result = await provider.vaults(mockWalletProvider, args);
156
+ expect(JSON.parse(result)).toStrictEqual({
157
+ totalResults: 2,
158
+ nextPage: false,
159
+ results: [mockedVaults[1].transformedResult, mockedVaults[0].transformedResult],
160
+ });
161
+ });
162
+ it("should sort by name by default", async () => {
163
+ const mockedVaults = [mockVault(2), mockVault(1)];
164
+ mockedFetch.mockResolvedValue(mockFetchResult(200, { data: mockedVaults.map(v => v.apiResult) }));
165
+ const args = {};
166
+ const result = await provider.vaults(mockWalletProvider, args);
167
+ expect(JSON.parse(result)).toStrictEqual({
168
+ totalResults: 2,
169
+ nextPage: false,
170
+ results: [mockedVaults[1].transformedResult, mockedVaults[0].transformedResult],
171
+ });
172
+ });
173
+ });
174
+ it("should return an error if the API request fails", async () => {
175
+ mockedFetch.mockResolvedValue(mockFetchResult(500, { error: "Internal Server Error", message: "some more info" }));
176
+ const args = {};
177
+ expect(await provider.vaults(mockWalletProvider, args)).toBe("Failed to fetch vaults: Internal Server Error, some more info");
178
+ });
179
+ });
180
+ describe("deposit action", () => {
181
+ it("should execute deposit", async () => {
182
+ mockedFetch.mockResolvedValue(mockFetchResult(200, {
183
+ currentActionIndex: 0,
184
+ actions: [
185
+ {
186
+ tx: {
187
+ to: "0x123",
188
+ data: "0x456",
189
+ value: "1",
190
+ chainId: 1,
191
+ },
192
+ description: "Deposit to vault",
193
+ },
194
+ ],
195
+ }));
196
+ const args = {
197
+ vaultAddress: "0x123",
198
+ assetAddress: "0x456",
199
+ network: "mainnet",
200
+ amount: 1,
201
+ };
202
+ const response = await provider.deposit(mockWalletProvider, args);
203
+ expect(response).toBe("Deposit successful");
204
+ expect(mockWalletProvider.sendTransaction).toHaveBeenCalledWith({
205
+ to: "0x123",
206
+ data: "0x456",
207
+ value: 1n,
208
+ chainId: 1,
209
+ });
210
+ expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalledWith(MOCK_TX_HASH);
211
+ });
212
+ it("should execute multiple transactions", async () => {
213
+ mockedFetch.mockResolvedValue(mockFetchResult(200, {
214
+ currentActionIndex: 0,
215
+ actions: [
216
+ {
217
+ tx: {
218
+ to: "0x123",
219
+ data: "0x456",
220
+ value: "1",
221
+ chainId: 1,
222
+ },
223
+ description: "Deposit to vault",
224
+ },
225
+ {
226
+ tx: {
227
+ to: "0x789",
228
+ data: "0xabc",
229
+ value: "2",
230
+ chainId: 1,
231
+ },
232
+ description: "Deposit to vault",
233
+ },
234
+ ],
235
+ }));
236
+ const args = {
237
+ vaultAddress: "0x123",
238
+ assetAddress: "0x456",
239
+ network: "mainnet",
240
+ amount: 1,
241
+ };
242
+ const response = await provider.deposit(mockWalletProvider, args);
243
+ expect(response).toBe("Deposit successful");
244
+ expect(mockWalletProvider.sendTransaction).toHaveBeenCalledWith({
245
+ to: "0x123",
246
+ data: "0x456",
247
+ value: 1n,
248
+ chainId: 1,
249
+ });
250
+ expect(mockWalletProvider.sendTransaction).toHaveBeenCalledWith({
251
+ to: "0x789",
252
+ data: "0xabc",
253
+ value: 2n,
254
+ chainId: 1,
255
+ });
256
+ expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalledWith(MOCK_TX_HASH);
257
+ });
258
+ it("should return an error if the API request fails", async () => {
259
+ mockedFetch.mockResolvedValue(mockFetchResult(500, { error: "Internal Server Error", message: "some more info" }));
260
+ const args = {
261
+ vaultAddress: "0x123",
262
+ assetAddress: "0x456",
263
+ network: "mainnet",
264
+ amount: 1,
265
+ };
266
+ expect(await provider.deposit(mockWalletProvider, args)).toBe("Failed to fetch deposit transactions: Internal Server Error, some more info");
267
+ });
268
+ });
269
+ describe("redeem action", () => {
270
+ it("should execute redeem", async () => {
271
+ mockedFetch.mockResolvedValue(mockFetchResult(200, {
272
+ currentActionIndex: 0,
273
+ actions: [
274
+ {
275
+ tx: {
276
+ to: "0x123",
277
+ data: "0x456",
278
+ value: "1",
279
+ chainId: 1,
280
+ },
281
+ description: "Redeem from vault",
282
+ },
283
+ ],
284
+ }));
285
+ const args = {
286
+ vaultAddress: "0x123",
287
+ assetAddress: "0x456",
288
+ network: "mainnet",
289
+ amount: 1,
290
+ };
291
+ const response = await provider.redeem(mockWalletProvider, args);
292
+ expect(response).toBe("Redeem successful");
293
+ expect(mockWalletProvider.sendTransaction).toHaveBeenCalledWith({
294
+ to: "0x123",
295
+ data: "0x456",
296
+ value: 1n,
297
+ chainId: 1,
298
+ });
299
+ expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalledWith(MOCK_TX_HASH);
300
+ });
301
+ it("should return an error if the API request fails", async () => {
302
+ mockedFetch.mockResolvedValue(mockFetchResult(500, { error: "Internal Server Error", message: "some more info" }));
303
+ const args = {
304
+ vaultAddress: "0x123",
305
+ assetAddress: "0x456",
306
+ network: "mainnet",
307
+ amount: 1,
308
+ };
309
+ expect(await provider.redeem(mockWalletProvider, args)).toBe("Failed to fetch redeem transactions: Internal Server Error, some more info");
310
+ });
311
+ });
312
+ describe("claim rewards action", () => {
313
+ it("should execute claim rewards", async () => {
314
+ mockedFetch.mockResolvedValue(mockFetchResult(200, {
315
+ currentActionIndex: 0,
316
+ actions: [
317
+ {
318
+ tx: {
319
+ to: "0x123",
320
+ data: "0x456",
321
+ value: "1",
322
+ chainId: 1,
323
+ },
324
+ description: "Claim rewards from vault",
325
+ },
326
+ ],
327
+ }));
328
+ const args = {
329
+ vaultAddress: "0x123",
330
+ assetAddress: "0x456",
331
+ network: "mainnet",
332
+ amount: 1,
333
+ };
334
+ const response = await provider.claim(mockWalletProvider, args);
335
+ expect(response).toBe("Claim successful");
336
+ expect(mockWalletProvider.sendTransaction).toHaveBeenCalledWith({
337
+ to: "0x123",
338
+ data: "0x456",
339
+ value: 1n,
340
+ chainId: 1,
341
+ });
342
+ expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalledWith(MOCK_TX_HASH);
343
+ });
344
+ it("should return an error if the API request fails", async () => {
345
+ mockedFetch.mockResolvedValue(mockFetchResult(500, { error: "Internal Server Error", message: "some more info" }));
346
+ const args = {
347
+ vaultAddress: "0x123",
348
+ assetAddress: "0x456",
349
+ network: "mainnet",
350
+ amount: 1,
351
+ };
352
+ expect(await provider.claim(mockWalletProvider, args)).toBe("Failed to fetch claim transactions: Internal Server Error, some more info");
353
+ });
354
+ });
355
+ describe("wallet balances action", () => {
356
+ it("should strip and transform balances correctly", async () => {
357
+ mockedFetch.mockResolvedValue(mockFetchResult(200, {
358
+ mainnet: [
359
+ {
360
+ address: "0x123",
361
+ name: "token-1",
362
+ symbol: "T1",
363
+ balance: (10 ** 18).toString(),
364
+ decimals: 18,
365
+ somethingElse: "should be stripped",
366
+ },
367
+ ],
368
+ }));
369
+ const response = await provider.balances(mockWalletProvider);
370
+ expect(JSON.parse(response)).toStrictEqual({
371
+ mainnet: [
372
+ {
373
+ address: "0x123",
374
+ name: "token-1",
375
+ symbol: "T1",
376
+ balance: 1,
377
+ },
378
+ ],
379
+ });
380
+ });
381
+ it("should return an error if the API request fails", async () => {
382
+ mockedFetch.mockResolvedValue(mockFetchResult(500, { error: "Internal Server Error", message: "some more info" }));
383
+ expect(await provider.balances(mockWalletProvider)).toBe("Failed to fetch wallet balances: Internal Server Error, some more info");
384
+ });
385
+ });
386
+ describe("wallet positions action", () => {
387
+ it("should strip and transform positions correctly", async () => {
388
+ mockedFetch.mockResolvedValue(mockFetchResult(200, {
389
+ mainnet: [
390
+ {
391
+ vaultName: "vault-1",
392
+ vaultAddress: "0x123",
393
+ asset: {
394
+ assetAddress: "0x456",
395
+ name: "token-1",
396
+ symbol: "T1",
397
+ decimals: 18,
398
+ },
399
+ balanceNative: (10 ** 18).toString(),
400
+ balanceLp: (10 ** 18).toString(),
401
+ unclaimedUsd: "100",
402
+ apy: {
403
+ base: 100,
404
+ rewards: 100,
405
+ total: 100,
406
+ },
407
+ },
408
+ ],
409
+ }));
410
+ const response = await provider.positions(mockWalletProvider);
411
+ expect(JSON.parse(response)).toStrictEqual({
412
+ mainnet: [
413
+ {
414
+ name: "vault-1",
415
+ vaultAddress: "0x123",
416
+ asset: {
417
+ address: "0x456",
418
+ name: "token-1",
419
+ symbol: "T1",
420
+ },
421
+ underlyingTokenBalance: 1,
422
+ lpTokenBalance: 1,
423
+ unclaimedRewards: true,
424
+ apy: {
425
+ base: 1,
426
+ rewards: 1,
427
+ total: 1,
428
+ },
429
+ },
430
+ ],
431
+ });
432
+ });
433
+ it("should return an error if the API request fails", async () => {
434
+ mockedFetch.mockResolvedValue(mockFetchResult(500, { error: "Internal Server Error", message: "some more info" }));
435
+ expect(await provider.positions(mockWalletProvider)).toBe("Failed to fetch positions: Internal Server Error, some more info");
436
+ });
437
+ });
438
+ });
@@ -0,0 +1 @@
1
+ export * from "./zeroDevWalletActionProvider";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./zeroDevWalletActionProvider"), exports);
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Input schema for get CAB action.
4
+ */
5
+ export declare const GetCABSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
6
+ type: z.ZodLiteral<"networkFilter">;
7
+ tokenTickers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
8
+ networks: z.ZodArray<z.ZodNumber, "many">;
9
+ }, "strip", z.ZodTypeAny, {
10
+ type: "networkFilter";
11
+ networks: number[];
12
+ tokenTickers?: string[] | undefined;
13
+ }, {
14
+ type: "networkFilter";
15
+ networks: number[];
16
+ tokenTickers?: string[] | undefined;
17
+ }>, z.ZodObject<{
18
+ type: z.ZodLiteral<"networkType">;
19
+ tokenTickers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
20
+ networkType: z.ZodEnum<["mainnet", "testnet"]>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ type: "networkType";
23
+ networkType: "testnet" | "mainnet";
24
+ tokenTickers?: string[] | undefined;
25
+ }, {
26
+ type: "networkType";
27
+ networkType: "testnet" | "mainnet";
28
+ tokenTickers?: string[] | undefined;
29
+ }>]>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetCABSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Input schema for get CAB action.
7
+ */
8
+ exports.GetCABSchema = zod_1.z.discriminatedUnion("type", [
9
+ zod_1.z.object({
10
+ type: zod_1.z.literal("networkFilter"),
11
+ tokenTickers: zod_1.z.array(zod_1.z.string()).optional(),
12
+ networks: zod_1.z.array(zod_1.z.number()).describe("The networks to get the balance for."),
13
+ }),
14
+ zod_1.z.object({
15
+ type: zod_1.z.literal("networkType"),
16
+ tokenTickers: zod_1.z.array(zod_1.z.string()).optional(),
17
+ networkType: zod_1.z
18
+ .enum(["mainnet", "testnet"])
19
+ .describe("The type of network to get the balance for."),
20
+ }),
21
+ ]);
@@ -0,0 +1,32 @@
1
+ import { ZeroDevWalletProvider } from "../../wallet-providers";
2
+ import { ActionProvider } from "../actionProvider";
3
+ import { Network } from "../../network";
4
+ import { GetCABSchema } from "./schemas";
5
+ import { z } from "zod";
6
+ /**
7
+ * ZeroDevWalletActionProvider is an action provider for ZeroDevWalletProvider.
8
+ *
9
+ * This provider is used for any action that requires a ZeroDevWalletProvider.
10
+ */
11
+ export declare class ZeroDevWalletActionProvider extends ActionProvider<ZeroDevWalletProvider> {
12
+ /**
13
+ * Constructs a new ZeroDevWalletActionProvider.
14
+ */
15
+ constructor();
16
+ /**
17
+ * Gets the chain abstracted balance for the wallet.
18
+ *
19
+ * @param walletProvider - The wallet provider to get the balance for.
20
+ * @param args - The arguments for the action.
21
+ * @returns The chain abstracted balance for the wallet.
22
+ */
23
+ getCAB(walletProvider: ZeroDevWalletProvider, args: z.infer<typeof GetCABSchema>): Promise<import("@zerodev/intent").GetCABResult>;
24
+ /**
25
+ * Checks if the ZeroDevWalletActionProvider supports the given network.
26
+ *
27
+ * @param network - The network to check.
28
+ * @returns True if the ZeroDevWalletActionProvider supports the network, false otherwise.
29
+ */
30
+ supportsNetwork: (network: Network) => boolean;
31
+ }
32
+ export declare const zeroDevWalletActionProvider: () => ZeroDevWalletActionProvider;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.zeroDevWalletActionProvider = exports.ZeroDevWalletActionProvider = void 0;
13
+ const wallet_providers_1 = require("../../wallet-providers");
14
+ const actionProvider_1 = require("../actionProvider");
15
+ const actionDecorator_1 = require("../actionDecorator");
16
+ const schemas_1 = require("./schemas");
17
+ const zod_1 = require("zod");
18
+ /**
19
+ * ZeroDevWalletActionProvider is an action provider for ZeroDevWalletProvider.
20
+ *
21
+ * This provider is used for any action that requires a ZeroDevWalletProvider.
22
+ */
23
+ class ZeroDevWalletActionProvider extends actionProvider_1.ActionProvider {
24
+ /**
25
+ * Constructs a new ZeroDevWalletActionProvider.
26
+ */
27
+ constructor() {
28
+ super("zeroDevWallet", []);
29
+ /**
30
+ * Checks if the ZeroDevWalletActionProvider supports the given network.
31
+ *
32
+ * @param network - The network to check.
33
+ * @returns True if the ZeroDevWalletActionProvider supports the network, false otherwise.
34
+ */
35
+ this.supportsNetwork = (network) => network.protocolFamily === "evm";
36
+ }
37
+ /**
38
+ * Gets the chain abstracted balance for the wallet.
39
+ *
40
+ * @param walletProvider - The wallet provider to get the balance for.
41
+ * @param args - The arguments for the action.
42
+ * @returns The chain abstracted balance for the wallet.
43
+ */
44
+ async getCAB(walletProvider, args) {
45
+ return walletProvider.getCAB(args);
46
+ }
47
+ }
48
+ exports.ZeroDevWalletActionProvider = ZeroDevWalletActionProvider;
49
+ __decorate([
50
+ (0, actionDecorator_1.CreateAction)({
51
+ name: "get_cab",
52
+ description: `This tool retrieves the chain abstracted balance (CAB) for specified tokens across multiple networks.
53
+ It takes the following inputs:
54
+ - tokenTickers: An array of token symbols (e.g., ["ETH", "USDC"]) to get balances for
55
+ - networks (optional): An array of network IDs to check balances on. If not provided, will check all supported networks
56
+ - networkType (optional): Filter networks by type ("mainnet" or "testnet"). If not provided, will check both types
57
+
58
+ The tool will return the aggregated balance across all specified networks for each token ticker. This is useful for getting a complete picture of a wallet's holdings across different chains in a single call.`,
59
+ schema: schemas_1.GetCABSchema,
60
+ }),
61
+ __metadata("design:type", Function),
62
+ __metadata("design:paramtypes", [wallet_providers_1.ZeroDevWalletProvider, void 0]),
63
+ __metadata("design:returntype", Promise)
64
+ ], ZeroDevWalletActionProvider.prototype, "getCAB", null);
65
+ const zeroDevWalletActionProvider = () => new ZeroDevWalletActionProvider();
66
+ exports.zeroDevWalletActionProvider = zeroDevWalletActionProvider;