Rewards
When validators are contributing to consesus for a consensus contract, rewards are to be distributed to all validators and restakers to incentivize the validation service.
Given the offchain and onchain conundrum of AVS, this is non-trivial to implement inside an onchain contract, especially in the many-to-many model. Hence, we recommend two types of reward distrbution methods.
Merkle Tree Distribution
Instead of performing the reward calculation onchain, we instead recommend AVSs to calculate the rewards for each address offchain, and to then distribute the rewards using a library such as MerkleProofLib.
This approach of reward distribution would be centralized, but works great in practise, as was seen in ~2021 when it was utilized by Votium for onchain vote-bribing. As parts of an AVS would be centralized, such as the sequencer, we deem this to be fine. If an AVS provider stops distributing rewards for some reason, a validator or restaker can simply stop providing validation and unstake.
The amount of onchain claim
transactions can also be reduced by a lot by batching together rewards for chunks. For example, create a claimable reward every 100 chunks, or even 1,000 chunks, depending on how often chunks are to be emitted.
Growth Distribution
For simpler restaking cases where one would only allow delegating voting power to yourself, it would be possible to do the reward calculation onchain through simple growth math. This terminology is from Uniswap's V3, and the concept for distributing rewards would be similar in nature:
reward := restake * (growthLatestX96 - growthUserX96)
where restake
is the token amount restaked, growthLatestX96
is a fixed-point value of reward tokens per token and growthLatestX96
is last observed reward tokens per token for a user.
One would need to implement a growth value on a per-token basis in the consensus contract, so there would not be a global growth value.