tellor-io / tellor-pallet

GNU General Public License v3.0
7 stars 3 forks source link

Resolve TODOs of update_rewards #112

Open pawanbisht62 opened 1 year ago

pawanbisht62 commented 1 year ago

Resolves #9.

This PR pertains to resolve TODOs marked on update_rewards() test case.

In tellorFlex's update_rewards() test case, we are using hard-coded value (150) in order to create new_pending_rewards. Is there any reason for not using actual business logic for calculating new_pending_rewards?

evilrobot-01 commented 1 year ago

@tkernell As a sanity check, could you please confirm that it is okay to simply convert the total stake amount (trb 18 decimal places to parachain decimals of say 12) for use with all the other derived rewards components, such as reward rate, accumulated reward per share and reward debt?

That is, only stake amounts, including StakeInfo.staked_balance and StakeInfo.locked_balance, are in Tributes (18 decimals) with all other rewards using the Balance type, denoting the local parachain token (12 decimals) in which local staking rewards are paid.

My understanding is that we are just using the ratio of a reporters stake vs the total stake amount to calculate individual rewards so this seemed sufficient. As an example, the same conversion happens for stake_info.staked_balance in update_stake_and_pay_rewards(), as well as within add_staking_rewards().

tkernell commented 1 year ago

I would run some tests to make sure the reward payouts don't skew too much as a result. My concern would be rounding errors causing a miscalculation of staking rewards, causing insolvency. But there's probably a way to do it.