-
Notifications
You must be signed in to change notification settings - Fork 91
/
UbiquityCreditToken.sol
88 lines (77 loc) · 2.76 KB
/
UbiquityCreditToken.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
78
79
80
81
82
83
84
85
86
87
88
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;
import {ManagerFacet} from "../facets/ManagerFacet.sol";
import {ERC20Ubiquity} from "./ERC20Ubiquity.sol";
import {IERC20Ubiquity} from "../../dollar/interfaces/IERC20Ubiquity.sol";
import "../libraries/Constants.sol";
/**
* @notice Credit token contract
*/
contract UbiquityCreditToken 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 Credit", "uCR");
}
// ----------- Modifiers -----------
/// @notice Modifier checks that the method is called by a user with the "Credit minter" role
modifier onlyCreditMinter() {
require(
accessControl.hasRole(CREDIT_TOKEN_MINTER_ROLE, _msgSender()),
"Credit token: not minter"
);
_;
}
/// @notice Modifier checks that the method is called by a user with the "Credit burner" role
modifier onlyCreditBurner() {
require(
accessControl.hasRole(CREDIT_TOKEN_BURNER_ROLE, _msgSender()),
"Credit token: not burner"
);
_;
}
/**
* @notice Raises capital in the form of Ubiquity Credit Token
* @param amount Amount to be minted
* @dev CREDIT_TOKEN_MINTER_ROLE access control role is required to call this function
*/
function raiseCapital(uint256 amount) external {
address treasuryAddress = ManagerFacet(address(accessControl))
.treasuryAddress();
mint(treasuryAddress, amount);
}
/**
* @notice Burns Ubiquity Credit tokens from specified account
* @param account Account to burn from
* @param amount Amount to burn
*/
function burnFrom(
address account,
uint256 amount
) public override onlyCreditBurner whenNotPaused {
_burn(account, amount);
emit Burning(account, amount);
}
/**
* @notice Creates `amount` new Credit tokens for `to`
* @param to Account to mint Credit tokens to
* @param amount Amount of Credit tokens to mint
*/
function mint(
address to,
uint256 amount
) public onlyCreditMinter 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 {}
}