[][src]Trait eq_balances::EqCurrency

pub trait EqCurrency<AccountId, Balance> where
    Balance: Member + AtLeast32BitUnsigned + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default
{ fn total_balance(currency: Currency, who: &AccountId) -> Balance;
fn debt(currency: Currency, who: &AccountId) -> Balance;
fn can_slash(currency: Currency, who: &AccountId, value: Balance) -> bool;
fn currency_total_issuance(currency: Currency) -> Balance;
fn currency_minimum_balance(currency: Currency) -> Balance;
fn burn(currency: Currency, amount: Balance) -> PositiveImbalance<Balance>;
fn issue(currency: Currency, amount: Balance) -> NegativeImbalance<Balance>;
fn free_balance(currency: Currency, who: &AccountId) -> Balance;
fn ensure_can_withdraw(
        currency: Currency,
        who: &AccountId,
        amount: Balance,
        reasons: WithdrawReasons,
        new_balance: Balance
    ) -> DispatchResult;
fn currency_transfer(
        currency: Currency,
        transactor: &AccountId,
        dest: &AccountId,
        value: Balance,
        existence_requirement: ExistenceRequirement,
        transfer_reason: TransferReason,
        ensure_can_change: bool
    ) -> DispatchResult;
fn slash(
        currency: Currency,
        who: &AccountId,
        value: Balance
    ) -> (NegativeImbalance<Balance>, Balance);
fn deposit_into_existing(
        currency: Currency,
        who: &AccountId,
        value: Balance
    ) -> Result<PositiveImbalance<Balance>, DispatchError>;
fn deposit_creating(
        currency: Currency,
        who: &AccountId,
        value: Balance,
        ensure_can_change: bool
    ) -> PositiveImbalance<Balance>;
fn withdraw(
        currency: Currency,
        who: &AccountId,
        value: Balance,
        reasons: WithdrawReasons,
        liveness: ExistenceRequirement,
        ensure_can_change: bool
    ) -> Result<NegativeImbalance<Balance>, DispatchError>;
fn make_free_balance_be(
        currency: Currency,
        who: &AccountId,
        value: Balance
    ) -> SignedImbalance<Balance, PositiveImbalance<Balance>>; fn resolve_creating(
        currency: Currency,
        who: &AccountId,
        value: NegativeImbalance<Balance>
    ) { ... } }

An extension to Substrate standard Currency, adapting it to work in Equilibrium substrate

Required methods

fn total_balance(currency: Currency, who: &AccountId) -> Balance

Returns balance value if balance is positive or zero if negative

fn debt(currency: Currency, who: &AccountId) -> Balance

Returns balance value if balance is negative or zero if negative

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

fn currency_total_issuance(currency: Currency) -> Balance

Gets total issuance of given currency

fn currency_minimum_balance(currency: Currency) -> Balance

Returns ExistentialDeposit for given currency

fn burn(currency: Currency, amount: Balance) -> PositiveImbalance<Balance>

Unimplemented

fn issue(currency: Currency, amount: Balance) -> NegativeImbalance<Balance>

Unimplemented. Use deposit instead

fn free_balance(currency: Currency, who: &AccountId) -> Balance

Same as total_balance

fn ensure_can_withdraw(
    currency: Currency,
    who: &AccountId,
    amount: Balance,
    reasons: WithdrawReasons,
    new_balance: Balance
) -> DispatchResult

Used to ensure that user's balance in specified currency can be decreased for amount

fn currency_transfer(
    currency: Currency,
    transactor: &AccountId,
    dest: &AccountId,
    value: Balance,
    existence_requirement: ExistenceRequirement,
    transfer_reason: TransferReason,
    ensure_can_change: bool
) -> DispatchResult

Operates transfers inside pallet functions

  • transactor - account sending currency
  • dest - account receiving currency
  • value - amount transferred
  • existence_requirement - currently unused
  • ensure_can_change - flag for ensuring transfer can be performed with can_change_balance

fn slash(
    currency: Currency,
    who: &AccountId,
    value: Balance
) -> (NegativeImbalance<Balance>, Balance)

fn deposit_into_existing(
    currency: Currency,
    who: &AccountId,
    value: Balance
) -> Result<PositiveImbalance<Balance>, DispatchError>

Adds given amount of currency to account's balance

fn deposit_creating(
    currency: Currency,
    who: &AccountId,
    value: Balance,
    ensure_can_change: bool
) -> PositiveImbalance<Balance>

Performs a deposit creating balance storage for account if it does not exist

fn withdraw(
    currency: Currency,
    who: &AccountId,
    value: Balance,
    reasons: WithdrawReasons,
    liveness: ExistenceRequirement,
    ensure_can_change: bool
) -> Result<NegativeImbalance<Balance>, DispatchError>

Decreases who account balance for specified amount of currency

fn make_free_balance_be(
    currency: Currency,
    who: &AccountId,
    value: Balance
) -> SignedImbalance<Balance, PositiveImbalance<Balance>>

Force the new free balance of a target account to some new value

Loading content...

Provided methods

fn resolve_creating(
    currency: Currency,
    who: &AccountId,
    value: NegativeImbalance<Balance>
)

Similar to deposit_creating, only accepts a NegativeImbalance and returns nothing on success

Loading content...

Implementors

impl<T: Trait> EqCurrency<<T as Trait>::AccountId, <T as Trait>::Balance> for Module<T>[src]

Loading content...