Removing Liquidity
In the following subsections, we will detail the functions related to the removal of liquidity that has been defined in the Infinity Protocol.
The WithPermit functions allow the wallet to sign an off-chain approval message to be sent with the liquidity removal. This saves the user gas and time over the standard method of having to first push an approval transaction before removing.

removeLiquidity

Use this function to remove both tokens in a liquidity pool at the current ratio of the pool.
1
function removeLiquidity(
2
address tokenA,
3
address tokenB,
4
uint liquidity,
5
uint amountAMin,
6
uint amountBMin,
7
address to,
8
uint deadline
9
)
Copied!
The removeLiquidity function accepts these parameters:
Parameter
Type
Description
tokenA
address
The contract address of the desired token.
tokenB
address
The contract address of the desired token.
liquidity
uint
The amount of liquidity tokens to remove.
amountAMin
uint
The minimum amount of tokenA that must be received for the transaction not to revert.
amountBMin
uint
The minimum amount of tokenB that must be received for the transaction not to revert.
to
address
The address to receive the tokens.
deadline
uint
The Unix-time deadline for which the transaction must be confirmed before.

removeLiquidityETH

Use this function to remove the token and the native asset such as ETH or BNB in a liquidity pool at the current ratio of the pool.
1
function removeLiquidityETH(
2
address token,
3
uint liquidity,
4
uint amountTokenMin,
5
uint amountETHMin,
6
address to,
7
uint deadline
8
)
Copied!
The removeLiquidityETH function accepts these parameters:
Parameter
Type
Description
token
address
The contract address of the desired token.
liquidity
uint
The amount of liquidity tokens to remove.
amountTokenMin
uint
The minimum amount of token that must be received for the transaction not to revert.
amountETHMin
uint
The minimum amount of ETH that must be received for the transaction not to revert.
to
address
The address to receive the liquidity tokens.
deadline
uint
The Unix-time deadline for which the transaction must be confirmed before.

removeLiquidityWithPermit

Use this function to remove both tokens in a liquidity pool at the current ratio of the pool and sign an off-chain approval message to be sent with the liquidity removal.
1
function removeLiquidityWithPermit(
2
address tokenA,
3
address tokenB,
4
uint liquidity,
5
uint amountAMin,
6
uint amountBMin,
7
address to,
8
uint deadline,
9
bool approveMax,
10
uint8 v,
11
bytes32 r,
12
bytes32 s
13
)
Copied!
The removeLiquidityWithPermit function accepts these parameters:
Parameter
Type
Description
tokenA
address
The contract address of the desired token.
tokenB
address
The contract address of the desired token.
liquidity
uint
The amount of liquidity tokens to remove.
amountAMin
uint
The minimum amount of tokenA that must be received for the transaction not to revert.
amountBMin
uint
The minimum amount of tokenB that must be received for the transaction not to revert.
to
address
The address to receive the tokens.
deadline
uint
Unix timestamp after which the transaction will revert.
approveMax
bool
Whether or not the approval amount in the signature is for liquidity or uint(-1).
v
uint8
The v component of the permit signature.
r
bytes32
The r component of the permit signature.
s
bytes32
The s component of the permit signature.

removeLiquidityETHWithPermit

Use this function to remove the token and the native asset such as ETH or BNB in a liquidity pool at the current ratio of the pool and sign an off-chain approval message to be sent with the liquidity removal.
1
function removeLiquidityETHWithPermit(
2
address token,
3
uint liquidity,
4
uint amountTokenMin,
5
uint amountETHMin,
6
address to,
7
uint deadline,
8
bool approveMax,
9
uint8 v,
10
bytes32 r,
11
bytes32 s
12
)
Copied!
The removeLiquidityETHWithPermit function accepts these parameters:
Parameter
Type
Description
token
address
The contract address of the desired token.
liquidity
uint
The amount of liquidity tokens to remove.
amountTokenMin
uint
The minimum amount of token that must be received for the transaction not to revert.
amountETHMin
uint
The minimum amount of ETH that must be received for the transaction not to revert.
to
address
The address to receive the liquidity tokens.
deadline
uint
The Unix-time deadline for which the transaction must be confirmed before.
approveMax
bool
Whether or not the approval amount in the signature is for liquidity or uint(-1).
v
uint8
The v component of the permit signature.
r
bytes32
The r component of the permit signature.
s
bytes32
The s component of the permit signature.

removeLiquidityETHSupportingFeeOnTransferTokens

This function is identical to removeLiquidityETH, but it is for tokens that take a fee on transfer. It allows the removal of liquidity of a token and the native asset such as ETH or BNB in a liquidity pool at the current ratio of the pool.
1
function removeLiquidityETHSupportingFeeOnTransferTokens(
2
address token,
3
uint liquidity,
4
uint amountTokenMin,
5
uint amountETHMin,
6
address to,
7
uint deadline
8
)
Copied!
The removeLiquidityETHSupportingFeeOnTransferTokens function accepts these parameters:
Parameter
Type
Description
token
address
The contract address of the desired token.
liquidity
uint
The amount of liquidity tokens to remove.
amountTokenMin
uint
The minimum amount of token that must be received for the transaction not to revert.
amountETHMin
uint
The minimum amount of ETH that must be received for the transaction not to revert.
to
address
The address to receive the liquidity tokens.
deadline
uint
The Unix-time deadline for which the transaction must be confirmed before.

removeLiquidityETHWithPermitSupportingFeeOnTransferTokens

