Earnium Docs Stardust
Documentation menu

Swap

On this page

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

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