Trait staging_xcm_executor::traits::AssetExchange
source · pub trait AssetExchange {
// Required methods
fn exchange_asset(
origin: Option<&Location>,
give: AssetsInHolding,
want: &Assets,
maximal: bool,
) -> Result<AssetsInHolding, AssetsInHolding>;
fn quote_exchange_price(
_give: &Assets,
_want: &Assets,
_maximal: bool,
) -> Option<Assets>;
}
Expand description
A service for exchanging assets.
Required Methods§
sourcefn exchange_asset(
origin: Option<&Location>,
give: AssetsInHolding,
want: &Assets,
maximal: bool,
) -> Result<AssetsInHolding, AssetsInHolding>
fn exchange_asset( origin: Option<&Location>, give: AssetsInHolding, want: &Assets, maximal: bool, ) -> Result<AssetsInHolding, AssetsInHolding>
Handler for exchanging an asset.
origin
: The location attempting the exchange; this should generally not matter.give
: The assets which have been removed from the caller.want
: The minimum amount of assets which should be given to the caller in case any exchange happens. If more assets are provided, then they should generally be of the same asset class if at all possible.maximal
: Iftrue
, then as much as possible should be exchanged.
Ok
is returned along with the new set of assets which have been exchanged for give
. At
least want must be in the set. Some assets originally in give
may also be in this set. In
the case of returning an Err
, then give
is returned.
sourcefn quote_exchange_price(
_give: &Assets,
_want: &Assets,
_maximal: bool,
) -> Option<Assets>
fn quote_exchange_price( _give: &Assets, _want: &Assets, _maximal: bool, ) -> Option<Assets>
Handler for quoting the exchange price of two asset collections.
It’s useful before calling exchange_asset
, to get some information on whether or not the
exchange will be successful.
Arguments:
give
The asset(s) that are going to be given.want
The asset(s) that are wanted.maximal
: - Iftrue
, then the return value is the resulting amount ofwant
obtained by swappinggive
.- If
false
, then the return value is the required amount ofgive
needed to getwant
.
- If
The return value is Assets
since it comprises both which assets and how much of them.
The relationship between this function and exchange_asset
is the following:
- quote(give, want, maximal) = resulting_want -> exchange(give, resulting_want, maximal) ✅
- quote(give, want, minimal) = required_give -> exchange(required_give_amount, want, minimal) ✅
Object Safety§
This trait is not object safe.