This function is identical to removeLiquidityETHWithPermit, but it is for tokens that take a fee on transfer. It allows the removal of liquidity of a token and the native asset such as ETH or BNB in a liquidity pool at the current ratio of the pool and sign an off-chain approval message to be sent with the liquidity removal.
1
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
2
address token,
3
uint liquidity,
4
uint amountTokenMin,
5
uint amountETHMin,
6
address to,
7
uint deadline,
8
bool approveMax,
9
uint8 v,
10
bytes32 r,
11
bytes32 s
12
)
Copied!
The removeLiquidityETHWithPermitSupportingFeeOnTransferTokens function accepts these parameters:
Parameter
Type
Description
token
address
The contract address of the desired token.
liquidity
uint
The amount of liquidity tokens to remove.
amountTokenMin
uint
The minimum amount of token that must be received for the transaction not to revert.
amountETHMin
uint
The minimum amount of ETH that must be received for the transaction not to revert.
to
address
The address to receive the liquidity tokens.
deadline
uint
The Unix-time deadline for which the transaction must be confirmed before.
approveMax
bool
Whether or not the approval amount in the signature is for liquidity or uint(-1).
v
uint8
The v component of the permit signature.
r
bytes32
The r component of the permit signature.
s
bytes32
The s component of the permit signature.

removeLiquiditySingle

Use this function to remove one of the constituent tokens in a liquidity pool.
The other token will be automatically swapped to the desired token as part of the single remove transaction and will be subject to any price impact and swap fee as normal.
1
function removeLiquiditySingle(
2
address tokenA,
3
address tokenOut,
4
uint liquidity,
5
uint amountOutMin,
6
address to,
7
uint deadline
8
)
Copied!
The removeLiquiditySingle function accepts these parameters:
Type
Parameter
Description
tokenA
address
The contract address of the other token in the pool.
tokenOut
address
The contract address of the token you want out of the pool.
liquidity
uint
The amount of liquidity pool tokens you want to redeem.
amountOutMin
uint
The minimum amount of the tokenOut you will accept in return.
to
address
The address to receive the tokens.
deadline
uint
The Unix-time deadline which the transaction must be confirmed before.

removeLiquidityETHSingle

Use this function to remove one of the constituents either token or the native asset such as ETH or BNB in a liquidity pool.
The other token or native asset such as ETH or BNB will be automatically swapped to the desired token or native asset such as ETH or BNB as part of the single remove transaction and will be subject to any price impact and swap fee as normal.
1
function removeLiquidityETHSingle(
2
address token,
3
uint liquidity,
4
uint amountETHMin,
5
address to,
6
uint deadline
7
)
Copied!
The removeLiquidityETHSingle function accepts these parameters:
Type
Parameter
Description
token
address
The contract address of the desired token.
liquidity
uint
The amount of liquidity tokens to remove.
amountETHMin
uint
The minimum amount of ETH that must be received for the transaction not to revert.
to
address
The address to receive the liquidity tokens.
deadline
uint
The Unix-time deadline for which the transaction must be confirmed before.

removeLiquiditySingleWithPermit

Use this function to remove one of the constituent tokens in a liquidity pool and sign an off-chain approval message to be sent with the liquidity removal.
The other token will be automatically swapped to the desired token as part of the single remove transaction and will be subject to any price impact and swap fee as normal.
1
function removeLiquiditySingle(
2
address tokenA,
3
address tokenOut,
4
uint liquidity,
5
uint amountOutMin,
6
address to,
7
uint deadline,
8
bool approveMax,
9
uint8 v,
10
bytes32 r,
11
bytes32 s
12
)
Copied!
The removeLiquiditySingleWithPermit function accepts these parameters:
Type
Parameter
Description
tokenA
address
The contract address of the other token in the pool.
tokenOut
address
The contract address of the token you want out of the pool.
liquidity
uint
The amount of liquidity pool tokens you want to redeem.
amountOutMin
uint
The minimum amount of the tokenOut you will accept in return.
to
address
The address to receive the tokens.
deadline
uint
The Unix-time deadline which the transaction must be confirmed before.
approveMax
bool
Whether or not the approval amount in the signature is for liquidity or uint(-1).
v
uint8
The v component of the permit signature.
r
bytes32
The r component of the permit signature.
s
bytes32
The s component of the permit signature.

removeLiquidityETHSingleWithPermit

Use this function to remove one of the constituents either token or the native asset such as ETH or BNB in a liquidity pool and sign an off-chain approval message to be sent with the liquidity removal.
The other token or native asset such as ETH or BNB will be automatically swapped to the desired token or native asset such as ETH or BNB as part of the single remove transaction and will be subject to any price impact and swap fee as normal.
1
function removeLiquidityETHSingle(
2
address token,
3
uint liquidity,
4
uint amountETHMin,
5
address to,
6
uint deadline,
7
bool approveMax,
8
uint8 v,
9
bytes32 r,
10
bytes32 s
11
)
Copied!
The removeLiquidityETHSingleWithPermit function accepts these parameters:
Type
Parameter
Description
token
address
The contract address of the desired token.
liquidity
uint
The amount of liquidity tokens to remove.
amountETHMin
uint
The minimum amount of ETH that must be received for the transaction not to revert.
to
address
The address to receive the liquidity tokens.
deadline
uint
The Unix-time deadline for which the transaction must be confirmed before.
approveMax
bool
Whether or not the approval amount in the signature is for liquidity or uint(-1).
v
uint8
The v component of the permit signature.
r
bytes32
The r component of the permit signature.
s
bytes32
The s component of the permit signature.
Last modified 6mo ago