-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPausable.sol
60 lines (52 loc) · 1.77 KB
/
Pausable.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.7.6;
contract Pausable {
// Partial paused paused exit and enter functions for GRT, but not internal
// functions, such as allocating
bool internal _partialPaused;
// Paused will pause all major protocol functions
bool internal _paused;
// Time last paused for both pauses
uint256 public lastPausePartialTime;
uint256 public lastPauseTime;
// Pause guardian is a separate entity from the governor that can pause
address public pauseGuardian;
event PartialPauseChanged(bool isPaused);
event PauseChanged(bool isPaused);
event NewPauseGuardian(address indexed oldPauseGuardian, address indexed pauseGuardian);
/**
* @notice Change the partial paused state of the contract
*/
function _setPartialPaused(bool _toPause) internal {
if (_toPause == _partialPaused) {
return;
}
_partialPaused = _toPause;
if (_partialPaused) {
lastPausePartialTime = block.timestamp;
}
emit PartialPauseChanged(_partialPaused);
}
/**
* @notice Change the paused state of the contract
*/
function _setPaused(bool _toPause) internal {
if (_toPause == _paused) {
return;
}
_paused = _toPause;
if (_paused) {
lastPauseTime = block.timestamp;
}
emit PauseChanged(_paused);
}
/**
* @notice Change the Pause Guardian
* @param newPauseGuardian The address of the new Pause Guardian
*/
function _setPauseGuardian(address newPauseGuardian) internal {
address oldPauseGuardian = pauseGuardian;
pauseGuardian = newPauseGuardian;
emit NewPauseGuardian(oldPauseGuardian, pauseGuardian);
}
}