|
| 1 | +--- |
| 2 | +title: Reward Manager |
| 3 | +description: How the Reward Manager calculates and distributes staking rewards |
| 4 | +updated: 2025-03-13 |
| 5 | +authors: [nicolasarnedo] |
| 6 | +icon: BookOpen |
| 7 | +--- |
| 8 | + |
| 9 | +The **Reward Manager** is an **optional but highly recommended component** that automates the calculation and distribution of staking rewards. While the Native Minter precompile handles the actual token minting, the Reward Manager determines *how much* each validator and delegator should receive based on their staking duration, stake amount, and network parameters. |
| 10 | + |
| 11 | +Without the Reward Manager enabled, rewards are set to zero—validators receive only their original stake back when they unstake, no reward UTXOs are created, and transaction fees are burned rather than distributed. This eliminates economic incentives for validators beyond minimal transaction fee revenue, significantly weakening the security model of Proof of Stake and reducing decentralization. |
| 12 | + |
| 13 | +## How the Reward Manager Works |
| 14 | + |
| 15 | +The reward system operates through a **proposal-commit/abort mechanism** on the P-Chain. When a validator's or delegator's staking period ends, the system automatically calculates and distributes their rewards. |
| 16 | + |
| 17 | +<Mermaid |
| 18 | + chart="sequenceDiagram |
| 19 | + participant BB as Block Builder |
| 20 | + participant RV as RewardValidatorTx |
| 21 | + participant PE as Proposal Executor |
| 22 | + participant RC as Reward Calculator |
| 23 | + participant PS as P-Chain State |
| 24 | + participant V as Validator |
| 25 | + participant D as Delegator |
| 26 | + |
| 27 | + note over BB,D: Validator end time reached |
| 28 | + BB->>RV: Create RewardValidatorTx |
| 29 | + RV->>PE: Execute as proposal |
| 30 | + PE->>RC: Get staker to reward |
| 31 | + RC->>PE: Calculate reward based on duration, weight, supply |
| 32 | + PE->>PS: Return potential reward |
| 33 | + alt Commit Path |
| 34 | + PE->>PS: Create reward UTXO (if reward > 0) |
| 35 | + PE->>PS: Create delegatee reward UTXO (if accumulated) |
| 36 | + PE->>PS: Remove from current validators |
| 37 | + PS-->>V: Stake + Validation Reward |
| 38 | + PS-->>D: Accumulated Delegation Fees |
| 39 | + else Abort Path |
| 40 | + PE->>PS: Return staked tokens only |
| 41 | + PE->>PS: Decrease supply by potential reward |
| 42 | + PE->>PS: Return accumulated delegatee rewards |
| 43 | + PS-->>V: Stake only (no validation reward) |
| 44 | + PS-->>D: Accumulated Delegation Fees |
| 45 | + end |
| 46 | + |
| 47 | + note over BB,D: When delegator ends |
| 48 | + BB->>RV: Split reward between delegator/delegatee |
| 49 | + RV->>PE: Create delegator reward UTXO |
| 50 | + alt Post-Cortina |
| 51 | + PE->>PS: Accumulate delegatee share |
| 52 | + else Pre-Cortina |
| 53 | + PE->>PS: Create delegatee reward UTXO immediately |
| 54 | + end |
| 55 | + PS-->>D: When delegator ends |
| 56 | +" |
| 57 | +/> |
| 58 | + |
| 59 | +## Reward Calculation |
| 60 | + |
| 61 | +When a validator's or delegator's staking period ends, the system calculates rewards using the `reward.Calculator` which considers: |
| 62 | + |
| 63 | +1. **Staking Duration**: How long tokens were staked |
| 64 | +2. **Stake Amount**: The weight of the validator (own stake + delegated stake) |
| 65 | +3. **Current Supply**: The total token supply affects reward rate |
| 66 | +4. **Network Parameters**: Configured reward rates and caps |
| 67 | + |
| 68 | +The calculation follows this general formula: |
| 69 | + |
| 70 | +``` |
| 71 | +reward = (stake_amount × staking_duration × reward_rate) / supply_factor |
| 72 | +``` |
| 73 | + |
| 74 | +The reward rate typically decreases as supply increases, creating controlled inflation. |
| 75 | + |
| 76 | +## Reward Distribution Process |
| 77 | + |
| 78 | +### 1. Block Building |
| 79 | + |
| 80 | +When a staker's end time is reached, the **Block Builder** creates a `RewardValidatorTx` transaction. This transaction proposes to: |
| 81 | +- Remove the validator/delegator from the active set |
| 82 | +- Calculate their earned rewards |
| 83 | +- Return their stake plus rewards |
| 84 | + |
| 85 | +### 2. Execution Phase |
| 86 | + |
| 87 | +The `RewardValidatorTx` is executed as a **proposal transaction** by the Proposal Executor: |
| 88 | + |
| 89 | +- The Reward Calculator computes the potential reward amount |
| 90 | +- The P-Chain State is queried for staker information |
| 91 | +- A reward UTXO is prepared (if reward > 0) |
| 92 | + |
| 93 | +### 3. Commit or Abort |
| 94 | + |
| 95 | +The transaction can follow two paths: |
| 96 | + |
| 97 | +#### Commit Path (Normal Operation) |
| 98 | +- Validator receives: Original stake + validation rewards |
| 99 | +- Delegators receive: Their share of rewards (minus delegation fees) |
| 100 | +- Delegation fees are either: |
| 101 | + - **Post-Cortina**: Accumulated for the validator to claim later |
| 102 | + - **Pre-Cortina**: Paid immediately to the validator |
| 103 | + |
| 104 | +#### Abort Path (Network Issues) |
| 105 | +- Validator receives: Only their original stake (no rewards) |
| 106 | +- Potential rewards are burned (supply decreased) |
| 107 | +- Accumulated delegation fees are still returned |
| 108 | +- This protects the network from rewarding validators during unstable periods |
0 commit comments