threshold-network / merkle-distribution

Threshold Network rewards generation and distribution
https://threshold.network
1 stars 6 forks source link

Refactor staking rewards package #33

Closed manumonti closed 1 year ago

manumonti commented 1 year ago

The staking rewards package is responsible for retrieving staking information from the staking subgraph (https://github.com/threshold-network/subgraph), calculating the corresponding rewards for each stake, and generating the Merkle distribution of the rewards.

Up to now, these three functionalities are mixed in the same software component (stakingrewards.js). But since the deployment of tBTCv2 will require a more flexible generation of rewards, with different percentages for rewards that come from PRE nodes and tBTCv2 nodes, it's necessary to have a more modular code to make easy the integration of tBTCv2 rewards calculation.

So, this refactoring will split the code into three components:

This will make easy to achieve the following software structure:

Rewards flowchart