Crypto Pool
This pool type will contain not-equivalent-value tokens
pub type PoolResultType<BigUint> = ManagedVec<BigUint, EsdtTokenPayment<BigUint>>;
pub struct AddLiquidityEvent<M: ManagedTypeApi> {
pub token_amounts: ManagedVec<M, BigUint<M>>,
pub fee: BigUint<M>,
pub lp_token_supply: BigUint<M>,
pub lp_token_amount: BigUint<M>,
}
pub struct RemoveLiquidityEvent<M: ManagedTypeApi> {
pub token_amounts: ManagedVec<M, BigUint<M>>,
pub lp_token_supply: BigUint<M>,
pub lp_token_amount: BigUint<M>,
}
pub struct TokenExchangeEvent<M: ManagedTypeApi> {
pub sold_id: TokenIdentifier<M>,
pub tokens_sold: BigUint<M>,
pub bought_id: TokenIdentifier<M>,
pub tokens_bought: BigUint<M>,
}
#[payable("*")]
#[endpoint(addLiquidity)]
fn add_liquidity(&self, min_mint_amount: BigUint, opt_receiver: OptionalValue<ManagedAddress>) -> BigUint;
#[payable("*")]
#[endpoint(removeLiquidity)]
fn remove_liquidity(&self, min_amounts: ManagedVec<BigUint>, opt_receiver: OptionalValue<ManagedAddress>) -> ManagedVec<BigUint>
#[payable("*")]
#[endpoint(exchange)]
fn exchange(&self, min_dy: BigUint) -> BigUint;
dy
: the minimum amount of the output token#[view(estimateAmountOut)]
fn get_dy(self, i: usize, j: usize, dx: BigUint) -> MultiValue2<BigUint, BigUint>
dx
: input token amounti
: input token indexj
: output token index#[derive(TopEncode, TopDecode, PartialEq, TypeAbi, Debug)]
pub enum State { Inactive, Active, ActiveNoSwaps }
#[view(getState)]
fn state(&self) -> State;
#[view(getLpTokenIdentifier)]
fn get_lp_token_identifier(&self) -> TokenIdentifier
#[view(getTotalSupply)]
fn get_lp_token_supply(&self) -> BigUint
#[view(getTokens)]
fn get_tokens(&self) -> ManagedVec<TokenIdentifier>
#[view(getBalances)]
fn get_balances(&self) -> ManagedVec<BigUint>
#[event("token_exchange")]
fn token_exchange_event(
&self,
#[indexed] buyer: ManagedAddress<Self::Api>,
token_exchange_event: &TokenExchangeEvent<Self::Api>,
);
#[event("add_liquidity")]
fn add_liquidity_event(
&self,
#[indexed] provider: ManagedAddress<Self::Api>,
add_liquidity_event: &AddLiquidityEvent<Self::Api>,
);
#[event("remove_liquidity")]
fn remove_liquidity_event(
&self,
#[indexed] provider: ManagedAddress<Self::Api>,
remove_liquidity_event: &RemoveLiquidityEvent<Self::Api>,
);
Last modified 1mo ago