Trait cfg_traits::rewards::AccountRewards
source · 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§
sourcetype CurrencyId
type CurrencyId
Type used to identify the currency.
Required Methods§
sourcefn deposit_stake(
currency_id: Self::CurrencyId,
account_id: &AccountId,
amount: Self::Balance
) -> DispatchResult
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.
sourcefn withdraw_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
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.
sourcefn compute_reward(
currency_id: Self::CurrencyId,
account_id: &AccountId
) -> Result<Self::Balance, DispatchError>
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.
sourcefn claim_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>
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.
sourcefn account_stake(
currency_id: Self::CurrencyId,
account_id: &AccountId
) -> Self::Balance
fn account_stake( currency_id: Self::CurrencyId, account_id: &AccountId ) -> Self::Balance
Retrieve the total staked amount of currency in an account.