pub trait MutateLiquidity<AccountId> {
type Balance: Balance;
type AssetKind;
type PoolId;
// Required methods
fn create_pool(
creator: &AccountId,
asset1: Self::AssetKind,
asset2: Self::AssetKind,
) -> Result<Self::PoolId, DispatchError>;
fn add_liquidity(
who: &AccountId,
asset1: AddLiquidityAsset<Self::AssetKind, Self::Balance>,
asset2: AddLiquidityAsset<Self::AssetKind, Self::Balance>,
mint_to: &AccountId,
) -> Result<Self::Balance, DispatchError>;
fn remove_liquidity(
who: &AccountId,
asset1: Self::AssetKind,
asset2: Self::AssetKind,
lp_token_burn: Self::Balance,
amount1_min_receive: Self::Balance,
amount2_min_receive: Self::Balance,
withdraw_to: &AccountId,
) -> Result<(Self::Balance, Self::Balance), DispatchError>;
}Expand description
Trait for providing methods to mutate liquidity pools. This includes creating pools, adding liquidity, and removing liquidity.
Required Associated Types§
Required Methods§
Sourcefn create_pool(
creator: &AccountId,
asset1: Self::AssetKind,
asset2: Self::AssetKind,
) -> Result<Self::PoolId, DispatchError>
fn create_pool( creator: &AccountId, asset1: Self::AssetKind, asset2: Self::AssetKind, ) -> Result<Self::PoolId, DispatchError>
Creates a new liquidity pool for the given assets.
Mints LP tokens to the creator account.
Returns the ID of the newly created pool.
Sourcefn add_liquidity(
who: &AccountId,
asset1: AddLiquidityAsset<Self::AssetKind, Self::Balance>,
asset2: AddLiquidityAsset<Self::AssetKind, Self::Balance>,
mint_to: &AccountId,
) -> Result<Self::Balance, DispatchError>
fn add_liquidity( who: &AccountId, asset1: AddLiquidityAsset<Self::AssetKind, Self::Balance>, asset2: AddLiquidityAsset<Self::AssetKind, Self::Balance>, mint_to: &AccountId, ) -> Result<Self::Balance, DispatchError>
Adds liquidity to an existing pool.
Mints LP tokens to the mint_to account.
Returns the amount of LP tokens minted.
Sourcefn remove_liquidity(
who: &AccountId,
asset1: Self::AssetKind,
asset2: Self::AssetKind,
lp_token_burn: Self::Balance,
amount1_min_receive: Self::Balance,
amount2_min_receive: Self::Balance,
withdraw_to: &AccountId,
) -> Result<(Self::Balance, Self::Balance), DispatchError>
fn remove_liquidity( who: &AccountId, asset1: Self::AssetKind, asset2: Self::AssetKind, lp_token_burn: Self::Balance, amount1_min_receive: Self::Balance, amount2_min_receive: Self::Balance, withdraw_to: &AccountId, ) -> Result<(Self::Balance, Self::Balance), DispatchError>
Removes liquidity from a pool.
Burns LP tokens from the who account and transfers the withdrawn assets to the
withdraw_to account.
Returns the amounts of assets withdrawn.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.