Trait reward::RewardsApi
source · pub trait RewardsApi<PoolId, StakeId, Balance>where
Balance: Saturating + PartialOrd + Copy,{
type CurrencyId;
// Required methods
fn reward_currencies_len(pool_id: &PoolId) -> u32;
fn distribute_reward(
pool_id: &PoolId,
currency_id: Self::CurrencyId,
amount: Balance
) -> DispatchResult;
fn compute_reward(
pool_id: &PoolId,
stake_id: &StakeId,
currency_id: Self::CurrencyId
) -> Result<Balance, DispatchError>;
fn withdraw_reward(
pool_id: &PoolId,
stake_id: &StakeId,
currency_id: Self::CurrencyId
) -> Result<Balance, DispatchError>;
fn deposit_stake(
pool_id: &PoolId,
stake_id: &StakeId,
amount: Balance
) -> DispatchResult;
fn withdraw_stake(
pool_id: &PoolId,
stake_id: &StakeId,
amount: Balance
) -> DispatchResult;
fn get_total_stake(pool_id: &PoolId) -> Result<Balance, DispatchError>;
fn get_stake(
pool_id: &PoolId,
stake_id: &StakeId
) -> Result<Balance, DispatchError>;
// Provided methods
fn withdraw_all_stake(
pool_id: &PoolId,
stake_id: &StakeId
) -> Result<Balance, DispatchError> { ... }
fn set_stake(
pool_id: &PoolId,
stake_id: &StakeId,
amount: Balance
) -> DispatchResult { ... }
}
Required Associated Types§
type CurrencyId
Required Methods§
fn reward_currencies_len(pool_id: &PoolId) -> u32
sourcefn distribute_reward(
pool_id: &PoolId,
currency_id: Self::CurrencyId,
amount: Balance
) -> DispatchResult
fn distribute_reward( pool_id: &PoolId, currency_id: Self::CurrencyId, amount: Balance ) -> DispatchResult
Distribute the amount
to all participants OR error if zero total stake.
sourcefn compute_reward(
pool_id: &PoolId,
stake_id: &StakeId,
currency_id: Self::CurrencyId
) -> Result<Balance, DispatchError>
fn compute_reward( pool_id: &PoolId, stake_id: &StakeId, currency_id: Self::CurrencyId ) -> Result<Balance, DispatchError>
Compute the expected reward for the stake_id
.
sourcefn withdraw_reward(
pool_id: &PoolId,
stake_id: &StakeId,
currency_id: Self::CurrencyId
) -> Result<Balance, DispatchError>
fn withdraw_reward( pool_id: &PoolId, stake_id: &StakeId, currency_id: Self::CurrencyId ) -> Result<Balance, DispatchError>
Withdraw all rewards from the stake_id
.
sourcefn deposit_stake(
pool_id: &PoolId,
stake_id: &StakeId,
amount: Balance
) -> DispatchResult
fn deposit_stake( pool_id: &PoolId, stake_id: &StakeId, amount: Balance ) -> DispatchResult
Deposit stake for an account.
sourcefn withdraw_stake(
pool_id: &PoolId,
stake_id: &StakeId,
amount: Balance
) -> DispatchResult
fn withdraw_stake( pool_id: &PoolId, stake_id: &StakeId, amount: Balance ) -> DispatchResult
Withdraw stake for an account.
sourcefn get_total_stake(pool_id: &PoolId) -> Result<Balance, DispatchError>
fn get_total_stake(pool_id: &PoolId) -> Result<Balance, DispatchError>
Return the stake associated with the pool_id
.
Provided Methods§
sourcefn withdraw_all_stake(
pool_id: &PoolId,
stake_id: &StakeId
) -> Result<Balance, DispatchError>
fn withdraw_all_stake( pool_id: &PoolId, stake_id: &StakeId ) -> Result<Balance, DispatchError>
Withdraw all stake for an account.