diff --git a/packages/subgraph-service/contracts/utilities/AllocationManager.sol b/packages/subgraph-service/contracts/utilities/AllocationManager.sol index c555f271c..5bb22cbe2 100644 --- a/packages/subgraph-service/contracts/utilities/AllocationManager.sol +++ b/packages/subgraph-service/contracts/utilities/AllocationManager.sol @@ -303,12 +303,14 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca // Distribute rewards to indexer tokensIndexerRewards = tokensRewards - tokensDelegationRewards; - address rewardsDestination = rewardsDestination[allocation.indexer]; - if (rewardsDestination == address(0)) { - _graphToken().approve(address(_graphStaking()), tokensIndexerRewards); - _graphStaking().stakeToProvision(allocation.indexer, address(this), tokensIndexerRewards); - } else { - _graphToken().pushTokens(rewardsDestination, tokensIndexerRewards); + if (tokensIndexerRewards > 0) { + address rewardsDestination = rewardsDestination[allocation.indexer]; + if (rewardsDestination == address(0)) { + _graphToken().approve(address(_graphStaking()), tokensIndexerRewards); + _graphStaking().stakeToProvision(allocation.indexer, address(this), tokensIndexerRewards); + } else { + _graphToken().pushTokens(rewardsDestination, tokensIndexerRewards); + } } } diff --git a/packages/subgraph-service/test/subgraphService/collect/indexing/indexing.t.sol b/packages/subgraph-service/test/subgraphService/collect/indexing/indexing.t.sol index bff35f574..38e9e7865 100644 --- a/packages/subgraph-service/test/subgraphService/collect/indexing/indexing.t.sol +++ b/packages/subgraph-service/test/subgraphService/collect/indexing/indexing.t.sol @@ -27,8 +27,7 @@ contract SubgraphServiceCollectIndexingTest is SubgraphServiceTest { uint256 delegationTokens, uint256 delegationFeeCut ) public useIndexer useAllocation(tokens) useDelegation(delegationTokens) { - // Collect reverts if delegationFeeCut is 100% - delegationFeeCut = bound(delegationFeeCut, 0, MAX_PPM - 1); + delegationFeeCut = bound(delegationFeeCut, 0, MAX_PPM); _setDelegationFeeCut( users.indexer, address(subgraphService), @@ -45,7 +44,6 @@ contract SubgraphServiceCollectIndexingTest is SubgraphServiceTest { uint256 delegationTokens, uint256 delegationFeeCut ) public useIndexer useAllocation(tokens) useDelegation(delegationTokens) { - // Collect reverts if delegationFeeCut is 100% delegationFeeCut = bound(delegationFeeCut, 0, MAX_PPM); _setDelegationFeeCut( users.indexer, @@ -90,8 +88,7 @@ contract SubgraphServiceCollectIndexingTest is SubgraphServiceTest { uint256 delegationTokens, uint256 delegationFeeCut ) public useIndexer useAllocation(tokens) useDelegation(delegationTokens) { - // Collect reverts if delegationFeeCut is 100% - delegationFeeCut = bound(delegationFeeCut, 0, MAX_PPM - 1); + delegationFeeCut = bound(delegationFeeCut, 0, MAX_PPM); _setDelegationFeeCut( users.indexer, address(subgraphService),