Trait orml_traits::currency::MultiCurrency

source ·
pub trait MultiCurrency<AccountId> {
    type CurrencyId: FullCodec + Eq + PartialEq + Copy + MaybeSerializeDeserialize + Debug + TypeInfo + MaxEncodedLen;
    type Balance: Balance;

    // Required methods
    fn minimum_balance(currency_id: Self::CurrencyId) -> Self::Balance;
    fn total_issuance(currency_id: Self::CurrencyId) -> Self::Balance;
    fn total_balance(
        currency_id: Self::CurrencyId,
        who: &AccountId
    ) -> Self::Balance;
    fn free_balance(
        currency_id: Self::CurrencyId,
        who: &AccountId
    ) -> Self::Balance;
    fn ensure_can_withdraw(
        currency_id: Self::CurrencyId,
        who: &AccountId,
        amount: Self::Balance
    ) -> DispatchResult;
    fn transfer(
        currency_id: Self::CurrencyId,
        from: &AccountId,
        to: &AccountId,
        amount: Self::Balance
    ) -> DispatchResult;
    fn deposit(
        currency_id: Self::CurrencyId,
        who: &AccountId,
        amount: Self::Balance
    ) -> DispatchResult;
    fn withdraw(
        currency_id: Self::CurrencyId,
        who: &AccountId,
        amount: Self::Balance
    ) -> DispatchResult;
    fn can_slash(
        currency_id: Self::CurrencyId,
        who: &AccountId,
        value: Self::Balance
    ) -> bool;
    fn slash(
        currency_id: Self::CurrencyId,
        who: &AccountId,
        amount: Self::Balance
    ) -> Self::Balance;
}
Expand description

Abstraction over a fungible multi-currency system.

Required Associated Types§

source

type CurrencyId: FullCodec + Eq + PartialEq + Copy + MaybeSerializeDeserialize + Debug + TypeInfo + MaxEncodedLen

The currency identifier.

source

type Balance: Balance

The balance of an account.

Required Methods§

source

fn minimum_balance(currency_id: Self::CurrencyId) -> Self::Balance

Existential deposit of currency_id.

source

fn total_issuance(currency_id: Self::CurrencyId) -> Self::Balance

The total amount of issuance of currency_id.

source

fn total_balance( currency_id: Self::CurrencyId, who: &AccountId ) -> Self::Balance

source

fn free_balance(currency_id: Self::CurrencyId, who: &AccountId) -> Self::Balance

source

fn ensure_can_withdraw( currency_id: Self::CurrencyId, who: &AccountId, amount: Self::Balance ) -> DispatchResult

A dry-run of withdraw. Returns Ok iff the account is able to make a withdrawal of the given amount.

source

fn transfer( currency_id: Self::CurrencyId, from: &AccountId, to: &AccountId, amount: Self::Balance ) -> DispatchResult

Transfer some amount from one account to another.

source

fn deposit( currency_id: Self::CurrencyId, who: &AccountId, amount: Self::Balance ) -> DispatchResult

Add amount to the balance of who under currency_id and increase total issuance.

source

fn withdraw( currency_id: Self::CurrencyId, who: &AccountId, amount: Self::Balance ) -> DispatchResult

Remove amount from the balance of who under currency_id and reduce total issuance.

source

fn can_slash( currency_id: Self::CurrencyId, who: &AccountId, value: Self::Balance ) -> bool

Same result as slash(currency_id, who, value) (but without the side-effects) assuming there are no balance changes in the meantime and only the reserved balance is not taken into account.

source

fn slash( currency_id: Self::CurrencyId, who: &AccountId, amount: Self::Balance ) -> Self::Balance

Deduct the balance of who by up to amount.

As much funds up to amount will be deducted as possible. If this is less than amount, then a non-zero excess value will be returned.

Object Safety§

This trait is not object safe.

Implementors§