Trait orml_traits::currency::MultiReservableCurrency
source · pub trait MultiReservableCurrency<AccountId>: MultiCurrency<AccountId> {
fn can_reserve(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> bool;
fn slash_reserved(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> Self::Balance;
fn reserved_balance(
currency_id: Self::CurrencyId,
who: &AccountId
) -> Self::Balance;
fn reserve(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> DispatchResult;
fn unreserve(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> Self::Balance;
fn repatriate_reserved(
currency_id: Self::CurrencyId,
slashed: &AccountId,
beneficiary: &AccountId,
value: Self::Balance,
status: BalanceStatus
) -> Result<Self::Balance, DispatchError>;
}
Expand description
A fungible multi-currency system where funds can be reserved from the user.
Required Methods§
sourcefn can_reserve(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> bool
fn can_reserve(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> bool
Same result as reserve(who, value)
(but without the side-effects)
assuming there are no balance changes in the meantime.
sourcefn slash_reserved(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> Self::Balance
fn slash_reserved(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> Self::Balance
Deducts up to value
from reserved balance of who
. This function
cannot fail.
As much funds up to value
will be deducted as possible. If the reserve
balance of who
is less than value
, then a non-zero excess will
be returned.
sourcefn reserved_balance(
currency_id: Self::CurrencyId,
who: &AccountId
) -> Self::Balance
fn reserved_balance(
currency_id: Self::CurrencyId,
who: &AccountId
) -> Self::Balance
The amount of the balance of a given account that is externally reserved; this can still get slashed, but gets slashed last of all.
This balance is a ‘reserve’ balance that other subsystems use in order to set aside tokens that are still ‘owned’ by the account holder, but which are suspendable.
sourcefn reserve(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> DispatchResult
fn reserve(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> DispatchResult
Moves value
from balance to reserved balance.
If the free balance is lower than value
, then no funds will be moved
and an Err
will be returned to notify of this. This is different
behavior than unreserve
.
sourcefn unreserve(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> Self::Balance
fn unreserve(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::Balance
) -> Self::Balance
Moves up to value
from reserved balance to free balance. This function
cannot fail.
As much funds up to value
will be moved as possible. If the reserve
balance of who
is less than value
, then the remaining amount will be
returned.
NOTES
- This is different from
reserve
.
sourcefn repatriate_reserved(
currency_id: Self::CurrencyId,
slashed: &AccountId,
beneficiary: &AccountId,
value: Self::Balance,
status: BalanceStatus
) -> Result<Self::Balance, DispatchError>
fn repatriate_reserved(
currency_id: Self::CurrencyId,
slashed: &AccountId,
beneficiary: &AccountId,
value: Self::Balance,
status: BalanceStatus
) -> Result<Self::Balance, DispatchError>
Moves up to value
from reserved balance of account slashed
to
balance of account beneficiary
. beneficiary
must exist for this to
succeed. If it does not, Err
will be returned. Funds will be placed in
either the free
balance or the reserved
balance, depending on the
status
.
As much funds up to value
will be deducted as possible. If this is
less than value
, then Ok(non_zero)
will be returned.