get_global_stats
Retrieve aggregated Polymarket platform statistics including total markets, volume, fees, and trades from combined subgraph data.
Instructions
Get aggregate Polymarket platform statistics. Combines market counts from the Main subgraph with accurate volume/fee/trade data from the Orderbook subgraph.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:389-436 (registration)Tool registration for 'get_global_stats' — registers the tool with the MCP server using server.registerTool with no input schema, and defines the handler that queries both the Main subgraph for condition/trader counts and the Orderbook subgraph for authoritative volume/fee/trade data.
// --------------------------------------------------------------------------- // Tool 9: get_global_stats // --------------------------------------------------------------------------- server.registerTool( "get_global_stats", { description: "Get aggregate Polymarket platform statistics. Combines market counts from the Main subgraph with accurate volume/fee/trade data from the Orderbook subgraph.", }, async () => { try { // Main subgraph: reliable for condition/trader counts const mainQuery = `{ globals { id numConditions numOpenConditions numClosedConditions numTraders } }`; // Orderbook subgraph: authoritative source for volume (main Global has zeroed volume fields) const orderbookQuery = `{ ordersMatchedGlobals(first: 1) { id tradesQuantity buysQuantity sellsQuantity collateralVolume scaledCollateralVolume collateralBuyVolume scaledCollateralBuyVolume collateralSellVolume scaledCollateralSellVolume totalFees averageTradeSize } }`; const [mainData, orderbookData] = await Promise.all([ querySubgraph(SUBGRAPHS.main.ipfsHash, mainQuery), querySubgraph(SUBGRAPHS.orderbook.ipfsHash, orderbookQuery), ]); return textResult({ markets: mainData, volume: orderbookData }); } catch (error) { return errorResult(error); } } ); - src/index.ts:398-435 (handler)Handler function for 'get_global_stats' — executes the tool logic: queries the Main subgraph's 'globals' entity (numConditions, numOpenConditions, numClosedConditions, numTraders) and the Orderbook subgraph's 'ordersMatchedGlobals' entity (tradesQuantity, collateralVolume, totalFees, etc.) in parallel, then returns combined results.
async () => { try { // Main subgraph: reliable for condition/trader counts const mainQuery = `{ globals { id numConditions numOpenConditions numClosedConditions numTraders } }`; // Orderbook subgraph: authoritative source for volume (main Global has zeroed volume fields) const orderbookQuery = `{ ordersMatchedGlobals(first: 1) { id tradesQuantity buysQuantity sellsQuantity collateralVolume scaledCollateralVolume collateralBuyVolume scaledCollateralBuyVolume collateralSellVolume scaledCollateralSellVolume totalFees averageTradeSize } }`; const [mainData, orderbookData] = await Promise.all([ querySubgraph(SUBGRAPHS.main.ipfsHash, mainQuery), querySubgraph(SUBGRAPHS.orderbook.ipfsHash, orderbookQuery), ]); return textResult({ markets: mainData, volume: orderbookData }); } catch (error) { return errorResult(error); } }