-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathUbiquityGovernanceToken.sol
77 lines (67 loc) · 2.44 KB
/
UbiquityGovernanceToken.sol
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
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;
import {ERC20Ubiquity} from "./ERC20Ubiquity.sol";
import {IERC20Ubiquity} from "../../dollar/interfaces/IERC20Ubiquity.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../libraries/Constants.sol";
/**
* @notice Ubiquity Governance token contract
*/
contract UbiquityGovernanceToken is ERC20Ubiquity {
/// @notice Ensures initialize cannot be called on the implementation contract
constructor() {
_disableInitializers();
}
/// @notice Initializes the contract
/// @param _manager Address of the Ubiquity Manager
function initialize(address _manager) public initializer {
// cspell: disable-next-line
__ERC20Ubiquity_init(_manager, "Ubiquity", "UBQ");
}
// ----------- Modifiers -----------
/// @notice Modifier checks that the method is called by a user with the "Governance minter" role
modifier onlyGovernanceMinter() {
require(
accessControl.hasRole(GOVERNANCE_TOKEN_MINTER_ROLE, _msgSender()),
"Governance token: not minter"
);
_;
}
/// @notice Modifier checks that the method is called by a user with the "Governance burner" role
modifier onlyGovernanceBurner() {
require(
accessControl.hasRole(GOVERNANCE_TOKEN_BURNER_ROLE, _msgSender()),
"Governance token: not burner"
);
_;
}
/**
* @notice Burns Governance tokens from the `account` address
* @param account Address to burn tokens from
* @param amount Amount of tokens to burn
*/
function burnFrom(
address account,
uint256 amount
) public override onlyGovernanceBurner whenNotPaused {
_burn(account, amount);
emit Burning(account, amount);
}
/**
* @notice Mints Governance tokens to the `to` address
* @param to Address to mint tokens to
* @param amount Amount of tokens to mint
*/
function mint(
address to,
uint256 amount
) public onlyGovernanceMinter whenNotPaused {
_mint(to, amount);
emit Minting(to, _msgSender(), amount);
}
/// @notice Allows an admin to upgrade to another implementation contract
/// @param newImplementation Address of the new implementation contract
function _authorizeUpgrade(
address newImplementation
) internal override onlyAdmin {}
}