Swap
1. Swap from Token
Use the swap_route_entry function from the router module.
public entry fun swap_route_entry(
user: &signer,
amount_in: u64,
amount_out_min: u64,
from_token: Object<Metadata>,
to_tokens: vector<Object<Metadata>>,
is_stables: vector<bool>,
recipient: address,
ref_by: address
) {
...
}Function Parameters
amount_in: The input amount.amount_out_min: The minimum acceptable output amount.to_tokens: An array of output tokens.is_stables: An array of boolean values indicating whether each corresponding output token is stableref_by: Referrer’s address
2. Swap from Coin
Use the swap_route_entry_from_coin function from the router module.
public entry fun swap_route_entry_from_coin<FromCoin>(
user: &signer,
amount_in: u64,
amount_out_min: u64,
to_tokens: vector<Object<Metadata>>,
is_stables: vector<bool>,
recipient: address,
ref_by: address
) {
...
}Function Parameters
FromCoin: Input coin for the swapamount_in: The input amount.amount_out_min: The minimum acceptable output amount.to_tokens: An array of output tokens.is_stables: An array of boolean values indicating whether each corresponding output token is stableref_by: Referrer’s address
Last updated