BTB
/

SUNSwap V2

Dexswebsite
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.

What you can do

quoteQuote a V2 swapRouter.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-tokenSwap TRC-20 to TRC-20approve(Router, amountIn) on tokenIn, then Router.swapExactTokensForTokens(amountIn, amountOutMin, path, to, nowSec+600)
swap-trx-for-tokenSell TRXRouter.swapExactETHForTokens(amountOutMin, [WTRX, token], to, deadline) with callValue = TRX amount in sun
swap-token-for-trxBuy TRXapprove Router, then Router.swapExactTokensForETH(amountIn, amountOutMin, [token, WTRX], to, deadline)
add-liquidityProvide liquidityapprove both tokens to Router; Router.addLiquidity(...) or addLiquidityETH(token, ..., to, deadline) with TRX callValue
remove-liquidityWithdraw liquidityFactory.getPair(a,b) -> approve pair LP to Router -> Router.removeLiquidity(...) / removeLiquidityETH(...)
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).

Contracts

Read any function, or build a write and sign it. Amounts are in base units (1 USDC = 1000000).
SunSwap V2 Router (UniswapV2Router02)router on tronTNJVzGqKBWkJxJB5XYSqGAwUTV15U24pPq
read getAmountsOut(uint256,address[])
Quote: amounts along path for an exact input (amountIn in the input token's base units). Includes the 0.3% fee per hop. Use WTRX TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR in the path for TRX. Apply slippage to the last element to get amountOutMin.
read getAmountsIn(uint256,address[])
Quote: required input for an exact output along path.
write swapExactTokensForTokens(uint256,uint256,address[],address,uint256)
(amountIn, amountOutMin, path, to, deadline). Sell an exact amount of a TRC-20 for another TRC-20. Approve the Router on the input token first. deadline is a Unix timestamp in seconds. Path hops must be existing V2 pairs.
write swapExactETHForTokens(uint256,address[],address,uint256)
(amountOutMin, path, to, deadline). Sell exact native TRX (callValue in sun, 1 TRX = 1e6 sun); path must start with WTRX TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR. "ETH" in V2 names means TRX.
write swapExactTokensForETH(uint256,uint256,address[],address,uint256)
(amountIn, amountOutMin, path, to, deadline). Sell a TRC-20 for native TRX; path must end with WTRX. Approve the Router first.
write swapTokensForExactTokens(uint256,uint256,address[],address,uint256)
(amountOut, amountInMax, path, to, deadline). Buy an exact output amount spending at most amountInMax.
write swapExactTokensForTokensSupportingFeeOnTransferTokens(uint256,uint256,address[],address,uint256)
Same as swapExactTokensForTokens but for tokens that take a fee on transfer; returns nothing.
write addLiquidity(address,address,uint256,uint256,uint256,uint256,address,uint256)
(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin, to, deadline). Add liquidity to a TRC-20/TRC-20 pair (created automatically if missing); LP tokens go to `to`. Approve both tokens to the Router.
write addLiquidityETH(address,uint256,uint256,uint256,address,uint256)
(token, amountTokenDesired, amountTokenMin, amountETHMin, to, deadline). Add liquidity to a token/TRX pair; send TRX as callValue (wrapped to WTRX).
write removeLiquidity(address,address,uint256,uint256,uint256,address,uint256)
(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline). Burn LP for both tokens. Approve the pair (LP token) to the Router first.
write removeLiquidityETH(address,uint256,uint256,uint256,address,uint256)
(token, liquidity, amountTokenMin, amountETHMin, to, deadline). Burn LP of a token/WTRX pair, receive the token and native TRX.
read WETH()
Returns WTRX TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR (checked on-chain).
read factory()
Returns the V2 Factory TKWJdrQkqHisa1X8HUdHEfREvTzw4pMAaY (checked on-chain).
SunSwap V2 Factory (UniswapV2Factory)factory on tronTKWJdrQkqHisa1X8HUdHEfREvTzw4pMAaY
read getPair(address,address)
Pair (pool/LP token) address for two tokens; zero address if none. Use WTRX for TRX. Pairs expose standard Uniswap V2 getReserves(), token0(), token1(), totalSupply().
read allPairsLength()
Number of pairs created.
read allPairs(uint256)
Pair address by index.
write createPair(address,address)
Permissionless pair creation (addLiquidity also creates the pair if missing).
read feeTo()
Protocol fee recipient (the 0.05% SUN buyback-and-burn share).
WTRX (Wrapped TRX)token on tronTNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR
write deposit()
Wrap TRX (callValue in sun) into WTRX 1:1. 6 decimals.
write withdraw(uint256)
Unwrap WTRX to TRX.
write approve(address,uint256)
Approve a spender such as the V2 Router.
read balanceOf(address)
WTRX balance (6 decimals).
SUN token (TRC-20)token on tronTSSMHYeV2uE9qYH95DqyoCuNCzEL1NvU3S
read balanceOf(address)
SUN balance (18 decimals).
write transfer(address,uint256)
Transfer SUN.
write approve(address,uint256)
Approve a spender, e.g. the V2 Router.
SUN.io Smart Router (SmartExchangeRouter)router on tronTGnC7LMji8hBpyvZt1TTEJhVpAZ5HFyJ3r
write swapExactInput(address[],string[],uint256[],uint24[],(uint256,uint256,address,uint256))
(path, poolVersion, versionLen, fees, data=(amountIn, amountOutMin, to, deadline)). Multi-protocol swap across SunSwap V1/V2/V3, PSM and curve pools, typically fed by the routing API output (pool names e.g. 'v1','v2','v3'; versionLen counts tokens per segment, first entry +1; fees all 0 except V3 hops, last entry 0). Use address T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb (zero address) for native TRX and send callValue = amountIn. Approve input TRC-20 to this router.