@coinbase/agentkit
Version:
Coinbase AgentKit core primitives
116 lines (115 loc) • 5.57 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.userEventsActionSchema = exports.totalVaultReturnsActionSchema = exports.historicalBenchmarkActionSchema = exports.benchmarkActionSchema = exports.claimRewardsActionSchema = exports.executeStepActionSchema = exports.transactionContextActionSchema = exports.VaultHistoricalDataActionSchema = exports.VaultDetailsActionSchema = exports.VaultsActionSchema = void 0;
const zod_1 = require("zod");
const sdk_1 = require("@vaultsfyi/sdk");
/**
* Action schemas for the vaultsfyi action provider.
*
* This file contains the Zod schemas that define the shape and validation
* rules for action parameters in the vaultsfyi action provider.
*/
const NetworkSchema = zod_1.z.enum(sdk_1.SUPPORTED_NETWORKS);
/**
* Vaults list action schema.
*/
exports.VaultsActionSchema = zod_1.z.object({
allowedAssets: zod_1.z
.array(zod_1.z.string())
.optional()
.describe("Optional: Symbols of the assets to filter vaults by"),
allowedProtocols: zod_1.z
.array(zod_1.z.string())
.optional()
.describe("Optional: Protocols to filter vaults by. Leave undefined to include all protocols."),
allowedNetworks: zod_1.z
.array(NetworkSchema)
.optional()
.describe("Optional: Networks to filter vaults by. Leave undefined to include all networks."),
minTvl: zod_1.z.coerce.number().optional().describe("Optional: Minimum TVL to filter vaults by"),
sort: zod_1.z
.object({
field: zod_1.z.enum(["tvl", "apy1day", "apy7day", "apy30day"]).optional().describe("Sort field"),
direction: zod_1.z.enum(["asc", "desc"]).optional().describe("Sort direction"),
})
.optional()
.describe("Sort options"),
perPage: zod_1.z.coerce
.number()
.optional()
.describe("Optional: Number of results per page (default: 5)"),
page: zod_1.z.coerce.number().optional().describe("Optional: Page number starting from 0 (default: 0)"),
});
/**
* Vault details action schema.
*/
exports.VaultDetailsActionSchema = zod_1.z.object({
vaultAddress: zod_1.z.string().describe("The address of the vault to fetch details for"),
network: NetworkSchema.describe("The network of the vault"),
});
exports.VaultHistoricalDataActionSchema = zod_1.z.object({
vaultAddress: zod_1.z.string().describe("The address of the vault to fetch historical data for"),
network: NetworkSchema.describe("The network of the vault"),
fromDate: zod_1.z.string().datetime().describe("The date to fetch historical data from"),
toDate: zod_1.z.string().datetime().describe("The date to fetch historical data to"),
granularity: zod_1.z.enum(["1hour", "1day", "1week"]).describe("The granularity of the data"),
apyInterval: zod_1.z.enum(["1day", "7day", "30day"]).describe("The interval of the apy data"),
page: zod_1.z.coerce.number().optional().describe("The page number to fetch"),
perPage: zod_1.z.coerce.number().optional().describe("The number of results per page"),
});
/**
* Base transaction params schema.
*/
exports.transactionContextActionSchema = zod_1.z.object({
vaultAddress: zod_1.z.string().describe("The address of the vault to interact with"),
network: NetworkSchema.describe("The network of the vault"),
});
exports.executeStepActionSchema = exports.transactionContextActionSchema.extend({
action: zod_1.z
.enum([
"deposit",
"redeem",
"request-redeem",
"request-deposit",
"claim-redeem",
"claim-deposit",
"claim-rewards",
"start-redeem-cooldown",
])
.describe("The action to execute"),
assetAddress: zod_1.z.string().describe("The address of the vault's underlying token"),
amount: zod_1.z.coerce
.bigint()
.or(zod_1.z.literal("all"))
.optional()
.describe("The amount of assets to use as a number with decimals"),
});
exports.claimRewardsActionSchema = zod_1.z.object({
claimIds: zod_1.z.array(zod_1.z.string()).describe("The ids of the rewards to claim"),
});
exports.benchmarkActionSchema = zod_1.z.object({
network: NetworkSchema.describe("The network to retrieve benchmark data for"),
benchmarkCode: zod_1.z.enum(["eth", "usd"]).describe("The benchmark code to retrieve data for"),
});
exports.historicalBenchmarkActionSchema = exports.benchmarkActionSchema.extend({
fromDate: zod_1.z.string().datetime().describe("The date to fetch historical data from"),
toDate: zod_1.z.string().datetime().describe("The date to fetch historical data to"),
page: zod_1.z.coerce.number().optional().describe("The page number to fetch"),
perPage: zod_1.z.coerce.number().optional().describe("The number of results per page"),
});
exports.totalVaultReturnsActionSchema = zod_1.z.object({
vaultAddress: zod_1.z.string().describe("The address of the vault to fetch total returns for"),
userAddress: zod_1.z
.string()
.optional()
.describe("The address of the user to fetch total returns for. (default: user's address)"),
network: NetworkSchema.describe("The network of the vault"),
});
exports.userEventsActionSchema = zod_1.z.object({
vaultAddress: zod_1.z.string().describe("The address of the vault to fetch user events for"),
userAddress: zod_1.z
.string()
.optional()
.describe("The address of the user to fetch user events for. (default: user's address)"),
network: NetworkSchema.describe("The network of the vault"),
});