@ensuro/core 2.0.0-beta6 → 2.0.0-beta8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/build/contracts/AccessManager.sol/AccessManager.json +74 -2
  2. package/build/contracts/ERC4626AssetManager.sol/ERC4626AssetManager.json +213 -0
  3. package/build/contracts/EToken.sol/EToken.json +114 -45
  4. package/build/contracts/LPManualWhitelist.sol/LPManualWhitelist.json +2 -2
  5. package/build/contracts/LiquidityThresholdAssetManager.sol/LiquidityThresholdAssetManager.json +197 -0
  6. package/build/contracts/Policy.sol/Policy.json +2 -2
  7. package/build/contracts/PolicyPool.sol/PolicyPool.json +324 -100
  8. package/build/contracts/PremiumsAccount.sol/PremiumsAccount.json +122 -2
  9. package/build/contracts/Reserve.sol/Reserve.json +71 -0
  10. package/build/contracts/TrustfulRiskModule.sol/TrustfulRiskModule.json +3 -3
  11. package/build/contracts/interfaces/IAccessManager.sol/IAccessManager.json +96 -0
  12. package/build/contracts/interfaces/IAssetManager.sol/IAssetManager.json +103 -0
  13. package/build/contracts/interfaces/IEToken.sol/IEToken.json +13 -0
  14. package/build/contracts/interfaces/IPolicyPool.sol/IPolicyPool.json +6 -14
  15. package/build/contracts/interfaces/IPremiumsAccount.sol/IPremiumsAccount.json +13 -0
  16. package/build/contracts/mocks/FixedRateVault.sol/FixedRateVault.json +736 -0
  17. package/build/contracts/mocks/PolicyPoolComponentMock.sol/PolicyPoolComponentMock.json +2 -2
  18. package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMock.json +7 -15
  19. package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMockForward.json +2 -2
  20. package/build/contracts/mocks/RiskModuleMock.sol/RiskModuleMock.json +674 -0
  21. package/contracts/AccessManager.sol +39 -8
  22. package/contracts/ERC4626AssetManager.sol +49 -0
  23. package/contracts/EToken.sol +72 -52
  24. package/contracts/LiquidityThresholdAssetManager.sol +159 -0
  25. package/contracts/PolicyPool.sol +155 -135
  26. package/contracts/PolicyPoolComponent.sol +29 -19
  27. package/contracts/PremiumsAccount.sol +125 -62
  28. package/contracts/Reserve.sol +86 -2
  29. package/contracts/RiskModule.sol +17 -6
  30. package/contracts/TrustfulRiskModule.sol +17 -2
  31. package/contracts/interfaces/IAccessManager.sol +23 -5
  32. package/contracts/interfaces/IAssetManager.sol +22 -0
  33. package/contracts/interfaces/IEToken.sol +21 -1
  34. package/contracts/interfaces/IPolicyPool.sol +6 -11
  35. package/contracts/interfaces/IPremiumsAccount.sol +5 -0
  36. package/contracts/mocks/FixedRateVault.sol +85 -0
  37. package/contracts/mocks/PolicyPoolMock.sol +2 -5
  38. package/contracts/mocks/RiskModuleMock.sol +69 -0
  39. package/js/test-utils.js +35 -26
  40. package/package.json +1 -1
  41. package/build/contracts/PolicyNFT.sol/PolicyNFT.json +0 -583
  42. package/build/contracts/interfaces/IPolicyNFT.sol/IPolicyNFT.json +0 -321
  43. package/contracts/PolicyNFT.sol +0 -96
  44. package/contracts/interfaces/IPolicyNFT.sol +0 -15
