Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewards- threshold lib updates #307

Open
wants to merge 10 commits into
base: staking-threshold-lib
Choose a base branch
from

Conversation

r-czajkowski
Copy link
Collaborator

@r-czajkowski r-czajkowski commented Nov 14, 2022

Depends on: #302

This PR moves the contract integration part from hooks to the Threshold-ts library. Thanks to this layer we can separate work between UI and contract integration. Also, it helps to unit test created services and move the "business logic" from the React hooks.

Main changes in Threshold-ts lib

  1. Creates a common interface for rewards. Currently, we support 2 types of rewards: staking bonus and interim staking rewards. NOTE that function that calculates interim staking rewards for each staking provider may include a staking bonus. Also, adds unit tests that cover various scenarios for calculating rewards.
  2. Adds functions to the IStaking interface that return Staked/ToppedUp/Unstaked events for staking providers.
  3. Adds function to the IPRE interface that returns OperatorConfirmed events for staking providers.
  4. Adds date utils functions.

These utils functions/variables will be useful in the threshold ts lib
eg for calculating staking bonus rewards.
In the future we should create a contract wrapper for each contract the
threshold lib integrates to keep the same interface. In some cases
multiple services need the same contract data like deployment block or
address. So to avoid duplicating the creation of each contract in each
service can create one contract instance and pass to the service in
constructor.
Move fetching the staking bonus rewards to the threshold lib. Also add a
function to the staking and pre service to fetch necessary events to
calculate rewards.
Move fetching the interim staking rewards to the threshold ts lib and
update hooks to use the services from threshold lib.
Rewards is a wrapper for all type of rewards in the threshold network.
Currently there are 2 types of rewards: staking bonus and interim
staking rewards. We should keep in mind that calculated reward from
interim rewards service may include the staking bonus reward.
We keep the abi for `ComulativeMerkleDrop` contract in the threshold ts
lib.
@github-actions
Copy link

@github-actions
Copy link

@r-czajkowski r-czajkowski marked this pull request as ready for review November 18, 2022 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant