pub trait AccountRewards<AccountId> {
    type Balance;
    type CurrencyId;

    // Required methods
    fn deposit_stake(
        currency_id: Self::CurrencyId,
        account_id: &AccountId,
        amount: Self::Balance
    ) -> Result<(), DispatchError>;
    fn withdraw_stake(
        currency_id: Self::CurrencyId,
        account_id: &AccountId,
        amount: Self::Balance
    ) -> Result<(), DispatchError>;
    fn compute_reward(
        currency_id: Self::CurrencyId,
        account_id: &AccountId
    ) -> Result<Self::Balance, DispatchError>;
    fn claim_reward(
        currency_id: Self::CurrencyId,
        account_id: &AccountId
    ) -> Result<Self::Balance, DispatchError>;
    fn account_stake(
        currency_id: Self::CurrencyId,
        account_id: &AccountId
    ) -> Self::Balance;
}
Expand description

Abstraction over a distribution reward system for accounts.

Required Associated Types§

type Balance

Type used as balance for all currencies and reward.

type CurrencyId

Type used to identify the currency.

Required Methods§

fn deposit_stake( currency_id: Self::CurrencyId, account_id: &AccountId, amount: Self::Balance ) -> Result<(), DispatchError>

Deposit a stake amount for a account_id associated to a currency_id. The account_id must have enough currency to make the deposit, if not, an Err will be returned.

fn withdraw_stake( currency_id: Self::CurrencyId, account_id: &AccountId, amount: Self::Balance ) -> Result<(), DispatchError>

Withdraw a stake amount for an account_id associated to a currency_id. The account_id must have enough currency staked to perform a withdraw, if not, an Err will be returned.

fn compute_reward( currency_id: Self::CurrencyId, account_id: &AccountId ) -> Result<Self::Balance, DispatchError>

Computes the reward the account_id can receive for a currency_id. This action does not modify the account currency balance.

fn claim_reward( currency_id: Self::CurrencyId, account_id: &AccountId ) -> Result<Self::Balance, DispatchError>

Computes the reward the account_id can receive for a currency_id and claim it. A reward using the native currency will be sent to the account_id.

fn account_stake( currency_id: Self::CurrencyId, account_id: &AccountId ) -> Self::Balance

Retrieve the total staked amount of currency in an account.

Object Safety§

This trait is not object safe.

Implementors§