Pixel Vault NFT Governance Audit#
The git commit hash used for the audit is
- Zac Denham
Audit report reviewed by Nick Mudge.
The Pixel Vault NFT governance contracts enable any ERC721 NFT to be used as an opt-in governance token. This could allow for new forms of utility and coordination amongst NFT holders.
It works by implementing a wrapper token called the "Community Token." End users can lock their NFT in the contract in exchange for a community token that corresponds to one governance vote. This vote can be delegated to another address for representation. Community tokens are not tradable on secondary markets (transfers are disabled).
The CommunityToken code makes use of inheritance to modularize functionality. It is broken up into the following main contracts, with each inheriting the previous:
CommunityTokenwhich is based on ERC721
ERC721Wrapperwhich handles receiving and disbursing the root token NFT in exchange for community tokens
ERC721WrapperVoteswhich adds checkpointing for historical vote balances as well as delegation functionality
The governance itself is based on Compound's popular "Governor Bravo" contract. More detailed documentation on compound governance can be found here.
One notable governance gas optimization is that not all "Ballots" are stored on chain. Only the vote totals are accounted for, and whether a user has voted on a given proposal is packed into one bit at a position that corresponds to the user's "community id". This optimization reduces the number of "cold" storage slots that need to be updated in order to vote, in the happy case only requiring one slot to be updated. This effectively decreases the gas cost to vote, which might in turn incentivize voter participation.
The quorum mechanic also differs from Compound in that it is dynamically calculated so as to account for fluctuating supply of community tokens vs. Compound which uses a fixed immutable number.
Similar to the community token, governance uses inheritance:
Governor- based on Compound governance, handles the proposal and voting lifecycle
PFVDGovernor- adds dynamic quorum functionality based on community token totalSupply
This audit is an assessment of the Pixel Vault NFT governance system.
- Find bugs, inefficiencies and security vulnerabilities in the code base.
- Make recommendations concerning bugs, inefficiencies and security vulnerabilities found as well as other recommendations that may improve the code base.
The following files were audited: