forked from aave-dao/aave-v3-origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathACLManager.sol
133 lines (110 loc) · 4.29 KB
/
ACLManager.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.10;
import {AccessControl} from '../../dependencies/openzeppelin/contracts/AccessControl.sol';
import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol';
import {IACLManager} from '../../interfaces/IACLManager.sol';
import {Errors} from '../libraries/helpers/Errors.sol';
/**
* @title ACLManager
* @author Aave
* @notice Access Control List Manager. Main registry of system roles and permissions.
*/
contract ACLManager is AccessControl, IACLManager {
bytes32 public constant override POOL_ADMIN_ROLE = keccak256('POOL_ADMIN');
bytes32 public constant override EMERGENCY_ADMIN_ROLE = keccak256('EMERGENCY_ADMIN');
bytes32 public constant override RISK_ADMIN_ROLE = keccak256('RISK_ADMIN');
bytes32 public constant override FLASH_BORROWER_ROLE = keccak256('FLASH_BORROWER');
bytes32 public constant override BRIDGE_ROLE = keccak256('BRIDGE');
bytes32 public constant override ASSET_LISTING_ADMIN_ROLE = keccak256('ASSET_LISTING_ADMIN');
IPoolAddressesProvider public immutable ADDRESSES_PROVIDER;
/**
* @dev Constructor
* @dev The ACL admin should be initialized at the addressesProvider beforehand
* @param provider The address of the PoolAddressesProvider
*/
constructor(IPoolAddressesProvider provider) {
ADDRESSES_PROVIDER = provider;
address aclAdmin = provider.getACLAdmin();
require(aclAdmin != address(0), Errors.ACL_ADMIN_CANNOT_BE_ZERO);
_setupRole(DEFAULT_ADMIN_ROLE, aclAdmin);
}
/// @inheritdoc IACLManager
function setRoleAdmin(
bytes32 role,
bytes32 adminRole
) external override onlyRole(DEFAULT_ADMIN_ROLE) {
_setRoleAdmin(role, adminRole);
}
/// @inheritdoc IACLManager
function addPoolAdmin(address admin) external override {
grantRole(POOL_ADMIN_ROLE, admin);
}
/// @inheritdoc IACLManager
function removePoolAdmin(address admin) external override {
revokeRole(POOL_ADMIN_ROLE, admin);
}
/// @inheritdoc IACLManager
function isPoolAdmin(address admin) external view override returns (bool) {
return hasRole(POOL_ADMIN_ROLE, admin);
}
/// @inheritdoc IACLManager
function addEmergencyAdmin(address admin) external override {
grantRole(EMERGENCY_ADMIN_ROLE, admin);
}
/// @inheritdoc IACLManager
function removeEmergencyAdmin(address admin) external override {
revokeRole(EMERGENCY_ADMIN_ROLE, admin);
}
/// @inheritdoc IACLManager
function isEmergencyAdmin(address admin) external view override returns (bool) {
return hasRole(EMERGENCY_ADMIN_ROLE, admin);
}
/// @inheritdoc IACLManager
function addRiskAdmin(address admin) external override {
grantRole(RISK_ADMIN_ROLE, admin);
}
/// @inheritdoc IACLManager
function removeRiskAdmin(address admin) external override {
revokeRole(RISK_ADMIN_ROLE, admin);
}
/// @inheritdoc IACLManager
function isRiskAdmin(address admin) external view override returns (bool) {
return hasRole(RISK_ADMIN_ROLE, admin);
}
/// @inheritdoc IACLManager
function addFlashBorrower(address borrower) external override {
grantRole(FLASH_BORROWER_ROLE, borrower);
}
/// @inheritdoc IACLManager
function removeFlashBorrower(address borrower) external override {
revokeRole(FLASH_BORROWER_ROLE, borrower);
}
/// @inheritdoc IACLManager
function isFlashBorrower(address borrower) external view override returns (bool) {
return hasRole(FLASH_BORROWER_ROLE, borrower);
}
/// @inheritdoc IACLManager
function addBridge(address bridge) external override {
grantRole(BRIDGE_ROLE, bridge);
}
/// @inheritdoc IACLManager
function removeBridge(address bridge) external override {
revokeRole(BRIDGE_ROLE, bridge);
}
/// @inheritdoc IACLManager
function isBridge(address bridge) external view override returns (bool) {
return hasRole(BRIDGE_ROLE, bridge);
}
/// @inheritdoc IACLManager
function addAssetListingAdmin(address admin) external override {
grantRole(ASSET_LISTING_ADMIN_ROLE, admin);
}
/// @inheritdoc IACLManager
function removeAssetListingAdmin(address admin) external override {
revokeRole(ASSET_LISTING_ADMIN_ROLE, admin);
}
/// @inheritdoc IACLManager
function isAssetListingAdmin(address admin) external view override returns (bool) {
return hasRole(ASSET_LISTING_ADMIN_ROLE, admin);
}
}