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

    // Required methods
    fn deposit_stake(
        currency_id: Self::CurrencyId,
        account_id: &AccountId,
        amount: Self::Balance
    ) -> DispatchResult;
    fn withdraw_stake(
        currency_id: Self::CurrencyId,
        account_id: &AccountId,
        amount: Self::Balance
    ) -> DispatchResult;
    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§

source

type Balance

Type used as balance for all currencies and reward.

source

type CurrencyId

Type used to identify the currency.

Required Methods§

source

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

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.

source

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

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.

source

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.

source

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.

source

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§