On chain governance smart contracts for GammaSwap protocol
This implementation is using governance smart contracts from OpenZeppelin, which are based on Compound Finance's governance model, which has become the industry standard.
GS Token holders submit proposals through GammaSwapGovernor. Proposals can only be submitted by wallets holding PROPOSAL_THRESHOLD % of GS token supply
VOTING_DELAY blocks must pass before proposal becomes active for voting
GS Token holders then vote on proposals through GammaSwapGovernor. GS token holders have the option to delegate their votes to a different wallet.
The voting period ends after VOTING_PERIOD blocks have passed.
Proposal becomes eligible for execution if at least QUORUM_PERCENTAGE % of token supply has voted.
After voting period ends GovernanceTimeLock executes proposal after MIN_DELAY seconds have passed.
Setting of all parameters (PROPOSAL_THRESHOLD, VOTING_DELAY, VOTING_PERIOD, QUORUM_PERCENTAGE) can be found in helper-hardhat-config.ts
./helper-hardhat-config.tsDeployment of smart contracts is handled with @wighawaag/hardhat-deploy
If you don't set the --tags option it will runn all deployment scripts
To deploy production smart contracts (GS, GovernanceTimeLock, GammaSwapGovernor) and run set up script, run the following
npx hardhat --network [networkName] deploy --tags prodTo deploy all smart contracts (GS, GovernanceTimeLock, GammaSwapGovernor, TestContract) and run set up script, run the following
npx hardhat --network [networkName] deploy --tags allBelow are the deployment scripts used to release the governance token, governor contract, and timelock contract which will serve to execute decentralized onchain governance
Deploys GS smart contract which will serve as GammaSwap's governance token
npx hardhat --network [networkName] deploy --tags gsDeploys GovernanceTimeLock smart contract which will execute proposals submitted by the DAO. GovernanceTimeLock is deployed with the deployer address having admin role over the GovernanceTimeLock contract.
npx hardhat --network [networkName] deploy --tags timelockDeploys GammaSwapGovernor smart contract which will create proposals and allow GS token holders to vote on such proposals, as well as count votes and queue them to be ready for execution by the GovernanceTimeLock contract.
npx hardhat --network [networkName] deploy --tags governorSets up governance contracts ready for DAO. Which means all proposals will only be made by GammaSwapGovernor and the execution of those proposals can only be made by GovernanceTimeLock. That is, it calls timeLock as the deployer (admin role) to grant the governance contract (GammaSwapGovernor) proposer role, it gives address zero executor role, which means anyone can now call the GovernanceTimeLock contract to execute approved proposals, and it revokes the deployer's address admin role on the GovernanceTimeLock contract, which means the deployer nor anyone else has control over the GovernanceTimeLock contract.
npx hardhat --network [networkName] deploy --tags setupTo run a local node, run the following
npx hardhat node --tags none