Skip to main content
Glama
lordbasilaiassistant-sudo

base-price-oracle-mcp

compare_prices

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

Instructions

Compare a token's price across multiple DEX pools to find arbitrage opportunities

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
token_addressYesToken contract address on Base

Implementation Reference

  • The handler logic for 'compare_prices' which fetches token decimals, identifies DEX pools, and calculates/compares prices across them.
    async ({ token_address }) => {
      try {
        const quoteAddress = WETH;
        const [tokenDecimals, quoteDecimals, tokenSymbol] = await Promise.all([
          getTokenDecimals(token_address),
          getTokenDecimals(quoteAddress),
          getTokenSymbol(token_address),
        ]);
    
        const pools = await findAllPools(token_address, quoteAddress);
        if (pools.length === 0) {
          return { content: [{ type: "text" as const, text: `No DEX pools found for ${token_address} on Base.` }] };
        }
    
        if (pools.length === 1) {
          const price = calculatePrice(pools[0], tokenDecimals, quoteDecimals);
          return {
            content: [{
              type: "text" as const,
              text: JSON.stringify({
                token: token_address,
                symbol: tokenSymbol,
                message: "Only one pool found. No cross-DEX comparison possible.",
                pool: { dex: pools[0].dex, address: pools[0].address, price: formatEth(price) },
              }, null, 2),
            }],
          };
        }
    
        const priceData = pools
          .map((pool) => ({
            dex: pool.dex,
            pool: pool.address,
            price: calculatePrice(pool, tokenDecimals, quoteDecimals),
          }))
          .filter((p) => p.price > 0)
          .sort((a, b) => a.price - b.price);
    
        if (priceData.length < 2) {
          return { content: [{ type: "text" as const, text: "Not enough pools with valid prices to compare." }] };
        }
  • src/index.ts:824-829 (registration)
    Registration of the 'compare_prices' tool.
    server.tool(
      "compare_prices",
      "Compare a token's price across multiple DEX pools to find arbitrage opportunities",
      {
        token_address: z.string().describe("Token contract address on Base"),
      },

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-price-oracle-mcp'

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