-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathZkProtocolGovernor.sol
More file actions
151 lines (139 loc) · 6.05 KB
/
ZkProtocolGovernor.sol
File metadata and controls
151 lines (139 loc) · 6.05 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
import {IGovernor} from "@openzeppelin/contracts/governance/IGovernor.sol";
import {Governor} from "@openzeppelin/contracts/governance/Governor.sol";
import {GovernorPreventLateQuorum} from "@openzeppelin/contracts/governance/extensions/GovernorPreventLateQuorum.sol";
import {GovernorSettings} from "@openzeppelin/contracts/governance/extensions/GovernorSettings.sol";
import {GovernorTimelockControl} from "@openzeppelin/contracts/governance/extensions/GovernorTimelockControl.sol";
import {GovernorVotes} from "@openzeppelin/contracts/governance/extensions/GovernorVotes.sol";
import {GovernorCountingFractional} from "src/lib/GovernorCountingFractional.sol";
import {IVotes} from "@openzeppelin/contracts/governance/utils/IVotes.sol";
import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol";
import {GovernorSettableFixedQuorum} from "src/extensions/GovernorSettableFixedQuorum.sol";
/// @title ZkProtocolGovernor
/// @author [ScopeLift](https://scopelift.co)
/// @notice A governance contract responsible for executing proposals that upgrade zkSync or components of the zkSync
/// governance system.
/// @custom:security-contact security@zksync.io
contract ZkProtocolGovernor is
GovernorCountingFractional,
GovernorSettings,
GovernorVotes,
GovernorTimelockControl,
GovernorPreventLateQuorum,
GovernorSettableFixedQuorum
{
/// @param _name The name used as the EIP712 signing domain.
/// @param _token The token used for voting on proposals.
/// @param _timelock The timelock used for managing proposals.
/// @param _initialVotingDelay The delay before voting on a proposal begins.
/// @param _initialVotingPeriod The period of time voting will take place.
/// @param _initialProposalThreshold The number of tokens needed to create a proposal.
/// @param _initialQuorum The number of total votes needed to pass a proposal.
/// @param _initialVoteExtension The time to extend the voting period if quorum is met near the end of voting.
constructor(
string memory _name,
IVotes _token,
TimelockController _timelock,
uint48 _initialVotingDelay,
uint32 _initialVotingPeriod,
uint256 _initialProposalThreshold,
uint224 _initialQuorum,
uint64 _initialVoteExtension
)
Governor(_name)
GovernorSettings(_initialVotingDelay, _initialVotingPeriod, _initialProposalThreshold)
GovernorVotes(_token)
GovernorTimelockControl(_timelock)
GovernorPreventLateQuorum(_initialVoteExtension)
GovernorSettableFixedQuorum(_initialQuorum)
{}
/// @inheritdoc GovernorCountingFractional
/// @dev We override this function to resolve ambiguity between inherited contracts.
function castVoteWithReasonAndParamsBySig(
uint256 _proposalId,
uint8 _support,
string calldata _reason,
bytes memory _params,
uint8 _v,
bytes32 _r,
bytes32 _s
) public override(Governor, GovernorCountingFractional, IGovernor) returns (uint256) {
return
GovernorCountingFractional.castVoteWithReasonAndParamsBySig(_proposalId, _support, _reason, _params, _v, _r, _s);
}
/// @inheritdoc GovernorPreventLateQuorum
/// @dev We override this function to resolve ambiguity between inherited contracts.
function proposalDeadline(uint256 _proposalId)
public
view
virtual
override(Governor, IGovernor, GovernorPreventLateQuorum)
returns (uint256)
{
return GovernorPreventLateQuorum.proposalDeadline(_proposalId);
}
/// @inheritdoc GovernorSettings
/// @dev We override this function to resolve ambiguity between inherited contracts.
function proposalThreshold() public view virtual override(Governor, GovernorSettings) returns (uint256) {
return GovernorSettings.proposalThreshold();
}
/// @inheritdoc GovernorTimelockControl
/// @dev We override this function to resolve ambiguity between inherited contracts.
function state(uint256 _proposalId)
public
view
virtual
override(Governor, GovernorTimelockControl)
returns (IGovernor.ProposalState)
{
return GovernorTimelockControl.state(_proposalId);
}
/// @inheritdoc GovernorTimelockControl
/// @dev We override this function to resolve ambiguity between inherited contracts.
function supportsInterface(bytes4 _interfaceId)
public
view
virtual
override(Governor, GovernorTimelockControl)
returns (bool)
{
return GovernorTimelockControl.supportsInterface(_interfaceId);
}
/// @inheritdoc GovernorTimelockControl
/// @dev We override this function to resolve ambiguity between inherited contracts.
function _cancel(
address[] memory _targets,
uint256[] memory _values,
bytes[] memory _calldatas,
bytes32 _descriptionHash
) internal virtual override(Governor, GovernorTimelockControl) returns (uint256) {
return GovernorTimelockControl._cancel(_targets, _values, _calldatas, _descriptionHash);
}
/// @inheritdoc GovernorPreventLateQuorum
/// @dev We override this function to resolve ambiguity between inherited contracts.
function _castVote(uint256 _proposalId, address _account, uint8 _support, string memory _reason, bytes memory _params)
internal
virtual
override(Governor, GovernorPreventLateQuorum)
returns (uint256)
{
return GovernorPreventLateQuorum._castVote(_proposalId, _account, _support, _reason, _params);
}
/// @inheritdoc GovernorTimelockControl
/// @dev We override this function to resolve ambiguity between inherited contracts.
function _execute(
uint256 _proposalId,
address[] memory _targets,
uint256[] memory _values,
bytes[] memory _calldatas,
bytes32 _descriptionHash
) internal virtual override(Governor, GovernorTimelockControl) {
return GovernorTimelockControl._execute(_proposalId, _targets, _values, _calldatas, _descriptionHash);
}
/// @inheritdoc GovernorTimelockControl
/// @dev We override this function to resolve ambiguity between inherited contracts.
function _executor() internal view virtual override(Governor, GovernorTimelockControl) returns (address) {
return GovernorTimelockControl._executor();
}
}