@@ -316,6 +316,7 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa
316
316
/**
317
317
* @dev Calculate current rewards for a given allocation on demand.
318
318
* The allocation could be a legacy allocation or a new subgraph service allocation.
319
+ * Returns 0 if the allocation is not active.
319
320
* @param _allocationID Allocation
320
321
* @return Rewards amount for an allocation
321
322
*/
@@ -326,13 +327,18 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa
326
327
);
327
328
328
329
(
330
+ bool isActive ,
329
331
,
330
332
bytes32 subgraphDeploymentId ,
331
333
uint256 tokens ,
332
334
uint256 alloAccRewardsPerAllocatedToken ,
333
335
uint256 accRewardsPending
334
336
) = IRewardsIssuer (_rewardsIssuer).getAllocationData (_allocationID);
335
337
338
+ if (! isActive) {
339
+ return 0 ;
340
+ }
341
+
336
342
(uint256 accRewardsPerAllocatedToken , ) = getAccRewardsPerAllocatedToken (subgraphDeploymentId);
337
343
return
338
344
accRewardsPending.add (_calcRewards (tokens, alloAccRewardsPerAllocatedToken, accRewardsPerAllocatedToken));
@@ -372,6 +378,7 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa
372
378
* This function can only be called by an authorized rewards issuer which are
373
379
* the staking contract (for legacy allocations), and the subgraph service (for new allocations).
374
380
* This function will mint the necessary tokens to reward based on the inflation calculation.
381
+ * Mints 0 tokens if the allocation is not active.
375
382
* @param _allocationID Allocation
376
383
* @return Assigned rewards amount
377
384
*/
@@ -383,6 +390,7 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa
383
390
);
384
391
385
392
(
393
+ bool isActive ,
386
394
address indexer ,
387
395
bytes32 subgraphDeploymentID ,
388
396
uint256 tokens ,
@@ -398,15 +406,18 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa
398
406
return 0 ;
399
407
}
400
408
401
- // Calculate rewards accrued by this allocation
402
- uint256 rewards = accRewardsPending.add (
403
- _calcRewards (tokens, accRewardsPerAllocatedToken, updatedAccRewardsPerAllocatedToken)
404
- );
405
- if (rewards > 0 ) {
406
- // Mint directly to rewards issuer for the reward amount
407
- // The rewards issuer contract will do bookkeeping of the reward and
408
- // assign in proportion to each stakeholder incentive
409
- graphToken ().mint (rewardsIssuer, rewards);
409
+ uint256 rewards = 0 ;
410
+ if (isActive) {
411
+ // Calculate rewards accrued by this allocation
412
+ rewards = accRewardsPending.add (
413
+ _calcRewards (tokens, accRewardsPerAllocatedToken, updatedAccRewardsPerAllocatedToken)
414
+ );
415
+ if (rewards > 0 ) {
416
+ // Mint directly to rewards issuer for the reward amount
417
+ // The rewards issuer contract will do bookkeeping of the reward and
418
+ // assign in proportion to each stakeholder incentive
419
+ graphToken ().mint (rewardsIssuer, rewards);
420
+ }
410
421
}
411
422
412
423
emit HorizonRewardsAssigned (indexer, _allocationID, rewards);
0 commit comments