Trait pallet_asset_conversion::QuotePrice

source ·
pub trait QuotePrice {
    type Balance: Balance;
    type AssetKind;

    // Required methods
    fn quote_price_tokens_for_exact_tokens(
        asset1: Self::AssetKind,
        asset2: Self::AssetKind,
        amount: Self::Balance,
        include_fee: bool,
    ) -> Option<Self::Balance>;
    fn quote_price_exact_tokens_for_tokens(
        asset1: Self::AssetKind,
        asset2: Self::AssetKind,
        amount: Self::Balance,
        include_fee: bool,
    ) -> Option<Self::Balance>;
}
Expand description

Trait providing methods to quote swap prices between asset classes.

The quoted price is only guaranteed if no other swaps are made after the price is quoted and before the target swap (e.g., the swap is made immediately within the same transaction).

Required Associated Types§

source

type Balance: Balance

Measurement units of the asset classes for pricing.

source

type AssetKind

Type representing the kind of assets for which the price is being quoted.

Required Methods§

source

fn quote_price_tokens_for_exact_tokens( asset1: Self::AssetKind, asset2: Self::AssetKind, amount: Self::Balance, include_fee: bool, ) -> Option<Self::Balance>

Quotes the amount of asset1 required to obtain the exact amount of asset2.

If include_fee is set to true, the price will include the pool’s fee. If the pool does not exist or the swap cannot be made, None is returned.

source

fn quote_price_exact_tokens_for_tokens( asset1: Self::AssetKind, asset2: Self::AssetKind, amount: Self::Balance, include_fee: bool, ) -> Option<Self::Balance>

Quotes the amount of asset2 resulting from swapping the exact amount of asset1.

If include_fee is set to true, the price will include the pool’s fee. If the pool does not exist or the swap cannot be made, None is returned.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T: Config> QuotePrice for Pallet<T>

§

type Balance = <T as Config>::Balance

§

type AssetKind = <T as Config>::AssetKind