V1 Functions
Get Liquidity Information
getExchange
Description: Get liquidity pool address
Calling Contract: Factory
Parameters:
token
address
Token address
Return Value: Pool address
Example: Find the TRX/USDT pool address
Return:
Add/Remove Liquidity
addLiquidity
Description: add liquidity
Calling Contract: pool
Parameters:
min_liquidity
uint256
Minimum expected liquidity to receive
max_tokens
uint256
Maximum amount to add as liquidity
deadline
uint256
Unix timestamp after which the transaction will revert
Return Value: hash
Example: Add liquidity to the TUSD/USDT pool
removeLiquidity
Description: remove liquidity
Calling Contract: pool
Parameters:
amount
uint256
Amount of liquidity to remove
min_trx
uint256
Minimum expected amount of TRX to receive
min_tokens
uint256
Minimum expected amount of Token to receive
deadline
uint256
Unix timestamp after which the transaction will revert
Return Value: hash
Example: Remove liquidity from the TUSD/USDT pool
Execute Exchange
trxToTokenSwapInput
Description: Sell TRX to buy Token (specify the amount of TRX to sell)
Calling Contract: pool
Parameters:
min_tokens
uint256
Minimum expected purchase amount
deadline
uint256
Unix timestamp after which the transaction will revert
Return Value: hash
Example: Sell TRX to Buy USDT
tokenToTrxSwapInput
Description: Sell Token to buy TRX (specify the amount of Token to sell)
Calling Contract: pool
Parameters:
tokens_sold
uint256
Amount of tokens sold
min_trx
uint256
Minimum expected amount of TRX to purchase
deadline
uint256
Unix timestamp after which the transaction will revert
Return Value: hash
Example: Sell USDT to Buy TRX
trxToTokenSwapOutput
Description: Sell TRX to buy Token (specify the amount of Token to buy)
Calling Contract: pool
Parameters:
tokens_bought
uint256
Amount of tokens bought
deadline
uint256
Unix timestamp after which the transaction will revert
Return Value: hash
Example: Sell TRX to Buy Token
tokenToTrxSwapOutput
Description: Sell Token to buy TRX (specify the amount of TRX to buy)
Calling Contract: pool
Parameters:
trx_bought
uint256
Amount of TRX bought
max_tokens
uint256
Maximum amount of tokens to sell
deadline
uint256
Unix timestamp after which the transaction will revert
Return Value: hash
Example: Sell Token to Buy TRX
trxToTokenTransferInput
Description: Sell TRX to buy Token (specify recipient address)
Calling Contract: pool
Parameters:
min_tokens
uint256
Minimum expected purchase amount
deadline
uint256
Unix timestamp after which the transaction will revert
recipient
address
Recipient address
Return Value: hash
Example: Sell TRX to Buy Token
tokenToTrxTransferInput
Description: Sell Token to buy TRX (specify recipient address)
Calling Contract: pool
Parameters:
tokens_sold
uint256
Amount of tokens sold
min_trx
uint256
Minimum expected amount of TRX to receive
deadline
uint256
Unix timestamp after which the transaction will revert
recipient
address
Recipient address
Return Value: hash
Example: Sell Token to Buy TRX
tokenToTokenSwapInput
Description: Sell Token to buy Token (bridged via TRX)
Calling Contract: pool
Parameters:
tokens_sold
uint256
Amount of tokens sold
min_tokens_bought
uint256
Minimum expected amount of tokens to receive
min_trx_bought
uint256
Minimum expected amount of TRX to receive
deadline
uint256
Unix timestamp after which the transaction will revert
token_addr
address
Address of the token to buy
Return Value: hash
Example: Sell USDT to Buy SUN
Last updated