AshSwap Docs
Search…
⌃K

Stable Pool

This pool type contain stable tokens

Contract Interface

Type

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

Add liquidity

#[payable("*")]
#[endpoint(addLiquidity)]
fn add_liquidity(&self, mint_amount_min: BigUint, lp_token_receiver: &ManagedAddress) -> PoolResultType<Self::Api>

Remove liquidity

#[payable("*")]
#[endpoint(removeLiquidity)]
fn remove_liquidity(&self, token_amount_min: MultiValueEncoded<BigUint>) -> PoolResultType<Self::Api>

Exchange

#[payable("*")]
#[endpoint(exchange)]
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>,
}
#[view(estimateAmountOut)]
fn get_amount_out(&self, token_in: &TokenIdentifier, token_out: &TokenIdentifier, amount_in: BigUint) -> ExchangeResultType<Self::Api>

Get AMP factor

#[view(getAmpFactor)]
fn get_amp_factor(&self) -> u64

Get pool state

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

Get LP token identifier

#[view(getLpTokenIdentifier)]
fn get_lp_token_identifier(&self) -> TokenIdentifier

Get pool tokens

#[view(getTokens)]
fn get_tokens(&self) -> ManagedVec<TokenIdentifier>

Get token balances

#[view(getBalances)]
fn get_balances(&self, token: &TokenIdentifier) -> BigUint

Get swap fee

#[view(getSwapFeePercent)]
fn swap_fee_percent(&self) -> u64;

Get admin fee

#[view(getAdminFeePercent)]
fn admin_fee_percent(&self) -> u64;