AshSwap Docs
Search…
⌃K

Crypto Pool

This pool type will contain not-equivalent-value tokens

Contract Interface

Type

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

Add liquidity

#[payable("*")]
#[endpoint(addLiquidity)]
fn add_liquidity(&self, min_mint_amount: BigUint, opt_receiver: OptionalValue<ManagedAddress>) -> BigUint;

Remove liquidity

#[payable("*")]
#[endpoint(removeLiquidity)]
fn remove_liquidity(&self, min_amounts: ManagedVec<BigUint>, opt_receiver: OptionalValue<ManagedAddress>) -> ManagedVec<BigUint>

Exchange

#[payable("*")]
#[endpoint(exchange)]
fn exchange(&self, min_dy: BigUint) -> BigUint;
dy: the minimum amount of the output token

Estimate the return of exchanging

#[view(estimateAmountOut)]
fn get_dy(self, i: usize, j: usize, dx: BigUint) -> MultiValue2<BigUint, BigUint>
dx: input token amount
i: input token index
j: output token index

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) -> ManagedVec<BigUint>