Skip to main content
Glama
PaulieB14

Limitless MCP

get_trader_positions

Retrieve a trader's current positions, balances, and PnL across market types using their wallet address.

Instructions

Get a trader's current positions across both market types with balances and PnL.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesTrader wallet address

Implementation Reference

  • The tool 'get_trader_positions' is registered and implemented directly in mcp-server/src/index.ts. It handles querying both 'simple' and 'negrisk' market types, hydrates condition names, and returns the positions.
    server.registerTool(
      "get_trader_positions",
      {
        description:
          "Get a trader's current positions across both market types with balances and PnL.",
        inputSchema: {
          address: z.string().describe("Trader wallet address"),
        },
      },
      async ({ address }) => {
        try {
          const addr = address.toLowerCase();
          const posQuery = `{
            userPositions(where: { user: "${addr}", balance_gt: "0" }, first: 100) {
              id tokenId balance netCostUSD realizedPnlUSD lastUpdated
              condition { id resolved payoutNumerators }
            }
          }`;
    
          const { simple, negrisk } = await queryBoth(posQuery, posQuery);
    
          const allPositions = [
            ...(simple.userPositions || []).map((p: any) => ({ ...p, marketType: "simple" })),
            ...(negrisk.userPositions || []).map((p: any) => ({ ...p, marketType: "negrisk" })),
          ];
    
          // Hydrate condition names
          const conditionIds = [
            ...new Set(allPositions.map((p: any) => p.condition?.id).filter(Boolean)),
          ];
          const names = new Map<string, string>();
          await Promise.all(
            conditionIds.map(async (id: string) => {
              names.set(id, await hydrateName(id));
            })
          );
    
          const enriched = allPositions.map((p: any) => ({
            ...p,
            marketName: names.get(p.condition?.id) || p.condition?.id || "unknown",
          }));
    
          return textResult({ address: addr, positionCount: enriched.length, positions: enriched });
        } catch (e) {
          return errorResult(e);
        }
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PaulieB14/limitless-subgraphs'

If you have feedback or need assistance with the MCP directory API, please join our Discord server