Trait frame_support::traits::tokens::currency::NamedReservableCurrency [−][src]
pub trait NamedReservableCurrency<AccountId>: ReservableCurrency<AccountId> { type ReserveIdentifier; fn slash_reserved_named(
id: &Self::ReserveIdentifier,
who: &AccountId,
value: Self::Balance
) -> (Self::NegativeImbalance, Self::Balance); fn reserved_balance_named(
id: &Self::ReserveIdentifier,
who: &AccountId
) -> Self::Balance; fn reserve_named(
id: &Self::ReserveIdentifier,
who: &AccountId,
value: Self::Balance
) -> DispatchResult; fn unreserve_named(
id: &Self::ReserveIdentifier,
who: &AccountId,
value: Self::Balance
) -> Self::Balance; fn repatriate_reserved_named(
id: &Self::ReserveIdentifier,
slashed: &AccountId,
beneficiary: &AccountId,
value: Self::Balance,
status: BalanceStatus
) -> Result<Self::Balance, DispatchError>; fn ensure_reserved_named(
id: &Self::ReserveIdentifier,
who: &AccountId,
value: Self::Balance
) -> DispatchResult { ... } fn unreserve_all_named(
id: &Self::ReserveIdentifier,
who: &AccountId
) -> Self::Balance { ... } fn slash_all_reserved_named(
id: &Self::ReserveIdentifier,
who: &AccountId
) -> Self::NegativeImbalance { ... } fn repatriate_all_reserved_named(
id: &Self::ReserveIdentifier,
slashed: &AccountId,
beneficiary: &AccountId,
status: BalanceStatus
) -> DispatchResult { ... } }
Associated Types
An identifier for a reserve. Used for disambiguating different reserves so that they can be individually replaced or removed.
Required methods
fn slash_reserved_named(
id: &Self::ReserveIdentifier,
who: &AccountId,
value: Self::Balance
) -> (Self::NegativeImbalance, Self::Balance)
fn slash_reserved_named(
id: &Self::ReserveIdentifier,
who: &AccountId,
value: Self::Balance
) -> (Self::NegativeImbalance, 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 second item will be returned.
fn reserved_balance_named(
id: &Self::ReserveIdentifier,
who: &AccountId
) -> Self::Balance
fn reserved_balance_named(
id: &Self::ReserveIdentifier,
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.
When this balance falls below the value of ExistentialDeposit
, then this ‘reserve account’
is deleted: specifically, ReservedBalance
.
system::AccountNonce
is also deleted if FreeBalance
is also zero (it also gets
collapsed to zero if it ever becomes less than ExistentialDeposit
.
fn reserve_named(
id: &Self::ReserveIdentifier,
who: &AccountId,
value: Self::Balance
) -> DispatchResult
fn reserve_named(
id: &Self::ReserveIdentifier,
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
.
fn unreserve_named(
id: &Self::ReserveIdentifier,
who: &AccountId,
value: Self::Balance
) -> Self::Balance
fn unreserve_named(
id: &Self::ReserveIdentifier,
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
. - If the remaining reserved balance is less than
ExistentialDeposit
, it will invokeon_reserved_too_low
and could reap the account.
fn repatriate_reserved_named(
id: &Self::ReserveIdentifier,
slashed: &AccountId,
beneficiary: &AccountId,
value: Self::Balance,
status: BalanceStatus
) -> Result<Self::Balance, DispatchError>
fn repatriate_reserved_named(
id: &Self::ReserveIdentifier,
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.
Provided methods
fn ensure_reserved_named(
id: &Self::ReserveIdentifier,
who: &AccountId,
value: Self::Balance
) -> DispatchResult
fn ensure_reserved_named(
id: &Self::ReserveIdentifier,
who: &AccountId,
value: Self::Balance
) -> DispatchResult
Ensure the reserved balance is equal to value
.
This will reserve extra amount of current reserved balance is less than value
.
And unreserve if current reserved balance is greater than value
.
fn unreserve_all_named(
id: &Self::ReserveIdentifier,
who: &AccountId
) -> Self::Balance
fn unreserve_all_named(
id: &Self::ReserveIdentifier,
who: &AccountId
) -> Self::Balance
Unreserve all the named reserved balances, returning unreserved amount.
Is a no-op if the value to be unreserved is zero.
fn slash_all_reserved_named(
id: &Self::ReserveIdentifier,
who: &AccountId
) -> Self::NegativeImbalance
fn slash_all_reserved_named(
id: &Self::ReserveIdentifier,
who: &AccountId
) -> Self::NegativeImbalance
Slash all the reserved balance, returning the negative imbalance created.
Is a no-op if the value to be slashed is zero.
fn repatriate_all_reserved_named(
id: &Self::ReserveIdentifier,
slashed: &AccountId,
beneficiary: &AccountId,
status: BalanceStatus
) -> DispatchResult
fn repatriate_all_reserved_named(
id: &Self::ReserveIdentifier,
slashed: &AccountId,
beneficiary: &AccountId,
status: BalanceStatus
) -> DispatchResult
Move all the named reserved balance of one account into the balance of another, according to status
.
If status
is Reserved
, the balance will be reserved with given id
.
Is a no-op if:
- the value to be moved is zero; or
- the
slashed
id equal tobeneficiary
and thestatus
isReserved
.