Synchronizes historical activity and performance of SSV validators and calculates their rewards according to Incentivized Mainnet Program.
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
# ...
First, start PostgreSQL and wait a few seconds for it to be ready:
docker-compose up -d postgres
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.
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.
After calculating the reward distribution, you may merkleize the rewards for a specific round.
- Copy the file at
./rewards/<year>-<month>/cumulative.json
over to./scripts/merkle-generator/scripts/input_1.json
. - Run the merkleization script:
cd scripts/merkle-generator npm i npx hardhat run scripts/merkle.ts
- The merkle tree is generated at
./merkle-generator/scripts/output-1.json
.
- Pull the changes and rebuild the Docker images:
git pull docker-compose build
- Refer to
.env.example
and update your.env
file if necessary. - Refer to
rewards.example.yaml
and update yourrewards.yaml
file if necessary. - Sync with
--fresh
to re-create the databases and sync from scratch:docker-compose run --rm sync sync --fresh