@@ -187,9 +187,10 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
187
187
uint256 p = graphToken.totalSupply ();
188
188
uint256 a = p.mul (_pow (r, t, TOKEN_DECIMALS)).div (TOKEN_DECIMALS);
189
189
190
- // New issuance per signalled token during time steps
190
+ // New issuance of tokens during time steps
191
191
uint256 x = a.sub (p);
192
192
193
+ // Get the new issuance per signalled token
193
194
// We multiply the decimals to keep the precision as fixed-point number
194
195
return x.mul (TOKEN_DECIMALS).div (signalledTokens);
195
196
}
@@ -214,14 +215,12 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
214
215
{
215
216
Subgraph storage subgraph = subgraphs[_subgraphDeploymentID];
216
217
217
- uint256 newAccrued = getAccRewardsPerSignal ().sub (subgraph.accRewardsPerSignalSnapshot);
218
+ uint256 newRewardsPerSignal = getAccRewardsPerSignal ().sub (
219
+ subgraph.accRewardsPerSignalSnapshot
220
+ );
218
221
uint256 subgraphSignalledTokens = curation ().getCurationPoolTokens (_subgraphDeploymentID);
219
- if (subgraphSignalledTokens == 0 ) {
220
- return 0 ;
221
- }
222
-
223
- uint256 newValue = newAccrued.mul (subgraphSignalledTokens).div (TOKEN_DECIMALS);
224
- return subgraph.accRewardsForSubgraph.add (newValue);
222
+ uint256 newRewards = newRewardsPerSignal.mul (subgraphSignalledTokens).div (TOKEN_DECIMALS);
223
+ return subgraph.accRewardsForSubgraph.add (newRewards);
225
224
}
226
225
227
226
/**
@@ -239,7 +238,9 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
239
238
Subgraph storage subgraph = subgraphs[_subgraphDeploymentID];
240
239
241
240
uint256 accRewardsForSubgraph = getAccRewardsForSubgraph (_subgraphDeploymentID);
242
- uint256 newAccrued = accRewardsForSubgraph.sub (subgraph.accRewardsForSubgraphSnapshot);
241
+ uint256 newRewardsForSubgraph = accRewardsForSubgraph.sub (
242
+ subgraph.accRewardsForSubgraphSnapshot
243
+ );
243
244
244
245
uint256 subgraphAllocatedTokens = staking ().getSubgraphAllocatedTokens (
245
246
_subgraphDeploymentID
@@ -248,8 +249,13 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
248
249
return (0 , accRewardsForSubgraph);
249
250
}
250
251
251
- uint256 newValue = newAccrued.mul (TOKEN_DECIMALS).div (subgraphAllocatedTokens);
252
- return (subgraph.accRewardsPerAllocatedToken.add (newValue), accRewardsForSubgraph);
252
+ uint256 newRewardsPerAllocatedToken = newRewardsForSubgraph.mul (TOKEN_DECIMALS).div (
253
+ subgraphAllocatedTokens
254
+ );
255
+ return (
256
+ subgraph.accRewardsPerAllocatedToken.add (newRewardsPerAllocatedToken),
257
+ accRewardsForSubgraph
258
+ );
253
259
}
254
260
255
261
/**
@@ -356,9 +362,7 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
356
362
IStaking staking = staking ();
357
363
require (msg .sender == address (staking), "Caller must be the staking contract " );
358
364
359
- IGraphToken graphToken = graphToken ();
360
365
IStaking.Allocation memory alloc = staking.getAllocation (_allocationID);
361
-
362
366
uint256 accRewardsPerAllocatedToken = onSubgraphAllocationUpdate (
363
367
alloc.subgraphDeploymentID
364
368
);
@@ -375,11 +379,12 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
375
379
alloc.accRewardsPerAllocatedToken,
376
380
accRewardsPerAllocatedToken
377
381
);
378
-
379
- // Mint directly to staking contract for the reward amount
380
- // The staking contract will do bookkeeping of the reward and
381
- // assign in proportion to each stakeholder incentive
382
- graphToken.mint (address (staking), rewards);
382
+ if (rewards > 0 ) {
383
+ // Mint directly to staking contract for the reward amount
384
+ // The staking contract will do bookkeeping of the reward and
385
+ // assign in proportion to each stakeholder incentive
386
+ graphToken ().mint (address (staking), rewards);
387
+ }
383
388
384
389
emit RewardsAssigned (alloc.indexer, _allocationID, alloc.closedAtEpoch, rewards);
385
390
0 commit comments