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.
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.
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.
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.
function swapExactSEIForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
Swaps an exact amount of SEI for as many output tokens as possible, along the route determined by the path. The first element of path must be WSEI, 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).
function swapTokensForExactSEI(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
Receive an exact amount of SEI 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 WSEI, 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 SEI.
function swapExactTokensForSEI(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 SEI as possible, along the route determined by the path. The first element of path is the input token, the last must be WSEI, 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 SEI.
function swapSEIForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
Receive an exact amount of tokens for as little SEIas possible, along the route determined by the path. The first element of path must be WETH, 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).