get_daily_stats
Retrieve daily platform statistics including volume, fees, trader counts, and market activity from the Beefy P&L subgraph for trend analysis and historical performance.
Instructions
Get daily platform statistics from the Beefy P&L subgraph: volume, fees, trader counts, and market activity per day. Use this for trend analysis and historical performance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Number of recent days to return (1-90) |
Implementation Reference
- src/index.ts:438-469 (registration)Registration of the 'get_daily_stats' tool using server.registerTool with name 'get_daily_stats', description, input schema (days parameter), and handler function.
// --------------------------------------------------------------------------- // Tool 10: get_daily_stats // --------------------------------------------------------------------------- server.registerTool( "get_daily_stats", { description: "Get daily platform statistics from the Beefy P&L subgraph: volume, fees, trader counts, and market activity per day. Use this for trend analysis and historical performance.", inputSchema: { days: z.number().min(1).max(90).default(7).describe("Number of recent days to return (1-90)"), }, }, async ({ days }) => { try { const query = `{ dailyStats_collection(first: ${days}, orderBy: date, orderDirection: desc) { id date volume fees numTraders numNewMarkets numResolvedMarkets } }`; const data = await querySubgraph(SUBGRAPHS.beefy_pnl.ipfsHash, query); return textResult(data); } catch (error) { return errorResult(error); } } ); - src/index.ts:450-469 (handler)Handler function that executes the 'get_daily_stats' tool logic. It queries the Beefy P&L subgraph for dailyStats_collection (ordered by date descending) fetching volume, fees, numTraders, numNewMarkets, numResolvedMarkets for the specified number of days.
async ({ days }) => { try { const query = `{ dailyStats_collection(first: ${days}, orderBy: date, orderDirection: desc) { id date volume fees numTraders numNewMarkets numResolvedMarkets } }`; const data = await querySubgraph(SUBGRAPHS.beefy_pnl.ipfsHash, query); return textResult(data); } catch (error) { return errorResult(error); } } ); - src/index.ts:446-449 (schema)Input schema for get_daily_stats: expects a 'days' parameter (zod number, min 1, max 90, default 7) describing how many recent days of stats to return.
inputSchema: { days: z.number().min(1).max(90).default(7).describe("Number of recent days to return (1-90)"), }, }, - src/index.ts:32-36 (helper)Helper function textResult() used by the handler to format successful responses as JSON text content.
function textResult(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; } - src/index.ts:38-44 (helper)Helper function errorResult() used by the handler to format error responses.
function errorResult(error: unknown) { const message = error instanceof Error ? error.message : String(error); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; }