-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathNPM.sol
More file actions
75 lines (61 loc) · 2.18 KB
/
NPM.sol
File metadata and controls
75 lines (61 loc) · 2.18 KB
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
// Neptune Mutual Protocol (https://neptunemutual.com)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "./WithRecovery.sol";
import "./WithPausability.sol";
contract NPM is WithPausability, WithRecovery, ERC20 {
uint256 private constant _CAP = 1_000_000_000 ether;
uint256 private _issued = 0;
event Minted(bytes32 indexed key, address indexed account, uint256 amount);
constructor(
address timelockOrOwner,
string memory tokenName,
string memory tokenSymbol
) Ownable() Pausable() ERC20(tokenName, tokenSymbol) {
require(timelockOrOwner != address(0), "Invalid owner");
require(bytes(tokenName).length > 0, "Invalid token name");
require(bytes(tokenSymbol).length > 0, "Invalid token symbol");
super._transferOwnership(timelockOrOwner);
}
// slither-disable-next-line dead-code
function _beforeTokenTransfer(
address,
address,
uint256
) internal view virtual override whenNotPaused {} // solhint-disable-line
function issueMany(
bytes32 key,
address[] calldata receivers,
uint256[] calldata amounts
) external onlyOwner whenNotPaused {
require(receivers.length > 0, "No receiver");
require(receivers.length == amounts.length, "Invalid args");
_issued += _sumOf(amounts);
require(_issued <= _CAP, "Cap exceeded");
for (uint256 i = 0; i < receivers.length; i++) {
_issue(key, receivers[i], amounts[i]);
}
}
function transferMany(address[] calldata receivers, uint256[] calldata amounts) external onlyOwner whenNotPaused {
require(receivers.length > 0, "No receiver");
require(receivers.length == amounts.length, "Invalid args");
for (uint256 i = 0; i < receivers.length; i++) {
super.transfer(receivers[i], amounts[i]);
}
}
function _issue(
bytes32 key,
address mintTo,
uint256 amount
) private {
require(amount > 0, "Invalid amount");
super._mint(mintTo, amount);
emit Minted(key, mintTo, amount);
}
function _sumOf(uint256[] calldata amounts) private pure returns (uint256 total) {
for (uint256 i = 0; i < amounts.length; i++) {
total += amounts[i];
}
}
}