> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rated.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Pre-Altair penalties computation

### Estimating rewards

Validator rewards pre- and post-Altair are some function of `base_reward`. Our calculation follows the spec along each of the two periods. To estimate the actual reward amounts in Gwei, we sum the number of `units` validators should receive per activity, and then we multiply them by the estimated `base_reward` for that day. `Base_reward` is a function of active validators and uptime, and is computed per epoch, but the variability between a day is small enough to approximate it with daily averages; which is the approach we are taking.

```sql theme={null}
CASE WHEN vd.day > 329
THEN (
    rewards*u.uptime*br.base_reward +
    proposed_count*br.base_reward*br.active_validators*8.0/(32.0*64.0) +
    sync_signature_count*(((br.total_active_balance64)/FLOOR(SQRT(br.total_active_balance))) / (32*512*32))
)
ELSE (
    rewards*u.uptime*br.pre_alt_base_reward +
    proposed_count*(br.pre_alt_base_reward/8.0)*(br.active_validators/32.0)
)
END as estimated_rewards
```

### Deriving penalties

Now from Lighthouse, we fetch a `validator_index`'s daily earnings and we can compare the theoretical maximum rewards for the given activities they performed with the actual outcome. We compute estimated penalties as:

<Frame className="text-grey-800 dark:text-white text-sm overflow-x-auto lg:justify-start justify-center">
  $$
  estimated\_penalties = estimated\_rewards - realized\_rewards
  $$
</Frame>

**Example under Altair:** A validator attested perfectly 90 times but missed 10 attestations. Say the `base_reward` is 20K GWei For the 90 perfect attestations, the validator should get:

```js theme={null}
90 * (0.218752 + 0.40625) = 75.9375 * base_reward =
75.9375 * 20K = 1,518.75K = 1.5M GWei
```

If a validator received 1.2M Gwei, we have a difference of 300K Gwei that we need to attribute somewhere. It is not opportunity cost, as the theoretical maximum is not factored in at all in the model.

Thus it has to be the penalties.
