Skip to main content
Glama

arb.spread_matrix

Calculate net arbitrage spread between Coinbase spot and DEX pool prices after gas costs to determine if a cross-venue trade is profitable.

Instructions

CEX-DEX arbitrage spread calculator: checks whether a global reference
price (Coinbase spot, CoinGecko fallback - NOT a specific exchange
orderbook, despite internal naming) and a DEX pool price (GeckoTerminal)
diverge enough to be worth trading after an assumed flat gas cost. Returns
gross/net spread, direction, and is_profitable.

Use this before executing a cross-venue arbitrage trade, or for kimchi-style
premium checks on non-Korean venues (use market.kimchi_alert instead for the
Upbit-specific case). net_spread_pct does NOT subtract the DEX pool's own
swap fee (see pool_fee_pct, typically 0.05-1%), CEX trading fees, CEX
deposit/withdrawal availability, or slippage beyond trade_size_usd - a
spread that clears the threshold before those costs may not clear it after,
so always re-verify with live quotes before executing. Requires exactly one
of pool_address or token_address; passing neither raises "invalid_input".

Args:
    symbol: Ticker symbol, e.g. "SUI", "BTC", "ETH".
    network: GeckoTerminal network id (default "base").
    trade_size_usd: Hypothetical trade size in USD (default 1000.0).
    min_spread_threshold_pct: Net spread threshold (%) above which
        is_profitable is true (default 0.8).
    pool_address: A specific DEX pool contract address.
    token_address: Token contract address (auto-picks the most liquid pool).
        One of pool_address or token_address is required.

Returns:
    On success: {"success": true, "gross_spread_pct", "net_spread_pct",
        "direction", "is_profitable", ...}
    On failure: {"success": false, "error": {"type", "message"}}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
networkNobase
pool_addressNo
token_addressNo
trade_size_usdNo
min_spread_threshold_pctNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.3

TDQS

A5/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It transparently reveals that net_spread_pct does NOT subtract pool swap fees, CEX fees, deposit/withdrawal availability, or slippage beyond trade_size_usd, and warns that a spread clearing the threshold may not be profitable after those costs. It also mentions the invalid_input error for missing addresses and the fallback price source logic. This is exemplary transparency.

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 dense but well-structured: purpose, usage, caveats, parameter list, and return format are clearly separated. Each sentence adds value—no filler. The caveats about fee exclusions are essential and not redundant. Despite length, it's warranted given the tool's complexity and lack of schema documentation.

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

Completeness5/5

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

Given six parameters, no output schema, and no annotations, the description covers all necessary aspects: what the tool does, when to use it, parameter semantics, return structure (success/failure), and critical limitations. Nothing an agent needs to decide correctness or call the tool properly is missing.

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

Parameters5/5

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

Schema description coverage is 0%, so the description is the sole source of parameter meaning. It provides examples for symbol, explains network's GeckoTerminal id default, clarifies trade_size_usd as hypothetical USD size, min_spread_threshold_pct as the threshold for is_profitable, and distinguishes pool_address (specific pool) from token_address (auto-picks most liquid pool) with the required-one constraint. Every parameter is fully explained beyond its type/name.

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 states a specific verb ('checks whether... diverge enough to be worth trading') on a clear resource (CEX-DEX arbitrage spread) and differentiates from sibling market.kimchi_alert by explicitly noting when to use that alternative instead. The distinction between Coinbase/CoinGecko reference and GeckoTerminal DEX price is precise, leaving no ambiguity about what the tool computes.

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

Usage Guidelines5/5

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

The description explicitly says to use this before executing cross-venue arbitrage or for non-Korean kimchi-style checks, and names market.kimchi_alert as the alternative for Upbit-specific cases. It also states the requirement of exactly one of pool_address or token_address, clarifying the input constraint. This gives clear when-to-use and when-not-to-use guidance.

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