Rewards System Architecture
The Revenue module’s primary responsibility is to assess validator performance, calculate appropriate compensation, and distribute rewards according to configurable schedules. The system leverages real-time performance data and price information to ensure fair and timely compensation.Performance Assessment
Validators are evaluated on two critical metrics:- Block Production Participation: The percentage of blocks signed during the payment period
- Oracle Price Submissions: The percentage of oracle votes provided during the payment period
Performance Requirements
The module uses two configurable thresholds to determine reward eligibility:- Required At Least: The minimum performance required on both metrics to qualify for any rewards
- Allowed To Miss: The maximum percentage of misses allowed to still receive full rewards
Performance Rating Calculation
Performance rating determines the proportion of rewards a validator receives:- Full Rating (1.0): If performance on both metrics meets or exceeds the “allowed to miss” threshold
- Zero Rating (0.0): If performance on either metric falls below the “required at least” threshold
- Partial Rating (0.0-1.0): Rating calculated using a quadratic formula when performance falls between thresholds
missedBlocksPerfQuo
is the proportion of blocks missed within the partial performance rangemissedOracleVotesPerfQuo
is the proportion of oracle votes missed within the partial performance range
Calculation of Performance Quotients
BothmissedBlocksPerfQuo
and missedOracleVotesPerfQuo
are calculated using the same algorithm. The module uses the calCMissedPerfQuo
function to determine how much a validator’s performance falls within the partial performance range:
- Check Full Performance: If
missedShare <= allowedToMiss
, return 0.0 (no penalty, full rewards) - Calculate Excess Misses:
finedMissedShare = missedShare - allowedToMiss
(how much over the allowed threshold) - Calculate Evaluation Window:
perfEvalWindow = perfThreshold - allowedToMiss
(the range for partial performance) - Calculate Performance Quotient:
missedPerfQuo = finedMissedShare / perfEvalWindow
(normalized position within partial range)
- 0.0 = performance at the “allowed to miss” threshold (full rewards)
- 1.0 = performance at the “required at least” threshold (no rewards)
Payment Scheduling
The module supports multiple payment schedule types:- Monthly: Rewards are distributed at the beginning of each calendar month
- Block-Based: Rewards are distributed after a specified number of blocks
- Empty: No rewards are distributed (used for testing or disabling payments)
- The schedule type in the module parameters (controllable by governance)
- The schedule state in the module’s store (updated automatically)
- Calculates each validator’s performance rating
- Determines the reward amount in the reward asset
- Transfers rewards to eligible validators
- Resets performance metrics for the new period
Price Calculation
Rewards are defined in USD terms but paid in the token specified in module parameters. To accurately convert between USD and token amounts, the module:- Tracks the cumulative price of the reward asset in each block
- Calculates the Time-Weighted Average Price (TWAP) over a configurable window
- Uses this TWAP to determine the exact token amount equivalent to the USD reward
Treasury Management
The Revenue module maintains a treasury account that holds funds for validator compensation. This treasury:- Receives funds through the
FundTreasury
message - Automatically pays validators at the end of each payment period
- Can be managed through governance decisions