@@ -74,6 +74,7 @@ contract TokenStaking is Initializable, IStaking, Checkpoints {
74
74
struct ApplicationInfo {
75
75
ApplicationStatus status;
76
76
address panicButton;
77
+ uint96 authorizedOverall;
77
78
}
78
79
79
80
struct SlashingEvent {
@@ -328,6 +329,36 @@ contract TokenStaking is Initializable, IStaking, Checkpoints {
328
329
emit ApplicationStatusChanged (application, ApplicationStatus.APPROVED);
329
330
}
330
331
332
+ /// @notice Update `authorizedOverall` field for each application.
333
+ /// Can only be called by Governance. `authorizedOVerall` should be
334
+ /// equal to the sum of all authorization for particular application.
335
+ // TODO remove after use
336
+ function updateAuthorizedOverall (int96 [] memory authorizedOverallValues )
337
+ external
338
+ onlyGovernance
339
+ {
340
+ require (
341
+ authorizedOverallValues.length == applications.length ,
342
+ "Wrong input parameters "
343
+ );
344
+ for (uint256 i = 0 ; i < applications.length ; i++ ) {
345
+ address application = applications[i];
346
+ ApplicationInfo storage applicationStruct = applicationInfo[
347
+ application
348
+ ];
349
+ int96 authorizedOverall = authorizedOverallValues[i];
350
+ if (authorizedOverall >= 0 ) {
351
+ applicationStruct.authorizedOverall += uint96 (
352
+ authorizedOverall
353
+ );
354
+ } else {
355
+ applicationStruct.authorizedOverall -= uint96 (
356
+ - authorizedOverall
357
+ );
358
+ }
359
+ }
360
+ }
361
+
331
362
/// @notice Increases the authorization of the given staking provider for
332
363
/// the given application by the given amount. Can only be called by
333
364
/// the given staking provider’s authorizer.
@@ -370,6 +401,7 @@ contract TokenStaking is Initializable, IStaking, Checkpoints {
370
401
);
371
402
require (availableTValue >= amount, "Not enough stake to authorize " );
372
403
authorization.authorized += amount;
404
+ applicationStruct.authorizedOverall += amount;
373
405
emit AuthorizationIncreased (
374
406
stakingProvider,
375
407
application,
@@ -446,6 +478,7 @@ contract TokenStaking is Initializable, IStaking, Checkpoints {
446
478
447
479
uint96 fromAmount = authorization.authorized;
448
480
authorization.authorized -= authorization.deauthorizing;
481
+ applicationStruct.authorizedOverall -= authorization.deauthorizing;
449
482
authorization.deauthorizing = 0 ;
450
483
emit AuthorizationDecreaseApproved (
451
484
stakingProvider,
@@ -469,8 +502,11 @@ contract TokenStaking is Initializable, IStaking, Checkpoints {
469
502
address stakingProvider ,
470
503
address application
471
504
) external override {
505
+ ApplicationInfo storage applicationStruct = applicationInfo[
506
+ application
507
+ ];
472
508
require (
473
- applicationInfo[application] .status == ApplicationStatus.DISABLED,
509
+ applicationStruct .status == ApplicationStatus.DISABLED,
474
510
"Application is not disabled "
475
511
);
476
512
@@ -483,6 +519,7 @@ contract TokenStaking is Initializable, IStaking, Checkpoints {
483
519
require (fromAmount > 0 , "Application is not authorized " );
484
520
authorization.authorized = 0 ;
485
521
authorization.deauthorizing = 0 ;
522
+ applicationStruct.authorizedOverall -= fromAmount;
486
523
487
524
emit AuthorizationDecreaseApproved (
488
525
stakingProvider,
@@ -612,6 +649,8 @@ contract TokenStaking is Initializable, IStaking, Checkpoints {
612
649
.authorizations[application];
613
650
uint96 fromAmount = authorization.authorized;
614
651
authorization.authorized += amount;
652
+ //slither-disable-next-line reentrancy-benign
653
+ applicationInfo[application].authorizedOverall += amount;
615
654
emit AuthorizationIncreased (
616
655
stakingProvider,
617
656
application,
@@ -1116,6 +1155,9 @@ contract TokenStaking is Initializable, IStaking, Checkpoints {
1116
1155
if (authorization.authorized > totalStake) {
1117
1156
authorization.authorized = totalStake;
1118
1157
}
1158
+ applicationInfo[authorizedApplication].authorizedOverall -=
1159
+ fromAmount -
1160
+ authorization.authorized;
1119
1161
1120
1162
bool successful = true ;
1121
1163
//slither-disable-next-line calls-loop
0 commit comments