contracts
contracts copied to clipboard
Stable cut for indexing and query rewards
Summary
New delegations and undelegations dramatically change the staking income for indexers and validators unless the cut rate is regularly adjusted.
Why is this happening? Staking income for the indexer and delegators is pooled before the Indexer cut is calculated.
This PR is inspired by https://forum.thegraph.com/t/proposal-to-change-the-indexer-cut-mechanism/1422
Solution
Distribute any new rewards based on the delegation to total-stake ratio at the moment the allocation was created. In addition, the indexer cut will be defined as the share of delegator rewards the indexer gets.
Example: If you delegate to an indexer with a ‘rewards cut’ and ‘fee cut’ of 10%, it means you will get 90% of whatever your staked GRT earns and your indexer will get the other 10%. If you run an indexer, you will earn your pro-rata staking income in full and a 10% commission on your delegators’ staking income.
Features
- Save the delegators rewards cut at the moment when the allocation is created. This avoids any manipulation of the cuts before closing an allocation. This means changing the allocation struct.
- Calculate the
indexerDelegationRatioas the ratio of delegation to total stake for a particular indexer. - Rename some delegation pool variables to make them clearer.
- Improve comments.
- Use a single function to collect any delegators rewards.