Specs
Source
See the github repo here.
Overview
Powers is a Role Restricted Governance Protocol that provides a modular, flexible, decentralized and efficient governance engine for DAOs. It is designed to be used in combination with implementations of Law.sol
contracts.
Key differences from OpenZeppelin's Governor.sol:
DAO actions must be encoded in role-restricted external contracts (laws) following the
ILaw
interfaceProposing, voting, cancelling and executing actions are role-restricted along the target law
All DAO actions must run through the governance flow provided by Powers.sol
Uses a non-weighted voting mechanism: one account has one vote
Core protocol is intentionally minimalistic - complexity (timelocks, delayed execution, guardian roles, weighted votes, staking) must be integrated through laws
State Variables
_actions
An internal mapping of Action
structs. Its data can be accessed through the getActionCalldata
, getActionUri
and getActionNonce
getter functions.
mapping(uint256 actionId => Action) internal _actions;
_laws
An internal mapping of ActiveLaw
structs that tracks all active laws in the protocol.
mapping(uint16 lawId => ActiveLaw) internal laws;
_roles
An internal mapping of Role
structs that tracks role assignments and membership.
mapping(uint256 roleId => Role) internal roles;
_deposits
An internal mapping that tracks deposits from accounts (only covers chain native currency).
mapping(address account => Deposit[]) internal deposits;
Constants
ADMIN_ROLE
: Set totype(uint256).min
(0)PUBLIC_ROLE
: Set totype(uint256).max
DENOMINATOR
: Set to 100 (100%)
Other State Variables
name
: Name of the DAOuri
: URI to metadata of the DAO_constituteExecuted
: Boolean tracking if constitute function has been calledlawCount
: Number of laws initiated (starts at 1)
Functions
Governance Functions
request
Initiates an action to be executed through a law. Entry point for all actions in the protocol.
function request(uint16 lawId, bytes calldata lawCalldata, uint256 nonce, string memory uriAction) external payable
fulfill
Completes an action by executing the actual calls. Can only be called by an active law contract.
function fulfill(uint16 lawId, uint256 actionId, address[] calldata targets, uint256[] calldata values, bytes[] calldata calldatas) external payable
propose
Creates a new proposal for an action that requires voting. Only callable if the law requires voting (quorum > 0).
function propose(uint16 lawId, bytes calldata lawCalldata, uint256 nonce, string memory uriAction) external returns (uint256)
cancel
Cancels an existing proposal. Can only be called by the original proposer.
function cancel(uint16 lawId, bytes calldata lawCalldata, uint256 nonce) public returns (uint256)
castVote&
castVoteWithReason
&
castVoteWithReasonCasts a vote on an active proposal. Vote types: 0=Against, 1=For, 2=Abstain.
function castVote(uint256 actionId, uint8 support) external
function castVoteWithReason(uint256 actionId, uint8 support, string calldata reason) public
Role and Law Administration
constitute
Initializes the DAO by activating its founding laws. Can only be called once by an admin account.
function constitute(LawInitData[] memory constituentLaws) external
adoptLaw & revokeLaw
Activates or deactivates a law in the protocol.
function adoptLaw(LawInitData memory lawInitData) public
function revokeLaw(uint16 lawId) public
assignRole & revokeRole
Grants or removes a role from an account.
function assignRole(uint256 roleId, address account) public
function revokeRole(uint256 roleId, address account) public
labelRole
Assigns a human-readable label to a role.
function labelRole(uint256 roleId, string memory label) public
Structs
Action
Tracks a proposal's state and voting information.
struct Action {
bool cancelled;
bool requested;
bool fulfilled;
uint16 lawId;
uint48 voteStart;
uint32 voteDuration;
address caller;
uint32 againstVotes;
uint32 forVotes;
uint32 abstainVotes;
mapping(address voter => bool) hasVoted;
bytes lawCalldata;
string uri;
uint256 nonce;
}
ActiveLaw
Tracks an active law's address and status.
struct ActiveLaw {
address targetLaw;
bool active;
}
Role
Tracks role assignments and membership.
struct Role {
mapping(address account => uint48 since) members;
uint256 amountMembers;
string label;
}
Deposit
Tracks a deposit's amount and block number.
struct Deposit {
uint256 amount;
uint48 atBlock;
}
Events
Governance Events
ActionRequested
: Emitted when an executive action is requestedActionExecuted
: Emitted when an executive action has been executedProposedActionCreated
: Emitted when a proposal is createdProposedActionCancelled
: Emitted when a proposal is cancelledVoteCast
: Emitted when a vote is cast
Role and Law Events
RoleSet
: Emitted when a role is assigned or revokedRoleLabel
: Emitted when a role is labeledLawAdopted
: Emitted when a law is adoptedLawRevoked
: Emitted when a law is revokedLawRevived
: Emitted when a law is revived
Other Events
Powers__Initialized
: Emitted when protocol is initializedFundsReceived
: Emitted when protocol receives funds
Enums
ActionState
Represents the state of a proposal:
Active
Cancelled
Defeated
Succeeded
Requested
Fulfilled
NonExistent
VoteType
Supported vote types (matches Governor Bravo ordering):
Against
For
Abstain
Last updated