AshSwap Docs

Stable Pool

This pool type contain stable tokens

Contract Interface


pub type PoolResultType<BigUint> = ManagedVec<BigUint, EsdtTokenPayment<BigUint>>;

Add liquidity

fn add_liquidity(&self, mint_amount_min: BigUint, lp_token_receiver: &ManagedAddress) -> PoolResultType<Self::Api>

Remove liquidity

fn remove_liquidity(&self, token_amount_min: MultiValueEncoded<BigUint>) -> PoolResultType<Self::Api>


fn exchange(&self, token_out: TokenIdentifier, amount_out_min: BigUint) -> PoolResultType<Self::Api>
token_out: The token id that you want to receive after exchanging.
amount_out_min: The minimum amount of token_out that you will receive. If the pool returns an amount that is smaller than amount_out_min the transaction will be reverted.

Estimate the exchange output

#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, PartialEq, TypeAbi, Clone)]
pub struct ExchangeResultType<M: ManagedTypeApi> {
pub total_fee: BigUint<M>,
pub admin_fee: BigUint<M>,
pub token_in: ExchangeAttributes<M>,
pub token_out: ExchangeAttributes<M>,
fn get_amount_out(&self, token_in: &TokenIdentifier, token_out: &TokenIdentifier, amount_in: BigUint) -> ExchangeResultType<Self::Api>

Get AMP factor

fn get_amp_factor(&self) -> u64

Get pool state

#[derive(TopEncode, TopDecode, PartialEq, TypeAbi, Debug)]
pub enum State { Inactive, Active, ActiveNoSwaps }
fn state(&self) -> State;

Get LP token identifier

fn get_lp_token_identifier(&self) -> TokenIdentifier

Get pool tokens

fn get_tokens(&self) -> ManagedVec<TokenIdentifier>

Get token balances

fn get_balances(&self, token: &TokenIdentifier) -> BigUint

Get swap fee

fn swap_fee_percent(&self) -> u64;

Get admin fee

fn admin_fee_percent(&self) -> u64;