Skip to content

FarmingRewards


Events


DepositStake

Attributes

Name Type Composition
pool_id T::PoolId u128
stake_id T::StakeId AccountId
amount T::SignedFixedPoint i128

DistributeReward

Attributes

Name Type Composition
currency_id T::CurrencyId u128
amount T::SignedFixedPoint i128

WithdrawReward

Attributes

Name Type Composition
pool_id T::PoolId u128
stake_id T::StakeId AccountId
currency_id T::CurrencyId u128
amount T::SignedFixedPoint i128

WithdrawStake

Attributes

Name Type Composition
pool_id T::PoolId u128
stake_id T::StakeId AccountId
amount T::SignedFixedPoint i128

Storage functions


RewardCurrencies

Track the currencies used for rewards.

Python

result = substrate.query(
    'FarmingRewards', 'RewardCurrencies', ['u128']
)

Return value

'scale_info::625'

RewardPerToken

Used to compute the rewards for a participant's stake.

Python

result = substrate.query(
    'FarmingRewards', 'RewardPerToken', ['u128', 'u128']
)

Return value

'i128'

RewardTally

Accounts for previous changes in stake size.

Python

result = substrate.query(
    'FarmingRewards', 'RewardTally', ['u128', ('u128', 'AccountId')]
)

Return value

'i128'

Stake

The stake of a participant in this reward pool.

Python

result = substrate.query(
    'FarmingRewards', 'Stake', [('u128', 'AccountId')]
)

Return value

'i128'

TotalRewards

The total unclaimed rewards distributed to this reward pool. NOTE: this is currently only used for integration tests.

Python

result = substrate.query(
    'FarmingRewards', 'TotalRewards', ['u128']
)

Return value

'i128'

TotalStake

The total stake deposited to this reward pool.

Python

result = substrate.query(
    'FarmingRewards', 'TotalStake', ['u128']
)

Return value

'i128'

Constants


MaxRewardCurrencies

The maximum number of reward currencies.

Value

10

Python

constant = substrate.get_constant('FarmingRewards', 'MaxRewardCurrencies')

Errors


InsufficientFunds

Balance not sufficient to withdraw stake.


MaxRewardCurrencies

Maximum rewards currencies reached.


TryIntoIntError

Unable to convert value.


ZeroTotalStake

Cannot distribute rewards without stake.