@coinbase/agentkit 0.8.1 → 0.9.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 (79) hide show
  1. package/README.md +382 -230
  2. package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +15 -15
  3. package/dist/action-providers/cdp/cdpApiActionProvider.js +110 -63
  4. package/dist/action-providers/cdp/cdpApiActionProvider.test.js +205 -124
  5. package/dist/action-providers/cdp/index.d.ts +0 -1
  6. package/dist/action-providers/cdp/index.js +0 -1
  7. package/dist/action-providers/cdp/schemas.d.ts +9 -70
  8. package/dist/action-providers/cdp/schemas.js +12 -61
  9. package/dist/action-providers/cdp-legacy/index.d.ts +3 -0
  10. package/dist/action-providers/cdp-legacy/index.js +19 -0
  11. package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.d.ts +45 -0
  12. package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.js +130 -0
  13. package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.test.js +146 -0
  14. package/dist/action-providers/{cdp/cdpWalletActionProvider.d.ts → cdp-legacy/legacyCdpWalletActionProvider.d.ts} +8 -8
  15. package/dist/action-providers/{cdp/cdpWalletActionProvider.js → cdp-legacy/legacyCdpWalletActionProvider.js} +14 -14
  16. package/dist/action-providers/{cdp/cdpWalletActionProvider.test.js → cdp-legacy/legacyCdpWalletActionProvider.test.js} +3 -3
  17. package/dist/action-providers/cdp-legacy/schemas.d.ts +91 -0
  18. package/dist/action-providers/cdp-legacy/schemas.js +77 -0
  19. package/dist/action-providers/erc20/erc20ActionProvider.js +1 -1
  20. package/dist/action-providers/index.d.ts +2 -1
  21. package/dist/action-providers/index.js +2 -1
  22. package/dist/action-providers/jupiter/jupiterActionProvider.test.js +2 -4
  23. package/dist/action-providers/vaultsfyi/api/historicalData.d.ts +31 -0
  24. package/dist/action-providers/vaultsfyi/api/historicalData.js +44 -0
  25. package/dist/action-providers/vaultsfyi/api/vaults.d.ts +38 -10
  26. package/dist/action-providers/vaultsfyi/api/vaults.js +19 -1
  27. package/dist/action-providers/vaultsfyi/schemas.d.ts +38 -3
  28. package/dist/action-providers/vaultsfyi/schemas.js +35 -3
  29. package/dist/action-providers/vaultsfyi/utils.d.ts +64 -0
  30. package/dist/action-providers/vaultsfyi/utils.js +53 -0
  31. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.d.ts +18 -2
  32. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.js +87 -20
  33. package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.test.js +165 -0
  34. package/dist/action-providers/x402/index.d.ts +1 -0
  35. package/dist/action-providers/{cdp-v2 → x402}/index.js +1 -2
  36. package/dist/action-providers/x402/schemas.d.ts +77 -0
  37. package/dist/action-providers/x402/schemas.js +79 -0
  38. package/dist/action-providers/x402/x402ActionProvider.d.ts +55 -0
  39. package/dist/action-providers/x402/x402ActionProvider.js +288 -0
  40. package/dist/action-providers/x402/x402ActionProvider.test.js +322 -0
  41. package/dist/agentkit.d.ts +1 -0
  42. package/dist/agentkit.js +3 -2
  43. package/dist/wallet-providers/{cdpV2EvmWalletProvider.d.ts → cdpEvmWalletProvider.d.ts} +16 -7
  44. package/dist/wallet-providers/{cdpV2EvmWalletProvider.js → cdpEvmWalletProvider.js} +50 -39
  45. package/dist/wallet-providers/{cdpV2EvmWalletProvider.test.js → cdpEvmWalletProvider.test.js} +7 -7
  46. package/dist/wallet-providers/{cdpV2Shared.d.ts → cdpShared.d.ts} +15 -4
  47. package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +115 -0
  48. package/dist/wallet-providers/cdpSmartWalletProvider.js +263 -0
  49. package/dist/wallet-providers/cdpSmartWalletProvider.test.js +287 -0
  50. package/dist/wallet-providers/{cdpV2SolanaWalletProvider.d.ts → cdpSolanaWalletProvider.d.ts} +16 -7
  51. package/dist/wallet-providers/{cdpV2SolanaWalletProvider.js → cdpSolanaWalletProvider.js} +43 -32
  52. package/dist/wallet-providers/cdpSolanaWalletProvider.test.d.ts +1 -0
  53. package/dist/wallet-providers/{cdpV2SolanaWalletProvider.test.js → cdpSolanaWalletProvider.test.js} +7 -7
  54. package/dist/wallet-providers/index.d.ts +6 -6
  55. package/dist/wallet-providers/index.js +6 -6
  56. package/dist/wallet-providers/{smartWalletProvider.d.ts → legacyCdpSmartWalletProvider.d.ts} +3 -3
  57. package/dist/wallet-providers/{smartWalletProvider.js → legacyCdpSmartWalletProvider.js} +21 -21
  58. package/dist/wallet-providers/legacyCdpSmartWalletProvider.test.d.ts +1 -0
  59. package/dist/wallet-providers/{smartWalletProvider.test.js → legacyCdpSmartWalletProvider.test.js} +2 -2
  60. package/dist/wallet-providers/{cdpWalletProvider.d.ts → legacyCdpWalletProvider.d.ts} +15 -11
  61. package/dist/wallet-providers/{cdpWalletProvider.js → legacyCdpWalletProvider.js} +72 -70
  62. package/dist/wallet-providers/legacyCdpWalletProvider.test.d.ts +1 -0
  63. package/dist/wallet-providers/{cdpWalletProvider.test.js → legacyCdpWalletProvider.test.js} +10 -10
  64. package/package.json +8 -5
  65. package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.d.ts +0 -34
  66. package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.js +0 -98
  67. package/dist/action-providers/cdp-v2/index.d.ts +0 -2
  68. package/dist/action-providers/cdp-v2/schemas.d.ts +0 -11
  69. package/dist/action-providers/cdp-v2/schemas.js +0 -13
  70. package/dist/wallet-providers/cdpV2WalletProvider.d.ts +0 -35
  71. package/dist/wallet-providers/cdpV2WalletProvider.js +0 -42
  72. /package/dist/action-providers/{cdp → cdp-legacy}/constants.d.ts +0 -0
  73. /package/dist/action-providers/{cdp → cdp-legacy}/constants.js +0 -0
  74. /package/dist/action-providers/{cdp/cdpWalletActionProvider.test.d.ts → cdp-legacy/legacyCdpApiActionProvider.test.d.ts} +0 -0
  75. /package/dist/{wallet-providers/cdpV2EvmWalletProvider.test.d.ts → action-providers/cdp-legacy/legacyCdpWalletActionProvider.test.d.ts} +0 -0
  76. /package/dist/{wallet-providers/cdpV2SolanaWalletProvider.test.d.ts → action-providers/x402/x402ActionProvider.test.d.ts} +0 -0
  77. /package/dist/wallet-providers/{cdpWalletProvider.test.d.ts → cdpEvmWalletProvider.test.d.ts} +0 -0
  78. /package/dist/wallet-providers/{cdpV2Shared.js → cdpShared.js} +0 -0
  79. /package/dist/wallet-providers/{smartWalletProvider.test.d.ts → cdpSmartWalletProvider.test.d.ts} +0 -0
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.cdpWalletActionProvider = exports.CdpWalletActionProvider = void 0;
12
+ exports.legacyCdpWalletActionProvider = exports.LegacyCdpWalletActionProvider = void 0;
13
13
  const coinbase_sdk_1 = require("@coinbase/coinbase-sdk");
