Skip to main content
Glama
lordbasilaiassistant-sudo

base-flash-arb-mcp

scan_top_tokens

Scans top traded tokens on Base blockchain for arbitrage opportunities by analyzing price gaps across DEXes using DexScreener data.

Instructions

Scan top traded tokens on Base for arb opportunities using DexScreener.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
min_liquidity_ethNoMinimum liquidity in ETH (default 1)
limitNoMax tokens to scan (default 20)

Implementation Reference

  • The handler function that executes the `scan_top_tokens` tool. It fetches token data from DexScreener, filters by liquidity, and returns the top tokens.
    async ({ min_liquidity_eth, limit }) => {
      try {
        // Fetch trending tokens on Base from DexScreener
        const response = await fetch(
          "https://api.dexscreener.com/latest/dex/search?q=WETH&chain=base"
        );
        const data = (await response.json()) as {
          pairs?: Array<{
            baseToken: { address: string; symbol: string; name: string };
            liquidity?: { usd: number };
            priceNative?: string;
            volume?: { h24: number };
            txns?: { h24: { buys: number; sells: number } };
          }>;
        };
    
        if (!data.pairs || data.pairs.length === 0) {
          return {
            content: [
              {
                type: "text" as const,
                text: "No pairs found on DexScreener for Base chain.",
              },
            ],
          };
        }
    
        // Deduplicate by token address, filter by min liquidity
        const ethPrice = 2500; // approximate for liquidity conversion
        const minLiqUsd = min_liquidity_eth * ethPrice;
        const seen = new Set<string>();
        const tokens: Array<{
          address: string;
          symbol: string;
          name: string;
          liquidityUsd: number;
          volume24h: number;
        }> = [];
    
        for (const pair of data.pairs) {
          const addr = pair.baseToken.address.toLowerCase();
          if (seen.has(addr)) continue;
          if (addr === WETH.toLowerCase()) continue;
          seen.add(addr);
    
          const liqUsd = pair.liquidity?.usd ?? 0;
          if (liqUsd < minLiqUsd) continue;
    
          tokens.push({
            address: pair.baseToken.address,
            symbol: pair.baseToken.symbol,
            name: pair.baseToken.name,
            liquidityUsd: liqUsd,
            volume24h: pair.volume?.h24 ?? 0,
          });
    
          if (tokens.length >= limit) break;
        }
    
        // Scan each token for arb opportunities
        const gasCost = await estimateGasCost();
        const testAmount = ethers.parseEther("0.01");
        const results = [];
    
        for (const token of tokens.slice(0, limit)) {
          try {
            const buyQuotes = await getAllBuyQuotes(token.address, testAmount);
  • src/index.ts:859-868 (registration)
    Registration of the `scan_top_tokens` tool, defining its schema and description.
    server.tool(
      "scan_top_tokens",
      "Scan top traded tokens on Base for arb opportunities using DexScreener.",
      {
        min_liquidity_eth: z
          .number()
          .default(1)
          .describe("Minimum liquidity in ETH (default 1)"),
        limit: z.number().default(20).describe("Max tokens to scan (default 20)"),
      },

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