1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | 27× 14× 14× 14× 14× 14× 14× 14× 14× 14× 14× 14× 14× 14× 14× 14× 4× 4× 4× 4× 1× 184× 184× | // SPDX-License-Identifier: MIT // _____ ____ _______ ____ _ ________ _ _ // | __ \ /\ / __ \ |__ __/ __ \| |/ / ____| \ | | // | | | | / \ | | | | | | | | | | ' /| |__ | \| | // | | | |/ /\ \| | | | | | | | | | < | __| | . ` | // | |__| / ____ \ |__| | | | | |__| | . \| |____| |\ | // |_____/_/ \_\____/ |_| \____/|_|\_\______|_| \_| // // // Deployed by createDAO.org - DAO Token Implementation // GitHub: https://github.com/createdao // // 🌍 This code is free. Like speech. Like people should be. // Use it, learn from it, build with it. Share what you make. // But remember what this is for: not greed, not ego — but freedom, creativity, and unity. // // Inspired by Chaplin's call in The Great Dictator: // “You, the people, have the power — the power to create happiness!” // // So build not for domination, but for decentralization. // Not for walls, but bridges. Not for power, but empowerment. // // Licensed under the MIT License — short, sweet, and to the point. // No restrictions, no delays. Just create. Just be human. ✌️ // — Diornov pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; contract DAOToken is Initializable, ERC20Upgradeable, OwnableUpgradeable, UUPSUpgradeable { // Constants string private constant VERSION = "1.0.0"; uint16 private constant MAX_TAX = 1000; // 10% in basis points // State variables address public stakingContract; address public taxRecipient; uint16 public taxRate; // In basis points (1 = 0.01%) mapping(address => bool) public isWhitelisted; // Events event StakingContractSet(address indexed stakingContract); event TaxRateUpdated(uint16 newRate); event TaxRecipientUpdated(address indexed newRecipient); event WhitelistUpdated(address[] accounts, bool status); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize( string memory name, string memory symbol, uint256 initialSupply, address initialHolder, address treasury, address owner ) external Einitializer { __ERC20_init(name, symbol); __Ownable_init(owner); __UUPSUpgradeable_init(); Erequire(initialHolder != address(0), "Zero holder"); Erequire(treasury != address(0), "Zero treasury"); // Mint initial supply _mint(initialHolder, 1e18); // 1 token for initial holder _mint(treasury, initialSupply - 1e18); // Rest to treasury // Initialize tax settings taxRate = 0; // 1% default tax taxRecipient = treasury; // Whitelist important addresses isWhitelisted[treasury] = true; isWhitelisted[initialHolder] = true; } function setStakingContract(address _stakingContract) external EonlyOwner { Erequire(_stakingContract != address(0), "Zero staking"); stakingContract = _stakingContract; isWhitelisted[_stakingContract] = true; emit StakingContractSet(_stakingContract); } function setTaxRate(uint16 newRate) external onlyOwner { require(newRate <= MAX_TAX, "Rate > 10%"); taxRate = newRate; emit TaxRateUpdated(newRate); } function setTaxRecipient(address newRecipient) external onlyOwner { require(newRecipient != address(0), "Zero recipient"); taxRecipient = newRecipient; emit TaxRecipientUpdated(newRecipient); } function updateWhitelist(address[] calldata accounts, bool status) external EonlyOwner { for(uint i = 0; i < accounts.length; i++) { Erequire(accounts[i] != address(0), "Zero address"); isWhitelisted[accounts[i]] = status; } emit WhitelistUpdated(accounts, status); } function _authorizeUpgrade(address newImplementation) internal override EonlyOwner {} function version() external pure virtual returns (string memory) { return VERSION; } function _update( address from, address to, uint256 amount ) internal virtual override { Iif ( taxRate > 0 && // Tax is enabled !isWhitelisted[from] && // Sender not whitelisted !isWhitelisted[to] && // Recipient not whitelisted from != address(0) && // Not minting to != address(0) // Not burning ) { uint256 taxAmount = (amount * taxRate) / 10000; super._update(from, taxRecipient, taxAmount); super._update(from, to, amount - taxAmount); } else { super._update(from, to, amount); } } } |