Skip to main content

Calculations for Consensus Layer APR

Another important task is calculating a validator’s live Consensus layer APR on every epoch while simultaneously adjusting its historical earnings from the validator activation epoch. At the end of every epoch, we receive the validator’s balance and can see its change relative to the previous epoch. After every epoch, we update the cumulative earnings for each validator and calculate the APR. This way we get the live APR for each validator which in turn gives the APR for each index. At the end of each epoch, the process of calculating APR and earnings looks like this:

The formula used for the APR calculation is:

Consensus layer Epoch APR=RewardsEpochs Since Activation Epoch82179.4524Consensus\ layer\ Epoch\ APR = \frac{\sum Rewards}{Epochs\ Since\ Activation\ Epoch} * \frac{82179.45}{24}

The Ethereum Foundation script detail how to calculate consensus layer epochs per year. The average number of seconds in a year is defined to be 31556908.8 to identify and calculate eligible epochs in a year. Since each Consensus layer epoch has 32 slots and each slot takes 12 seconds to complete, the number of epochs in a year can be calculated as follows:

Epochs In A Year=Seconds in A Year3212 = 31556908.83212 = 82179.45 EpochsEpochs\ In\ A\ Year= \frac{Seconds\ in\ A\ Year}{32 * 12}\ =\ \frac{31556908.8}{32 * 12}\ =\ 82179.45\ Epochs

Using these formulas, we are able to calculate a validator’s dETH APR in real time after every epoch. We can also derive the APR of the indexes from the average APR of all the validators.