14
14
  const zod_1 = require("zod");
15
15
  const package_json_1 = require("../../../package.json");
@@ -23,14 +23,14 @@ const schemas_1 = require("./schemas");
23
23
  *
24
24
  * This provider is used for any action that requires a CDP Wallet.
25
25
  */
26
- class CdpWalletActionProvider extends actionProvider_1.ActionProvider {
26
+ class LegacyCdpWalletActionProvider extends actionProvider_1.ActionProvider {
27
27
  /**
28
28
  * Constructor for the CdpWalletActionProvider class.
29
29
  *
30
30
  * @param config - The configuration options for the CdpWalletActionProvider.
31
31
  */
32
32
  constructor(config = {}) {
33
- super("cdp_wallet", []);
33
+ super("legacy_cdp_wallet", []);
34
34
  /**
35
35
  * Checks if the Cdp action provider supports the given network.
36
36
  *
@@ -154,7 +154,7 @@ class CdpWalletActionProvider extends actionProvider_1.ActionProvider {
154
154
  }
155
155
  }
156
156
  }
157
- exports.CdpWalletActionProvider = CdpWalletActionProvider;
157
+ exports.LegacyCdpWalletActionProvider = LegacyCdpWalletActionProvider;
158
158
  __decorate([
159
159
  (0, actionDecorator_1.CreateAction)({
160
160
  name: "deploy_contract",
@@ -176,9 +176,9 @@ map where the key is the arg name and the value is the arg value. Encode uint/in
176
176
  schema: schemas_1.DeployContractSchema,
177
177
  }),
178
178
  __metadata("design:type", Function),
179
- __metadata("design:paramtypes", [wallet_providers_1.CdpWalletProvider, void 0]),
179
+ __metadata("design:paramtypes", [wallet_providers_1.LegacyCdpWalletProvider, void 0]),
180
180
  __metadata("design:returntype", Promise)
181
- ], CdpWalletActionProvider.prototype, "deployContract", null);
181
+ ], LegacyCdpWalletActionProvider.prototype, "deployContract", null);
182
182
  __decorate([
183
183
  (0, actionDecorator_1.CreateAction)({
184
184
  name: "deploy_nft",
@@ -187,9 +187,9 @@ __decorate([
187
187
  schema: schemas_1.DeployNftSchema,
188
188
  }),
189
189
  __metadata("design:type", Function),
190
- __metadata("design:paramtypes", [wallet_providers_1.CdpWalletProvider, void 0]),
190
+ __metadata("design:paramtypes", [wallet_providers_1.LegacyCdpWalletProvider, void 0]),
191
191
  __metadata("design:returntype", Promise)
192
- ], CdpWalletActionProvider.prototype, "deployNFT", null);
192
+ ], LegacyCdpWalletActionProvider.prototype, "deployNFT", null);
193
193
  __decorate([
194
194
  (0, actionDecorator_1.CreateAction)({
195
195
  name: "deploy_token",
@@ -198,9 +198,9 @@ The token will be deployed using the wallet's default address as the owner and i
198
198
  schema: schemas_1.DeployTokenSchema,
199
199
  }),
200
200
  __metadata("design:type", Function),
201
- __metadata("design:paramtypes", [wallet_providers_1.CdpWalletProvider, void 0]),
201
+ __metadata("design:paramtypes", [wallet_providers_1.LegacyCdpWalletProvider, void 0]),
202
202
  __metadata("design:returntype", Promise)
203
- ], CdpWalletActionProvider.prototype, "deployToken", null);
203
+ ], LegacyCdpWalletActionProvider.prototype, "deployToken", null);
204
204
  __decorate([
205
205
  (0, actionDecorator_1.CreateAction)({
206
206
  name: "trade",
@@ -217,8 +217,8 @@ Important notes:
217
217
  schema: schemas_1.TradeSchema,
218
218
  }),
219
219
  __metadata("design:type", Function),
220
- __metadata("design:paramtypes", [wallet_providers_1.CdpWalletProvider, void 0]),
220
+ __metadata("design:paramtypes", [wallet_providers_1.LegacyCdpWalletProvider, void 0]),
221
221
  __metadata("design:returntype", Promise)
222
- ], CdpWalletActionProvider.prototype, "trade", null);
223
- const cdpWalletActionProvider = (config = {}) => new CdpWalletActionProvider(config);
224
- exports.cdpWalletActionProvider = cdpWalletActionProvider;
222
+ ], LegacyCdpWalletActionProvider.prototype, "trade", null);
223
+ const legacyCdpWalletActionProvider = (config = {}) => new LegacyCdpWalletActionProvider(config);
224
+ exports.legacyCdpWalletActionProvider = legacyCdpWalletActionProvider;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const cdpWalletActionProvider_1 = require("./cdpWalletActionProvider");
3
+ const legacyCdpWalletActionProvider_1 = require("./legacyCdpWalletActionProvider");
4
4
  const schemas_1 = require("./schemas");
5
5
  // Mock the entire module
6
6
  jest.mock("@coinbase/coinbase-sdk");
@@ -55,7 +55,7 @@ describe("CDP Wallet Action Provider Input Schemas", () => {
55
55
  });
56
56
  });
57
57
  });
58
- describe("CDP Wallet Action Provider", () => {
58
+ describe("Legacy CDP Wallet Action Provider", () => {
59
59
  let actionProvider;
60
60
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
61
  let mockExternalAddressInstance;
@@ -63,7 +63,7 @@ describe("CDP Wallet Action Provider", () => {
63
63
  beforeEach(() => {
64
64
  // Reset all mocks before each test
65
65
  jest.clearAllMocks();
66
- actionProvider = new cdpWalletActionProvider_1.CdpWalletActionProvider();
66
+ actionProvider = new legacyCdpWalletActionProvider_1.LegacyCdpWalletActionProvider();
67
67
  mockExternalAddressInstance = {
68
68
  reputation: jest.fn(),
69
69
  faucet: jest.fn(),
@@ -0,0 +1,91 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Input schema for address reputation check.
4
+ */
5
+ export declare const AddressReputationSchema: z.ZodObject<{
6
+ address: z.ZodString;
7
+ network: z.ZodString;
8
+ }, "strip", z.ZodTypeAny, {
9
+ address: string;
10
+ network: string;
11
+ }, {
12
+ address: string;
13
+ network: string;
14
+ }>;
15
+ /**
16
+ * Input schema for deploy contract action.
17
+ */
18
+ export declare const DeployContractSchema: z.ZodObject<{
19
+ solidityVersion: z.ZodEnum<[string, ...string[]]>;
20
+ solidityInputJson: z.ZodString;
21
+ contractName: z.ZodString;
22
+ constructorArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
23
+ }, "strip", z.ZodTypeAny, {
24
+ solidityVersion: string;
25
+ solidityInputJson: string;
26
+ contractName: string;
27
+ constructorArgs?: Record<string, any> | undefined;
28
+ }, {
29
+ solidityVersion: string;
30
+ solidityInputJson: string;
31
+ contractName: string;
32
+ constructorArgs?: Record<string, any> | undefined;
33
+ }>;
34
+ /**
35
+ * Input schema for deploy NFT action
36
+ */
37
+ export declare const DeployNftSchema: z.ZodObject<{
38
+ name: z.ZodString;
39
+ symbol: z.ZodString;
40
+ baseURI: z.ZodString;
41
+ }, "strip", z.ZodTypeAny, {
42
+ symbol: string;
43
+ name: string;
44
+ baseURI: string;
45
+ }, {
46
+ symbol: string;
47
+ name: string;
48
+ baseURI: string;
49
+ }>;
50
+ /**
51
+ * Input schema for deploy token action.
52
+ */
53
+ export declare const DeployTokenSchema: z.ZodObject<{
54
+ name: z.ZodString;
55
+ symbol: z.ZodString;
56
+ totalSupply: z.ZodType<bigint, z.ZodTypeDef, bigint>;
57
+ }, "strip", z.ZodTypeAny, {
58
+ symbol: string;
59
+ name: string;
60
+ totalSupply: bigint;
61
+ }, {
62
+ symbol: string;
63
+ name: string;
64
+ totalSupply: bigint;
65
+ }>;
66
+ /**
67
+ * Input schema for request faucet funds action.
68
+ */
69
+ export declare const RequestFaucetFundsSchema: z.ZodObject<{
70
+ assetId: z.ZodOptional<z.ZodString>;
71
+ }, "strip", z.ZodTypeAny, {
72
+ assetId?: string | undefined;
73
+ }, {
74
+ assetId?: string | undefined;
75
+ }>;
76
+ /**
77
+ * Input schema for trade action.
78
+ */
79
+ export declare const TradeSchema: z.ZodObject<{
80
+ amount: z.ZodType<bigint, z.ZodTypeDef, bigint>;
81
+ fromAssetId: z.ZodString;
82
+ toAssetId: z.ZodString;
83
+ }, "strip", z.ZodTypeAny, {
84
+ amount: bigint;
85
+ fromAssetId: string;
86
+ toAssetId: string;
87
+ }, {
88
+ amount: bigint;
89
+ fromAssetId: string;
90
+ toAssetId: string;
91
+ }>;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TradeSchema = exports.RequestFaucetFundsSchema = exports.DeployTokenSchema = exports.DeployNftSchema = exports.DeployContractSchema = exports.AddressReputationSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const constants_1 = require("./constants");
6
+ /**
7
+ * Input schema for address reputation check.
8
+ */
9
+ exports.AddressReputationSchema = zod_1.z
10
+ .object({
11
+ address: zod_1.z
12
+ .string()
13
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
14
+ .describe("The Ethereum address to check"),
15
+ network: zod_1.z.string().describe("The network to check the address on"),
16
+ })
17
+ .strip()
18
+ .describe("Input schema for address reputation check");
19
+ /**
20
+ * Input schema for deploy contract action.
21
+ */
22
+ exports.DeployContractSchema = zod_1.z
23
+ .object({
24
+ solidityVersion: zod_1.z
25
+ .enum(Object.keys(constants_1.SolidityVersions))
26
+ .describe("The solidity compiler version"),
27
+ solidityInputJson: zod_1.z.string().describe("The input json for the solidity compiler"),
28
+ contractName: zod_1.z.string().describe("The name of the contract class to be deployed"),
29
+ constructorArgs: zod_1.z
30
+ .record(zod_1.z.string(), zod_1.z.any())
31
+ .describe("The constructor arguments for the contract")
32
+ .optional(),
33
+ })
34
+ .strip()
35
+ .describe("Instructions for deploying an arbitrary contract");
36
+ /**
37
+ * Input schema for deploy NFT action
38
+ */
39
+ exports.DeployNftSchema = zod_1.z
40
+ .object({
41
+ name: zod_1.z.string().describe("The name of the NFT collection"),
42
+ symbol: zod_1.z.string().describe("The symbol of the NFT collection"),
43
+ baseURI: zod_1.z.string().describe("The base URI for the token metadata"),
44
+ })
45
+ .strip()
46
+ .describe("Instructions for deploying an NFT collection");
47
+ /**
48
+ * Input schema for deploy token action.
49
+ */
50
+ exports.DeployTokenSchema = zod_1.z
51
+ .object({
52
+ name: zod_1.z.string().describe("The name of the token"),
53
+ symbol: zod_1.z.string().describe("The token symbol"),
54
+ totalSupply: zod_1.z.custom().describe("The total supply of tokens to mint"),
55
+ })
56
+ .strip()
57
+ .describe("Instructions for deploying a token");
58
+ /**
59
+ * Input schema for request faucet funds action.
60
+ */
61
+ exports.RequestFaucetFundsSchema = zod_1.z
62
+ .object({
63
+ assetId: zod_1.z.string().optional().describe("The optional asset ID to request from faucet"),
64
+ })
65
+ .strip()
66
+ .describe("Instructions for requesting faucet funds");
67
+ /**
68
+ * Input schema for trade action.
69
+ */
70
+ exports.TradeSchema = zod_1.z
71
+ .object({
72
+ amount: zod_1.z.custom().describe("The amount of the from asset to trade"),
73
+ fromAssetId: zod_1.z.string().describe("The from asset ID to trade"),
74
+ toAssetId: zod_1.z.string().describe("The to asset ID to receive from the trade"),
75
+ })
76
+ .strip()
77
+ .describe("Instructions for trading assets");
@@ -78,7 +78,7 @@ class ERC20ActionProvider extends actionProvider_1.ActionProvider {
78
78
  ((network.networkId === "base-mainnet" && constants_1.BaseTokenToAssetId.has(tokenAddress)) ||
79
79
  (network.networkId === "base-sepolia" && constants_1.BaseSepoliaTokenToAssetId.has(tokenAddress)));
80
80
  if (canDoGasless) {
81
- // Cast to CdpWalletProvider to access erc20Transfer
81
+ // Cast to LegacyCdpWalletProvider to access erc20Transfer
82
82
  const cdpWallet = walletProvider;
83
83
  const assetId = network.networkId === "base-mainnet"
84
84
  ? constants_1.BaseTokenToAssetId.get(tokenAddress)
@@ -4,8 +4,8 @@ export * from "./customActionProvider";
4
4
  export * from "./across";
5
5
  export * from "./alchemy";
6
6
  export * from "./basename";
7
+ export * from "./cdp-legacy";
7
8
  export * from "./cdp";
8
- export * from "./cdp-v2";
9
9
  export * from "./compound";
10
10
  export * from "./defillama";
11
11
  export * from "./erc20";
@@ -26,4 +26,5 @@ export * from "./allora";
26
26
  export * from "./flaunch";
27
27
  export * from "./onramp";
28
28
  export * from "./vaultsfyi";
29
+ export * from "./x402";
29
30
  export * from "./zerodev";
@@ -20,8 +20,8 @@ __exportStar(require("./customActionProvider"), exports);
20
20
  __exportStar(require("./across"), exports);
21
21
  __exportStar(require("./alchemy"), exports);
22
22
  __exportStar(require("./basename"), exports);
23
+ __exportStar(require("./cdp-legacy"), exports);
23
24
  __exportStar(require("./cdp"), exports);
24
- __exportStar(require("./cdp-v2"), exports);
25
25
  __exportStar(require("./compound"), exports);
26
26
  __exportStar(require("./defillama"), exports);
27
27
  __exportStar(require("./erc20"), exports);
@@ -42,4 +42,5 @@ __exportStar(require("./allora"), exports);
42
42
  __exportStar(require("./flaunch"), exports);
43
43
  __exportStar(require("./onramp"), exports);
44
44
  __exportStar(require("./vaultsfyi"), exports);
45
+ __exportStar(require("./x402"), exports);
45
46
  __exportStar(require("./zerodev"), exports);
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const web3_js_1 = require("@solana/web3.js");
4
4
  const jupiterActionProvider_1 = require("./jupiterActionProvider");
5
5
  const api_1 = require("@jup-ag/api");
6
- // Default SPL token decimals for tests
7
- const DECIMALS = 6;
8
6
  // Mock the @solana/web3.js module
9
7
  jest.mock("@solana/web3.js", () => ({
10
8
  // Preserve the actual implementation of @solana/web3.js while overriding specific methods
@@ -28,7 +26,7 @@ jest.mock("@solana/spl-token", () => ({
28
26
  // Preserve the actual implementation of @solana/spl-token while overriding specific methods
29
27
  ...jest.requireActual("@solana/spl-token"),
30
28
  // Mock getMint to always return a fixed decimal value for tokens
31
- getMint: jest.fn().mockReturnValue({ decimals: DECIMALS }),
29
+ getMint: jest.fn().mockReturnValue({ decimals: 6 }),
32
30
  }));
33
31
  // Mock the @jup-ag/api module
34
32
  jest.mock("@jup-ag/api", () => ({
@@ -107,7 +105,7 @@ describe("JupiterActionProvider", () => {
107
105
  expect(mockQuoteGet).toHaveBeenCalledWith({
108
106
  inputMint: INPUT_MINT,
109
107
  outputMint: OUTPUT_MINT,
110
- amount: swapArgs.amount * 10 ** DECIMALS, // Ensure correct decimal conversion
108
+ amount: swapArgs.amount * 10 ** 6, // Ensure correct decimal conversion
111
109
  slippageBps: swapArgs.slippageBps,
112
110
  });
113
111
  expect(mockSwapPost).toHaveBeenCalled();
@@ -0,0 +1,31 @@
1
+ import z from "zod";
2
+ import { VaultHistoricalDataActionSchema } from "../schemas";
3
+ import { ApiError } from "./types";
4
+ type ApyData = {
5
+ timestamp: number;
6
+ blockNumber: number;
7
+ apy: {
8
+ base: number;
9
+ rewards: number;
10
+ total: number;
11
+ };
12
+ };
13
+ type TvlData = {
14
+ timestamp: number;
15
+ blockNumber: number;
16
+ tvlDetails: {
17
+ tvlUsd: number;
18
+ };
19
+ };
20
+ /**
21
+ * Fetch historical data for a vault
22
+ *
23
+ * @param args - The arguments for the action
24
+ * @param apiKey - The API key to use for the request
25
+ * @returns The historical data for the vault
26
+ */
27
+ export declare function fetchVaultHistoricalData(args: z.infer<typeof VaultHistoricalDataActionSchema>, apiKey: string): Promise<ApiError | {
28
+ apy: ApyData;
29
+ tvl: TvlData;
30
+ }>;
31
+ export {};
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchVaultHistoricalData = fetchVaultHistoricalData;
4
+ const constants_1 = require("../constants");
5
+ const utils_1 = require("../utils");
6
+ /**
7
+ * Fetch historical data for a vault
8
+ *
9
+ * @param args - The arguments for the action
10
+ * @param apiKey - The API key to use for the request
11
+ * @returns The historical data for the vault
12
+ */
13
+ async function fetchVaultHistoricalData(args, apiKey) {
14
+ const params = (0, utils_1.createSearchParams)({
15
+ interval: args.apyRange ?? "7day",
16
+ });
17
+ const timestamp = new Date(args.date).getTime() / 1000;
18
+ const [tvlResponse, apyResponse] = await Promise.all([
19
+ fetch(`${constants_1.VAULTS_API_URL}/vaults/${args.network}/${args.vaultAddress}/historical-tvl/${timestamp}?${params}`, {
20
+ method: "GET",
21
+ headers: {
22
+ "x-api-key": apiKey,
23
+ },
24
+ }),
25
+ fetch(`${constants_1.VAULTS_API_URL}/vaults/${args.network}/${args.vaultAddress}/historical-apy/${timestamp}?${params}`, {
26
+ method: "GET",
27
+ headers: {
28
+ "x-api-key": apiKey,
29
+ },
30
+ }),
31
+ ]);
32
+ const [apy, tvl] = await Promise.all([
33
+ apyResponse.json(),
34
+ tvlResponse.json(),
35
+ ]);
36
+ if ("error" in apy)
37
+ return apy;
38
+ if ("error" in tvl)
39
+ return tvl;
40
+ return {
41
+ apy,
42
+ tvl,
43
+ };
44
+ }
@@ -1,11 +1,17 @@
1
1
  import z from "zod";
2
- import { VaultsActionSchema } from "../schemas";
2
+ import { VaultDetailsActionSchema, VaultsActionSchema } from "../schemas";
3
3
  import { ApiError } from "./types";
4
+ type ApyData = {
5
+ "1day": number;
6
+ "7day": number;
7
+ "30day": number;
8
+ };
4
9
  export type ApiVault = {
5
10
  name: string;
6
11
  address: string;
7
12
  network: string;
8
13
  protocol: string;
14
+ isTransactional: boolean;
9
15
  tvlDetails: {
10
16
  tvlUsd: string;
11
17
  };
@@ -16,17 +22,30 @@ export type ApiVault = {
16
22
  decimals: number;
17
23
  };
18
24
  apy: {
19
- base: {
20
- "7day": number;
21
- };
22
- rewards: {
23
- "7day": number;
24
- };
25
- total: {
26
- "7day": number;
25
+ base: ApyData;
26
+ rewards: ApyData;
27
+ total: ApyData;
28
+ };
29
+ numberOfHolders: number;
30
+ rewards: {
31
+ apy: ApyData;
32
+ asset: {
33
+ name: string;
34
+ symbol: string;
35
+ assetAddress: string;
36
+ decimals: number;
27
37
  };
38
+ }[];
39
+ description: string;
40
+ additionalIncentives: string;
41
+ score: {
42
+ vaultScore: number;
43
+ vaultTvlScore: number;
44
+ protocolTvlScore: number;
45
+ holderScore: number;
46
+ networkScore: number;
47
+ assetScore: number;
28
48
  };
29
- isTransactional: boolean;
30
49
  };
31
50
  /**
32
51
  * Fetches a list of vaults from the vaultsfyi API.
@@ -36,3 +55,12 @@ export type ApiVault = {
36
55
  * @returns The list of vaults
37
56
  */
38
57
  export declare function fetchVaults(args: z.infer<typeof VaultsActionSchema>, apiKey: string): Promise<ApiVault[] | ApiError>;
58
+ /**
59
+ * Fetches the details of a specific vault from the vaultsfyi API.
60
+ *
61
+ * @param args - The action parameters
62
+ * @param apiKey - The vaultsfyi API key
63
+ * @returns The vault details
64
+ */
65
+ export declare function fetchVault(args: z.infer<typeof VaultDetailsActionSchema>, apiKey: string): Promise<ApiError | ApiVault>;
66
+ export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchVaults = fetchVaults;
4
+ exports.fetchVault = fetchVault;
4
5
  const utils_1 = require("../utils");
5
6
  const constants_1 = require("../constants");
6
7
  /**
@@ -17,7 +18,7 @@ async function fetchVaults(args, apiKey) {
17
18
  token: args.token,
18
19
  network: args.network,
19
20
  tvl_min: args.minTvl ?? 100000,
20
- transactional_only: true,
21
+ transactionalOnly: true,
21
22
  });
22
23
  for (let i = 0; i < 10; i++) {
23
24
  const response = await fetch(`${constants_1.VAULTS_API_URL}/detailed/vaults?${params}`, {
@@ -37,3 +38,20 @@ async function fetchVaults(args, apiKey) {
37
38
  }
38
39
  return vaults;
39
40
  }
41
+ /**
42
+ * Fetches the details of a specific vault from the vaultsfyi API.
43
+ *
44
+ * @param args - The action parameters
45
+ * @param apiKey - The vaultsfyi API key
46
+ * @returns The vault details
47
+ */
48
+ async function fetchVault(args, apiKey) {
49
+ const response = await fetch(`${constants_1.VAULTS_API_URL}/vaults/${args.network}/${args.vaultAddress}`, {
50
+ method: "GET",
51
+ headers: {
52
+ "x-api-key": apiKey,
53
+ },
54
+ });
55
+ const data = (await response.json());
56
+ return data;
57
+ }
@@ -3,9 +3,9 @@ import { z } from "zod";
3
3
  * Vaults list action schema.
4
4
  */
5
5
  export declare const VaultsActionSchema: z.ZodObject<{
6
- token: z.ZodOptional<z.ZodString>;
7
- protocol: z.ZodOptional<z.ZodString>;
8
- network: z.ZodOptional<z.ZodEnum<[string, ...string[]]>>;
6
+ token: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
7
+ protocol: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
8
+ network: z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodEnum<[string, ...string[]]>, z.ZodEnum<["", "all"]>]>>, string | undefined, string | undefined>;
9
9
  minTvl: z.ZodOptional<z.ZodNumber>;
10
10
  sort: z.ZodOptional<z.ZodObject<{
11
11
  field: z.ZodOptional<z.ZodEnum<["tvl", "apy", "name"]>>;
@@ -17,6 +17,7 @@ export declare const VaultsActionSchema: z.ZodObject<{
17
17
  field?: "name" | "tvl" | "apy" | undefined;
18
18
  direction?: "asc" | "desc" | undefined;
19
19
  }>>;
20
+ apyRange: z.ZodOptional<z.ZodEnum<["1day", "7day", "30day"]>>;
20
21
  take: z.ZodOptional<z.ZodNumber>;
21
22
  page: z.ZodOptional<z.ZodNumber>;
22
23
  }, "strip", z.ZodTypeAny, {
@@ -28,6 +29,7 @@ export declare const VaultsActionSchema: z.ZodObject<{
28
29
  token?: string | undefined;
29
30
  protocol?: string | undefined;
30
31
  minTvl?: number | undefined;
32
+ apyRange?: "1day" | "7day" | "30day" | undefined;
31
33
  take?: number | undefined;
32
34
  page?: number | undefined;
33
35
  }, {
@@ -39,9 +41,42 @@ export declare const VaultsActionSchema: z.ZodObject<{
39
41
  token?: string | undefined;
40
42
  protocol?: string | undefined;
41
43
  minTvl?: number | undefined;
44
+ apyRange?: "1day" | "7day" | "30day" | undefined;
42
45
  take?: number | undefined;
43
46
  page?: number | undefined;
44
47
  }>;
48
+ /**
49
+ * Vault details action schema.
50
+ */
51
+ export declare const VaultDetailsActionSchema: z.ZodObject<{
52
+ vaultAddress: z.ZodString;
53
+ network: z.ZodEnum<[string, ...string[]]>;
54
+ apyRange: z.ZodOptional<z.ZodEnum<["1day", "7day", "30day"]>>;
55
+ }, "strip", z.ZodTypeAny, {
56
+ network: string;
57
+ vaultAddress: string;
58
+ apyRange?: "1day" | "7day" | "30day" | undefined;
59
+ }, {
60
+ network: string;
61
+ vaultAddress: string;
62
+ apyRange?: "1day" | "7day" | "30day" | undefined;
63
+ }>;
64
+ export declare const VaultHistoricalDataActionSchema: z.ZodObject<{
65
+ vaultAddress: z.ZodString;
66
+ network: z.ZodEnum<[string, ...string[]]>;
67
+ date: z.ZodString;
68
+ apyRange: z.ZodOptional<z.ZodEnum<["1day", "7day", "30day"]>>;
69
+ }, "strip", z.ZodTypeAny, {
70
+ network: string;
71
+ date: string;
72
+ vaultAddress: string;
73
+ apyRange?: "1day" | "7day" | "30day" | undefined;
74
+ }, {
75
+ network: string;
76
+ date: string;
77
+ vaultAddress: string;
78
+ apyRange?: "1day" | "7day" | "30day" | undefined;
79
+ }>;
45
80
  export declare const depositActionSchema: z.ZodObject<{
46
81
  vaultAddress: z.ZodString;
47
82
  assetAddress: z.ZodString;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.claimActionSchema = exports.redeemActionSchema = exports.depositActionSchema = exports.VaultsActionSchema = void 0;
3
+ exports.claimActionSchema = exports.redeemActionSchema = exports.depositActionSchema = exports.VaultHistoricalDataActionSchema = exports.VaultDetailsActionSchema = exports.VaultsActionSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const constants_1 = require("./constants");
6
6
  /**
@@ -16,10 +16,18 @@ const NetworkSchema = zod_1.z.enum(Object.values(constants_1.VAULTSFYI_SUPPORTED
16
16
  exports.VaultsActionSchema = zod_1.z.object({
17
17
  token: zod_1.z
18
18
  .string()
19
+ .transform(val => (val === "" ? undefined : val))
19
20
  .optional()
20
21
  .describe("Optional: Name or symbol of the token to filter vaults by"),
21
- protocol: zod_1.z.string().optional().describe("Optional: Protocol to filter vaults by"),
22
- network: NetworkSchema.optional().describe("Optional: Network name to filter vaults by. Supported networks: mainnet, arbitrum, optimism, polygon, base, gnosis, unichain"),
22
+ protocol: zod_1.z
23
+ .string()
24
+ .transform(val => (val === "" ? undefined : val))
25
+ .optional()
26
+ .describe("Optional: Protocol to filter vaults by"),
27
+ network: NetworkSchema.or(zod_1.z.enum(["", "all"]))
28
+ .optional()
29
+ .transform(val => (val === "" || val === "all" ? undefined : val))
30
+ .describe("Optional: Network name to filter vaults by. Supported networks: mainnet, arbitrum, optimism, polygon, base, gnosis, unichain"),
23
31
  minTvl: zod_1.z.number().optional().describe("Optional: Minimum TVL to filter vaults by"),
24
32
  sort: zod_1.z
25
33
  .object({
@@ -28,9 +36,33 @@ exports.VaultsActionSchema = zod_1.z.object({
28
36
  })
29
37
  .optional()
30
38
  .describe("Sort options"),
39
+ apyRange: zod_1.z
40
+ .enum(["1day", "7day", "30day"])
41
+ .optional()
42
+ .describe("Optional: APY moving average range (default: 7day)"),
31
43
  take: zod_1.z.number().optional().describe("Optional: Limit the number of results"),
32
44
  page: zod_1.z.number().optional().describe("Optional: Page number"),
33
45
  });
46
+ /**
47
+ * Vault details action schema.
48
+ */
49
+ exports.VaultDetailsActionSchema = zod_1.z.object({
50
+ vaultAddress: zod_1.z.string().describe("The address of the vault to fetch details for"),
51
+ network: NetworkSchema.describe("The network of the vault"),
52
+ apyRange: zod_1.z
53
+ .enum(["1day", "7day", "30day"])
54
+ .optional()
55
+ .describe("Optional: APY moving average range (default: 7day)"),
56
+ });
57
+ exports.VaultHistoricalDataActionSchema = zod_1.z.object({
58
+ vaultAddress: zod_1.z.string().describe("The address of the vault to fetch historical data for"),
59
+ network: NetworkSchema.describe("The network of the vault"),
60
+ date: zod_1.z.string().datetime().describe("The date to fetch historical data for"),
61
+ apyRange: zod_1.z
62
+ .enum(["1day", "7day", "30day"])
63
+ .optional()
64
+ .describe("Optional: APY moving average range (default: 7day)"),
65
+ });
34
66
  /**
35
67
  * Base transaction params schema.
36
68
  */