-
Notifications
You must be signed in to change notification settings - Fork 4
/
AlchemixGovernor.sol
94 lines (82 loc) · 3.34 KB
/
AlchemixGovernor.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
// SPDX-License-Identifier: GPL-3
pragma solidity ^0.8.15;
import "src/governance/L2GovernorCountingSimple.sol";
import "src/governance/L2GovernorVotes.sol";
import "src/governance/L2GovernorVotesQuorumFraction.sol";
import "src/governance/TimelockExecutor.sol";
import "openzeppelin-contracts/contracts/governance/IGovernor.sol";
import "openzeppelin-contracts/contracts/governance/utils/IVotes.sol";
/**
* @title Alchemix Governor
* @notice Alchemix specific governance parameters
* @dev Extends the Open Zeppelin governance system
*/
contract AlchemixGovernor is L2Governor, L2GovernorVotes, L2GovernorVotesQuorumFraction, L2GovernorCountingSimple {
address public admin;
address public pendingAdmin;
uint256 public constant MAX_PROPOSAL_NUMERATOR = 5000; // 50% of total supply to create a proposal
uint256 public constant PROPOSAL_DENOMINATOR = 10_000; // BPS denominator
uint256 public proposalNumerator = 400; // 4% of total supply to create a proposal
uint256 public quorumNumeratorValue = 2000; // 20% of total supply to pass a proposal
constructor(
IVotes _ve,
TimelockExecutor timelockAddress
)
L2Governor("Alchemix Governor", timelockAddress)
L2GovernorVotes(_ve)
L2GovernorVotesQuorumFraction(quorumNumeratorValue)
{
require(address(_ve) != address(0), "ve address cannot be zero address");
require(address(timelockAddress) != address(0), "timelock address cannot be zero address");
admin = msg.sender;
}
/*
View functions
*/
/**
* @dev Part of the Governor Bravo's interface: _"The number of votes required in order for a voter to become a proposer"_.
*/
function proposalThreshold() public view override(L2Governor) returns (uint256) {
return (token.getPastTotalSupply(block.timestamp) * proposalNumerator) / PROPOSAL_DENOMINATOR;
}
/*
Admin functions
*/
function setAdmin(address _admin) external {
require(msg.sender == admin, "not admin");
pendingAdmin = _admin;
}
function acceptAdmin() external {
require(msg.sender == pendingAdmin, "not pending admin");
admin = pendingAdmin;
emit AdminUpdated(pendingAdmin);
}
/**
* @dev Set the % of total supply required to create a proposal
* @param numerator The new numerator value for the quorum fraction
*/
function setProposalNumerator(uint256 numerator) external {
require(msg.sender == admin, "not admin");
require(numerator <= MAX_PROPOSAL_NUMERATOR, "numerator too high");
proposalNumerator = numerator;
emit ProposalNumberSet(numerator);
}
/**
* @dev Set the value for the voting delay as defined in L2Governor.sol
* @param newDelay The new number of days voting will be delayed by
*/
function setVotingDelay(uint256 newDelay) external {
require(msg.sender == admin, "not admin");
votingDelay = newDelay;
emit VotingDelaySet(votingDelay);
}
/**
* @dev Set the value for the voting period as defined in L2Governor.sol
* @param newPeriod The new number of days voting will be open for
*/
function setVotingPeriod(uint256 newPeriod) external {
require(msg.sender == admin, "not admin");
votingPeriod = newPeriod;
emit VotingPeriodSet(votingPeriod);
}
}