Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand Down