Skip to main content
Glama

get_funding_rates

Fetch perpetual futures funding rates from 6 venues and identify arbitrage opportunities with annualized carry. Returns per-8h rates, APR, open interest, and next funding time.

Instructions

Get perpetual futures funding rates across 6 venues: Hyperliquid, dYdX v4, Aevo, GMX, Drift, and Vertex. Returns per-8h funding rate, annualized APR, predicted rate, open interest, and next funding time for each venue. Also returns ranked arbitrage opportunities (long low-rate venue, short high-rate venue) with spread in bps and annualized carry. Costs 0.008 USDC per call (x402 micropayment on Base).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
assetNoAsset symbol (e.g. "BTC", "ETH", "SOL"). Returns all assets if omitted.
min_spreadNoFilter for arbitrage spreads >= N basis points (e.g. 0.5). Omit for no filter.

Implementation Reference

  • Schema/definition for the 'get_funding_rates' tool: describes it as getting perpetual futures funding rates across 6 venues (Hyperliquid, dYdX v4, Aevo, GMX, Drift, Vertex). Accepts optional 'asset' and 'min_spread' parameters. Costs 0.008 USDC.
    name: 'get_funding_rates',
    description:
      'Get perpetual futures funding rates across 6 venues: Hyperliquid, dYdX v4, Aevo, GMX, Drift, and Vertex. ' +
      'Returns per-8h funding rate, annualized APR, predicted rate, open interest, and next funding time for each venue. ' +
      'Also returns ranked arbitrage opportunities (long low-rate venue, short high-rate venue) with spread in bps and annualized carry. ' +
      'Costs 0.008 USDC per call (x402 micropayment on Base).',
    inputSchema: {
      type: 'object',
      properties: {
        asset: {
          type: 'string',
          description: 'Asset symbol (e.g. "BTC", "ETH", "SOL"). Returns all assets if omitted.',
        },
        min_spread: {
          type: 'number',
          description: 'Filter for arbitrage spreads >= N basis points (e.g. 0.5). Omit for no filter.',
        },
      },
      required: [],
    },
  • src/index.ts:246-417 (registration)
    The tool is registered in the TOOLS array at line 374 and in the TOOLS constant section starting at line 246. It is part of the ListToolsRequestSchema handler (line 434) and the CallToolRequestSchema switch statement (line 498).
    const TOOLS = [
      {
        name: 'get_crypto_prices',
        description:
          'Get live cryptocurrency prices and top 24h movers. Returns BTC, ETH, SOL prices plus top gainers/losers. ' +
          'Costs 0.001 USDC per call (x402 micropayment on Base). ' +
          'Data sourced live from CoinGecko.',
        inputSchema: {
          type: 'object',
          properties: {},
          required: [],
        },
      },
      {
        name: 'get_gas_prices',
        description:
          'Get current gas prices across multiple chains: Ethereum, Base, Polygon, and Arbitrum. ' +
          'Returns slow/standard/fast tiers in gwei and estimated USD cost. ' +
          'Costs 0.001 USDC per call (x402 micropayment on Base).',
        inputSchema: {
          type: 'object',
          properties: {},
          required: [],
        },
      },
      {
        name: 'get_dex_quotes',
        description:
          'Compare swap quotes across DEXes: Uniswap, SushiSwap, and 1inch. ' +
          'Returns best price, price impact, liquidity, and estimated fees for each venue. ' +
          'Costs 0.002 USDC per call (x402 micropayment on Base).',
        inputSchema: {
          type: 'object',
          properties: {
            from: {
              type: 'string',
              description: 'Input token symbol or address (e.g. "ETH", "USDC", "0x...")',
            },
            to: {
              type: 'string',
              description: 'Output token symbol or address (e.g. "USDC", "DAI", "0x...")',
            },
            amount: {
              type: 'string',
              description: 'Amount to swap (e.g. "1.5" for 1.5 ETH)',
            },
            chain: {
              type: 'string',
              description: 'Chain to query (e.g. "ethereum", "base", "arbitrum"). Defaults to "ethereum".',
            },
          },
          required: ['from', 'to', 'amount'],
        },
      },
      {
        name: 'scan_token',
        description:
          'Perform a security scan on a token contract. Detects rug-pull risks, honeypot patterns, ' +
          'ownership concentration, mint authority, and other red flags. ' +
          'Costs 0.003 USDC per call (x402 micropayment on Base).',
        inputSchema: {
          type: 'object',
          properties: {
            token: {
              type: 'string',
              description: 'Token contract address (0x...) or symbol (e.g. "PEPE", "UNI")',
            },
            chain: {
              type: 'string',
              description: 'Chain to scan on (e.g. "ethereum", "base", "arbitrum", "polygon"). Defaults to "ethereum".',
            },
          },
          required: ['token'],
        },
      },
      {
        name: 'track_whales',
        description:
          'Analyze whale activity and holder concentration for a token. Returns top holders, ' +
          'Gini coefficient, whale alerts (large recent buys/sells), and distribution breakdown. ' +
          'Costs 0.005 USDC per call (x402 micropayment on Base).',
        inputSchema: {
          type: 'object',
          properties: {
            token: {
              type: 'string',
              description: 'Token contract address (0x...) or symbol (e.g. "ETH", "PEPE")',
            },
            chain: {
              type: 'string',
              description: 'Chain to query (e.g. "ethereum", "base", "solana", "arbitrum"). Defaults to "ethereum".',
            },
          },
          required: ['token'],
        },
      },
      {
        name: 'scan_yields',
        description:
          'Scan top DeFi yield opportunities across protocols: Aave, Compound, Morpho, Lido, Pendle, and more. ' +
          'Filter by chain, asset, and minimum TVL. Returns APY, TVL, risk score, and protocol details. ' +
          'Costs 0.005 USDC per call (x402 micropayment on Base).',
        inputSchema: {
          type: 'object',
          properties: {
            chain: {
              type: 'string',
              description:
                'Blockchain to filter by (e.g. "ethereum", "base", "arbitrum", "polygon"). ' +
                'Omit for all chains.',
            },
            asset: {
              type: 'string',
              description: 'Filter by asset symbol (e.g. "ETH", "USDC", "stETH"). Omit for all assets.',
            },
            min_tvl: {
              type: 'number',
              description: 'Minimum TVL in USD (e.g. 1000000 for $1M). Omit for no minimum.',
            },
            limit: {
              type: 'number',
              description: 'Maximum number of results to return (1–50). Defaults to 20.',
            },
          },
          required: [],
        },
      },
      {
        name: 'get_funding_rates',
        description:
          'Get perpetual futures funding rates across 6 venues: Hyperliquid, dYdX v4, Aevo, GMX, Drift, and Vertex. ' +
          'Returns per-8h funding rate, annualized APR, predicted rate, open interest, and next funding time for each venue. ' +
          'Also returns ranked arbitrage opportunities (long low-rate venue, short high-rate venue) with spread in bps and annualized carry. ' +
          'Costs 0.008 USDC per call (x402 micropayment on Base).',
        inputSchema: {
          type: 'object',
          properties: {
            asset: {
              type: 'string',
              description: 'Asset symbol (e.g. "BTC", "ETH", "SOL"). Returns all assets if omitted.',
            },
            min_spread: {
              type: 'number',
              description: 'Filter for arbitrage spreads >= N basis points (e.g. 0.5). Omit for no filter.',
            },
          },
          required: [],
        },
      },
      {
        name: 'profile_wallet',
        description:
          'Generate a full portfolio profile for an Ethereum/Base wallet address. ' +
          'Returns token holdings, NFTs, DeFi positions, transaction history summary, ' +
          'PnL estimate, and risk profile score. ' +
          'Costs 0.008 USDC per call (x402 micropayment on Base).',
        inputSchema: {
          type: 'object',
          properties: {
            address: {
              type: 'string',
              description: 'Ethereum or Base wallet address (0x...)',
            },
            chain: {
              type: 'string',
              description: 'Filter by chain (e.g. "ethereum", "base", "arbitrum", "polygon"). Defaults to "all".',
            },
          },
          required: ['address'],
        },
      },
    ];
  • Handler for 'get_funding_rates': calls the backend API at '/api/funding-rates' with optional 'asset' and 'min_spread' query parameters via callApi(). The result is formatted and returned as text content.
    case 'get_funding_rates':
      result = await callApi('/api/funding-rates', {
        asset: params.asset,
        min_spread: params.min_spread,
      });
      break;
  • The callApi() helper function (lines 114-180) is the generic HTTP request helper used by all tool handlers. For get_funding_rates, it sends a GET to '/api/funding-rates?asset=...&min_spread=...'. Handles x402 payment protocol (402 responses), timeouts, and error formatting.
    async function callApi(
      endpoint: string,
      params: Record<string, string | number | undefined> = {}
    ): Promise<ApiResponse> {
      const url = new URL(`${API_BASE_URL}${endpoint}`);
      for (const [key, value] of Object.entries(params)) {
        if (value !== undefined && value !== '') {
          url.searchParams.set(key, String(value));
        }
      }
    
      const fetchFn = await getX402Fetch();
    
      let response: Response;
      const controller = new AbortController();
      const fetchTimeout = setTimeout(() => controller.abort(), 30_000);
      try {
        response = await fetchFn(url.toString(), {
          headers: {
            'Accept': 'application/json',
            'User-Agent': `x402-api-mcp/${SERVER_VERSION}`,
          },
          signal: controller.signal,
        });
      } catch (err) {
        const isTimeout = err instanceof Error && err.name === 'AbortError';
        throw new McpError(
          ErrorCode.InternalError,
          isTimeout
            ? `Request to ${endpoint} timed out after 30 seconds`
            : `Network error calling ${endpoint}: ${err instanceof Error ? err.message : String(err)}`
        );
      } finally {
        clearTimeout(fetchTimeout);
      }
    
      if (response.status === 402) {
        // Clone before reading so we can fall back to text() if JSON parsing fails.
        // Without the clone, calling response.json() consumes the body; a subsequent
        // response.text() call then throws "body already used".
        const cloned = response.clone();
        let paymentDetails: unknown;
        try {
          paymentDetails = await response.json();
        } catch {
          paymentDetails = await cloned.text();
        }
        return { status: 402, data: null, paymentRequired: true, paymentDetails };
      }
    
      if (!response.ok) {
        const errorText = await response.text();
        if (response.status === 400 || response.status === 422) {
          throw new McpError(
            ErrorCode.InvalidParams,
            `Invalid request to ${endpoint}: ${errorText}`
          );
        }
        throw new McpError(
          ErrorCode.InternalError,
          `API error ${response.status} from ${endpoint}: ${errorText}`
        );
      }
    
      const data = await response.json();
      return { status: response.status, data };
    }
