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:
subgraph.js: that will retrieve the staking data from subgraph.
rewards.js: that will calculate the corresponding rewards from the staking data.
merkle_dist.js: that will generate the Threshold Merkle distribution of the calculated rewards.
This will make easy to achieve the following software structure:
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: