Vote Splitter lets users 'rent out' their votes for Governor Alpha (Compound-style) governances.
Voter Splitter lets owners of on-chain governance tokens temporarily transfer their voting power to someone else.
How it works:
CONTRACT:
createVault(uint256 amount)
- locks amount
of underlying governance tokens in a vote vault. Caller receives amount
of wrapped governance tokens and an NFT that represents the vault.
closeOwnVault(uint vaultId)
- the owner of the given vault can close their vault by redeeming enough wrapped tokens to cover the balance of the tokens locked in the vault.
closeExpiredVault(uint vaultId)
- anyone can close an expired vault by redeeming enough wrapped tokens to cover the balance of the tokens locked in the vault.
VAULT:
vote(uint proposalId, bool support)
- votes yea/nay on the given proposalId
on the underlying governance.
delegate(address delegatee)
- delegate to someone on the underlying governance, with vote weight equal to the locked tokens.
also implements ERC721 functions such as transferFrom(address from, address to, uint256 tokenId)
WRAPPED TOKEN:
implements ERC20 functions such as transfer(address recipient, uint256 amount)
The vault owner can call closeOwnVault()
if they have enough wrapped governance tokens to cover the underlying tokens in the vault. Closing the vault redeems the wrapped tokens for the underlying tokens.
Every 50000 blocks, all vaults expire. Anyone can call closeExpiredVault()
on an expired vault if they have enough wrapped governance tokens. Closing the vault redeems the wrapped tokens for the underlying tokens.
VoteSplitter is built with some fantastic tools! We've been doing hackathons for years now, and we're always impressed how quickly the development tools improve.
SMART CONTRACT LAYER:
We built the smart contracts in Soldity.
We used @openzeppelin/contracts library for things like ERC20 and ERC721 contracts.
We use hardhat for building and compiling the contracts
Typechain! We're glad that we can use typescript for writing our unit tests instead of javascript.
Waffle for writing smart contract tests
WEB3 FRONTEND
We built a React frontend with chakra UI components for users to communicate with the on-chain contracts
We use ethers to send transactions to the blockchain
The app also uses eth-hooks for some helper methods for reading data from the contracts.