Adding Liquidity
In the following subsections, we will detail the functions related to the addition of liquidity that has been defined in the Infinity Protocol.
When adding liquidity to a pool, if it does not exist for the pair then it will be created automatically. The first user to add liquidity and create the pool will set the initial ratio of the pair tokens, this should be at the current market price.

addLiquidity

When adding liquidity to a TOKEN⇄TOKEN pool use this function. Your tokens will be added at the exact ratio of the pair reserves (the current price) and receive the proportional amount of liquidity tokens. With no fee or price impact on the pool at the time of execution.
The amountAMin and amountBMin can be modified by your slippage tolerance to revert on unfavorable price changes.
1
function addLiquidity(
2
address tokenA,
3
address tokenB,
4
uint amountADesired,
5
uint amountBDesired,
6
uint amountAMin,
7
uint amountBMin,
8
address to,
9
uint deadline
10
)
Copied!
The addLiquidity function accepts these parameters:
Type
Parameter
Description
tokenA
address
The contract address of one of the tokens you wish to provide.
tokenB
address
The contract address of the other token.
amountADesired
uint
The amount of tokenA desired to provide.
amountBDesired
uint
The amount of tokenB desired to provide.
amountAMin
uint
The minimum amount of tokenA to provide.
amountBMin
uint
The minimum amount of tokenB to provide.
to
address
The address to receive the liquidity tokens.
deadline
uint
The Unix-time deadline for which the transaction must be confirmed before.

addLiquidityETH

When adding liquidity to a TOKEN⇄ETH or BNB pool use the this function. Your token and native asset such as ETH or BNB will be added at the exact ratio of the pair reserves (the current price) and receive the proportional amount of liquidity tokens. With no fee or price impact on the pool at the time of execution.
1
function addLiquidityETH(
2
address token,
3
uint amountTokenDesired,
4
uint amountTokenMin,
5
uint amountETHMin,
6
address to,
7
uint deadline
8
)
Copied!
The addLiquidityETH function accepts these parameters:
Type
Parameter
Description
token
address
The contract address of one of the tokens you wish to provide.
amountTokenDesired
uint
The amount of token to add as liquidity if the WETH/token price is <= msg.value/amountTokenDesired (token depreciates).
amountTokenMin
uint
Bounds the extent to which the WETH/token price can go up before the transaction reverts. Must be <= amountTokenDesired.
amountETHMin
uint
Bounds the extent to which the token/WETH price can go up before the transaction reverts. Must be <= msg.value.
to
address
The address to receive the liquidity tokens.
deadline
uint
The Unix-time deadline for which the transaction must be confirmed before.

addLiquidityFlexible

When adding flexible liquidity to a TOKEN⇄ETH or BNB pool use the this function. With Flexible adding, users have the ability to add liquidity with any amount of both of the tokens or a single token.
Liquidity tokens will be given with no swap fee for any amount that can be deposited at the exact rate, with any excess amount provided in one of the tokens being added with the swap fee on half the value as with single adding.
Adding a very large amount in a single token in comparison to the reserves for the pair can cause a large pool price impact which should be displayed in any interface to the user as a large price difference.
1
function addLiquidityFlexible(
2
address tokenA,
3
address tokenB,
4
uint amountA,
5
uint amountB,
6
uint liquidityMin,
7
address to,
8
uint deadline
9
)
Copied!
The addLiquidityFlexible function accepts these parameters:
Type
Parameter
Description
tokenA
address
The contract address of one of the tokens you wish to provide.
tokenB
address
The contract address of the other token.
amountA
uint
The amount of tokenA to provide.
amountB
uint
The amount of tokenB to provide.
liquidityMin
uint
The minimum amount of liquidity pool tokens you will accept in return.
to
address
The address to receive the liquidity tokens.
deadline
uint
The Unix-time deadline which the transaction must be confirmed before.

addLiquidityETHFlexible

When adding flexible liquidity to a TOKEN⇄ETH or BNB pool use the this function. With Flexible adding, users have the ability to add liquidity with any amount of both of the tokens or a single token.
Liquidity tokens will be given with no swap fee for any amount that can be deposited at the exact rate, with any excess amount provided in one of the tokens being added with the swap fee on half the value as with single adding.
Adding a very large amount in a single token in comparison to the reserves for the pair can cause a large pool price impact, which should be displayed in any interface to the user as a large price difference.
1
function addLiquidityETHFlexible(
2
address token,
3
uint amountToken,
4
uint liquidityMin,
5
address to,
6
uint deadline
7
)
Copied!
The addLiquidityETHFlexible function accepts these parameters:
Type
Parameter
Description
token
address
The contract address of the desired token.
amountToken
uint
The amount of token sent to the pool.
liquidityMin
uint
The minimum amount of liquidity pool tokens you will accept in return.
to
address
The address to receive the liquidity tokens.
deadline
uint
The Unix-time deadline for which the transaction must be confirmed before.
Last modified 5mo ago