Skills tron-swap
This skill should be used when the user asks to 'swap tokens on TRON', 'buy token on TRON', 'sell TRC-20 token', 'trade TRX for USDT', 'exchange tokens on SunSwap', 'DEX trade on TRON', 'get swap quote on TRON', 'best route for TRON swap', or mentions swapping, trading, buying, selling, or exchanging tokens on the TRON network. Aggregates liquidity from SunSwap V2/V3, Sun.io, and other TRON DEXes. Do NOT use for staking — use tron-staking. Do NOT use for token research — use tron-token.
git clone https://github.com/openclaw/skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/openclaw/skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/bbsyaya/tronlink-skills/skills/tron-swap" ~/.claude/skills/openclaw-skills-tron-swap && rm -rf "$T"
T=$(mktemp -d) && git clone --depth=1 https://github.com/openclaw/skills "$T" && mkdir -p ~/.openclaw/skills && cp -r "$T/skills/bbsyaya/tronlink-skills/skills/tron-swap" ~/.openclaw/skills/openclaw-skills-tron-swap && rm -rf "$T"
skills/bbsyaya/tronlink-skills/skills/tron-swap/SKILL.mdTRON DEX Swap
3 commands for swap quote, route optimization, and transaction status tracking (read-only queries).
Pre-flight Checks
-
Confirm Python & dependencies:
node -e "console.log('ok')" # Node.js >= 18 required -
Check energy before swapping: Swaps consume significant Energy (typically 50,000–200,000). Run:
node scripts/tron_api.mjs resource-info --address <YOUR_ADDRESS>If energy is insufficient, consider freezing TRX first (
) or accept TRX burn cost.tron-staking
Commands
1. Swap Quote
node scripts/tron_api.mjs swap-quote \ --from-token <FROM_CONTRACT_OR_TRX> \ --to-token <TO_CONTRACT_OR_TRX> \ --amount <HUMAN_READABLE_AMOUNT>
Returns: expected output amount, price impact, route path, minimum received (with slippage), estimated energy cost.
⚠️ Amount is human-readable — pass
100 for 100 TRX, NOT 100000000.
Example:
# Quote: 100 TRX → USDT node scripts/tron_api.mjs swap-quote \ --from-token TRX \ --to-token TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t \ --amount 100
2. Best Route
node scripts/tron_api.mjs swap-route \ --from-token <FROM_CONTRACT> \ --to-token <TO_CONTRACT> \ --amount <AMOUNT>
Returns: optimal route across SunSwap V2, V3, Sun.io — may include multi-hop routes (e.g., TRX → WTRX → USDT).
3. Transaction Status
node scripts/tron_api.mjs tx-status --txid <TRANSACTION_HASH>
Returns: confirmation status, block number, energy used, bandwidth used, result.
DEX Router Addresses (Mainnet)
| DEX | Router Contract |
|---|---|
| SunSwap V2 Router | |
| SunSwap V3 Router | |
| Sun.io Swap | |
Swap Cost Estimation
TRON swap costs differ from EVM chains:
| Operation | Bandwidth | Energy | TRX Burn (if no resources) |
|---|---|---|---|
| TRX → TRC-20 | ~345 | ~65,000 | ~13 TRX |
| TRC-20 → TRX | ~345 | ~50,000 | ~10 TRX |
| TRC-20 → TRC-20 | ~345 | ~130,000 | ~26 TRX |
| Approve (first time) | ~345 | ~30,000 | ~6 TRX |
⚠️ Energy costs fluctuate. Always check current energy price:
node scripts/tron_api.mjs energy-price
Slippage Guide
| Token Type | Recommended Slippage |
|---|---|
| Stablecoins (USDT↔USDC) | 0.1% |
| Major tokens (TRX, JST, SUN) | 0.5% |
| Mid-cap tokens | 1-2% |
| Low-cap / Meme tokens | 3-5% |
| New launches | 5-10% (⚠️ high risk) |
Safety Checks Before Swap
- Security audit: Run
before trading unfamiliar tokensnode scripts/tron_api.mjs token-security --contract <TOKEN> - Liquidity check: Run
— avoid tokens with < $10k liquiditynode scripts/tron_api.mjs pool-info --contract <TOKEN> - Energy check: Run
— swap without energy burns TRXnode scripts/tron_api.mjs resource-info --address <YOUR_ADDRESS> - Price impact: If price impact > 3%, consider splitting into smaller trades