pub trait Swap<AccountId, Balance, MultiAssetId> {
    // Required methods
    fn swap_exact_tokens_for_tokens(
        sender: AccountId,
        path: Vec<MultiAssetId>,
        amount_in: Balance,
        amount_out_min: Option<Balance>,
        send_to: AccountId,
        keep_alive: bool
    ) -> Result<Balance, DispatchError>;
    fn swap_tokens_for_exact_tokens(
        sender: AccountId,
        path: Vec<MultiAssetId>,
        amount_out: Balance,
        amount_in_max: Option<Balance>,
        send_to: AccountId,
        keep_alive: bool
    ) -> Result<Balance, DispatchError>;
}
Expand description

Trait for providing methods to swap between the various asset classes.

Required Methods§

source

fn swap_exact_tokens_for_tokens( sender: AccountId, path: Vec<MultiAssetId>, amount_in: Balance, amount_out_min: Option<Balance>, send_to: AccountId, keep_alive: bool ) -> Result<Balance, DispatchError>

Swap exactly amount_in of asset path[0] for asset path[1]. If an amount_out_min is specified, it will return an error if it is unable to acquire the amount desired.

Withdraws the path[0] asset from sender, deposits the path[1] asset to send_to, respecting keep_alive.

If successful, returns the amount of path[1] acquired for the amount_in.

source

fn swap_tokens_for_exact_tokens( sender: AccountId, path: Vec<MultiAssetId>, amount_out: Balance, amount_in_max: Option<Balance>, send_to: AccountId, keep_alive: bool ) -> Result<Balance, DispatchError>

Take the path[0] asset and swap some amount for amount_out of the path[1]. If an amount_in_max is specified, it will return an error if acquiring amount_out would be too costly.

Withdraws path[0] asset from sender, deposits path[1] asset to send_to, respecting keep_alive.

If successful returns the amount of the path[0] taken to provide path[1].

Implementors§