Skip to content

Commit

Permalink
fix(SubgraphService): allow collecting rewards when delegation fee cu…
Browse files Browse the repository at this point in the history
…t is 100% (#1038)
  • Loading branch information
Maikol authored Sep 20, 2024
1 parent 51dd7a8 commit 08539af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
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

0 comments on commit 08539af

Please sign in to comment.