Skip to content

Commit 9ac3b07

Browse files
committed
fix: prevent underflow when subgraphs go under the minimum signal threshold
1 parent 8a844a1 commit 9ac3b07

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

contracts/rewards/RewardsManager.sol

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,12 @@ contract RewardsManager is RewardsManagerV3Storage, GraphUpgradeable, IRewardsMa
281281
Subgraph storage subgraph = subgraphs[_subgraphDeploymentID];
282282

283283
uint256 accRewardsForSubgraph = getAccRewardsForSubgraph(_subgraphDeploymentID);
284-
uint256 newRewardsForSubgraph = accRewardsForSubgraph.sub(
285-
subgraph.accRewardsForSubgraphSnapshot
286-
);
284+
uint256 newRewardsForSubgraph;
285+
if (accRewardsForSubgraph > subgraph.accRewardsForSubgraphSnapshot) {
286+
newRewardsForSubgraph = accRewardsForSubgraph.sub(
287+
subgraph.accRewardsForSubgraphSnapshot
288+
);
289+
}
287290

288291
uint256 subgraphAllocatedTokens = staking().getSubgraphAllocatedTokens(
289292
_subgraphDeploymentID

0 commit comments

Comments
 (0)