mirror of
https://github.com/Instadapp/dsa-governance.git
synced 2024-07-29 22:27:52 +00:00
180 lines
6.2 KiB
Solidity
180 lines
6.2 KiB
Solidity
|
pragma solidity ^0.7.0;
|
||
|
pragma experimental ABIEncoderV2;
|
||
|
|
||
|
interface TimelockInterface {
|
||
|
function delay() external view returns (uint);
|
||
|
function GRACE_PERIOD() external view returns (uint);
|
||
|
function acceptAdmin() external;
|
||
|
function queuedTransactions(bytes32 hash) external view returns (bool);
|
||
|
function queueTransaction(address target, uint value, string calldata signature, bytes calldata data, uint eta) external returns (bytes32);
|
||
|
function cancelTransaction(address target, uint value, string calldata signature, bytes calldata data, uint eta) external;
|
||
|
function executeTransaction(address target, uint value, string calldata signature, bytes calldata data, uint eta) external payable returns (bytes memory);
|
||
|
}
|
||
|
|
||
|
interface TokenInterface {
|
||
|
function getPriorVotes(address account, uint blockNumber) external view returns (uint96);
|
||
|
}
|
||
|
|
||
|
contract GovernorBravoEvents {
|
||
|
/// @notice An event emitted when a new proposal is created
|
||
|
event ProposalCreated(
|
||
|
uint id,
|
||
|
address proposer,
|
||
|
address[] targets,
|
||
|
uint[] values,
|
||
|
string[] signatures,
|
||
|
bytes[] calldatas,
|
||
|
uint startBlock,
|
||
|
uint endBlock,
|
||
|
string description
|
||
|
);
|
||
|
|
||
|
/// @notice An event emitted when a vote has been cast on a proposal
|
||
|
/// @param voter The address which casted a vote
|
||
|
/// @param proposalId The proposal id which was voted on
|
||
|
/// @param support Support value for the vote. 0=against, 1=for, 2=abstain
|
||
|
/// @param votes Number of votes which were cast by the voter
|
||
|
/// @param reason The reason given for the vote by the voter
|
||
|
event VoteCast(address indexed voter, uint proposalId, uint8 support, uint votes, string reason);
|
||
|
|
||
|
/// @notice An event emitted when a proposal has been canceled
|
||
|
event ProposalCanceled(uint id);
|
||
|
|
||
|
/// @notice An event emitted when a proposal has been queued in the Timelock
|
||
|
event ProposalQueued(uint id, uint eta);
|
||
|
|
||
|
/// @notice An event emitted when a proposal has been executed in the Timelock
|
||
|
event ProposalExecuted(uint id);
|
||
|
|
||
|
/// @notice An event emitted when the voting delay is set
|
||
|
event VotingDelaySet(uint oldVotingDelay, uint newVotingDelay);
|
||
|
|
||
|
/// @notice An event emitted when the voting period is set
|
||
|
event VotingPeriodSet(uint oldVotingPeriod, uint newVotingPeriod);
|
||
|
|
||
|
/// @notice Emitted when implementation is changed
|
||
|
event NewImplementation(address oldImplementation, address newImplementation);
|
||
|
|
||
|
/// @notice Emitted when proposal threshold is set
|
||
|
event ProposalThresholdSet(uint oldProposalThreshold, uint newProposalThreshold);
|
||
|
|
||
|
/// @notice Emitted when pendingAdmin is changed
|
||
|
event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);
|
||
|
|
||
|
/// @notice Emitted when pendingAdmin is accepted, which means admin is updated
|
||
|
event NewAdmin(address oldAdmin, address newAdmin);
|
||
|
}
|
||
|
|
||
|
contract GovernorBravoDelegatorStorage {
|
||
|
/// @notice Administrator for this contract
|
||
|
address public admin;
|
||
|
|
||
|
/// @notice Pending administrator for this contract
|
||
|
address public pendingAdmin;
|
||
|
|
||
|
/// @notice Active brains of Governor
|
||
|
address public implementation;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @title Storage for Governor Bravo Delegate
|
||
|
* @notice For future upgrades, do not change GovernorBravoDelegateStorageV1. Create a new
|
||
|
* contract which implements GovernorBravoDelegateStorageV1 and following the naming convention
|
||
|
* GovernorBravoDelegateStorageVX.
|
||
|
*/
|
||
|
contract GovernorBravoDelegateStorageV1 is GovernorBravoDelegatorStorage {
|
||
|
/// @notice The delay before voting on a proposal may take place, once proposed, in blocks
|
||
|
uint public votingDelay;
|
||
|
|
||
|
/// @notice The duration of voting on a proposal, in blocks
|
||
|
uint public votingPeriod;
|
||
|
|
||
|
/// @notice The number of votes required in order for a voter to become a proposer
|
||
|
uint public proposalThreshold;
|
||
|
|
||
|
/// @notice The total number of proposals
|
||
|
uint public proposalCount;
|
||
|
|
||
|
/// @notice The address of the DSL Protocol Timelock
|
||
|
TimelockInterface public timelock;
|
||
|
|
||
|
/// @notice The address of the DSL governance token
|
||
|
TokenInterface public token;
|
||
|
|
||
|
/// @notice The official record of all proposals ever proposed
|
||
|
mapping (uint => Proposal) public proposals;
|
||
|
|
||
|
/// @notice The latest proposal for each proposer
|
||
|
mapping (address => uint) public latestProposalIds;
|
||
|
|
||
|
struct Proposal {
|
||
|
// Unique id for looking up a proposal
|
||
|
uint id;
|
||
|
|
||
|
// Creator of the proposal
|
||
|
address proposer;
|
||
|
|
||
|
// The timestamp that the proposal will be available for execution, set once the vote succeeds
|
||
|
uint eta;
|
||
|
|
||
|
// the ordered list of target addresses for calls to be made
|
||
|
address[] targets;
|
||
|
|
||
|
// The ordered list of values (i.e. msg.value) to be passed to the calls to be made
|
||
|
uint[] values;
|
||
|
|
||
|
// The ordered list of function signatures to be called
|
||
|
string[] signatures;
|
||
|
|
||
|
// The ordered list of calldata to be passed to each call
|
||
|
bytes[] calldatas;
|
||
|
|
||
|
// The block at which voting begins: holders must delegate their votes prior to this block
|
||
|
uint startBlock;
|
||
|
|
||
|
// The block at which voting ends: votes must be cast prior to this block
|
||
|
uint endBlock;
|
||
|
|
||
|
// Current number of votes in favor of this proposal
|
||
|
uint forVotes;
|
||
|
|
||
|
// Current number of votes in opposition to this proposal
|
||
|
uint againstVotes;
|
||
|
|
||
|
// Current number of votes for abstaining for this proposal
|
||
|
uint abstainVotes;
|
||
|
|
||
|
// Flag marking whether the proposal has been canceled
|
||
|
bool canceled;
|
||
|
|
||
|
// Flag marking whether the proposal has been executed
|
||
|
bool executed;
|
||
|
|
||
|
// Receipts of ballots for the entire set of voters
|
||
|
mapping (address => Receipt) receipts;
|
||
|
}
|
||
|
|
||
|
/// @notice Ballot receipt record for a voter
|
||
|
struct Receipt {
|
||
|
// Whether or not a vote has been cast
|
||
|
bool hasVoted;
|
||
|
|
||
|
// Whether or not the voter supports the proposal or abstains
|
||
|
uint8 support;
|
||
|
|
||
|
// The number of votes the voter had, which were cast
|
||
|
uint96 votes;
|
||
|
}
|
||
|
|
||
|
/// @notice Possible states that a proposal may be in
|
||
|
enum ProposalState {
|
||
|
Pending,
|
||
|
Active,
|
||
|
Canceled,
|
||
|
Defeated,
|
||
|
Succeeded,
|
||
|
Queued,
|
||
|
Expired,
|
||
|
Executed
|
||
|
}
|
||
|
}
|