get_market_analytics
Retrieve comprehensive market analytics by conditionId, combining on-chain data like volume and trades with metadata such as title and categories for complete market analysis.
Instructions
Get full analytics for a specific market by conditionId. Combines on-chain data (volume, trades, fees, resolution status) with market metadata (title, description, categories). Queries both subgraphs to find the market.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| conditionId | Yes | The conditionId (hex) of the market |
Implementation Reference
- mcp-server/src/index.ts:97-146 (handler)The registration and handler implementation for the 'get_market_analytics' tool, which queries market and condition data from subgraphs and fetches metadata to provide a comprehensive market report.
server.registerTool( "get_market_analytics", { description: "Get full analytics for a specific market by conditionId. Combines on-chain data (volume, trades, fees, resolution status) with market metadata (title, description, categories). Queries both subgraphs to find the market.", inputSchema: { conditionId: z.string().describe("The conditionId (hex) of the market"), }, }, async ({ conditionId }) => { try { const marketQuery = (entity: string) => `{ ${entity}(id: "${conditionId}") { id venue tradesCount buysCount sellsCount volumeUSD buyVolumeUSD sellVolumeUSD feesUSD createdAt createdTx } condition(id: "${conditionId}") { id oracle questionId outcomeSlotCount resolved payoutNumerators resolvedAt resolvedTx createdAt } }`; const [simpleData, negriskData, meta] = await Promise.all([ querySimple(marketQuery("market")), queryNegRisk(marketQuery("negRiskMarket")), getMarketMeta(conditionId), ]); const onChain = simpleData.market || negriskData.negRiskMarket; const condition = simpleData.condition || negriskData.condition; const marketType = simpleData.market ? "simple" : negriskData.negRiskMarket ? "negrisk" : "unknown"; return textResult({ title: meta?.title || "Unknown", description: meta?.description || "", categories: meta?.categories || [], slug: meta?.slug || "", currentPrices: meta?.prices || [], expirationDate: meta?.expirationDate || "", tradeType: meta?.tradeType || "", marketType, onChain: onChain || null, condition: condition || null, }); } catch (e) { return errorResult(e); } } );