Skip to main content
Glama
lordbasilaiassistant-sudo

base-flash-arb-mcp

detect_arb_opportunity

Identify profitable arbitrage opportunities by comparing token prices across Uniswap V2, Uniswap V3, and Aerodrome on Base blockchain.

Instructions

Compare token prices across Uniswap V2, Uniswap V3, and Aerodrome on Base. Find profitable arbitrage routes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
token_addressYesToken contract address on Base
min_profit_bpsNoMinimum profit in basis points (default 50 = 0.5%)

Implementation Reference

  • The handler for the "detect_arb_opportunity" tool which compares token prices across different DEXes (Uniswap V2/V3, Aerodrome) to identify arbitrage opportunities.
    server.tool(
      "detect_arb_opportunity",
      "Compare token prices across Uniswap V2, Uniswap V3, and Aerodrome on Base. Find profitable arbitrage routes.",
      {
        token_address: z.string().describe("Token contract address on Base"),
        min_profit_bps: z
          .number()
          .default(50)
          .describe("Minimum profit in basis points (default 50 = 0.5%)"),
      },
      async ({ token_address, min_profit_bps }) => {
        try {
          const symbol = await getSymbol(token_address);
          const testAmount = ethers.parseEther("0.01"); // Test with 0.01 ETH
          const gasCost = await estimateGasCost();
    
          // Get all buy quotes
          const buyQuotes = await getAllBuyQuotes(token_address, testAmount);
          if (buyQuotes.length < 2) {
            return {
              content: [
                {
                  type: "text" as const,
                  text: JSON.stringify(
                    {
                      token: token_address,
                      symbol,
                      result: "INSUFFICIENT_ROUTES",
                      message: `Only ${buyQuotes.length} DEX route(s) found. Need at least 2 for cross-DEX arb.`,
                      availableRoutes: buyQuotes.map((q) => q.label),
                    },
                    null,
                    2
                  ),
                },
              ],
            };
          }
    
          // Sort by best rate (most tokens per ETH)
          buyQuotes.sort((a, b) => (b.amountOut > a.amountOut ? 1 : -1));
          const bestBuy = buyQuotes[0];
    
          // Get sell quotes for the tokens we'd receive
          const sellQuotes = await getAllSellQuotes(
            token_address,
            bestBuy.amountOut
          );
    
          const opportunities = [];
    
          for (const sellQ of sellQuotes) {
            // Skip same route
            if (bestBuy.label === sellQ.label) continue;
    
            const ethOut = sellQ.amountOut;
            const profitWei = ethOut - testAmount;
            const profitAfterGas = profitWei - gasCost;
            const profitBps =
              testAmount > 0n
                ? Number((profitWei * 10000n) / testAmount)
                : 0;
    
            if (profitBps >= min_profit_bps) {
              opportunities.push({
                buyOn: bestBuy.label,
                sellOn: sellQ.label,
                ethIn: ethers.formatEther(testAmount),
                tokensReceived: bestBuy.amountOut.toString(),
                ethOut: ethers.formatEther(ethOut),
                grossProfitEth: ethers.formatEther(profitWei),
                gasCostEth: ethers.formatEther(gasCost),
                netProfitEth: ethers.formatEther(profitAfterGas),
                profitBps,
                profitable: profitAfterGas > 0n,
              });
            }
          }
    
          opportunities.sort(
            (a, b) =>
              parseFloat(b.netProfitEth) - parseFloat(a.netProfitEth)
          );
    
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(
                  {
                    token: token_address,
                    symbol,
                    testAmountEth: "0.01",
                    routesChecked: buyQuotes.length,
                    opportunitiesFound: opportunities.length,
                    opportunities,
                    allBuyQuotes: buyQuotes.map((q) => ({
                      label: q.label,
                      tokensOut: q.amountOut.toString(),
                    })),
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } catch (e) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error detecting arb: ${e instanceof Error ? e.message : String(e)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. While it mentions the tool's core function, it lacks behavioral details such as rate limits, computational requirements, whether it performs live queries or uses cached data, error conditions, or what constitutes a 'profitable arbitrage route' in the response. The description doesn't contradict annotations (none exist).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (two sentences) and front-loaded with the core purpose. Every word earns its place—no redundant phrases or unnecessary elaboration. It efficiently communicates the tool's function without verbosity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of arbitrage detection (involving multiple DEXes and profit calculations) and the absence of both annotations and an output schema, the description is insufficient. It doesn't explain what the output looks like (e.g., route details, profit amounts), performance characteristics, or limitations. For a tool with no structured behavioral hints, more descriptive context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description doesn't add any parameter-specific semantics beyond what's in the schema (e.g., it doesn't clarify token_address format beyond 'contract address' or explain min_profit_bps implications). Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('compare', 'find') and resources (token prices across Uniswap V2, Uniswap V3, and Aerodrome on Base). It distinguishes itself from siblings by focusing on arbitrage opportunity detection rather than risk assessment, profit estimation, or data retrieval.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context (finding arbitrage opportunities) but doesn't explicitly state when to use this tool versus alternatives like 'get_price_across_dexes' or 'estimate_flash_profit'. No guidance is provided about prerequisites, exclusions, or specific scenarios where this tool is preferred.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/lordbasilaiassistant-sudo/base-flash-arb-mcp'

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