Skip to main content
Glama
PaulieB14

Limitless MCP

get_trader_trades

Retrieve a trader's recent trades across markets with enriched market names, filtering by trade role and wallet address.

Instructions

Get a trader's recent trades across both market types, enriched with market names.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesTrader wallet address
firstNo
roleNoFilter by role in tradeboth

Implementation Reference

  • The handler function for 'get_trader_trades' that queries both 'simple' and 'negrisk' markets, hydrates market names, and returns enriched trade data.
    async ({ address, first, role }) => {
      try {
        const addr = address.toLowerCase();
        let where = "";
        if (role === "maker") where = `maker: "${addr}"`;
        else if (role === "taker") where = `taker: "${addr}"`;
        else where = `or: [{maker: "${addr}"}, {taker: "${addr}"}]`;
    
        const tradesQuery = `{
          trades(first: ${first}, orderBy: timestamp, orderDirection: desc, where: { ${where} }) {
            id market { id } type maker taker amountUSD feeUSD price venue timestamp txHash
          }
        }`;
    
        const negriskTradesQuery = tradesQuery.replace("market { id }", "market { id }");
    
        const { simple, negrisk } = await queryBoth(tradesQuery, negriskTradesQuery);
    
        const allTrades = [
          ...(simple.trades || []).map((t: any) => ({ ...t, marketType: "simple" })),
          ...(negrisk.trades || []).map((t: any) => ({ ...t, marketType: "negrisk" })),
        ]
          .sort((a, b) => Number(b.timestamp) - Number(a.timestamp))
          .slice(0, first);
    
        // Hydrate market names
        const conditionIds = [...new Set(allTrades.map((t: any) => t.market?.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 = allTrades.map((t: any) => ({
          ...t,
          marketName: names.get(t.market?.id) || t.market?.id || "unknown",
        }));
    
        return textResult({ address: addr, trades: enriched });
  • Tool registration for 'get_trader_trades' including input schema definition.
    server.registerTool(
      "get_trader_trades",
      {
        description:
          "Get a trader's recent trades across both market types, enriched with market names.",
        inputSchema: {
          address: z.string().describe("Trader wallet address"),
          first: z.number().default(20),
          role: z
            .enum(["maker", "taker", "both"])
            .default("both")
            .describe("Filter by role in trade"),
        },
      },

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