Behavior4/5

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

With no annotations, the description fully bears the burden of behavioral disclosure. It explicitly mentions the cost per call (0.008 USDC) and the payment method (x402 micropayment on Base), which is critical for agent awareness. It also lists the venues and outputs, but lacks info on rate limits or error behavior.

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 three sentences with no redundancy. It front-loads the primary function, then details outputs and cost. Every sentence adds essential information without being verbose.

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

Completeness4/5

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

Despite lacking an output schema, the description thoroughly explains what is returned (per-venue data and arbitrage opportunities). The optional parameters are handled. It covers the cost detail. Minor gaps remain regarding possible error scenarios or response size, but it is largely complete for a data-fetching tool.

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

Parameters4/5

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

The input schema has 100% description coverage, already explaining the parameters. The description adds value by clarifying that omitting 'asset' returns all assets and that 'min_spread' filters arbitrage opportunities. This enhances understanding beyond the schema.

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 retrieves perpetual futures funding rates across six named venues, specifying the exact data returned. It distinguishes itself from sibling tools like get_crypto_prices and get_dex_quotes by focusing on funding rates and arbitrage analysis.

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

Usage Guidelines4/5

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

The description is clear about what the tool does and its output, including arbitrage opportunities, which implies usage for spread analysis. However, it does not explicitly state when not to use it or mention alternatives, though the context from sibling names provides indirect differentiation.

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/fernsugi/x402-api-mcp-server'

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