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§

Required Methods§

source

fn reward_currencies_len(pool_id: &PoolId) -> u32

source

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.

source

fn compute_reward( pool_id: &PoolId, stake_id: &StakeId, currency_id: Self::CurrencyId ) -> Result<Balance, DispatchError>

Compute the expected reward for the stake_id.

source

fn withdraw_reward( pool_id: &PoolId, stake_id: &StakeId, currency_id: Self::CurrencyId ) -> Result<Balance, DispatchError>

Withdraw all rewards from the stake_id.

source

fn deposit_stake( pool_id: &PoolId, stake_id: &StakeId, amount: Balance ) -> DispatchResult

Deposit stake for an account.

source

fn withdraw_stake( pool_id: &PoolId, stake_id: &StakeId, amount: Balance ) -> DispatchResult

Withdraw stake for an account.

source

fn get_total_stake(pool_id: &PoolId) -> Result<Balance, DispatchError>

Return the stake associated with the pool_id.

source

fn get_stake( pool_id: &PoolId, stake_id: &StakeId ) -> Result<Balance, DispatchError>

Return the stake associated with the stake_id.

Provided Methods§

source

fn withdraw_all_stake( pool_id: &PoolId, stake_id: &StakeId ) -> Result<Balance, DispatchError>

Withdraw all stake for an account.

source

fn set_stake( pool_id: &PoolId, stake_id: &StakeId, amount: Balance ) -> DispatchResult

Set the stake to amount for stake_id regardless of its current stake.

Implementations on Foreign Types§

source§

impl<PoolId, StakeId, Balance> RewardsApi<PoolId, StakeId, Balance> for ()where Balance: Saturating + PartialOrd + Default + Copy,

§

type CurrencyId = ()

source§

fn reward_currencies_len(_: &PoolId) -> u32

source§

fn distribute_reward( _: &PoolId, _: Self::CurrencyId, _: Balance ) -> DispatchResult

source§

fn compute_reward( _: &PoolId, _: &StakeId, _: Self::CurrencyId ) -> Result<Balance, DispatchError>

source§

fn withdraw_reward( _: &PoolId, _: &StakeId, _: Self::CurrencyId ) -> Result<Balance, DispatchError>

source§

fn get_total_stake(_: &PoolId) -> Result<Balance, DispatchError>

source§

fn get_stake(_: &PoolId, _: &StakeId) -> Result<Balance, DispatchError>

source§

fn deposit_stake(_: &PoolId, _: &StakeId, _: Balance) -> DispatchResult

source§

fn withdraw_stake(_: &PoolId, _: &StakeId, _: Balance) -> DispatchResult

Implementors§

source§

impl<T, I, Balance> RewardsApi<<T as Config<I>>::PoolId, <T as Config<I>>::StakeId, Balance> for Pallet<T, I>where T: Config<I>, I: 'static, Balance: BalanceToFixedPoint<<T as Config<I>>::SignedFixedPoint> + Saturating + PartialOrd + Copy, <T::SignedFixedPoint as FixedPointNumber>::Inner: TryInto<Balance>,

§

type CurrencyId = <T as Config<I>>::CurrencyId