-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathConfigurationManager.sol
76 lines (66 loc) · 2.31 KB
/
ConfigurationManager.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
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.17;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { IConfigurationManager } from "../interfaces/IConfigurationManager.sol";
/**
* @title ConfigurationManager
* @author Pods Finance
* @notice Allows contracts to read protocol-wide settings
*/
contract ConfigurationManager is IConfigurationManager, Ownable {
mapping(address => mapping(bytes32 => uint256)) private _parameters;
mapping(address => uint256) private _caps;
mapping(address => address) private _allowedVaults;
address private immutable _global = address(0);
/**
* @inheritdoc IConfigurationManager
*/
function setParameter(
address target,
bytes32 name,
uint256 value
) public override onlyOwner {
_parameters[target][name] = value;
emit ParameterSet(target, name, value);
}
/**
* @inheritdoc IConfigurationManager
*/
function getParameter(address target, bytes32 name) external view override returns (uint256) {
return _parameters[target][name];
}
/**
* @inheritdoc IConfigurationManager
*/
function getGlobalParameter(bytes32 name) external view override returns (uint256) {
return _parameters[_global][name];
}
/**
* @inheritdoc IConfigurationManager
*/
function setCap(address target, uint256 value) external override onlyOwner {
if (target == address(0)) revert ConfigurationManager__TargetCannotBeTheZeroAddress();
_caps[target] = value;
emit SetCap(target, value);
}
/**
* @inheritdoc IConfigurationManager
*/
function getCap(address target) external view override returns (uint256) {
return _caps[target];
}
/**
* @inheritdoc IConfigurationManager
*/
function setVaultMigration(address oldVault, address newVault) external override onlyOwner {
if (newVault == address(0)) revert ConfigurationManager__NewVaultCannotBeTheZeroAddress();
_allowedVaults[oldVault] = newVault;
emit VaultAllowanceSet(oldVault, newVault);
}
/**
* @inheritdoc IConfigurationManager
*/
function getVaultMigration(address oldVault) external view override returns (address) {
return _allowedVaults[oldVault];
}
}