@@ -186,7 +186,7 @@ contract Staking is StakingV2Storage, GraphUpgradeable, IStaking {
186
186
/**
187
187
* @dev Check if the caller is the slasher.
188
188
*/
189
- modifier onlySlasher {
189
+ modifier onlySlasher () {
190
190
require (slashers[msg .sender ] == true , "!slasher " );
191
191
_;
192
192
}
@@ -976,10 +976,10 @@ contract Staking is StakingV2Storage, GraphUpgradeable, IStaking {
976
976
977
977
// -- Collect protocol tax --
978
978
// If the Allocation is not active or closed we are going to charge a 100% protocol tax
979
- uint256 usedProtocolPercentage =
980
- (allocState == AllocationState.Active || allocState == AllocationState.Closed)
981
- ? protocolPercentage
982
- : MAX_PPM;
979
+ uint256 usedProtocolPercentage = (allocState == AllocationState.Active ||
980
+ allocState == AllocationState.Closed)
981
+ ? protocolPercentage
982
+ : MAX_PPM;
983
983
uint256 protocolTax = _collectTax (graphToken, queryFees, usedProtocolPercentage);
984
984
queryFees = queryFees.sub (protocolTax);
985
985
@@ -1114,17 +1114,16 @@ contract Staking is StakingV2Storage, GraphUpgradeable, IStaking {
1114
1114
// Creates an allocation
1115
1115
// Allocation identifiers are not reused
1116
1116
// The assetHolder address can send collected funds to the allocation
1117
- Allocation memory alloc =
1118
- Allocation (
1119
- _indexer,
1120
- _subgraphDeploymentID,
1121
- _tokens, // Tokens allocated
1122
- epochManager ().currentEpoch (), // createdAtEpoch
1123
- 0 , // closedAtEpoch
1124
- 0 , // Initialize collected fees
1125
- 0 , // Initialize effective allocation
1126
- _updateRewards (_subgraphDeploymentID) // Initialize accumulated rewards per stake allocated
1127
- );
1117
+ Allocation memory alloc = Allocation (
1118
+ _indexer,
1119
+ _subgraphDeploymentID,
1120
+ _tokens, // Tokens allocated
1121
+ epochManager ().currentEpoch (), // createdAtEpoch
1122
+ 0 , // closedAtEpoch
1123
+ 0 , // Initialize collected fees
1124
+ 0 , // Initialize effective allocation
1125
+ _updateRewards (_subgraphDeploymentID) // Initialize accumulated rewards per stake allocated
1126
+ );
1128
1127
allocations[_allocationID] = alloc;
1129
1128
1130
1129
// Mark allocated tokens as used
@@ -1134,8 +1133,7 @@ contract Staking is StakingV2Storage, GraphUpgradeable, IStaking {
1134
1133
// Used for rewards calculations
1135
1134
subgraphAllocations[alloc.subgraphDeploymentID] = subgraphAllocations[
1136
1135
alloc.subgraphDeploymentID
1137
- ]
1138
- .add (alloc.tokens);
1136
+ ].add (alloc.tokens);
1139
1137
1140
1138
emit AllocationCreated (
1141
1139
_indexer,
@@ -1207,8 +1205,7 @@ contract Staking is StakingV2Storage, GraphUpgradeable, IStaking {
1207
1205
// Used for rewards calculations
1208
1206
subgraphAllocations[alloc.subgraphDeploymentID] = subgraphAllocations[
1209
1207
alloc.subgraphDeploymentID
1210
- ]
1211
- .sub (alloc.tokens);
1208
+ ].sub (alloc.tokens);
1212
1209
1213
1210
emit AllocationClosed (
1214
1211
alloc.indexer,
@@ -1310,16 +1307,16 @@ contract Staking is StakingV2Storage, GraphUpgradeable, IStaking {
1310
1307
uint256 delegatedTokens = _tokens.sub (delegationTax);
1311
1308
1312
1309
// Calculate shares to issue
1313
- uint256 shares =
1314
- (pool.tokens == 0 )
1315
- ? delegatedTokens
1316
- : delegatedTokens. mul (pool. shares). div (pool.tokens );
1310
+ uint256 shares = (pool.tokens == 0 )
1311
+ ? delegatedTokens
1312
+ : delegatedTokens. mul (pool.shares). div (pool.tokens);
1313
+ require (shares > 0 , " ! shares" );
1317
1314
1318
1315
// Update the delegation pool
1319
1316
pool.tokens = pool.tokens.add (delegatedTokens);
1320
1317
pool.shares = pool.shares.add (shares);
1321
1318
1322
- // Update the delegation
1319
+ // Update the individual delegation
1323
1320
delegation.shares = delegation.shares.add (shares);
1324
1321
1325
1322
emit StakeDelegated (_indexer, _delegator, delegatedTokens, shares);
0 commit comments