Smart Router
A tool that provides better trading strategy
Last updated
A tool that provides better trading strategy
Last updated
To help users boost returns, SUN.io has rolled out the Smart Router feature, which plays an essential role in the following aspects:
Executing trades at the best price: The Smart Router finds the best price for traders by choosing the optimal path to execute trades based on the price difference across markets. This means users get more favorable trade prices at execution to maximize returns.
Enhancing liquidity: The Smart Router utilizes the liquidity of different markets to provide better depth and liquidity for traders. By executing trades across multiple liquidity pools, it reduces slippage and market shocks, thus offering an enhanced trading experience.
Improving liquidity utilization: The Smart Router helps improve the utilization of liquidity. By channeling liquidity from highly liquid markets to less liquid ones, it helps improve the overall utilization of liquidity and enables the completion of more trades.
SUN.io's Smart Router algorithm service retrieves data from SunSwap V1, SunSwap V2, SunSwap V3, PSM, and SunCurve by utilizing the contract image built on the server. It sorts trade paths by the amount of the token users can obtain and displays the top three as options for users. The contract of the Smart Router is a nested contract through which the liquidity pools on SunSwap V1, SunSwap V2, SunSwap V3, PSM, and SunCurve can be called to complete trades.
Contract address on Mainnet: TJ4NNy8xZEqsowCBhLvZ45LCqPdGjkET5j
TFVisXFaijZfeyeSjCEVkHfex7HGdTxzF9(deprecated)
Contract address on Nile testnet: TB6xBCixqRPUSKiXb45ky1GhChFJ7qrfFj
Smart Router algorithm service URL: https://rot.endjgfsv.link/swap/router
We utilize TronWeb to facilitate interaction with on-chain contracts. First, you need to initialize the TronWeb instance.
Smart Router algorithm service endpoint
Type: GET
Parameters:
Name | Description |
---|---|
fromToken | Address of fromToken |
toToken | Address of toToken |
amountIn | Amount of the token to be swapped |
typeList | Types available for the swap (PSM,CURVE,CURVE_COMBINATION,WTRX,SUNSWAP_V1,SUNSWAP_V2,SUNSWAP_V3) |
Return
Name | Description |
---|---|
amountIn | Amount of the token entered (divided by precision) |
amountOut | Amount of the token that can be swapped for, calculated by the Smart Router (divided by precision) |
InUsd | USD price of the entered token |
OutUsd | USD price of the token to be swapped for |
impact | Price impact |
fee | Transaction fee |
tokens | Addresses of the tokens that the path from fromToken to toToken involves |
symbols | Symbols of the tokens that the path from fromToken to toToken involves |
poolFees | Transaction fees of the liquidity pools that the path from fromToken to toToken involves (0 is displayed for non-SunSwap V3 pools) |
poolVersions | Versions of the liquidity pools that the path from fromToken to toToken involves |
stepAmountsOut | Amounts of the tokens obtained from each pool along the path from fromToken to toToken |
Trade
Name: swapExactInput( address[], string[], uint256[], uint24[], SwapData)
Parameters: array of paths, array of pool versions, array of lengths of adjacent pool versions, array of fee rates, [amount of the token to be swapped, minimum acceptable amount of the token obtained from the swap, address to receive the token obtained from the swap, deadline].