Protocols / Dexs
SUNSwap V2
Uniswap-V2-style constant-product DEX on TRON run by SUN.io (Factory + Router02 + per-pair contracts, 0.3% fee). An agent can swap TRC-20 tokens and TRX, quote with getAmountsOut, add/remove liquidity and look up pairs on-chain, or get best routes across SunSwap V1/V2/V3/V4, PSM and SunCurve from the official SUN.io routing API.
On-chain + APIMIXED5 contractsWebsite · Docs
get_protocol({ "protocol": "sunswap-v2" })Risks an agent should know
- Permissionless pair creation: anyone can list any TRC-20, including scam, copycat or fee-on-transfer/honeypot tokens. Verify token addresses (e.g. against the SUN.io token list) before swapping.
- Router and Smart Router addresses have changed: SUN.io marks older mainnet V2 contracts (TXF1xDbVGdxFGbovmmmXvBGu8ZiE3Lq4mR, TMmRKgwC1hx4azzkXoPzujgQThzF48Actq) and older Smart Routers as deprecated. Use only the current addresses from docs.sun.io.
- Fee 0.3% per hop: 0.25% to LPs and 0.05% used to buy back and burn SUN.
- Uniswap V2 code: Factory feeToSetter can change the protocol fee recipient; Router/Factory/Pairs are not upgradeable proxies (TronGrid shows plain UniswapV2Factory/UniswapV2Router02 contracts).
- TRON resource costs: write calls burn energy/bandwidth; set an adequate feeLimit (docs examples use up to 10,000 TRX for Smart Router) or the tx fails and still costs TRX.
- Audits: SUN.io states its contracts were audited by SlowMist (https://docs.sun.io/get-started/risks); DefiLlama links https://sunswap.com/docs/audit-report_en.pdf. Standard AMM risks: impermanent loss, slippage, MEV.
What an agent can do
| quote | Quote a V2 swap Router.getAmountsOut(amountIn, [tokenIn, ..., tokenOut]) with WTRX for TRX; or GET https://open.sun.io/apiv2/quote/swap/routingInV2 for best multi-protocol route |
| swap-token-for-token | Swap TRC-20 to TRC-20 approve(Router, amountIn) on tokenIn, then Router.swapExactTokensForTokens(amountIn, amountOutMin, path, to, nowSec+600) |
| swap-trx-for-token | Sell TRX Router.swapExactETHForTokens(amountOutMin, [WTRX, token], to, deadline) with callValue = TRX amount in sun |
| swap-token-for-trx | Buy TRX approve Router, then Router.swapExactTokensForETH(amountIn, amountOutMin, [token, WTRX], to, deadline) |
| add-liquidity | Provide liquidity approve both tokens to Router; Router.addLiquidity(...) or addLiquidityETH(token, ..., to, deadline) with TRX callValue |
| remove-liquidity | Withdraw liquidity Factory.getPair(a,b) -> approve pair LP to Router -> Router.removeLiquidity(...) / removeLiquidityETH(...) |
Contracts
tron
| Contract | Address | Key functions | Try |
|---|---|---|---|
| SunSwap V2 Router (UniswapV2Router02) router | TNJVzGqKBWkJxJB5XYSqGAwUTV15U24pPq source | readgetAmountsOut(uint256,address[]) readgetAmountsIn(uint256,address[]) writeswapExactTokensForTokens(uint256,uint256,address[],address,uint256) writeswapExactETHForTokens(uint256,address[],address,uint256) writeswapExactTokensForETH(uint256,uint256,address[],address,uint256) writeswapTokensForExactTokens(uint256,uint256,address[],address,uint256) writeswapExactTokensForTokensSupportingFeeOnTransferTokens(uint256,uint256,address[],address,uint256) writeaddLiquidity(address,address,uint256,uint256,uint256,uint256,address,uint256) +5 more via get_protocol | |
| SunSwap V2 Factory (UniswapV2Factory) factory | TKWJdrQkqHisa1X8HUdHEfREvTzw4pMAaY source | readgetPair(address,address) readallPairsLength() readallPairs(uint256) writecreatePair(address,address) readfeeTo() | |
| WTRX (Wrapped TRX) token | TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR source | writedeposit() writewithdraw(uint256) writeapprove(address,uint256) readbalanceOf(address) | |
| SUN token (TRC-20) token | TSSMHYeV2uE9qYH95DqyoCuNCzEL1NvU3S source | readbalanceOf(address) writetransfer(address,uint256) writeapprove(address,uint256) | |
| SUN.io Smart Router (SmartExchangeRouter) router | TGnC7LMji8hBpyvZt1TTEJhVpAZ5HFyJ3r source | writeswapExactInput(address[],string[],uint256[],uint24[],(uint256,uint256,address,uint256)) |
APIs
| Smart Router calculation service auth: none | https://open.sun.io/apiv2/quote/swap/routingInV2 GET ?fromTokenAddr&toTokenAddr&inAmount (base units) returns the top 3 paths (roadForAddr, pool per hop, amount, impact, fee) across SunSwap V1/V2/V3/V4, PSM and SunCurve; feed into Smart Router swapExactInput. |
| SUN.IO API auth: none | https://open.sun.io Read-only REST (GET, JSON): token prices and search, pools/pairs, user positions, transactions, protocol stats, Universal Router quotes, SUN token data. 10 QPS without key; optional X-API-KEY header for higher limits. |
| SUN MCP Server auth: none | https://mcp.sun.io Official hosted SUN MCP Server: read-only SunSwap data (prices, quotes, pools/APYs, protocol stats, positions) with no wallet credentials. Swaps/liquidity need the self-hosted (local) deployment. |
Notes
VM is TVM (TRON Virtual Machine, EVM-compatible ABI); addresses are base58 T... Every address above is from docs.sun.io and was confirmed via TronGrid getcontract (Router = UniswapV2Router02, Factory = UniswapV2Factory, WTRX, SunToken, SmartExchangeRouter); Router.factory() and Router.WETH() return the listed Factory and WTRX. Testnet (Nile): Factory THomLGMLhAjMecQf9FQjbZ8a1RtwsZLrGE, Router TYMjxCXfqLpMWW1QToP6hbcjpion7EE25p. The often-cited router TKzxdSv2FZKQrEqkKVgp5DcwEXBEKMg2Ax is not on the official contract page and is left out. SUN.io also runs a Universal Router (TQqgNg13s2DjvXhW1ky4v6TsR8wZGvb7Y4, https://docs.sun.io/protocols/universal-router/reference/contract) with Permit2; it is not part of SunSwap V2 and its functions are not documented here. SunSwap V1/V3/V4 are separate protocols. Decimals per SUN CLI docs: TRX/WTRX/USDT 6, SUN/USDD/JST 18. Router function signatures come from the TronGrid ABI and docs.sun.io main-interfaces page. No specific SunSwap V2 exploit was found on official pages.
Sources
- https://defillama.com/protocol/sunswap-v2
- https://api.llama.fi/protocol/sunswap-v2
- https://docs.sun.io/protocols/sunswap-v2/overview
- https://docs.sun.io/protocols/sunswap-v2/reference/contract
- https://docs.sun.io/protocols/sunswap-v2/reference/functions
- https://docs.sun.io/protocols/smart-router/reference/contract
- https://docs.sun.io/protocols/smart-router/reference/swap-functions
- https://docs.sun.io/protocols/smart-router/reference/calculation-service
- https://docs.sun.io/protocols/universal-router/reference/contract
- https://docs.sun.io/api/sun-io-api
- https://docs.sun.io/sun-ai/sun-mcp-server/official-server-access
- https://docs.sun.io/sun-ai/sun-cli/command-guide
- https://docs.sun.io/trade/trading-fee
- https://docs.sun.io/get-started/risks
- https://docs.sun.io/ecosystem/tokenomics/overview
- https://api.trongrid.io/wallet/getcontract
- https://api.trongrid.io/wallet/triggerconstantcontract
Researched 2026-11-25. Addresses are copied from the official sources above; check them before moving large amounts.