Trait orml_traits::currency::BasicCurrency

source ·
pub trait BasicCurrency<AccountId> {
    type Balance: AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + MaxEncodedLen;

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

Abstraction over a fungible (single) currency system.

Required Associated Types§

Required Methods§

source

fn minimum_balance() -> Self::Balance

Existential deposit.

source

fn total_issuance() -> Self::Balance

The total amount of issuance.

source

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

The combined balance of who.

source

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

The free balance of who.

source

fn ensure_can_withdraw(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( from: &AccountId, to: &AccountId, amount: Self::Balance ) -> DispatchResult

Transfer some amount from one account to another.

source

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

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

source

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

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

source

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

Same result as slash(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(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§