@coinbase/agentkit 0.0.0-nightly-20250430210501 → 0.0.0-nightly-20250611210407
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 +20 -20
- package/dist/action-providers/cdp/cdpApiActionProvider.js +3 -3
- package/dist/action-providers/cdp/cdpWalletActionProvider.js +3 -3
- package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.d.ts +2 -5
- package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.js +27 -20
- package/dist/action-providers/vaultsfyi/api/historicalData.d.ts +31 -0
- package/dist/action-providers/vaultsfyi/api/historicalData.js +44 -0
- package/dist/action-providers/vaultsfyi/api/vaults.d.ts +38 -10
- package/dist/action-providers/vaultsfyi/api/vaults.js +19 -1
- package/dist/action-providers/vaultsfyi/schemas.d.ts +38 -3
- package/dist/action-providers/vaultsfyi/schemas.js +35 -3
- package/dist/action-providers/vaultsfyi/utils.d.ts +64 -0
- package/dist/action-providers/vaultsfyi/utils.js +53 -0
- package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.d.ts +18 -2
- package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.js +87 -20
- package/dist/action-providers/vaultsfyi/vaultsfyiActionProvider.test.js +165 -0
- package/dist/agentkit.d.ts +2 -2
- package/dist/agentkit.js +4 -4
- package/dist/wallet-providers/cdpV2EvmWalletProvider.js +21 -1
- package/dist/wallet-providers/cdpV2Shared.d.ts +7 -0
- package/dist/wallet-providers/cdpV2Shared.js +13 -0
- package/dist/wallet-providers/cdpWalletProvider.d.ts +2 -2
- package/dist/wallet-providers/cdpWalletProvider.js +3 -3
- package/dist/wallet-providers/cdpWalletProvider.test.js +6 -6
- package/dist/wallet-providers/smartWalletProvider.d.ts +4 -4
- package/dist/wallet-providers/smartWalletProvider.js +7 -7
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -65,8 +65,8 @@ npm install @coinbase/agentkit
|
|
|
65
65
|
|
|
66
66
|
```typescript
|
|
67
67
|
const agentKit = await AgentKit.from({
|
|
68
|
-
|
|
69
|
-
cdpApiKeyPrivate: "CDP API KEY
|
|
68
|
+
cdpApiKeyId: "CDP API KEY NAME",
|
|
69
|
+
cdpApiKeyPrivate: "CDP API KEY SECRET",
|
|
70
70
|
});
|
|
71
71
|
```
|
|
72
72
|
|
|
@@ -76,8 +76,8 @@ If no wallet or action provider are specified, the agent will use the `CdpWallet
|
|
|
76
76
|
|
|
77
77
|
```typescript
|
|
78
78
|
const agentKit = await AgentKit.from({
|
|
79
|
-
|
|
80
|
-
cdpApiKeyPrivate: "CDP API KEY
|
|
79
|
+
cdpApiKeyId: "CDP API KEY NAME",
|
|
80
|
+
cdpApiKeyPrivate: "CDP API KEY SECRET",
|
|
81
81
|
});
|
|
82
82
|
```
|
|
83
83
|
|
|
@@ -87,8 +87,8 @@ const agentKit = await AgentKit.from({
|
|
|
87
87
|
import { CdpWalletProvider } from "@coinbase/agentkit";
|
|
88
88
|
|
|
89
89
|
const walletProvider = await CdpWalletProvider.configureWithWallet({
|
|
90
|
-
|
|
91
|
-
apiKeyPrivate: "CDP API KEY
|
|
90
|
+
apiKeyId: "CDP API KEY NAME",
|
|
91
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
92
92
|
networkId: "base-mainnet",
|
|
93
93
|
});
|
|
94
94
|
|
|
@@ -106,8 +106,8 @@ const agentKit = await AgentKit.from({
|
|
|
106
106
|
walletProvider,
|
|
107
107
|
actionProviders: [
|
|
108
108
|
cdpApiActionProvider({
|
|
109
|
-
|
|
110
|
-
apiKeyPrivate: "CDP API KEY
|
|
109
|
+
apiKeyId: "CDP API KEY NAME",
|
|
110
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
111
111
|
}),
|
|
112
112
|
pythActionProvider(),
|
|
113
113
|
],
|
|
@@ -528,8 +528,8 @@ This gives your agent access to the actions defined in the action provider.
|
|
|
528
528
|
|
|
529
529
|
```typescript
|
|
530
530
|
const agentKit = new AgentKit({
|
|
531
|
-
|
|
532
|
-
cdpApiKeyPrivate: "CDP API KEY
|
|
531
|
+
cdpApiKeyId: "CDP API KEY NAME",
|
|
532
|
+
cdpApiKeyPrivate: "CDP API KEY SECRET",
|
|
533
533
|
actionProviders: [myActionProvider()],
|
|
534
534
|
});
|
|
535
535
|
```
|
|
@@ -621,8 +621,8 @@ The `CdpWalletProvider` can be configured to use a specific network by passing t
|
|
|
621
621
|
import { CdpWalletProvider } from "@coinbase/agentkit";
|
|
622
622
|
|
|
623
623
|
const walletProvider = await CdpWalletProvider.configureWithWallet({
|
|
624
|
-
|
|
625
|
-
apiKeyPrivate: "CDP API KEY
|
|
624
|
+
apiKeyId: "CDP API KEY NAME",
|
|
625
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
626
626
|
networkId: "base-mainnet",
|
|
627
627
|
});
|
|
628
628
|
```
|
|
@@ -636,8 +636,8 @@ import { CdpWalletProvider } from "@coinbase/agentkit";
|
|
|
636
636
|
import { Wallet } from "@coinbase/coinbase-sdk";
|
|
637
637
|
const walletProvider = await CdpWalletProvider.configureWithWallet({
|
|
638
638
|
wallet,
|
|
639
|
-
|
|
640
|
-
apiKeyPrivate: "CDP API KEY
|
|
639
|
+
apiKeyId: "CDP API KEY NAME",
|
|
640
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
641
641
|
});
|
|
642
642
|
```
|
|
643
643
|
|
|
@@ -678,8 +678,8 @@ import { CdpWalletProvider } from "@coinbase/agentkit";
|
|
|
678
678
|
|
|
679
679
|
const walletProvider = await CdpWalletProvider.configureWithWallet({
|
|
680
680
|
cdpWalletData: "WALLET DATA JSON STRING",
|
|
681
|
-
|
|
682
|
-
apiKeyPrivate: "CDP API KEY
|
|
681
|
+
apiKeyId: "CDP API KEY NAME",
|
|
682
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
683
683
|
});
|
|
684
684
|
```
|
|
685
685
|
|
|
@@ -692,8 +692,8 @@ import { CdpWalletProvider } from "@coinbase/agentkit";
|
|
|
692
692
|
|
|
693
693
|
const walletProvider = await CdpWalletProvider.configureWithWallet({
|
|
694
694
|
cdpWalletData: "WALLET DATA JSON STRING",
|
|
695
|
-
|
|
696
|
-
apiKeyPrivate: "CDP API KEY
|
|
695
|
+
apiKeyId: "CDP API KEY NAME",
|
|
696
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
697
697
|
gas: {
|
|
698
698
|
gasLimitMultiplier: 2.0, // Adjusts gas limit estimation
|
|
699
699
|
feePerGasMultiplier: 2.0, // Adjusts max fee per gas
|
|
@@ -879,8 +879,8 @@ import { ZeroDevWalletProvider, CdpWalletProvider } from "@coinbase/agentkit";
|
|
|
879
879
|
|
|
880
880
|
// First create a CDP wallet provider as the signer
|
|
881
881
|
const cdpWalletProvider = await CdpWalletProvider.configureWithWallet({
|
|
882
|
-
|
|
883
|
-
apiKeyPrivate: "CDP API KEY
|
|
882
|
+
apiKeyId: "CDP API KEY NAME",
|
|
883
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
884
884
|
networkId: "base-mainnet",
|
|
885
885
|
});
|
|
886
886
|
|
|
@@ -39,10 +39,10 @@ class CdpApiActionProvider extends actionProvider_1.ActionProvider {
|
|
|
39
39
|
* @returns True if the Cdp action provider supports the network, false otherwise.
|
|
40
40
|
*/
|
|
41
41
|
this.supportsNetwork = (_) => true;
|
|
42
|
-
if (config.
|
|
42
|
+
if (config.apiKeyId && config.apiKeySecret) {
|
|
43
43
|
coinbase_sdk_1.Coinbase.configure({
|
|
44
|
-
apiKeyName: config.
|
|
45
|
-
privateKey: config.
|
|
44
|
+
apiKeyName: config.apiKeyId,
|
|
45
|
+
privateKey: config.apiKeySecret?.replace(/\\n/g, "\n"),
|
|
46
46
|
source: "agentkit",
|
|
47
47
|
sourceVersion: package_json_1.version,
|
|
48
48
|
});
|
|
@@ -38,10 +38,10 @@ class CdpWalletActionProvider extends actionProvider_1.ActionProvider {
|
|
|
38
38
|
* @returns True if the Cdp action provider supports the network, false otherwise.
|
|
39
39
|
*/
|
|
40
40
|
this.supportsNetwork = (network) => network.protocolFamily === "evm";
|
|
41
|
-
if (config.
|
|
41
|
+
if (config.apiKeyId && config.apiKeySecret) {
|
|
42
42
|
coinbase_sdk_1.Coinbase.configure({
|
|
43
|
-
apiKeyName: config.
|
|
44
|
-
privateKey: config.
|
|
43
|
+
apiKeyName: config.apiKeyId,
|
|
44
|
+
privateKey: config.apiKeySecret?.replace(/\\n/g, "\n"),
|
|
45
45
|
source: "agentkit",
|
|
46
46
|
sourceVersion: package_json_1.version,
|
|
47
47
|
});
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { Network } from "../../network";
|
|
3
3
|
import { WalletProvider } from "../../wallet-providers";
|
|
4
|
-
import { WalletProviderWithClient } from "../../wallet-providers/cdpV2Shared";
|
|
5
4
|
import { ActionProvider } from "../actionProvider";
|
|
6
5
|
import { RequestFaucetFundsV2Schema } from "./schemas";
|
|
7
|
-
type CdpV2WalletProviderWithClient = WalletProvider & WalletProviderWithClient;
|
|
8
6
|
/**
|
|
9
7
|
* CdpApiActionProvider is an action provider for CDP API.
|
|
10
8
|
*
|
|
11
9
|
* This provider is used for any action that uses the CDP API, but does not require a CDP Wallet.
|
|
12
10
|
*/
|
|
13
|
-
export declare class CdpApiV2ActionProvider extends ActionProvider<
|
|
11
|
+
export declare class CdpApiV2ActionProvider extends ActionProvider<WalletProvider> {
|
|
14
12
|
/**
|
|
15
13
|
* Constructor for the CdpApiActionProvider class.
|
|
16
14
|
*/
|
|
@@ -22,7 +20,7 @@ export declare class CdpApiV2ActionProvider extends ActionProvider<CdpV2WalletPr
|
|
|
22
20
|
* @param args - The input arguments for the action.
|
|
23
21
|
* @returns A confirmation message with transaction details.
|
|
24
22
|
*/
|
|
25
|
-
faucet(walletProvider:
|
|
23
|
+
faucet(walletProvider: WalletProvider, args: z.infer<typeof RequestFaucetFundsV2Schema>): Promise<string>;
|
|
26
24
|
/**
|
|
27
25
|
* Checks if the Cdp action provider supports the given network.
|
|
28
26
|
*
|
|
@@ -34,4 +32,3 @@ export declare class CdpApiV2ActionProvider extends ActionProvider<CdpV2WalletPr
|
|
|
34
32
|
supportsNetwork: (_: Network) => boolean;
|
|
35
33
|
}
|
|
36
34
|
export declare const cdpApiV2ActionProvider: () => CdpApiV2ActionProvider;
|
|
37
|
-
export {};
|
|
@@ -11,6 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.cdpApiV2ActionProvider = exports.CdpApiV2ActionProvider = void 0;
|
|
13
13
|
const zod_1 = require("zod");
|
|
14
|
+
const wallet_providers_1 = require("../../wallet-providers");
|
|
15
|
+
const cdpV2Shared_1 = require("../../wallet-providers/cdpV2Shared");
|
|
14
16
|
const actionDecorator_1 = require("../actionDecorator");
|
|
15
17
|
const actionProvider_1 = require("../actionProvider");
|
|
16
18
|
const schemas_1 = require("./schemas");
|
|
@@ -45,29 +47,34 @@ class CdpApiV2ActionProvider extends actionProvider_1.ActionProvider {
|
|
|
45
47
|
async faucet(walletProvider, args) {
|
|
46
48
|
const network = walletProvider.getNetwork();
|
|
47
49
|
const networkId = network.networkId;
|
|
48
|
-
if (
|
|
49
|
-
if (
|
|
50
|
-
|
|
50
|
+
if ((0, cdpV2Shared_1.isWalletProviderWithClient)(walletProvider)) {
|
|
51
|
+
if (network.protocolFamily === "evm") {
|
|
52
|
+
if (networkId !== "base-sepolia" && networkId !== "ethereum-sepolia") {
|
|
53
|
+
throw new Error("Faucet is only supported on 'base-sepolia' or 'ethereum-sepolia' evm networks.");
|
|
54
|
+
}
|
|
55
|
+
const faucetTx = await walletProvider.getClient().evm.requestFaucet({
|
|
56
|
+
address: walletProvider.getAddress(),
|
|
57
|
+
token: (args.assetId || "eth"),
|
|
58
|
+
network: networkId,
|
|
59
|
+
});
|
|
60
|
+
return `Received ${args.assetId || "ETH"} from the faucet. Transaction hash: ${faucetTx.transactionHash}`;
|
|
51
61
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
else if (network.protocolFamily === "svm") {
|
|
63
|
+
if (networkId !== "solana-devnet") {
|
|
64
|
+
throw new Error("Faucet is only supported on 'solana-devnet' solana networks.");
|
|
65
|
+
}
|
|
66
|
+
const faucetTx = await walletProvider.getClient().solana.requestFaucet({
|
|
67
|
+
address: walletProvider.getAddress(),
|
|
68
|
+
token: (args.assetId || "sol"),
|
|
69
|
+
});
|
|
70
|
+
return `Received ${args.assetId || "SOL"} from the faucet. Transaction signature hash: ${faucetTx.signature}`;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw new Error("Faucet is only supported on Ethereum and Solana protocol families.");
|
|
62
74
|
}
|
|
63
|
-
const faucetTx = await walletProvider.getClient().solana.requestFaucet({
|
|
64
|
-
address: walletProvider.getAddress(),
|
|
65
|
-
token: (args.assetId || "sol"),
|
|
66
|
-
});
|
|
67
|
-
return `Received ${args.assetId || "SOL"} from the faucet. Transaction signature hash: ${faucetTx.signature}`;
|
|
68
75
|
}
|
|
69
76
|
else {
|
|
70
|
-
throw new Error("
|
|
77
|
+
throw new Error("Wallet provider is not a CDP Wallet Provider.");
|
|
71
78
|
}
|
|
72
79
|
}
|
|
73
80
|
}
|
|
@@ -84,7 +91,7 @@ from another wallet and provide the user with your wallet details.`,
|
|
|
84
91
|
schema: schemas_1.RequestFaucetFundsV2Schema,
|
|
85
92
|
}),
|
|
86
93
|
__metadata("design:type", Function),
|
|
87
|
-
__metadata("design:paramtypes", [
|
|
94
|
+
__metadata("design:paramtypes", [wallet_providers_1.WalletProvider, void 0]),
|
|
88
95
|
__metadata("design:returntype", Promise)
|
|
89
96
|
], CdpApiV2ActionProvider.prototype, "faucet", null);
|
|
90
97
|
const cdpApiV2ActionProvider = () => new CdpApiV2ActionProvider();
|
|
@@ -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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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
|
|
22
|
-
|
|
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
|
*/
|
|
@@ -32,3 +32,67 @@ export declare function createSearchParams(obj: Record<string, string | number |
|
|
|
32
32
|
* @returns The parsed amount
|
|
33
33
|
*/
|
|
34
34
|
export declare function parseAssetAmount(wallet: EvmWalletProvider, assetAddress: string, amount: number): Promise<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Transform a vault from the API to a format that can be used by the agent
|
|
37
|
+
*
|
|
38
|
+
* @param vault - The vault to transform
|
|
39
|
+
* @param apyRange - The APY range to use
|
|
40
|
+
* @returns The transformed vault
|
|
41
|
+
*/
|
|
42
|
+
export declare function transformVault(vault: ApiVault, apyRange: "1day" | "7day" | "30day"): {
|
|
43
|
+
name: string;
|
|
44
|
+
address: string;
|
|
45
|
+
network: string;
|
|
46
|
+
protocol: string;
|
|
47
|
+
tvlInUsd: number;
|
|
48
|
+
numberOfHolders: number;
|
|
49
|
+
apy: {
|
|
50
|
+
base: number;
|
|
51
|
+
rewards: number | undefined;
|
|
52
|
+
total: number;
|
|
53
|
+
};
|
|
54
|
+
token: {
|
|
55
|
+
address: string;
|
|
56
|
+
name: string;
|
|
57
|
+
symbol: string;
|
|
58
|
+
};
|
|
59
|
+
vaultsFyiScore: number;
|
|
60
|
+
link: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Transform a detailed vault from the API to a format that can be used by the agent
|
|
64
|
+
*
|
|
65
|
+
* @param vault - The vault to transform
|
|
66
|
+
* @param apyRange - The APY range to use
|
|
67
|
+
* @returns The transformed vault
|
|
68
|
+
*/
|
|
69
|
+
export declare function transformDetailedVault(vault: ApiVault, apyRange: "1day" | "7day" | "30day"): {
|
|
70
|
+
rewards: {
|
|
71
|
+
apy: number;
|
|
72
|
+
asset: {
|
|
73
|
+
address: string;
|
|
74
|
+
name: string;
|
|
75
|
+
symbol: string;
|
|
76
|
+
};
|
|
77
|
+
}[];
|
|
78
|
+
description: string;
|
|
79
|
+
additionalIncentives: string;
|
|
80
|
+
name: string;
|
|
81
|
+
address: string;
|
|
82
|
+
network: string;
|
|
83
|
+
protocol: string;
|
|
84
|
+
tvlInUsd: number;
|
|
85
|
+
numberOfHolders: number;
|
|
86
|
+
apy: {
|
|
87
|
+
base: number;
|
|
88
|
+
rewards: number | undefined;
|
|
89
|
+
total: number;
|
|
90
|
+
};
|
|
91
|
+
token: {
|
|
92
|
+
address: string;
|
|
93
|
+
name: string;
|
|
94
|
+
symbol: string;
|
|
95
|
+
};
|
|
96
|
+
vaultsFyiScore: number;
|
|
97
|
+
link: string;
|
|
98
|
+
};
|