@@ -1,321 +0,0 @@
1
- {
2
- "_format": "hh-sol-artifact-1",
3
- "contractName": "IPolicyNFT",
4
- "sourceName": "contracts/interfaces/IPolicyNFT.sol",
5
- "abi": [
6
- {
7
- "anonymous": false,
8
- "inputs": [
9
- {
10
- "indexed": true,
11
- "internalType": "address",
12
- "name": "owner",
13
- "type": "address"
14
- },
15
- {
16
- "indexed": true,
17
- "internalType": "address",
18
- "name": "approved",
19
- "type": "address"
20
- },
21
- {
22
- "indexed": true,
23
- "internalType": "uint256",
24
- "name": "tokenId",
25
- "type": "uint256"
26
- }
27
- ],
28
- "name": "Approval",
29
- "type": "event"
30
- },
31
- {
32
- "anonymous": false,
33
- "inputs": [
34
- {
35
- "indexed": true,
36
- "internalType": "address",
37
- "name": "owner",
38
- "type": "address"
39
- },
40
- {
41
- "indexed": true,
42
- "internalType": "address",
43
- "name": "operator",
44
- "type": "address"
45
- },
46
- {
47
- "indexed": false,
48
- "internalType": "bool",
49
- "name": "approved",
50
- "type": "bool"
51
- }
52
- ],
53
- "name": "ApprovalForAll",
54
- "type": "event"
55
- },
56
- {
57
- "anonymous": false,
58
- "inputs": [
59
- {
60
- "indexed": true,
61
- "internalType": "address",
62
- "name": "from",
63
- "type": "address"
64
- },
65
- {
66
- "indexed": true,
67
- "internalType": "address",
68
- "name": "to",
69
- "type": "address"
70
- },
71
- {
72
- "indexed": true,
73
- "internalType": "uint256",
74
- "name": "tokenId",
75
- "type": "uint256"
76
- }
77
- ],
78
- "name": "Transfer",
79
- "type": "event"
80
- },
81
- {
82
- "inputs": [
83
- {
84
- "internalType": "address",
85
- "name": "to",
86
- "type": "address"
87
- },
88
- {
89
- "internalType": "uint256",
90
- "name": "tokenId",
91
- "type": "uint256"
92
- }
93
- ],
94
- "name": "approve",
95
- "outputs": [],
96
- "stateMutability": "nonpayable",
97
- "type": "function"
98
- },
99
- {
100
- "inputs": [
101
- {
102
- "internalType": "address",
103
- "name": "owner",
104
- "type": "address"
105
- }
106
- ],
107
- "name": "balanceOf",
108
- "outputs": [
109
- {
110
- "internalType": "uint256",
111
- "name": "balance",
112
- "type": "uint256"
113
- }
114
- ],
115
- "stateMutability": "view",
116
- "type": "function"
117
- },
118
- {
119
- "inputs": [],
120
- "name": "connect",
121
- "outputs": [],
122
- "stateMutability": "nonpayable",
123
- "type": "function"
124
- },
125
- {
126
- "inputs": [
127
- {
128
- "internalType": "uint256",
129
- "name": "tokenId",
130
- "type": "uint256"
131
- }
132
- ],
133
- "name": "getApproved",
134
- "outputs": [
135
- {
136
- "internalType": "address",
137
- "name": "operator",
138
- "type": "address"
139
- }
140
- ],
141
- "stateMutability": "view",
142
- "type": "function"
143
- },
144
- {
145
- "inputs": [
146
- {
147
- "internalType": "address",
148
- "name": "owner",
149
- "type": "address"
150
- },
151
- {
152
- "internalType": "address",
153
- "name": "operator",
154
- "type": "address"
155
- }
156
- ],
157
- "name": "isApprovedForAll",
158
- "outputs": [
159
- {
160
- "internalType": "bool",
161
- "name": "",
162
- "type": "bool"
163
- }
164
- ],
165
- "stateMutability": "view",
166
- "type": "function"
167
- },
168
- {
169
- "inputs": [
170
- {
171
- "internalType": "uint256",
172
- "name": "tokenId",
173
- "type": "uint256"
174
- }
175
- ],
176
- "name": "ownerOf",
177
- "outputs": [
178
- {
179
- "internalType": "address",
180
- "name": "owner",
181
- "type": "address"
182
- }
183
- ],
184
- "stateMutability": "view",
185
- "type": "function"
186
- },
187
- {
188
- "inputs": [
189
- {
190
- "internalType": "address",
191
- "name": "to",
192
- "type": "address"
193
- },
194
- {
195
- "internalType": "uint256",
196
- "name": "policyId",
197
- "type": "uint256"
198
- }
199
- ],
200
- "name": "safeMint",
201
- "outputs": [],
202
- "stateMutability": "nonpayable",
203
- "type": "function"
204
- },
205
- {
206
- "inputs": [
207
- {
208
- "internalType": "address",
209
- "name": "from",
210
- "type": "address"
211
- },
212
- {
213
- "internalType": "address",
214
- "name": "to",
215
- "type": "address"
216
- },
217
- {
218
- "internalType": "uint256",
219
- "name": "tokenId",
220
- "type": "uint256"
221
- }
222
- ],
223
- "name": "safeTransferFrom",
224
- "outputs": [],
225
- "stateMutability": "nonpayable",
226
- "type": "function"
227
- },
228
- {
229
- "inputs": [
230
- {
231
- "internalType": "address",
232
- "name": "from",
233
- "type": "address"
234
- },
235
- {
236
- "internalType": "address",
237
- "name": "to",
238
- "type": "address"
239
- },
240
- {
241
- "internalType": "uint256",
242
- "name": "tokenId",
243
- "type": "uint256"
244
- },
245
- {
246
- "internalType": "bytes",
247
- "name": "data",
248
- "type": "bytes"
249
- }
250
- ],
251
- "name": "safeTransferFrom",
252
- "outputs": [],
253
- "stateMutability": "nonpayable",
254
- "type": "function"
255
- },
256
- {
257
- "inputs": [
258
- {
259
- "internalType": "address",
260
- "name": "operator",
261
- "type": "address"
262
- },
263
- {
264
- "internalType": "bool",
265
- "name": "_approved",
266
- "type": "bool"
267
- }
268
- ],
269
- "name": "setApprovalForAll",
270
- "outputs": [],
271
- "stateMutability": "nonpayable",
272
- "type": "function"
273
- },
274
- {
275
- "inputs": [
276
- {
277
- "internalType": "bytes4",
278
- "name": "interfaceId",
279
- "type": "bytes4"
280
- }
281
- ],
282
- "name": "supportsInterface",
283
- "outputs": [
284
- {
285
- "internalType": "bool",
286
- "name": "",
287
- "type": "bool"
288
- }
289
- ],
290
- "stateMutability": "view",
291
- "type": "function"
292
- },
293
- {
294
- "inputs": [
295
- {
296
- "internalType": "address",
297
- "name": "from",
298
- "type": "address"
299
- },
300
- {
301
- "internalType": "address",
302
- "name": "to",
303
- "type": "address"
304
- },
305
- {
306
- "internalType": "uint256",
307
- "name": "tokenId",
308
- "type": "uint256"
309
- }
310
- ],
311
- "name": "transferFrom",
312
- "outputs": [],
313
- "stateMutability": "nonpayable",
314
- "type": "function"
315
- }
316
- ],
317
- "bytecode": "0x",
318
- "deployedBytecode": "0x",
319
- "linkReferences": {},
320
- "deployedLinkReferences": {}
321
- }
@@ -1,96 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.2;
3
-
4
- import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
5
- import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
6
- import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
7
- import {IPolicyPool} from "./interfaces/IPolicyPool.sol";
8
- import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
9
- import {IPolicyNFT} from "./interfaces/IPolicyNFT.sol";
10
-
11
- /**
12
- * @title PolicyNFT - NFT that keeps track of issued policies and its owners
13
- * @dev Every time a new policy is accepted by the PolicyPool, a new NFT is minted generating a new
14
- * policyId owned by the customer. Only the PolicyPool can mint NFTs.
15
- * After creation, NFTs can be transferred in the ERC721 standard way and that changes the policy holder.
16
- * @custom:security-contact security@ensuro.co
17
- * @author Ensuro
18
- */
19
- contract PolicyNFT is UUPSUpgradeable, ERC721Upgradeable, PausableUpgradeable, IPolicyNFT {
20
- bytes32 public constant GUARDIAN_ROLE = keccak256("GUARDIAN_ROLE");
21
- bytes32 public constant LEVEL1_ROLE = keccak256("LEVEL1_ROLE");
22
-
23
- IPolicyPool internal _policyPool;
24
-
25
- modifier onlyPolicyPool() {
26
- require(_msgSender() == address(_policyPool), "The caller must be the PolicyPool");
27
- _;
28
- }
29
-
30
- modifier onlyPoolRole2(bytes32 role1, bytes32 role2) {
31
- _policyPool.access().checkRole2(role1, role2, msg.sender);
32
- _;
33
- }
34
-
35
- modifier onlyPoolRole(bytes32 role) {
36
- _policyPool.access().checkRole(role, msg.sender);
37
- _;
38
- }
39
-
40
- function initialize(
41
- string memory name_,
42
- string memory symbol_,
43
- IPolicyPool policyPool_
44
- ) public initializer {
45
- __UUPSUpgradeable_init();
46
- __Pausable_init();
47
- __ERC721_init(name_, symbol_);
48
- __PolicyNFT_init_unchained(policyPool_);
49
- }
50
-
51
- // solhint-disable-next-line func-name-mixedcase
52
- function __PolicyNFT_init_unchained(IPolicyPool policyPool_) internal initializer {
53
- _policyPool = policyPool_;
54
- }
55
-
56
- // solhint-disable-next-line no-empty-blocks
57
- function _authorizeUpgrade(address) internal override onlyPoolRole2(GUARDIAN_ROLE, LEVEL1_ROLE) {}
58
-
59
- function pause() public onlyPoolRole(GUARDIAN_ROLE) {
60
- _pause();
61
- }
62
-
63
- function unpause() public onlyPoolRole2(GUARDIAN_ROLE, LEVEL1_ROLE) {
64
- _unpause();
65
- }
66
-
67
- /**
68
- * @dev This function can be called only once in contract's lifetime. It links the NFT with the
69
- * PolicyPool contract. It's called in PolicyPool initialization.
70
- */
71
- function connect() external override {
72
- require(
73
- address(_policyPool) == address(0) || address(_policyPool) == _msgSender(),
74
- "PolicyPool already connected"
75
- );
76
- _policyPool = IPolicyPool(_msgSender());
77
- // Not possible to do this validation because connect is called in _policyPool initialize :'(
78
- // require(_policyPool.policyNFT() == address(this), "PolicyPool not connected to this access");
79
- }
80
-
81
- function policyPool() external view returns (IPolicyPool) {
82
- return _policyPool;
83
- }
84
-
85
- function safeMint(address to, uint256 policyId) external override onlyPolicyPool whenNotPaused {
86
- _safeMint(to, policyId, "");
87
- }
88
-
89
- function _beforeTokenTransfer(
90
- address from,
91
- address to,
92
- uint256 tokenId
93
- ) internal override whenNotPaused {
94
- super._beforeTokenTransfer(from, to, tokenId);
95
- }
96
- }
@@ -1,15 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.0;
3
-
4
- import {IERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
5
-
6
- /**
7
- * @title IPolicyNFT interface
8
- * @dev Interface for mintable NFT token that returns tokenId
9
- * @author Ensuro
10
- */
11
- interface IPolicyNFT is IERC721Upgradeable {
12
- function safeMint(address to, uint256 policyId) external;
13
-
14
- function connect() external;
15
- }