This page explains how to deploy your own DAO pool and retrieve its on-chain address for further interactions.
First, find the PoolFactory contract address on the chain you are using. Once found, simply call the PoolFactory.deployGovPool method with the appropriate parameters.
The factory under the hood uses the create2 mechanism to predict the pool address. It can be predicted either before or after the deployment itself, using the deployer's address tx.origin and the pool name poolParameters.name. With this knowledge, let's calculate the deployed GovPool address and, to see if it works, get the GovUserKeeper contract by calling the GovPool.getHelperContracts method.
Now, the only task remaining is to implement the _getPoolParameters method. This task is not trivial, so let's break it down step by step. Initially, we'll configure the proposal settings. Assuming our DAO has no validator voting, the reward token is the native currency, and proposals require 25% of the total votes for execution, the following settings should be configured. It's worth noting that constants from the listing can be imported from core/Globals.sol.
To configure GovSettings, it is necessary to match the executors to their respective settings. In this context, an executor refers to a contract called during the execution of a proposal, and each executor can have its own settings. The protocol will choose the appropriate settings based on the executors associated with the proposal. If there is more than one executor, the settings of the main executor will be considered (the last one in the list).
By default, there are three types of executor settings that must be defined: DEFAULT (for executors without specific settings), INTERNAL (for contracts such as GovPool, GovSettings, GovUserKeeper), and VALIDATORS (for the GovValidators contract). Additionally, special settings are set for an executor at the address(1337), which can represent any desired contract. For example, if the main executor is set to address(1337), a 10% quorum validator voting will be activated, unlike other executors.
Setting up GovUserKeeper is straightforward. We just need to specify the tokens with which users will vote (use the address(0) if no token is required). If the NFT is used, it should support the ERC165 standard, and individual voting power should be set unless it supports IERC721Power. If the NFT doesn't support IERC721Enumerable, the total supply of NFTs should be manually specified. Note that at least one token (tokenAddress or nftAddress) must be set. Suppose that in the listing below, address(2) is the address of the IERC721Enumerable.
Validators vote on two types of proposals within the GovValidators contract. The first type, external proposals, are moved from the GovPool to the second level of voting. The second type, internal proposals, involve changes to the GovValidators state and require special proposalSettings. Validators use a special ERC20Snapshot token that is deployed with the pool. Therefore, it is important to set the initial validator addresses and their balances to be minted.
The ERC20Gov token is also deployed with the pool and serves as a token that can be minted, burned, paused, and has a cap. Its management is handled by the DAO. Initial holders can be established. The difference between mintedTotal and amounts will be sent to the DAO. This token can also be sold in the TokenSaleProposal.
The user votes can be transformed based on specific rules set by the VotePower contract. There are two options available for deployment:
Deploy our VotePower contract, supporting one of two types of voting: LINEAR_VOTES, where the vote power equals the exact number of tokens, and POLYNOMIAL_VOTES, where the vote power is calculated using a polynomial formula. In this case, initData is expected to be passed.
Customize and deploy your own VotePower contract, then pass the presetAddress.
Let's finally consolidate all the parameters and implement the _getPoolParameters method. The parameter onlyBABTHolders indicates that only holders of Binance's SBT token can participate in the DAO.