💻UFOSwap Router
This is documentation for UFOswap, a released version of the UFOswap protocol.
UfoRouter
Because routers are stateless and do not hold token balances, they can be replaced safely and trustlessly, if necessary. This may happen if more efficient smart contract patterns are discovered, or if additional functionality is desired.
Address
UfoRouter
is deployed at 0x155A5B66705812b54FAe396D05Fd0dFA38BECe46 on the Klaytn mainnet
Read-Only Functions
factory
function factory() external pure returns (address);
Returns factory address
WKLAY
function WKLAY() external pure returns (address);
Returns the WKLAY Address on the Klaytn mainnet
State-Changing Functions
addLiquidity
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
Adds liquidity to an KIP-7⇄KIP-7 pool.
To cover all possible scenarios,
msg.sender
should have already given the router an allowance of at least amountADesired/amountBDesired on tokenA/tokenB.Always adds assets at the ideal ratio, according to the price when the transaction is executed.
If a pool for the passed tokens does not exists, one is created automatically, and exactly amountADesired/amountBDesired tokens are added.
Untitled
tokenA | address | A pool token. |
tokenB | address | A pool token. |
amountADesired | unit | The amount of tokenA to add as liquidity if the B/A price is <= amountBDesired/amountADesired (A depreciates). |
amountBDesired | unit | The amount of tokenB to add as liquidity if the A/B price is <= amountADesired/amountBDesired (B depreciates). |
amountAMin | unit | Bounds the extent to which the B/A price can go up before the transaction reverts. Must be <= amountADesired. |
amountBMin | unit | Bounds the extent to which the A/B price can go up before the transaction reverts. Must be <= amountBDesired. |
to | address | Recipient of the liquidity tokens. |
deadline | unit | Unix timestamp after which the transaction will revert. |
amountA | unit | The amount of tokenA sent to the pool. |
amountB | unit | The amount of tokenB sent to the pool. |
liquidity | unit | The amount of liquidity tokens minted. |
addLiquidityKLAY
function addLiquidityKLAY( address token, uint amountTokenDesired, uint amountTokenMin, uint amountKLAYMin, address to, uint deadline) external payable returns (uint amountToken, uint amountKLAY, uint liquidity);
Adds liquidity to an KIP-7⇄WKLAY pool with KLAY.
To cover all possible scenarios,
msg.sender
should have already given the router an allowance of at least amountTokenDesired on token.Always adds assets at the ideal ratio, according to the price when the transaction is executed.
msg.value
is treated as a amountKLAYDesired.Leftover KLAY, if any, is returned to
msg.sender
.If a pool for the passed token and WKLAY does not exists, one is created automatically, and exactly amountTokenDesired/
msg.value
tokens are added.
Untitled
token | address | A pool token. |
amountTokenDesired | unit | The amount of token to add as liquidity if the WKLAY/token price is <= msg.value/amountTokenDesired (token depreciates). |
msg.value (amountKLAYDesired) | unit | The amount of KLAY to add as liquidity if the token/WKLAY price is <= amountTokenDesired/msg.value (WKLAY depreciates). |
amountTokenMin | unit | Bounds the extent to which the WKLAY/token price can go up before the transaction reverts. Must be <= amountTokenDesired. |
amountKLAYMin | unit | Bounds the extent to which the token/WKLAY price can go up before the transaction reverts. Must be <= msg.value. |
to | address | Recipient of the liquidity tokens. |
deadline | unit | Unix timestamp after which the transaction will revert. |
amountToken | unit | The amount of token sent to the pool. |
amountKLAY | unit | The amount of KLAY converted to WKLAY and sent to the pool. |
liquidity | unit | The amount of liquidity tokens minted. |
removeLiquidity
function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline) external returns (uint amountA, uint amountB);
Removes liquidity from an KIP-7⇄KIP-7 pool.
msg.sender
should have already given the router an allowance of at least liquidity on the pool.
Untitled
tokenA | address | A pool token. |
tokenB | address | A pool token. |
liquidity | unit | The amount of liquidity tokens to remove. |
amountAMin | unit | The minimum amount of tokenA that must be received for the transaction not to revert. |
amountBMin | unit | The minimum amount of tokenB that must be received for the transaction not to revert. |
to | address | Recipient of the underlying assets. |
deadline | unit | Unix timestamp after which the transaction will revert. |
amountA | unit | The amount of tokenA received. |
amountB | unit | The amount of tokenB received. |
removeLiquidityKLAY
function removeLiquidityKLAY( address token, uint liquidity, uint amountTokenMin, uint amountKLAYMin, address to, uint deadline) external returns (uint amountToken, uint amountKLAY);
Removes liquidity from an KIP-7⇄WKLAY pool and receive KLAY.
msg.sender
should have already given the router an allowance of at least liquidity on the pool.
Untitled
token | address | A pool token. |
liquidity | unit | The amount of liquidity tokens to remove. |
amountTokenMin | unit | The minimum amount of token that must be received for the transaction not to revert. |
amountKLAYMin | unit | The minimum amount of KLAY that must be received for the transaction not to revert. |
to | address | Recipient of the underlying assets. |
deadline | unit | Unix timestamp after which the transaction will revert. |
amountToken | unit | The amount of token received. |
amountKLAY | unit | The amount of KLAY received. |
swapExactTokensForTokens
function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts);
Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path. The first element of path is the input token, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).
msg.sender
should have already given the router an allowance of at least amountIn on the input token.
Untitled
amountIn | unit | The amount of input tokens to send. |
amountOutMin | unit | The minimum amount of output tokens that must be received for the transaction not to revert. |
path | address[] calldata | An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity. |
to | address | Recipient of the output tokens. |
deadline | uint | Unix timestamp after which the transaction will revert. |
amounts | uint[] memory | The input token amount and all subsequent output token amounts. |
swapTokensForExactTokens
function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts);
Receive an exact amount of output tokens for as few input tokens as possible, along the route determined by the path. The first element of path is the input token, the last is the output token, and any intermediate elements represent intermediate tokens to trade through (if, for example, a direct pair does not exist).
msg.sender
should have already given the router an allowance of at least amountInMax on the input token.
Untitled
tokenA | address | A pool token. |
tokenB | address | A pool token. |
liquidity | unit | The amount of liquidity tokens to remove. |
amountAMin | unit | The minimum amount of tokenA that must be received for the transaction not to revert. |
amountBMin | unit | The minimum amount of tokenB that must be received for the transaction not to revert. |
to | address | Recipient of the underlying assets. |
deadline | unit | Unix timestamp after which the transaction will revert. |
amountA | unit | The amount of tokenA received. |
amountB | unit | The amount of tokenB received. |
swapExactKLAYForTokens
function swapExactKLAYForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts);
Swaps an exact amount of KLAY for as many output tokens as possible, along the route determined by the path. The first element of path must be WKLAY, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).
Untitled
msg.value (amountIn) | address | The amount of WKLAY to send. |
amountOutMin | unit | TThe minimum amount of output tokens that must be received for the transaction not to revert. |
path | address[] calldata | An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity. |
to | address | Recipient of the output tokens. |
deadline | unit | Unix timestamp after which the transaction will revert. |
amounts | uint[] memory | The input token amount and all subsequent output token amounts. |
swapTokensForExactKLAY
function swapTokensForExactKLAY(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts);
Receive an exact amount of KLAY for as few input tokens as possible, along the route determined by the path. The first element of path is the input token, the last must be WKLAY, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).
msg.sender
should have already given the router an allowance of at least amountInMax on the input token.If the to address is a smart contract, it must have the ability to receive KLAY.
Untitled
amountOut | uint | The amount of KLAY to receive. |
amountInMax | uint | The maximum amount of input tokens that can be required before the transaction reverts. |
path | address[] calldata | An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity. |
to | address | Recipient of KLAY. |
deadline | uint | Unix timestamp after which the transaction will revert. |
amounts | uint[] memory | The input token amount and all subsequent output token amounts. |
swapExactTokensForKLAY
function swapExactTokensForKLAY(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts);
Swaps an exact amount of tokens for as much KLAY as possible, along the route determined by the path. The first element of path is the input token, the last must be WKLAY, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).
If the to address is a smart contract, it must have the ability to receive KLAY.
Untitled
amountIn | uint | The amount of input tokens to send. |
amountOutMin | uint | The minimum amount of output tokens that must be received for the transaction not to revert. |
path | address[] calldata | An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity. |
to | address | Recipient of the KLAY. |
deadline | uint | Unix timestamp after which the transaction will revert. |
amounts | uint[] memory | The input token amount and all subsequent output token amounts. |
swapKLAYForExactTokens
function swapKLAYForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts);
Receive an exact amount of tokens for as little KLAY as possible, along the route determined by the path. The first element of path must be WKLAY, the last is the output token and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).
Leftover KLAY, if any, is returned to
msg.sender
.
Untitled
amountOut | uint | The amount of tokens to receive. |
msg.value (amountInMax) | uint | The maximum amount of KLAY that can be required before the transaction reverts. |
path | address[] calldata | An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity. |
to | address | Recipient of the output tokens. |
deadline | uint | Unix timestamp after which the transaction will revert. |
amounts | uint[] memory | The input token amount and all subsequent output token amounts. |
UfoRouter Contract ABI
Last updated