Source: contracts/DAO.sol (Note: Update link if necessary)
Inherits: DAOProposals, DAOExecutor

The DAO.sol contract is the core implementation logic for a DAO deployed via the DAOFactory. It acts as the central governance hub, orchestrating proposal creation, voting, and execution. It does not hold funds directly but controls the associated DAOTreasury, DAOStaking, and DAOToken contracts. This contract is intended to be used behind a DAOProxy.

Key Concepts

  • Governance Engine: Combines proposal lifecycle management (from DAOProposals) and execution logic (from DAOExecutor).
  • State Management: Uses ERC-7201 namespaced storage (CoreStorage, ProposalStorage) inherited from its parent contracts to manage DAO settings (name, voting period, quorum, etc.) and proposal data.
  • Module References: Stores the addresses of the DAO’s specific Token, Treasury, and Staking contract proxies.
  • Upgradeability: Implements the UUPS pattern. Upgrades are authorized only via successful governance proposals (proposeUpgrade) executed through the execute function, or directly by the owner during initial setup (before ownership is transferred to the DAO itself).

Initialization

The DAO implementation is initialized via its proxy by the DAOFactory during the createDAO process.

function initialize(
    string memory _name,
    address _treasury,
    address _stakingContract,
    address _token,
    address _factory
) external initializer;
  • Sets the DAO’s name and references to the factory and associated module contracts.
  • Initializes default governance parameters (e.g., votingPeriod, minProposalStake, quorum). These can be changed later via governance proposals (if such proposal types are implemented).
  • Initializes Ownable and UUPSUpgradeable components. Ownership is initially set to the factory and then transferred to the DAO proxy address itself upon successful deployment completion in the factory.

Key Functions

The DAO.sol contract itself primarily serves as the container. Most user-facing functions are inherited from DAOProposals and DAOExecutor.

Events

The DAO contract inherits and utilizes events defined in DAOEvents.sol (via its parent contracts) to signal significant actions:

  • ProposalCreated
  • Voted
  • ProposalExecuted
  • DAOPaused / DAOUnpaused
  • TransferProposalCreated, UpgradeProposalCreated, etc. (Specific proposal type events)
  • TransferExecuted, UpgradeExecuted, etc. (Specific execution events)

Upgradeability

Upgrades to the DAO logic are handled via the proposeUpgrade governance proposal type. When such a proposal is executed, the _executeUpgrade function within DAOExecutor calls upgradeToAndCall on the DAOProxy address, pointing it to the new DAO.sol implementation address specified in the proposal (which must match an implementation registered in the DAOFactory). The _authorizeUpgrade function ensures this can only happen during the execution of a valid proposal.