@@ -812,18 +812,18 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M
812
812
// Get allocation
813
813
Allocation memory alloc = __allocations[_allocationID];
814
814
815
- // Validate that an allocation cannot be closed before one epoch
816
815
alloc.closedAtEpoch = epochManager ().currentEpoch ();
816
+
817
+ // Allocation duration in epochs
817
818
uint256 epochs = MathUtils.diffOrZero (alloc.closedAtEpoch, alloc.createdAtEpoch);
818
- require (epochs > 0 , "<epochs " );
819
819
820
820
// Indexer or operator can close an allocation
821
821
// Anyone is allowed to close ONLY under two concurrent conditions
822
822
// - After maxAllocationEpochs passed
823
823
// - When the allocation is for non-zero amount of tokens
824
- bool isIndexer = _isAuth (alloc.indexer);
824
+ bool isIndexerOrOperator = _isAuth (alloc.indexer);
825
825
if (epochs <= __maxAllocationEpochs || alloc.tokens == 0 ) {
826
- require (isIndexer , "!auth " );
826
+ require (isIndexerOrOperator , "!auth " );
827
827
}
828
828
829
829
// Close the allocation
@@ -834,7 +834,9 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M
834
834
// Process non-zero-allocation rewards tracking
835
835
if (alloc.tokens > 0 ) {
836
836
// Distribute rewards if proof of indexing was presented by the indexer or operator
837
- if (isIndexer && _poi != 0 ) {
837
+ // and the allocation is at least one epoch old (most indexed chains require the EBO
838
+ // posting epoch block numbers to produce a valid POI which happens once per epoch)
839
+ if (isIndexerOrOperator && _poi != 0 && epochs > 0 ) {
838
840
_distributeRewards (_allocationID, alloc.indexer);
839
841
} else {
840
842
_updateRewards (alloc.subgraphDeploymentID);
@@ -858,7 +860,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M
858
860
_allocationID,
859
861
msg .sender ,
860
862
_poi,
861
- ! isIndexer
863
+ ! isIndexerOrOperator
862
864
);
863
865
}
864
866
0 commit comments