This pallet provides the functionality to accept transaction fees in other currencies.
It extends Substrate's
Transaction fees are paid in native currency by default. This pallet allows to set a different currency to pay fees with.
When the transaction fees are being paid and the chosen currency is not native currency, a swap is executed to obtain fee amount in native currency first.
The swap (or buy) is done via selected AMM pool.
Subsequently, the fee is paid in the native currency.
Currency deals with the native asset while MultiCurrency deals with all other currencies in the system.
AMMPool is again (like with exchange pallet) an implementation of AMM pool which will be used to swap non-native currency for native.
We want to allow users to set currency even if they don't have any native currency. THerefore, the tx fee payment is set to Pays::No
However, the fee is withdrawn when currency is successfully set. It is a fixed fee consisting of base fee and set_currency weight.
A map between an account and a chosen currency in which fees are paid.
A curated list of currencies which can be used to pay fees. It is possible to select a currency only if it is in this list.
Only selected members can add or remove currency from this list.
List of accounts which are allowed to add or remove currencies from the list of accepted currencies.
Only a root can add a member to this list.
There are few extrinsics in this pallet. All are self-explanatory and easy to understand just by look at the Implementation.
Where is the actual
hook in the runtime where the fees are paid?
This is list of signed extensions which every transaction has to go through. And one of them is ChargeTransactionPayment.
The multi payment transaction pallet implements the
OnChargeTransaction trait and handles the withdraw_fee accordingly.
swap_currency ensures that there is enough balance of the native currency to pay the fee by swapping the chosen currency for native currency.