Deriving fair share of token incentives for a channel from stake pool
The stake pool is a pool that contains all the staking fees from all the channels. There are two important concepts to keep in mind to derive the fair share of token incentives for an individual channel.
- The staking fee starts accumulating token incentives as soon as a channel is activated, this means that the fair share of a channel would need to account for the time since the channel is activated to ensure fair play. This is achieved by recording the block number at which a channel is activated.
- The staking fee is dynamic and can differ from one channel to another, i.e. channel decides the amount based on their game theory and incentive plan they put in place. To account for this, the weight of the channel and aggregated weight of all channels are recorded at the time a new channel creation.
We need to derive the formula which gives us the ratio of the token incentives the channel has generated so that it can be distributed among the subscribers fairly proportionate to their joining of the channel and the number of subscribers joined earlier.
While this can be solved by recursion of all channels, getting their share in the pool, deriving their weight and the start block number. This will be inefficient as more channels continue to get activated on the protocol.
Instead of recursion, we are going to approach the formula in a linear way. We know that each time a channel is added, the previous number of channels, their block number, etc can be treated like a constant as their values will not change moving forward.
For example, if channel x got added at block y, then the channels count before block y would never change, nor will the differential which we have before channel x was added. We utilize this to form our own ratio calculation that is not based on recursion but instead is based on the aggregation that happens whenever a channel is added or removed. The different weights of the channel are also mapped to an aggregated weight variable which helps us in determining the total sum needed to derive the fair share of token incentives for the channel.
Putting it together, the formula by which we can derive a channels' fair share of token incentives from the stake pool for current block can be written as:
Occurs whenever a channel is added, deactivated or the stake fees changes