V2 Functions
Get Liquidity Information
getPair
Description: Get the liquidity pool address
Contract called: Factory
Parameters:
tokenA
address
The address of tokenA
tokenB
address
The address of tokenB
Return value: Pool address
Example: Query the pool address for TRX/USDT
Return
TKioHQsGLkaEWwBwkUB2T4Rm6nwGATtJyh
Add/Remove Liquidity
addLiquidity
Description: Add liquidity (tokenA and tokenB do not include TRX)
Contract called: Router
Parameters:
tokenA
address
The address of tokenA
tokenB
address
The address of tokenB
amountADesired
uint256
The desired amount of tokenA to add
amountBDesired
uint256
The desired amount of tokenB to add
amountAMin
uint256
The minimum amount of tokenA to add
amountBMin
uint256
The minimum amount of tokenB to add
to
address
The recipient of the liquidity tokens
deadline
uint256
Unix timestamp after which the transaction will revert
Return value: hash
Example: Add liquidity to the TUSD/USDT pool
addLiquidityETH
Description: Add liquidity (One of the tokens is TRX)
Contract called: Router
Parameters:
token
address
The address of the token to add liquidity for
amountTokenDesired
uint256
The desired amount of token to add
amountTokenMin
uint256
The minimum amount of token to add
amountETHMin
uint256
The minimum amount of TRX to add
to
address
The recipient of the liquidity tokens
deadline
uint256
Unix timestamp after which the transaction will revert
Return value: hash
Example: Add liquidity to the TRX/USDT pool
removeLiquidity
Description: Remove liquidity (tokenA and tokenB do not include TRX)
Contract called: Router
Parameters:
tokenA
address
The address of tokenA
tokenB
address
The address of tokenB
liquidity
uint256
The amount of liquidity tokens to remove
amountAMin
uint256
The minimum amount of tokenA to receive
amountBMin
uint256
The minimum amount of tokenB to receive
to
address
The recipient of the tokens
deadline
uint256
Unix timestamp after which the transaction will revert
Return value: hash
Example: Remove liquidity from the TUSD/USDT pool
removeLiquidityETH
Description: Remove liquidity (One of the tokens is TRX)
Contract called: Router
Parameters:
token
address
The address of the token to remove liquidity for
liquidity
uint256
The amount of liquidity tokens to remove
amountTokenMin
uint256
The minimum amount of token to receive
amountETHMin
uint256
The minimum amount of TRX to receive
to
address
The recipient of the tokens
deadline
uint256
Unix timestamp after which the transaction will revert
Return value: hash
Example: Remove liquidity from the TRX/USDT pool
Execute Swap
swapExactTokensForTokens
Description: Sell Token to Buy Token
Contract Called: Router
Parameters:
amountIn
uint256
The amount of input tokens to send
amountOutMin
uint256
The minimum amount of output tokens to receive
path
address[]
An array of token addresses, ordered from input to output
to
address
The recipient of the output tokens
deadline
uint256
Unix timestamp after which the transaction will revert
Return value: hash
Example: Sell USDT to Buy SUN
swapExactETHForTokens
Description: Sell TRX to Buy Token
Contract Called: Router
Parameters:
amountOutMin
uint256
The minimum amount of output tokens to receive
path
address[]
An array of token addresses, ordered from input (WTRX) to output
to
address
The recipient of the output tokens
deadline
uint256
Unix timestamp after which the transaction will revert
Return value: hash
Example: Sell TRX to Buy USDT
swapExactTokensForETH
Description: Sell Token to Buy TRX
Contract Called: Router
Parameters:
amountIn
uint256
The amount of input tokens to send
amountOutMin
uint256
The minimum amount of TRX to receive
path
address[]
An array of token addresses, ordered from input to output (WTRX)
to
address
The recipient of the output TRX
deadline
uint256
Unix timestamp after which the transaction will revert
Return value: hash
Example: Sell USDT to Buy TRX
Last updated