-
Notifications
You must be signed in to change notification settings - Fork 3
/
SygnumToken.sol
169 lines (156 loc) · 6.3 KB
/
SygnumToken.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/**
* @title SygnumToken
* @author Team 3301 <team3301@sygnum.com>
* @notice ERC20 token with additional features.
*/
pragma solidity 0.5.12;
import "./ERC20/ERC20SygnumDetailed.sol";
import "@sygnum/solidity-base-contracts/contracts/helpers/ERC20/ERC20Whitelist.sol";
import "@sygnum/solidity-base-contracts/contracts/helpers/ERC20/ERC20Pausable.sol";
import "@sygnum/solidity-base-contracts/contracts/helpers/ERC20/ERC20Mintable.sol";
import "@sygnum/solidity-base-contracts/contracts/helpers/ERC20/ERC20Burnable.sol";
import "@sygnum/solidity-base-contracts/contracts/helpers/ERC20/ERC20Freezable.sol";
import "@sygnum/solidity-base-contracts/contracts/helpers/ERC20/ERC20Destroyable.sol";
import "@sygnum/solidity-base-contracts/contracts/helpers/ERC20/ERC20Snapshot.sol";
import "@sygnum/solidity-base-contracts/contracts/helpers/ERC20/ERC20Tradeable.sol";
import "@sygnum/solidity-base-contracts/contracts/helpers/ERC20/ERC20Blockable.sol";
contract SygnumToken is
ERC20Snapshot,
ERC20SygnumDetailed,
ERC20Pausable,
ERC20Mintable,
ERC20Whitelist,
ERC20Tradeable,
ERC20Blockable,
ERC20Burnable,
ERC20Freezable,
ERC20Destroyable
{
event Minted(address indexed minter, address indexed account, uint256 value);
event Burned(address indexed burner, uint256 value);
event BurnedFor(address indexed burner, address indexed account, uint256 value);
event Confiscated(address indexed account, uint256 amount, address indexed receiver);
uint16 internal constant BATCH_LIMIT = 256;
/**
* @dev Initialize contracts.
* @param _baseOperators Base operators contract address.
* @param _whitelist Whitelist contract address.
* @param _traderOperators Trader operators contract address.
* @param _blockerOperators Blocker operators contract address.
*/
function initializeContractsAndConstructor(
string memory _name,
string memory _symbol,
uint8 _decimals,
bytes4 _category,
string memory _class,
address _issuer,
address _baseOperators,
address _whitelist,
address _traderOperators,
address _blockerOperators
) public initializer {
super.initialize(_baseOperators);
_setWhitelistContract(_whitelist);
_setTraderOperatorsContract(_traderOperators);
_setBlockerOperatorsContract(_blockerOperators);
_setDetails(_name, _symbol, _decimals, _category, _class, _issuer);
}
/**
* @dev Burn.
* @param _amount Amount of tokens to burn.
*/
function burn(uint256 _amount) public {
require(!isFrozen(msg.sender), "SygnumToken: Account must not be frozen.");
super._burn(msg.sender, _amount);
emit Burned(msg.sender, _amount);
}
/**
* @dev BurnFor.
* @param _account Address to burn tokens for.
* @param _amount Amount of tokens to burn.
*/
function burnFor(address _account, uint256 _amount) public {
super._burnFor(_account, _amount);
emit BurnedFor(msg.sender, _account, _amount);
}
/**
* @dev BurnFrom.
* @param _account Address to burn tokens from.
* @param _amount Amount of tokens to burn.
*/
function burnFrom(address _account, uint256 _amount) public {
super._burnFrom(_account, _amount);
emit Burned(_account, _amount);
}
/**
* @dev Mint.
* @param _account Address to mint tokens to.
* @param _amount Amount to mint.
*/
function mint(address _account, uint256 _amount) public {
if (isSystem(msg.sender)) {
require(!isFrozen(_account), "SygnumToken: Account must not be frozen if system calling.");
}
super._mint(_account, _amount);
emit Minted(msg.sender, _account, _amount);
}
/**
* @dev Confiscate.
* @param _confiscatee Account to confiscate funds from.
* @param _receiver Account to transfer confiscated funds to.
* @param _amount Amount of tokens to confiscate.
*/
function confiscate(
address _confiscatee,
address _receiver,
uint256 _amount
) public onlyOperator whenNotPaused whenWhitelisted(_receiver) whenWhitelisted(_confiscatee) {
super._confiscate(_confiscatee, _receiver, _amount);
emit Confiscated(_confiscatee, _amount, _receiver);
}
/**
* @dev Batch burn for.
* @param _amounts Array of all values to burn.
* @param _accounts Array of all addresses to burn from.
*/
function batchBurnFor(address[] memory _accounts, uint256[] memory _amounts) public {
require(_accounts.length == _amounts.length, "SygnumToken: values and recipients are not equal.");
require(_accounts.length <= BATCH_LIMIT, "SygnumToken: batch count is greater than BATCH_LIMIT.");
for (uint256 i = 0; i < _accounts.length; i++) {
burnFor(_accounts[i], _amounts[i]);
}
}
/**
* @dev Batch mint.
* @param _accounts Array of all addresses to mint to.
* @param _amounts Array of all values to mint.
*/
function batchMint(address[] memory _accounts, uint256[] memory _amounts) public {
require(_accounts.length == _amounts.length, "SygnumToken: values and recipients are not equal.");
require(_accounts.length <= BATCH_LIMIT, "SygnumToken: batch count is greater than BATCH_LIMIT.");
for (uint256 i = 0; i < _accounts.length; i++) {
mint(_accounts[i], _amounts[i]);
}
}
/**
* @dev Batch confiscate to a maximum of 256 addresses.
* @param _confiscatees array of addresses whose funds are being confiscated
* @param _receivers array of addresses who's receiving the funds
* @param _values array of values of funds being confiscated
*/
function batchConfiscate(
address[] memory _confiscatees,
address[] memory _receivers,
uint256[] memory _values
) public returns (bool) {
require(
_confiscatees.length == _values.length && _receivers.length == _values.length,
"SygnumToken: confiscatees, recipients and values are not equal."
);
require(_confiscatees.length <= BATCH_LIMIT, "SygnumToken: batch count is greater than BATCH_LIMIT.");
for (uint256 i = 0; i < _confiscatees.length; i++) {
confiscate(_confiscatees[i], _receivers[i], _values[i]);
}
}
}