Skip to main content
Glama

Buy a token

trnch_buy

Build a buy in one call: quotes eight routers and returns the best route as a transaction for the key's wallet to sign. Give tokenId or token, and amountUsd (paid in USDG) or amountIn with tokenIn. The Trnch fee (0.25% standard, 0.10% between major assets, 0.05% between a Stock Token and a major asset, 0.50% for tokens under 24 h old or with no known launch time; the rate applied is returned as feeBps) is already deducted from the quote. Returns { router, feeBps, quote, approval, tx, chainId, from }: approval, when not null, has to be sent before tx, from the same wallet (chainId 4663). Nothing is sent by Trnch. Errors: 409 token not tradable through Trnch (kept out by Trnch), 429 rate or build limit (retry-after). A partner's integrator fee (integratorFeeBps, or the partner's default fee when the request carries X-Trnch-Partner-Key) is added to the Trnch fee and taken by the same router fee on every router; a router whose maximum fee is below the total is left out of the quote. The integrator fee is paid to the partner through the Trnch partner program after the swap is confirmed on chain. fees in the response: { side, token, trnch { bps, amount }, integrator { bps, amount, partner } or null, minAmountOut }, amounts in the smallest unit; minAmountOut is net of both fees and of slippage. Requires an API key (created by wallet signature), sent as Authorization: Bearer .

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "trnch_buy"
  }
}

Input Schema

NameRequiredDescriptionDefault
tokenNoToken to buy, as an address. Use this or tokenId.
tokenIdNoOpaque token id from the Heat feed (field id). Use this or token.
tokenInNoToken paid with amountIn. Default USDG.
amountInNoAmount of tokenIn to spend, smallest unit. Use this or amountUsd.
amountUsdNoAmount to spend in US dollars, paid in USDG. Use this or amountIn.
slippageBpsNoMax slippage in basis points (100 = 1%). Default 100, raised to a known token tax + 1% up to 15%; above that, required.
integratorFeeBpsNoIntegrator fee in basis points, 0 to 100, for a partner identified by X-Trnch-Partner-Key or by the partner ref of the API key. Overrides the partner's default fee; the default fee applies only with X-Trnch-Partner-Key, never through the partner ref of the API key alone. Without a partner, a value above 0 is refused.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • changedInput schema / properties / integratorFeeBps / description
      Previous value: -"Optional integrator fee in basis points, 0 to 100. Added to the Trnch fee and paid by the router to integratorRecipient in the same transaction. Default 0."New value: +"Integrator fee in basis points, 0 to 100, for a partner identified by X-Trnch-Partner-Key or by the partner ref of the API key. Overrides the partner's default fee; the default fee applies only with X-Trnch-Partner-Key, never through the partner ref of the API key alone. Without a partner, a value above 0 is refused."
    • removedInput schema / properties / integratorRecipient
      Removed value: -{
      -  "description": "EVM address that receives the integrator fee. Required when integratorFeeBps is above 0; the zero address is refused.",
      -  "pattern": "^0x[0-9a-fA-F]{40}$",
      -  "type": "string"
      -}
  2. Changed2 schema fields changed
    • addedInput schema / properties / integratorFeeBps
      Added value: +{
      +  "description": "Optional integrator fee in basis points, 0 to 100. Added to the Trnch fee and paid by the router to integratorRecipient in the same transaction. Default 0.",
      +  "maximum": 100,
      +  "minimum": 0,
      +  "type": "integer"
      +}
    • addedInput schema / properties / integratorRecipient
      Added value: +{
      +  "description": "EVM address that receives the integrator fee. Required when integratorFeeBps is above 0; the zero address is refused.",
      +  "pattern": "^0x[0-9a-fA-F]{40}$",
      +  "type": "string"
      +}
  3. Changed1 schema field changed
    • changedInput schema / properties / slippageBps / description
      Previous value: -"Max slippage in basis points (100 = 1%). Default 100."New value: +"Max slippage in basis points (100 = 1%). Default 100, raised to a known token tax + 1% up to 15%; above that, required."
  4. Changed1 schema field changed
    • changedInput schema / properties / tokenId / description
      Previous value: -"Opaque token id from trnch_heat (field id). Use this or token."New value: +"Opaque token id from the Heat feed (field id). Use this or token."
  5. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Beyond the annotations (which only say it is a non-idempotent, non-destructive, open-world write), the description discloses the full fee schedule with tier conditions, that fees are pre-deducted from the quote, that Trnch sends nothing on chain, the exact response shape and field meanings, the approval-before-tx ordering, and error semantics (409 untradable, 429 with retry-after). That is unusually rich behavioral context for a mutation tool.

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?

Purpose, fee, return and error information are front-loaded and there is no filler, but the single dense block mixes response-shape, fee-tier and partner-fee semantics together, and the fee topic is revisited across three separate clauses. Restructuring would improve scannability without losing content.

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?

There is no output schema, so the description must carry return semantics, and it does: the response object's fields, the nested fees structure, and unit conventions (smallest unit) are all documented. Auth, error handling, and the pre-signing approval step are also covered, leaving nothing material an agent would need before invoking it.

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 100%, so baseline is 3, but the description adds real meaning: amountUsd is settled in USDG, integratorFeeBps overrides the partner default and is only honored with X-Trnch-Partner-Key, a non-zero value without a partner is refused, and routers whose max fee is below the combined fee are excluded. It also explains that minAmountOut is net of both fees and slippage, which the schema does not convey.

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 opening clause states a specific verb and resource ('Build a buy in one call'), plus the mechanism (quotes eight routers, returns the best route as a signable transaction). It is distinguishable from trnch_sell and trnch_quote by the build-a-transaction framing without needing to compare schemas.

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?

It specifies the mutually exclusive input pairs (tokenId or token, amountUsd or amountIn), the auth prerequisite (API key as Bearer), and the operational prerequisite that approval must be sent before tx from the same wallet. It does not explicitly say when to use trnch_quote trnch_check or trnch_confirm instead, so routing among siblings is left partly implicit.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources