Add `on_initialize` hook to `reward-distribution` pallet
Closed this issue · 2 comments
TorstenStueber commented
This ticket is a part of https://github.com/pendulum-chain/tasks/issues/47
This ticket depends on #405
Add an on_initialize
hook
- if
RewardPerBlock
isNone
, return - call
ensure_parachain_status_running
of the security pallet and return if error - call
parachain_block_expired
of the security pallet providingRewardsAdaptedAt
and theDecayInterval
- 1 (becauseparachain_block_expired
checks for>
instead of>=
). If it istrue
, then multiplyRewardPerBlock
byDecayRate
and setRewardsAdaptedAt
to the current active block number - for each collateral currency id in the system
- call
total_stake
ofPooledRewards
, wherepool_id
is that currency id - determine the USD value of the total locked collateral of this currency id (using
convert_to
of theAmount
type)
- call
- add up the USD value over all currency ids
- for each collateral currency id in the system
- determine the percentage of the USD value of this currency id over the total USD value (as a
Perquintill
usingPerquintill::from_rational
) - call
distribute_reward
ofPooledRewards
, wherepool_id
is the currency id,currency_id
is the native token,reward
isRewardPerBlock
multiplied with the percentage
- determine the percentage of the USD value of this currency id over the total USD value (as a
annatekl commented
Hey team! Please add your planning poker estimate with Zenhub @adelarja @b-yap @ebma @gianfra-t @TorstenStueber