pub struct AssetConversionAdapter<C, CON>(_);
Expand description
Implements the asset transaction for a balance to asset converter (implementing [Swap
]).
The converter is given the complete fee in terms of the asset used for the transaction.
Trait Implementations§
source§impl<T, C, CON> OnChargeAssetTransaction<T> for AssetConversionAdapter<C, CON>where
T: Config,
C: Inspect<<T as Config>::AccountId>,
CON: Swap<T::AccountId, T::HigherPrecisionBalance, T::MultiAssetId>,
T::HigherPrecisionBalance: From<<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance> + TryInto<<<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance>,
T::MultiAssetId: From<<<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::AssetId>,
<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: IsType<<C as Inspect<<T as Config>::AccountId>>::Balance>,
impl<T, C, CON> OnChargeAssetTransaction<T> for AssetConversionAdapter<C, CON>where T: Config, C: Inspect<<T as Config>::AccountId>, CON: Swap<T::AccountId, T::HigherPrecisionBalance, T::MultiAssetId>, T::HigherPrecisionBalance: From<<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance> + TryInto<<<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance>, T::MultiAssetId: From<<<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::AssetId>, <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance: IsType<<C as Inspect<<T as Config>::AccountId>>::Balance>,
Default implementation for a runtime instantiating this pallet, an asset to native swapper.
source§fn withdraw_fee(
who: &T::AccountId,
call: &T::RuntimeCall,
info: &DispatchInfoOf<T::RuntimeCall>,
asset_id: Self::AssetId,
fee: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance,
tip: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance
) -> Result<(<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::LiquidityInfo, Self::LiquidityInfo, <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance), TransactionValidityError>
fn withdraw_fee( who: &T::AccountId, call: &T::RuntimeCall, info: &DispatchInfoOf<T::RuntimeCall>, asset_id: Self::AssetId, fee: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance, tip: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance ) -> Result<(<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::LiquidityInfo, Self::LiquidityInfo, <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance), TransactionValidityError>
Swap & withdraw the predicted fee from the transaction origin.
Note: The fee
already includes the tip
.
Returns the total amount in native currency received by exchanging the asset_id
and the
amount in native currency used to pay the fee.
source§fn correct_and_deposit_fee(
who: &T::AccountId,
dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
post_info: &PostDispatchInfoOf<T::RuntimeCall>,
corrected_fee: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance,
tip: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance,
fee_paid: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::LiquidityInfo,
received_exchanged: Self::LiquidityInfo,
asset_id: Self::AssetId,
initial_asset_consumed: <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance
) -> Result<<<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance, TransactionValidityError>
fn correct_and_deposit_fee( who: &T::AccountId, dispatch_info: &DispatchInfoOf<T::RuntimeCall>, post_info: &PostDispatchInfoOf<T::RuntimeCall>, corrected_fee: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance, tip: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance, fee_paid: <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::LiquidityInfo, received_exchanged: Self::LiquidityInfo, asset_id: Self::AssetId, initial_asset_consumed: <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance ) -> Result<<<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance, TransactionValidityError>
Correct the fee and swap the refund back to asset.
Note: The corrected_fee
already includes the tip
.
Note: Is the ED wasn’t needed, the received_exchanged
will be equal to fee_paid
, or
fee_paid + ed
otherwise.
§type Balance = <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance
type Balance = <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance
The underlying integer type in which fees are calculated.
§type AssetId = <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::AssetId
type AssetId = <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::AssetId
The type used to identify the assets used for transaction payment.
§type LiquidityInfo = <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance
type LiquidityInfo = <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance
The type used to store the intermediate values between pre- and post-dispatch.
Auto Trait Implementations§
impl<C, CON> RefUnwindSafe for AssetConversionAdapter<C, CON>where C: RefUnwindSafe, CON: RefUnwindSafe,
impl<C, CON> Send for AssetConversionAdapter<C, CON>where C: Send, CON: Send,
impl<C, CON> Sync for AssetConversionAdapter<C, CON>where C: Sync, CON: Sync,
impl<C, CON> Unpin for AssetConversionAdapter<C, CON>where C: Unpin, CON: Unpin,
impl<C, CON> UnwindSafe for AssetConversionAdapter<C, CON>where C: UnwindSafe, CON: UnwindSafe,
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of
T
. Read more§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
The counterpart to
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of
T
.