get_market_positions
Retrieve top position holders for a specific market to analyze major participants and their profit/loss performance.
Instructions
Get top position holders for a specific market. Shows who holds the biggest positions and their PnL.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| conditionId | Yes | Market conditionId | |
| first | No |
Implementation Reference
- mcp-server/src/index.ts:714-756 (handler)Registration and handler implementation for the 'get_market_positions' tool, which queries position data from Simple and NegRisk markets.
server.registerTool( "get_market_positions", { description: "Get top position holders for a specific market. Shows who holds the biggest positions and their PnL.", inputSchema: { conditionId: z.string().describe("Market conditionId"), first: z.number().default(20), }, }, async ({ conditionId, first }) => { try { const posQuery = `{ userPositions( where: { condition: "${conditionId}", balance_gt: "0" } first: ${first} orderBy: balance orderDirection: desc ) { id user { id tradesCount totalVolumeUSD } tokenId balance netCostUSD realizedPnlUSD lastUpdated } }`; const [simpleData, negriskData, name] = await Promise.all([ querySimple(posQuery).catch(() => ({ userPositions: [] })), queryNegRisk(posQuery).catch(() => ({ userPositions: [] })), getMarketName(conditionId), ]); const positions = [ ...(simpleData.userPositions || []), ...(negriskData.userPositions || []), ] .sort((a, b) => parseInt(b.balance) - parseInt(a.balance)) .slice(0, first); return textResult({ market: name, conditionId, positionCount: positions.length, positions }); } catch (e) { return errorResult(e); } } );