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§

Required Methods§

source

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.

source

fn reward_group( group: &mut Self::Group, amount: Self::Balance ) -> Result<Self::Balance, DispatchError>

Reward the group mutating the group entity.

source

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.

source

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.

source

fn compute_reward( account: &Self::Account, currency: &Self::Currency, group: &Self::Group ) -> Result<Self::Balance, DispatchError>

Computes the reward for the account

source

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.

source

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.

source

fn account_stake(account: &Self::Account) -> Self::Balance

Returns the balance of an account

source

fn group_stake(group: &Self::Group) -> Self::Balance

Returns the balance of a group

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Balance, IBalance, Rate, MaxCurrencyMovements> RewardMechanism for Mechanism<Balance, IBalance, Rate, MaxCurrencyMovements>
where Balance: Balance + FixedPointOperand + TryFrom<IBalance>, IBalance: FixedPointOperand + TryFrom<Balance> + EnsureAdd + EnsureSub + Copy + Signed + Debug, Rate: EnsureFixedPointNumber, MaxCurrencyMovements: Get<u32>, <Rate as FixedPointNumber>::Inner: Signed,

§

type Account = Account<<Mechanism<Balance, IBalance, Rate, MaxCurrencyMovements> as RewardMechanism>::Balance, IBalance>

§

type Balance = Balance

§

type Currency = Currency<Balance, Rate, MaxCurrencyMovements>

§

type Group = Group<Balance, Rate>

§

type MaxCurrencyMovements = MaxCurrencyMovements

source§

impl<T: Config> RewardMechanism for pallet_rewards::mechanism::deferred::pallet::Pallet<T>
where <T::Rate as FixedPointNumber>::Inner: Signed,

source§

impl<T: Config> RewardMechanism for pallet_rewards::mechanism::gap::pallet::Pallet<T>
where <T::Rate as FixedPointNumber>::Inner: Signed,