This repo contains:
stakenet-simulator-db- This is a common library that interacts with the database schemaservices/cli- It is the main backtesting binary which is used to backtest the steward protocol. It calculates the APY of the steward protocol with the new parameters provided in the CLI.services/epoch-rewards-tracker- It is a seperate binary target that is used to inject data into the database
Read CONSIDERATIONS.md for more detailed overview of the program.
Runs a backtesting simulation with configurable steward parameters.
steward-simulator-cli backtest [OPTIONS]Set env variables -
- RPC_URL
- DB_CONNECTION_URL
- VALIDATOR_HISTORY_PROGRAM_ID (
HistoryJTGbKQD2mRgLZ3XhqHnN811Qpez8X9kCcGHoa) - EPOCH_CHECK_CYCLE_SEC
- DUNE_API_KEY
| Parameter | Type | Description |
|---|---|---|
--mev-commission-range |
u16 |
Range for MEV commission scoring |
--mev-commission-bps-threshold |
u16 |
MEV commission threshold in basis points |
--commission-range |
u16 |
Range for commission scoring |
--commission-threshold |
u8 |
Commission threshold percentage |
--historical-commission-threshold |
u8 |
Historical commission threshold |
| Parameter | Type | Description |
|---|---|---|
--epoch-credits-range |
u16 |
Range for epoch credits scoring |
--scoring-delinquency-threshold-ratio |
f64 |
Delinquency threshold for scoring |
--num-epochs-between-scoring |
u64 |
Epochs between scoring cycles |
--compute-score-slot-range |
u64 |
Slot range for score computation |
--minimum-voting-epochs |
u64 |
Minimum epochs a validator must vote |
| Parameter | Type | Description |
|---|---|---|
--instant-unstake-delinquency-threshold-ratio |
f64 |
Delinquency threshold for instant unstaking |
--scoring-unstake-cap-bps |
u32 |
Cap for scoring-based unstaking (basis points) |
--instant-unstake-cap-bps |
u32 |
Cap for instant unstaking (basis points) |
--stake-deposit-unstake-cap-bps |
u32 |
Cap for stake deposit unstaking (basis points) |
--instant-unstake-epoch-progress |
f64 |
Epoch progress threshold for instant unstaking |
--instant-unstake-inputs-epoch-progress |
f64 |
Input epoch progress for instant unstaking |
| Parameter | Type | Description |
|---|---|---|
--priority-fee-lookback-epochs |
u8 |
Epochs to look back for priority fee analysis |
--priority-fee-lookback-offset |
u8 |
Offset for priority fee lookback |
--priority-fee-max-commission-bps |
u16 |
Maximum commission for priority fee (basis points) |
--priority-fee-error-margin-bps |
u16 |
Error margin for priority fees (basis points) |
--priority-fee-scoring-start-epoch |
u16 |
Starting epoch for priority fee scoring |
| Parameter | Type | Description |
|---|---|---|
--num-delegation-validators |
u32 |
Number of validators to delegate to |
--minimum-stake-lamports |
u64 |
Minimum stake amount in lamports |
| Parameter | Type | Default | Description |
|---|---|---|---|
--target-epoch |
u64 |
- | Target epoch for simulation |
--steward-cycle-rate |
u16 |
10 |
Rate of steward cycles |
The application uses environment variables for configuration:
| Variable | Description | Default |
|---|---|---|
RPC_URL |
Solana RPC endpoint URL | Required |
DB_CONNECTION_URL |
PostgreSQL connection string | postgresql://postgres:[email protected]:54322/postgres |
VALIDATOR_HISTORY_PROGRAM_ID |
Validator history program ID | Validator history program default |
EPOCH_CHECK_CYCLE_SEC |
Epoch check cycle in seconds | 60 |
DUNE_API_KEY |
For operations that require Dune | None |
The application provides several subcommands for different data collection tasks:
epoch-rewards-tracker [OPTIONS] <COMMAND>--rpc-url, -r <URL>: Solana RPC endpoint URL--db-connection-url <URL>: PostgreSQL database connection string--validator-history-program-id <ID>: Validator history program ID--epoch-check-cycle-sec <SECONDS>: Epoch check cycle duration
Collects and stores historical validator performance data.
epoch-rewards-tracker fetch-validator-historyPurpose: Gathers comprehensive validator metrics including performance scores, commission rates, and historical voting records.
Collects cluster-wide metrics and health data.
epoch-rewards-tracker fetch-cluster-historyPurpose: Tracks overall network health, epoch transitions, and cluster-wide performance metrics.
Analyzes stake account distribution across validators.
epoch-rewards-tracker get-stake-accountsPurpose: Collects information about stake accounts, delegation patterns, and stake distribution across the validator set.
Calculates and tracks inflation rewards for validators.
epoch-rewards-tracker get-inflation-rewardsPurpose: Computes inflation rewards based on validator performance and stake amounts.
Analyzes priority fee data for a specific epoch.
epoch-rewards-tracker get-priority-fee-data-for-epoch --epoch <EPOCH_NUMBER>Purpose: Collects and analyzes transaction priority fees for the specified epoch, useful for fee market analysis.
Processes active stake data from the database.
epoch-rewards-tracker fetch-active-stakePurpose: Analyzes currently active stake positions. This command operates on existing database data and doesn't require RPC calls.
Processes inactive stake data from the database.
epoch-rewards-tracker fetch-inactive-stakePurpose: Analyzes inactive or deactivating stake positions. This command operates on existing database data.
Follow the following steps to setup the local database initally -
- Install
supabasecli and in the root directory run
supabase start
- Temporarily download inflation data from Google Sheets or later complete data as
csvand store it in the root dir asdata.csv. - Build the cargo project and run the following commands to populate the table -
export RPC_URL={YOUR_RPC_URL}
export DB_CONNECTION_URL="postgresql://postgres:[email protected]:54322/postgres"
export DUNE_API_KEY={YOUR_DUNE_API_KEY}
./target/release/epoch_rewards
./target/release/epoch-rewards-tracker fetch-active-stake
./target/release/epoch-rewards-tracker fetch-inactive-stake
./target/release/epoch-rewards-tracker withdraw-and-deposit-stake
./target/release/epoch-rewards-tracker withdraw-and-deposit-sol
./target/release/epoch-rewards-tracker fetch-cluster-history
./target/release/epoch-rewards-tracker fetch-validator-history
./target/release/epoch-rewards-tracker get-stake-accounts
./target/release/epoch-rewards-tracker get-inflation-rewards- We have intentionally converted
priority_fee_merkle_root_upload_authorityall DNE to Unset for calculation purposes. Should be removed when the issue is solved. - To factor in manual SOL deposits and withdraws, we are equally distributing the net of that epoch to all the validators, irrespective of their stake.