UNPKG

@coinbase/agentkit

Version:

Coinbase AgentKit core primitives

82 lines (81 loc) 3.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.claimActionSchema = exports.redeemActionSchema = exports.depositActionSchema = exports.VaultHistoricalDataActionSchema = exports.VaultDetailsActionSchema = exports.VaultsActionSchema = void 0; const zod_1 = require("zod"); const constants_1 = require("./constants"); /** * 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(Object.values(constants_1.VAULTSFYI_SUPPORTED_CHAINS)); /** * Vaults list action schema. */ exports.VaultsActionSchema = zod_1.z.object({ token: zod_1.z .string() .transform(val => (val === "" ? undefined : val)) .optional() .describe("Optional: Name or symbol of the token to filter vaults by"), protocol: zod_1.z .string() .transform(val => (val === "" ? undefined : val)) .optional() .describe("Optional: Protocol to filter vaults by"), network: NetworkSchema.or(zod_1.z.enum(["", "all"])) .optional() .transform(val => (val === "" || val === "all" ? undefined : val)) .describe("Optional: Network name to filter vaults by. Supported networks: mainnet, arbitrum, optimism, polygon, base, gnosis, unichain"), minTvl: zod_1.z.number().optional().describe("Optional: Minimum TVL to filter vaults by"), sort: zod_1.z .object({ field: zod_1.z.enum(["tvl", "apy", "name"]).optional().describe("Sort field"), direction: zod_1.z.enum(["asc", "desc"]).optional().describe("Sort direction"), }) .optional() .describe("Sort options"), apyRange: zod_1.z .enum(["1day", "7day", "30day"]) .optional() .describe("Optional: APY moving average range (default: 7day)"), take: zod_1.z.number().optional().describe("Optional: Limit the number of results"), page: zod_1.z.number().optional().describe("Optional: Page number"), }); /** * 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"), apyRange: zod_1.z .enum(["1day", "7day", "30day"]) .optional() .describe("Optional: APY moving average range (default: 7day)"), }); 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"), date: zod_1.z.string().datetime().describe("The date to fetch historical data for"), apyRange: zod_1.z .enum(["1day", "7day", "30day"]) .optional() .describe("Optional: APY moving average range (default: 7day)"), }); /** * Base transaction params schema. */ const TransactionActionSchema = zod_1.z.object({ vaultAddress: zod_1.z.string().describe("The address of the vault to interact with"), assetAddress: zod_1.z.string().describe("The address of the vault's underlying token"), network: NetworkSchema.describe("The network of the vault"), amount: zod_1.z.number().describe("The amount of assets to use"), }); exports.depositActionSchema = TransactionActionSchema; exports.redeemActionSchema = TransactionActionSchema.extend({ all: zod_1.z.boolean().optional().describe("Should redeem all assets"), }); exports.claimActionSchema = TransactionActionSchema.omit({ amount: true, });