forked from neptune-mutual-blue/protocol
-
Notifications
You must be signed in to change notification settings - Fork 1
/
POT.sol
83 lines (71 loc) · 2.64 KB
/
POT.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
// Neptune Mutual Protocol (https://neptunemutual.com)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "./NPM.sol";
import "../../interfaces/IStore.sol";
/**
* @title Proof of Authority Tokens (POTs)
*
* @dev POTs can't be used outside of the protocol
* for example in DEXes. Once NPM token is launched, it will replace POTs.
*
* For now, Neptune Mutual team and a few others will have access to POTs.
*
* POTs aren't conventional ERC-20 tokens; they can't be transferred freely;
* they don't have any value, and therefore must not be purchased or sold.
*
* Agan, POTs are distributed to individuals and companies
* who particpate in our governance and dispute management portals.
*
*/
contract POT is NPM {
IStore public immutable s;
mapping(address => bool) public whitelist;
bytes32 public constant NS_MEMBERS = "ns:members";
event WhitelistUpdated(address indexed updatedBy, address[] accounts, bool[] statuses);
constructor(address timelockOrOwner, IStore store) NPM(timelockOrOwner, "Neptune Mutual POT", "POT") {
// require(timelockOrOwner != address(0), "Invalid owner"); // Already checked in `NPM`
require(address(store) != address(0), "Invalid store");
s = store;
whitelist[address(this)] = true;
whitelist[timelockOrOwner] = true;
}
function _throwIfNotProtocolMember(address account) private view {
bytes32 key = keccak256(abi.encodePacked(NS_MEMBERS, account));
bool isMember = s.getBool(key);
// POTs can only be used within the Neptune Mutual protocol
require(isMember == true, "Access denied");
}
/**
* @dev Updates whitelisted addresses.
* Provide a list of accounts and list of statuses to add or remove from the whitelist.
*
* @custom:suppress-pausable Risk tolerable
*
*/
function updateWhitelist(address[] calldata accounts, bool[] memory statuses) external onlyOwner {
require(accounts.length > 0, "No account");
require(accounts.length == statuses.length, "Invalid args");
for (uint256 i = 0; i < accounts.length; i++) {
whitelist[accounts[i]] = statuses[i];
}
emit WhitelistUpdated(msg.sender, accounts, statuses);
}
function _beforeTokenTransfer(
address from,
address to,
uint256
) internal view override whenNotPaused {
// Token mints
if (from == address(0)) {
// aren't restricted
return;
}
// Someone not whitelisted
// ............................ can still transfer to a whitelisted address
if (whitelist[from] == false && whitelist[to] == false) {
// and to the Neptune Mutual Protocol contracts but nowhere else
_throwIfNotProtocolMember(to);
}
}
}