links daoø

protocols daoø

open source daoø


      // SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/* ===================== IMPORTS ===================== */
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Votes.sol";
import "@openzeppelin/contracts/governance/Governor.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotes.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorTimelockControl.sol";
import "@openzeppelin/contracts/governance/TimelockController.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/* ===================== TOKEN ===================== */
contract DAOØToken is ERC20Votes, Ownable {
    constructor()
        ERC20("DAOØ Token", "DAOØ")
        ERC20Permit("DAOØ Token")
    {
        _mint(msg.sender, 1_000_000 ether);
    }

    function _update(
        address from,
        address to,
        uint256 amount
    ) internal override(ERC20, ERC20Votes) {
        super._update(from, to, amount);
    }

    function nonces(address owner)
        public
        view
        override(ERC20Permit)
        returns (uint256)
    {
        return super.nonces(owner);
    }
}

/* ===================== TREASURY ===================== */
contract DAOØTreasury {
    address public governor;

    constructor(address _governor) {
        governor = _governor;
    }

    modifier onlyGovernor() {
        require(msg.sender == governor, "ONLY_GOVERNOR");
        _;
    }

    receive() external payable {}

    function execute(
        address to,
        uint256 value,
        bytes calldata data
    ) external onlyGovernor {
        (bool ok, ) = to.call{value: value}(data);
        require(ok, "TX_FAILED");
    }
}

/* ===================== GOVERNANCE ===================== */
contract DAOØGovernor is
    Governor,
    GovernorVotes,
    GovernorVotesQuorumFraction,
    GovernorTimelockControl
{
    constructor(
        IVotes token,
        TimelockController timelock
    )
        Governor("DAOØ Governor")
        GovernorVotes(token)
        GovernorVotesQuorumFraction(4) // 4% quorum
        GovernorTimelockControl(timelock)
    {}

    /* -------- DAO params -------- */

    function votingDelay() public pure override returns (uint256) {
        return 1; // 1 block
    }

    function votingPeriod() public pure override returns (uint256) {
        return 45_818; // ~1 day on Base
    }

    function proposalThreshold() public pure override returns (uint256) {
        return 1_000 ether;
    }

    /* -------- overrides -------- */

    function state(uint256 proposalId)
        public
        view
        override(Governor, GovernorTimelockControl)
        returns (ProposalState)
    {
        return super.state(proposalId);
    }

    function _execute(
        uint256 proposalId,
        address[] memory targets,
        uint256[] memory values,
        bytes[] memory calldatas,
        bytes32 descriptionHash
    )
        internal
        override(Governor, GovernorTimelockControl)
    {
        super._execute(proposalId, targets, values, calldatas, descriptionHash);
    }

    function _cancel(
        address[] memory targets,
        uint256[] memory values,
        bytes[] memory calldatas,
        bytes32 descriptionHash
    )
        internal
        override(Governor, GovernorTimelockControl)
        returns (uint256)
    {
        return super._cancel(targets, values, calldatas, descriptionHash);
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(Governor, GovernorTimelockControl)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }
}
home