Trait staking::RewardsApi
pub trait RewardsApi<PoolId, StakeId, Balance>where
Balance: Saturating + PartialOrd<Balance> + 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
) -> Result<(), DispatchError>;
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
) -> Result<(), DispatchError>;
fn withdraw_stake(
pool_id: &PoolId,
stake_id: &StakeId,
amount: Balance
) -> Result<(), DispatchError>;
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
) -> Result<(), DispatchError> { ... }
}
Required Associated Types§
type CurrencyId
Required Methods§
fn reward_currencies_len(pool_id: &PoolId) -> u32
fn distribute_reward(
pool_id: &PoolId,
currency_id: Self::CurrencyId,
amount: Balance
) -> Result<(), DispatchError>
fn distribute_reward( pool_id: &PoolId, currency_id: Self::CurrencyId, amount: Balance ) -> Result<(), DispatchError>
Distribute the amount
to all participants OR error if zero total stake.
fn 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
.
fn 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
.
fn deposit_stake(
pool_id: &PoolId,
stake_id: &StakeId,
amount: Balance
) -> Result<(), DispatchError>
fn deposit_stake( pool_id: &PoolId, stake_id: &StakeId, amount: Balance ) -> Result<(), DispatchError>
Deposit stake for an account.
fn withdraw_stake(
pool_id: &PoolId,
stake_id: &StakeId,
amount: Balance
) -> Result<(), DispatchError>
fn withdraw_stake( pool_id: &PoolId, stake_id: &StakeId, amount: Balance ) -> Result<(), DispatchError>
Withdraw stake for an account.
fn 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§
fn 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.