Calculation Service
SUN.io Smart Routing Calculation Service implements full graph search on SunSwap V1, SunSwap V2, SunSwap V3, PSM, and SunCurve by building contract mirrors on the server. It sorts the paths based on the amount of tokens exchanged and returns the top three paths that yield the most tokens to the user.
Smart Routing Calculation Service URL: https://rot.endjgfsv.link/swap/router
Smart Routing Calculation Service Interface
Name: https://rot.endjgfsv.link/swap/router
Type: GET
Parameters:
fromToken
fromToken address
toToken
toToken address
amountIn
Amount of tokens to exchange (excluding precision)
typeList
Available exchange types (PSM,CURVE,CURVE_COMBINATION,WTRX,SUNSWAP_V1,SUNSWAP_V2,SUNSWAP_V3)
Return Values:
amountIn
Input token amount (excluding precision)
amountOut
Amount of tokens that can be exchanged through routing calculation (excluding precision)
inUsd
Input token price in USD
outUsd
Output token price in USD
impact
Price impact
fee
Transaction fee
tokens
Token addresses in the path from fromToken to toToken
symbols
Token symbols in the path from fromToken to toToken
poolFees
Fee rates of pools in the path from fromToken to toToken (non-SunSwap V3 versions show 0)
poolVersions
Versions of pools in the path from fromToken to toToken
stepAmountsOut
Amount of tokens exchanged at each pool in the path from fromToken to toToken
Example
Input the token address to be exchanged, amount, and available pool types. (This example gets the optimal three paths for exchanging TRX for USDJ)
WTRX mainnet contract address: TNUC9Qb1rRpS5CbWLmNMxXBjyFoydXjWFR
USDJ mainnet contract address: TMwFHYXLJaRUPeW6421aqXL4ZEzPRFGkGT
Output of the three optimal paths