Update rewards snapshot when close allocation with empty POI

I’m submitting this new proposal to fix an issue with the rewards calculation whenever an allocation is closed with 0x0 POI.

Abstract

Indexers get rewards for indexing subgraphs. These rewards are minted whenever an indexer close an allocation with a non-zero POI. A function called distributeRewards() within the Staking contract is used for that purpose. This function calls RewardsManager.takeRewards() that updates the snapshots used for rewards calculations and then mint the tokens. In some cases the snapshot calculation is not called.

Motivation

When an indexer calls closeAllocation() with a POI=0x0 the function distributeRewards() is not called, as a consequence, takeRewards() is not called and in turn the snapshots are not updated before unallocating tokens. This creates a situation where the rewards manager considers there are a different amount of allocated tokens and distort calculations until it is called next time. Hopefully the distortion self corrects when another action is performed that updates the snapshot.

Full version of the GIP is published on this link and will be available on Radicle:

5 Likes