@gearbox-protocol/periphery-v3 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,11 @@ import {ICreditManagerV3} from "@gearbox-protocol/core-v3/contracts/interfaces/I
9
9
  import {ACLNonReentrantTrait} from "@gearbox-protocol/core-v3/contracts/traits/ACLNonReentrantTrait.sol";
10
10
  import {ContractsRegisterTrait} from "@gearbox-protocol/core-v3/contracts/traits/ContractsRegisterTrait.sol";
11
11
 
12
+ enum PausableAction {
13
+ Pause,
14
+ Unpause
15
+ }
16
+
12
17
  /// @title MultiPause
13
18
  /// @author Gearbox Foundation
14
19
  /// @notice Allows pausable admins to pause multiple contracts in a single transaction
@@ -23,14 +28,14 @@ contract MultiPause is ACLNonReentrantTrait, ContractsRegisterTrait {
23
28
  /// @dev Ignores contracts that are already paused
24
29
  /// @dev Reverts if caller is not a pausable admin
25
30
  function pauseContracts(address[] memory contracts) external pausableAdminsOnly {
26
- _pauseContracts(contracts);
31
+ _pauseContracts(contracts, PausableAction.Pause);
27
32
  }
28
33
 
29
34
  /// @notice Pauses all registered pools
30
35
  /// @dev Ignores contracts that are already paused
31
36
  /// @dev Reverts if caller is not a pausable admin
32
37
  function pauseAllPools() external pausableAdminsOnly {
33
- _pauseAllPools();
38
+ _pauseAllPools(PausableAction.Pause);
34
39
  }
35
40
 
36
41
  /// @notice Pauses all registered credit managers
@@ -38,24 +43,32 @@ contract MultiPause is ACLNonReentrantTrait, ContractsRegisterTrait {
38
43
  /// @dev Ignores contracts that are already paused
39
44
  /// @dev Reverts if caller is not a pausable admin
40
45
  function pauseAllCreditManagers() external pausableAdminsOnly {
41
- _pauseAllCreditManagers();
46
+ _pauseAllCreditManagers(PausableAction.Pause);
42
47
  }
43
48
 
44
49
  /// @notice Pauses all registered credit managers and pools
45
50
  /// @dev Ignores contracts that are already paused
46
51
  /// @dev Reverts if caller is not a pausable admin
47
52
  function pauseAllContracts() external pausableAdminsOnly {
48
- _pauseAllPools();
49
- _pauseAllCreditManagers();
53
+ _pauseAllPools(PausableAction.Pause);
54
+ _pauseAllCreditManagers(PausableAction.Pause);
55
+ }
56
+
57
+ /// @notice Unpauses all registered credit managers and pools
58
+ /// @dev Ignores contracts that aren't paused
59
+ /// @dev Reverts if caller is not a unpausable admin
60
+ function unpauseAllContracts() external unpausableAdminsOnly {
61
+ _pauseAllPools(PausableAction.Unpause);
62
+ _pauseAllCreditManagers(PausableAction.Unpause);
50
63
  }
51
64
 
52
65
  /// @dev Internal function to pause all pools
53
- function _pauseAllPools() internal {
54
- _pauseContracts(IContractsRegister(contractsRegister).getPools());
66
+ function _pauseAllPools(PausableAction action) internal {
67
+ _pauseContracts(IContractsRegister(contractsRegister).getPools(), action);
55
68
  }
56
69
 
57
70
  /// @dev Internal function to pause all credit managers
58
- function _pauseAllCreditManagers() internal {
71
+ function _pauseAllCreditManagers(PausableAction action) internal {
59
72
  address[] memory contracts = IContractsRegister(contractsRegister).getCreditManagers();
60
73
  uint256 len = contracts.length;
61
74
  unchecked {
@@ -64,16 +77,21 @@ contract MultiPause is ACLNonReentrantTrait, ContractsRegisterTrait {
64
77
  contracts[i] = ICreditManagerV3(contracts[i]).creditFacade();
65
78
  }
66
79
  }
67
- _pauseContracts(contracts);
80
+ _pauseContracts(contracts, action);
68
81
  }
69
82
 
70
- /// @dev Internal function to pause contracts from the given list
71
- function _pauseContracts(address[] memory contracts) internal {
83
+ /// @dev Internal function to pause/unpause contracts from the given list
84
+ function _pauseContracts(address[] memory contracts, PausableAction action) internal {
72
85
  uint256 len = contracts.length;
73
86
  unchecked {
74
87
  for (uint256 i; i < len; ++i) {
75
- if (ACLNonReentrantTrait(contracts[i]).paused()) continue;
76
- ACLNonReentrantTrait(contracts[i]).pause();
88
+ if (action == PausableAction.Pause) {
89
+ if (ACLNonReentrantTrait(contracts[i]).paused()) continue;
90
+ ACLNonReentrantTrait(contracts[i]).pause();
91
+ } else {
92
+ if (!ACLNonReentrantTrait(contracts[i]).paused()) continue;
93
+ ACLNonReentrantTrait(contracts[i]).unpause();
94
+ }
77
95
  }
78
96
  }
79
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/periphery-v3",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "main": "index.js",
5
5
  "repository": "git@github.com:Gearbox-protocol/periphery-v3.git",
6
6
  "author": "Mikael <26343374+0xmikko@users.noreply.github.com>",