BTB Finance for agents

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

What an agent can do

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

Contracts

tron

ContractAddressKey functionsTry
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

Researched 2026-11-25. Addresses are copied from the official sources above; check them before moving large amounts.