Skip to main content
Glama

prepare_sunswap_swap

DestructiveIdempotent

Builds an unsigned SunSwap V2 same-chain swap on TRON, handling TRX and TRC-20 tokens with automatic path encoding, allowance verification, and slippage protection.

Instructions

Build an unsigned SunSwap V2 same-chain swap on TRON. SunSwap V2 is a Uniswap-V2 fork; this tool routes through the V2 router (TNJVzGqKBWkJxJB5XYSqGAwUTV15U24pPq) using the standard swapExactETHForTokens / swapExactTokensForETH / swapExactTokensForTokens selectors based on which side is native TRX. Path encoding: TRX→TRC20 = [WTRX, toToken]; TRC20→TRX = [fromToken, WTRX]; TRC20→TRC20 = [fromToken, WTRX, toToken]. The builder (1) calls getAmountsOut on the router via /triggerconstantcontract to compute the expected output, (2) derives minOut as quotedOut * (10000 - slippageBps) / 10000, (3) for TRC-20 sources, reads allowance(wallet, router) and refuses with a recovery hint if insufficient — the user must run prepare_tron_trc20_approve(token, spender=router, amount) first, broadcast it, wait ~3s for it to land, then retry. (4) hand-rolls ABI calldata for the swap call (no SDK), (5) hits TronGrid /triggersmartcontract to build the tx, (6) verifies the returned raw_data_hex matches exactly what we asked for (selector + parameter + call_value + fee_limit) and refuses any drift. BLIND-SIGN on Ledger TRON app — the SunSwap router is not in the device's clear-sign allowlist. Enable "Allow blind signing" in the on-device TRON app Settings; the device shows the txID, which the user matches against the txID in the prepare receipt. Pair the Ledger via pair_ledger_tron first. Smart Router (V1+V2+V3+PSM aggregator) is intentionally not used — V2 router only — because Smart Router's mainnet address has not been published officially and its multi-version path encoding is a different ABI shape.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletYesTRON base58 wallet (T-prefixed, 34 chars) — funds the swap and signs the source tx on Ledger via USB. Pair via `pair_ledger_tron` first.
fromTokenYesSource token. Either the literal string "TRX" for native TRX, OR a T-prefixed TRC-20 contract address. TRC-20 source REQUIRES a prior approve to the SunSwap V2 router (TNJVzGqKBWkJxJB5XYSqGAwUTV15U24pPq) — this tool checks allowance up-front and refuses with a recovery hint if insufficient.
toTokenYesDestination token. Either the literal "TRX" or a T-prefixed TRC-20 contract address. Cannot equal fromToken.
amountYesHuman-readable amount of fromToken (e.g. "100" for 100 TRX, "10.5" for 10.5 USDT). Decimals are resolved from the canonical TRC-20 set (USDT/USDC/USDD/TUSD) or from `fromTokenDecimals` for non-canonical tokens.
slippageBpsNoSlippage tolerance in basis points (50 = 0.5%). Default 50.
deadlineSecondsNoDeadline window in seconds from now. Default 1200 (20 min). The router rejects the swap if it hasn't landed by then.
fromTokenDecimalsNoREQUIRED when fromToken is a non-canonical TRC-20 (i.e. not USDT/USDC/USDD/TUSD or "TRX"). We refuse to guess decimals on a swap because an off-by-power-of-ten amountIn silently exposes the user to ~10^N-fold larger slippage than intended.
toTokenDecimalsNoREQUIRED when toToken is a non-canonical TRC-20. Same reasoning as `fromTokenDecimals`.
feeLimitTrxNoOverride the energy fee_limit cap (default 100 TRX). Pass a human-readable TRX amount (e.g. "50"). Energy estimate is reported separately in `estimatedEnergyCostSun`.
Behavior5/5

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

Annotations indicate destructiveHint=true and idempotentHint=true, but description adds extensive behavioral context: steps, verification, refusal conditions, blind-signing requirement. No contradiction with annotations.

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?

Description is lengthy but every sentence adds value. Well-structured with clear steps and details. Could be slightly more concise, but still highly effective.

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 complexity and absence of output schema, description covers input, process, error handling, and prerequisites comprehensively. No gaps.

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 coverage is 100%, but description adds significant meaning beyond schema: explains each parameter's role, edge cases (non-canonical decimals), and refusal reasons (e.g., insufficient allowance).

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?

Description clearly states it builds an unsigned SunSwap V2 same-chain swap on TRON, specifies router address, selectors, and path encoding. Distinguishes from sibling tools like prepare_swap and other swap-related tools.

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?

Explicitly states when to use (SunSwap V2 only, not Smart Router) and prerequisites (approve TRC-20, pair Ledger, enable blind signing). Provides detailed process and error recovery hints.

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/szhygulin/recon-crypto-mcp'

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