-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gov.sol
86 lines (77 loc) · 3.1 KB
/
Gov.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
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/governance/Governor.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorSettings.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotes.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol";
/// @title DAO Contract
/// @notice This contract implements a voting system using OpenZeppelin's Governor framework
/// @dev Uses OpenZeppelin contracts v5.0.2
contract Gov is
Governor,
GovernorSettings,
GovernorCountingSimple,
GovernorVotes,
GovernorVotesQuorumFraction
{
string public manifesto;
event ManifestoUpdated(string cid);
/// @notice Initializes the governance contract
/// @param _token The address of the token used for voting
/// @param _manifesto The initial CID of the manifesto
/// @param _name The name of the governance contract
/// @param _votingDelay The delay before voting starts
/// @param _votingPeriod The duration of the voting period
/// @param _votingThreshold The minimum number of votes required to create a proposal
/// @param _quorum The percentage of total supply that must participate for a vote to succeed
constructor(
IVotes _token,
string memory _manifesto,
string memory _name,
uint48 _votingDelay,
uint32 _votingPeriod,
uint256 _votingThreshold,
uint256 _quorum
)
Governor(_name)
GovernorSettings(_votingDelay, _votingPeriod, _votingThreshold)
GovernorVotes(_token)
GovernorVotesQuorumFraction(_quorum)
{
manifesto = _manifesto;
}
/// @notice Returns the delay before voting on a proposal may take place
function votingDelay() public view override(Governor, GovernorSettings) returns (uint256) {
return super.votingDelay();
}
/// @notice Returns the duration of the voting period
function votingPeriod() public view override(Governor, GovernorSettings) returns (uint256) {
return super.votingPeriod();
}
/// @notice Returns the quorum for a specific block number
/// @param blockNumber The block number to check the quorum for
/// @return The number of votes required for a quorum
function quorum(
uint256 blockNumber
) public view override(Governor, GovernorVotesQuorumFraction) returns (uint256) {
return super.quorum(blockNumber);
}
/// @notice Returns the proposal threshold
/// @return The minimum number of votes required to create a proposal
function proposalThreshold()
public
view
override(Governor, GovernorSettings)
returns (uint256)
{
return super.proposalThreshold();
}
/// @notice Replaces the CID of the manifesto
/// @dev Must include the DAO mission statement
/// @param cid The CID of the new manifesto
function setManifesto(string memory cid) public onlyGovernance {
manifesto = cid;
emit ManifestoUpdated(cid);
}
}