Add Liquidity
1. Add liquidity with two tokens
Use the add_liquidity_entry
function from the router
module.
public entry fun add_liquidity_entry(
lp: &signer,
token_1: Object<Metadata>,
token_2: Object<Metadata>,
is_stable: bool,
amount_1: u64,
amount_2: u64,
) {
...
}
Function Parameters
lp: The transaction signer (liquidity provider).token_1: The first token object used to provide liquidity.token_2: The second token object used to provide liquidity.is_stable: A boolean flag indicating whether the pool is stable (true) or volatile (false)amount_1: Amount oftoken_1amount_2: Amount oftoken_2
2. Add liquidity with two coins
Use theadd_liquidity_both_coins_entryfunction from theroutermodule.
public entry fun add_liquidity_both_coins_entry<CoinA, CoinB>(
lp: &signer,
is_stable: bool,
amount_1: u64,
amount_2: u64,
) {
...
}
Function Parameters
lp
: The transaction signer (liquidity provider).coinA
: The first coin object used to provide liquidity.coinB
: The second coin object used to provide liquidity.is_stable
: A boolean flag indicating whether the pool is stable (true
) or volatile (false
)amount_1
: Amount ofcoinA
amount_2
: Amount ofcoinB
3. Add liquidity with a coin and a token
Use the add_liquidity_and_stake_coin_entry
function from the router
module.
public entry fun add_liquidity_and_stake_coin_entry<CoinType>(
lp: &signer,
token_2: Object<Metadata>,
is_stable: bool,
amount_1: u64,
amount_2: u64,
) {
...
}
Function Parameters
lp
: The transaction signer (liquidity provider).CoinType
: The first coin object used to provide liquidity.token_2
: The second token object used to provide liquidity.is_stable
: A boolean flag indicating whether the pool is stable (true
) or volatile (false
)amount_1
: Amount of coinamount_2
: Amount of token
4. Add liquidity and stake with two tokens
Use the add_liquidity_and_stake_entry
function from the router
module.
public entry fun add_liquidity_and_stake_entry(
lp: &signer,
token_1: Object<Metadata>,
token_2: Object<Metadata>,
is_stable: bool,
amount_1: u64,
amount_2: u64,
) {
...
}
Function Parameters
lp
: The transaction signer (liquidity provider).token_1
: The first token object used to provide liquidity.token_2
: The second token object used to provide liquidity.is_stable
: A boolean flag indicating whether the pool is stable (true
) or volatile (false
)amount_1
: Amount oftoken_1
amount_2
: Amount oftoken_2
5. Add liquidity and stake with two coins
Use the add_liquidity_and_stake_both_coins_entry
function from the router
module.
public entry fun add_liquidity_and_stake_both_coins_entry<CoinA, CoinB>(
lp: &signer,
is_stable: bool,
amount_1: u64,
amount_2: u64,
) {
...
}
Function Parameters
lp
: The transaction signer (liquidity provider).coinA
: The first coin object used to provide liquidity.coinB
: The second coin object used to provide liquidity.is_stable
: A boolean flag indicating whether the pool is stable (true
) or volatile (false
)amount_1
: Amount ofcoinA
amount_2
: Amount ofcoinB
6. Add liquidity and stake with a coin and a token
Use the add_liquidity_and_stake_coin_entry
function from the router
module.
public entry fun add_liquidity_and_stake_coin_entry<CoinType>(
lp: &signer,
token_2: Object<Metadata>,
is_stable: bool,
amount_1: u64,
amount_2: u64,
) {
...
}
Function Parameters
lp
: The transaction signer (liquidity provider).CoinType
: The first coin object used to provide liquidity.token_2
: The second token object used to provide liquidity.is_stable
: A boolean flag indicating whether the pool is stable (true
) or volatile (false
)amount_1
: Amount of coinamount_2
: Amount of token
Last updated