pub trait OnChargeAssetTransaction<T: Config> {
    type Balance: Balance;
    type AssetId: AssetId;
    type LiquidityInfo;

    // Required methods
    fn withdraw_fee(
        who: &T::AccountId,
        call: &T::RuntimeCall,
        dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
        asset_id: Self::AssetId,
        fee: Self::Balance,
        tip: Self::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 correct_and_deposit_fee(
        who: &T::AccountId,
        dispatch_info: &DispatchInfoOf<T::RuntimeCall>,
        post_info: &PostDispatchInfoOf<T::RuntimeCall>,
        corrected_fee: Self::Balance,
        tip: Self::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>;
}
Expand description

Handle withdrawing, refunding and depositing of transaction fees.

Required Associated Types§

source

type Balance: Balance

The underlying integer type in which fees are calculated.

source

type AssetId: AssetId

The type used to identify the assets used for transaction payment.

source

type LiquidityInfo

The type used to store the intermediate values between pre- and post-dispatch.

Required Methods§

source

fn withdraw_fee( who: &T::AccountId, call: &T::RuntimeCall, dispatch_info: &DispatchInfoOf<T::RuntimeCall>, asset_id: Self::AssetId, fee: Self::Balance, tip: Self::Balance ) -> Result<(<<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::LiquidityInfo, Self::LiquidityInfo, <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::Balance), TransactionValidityError>

Secure the payment of the transaction fees before the transaction is executed.

Note: The fee already includes the tip.

source

fn correct_and_deposit_fee( who: &T::AccountId, dispatch_info: &DispatchInfoOf<T::RuntimeCall>, post_info: &PostDispatchInfoOf<T::RuntimeCall>, corrected_fee: Self::Balance, tip: Self::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>

Refund any overpaid fees and deposit the corrected amount. The actual fee gets calculated once the transaction is executed.

Note: The fee already includes the tip.

Returns the fee and tip in the asset used for payment as (fee, tip).

Implementors§

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>,

Default implementation for a runtime instantiating this pallet, an asset to native swapper.

§

type Balance = <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance

§

type AssetId = <<T as Config>::Fungibles as Inspect<<T as Config>::AccountId>>::AssetId

§

type LiquidityInfo = <<T as Config>::OnChargeTransaction as OnChargeTransaction<T>>::Balance