Skip to main content
Glama
lordbasilaiassistant-sudo

base-flash-arb-mcp

get_price_across_dexes

Compare token prices across multiple decentralized exchanges on Base to identify arbitrage opportunities by analyzing price differences.

Instructions

Get current price of a token on all available DEXes on Base.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
token_addressYesToken contract address on Base

Implementation Reference

  • The implementation of the get_price_across_dexes MCP tool, which fetches token prices across multiple DEXes on Base and calculates the spread.
    server.tool(
      "get_price_across_dexes",
      "Get current price of a token on all available DEXes on Base.",
      {
        token_address: z.string().describe("Token contract address on Base"),
      },
      async ({ token_address }) => {
        try {
          const [symbol, decimals] = await Promise.all([
            getSymbol(token_address),
            getDecimals(token_address),
          ]);
    
          const testAmount = ethers.parseEther("0.001"); // Small test amount
          const buyQuotes = await getAllBuyQuotes(token_address, testAmount);
    
          const prices = buyQuotes.map((q) => {
            // Price = ETH spent / tokens received
            const tokensOut = Number(
              ethers.formatUnits(q.amountOut, decimals)
            );
            const ethIn = Number(ethers.formatEther(testAmount));
            const priceInEth = tokensOut > 0 ? ethIn / tokensOut : 0;
            const tokensPerEth = tokensOut > 0 ? tokensOut : 0;
    
            return {
              dex: q.label,
              tokensPerEth: tokensPerEth.toFixed(4),
              pricePerTokenEth: priceInEth.toFixed(18),
              pricePerTokenUsd: (priceInEth * 2500).toFixed(6), // approximate
            };
          });
    
          // Calculate spread
          const priceValues = prices.map((p) => parseFloat(p.pricePerTokenEth));
          const minPrice = Math.min(...priceValues);
          const maxPrice = Math.max(...priceValues);
          const spreadBps =
            minPrice > 0
              ? Math.round(((maxPrice - minPrice) / minPrice) * 10000)
              : 0;
    
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(
                  {
                    token: token_address,
                    symbol,
                    decimals,
                    testAmountEth: "0.001",
                    dexCount: prices.length,
                    spreadBps,
                    prices,
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } catch (e) {
          return {
            content: [
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. It states what the tool does but lacks behavioral details such as rate limits, authentication needs, whether it returns real-time or cached data, error handling, or what 'all available DEXes' entails. This is a significant gap for a tool with no annotation coverage.

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 a single, efficient sentence with zero waste. It is front-loaded with the core purpose and appropriately sized for the tool's complexity.

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 no annotations and no output schema, the description is incomplete. It lacks details on return format (e.g., structured price data per DEX), behavioral traits, and usage context. For a tool that likely returns complex data across multiple DEXes, this is inadequate.

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%, with the single parameter 'token_address' well-documented in the schema. The description adds no additional parameter semantics beyond implying it's for a token on Base, which is already covered. Baseline 3 is appropriate as the 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 specific action ('Get current price') and resource ('token on all available DEXes on Base'), with precise scope. It distinguishes from siblings like 'scan_top_tokens' (which scans tokens rather than getting prices) and 'get_pool_reserves' (which gets reserves rather than prices).

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. While the purpose is clear, there's no mention of when-not-to-use scenarios or explicit alternatives among the sibling tools (e.g., 'detect_arb_opportunity' might be related but not compared).

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