get_vault_apy_history
Retrieve historical Annual Percentage Yield (APY) data for a specific vault by providing its address and a time range with interval options.
Instructions
Get historical APY data for a vault.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | ||
| options | Yes |
Implementation Reference
- src/index.ts:1593-1633 (handler)Handler function that performs a GraphQL query to the Morpho API to fetch historical APY and netApy data for a specific vault.if (name === GET_VAULT_APY_HISTORY_TOOL) { try { const { address, options } = params as VaultApyHistoryParams; const query = ` query { vaultByAddress(address: "${address}") { address historicalState { apy(options: { startTimestamp: ${options.startTimestamp} endTimestamp: ${options.endTimestamp} interval: ${options.interval} }) { x y } netApy(options: { startTimestamp: ${options.startTimestamp} endTimestamp: ${options.endTimestamp} interval: ${options.interval} }) { x y } } } }`; const response = await axios.post(MORPHO_API_BASE, { query }); const validatedData = VaultApyHistoryResponseSchema.parse(response.data); return { content: [{ type: 'text', text: JSON.stringify(validatedData.data.vaultByAddress, null, 2) }] }; } catch (error: any) { return { isError: true, content: [{ type: 'text', text: `Error retrieving vault APY history: ${error.message}` }] }; } }
- src/index.ts:866-888 (registration)Tool registration in the listTools response, including name, description, and input schema definition.{ name: GET_VAULT_APY_HISTORY_TOOL, description: 'Get historical APY data for a vault.', inputSchema: { type: 'object', properties: { address: { type: 'string' }, options: { type: 'object', properties: { startTimestamp: { type: 'number' }, endTimestamp: { type: 'number' }, interval: { type: 'string', enum: ['HOUR', 'DAY', 'WEEK', 'MONTH'] } }, required: ['startTimestamp', 'endTimestamp', 'interval'] } }, required: ['address', 'options'] } }
- src/index.ts:566-576 (schema)Zod schema for parsing and validating the GraphQL response containing vault historical APY data.const VaultApyHistoryResponseSchema = z.object({ data: z.object({ vaultByAddress: z.object({ address: z.string(), historicalState: z.object({ apy: z.array(TimeseriesPointSchema), netApy: z.array(TimeseriesPointSchema) }) }) }) });
- src/index.ts:515-523 (schema)TypeScript type definition for the input parameters expected by the get_vault_apy_history tool.type VaultApyHistoryParams = { address: string; options: { startTimestamp: number; endTimestamp: number; interval: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH'; }; };
- src/index.ts:491-491 (helper)Constant defining the tool name for consistent reference throughout the code.const GET_VAULT_APY_HISTORY_TOOL = 'get_vault_apy_history';