Giter VIP home page Giter VIP logo

ssv-rewards's Introduction

ssv-rewards

Synchronizes historical activity and performance of SSV validators and calculates their rewards according to Incentivized Mainnet Program.

Installation

git clone https://github.com/bloxapp/ssv-rewards
cd ssv-rewards
cp .env.example .env
cp rewards.example.yaml rewards.yaml

Edit .env and fill in the required values:

# SSV network
NETWORK=mainnet

# Beacon API endpoint of the consensus node
CONSENSUS_ENDPOINT=http://beacon-node:5052

# JSON-RPC API endpoint of the execution node
EXECUTION_ENDPOINT=http://excution-node:8545

# SSV API endpoint
SSV_API_ENDPOINT=https://api.ssv.network/api/v4

# Beaconcha.in API
BEACONCHA_ENDPOINT=https://beaconcha.in
BEACONCHA_API_KEY= # Optional
BEACONCHA_REQUESTS_PER_MINUTE=20 # Adjust according to your Beaconcha.in API plan

# Etherscan API
ETHERSCAN_API_ENDPOINT=https://api.etherscan.io
ETHERSCAN_API_KEY= # Optional
ETHERSCAN_REQUESTS_PER_SECOND=0.1 # Adjust according to your Etherscan API plan

Edit rewards.yaml to match the specifications:

criteria:
  min_attestations_per_day: 202
  min_decideds_per_day: 22

tiers:
  # Tiers apply to rounds below the participation threshold.
  - max_participants: 2000 # Up to 2,000 validators
    apr_boost: 0.5 # Fraction of ETH APR to reward in SSV tokens
  # ...
  - max_participants: 30000
    apr_boost: 0.1

rounds:
  - period: 2023-07 # Designated period (year-month)
    eth_apr: 0.047 # ETH Staking APR
    ssv_eth: 0.0088235294 # SSV/ETH price
  # ...

Usage

First, start PostgreSQL and wait a few seconds for it to be ready:

docker-compose up -d postgres

Synchronization

Synchronize validator activity and performance:

docker-compose run --rm sync

This might take a while, depending on how long ago the SSV contract was deployed and how many validators there are.

Calculation

After syncing, you may calculate the reward distribution:

docker-compose run --rm calc

This produces the following documents under the ./rewards directory:

๐Ÿ“‚ rewards
โ”œโ”€โ”€ ๐Ÿ“„ by-owner.csv            # Reward for each owner for each round
โ”œโ”€โ”€ ๐Ÿ“„ by-validator.csv        # Reward for each validator for each round
โ”œโ”€โ”€ ๐Ÿ“„ by-recipient.csv        # Reward for each recipient for each round
โ”œโ”€โ”€ ๐Ÿ“„ total-by-owner.csv      # Total reward for each owner
โ”œโ”€โ”€ ๐Ÿ“„ total-by-validator.csv  # Total reward for each validator
โ””โ”€โ”€ ๐Ÿ“‚ <year>-<month>
    โ”œโ”€โ”€ ๐Ÿ“„ by-owner.csv        # Total reward for each owner for that round
    โ”œโ”€โ”€ ๐Ÿ“„ by-validator.csv    # Total reward for each validator for that round
    โ”œโ”€โ”€ ๐Ÿ“„ by-recipient.csv    # Total reward for each recipient for that round
    โ””โ”€โ”€ ๐Ÿ“„ cumulative.json     # Cumulative reward for each owner until and including that round
  • recipient is the address that eventually receives the reward, which is either the owner address, or if the owner is a contract, then the deployer address of the contract.

Merkleization

After calculating the reward distribution, you may merkleize the rewards for a specific round.

  1. Copy the file at ./rewards/<year>-<month>/cumulative.json over to ./scripts/merkle-generator/scripts/input_1.json.
  2. Run the merkleization script:
    cd scripts/merkle-generator
    npm i
    npx hardhat run scripts/merkle.ts
  3. The merkle tree is generated at ./merkle-generator/scripts/output-1.json.

Updating

  1. Pull the changes and rebuild the Docker images:
    git pull
    docker-compose build
  2. Refer to .env.example and update your .env file if necessary.
  3. Refer to rewards.example.yaml and update your rewards.yaml file if necessary.
  4. Sync with --fresh to re-create the databases and sync from scratch:
    docker-compose run --rm sync sync --fresh

ssv-rewards's People

Contributors

moshe-blox avatar eridianalpha avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.