EasyBRLStable.sol 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SPDX-License-Identifier: UNLICENSED
  2. pragma solidity ^0.8.20;
  3. import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
  4. import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
  5. import "@openzeppelin/contracts/access/AccessControl.sol";
  6. import "@openzeppelin/contracts/utils/Pausable.sol";
  7. contract EasyBRLStable is ERC20, ERC20Burnable, AccessControl, Pausable {
  8. bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
  9. bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
  10. bytes32 public constant COMPLIANCE_ROLE = keccak256("COMPLIANCE_ROLE");
  11. mapping(address => bool) private _blacklist;
  12. event BlacklistUpdated(address indexed account, bool isBlacklisted);
  13. constructor(address admin, string memory name_, string memory symbol_) ERC20(name_, symbol_) {
  14. _grantRole(DEFAULT_ADMIN_ROLE, admin);
  15. _grantRole(PAUSER_ROLE, admin);
  16. _grantRole(MINTER_ROLE, admin);
  17. _grantRole(COMPLIANCE_ROLE, admin);
  18. }
  19. function decimals() public pure override returns (uint8) {
  20. return 6;
  21. }
  22. function pause() external onlyRole(PAUSER_ROLE) {
  23. _pause();
  24. }
  25. function unpause() external onlyRole(PAUSER_ROLE) {
  26. _unpause();
  27. }
  28. function setBlacklist(address account, bool status) external onlyRole(COMPLIANCE_ROLE) {
  29. _blacklist[account] = status;
  30. emit BlacklistUpdated(account, status);
  31. }
  32. function isBlacklisted(address account) external view returns (bool) {
  33. return _blacklist[account];
  34. }
  35. function mint(address to, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
  36. _mint(to, amount);
  37. }
  38. function burn(uint256 value) public override onlyRole(DEFAULT_ADMIN_ROLE) {
  39. super.burn(value);
  40. }
  41. function burnFrom(address account, uint256 value) public override onlyRole(DEFAULT_ADMIN_ROLE) {
  42. super.burnFrom(account, value);
  43. }
  44. function _update(address from, address to, uint256 value) internal override whenNotPaused {
  45. if (from != address(0)) {
  46. require(!_blacklist[from], "Blacklisted");
  47. }
  48. if (to != address(0)) {
  49. require(!_blacklist[to], "Blacklisted");
  50. }
  51. require(!_blacklist[_msgSender()], "Blacklisted");
  52. super._update(from, to, value);
  53. }
  54. function grantComplianceRole(address account) external onlyRole(DEFAULT_ADMIN_ROLE) {
  55. _grantRole(COMPLIANCE_ROLE, account);
  56. }
  57. }