Skip to content

Commit affc8b4

Browse files
committed
fix: remove redundant subgraphAllocatedTokens check (TRST-R-3)
In _updateSubgraphRewards(), the check `subgraphAllocatedTokens != 0` is redundant: if undistributedRewards != 0 then condition == NONE, and _getSubgraphRewardsState() guarantees subgraphAllocatedTokens != 0 when condition is NONE (otherwise it sets NO_ALLOCATION which triggers reclaim above, zeroing undistributedRewards). Also fixes inaccurate NatSpec on _getSubgraphRewardsState return value.
1 parent 22954a4 commit affc8b4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/contracts/contracts/rewards/RewardsManager.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ contract RewardsManager is
420420
* When multiple conditions apply, prefers conditions with configured reclaim addresses.
421421
* @param _subgraphDeploymentID Subgraph deployment
422422
* @return newRewards Rewards accumulated since last snapshot
423-
* @return subgraphAllocatedTokens Total tokens allocated (0 if condition is not NONE)
423+
* @return subgraphAllocatedTokens Total tokens allocated to this subgraph
424424
* @return condition The effective condition for reclaim routing (NONE if claimable)
425425
*/
426426
function _getSubgraphRewardsState(
@@ -534,7 +534,7 @@ contract RewardsManager is
534534
subgraph.accRewardsForSubgraphSnapshot = newAccRewardsForSubgraph;
535535

536536
newAccRewardsPerAllocatedToken = accRewardsPerAllocatedToken;
537-
if (undistributedRewards != 0 && subgraphAllocatedTokens != 0) {
537+
if (undistributedRewards != 0) {
538538
newAccRewardsPerAllocatedToken = accRewardsPerAllocatedToken.add(
539539
undistributedRewards.mul(FIXED_POINT_SCALING_FACTOR).div(subgraphAllocatedTokens)
540540
);

0 commit comments

Comments
 (0)