Functions
Here’s a list of all the functions from our Router ABI with a quick explanation of each function and its parameters:
The WETH()
function retrieves the address of the Wrapped Ether (WETH) token used in the contract.
Signature:
function WETH() external view returns (address)
Parameters: None.
Returns:
The address of the WETH token.
The addLiquidity
function allows adding liquidity to a Uniswap pool between two ERC20 tokens.
Signature:
function addLiquidity(address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline) external returns (uint256 amountA, uint256 amountB, uint256 liquidity)
Parameters:
address tokenA
: Address of the first token in the pair.address tokenB
: Address of the second token in the pair.uint256 amountADesired
: Desired amount oftokenA
to add as liquidity.uint256 amountBDesired
: Desired amount oftokenB
to add as liquidity.uint256 amountAMin
: Minimum acceptable amount oftokenA
(slippage tolerance).uint256 amountBMin
: Minimum acceptable amount oftokenB
(slippage tolerance).address to
: Address where liquidity (LP) tokens will be sent.uint256 deadline
: Unix timestamp after which the transaction will revert if not executed.
Returns:
uint256 amountA
: Actual amount oftokenA
added to the pool.uint256 amountB
: Actual amount oftokenB
added to the pool.uint256 liquidity
: Amount of liquidity tokens minted.
The addLiquidityETH
function allows adding liquidity to a token-ETH pair.
Signature:
function addLiquidityETH(address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity)
Parameters:
address token
: Address of the ERC20 token in the pair.uint256 amountTokenDesired
: Desired amount of the ERC20 token to add as liquidity.uint256 amountTokenMin
: Minimum acceptable amount of the ERC20 token (slippage tolerance).uint256 amountETHMin
: Minimum acceptable amount of ETH (slippage tolerance).address to
: Address where liquidity (LP) tokens will be sent.uint256 deadline
: Unix timestamp after which the transaction will revert if not executed.
Returns:
uint256 amountToken
: Actual amount of the ERC20 token added to the pool.uint256 amountETH
: Actual amount of ETH added to the pool.uint256 liquidity
: Amount of liquidity tokens minted.
The factory()
function retrieves the address of the Uniswap factory contract associated with this instance.
Signature:
function factory() external view returns (address)
Parameters: None.
Returns:
The address of the Uniswap factory contract.
The getAmountsOut
function calculates the output token amounts for a given input amount and swap path.
Signature:
function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts)
Parameters:
uint256 amountIn
: Amount of the input token.address[] path
: Array of token addresses defining the swap path.
Returns:
uint256[] amounts
: Array of output amounts for each token in the path.
The getPair
function retrieves the address of the liquidity pool (pair) for two given tokens.
Signature:
function getPair(address token1, address token2) external view returns (address)
Parameters:
address token1
: Address of the first token.address token2
: Address of the second token.
Returns:
The address of the liquidity pool (pair) contract.
The quote
function calculates how much of tokenB
you would get for a given amount of tokenA
based on their reserves.
Signature:
function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) external pure returns (uint256 amountB)
Parameters:
uint256 amountA
: Amount oftokenA
you want to convert.uint256 reserveA
: Reserve oftokenA
in the liquidity pool.uint256 reserveB
: Reserve oftokenB
in the liquidity pool.
Returns:
uint256 amountB
: Calculated amount oftokenB
.
The removeLiquidity
function removes liquidity from a pool of two ERC20 tokens.
Signature:
function removeLiquidity(address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline) external returns (uint256 amountA, uint256 amountB)
Parameters:
address tokenA
: Address of the first token in the pair.address tokenB
: Address of the second token in the pair.uint256 liquidity
: Amount of liquidity tokens to burn.uint256 amountAMin
: Minimum acceptable amount oftokenA
.uint256 amountBMin
: Minimum acceptable amount oftokenB
.address to
: Address to send the withdrawn tokens.uint256 deadline
: Unix timestamp after which the transaction will revert if not executed.
Returns:
uint256 amountA
: Amount oftokenA
returned.uint256 amountB
: Amount oftokenB
returned.
The removeLiquidityETH
function removes liquidity from a token-ETH pair.
Signature:
function removeLiquidityETH(address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline) external returns (uint256 amountToken, uint256 amountETH)
Parameters:
address token
: Address of the ERC20 token in the pair.uint256 liquidity
: Amount of liquidity tokens to burn.uint256 amountTokenMin
: Minimum acceptable amount of the token.uint256 amountETHMin
: Minimum acceptable amount of ETH.address to
: Address to send the withdrawn tokens.uint256 deadline
: Unix timestamp after which the transaction will revert if not executed.
Returns:
uint256 amountToken
: Amount of the token returned.uint256 amountETH
: Amount of ETH returned.
The removeLiquidityETHWithPermit
function removes liquidity from a token-ETH pair, allowing token approval through an off-chain signature.
Signature:
function removeLiquidityETHWithPermit(address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s) external returns (uint256 amountToken, uint256 amountETH)
Parameters:
address token
: Address of the ERC20 token in the pair.uint256 liquidity
: Amount of liquidity tokens to burn.uint256 amountTokenMin
: Minimum acceptable amount of the token.uint256 amountETHMin
: Minimum acceptable amount of ETH.address to
: Address to send the withdrawn tokens.uint256 deadline
: Unix timestamp after which the transaction will revert if not executed.bool approveMax
: Iftrue
, the max amount of liquidity will be approved.uint8 v
,bytes32 r
,bytes32 s
: Signature components for the permit (used for off-chain approval).
Returns:
uint256 amountToken
: Amount of the token returned.uint256 amountETH
: Amount of ETH returned.
The removeLiquidityETHWithPermitSupportingFeeOnTransferTokens
function removes liquidity from a token-ETH pair while supporting tokens with transfer fees, and uses a permit for token approvals.
Signature:
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s) external returns (uint256 amountETH)
Parameters:
Same as
removeLiquidityETHWithPermit
.
Returns:
uint256 amountETH
: Amount of ETH returned.
The removeLiquidityWithPermit
function removes liquidity from a token-token pair, allowing token approval through an off-chain signature.
Signature:
function removeLiquidityWithPermit(address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s) external returns (uint256 amountA, uint256 amountB)
Parameters:
address tokenA
: Address of the first token in the pair.address tokenB
: Address of the second token in the pair.uint256 liquidity
: Amount of liquidity tokens to burn.uint256 amountAMin
: Minimum acceptable amount oftokenA
.uint256 amountBMin
: Minimum acceptable amount oftokenB
.address to
: Address to send the withdrawn tokens.uint256 deadline
: Unix timestamp after which the transaction will revert if not executed.bool approveMax
: Iftrue
, the max amount of liquidity will be approved.uint8 v
,bytes32 r
,bytes32 s
: Signature components for the permit (used for off-chain approval).
Returns:
uint256 amountA
: Amount oftokenA
returned.uint256 amountB
: Amount oftokenB
returned.
The swapExactETHForTokensSupportingFeeOnTransferTokens
function swaps an exact amount of ETH for tokens, supporting tokens with transfer fees.
Signature:
function swapExactETHForTokensSupportingFeeOnTransferTokens(uint256 amountOutMin, address[] calldata path, address to, address referrer, uint256 deadline) external payable
Parameters:
uint256 amountOutMin
: Minimum acceptable amount of output tokens (slippage tolerance).address[] path
: Array of token addresses representing the swap path, starting with WETH and ending with the desired token.address to
: Address to receive the output tokens.address referrer
: Address of the referrer, if applicable (optional for referral programs).uint256 deadline
: Unix timestamp after which the transaction will revert if not executed.
The swapExactTokensForETHSupportingFeeOnTransferTokens
function swaps an exact amount of tokens for ETH, supporting tokens with transfer fees.
Signature:
function swapExactTokensForETHSupportingFeeOnTransferTokens(uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, address referrer, uint256 deadline) external
Parameters:
uint256 amountIn
: Exact amount of input tokens to swap.uint256 amountOutMin
: Minimum acceptable amount of ETH to receive (slippage tolerance).address[] path
: Array of token addresses representing the swap path, starting with the input token and ending with WETH.address to
: Address to receive the ETH.address referrer
: Address of the referrer, if applicable.uint256 deadline
: Unix timestamp after which the transaction will revert if not executed.
The swapExactTokensForTokensSupportingFeeOnTransferTokens
function swaps an exact amount of tokens for another token, supporting tokens with transfer fees.
Signature:
function swapExactTokensForTokensSupportingFeeOnTransferTokens(uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, address referrer, uint256 deadline) external
Parameters:
uint256 amountIn
: Exact amount of input tokens to swap.uint256 amountOutMin
: Minimum acceptable amount of output tokens (slippage tolerance).address[] path
: Array of token addresses representing the swap path, starting with the input token and ending with the output token.address to
: Address to receive the output tokens.address referrer
: Address of the referrer, if applicable.uint256 deadline
: Unix timestamp after which the transaction will revert if not executed.
The receive()
function allows the contract to accept ETH directly.
Signature:
receive() external payable
Parameters: None.
Functionality: The contract can receive ETH without requiring any specific method call.
Last updated