@coinbase/agentkit 0.8.0 → 0.8.2
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 +14 -1
- package/dist/action-providers/index.d.ts +1 -0
- package/dist/action-providers/index.js +1 -0
- 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/action-providers/x402/index.d.ts +1 -0
- package/dist/action-providers/x402/index.js +17 -0
- package/dist/action-providers/x402/schemas.d.ts +30 -0
- package/dist/action-providers/x402/schemas.js +27 -0
- package/dist/action-providers/x402/x402ActionProvider.d.ts +38 -0
- package/dist/action-providers/x402/x402ActionProvider.js +238 -0
- package/dist/action-providers/x402/x402ActionProvider.test.d.ts +1 -0
- package/dist/action-providers/x402/x402ActionProvider.test.js +469 -0
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -418,6 +418,19 @@ const agent = createReactAgent({
|
|
|
418
418
|
</table>
|
|
419
419
|
</details>
|
|
420
420
|
<details>
|
|
421
|
+
<summary><strong>X402</strong></summary>
|
|
422
|
+
<table width="100%">
|
|
423
|
+
<tr>
|
|
424
|
+
<td width="200"><code>paid_request</code></td>
|
|
425
|
+
<td width="768">Makes HTTP requests to x402-protected API endpoints with automatic payment handling.</td>
|
|
426
|
+
</tr>
|
|
427
|
+
<tr>
|
|
428
|
+
<td width="200"><code>fetch_payment_info</code></td>
|
|
429
|
+
<td width="768">Fetches payment information from x402-protected endpoints without making payments.</td>
|
|
430
|
+
</tr>
|
|
431
|
+
</table>
|
|
432
|
+
</details>
|
|
433
|
+
<details>
|
|
421
434
|
<summary><strong>ZeroDev Wallet</strong></summary>
|
|
422
435
|
<table width="100%">
|
|
423
436
|
<tr>
|
|
@@ -1024,7 +1037,7 @@ The `CdpV2SolanaWalletProvider` supports the following Solana networks:
|
|
|
1024
1037
|
|
|
1025
1038
|
### SolanaKeypairWalletProvider
|
|
1026
1039
|
|
|
1027
|
-
The `SolanaKeypairWalletProvider` is a wallet provider that uses the API [Solana web3.js](https://solana
|
|
1040
|
+
The `SolanaKeypairWalletProvider` is a wallet provider that uses the API [Solana web3.js](https://solana.com/docs/clients/javascript).
|
|
1028
1041
|
|
|
1029
1042
|
NOTE: It is highly recommended to use a dedicated RPC provider. See [here](https://solana.com/rpc) for more info on Solana RPC infrastructure, and see [here](#rpc-url-configuration) for instructions on configuring `SolanaKeypairWalletProvider` with a custom RPC URL.
|
|
1030
1043
|
|
|
@@ -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);
|
|
@@ -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
|
+
};
|
|
@@ -4,6 +4,8 @@ exports.getVaultsLink = getVaultsLink;
|
|
|
4
4
|
exports.executeActions = executeActions;
|
|
5
5
|
exports.createSearchParams = createSearchParams;
|
|
6
6
|
exports.parseAssetAmount = parseAssetAmount;
|
|
7
|
+
exports.transformVault = transformVault;
|
|
8
|
+
exports.transformDetailedVault = transformDetailedVault;
|
|
7
9
|
const viem_1 = require("viem");
|
|
8
10
|
/**
|
|
9
11
|
* Get the link to the vaults.fyi page for a vault
|
|
@@ -67,3 +69,54 @@ async function parseAssetAmount(wallet, assetAddress, amount) {
|
|
|
67
69
|
});
|
|
68
70
|
return Math.floor(amount * 10 ** decimals);
|
|
69
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Transform a vault from the API to a format that can be used by the agent
|
|
74
|
+
*
|
|
75
|
+
* @param vault - The vault to transform
|
|
76
|
+
* @param apyRange - The APY range to use
|
|
77
|
+
* @returns The transformed vault
|
|
78
|
+
*/
|
|
79
|
+
function transformVault(vault, apyRange) {
|
|
80
|
+
return {
|
|
81
|
+
name: vault.name,
|
|
82
|
+
address: vault.address,
|
|
83
|
+
network: vault.network,
|
|
84
|
+
protocol: vault.protocol,
|
|
85
|
+
tvlInUsd: Number(vault.tvlDetails.tvlUsd),
|
|
86
|
+
numberOfHolders: vault.numberOfHolders,
|
|
87
|
+
apy: {
|
|
88
|
+
base: vault.apy.base[apyRange] / 100,
|
|
89
|
+
rewards: vault.apy.rewards?.[apyRange] ? vault.apy.rewards[apyRange] / 100 : undefined,
|
|
90
|
+
total: vault.apy.total[apyRange] / 100,
|
|
91
|
+
},
|
|
92
|
+
token: {
|
|
93
|
+
address: vault.token.assetAddress,
|
|
94
|
+
name: vault.token.name,
|
|
95
|
+
symbol: vault.token.symbol,
|
|
96
|
+
},
|
|
97
|
+
vaultsFyiScore: vault.score.vaultScore,
|
|
98
|
+
link: getVaultsLink(vault),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Transform a detailed vault from the API to a format that can be used by the agent
|
|
103
|
+
*
|
|
104
|
+
* @param vault - The vault to transform
|
|
105
|
+
* @param apyRange - The APY range to use
|
|
106
|
+
* @returns The transformed vault
|
|
107
|
+
*/
|
|
108
|
+
function transformDetailedVault(vault, apyRange) {
|
|
109
|
+
return {
|
|
110
|
+
...transformVault(vault, apyRange),
|
|
111
|
+
rewards: vault.rewards.map(reward => ({
|
|
112
|
+
apy: reward.apy[apyRange] / 100,
|
|
113
|
+
asset: {
|
|
114
|
+
address: reward.asset.assetAddress,
|
|
115
|
+
name: reward.asset.name,
|
|
116
|
+
symbol: reward.asset.symbol,
|
|
117
|
+
},
|
|
118
|
+
})),
|
|
119
|
+
description: vault.description,
|
|
120
|
+
additionalIncentives: vault.additionalIncentives,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -10,7 +10,7 @@ import { z } from "zod";
|
|
|
10
10
|
import { ActionProvider } from "../actionProvider";
|
|
11
11
|
import { Network } from "../../network";
|
|
12
12
|
import { EvmWalletProvider } from "../../wallet-providers";
|
|
13
|
-
import { claimActionSchema, depositActionSchema, redeemActionSchema, VaultsActionSchema } from "./schemas";
|
|
13
|
+
import { claimActionSchema, depositActionSchema, redeemActionSchema, VaultDetailsActionSchema, VaultHistoricalDataActionSchema, VaultsActionSchema } from "./schemas";
|
|
14
14
|
/**
|
|
15
15
|
* Configuration options for the OpenseaActionProvider.
|
|
16
16
|
*/
|
|
@@ -39,10 +39,26 @@ export declare class VaultsfyiActionProvider extends ActionProvider<EvmWalletPro
|
|
|
39
39
|
* vaults action
|
|
40
40
|
*
|
|
41
41
|
* @param wallet - The wallet provider instance for blockchain interactions
|
|
42
|
-
* @param args - Input arguments: token, network
|
|
42
|
+
* @param args - Input arguments: token, network...
|
|
43
43
|
* @returns A list of vaults.
|
|
44
44
|
*/
|
|
45
45
|
vaults(wallet: EvmWalletProvider, args: z.infer<typeof VaultsActionSchema>): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* vault details action
|
|
48
|
+
*
|
|
49
|
+
* @param wallet - The wallet provider instance for blockchain interactions
|
|
50
|
+
* @param args - Input arguments: address, network, apyRange
|
|
51
|
+
* @returns A detailed view of a single vault.
|
|
52
|
+
*/
|
|
53
|
+
vaultDetails(wallet: EvmWalletProvider, args: z.infer<typeof VaultDetailsActionSchema>): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* vault historical data action
|
|
56
|
+
*
|
|
57
|
+
* @param wallet - The wallet provider instance for blockchain interactions
|
|
58
|
+
* @param args - Input arguments: address, network, date, apyRange
|
|
59
|
+
* @returns A detailed view of a single vault.
|
|
60
|
+
*/
|
|
61
|
+
vaultHistoricalData(wallet: EvmWalletProvider, args: z.infer<typeof VaultHistoricalDataActionSchema>): Promise<string>;
|
|
46
62
|
/**
|
|
47
63
|
* Deposit action
|
|
48
64
|
*
|