A standard for Governance contracts that holds the administrative ownership of other smart contracts with voting power distributed as SRC-20 tokens.
Abstract
The following standard defines the implementation of a standard API for a Governance smart contract based on SRC-20. Existing SRC-173 compatible contracts can upgrade from private key wallet ownership to a Governance smart contract. Adhering to a standard API enables general tools to populate governance information of various projects, thus increasing transparency.
Motivation
Traditionally, many contracts that require that they be owned or controlled in some way use SRC-173 which standardized the use of ownership in the smart contracts. For example to withdraw funds or perform administrative actions.
contractdApp{functiondoSomethingAdministrative()externalonlyOwner{// admin logic that can be performed by a single wallet
}}
Often, such administrative rights for a contract are written for maintenance purpose but users need to trust the owner. Rescue operations by an owner have raised questions on decentralised nature of the projects. Also, there is a possibility of compromise of an owner’s private key.
At present, many governance implementations by ambitious projects need users to visit a specific UI to see governance information about their project. Some examples of live implementations having different API that does the same thing are Compound Governance, Uniswap Governance and Sushiswap Governance. It’s just like if the SRC-20 standard wasn’t finalized, then token projects would have their own block explorer. Adhering to a standard API would enable general tools (like SilaScan) to populate governance information, thus increasing transparency to users. Using widely popular SRC-20 token as a governance token, existing tools built to work with SRC-20 can already display voters. This can result in a wide adoption for contract governance over private key based ownership.
Specification
A Governance contract that is compliant with SRC-2767 shall implement the following interfaces:
/// @title SRC-2767 Governance
/// @dev SRC-165 InterfaceID: 0xd8b04e0e
interfaceSRC2767isSRC165{/// @notice Gets number votes required for achieving consensus
/// @dev Should cost less than 30000 gas
/// @return Required number of votes for achieving consensus
functionquorumVotes()externalviewreturns(uint256);/// @notice The address of the Governance SRC20 token
functiontoken()externalviewreturns(address);}
SRC-20 Governance Token
An SRC-2767 Governance Contract should reference an address through token() that implements SRC-20 interface. token() is allowed to return self address (address(this)), if SRC-20 functionalities are implemented in the same contract (one can consider checking out Diamond Standard SRC-2535 to optimise contract size).
Implementations are allowed to have varying SRC-20’s totalSupply() (through any standard of minting or burning). But having a fixed quorumVotes() return value in this case would cause required votes consensus in % with respect to totalSupply() to change. To automatically account for this, any custom logic under quorumVotes() is allowed to return for e.g. 51% of totalSupply().
SRC-165 Interface Identification
An SRC-2767 Governance Contract should also implement SRC-165. This helps general tools to identify whether a contract is a SRC-2767 Governance contract.
interfaceSRC165{/// @notice Query if a contract implements an interface
/// @param interfaceID The interface identifier, as specified in SRC-165
/// @dev Interface identification is specified in SRC-165. This function
/// uses less than 30,000 gas.
/// @return `true` if the contract implements `interfaceID` and
/// `interfaceID` is not 0xffffffff, `false` otherwise
functionsupportsInterface(bytes4interfaceID)externalviewreturns(bool);}
Rationale
The goals of this SIP have been the following:
Standardize API of Governance contracts to make it easy for analysis tools to be built.
Encourage use of SRC-20 based weighted governance over existing multi-sig (generally limited to 50 max owners) for big projects.
Encourage existing SRC-173 ownership smart contracts / projects to move to Governance based ownership by removing the effort needed to host custom UI for their project.
Encourage availability of publicly audited governance contracts, just like SRC-20 which anyone can use.
Make it possible to utilize existing SRC-20 tools for owners of governance token analysis.
Make future protocols possible that need to interact with governances of multiple projects.
Keep this SIP minimal and allow another SIPs to standardize any specific functionalities.
Backwards Compatibility
Smart contracts that are SRC-173 compliant can transfer their ownership to a Governance contract. This enables such contracts to become compatible with SRC-2767 Governance.
However, there are some existing projects with governance implementations and most of them have custom APIs (Compound Governance, Uniswap Governance and Sushiswap Governance), since a standard did not exist. Not having an SRC-2767 compatible governance contract means only that general tools might not be able to populate their governance information without including some special code for the project.
For existing governance contracts to get compatible with SRC-2767:
Projects can deploy a new governance contract and transfer ownership to it to be SRC-2767 compatible. This is suitable for those who use Multi-sig wallets for Governance.
It is understood that redeploying governance contracts would be a troublesome task, and contracts who already have functionality similar to SRC-20 based (weighted votes) have a bit advanced way to avoid it. Basically, they can create a forwarder contract implements SRC-2767 and forwards all calls to the actual non-standard methods. Projects can list the forwarder contract to display the information project’s governance info without requiring any custom code in analysys tool, but this might have certain limitations depending on the project’s existing governance implementation. Specification of forwarder contract is out of scope for this SIP and it may be addressed in another SIP if required.
Implementation
The reference implementations are available in this repository. Publicly audited implementations will be included in future.
Security Considerations
Implementers are free to choose between On-chain and Off-chain consensus. Exact specification is out of scope for this standard (open for other SIPs to standardize). However, this section mentions points that implementers can consider.
On-chain
In such implementations, community can create transaction proposals and vote on it by sending on-chain transactions.
OpenZeppelin Snapshots can be used to prevent double voting.
Off-chain
The signatures in off-chain governance implementation can follow recommendations of SRC-191 or SRC-712.
To prevent replaying signatures, it’d be best if executer is required to sort the signatures based on increasing addresses.