Skip to main content
Glama

gdex_preview_trade

Read-only

Converts a trade intent into exact executable quote terms without placing an order, returning a previewId for later execution. Covers spot buys/sells and perpetual opens/closes.

Instructions

Turn an explicit trade intent into exact executable terms without trading: market, side, human and raw amounts, quote source and time, minimum received or limit price, funding plan, expiry (60s). Returns a previewId for gdex_execute_trade. kind=spot (USDC wallet), perp_open, perp_close. For perps give notionalUsd (position size) or marginUsd (collateral), never guess which.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "accountRef": "<accountRef>",
      "kind": "<kind>"
    },
    "name": "gdex_preview_trade"
  }
}

Input Schema

NameRequiredDescriptionDefault
dexNoperp_close: builder DEX for a bare coin
coinNoperp: e.g. BTC, or xyz:TSLA for builder DEXes
kindYes
sideNospot: buy|sell; perp_open: long|short
sizeNoperp_close: contracts to close (omit = full)
chainNospot: chain name or id
amountNospot: USDC to spend (buy) or token amount (sell)
budgetNospot buy: "total" = amount is the most that leaves the wallet, routing and gas included ("spend $20 total"); "trade" (default) = amount buys the token, routing on top up to the shown cap ("buy $20 of X")
slPriceNoperp_open stop-loss
tpPriceNoperp_open take-profit
leverageNoperp_open: leverage (backend: cross on core perps, isolated on builder-DEX markets)
marginUsdNoperp_open: collateral in USD
orderTypeNo
accountRefYesFrom gdex_connect
limitPriceNoperp_open limit price
autoFundingNospot buy: bridge USDC/gas from other chains (default true)
notionalUsdNoperp_open: position size in USD
slippagePctNospot: max slippage %, default 1, max 5
tokenAddressNospot: token contract / mint

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv5.3.0
    • addedInput schema / properties / budget
      Added value: +{
      +  "description": "spot buy: \"total\" = amount is the most that leaves the wallet, routing and gas included (\"spend $20 total\"); \"trade\" (default) = amount buys the token, routing on top up to the shown cap (\"buy $20 of X\")",
      +  "enum": [
      +    "trade",
      +    "total"
      +  ],
      +  "type": "string"
      +}
  2. Addedv5.1.0

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=true, and the description is consistent with that ('without trading'). It adds genuinely non-obvious behavior: a 60-second expiry on the preview, the returned previewId, the funding plan surfaced in the preview, and the exclusivity of notionalUsd vs marginUsd for perps. What it omits is what happens when the preview expires or the quote moves beyond slippage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The purpose is front-loaded in the first clause, and every later sentence (return value, kind enumeration, perp sizing rule) carries distinct information. The opening sentence is dense and runs long, but no sentence is redundant padding for a 19-parameter tool.

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?

For a complex 19-parameter, three-mode trade preview with no output schema, the description covers the critical gaps: what the preview resolves, its 60s lifetime, the previewId handoff, and the modal kind values. Remaining gaps (failure/expiry behavior, how slippage interacts with the preview) are real but secondary.

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?

Schema coverage is already 89%, so the baseline is 3, but the description adds meaning the schema does not: that kind=spot operates on the USDC wallet, and that perp parameters require choosing notionalUsd (position size) or marginUsd (collateral) rather than guessing. That precedence rule is decision-relevant and lives nowhere in 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 uses a specific verb ('Turn an explicit trade intent into exact executable terms') and explicitly negates execution ('without trading'), which distinguishes it cleanly from gdex_execute_trade and the execute_* siblings. It also enumerates exactly what the preview resolves (market, side, amounts, quote source/time, min received, funding plan, expiry).

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 two-step flow is made explicit: the preview returns a previewId consumed by gdex_execute_trade, so an agent knows this precedes execution. It also gives per-tool guidance on when to supply notionalUsd vs marginUsd ('never guess which'). It stops short of stating that a preview is mandatory or naming the execution alternatives it replaces.

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

Deploy Server

Other Tools