-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathEasyTrackStorage.sol
135 lines (105 loc) · 4.75 KB
/
EasyTrackStorage.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
134
135
// SPDX-FileCopyrightText: 2021 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
import "./interfaces/IEVMScriptExecutor.sol";
import "OpenZeppelin/[email protected]/contracts/access/AccessControlUpgradeable.sol";
import "OpenZeppelin/[email protected]/contracts/security/PausableUpgradeable.sol";
interface IMiniMeToken {
function balanceOfAt(address _owner, uint256 _blockNumber) external pure returns (uint256);
function totalSupplyAt(uint256 _blockNumber) external view returns (uint256);
}
struct Motion {
uint256 id;
address evmScriptFactory;
address creator;
uint256 duration;
uint256 startDate;
uint256 snapshotBlock;
uint256 objectionsThreshold;
uint256 objectionsAmount;
uint256 objectionsAmountPct;
bytes32 evmScriptHash;
}
/// @author psirex
/// @notice Keeps all variables of the EasyTrack
/// @dev All variables stored in this contract to simplify
/// future upgrades of Easy Track and and minimize the risk of storage collisions.
/// New variables can be added ONLY after already declared variables.
/// Existed variables CAN'T be deleted or reordered
contract EasyTrackStorage is Initializable, PausableUpgradeable, AccessControlUpgradeable {
// -------------
// EVENTS
// -------------
event MotionDurationChanged(uint256 _motionDuration);
event MotionsCountLimitChanged(uint256 _newMotionsCountLimit);
event ObjectionsThresholdChanged(uint256 _newThreshold);
// -------------
// ROLES
// -------------
bytes32 public constant PAUSE_ROLE = keccak256("PAUSE_ROLE");
bytes32 public constant UNPAUSE_ROLE = keccak256("UNPAUSE_ROLE");
bytes32 public constant CANCEL_ROLE = keccak256("CANCEL_ROLE");
// ------------
// CONSTANTS
// ------------
/// @notice Upper bound for motionsCountLimit variable.
uint256 public constant MAX_MOTIONS_LIMIT = 24;
/// @notice Upper bound for objectionsThreshold variable.
/// @dev Stored in basis points (1% = 100)
uint256 public constant MAX_OBJECTIONS_THRESHOLD = 500;
/// @notice Lower bound for motionDuration variable
uint256 public constant MIN_MOTION_DURATION = 48 hours;
// ------------
// MOTION SETTING VARIABLES
// ------------
/// @notice Percent from total supply of governance tokens required to reject motion.
/// @dev Value stored in basis points: 1% == 100.
uint256 public objectionsThreshold;
/// @notice Max count of active motions
uint256 public motionsCountLimit;
/// @notice Minimal time required to pass before enacting of motion
uint256 public motionDuration;
// ------------
// EVM SCRIPT FACTORIES VARIABLES
// ------------
/// @notice List of allowed EVMScript factories
address[] public evmScriptFactories;
// Position of the EVMScript factory in the `evmScriptFactories` array,
// plus 1 because index 0 means a value is not in the set.
mapping(address => uint256) internal evmScriptFactoryIndices;
/// @notice Permissions of current list of allowed EVMScript factories.
mapping(address => bytes) public evmScriptFactoryPermissions;
// ------------
// EASY TRACK VARIABLES
// ------------
/// @notice List of active motions
Motion[] public motions;
// Id of the lastly created motion
uint256 internal lastMotionId;
/// @notice Address of governanceToken which implements IMiniMeToken interface
IMiniMeToken public governanceToken;
/// @notice Address of current EVMScriptExecutor
IEVMScriptExecutor public evmScriptExecutor;
// Position of the motion in the `motions` array, plus 1
// because index 0 means a value is not in the set.
mapping(uint256 => uint256) internal motionIndicesByMotionId;
/// @notice Stores if motion with given id has been objected from given address.
mapping(uint256 => mapping(address => bool)) public objections;
/// @notice Initializes EasyTrackStorage variables with default values and calls initialize methods on base contracts.
/// @dev This method can be called only once
function __EasyTrackStorage_init(address _governanceToken, address _admin) public initializer {
__Pausable_init();
__AccessControl_init();
_setupRole(DEFAULT_ADMIN_ROLE, _admin);
_setupRole(PAUSE_ROLE, _admin);
_setupRole(UNPAUSE_ROLE, _admin);
_setupRole(CANCEL_ROLE, _admin);
objectionsThreshold = 50;
motionsCountLimit = MAX_MOTIONS_LIMIT;
motionDuration = MIN_MOTION_DURATION;
governanceToken = IMiniMeToken(_governanceToken);
emit ObjectionsThresholdChanged(50);
emit MotionsCountLimitChanged(MAX_MOTIONS_LIMIT);
emit MotionDurationChanged(MIN_MOTION_DURATION);
}
}