Skip to main content
Glama

prepare_sunswap_swap

DestructiveIdempotent

Construct an unsigned SunSwap V2 swap transaction on TRON, supporting TRX and TRC20 pairs with automatic allowance checks and slippage-based minimum output calculation.

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?

Discloses the full 6-step internal process, including allowance check, minOut derivation, hand-rolled ABI, and verification of raw_data_hex. Warns about blind-signing requirement on Ledger, that the router is not in the clear-sign allowlist, and that user must match txID. 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.

Conciseness5/5

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

Well-structured with clear sequential steps and warnings. Every sentence provides essential value given tool complexity. Front-loaded with purpose, then details prerequisites, process, and special considerations.

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?

Complete coverage for a complex tool: explains what, how, prerequisites, error handling, blind-signing risks, and the rationale for not using Smart Router. No output schema, but mentions receipt includes txID. No gaps.

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?

Main description adds significant meaning beyond the 100% schema coverage: explains how fromToken/toToken path encoding works, why decimals are required for non-canonical tokens (off-by-power-of-ten exposure), and how slippageBps is applied mathematically. Slightly above baseline 3 due to algorithmic context.

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 precisely states 'Build an unsigned SunSwap V2 same-chain swap on TRON', clearly identifying the verb, resource, and chain. It distinguishes from siblings by specifying SunSwap V2 (not V3 or Smart Router) and TRON (not Ethereum or Solana), with detailed path encoding.

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 same-chain TRON), prerequisites (prior approve for TRC-20 sources, pair Ledger via pair_ledger_tron), and explicitly excludes Smart Router with reasoning. Provides recovery hints for insufficient allowance.

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/vaultpilot-mcp'

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