Trait pallet_rewards::mechanism::RewardMechanism
source · pub trait RewardMechanism {
type Group;
type Account;
type Currency;
type Balance: Balance;
type MaxCurrencyMovements: Get<u32>;
// Required methods
fn is_ready(group: &Self::Group) -> bool;
fn reward_group(
group: &mut Self::Group,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError>;
fn deposit_stake(
account: &mut Self::Account,
currency: &mut Self::Currency,
group: &mut Self::Group,
amount: Self::Balance
) -> DispatchResult;
fn withdraw_stake(
account: &mut Self::Account,
currency: &mut Self::Currency,
group: &mut Self::Group,
amount: Self::Balance
) -> DispatchResult;
fn compute_reward(
account: &Self::Account,
currency: &Self::Currency,
group: &Self::Group
) -> Result<Self::Balance, DispatchError>;
fn claim_reward(
account: &mut Self::Account,
currency: &Self::Currency,
group: &Self::Group
) -> Result<Self::Balance, DispatchError>;
fn move_currency(
currency: &mut Self::Currency,
from_group: &mut Self::Group,
to_group: &mut Self::Group
) -> Result<(), MoveCurrencyError>;
fn account_stake(account: &Self::Account) -> Self::Balance;
fn group_stake(group: &Self::Group) -> Self::Balance;
}
Required Associated Types§
type Group
type Account
type Currency
type Balance: Balance
type MaxCurrencyMovements: Get<u32>
Required Methods§
sourcefn is_ready(group: &Self::Group) -> bool
fn is_ready(group: &Self::Group) -> bool
Check if the group is ready to be rewarded. Most of the cases it means that the group has stake that should be rewarded.
sourcefn reward_group(
group: &mut Self::Group,
amount: Self::Balance
) -> Result<Self::Balance, DispatchError>
fn reward_group( group: &mut Self::Group, amount: Self::Balance ) -> Result<Self::Balance, DispatchError>
Reward the group mutating the group entity.
sourcefn deposit_stake(
account: &mut Self::Account,
currency: &mut Self::Currency,
group: &mut Self::Group,
amount: Self::Balance
) -> DispatchResult
fn deposit_stake( account: &mut Self::Account, currency: &mut Self::Currency, group: &mut Self::Group, amount: Self::Balance ) -> DispatchResult
Add stake to the account and mutates currency and group to archieve that.
sourcefn withdraw_stake(
account: &mut Self::Account,
currency: &mut Self::Currency,
group: &mut Self::Group,
amount: Self::Balance
) -> DispatchResult
fn withdraw_stake( account: &mut Self::Account, currency: &mut Self::Currency, group: &mut Self::Group, amount: Self::Balance ) -> DispatchResult
Remove stake from the account and mutates currency and group to archieve that.
sourcefn compute_reward(
account: &Self::Account,
currency: &Self::Currency,
group: &Self::Group
) -> Result<Self::Balance, DispatchError>
fn compute_reward( account: &Self::Account, currency: &Self::Currency, group: &Self::Group ) -> Result<Self::Balance, DispatchError>
Computes the reward for the account
sourcefn claim_reward(
account: &mut Self::Account,
currency: &Self::Currency,
group: &Self::Group
) -> Result<Self::Balance, DispatchError>
fn claim_reward( account: &mut Self::Account, currency: &Self::Currency, group: &Self::Group ) -> Result<Self::Balance, DispatchError>
Claims the reward, mutating the account to reflect this action. Once a reward is claimed, next calls will return 0 until the group will be rewarded again.
sourcefn move_currency(
currency: &mut Self::Currency,
from_group: &mut Self::Group,
to_group: &mut Self::Group
) -> Result<(), MoveCurrencyError>
fn move_currency( currency: &mut Self::Currency, from_group: &mut Self::Group, to_group: &mut Self::Group ) -> Result<(), MoveCurrencyError>
Move a currency from one group to another one.
sourcefn account_stake(account: &Self::Account) -> Self::Balance
fn account_stake(account: &Self::Account) -> Self::Balance
Returns the balance of an account
sourcefn group_stake(group: &Self::Group) -> Self::Balance
fn group_stake(group: &Self::Group) -> Self::Balance
Returns the balance of a group
Object Safety§
This trait is not object safe.