@@ -10,7 +10,7 @@ import "./IRewardsManager.sol";
10
10
contract RewardsManager is RewardsManagerV1Storage , GraphUpgradeable , IRewardsManager , Governed {
11
11
using SafeMath for uint256 ;
12
12
13
- uint256 private constant ISSUANCE_RATE_DECIMALS = 1e18 ;
13
+ uint256 private constant TOKEN_DECIMALS = 1e18 ;
14
14
15
15
// -- Events --
16
16
@@ -113,6 +113,15 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
113
113
emit ParameterUpdated ("issuanceRate " );
114
114
}
115
115
116
+ /**
117
+ * @dev Sets the enforcer for denegation of rewards to subgraphs
118
+ * @param _enforcer Address of the enforcer of denied subgraphs
119
+ */
120
+ function setEnforcer (address _enforcer ) external override onlyGovernor {
121
+ enforcer = _enforcer;
122
+ emit ParameterUpdated ("enforcer " );
123
+ }
124
+
116
125
/**
117
126
* @dev Sets the indexer as denied to claim rewards
118
127
* NOTE: Can only be called by the enforcer role
@@ -165,13 +174,13 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
165
174
166
175
uint256 r = issuanceRate;
167
176
uint256 p = token.totalSupply ();
168
- uint256 a = p.mul (_pow (r, t, ISSUANCE_RATE_DECIMALS )).div (ISSUANCE_RATE_DECIMALS );
177
+ uint256 a = p.mul (_pow (r, t, TOKEN_DECIMALS )).div (TOKEN_DECIMALS );
169
178
170
179
// New issuance per signal during time steps
171
180
uint256 x = a.sub (p);
172
181
173
182
// We multiply the decimals to keep the precision as fixed-point number
174
- return x.mul (ISSUANCE_RATE_DECIMALS ).div (signalledTokens);
183
+ return x.mul (TOKEN_DECIMALS ).div (signalledTokens);
175
184
}
176
185
177
186
/**
@@ -195,9 +204,10 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
195
204
Subgraph storage subgraph = subgraphs[_subgraphDeploymentID];
196
205
197
206
uint256 newAccrued = getAccRewardsPerSignal ().sub (subgraph.accRewardsPerSignalSnapshot);
198
-
199
207
uint256 subgraphSignalledTokens = curation.getCurationPoolTokens (_subgraphDeploymentID);
200
- return subgraphSignalledTokens.mul (newAccrued).add (subgraph.accRewardsForSubgraph);
208
+
209
+ uint256 newValue = newAccrued.mul (subgraphSignalledTokens).div (TOKEN_DECIMALS);
210
+ return subgraph.accRewardsForSubgraph.add (newValue);
201
211
}
202
212
203
213
/**
@@ -218,10 +228,12 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
218
228
uint256 newAccrued = accRewardsForSubgraph.sub (subgraph.accRewardsForSubgraphSnapshot);
219
229
220
230
uint256 subgraphAllocatedTokens = staking.getSubgraphAllocatedTokens (_subgraphDeploymentID);
221
- return (
222
- subgraphAllocatedTokens.mul (newAccrued).add (subgraph.accRewardsPerAllocatedToken),
223
- accRewardsForSubgraph
224
- );
231
+ if (subgraphAllocatedTokens == 0 ) {
232
+ return (0 , accRewardsForSubgraph);
233
+ }
234
+
235
+ uint256 newValue = newAccrued.mul (TOKEN_DECIMALS).div (subgraphAllocatedTokens);
236
+ return (subgraph.accRewardsPerAllocatedToken.add (newValue), accRewardsForSubgraph);
225
237
}
226
238
227
239
/**
@@ -291,7 +303,8 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
291
303
(uint256 accRewardsPerAllocatedToken , uint256 _ ) = getAccRewardsPerAllocatedToken (
292
304
alloc.subgraphDeploymentID
293
305
);
294
- return accRewardsPerAllocatedToken.sub (alloc.accRewardsPerAllocatedToken).mul (alloc.tokens);
306
+ uint256 newAccrued = accRewardsPerAllocatedToken.sub (alloc.accRewardsPerAllocatedToken);
307
+ return newAccrued.mul (alloc.tokens).div (TOKEN_DECIMALS);
295
308
}
296
309
297
310
/**
@@ -326,6 +339,7 @@ contract RewardsManager is RewardsManagerV1Storage, GraphUpgradeable, IRewardsMa
326
339
address indexer = msg .sender ;
327
340
328
341
uint256 rewards = indexerRewards[indexer];
342
+ require (rewards > 0 , "No rewards available for claiming " );
329
343
emit RewardsClaimed (indexer, rewards);
330
344
331
345
// Mint rewards tokens
0 commit comments