Trait hydradx_traits::AMM

source ·
pub trait AMM<AccountId, AssetId, AssetPair, Amount: Zero> {
Show 16 methods fn exists(assets: AssetPair) -> bool; fn get_pair_id(assets: AssetPair) -> AccountId; fn get_share_token(assets: AssetPair) -> AssetId; fn get_pool_assets(pool_account_id: &AccountId) -> Option<Vec<AssetId>>; fn get_spot_price_unchecked(
        asset_a: AssetId,
        asset_b: AssetId,
        amount: Amount
    ) -> Amount; fn validate_sell(
        origin: &AccountId,
        assets: AssetPair,
        amount: Amount,
        min_bought: Amount,
        discount: bool
    ) -> Result<AMMTransfer<AccountId, AssetId, AssetPair, Amount>, DispatchError>; fn execute_sell(
        transfer: &AMMTransfer<AccountId, AssetId, AssetPair, Amount>
    ) -> DispatchResult; fn validate_buy(
        origin: &AccountId,
        assets: AssetPair,
        amount: Amount,
        max_limit: Amount,
        discount: bool
    ) -> Result<AMMTransfer<AccountId, AssetId, AssetPair, Amount>, DispatchError>; fn execute_buy(
        transfer: &AMMTransfer<AccountId, AssetId, AssetPair, Amount>
    ) -> DispatchResult; fn get_min_trading_limit() -> Amount; fn get_min_pool_liquidity() -> Amount; fn get_max_in_ratio() -> u128; fn get_max_out_ratio() -> u128; fn get_fee(pool_account_id: &AccountId) -> (u32, u32); fn sell(
        origin: &AccountId,
        assets: AssetPair,
        amount: Amount,
        min_bought: Amount,
        discount: bool
    ) -> DispatchResult { ... } fn buy(
        origin: &AccountId,
        assets: AssetPair,
        amount: Amount,
        max_limit: Amount,
        discount: bool
    ) -> DispatchResult { ... }
}
Expand description

Traits for handling AMM Pool trades.

Required Methods§

Check if both assets exist in a pool.

Return pair account.

Return share token for assets.

Return list of active assets in a given pool.

Calculate spot price for asset a and b.

Sell trade validation Perform all necessary checks to validate an intended sale.

Execute buy for given validated transfer.

Buy trade validation Perform all necessary checks to validate an intended buy.

Execute buy for given validated transfer.

Provided Methods§

Perform asset swap. Call execute following the validation.

Perform asset swap.

Implementors§