-
Notifications
You must be signed in to change notification settings - Fork 13
/
GlobalPause.sol
70 lines (64 loc) · 2.54 KB
/
GlobalPause.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
61
62
63
64
65
66
67
68
69
70
// SPDX-License-Identifier: MIT
pragma solidity 0.8.18;
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import {GlobalOwnableUpgradeable} from "./abstracts/GlobalOwnableUpgradeable.sol";
/**
* @title GlobalPause
* @author Lila Rest (https://lila.rest)
* @custom:security-contact security@ledgity.com
*
* @notice Holds a global pause state shared by all contracts of the Ledgity Yield
* codebase.
*
* @dev Specifically, some contracts within the codebase inherit from the
* GlobalPausableUpgradeable abstract contract. This provides them with an overriden
* paused() function that retrieves the pause state from this contract instead.
*
* @dev For further details, see "GlobalPause" section of whitepaper.
* @custom:security-contact security@ledgity.com
*/
contract GlobalPause is
Initializable,
UUPSUpgradeable,
GlobalOwnableUpgradeable,
PausableUpgradeable
{
/**
* @notice Prevents implementation contract from being initialized as recommended by
* OpenZeppelin.
* @dev See: https://docs.openzeppelin.com/contracts/4.x/api/proxy#Initializable-_disableInitializers--
* @custom:oz-upgrades-unsafe-allow constructor
*/
constructor() {
_disableInitializers();
}
/**
* @notice Initializer function of the contract. It replaces the constructor()
* function in the context of upgradeable contracts.
* @dev See: https://docs.openzeppelin.com/contracts/4.x/upgradeable
* @param globalOwner_ The address of the GlobalOwner contract.
*/
function initialize(address globalOwner_) public initializer {
__GlobalOwnable_init(globalOwner_);
__Pausable_init();
__UUPSUpgradeable_init();
}
/**
* @notice Override of UUPSUpgradeable._authorizeUpgrade() function restricted to
* global owner. It is called by the proxy contract during an upgrade.
* @param newImplementation The address of the new implementation contract.
*/
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
/**
* @dev Public implementation of PausableUpgradeable's pausing and unpausing functions
* but restricted to contract's owner.
*/
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
}