@ensuro/core 2.0.0-beta8 → 2.0.0

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 (65) hide show
  1. package/README.md +31 -14
  2. package/build/contracts/AccessManager.sol/AccessManager.json +7 -2
  3. package/build/contracts/ERC4626AssetManager.sol/ERC4626AssetManager.json +28 -3
  4. package/build/contracts/EToken.sol/EToken.json +21 -15
  5. package/build/contracts/LPManualWhitelist.sol/LPManualWhitelist.json +21 -2
  6. package/build/contracts/LiquidityThresholdAssetManager.sol/LiquidityThresholdAssetManager.json +26 -1
  7. package/build/contracts/Policy.sol/Policy.json +2 -2
  8. package/build/contracts/PolicyPool.sol/PolicyPool.json +40 -2
  9. package/build/contracts/PolicyPoolComponent.sol/PolicyPoolComponent.json +19 -0
  10. package/build/contracts/PremiumsAccount.sol/PremiumsAccount.json +21 -15
  11. package/build/contracts/Reserve.sol/Reserve.json +19 -13
  12. package/build/contracts/RiskModule.sol/RiskModule.json +19 -0
  13. package/build/contracts/SignedQuoteRiskModule.sol/SignedQuoteRiskModule.json +1110 -0
  14. package/build/contracts/TimeScaled.sol/TimeScaled.json +3 -17
  15. package/build/contracts/TrustfulRiskModule.sol/TrustfulRiskModule.json +137 -2
  16. package/build/contracts/{WadRayMath.sol → dependencies/WadRayMath.sol}/WadRayMath.json +3 -3
  17. package/build/contracts/interfaces/IAssetManager.sol/IAssetManager.json +26 -1
  18. package/build/contracts/interfaces/IPolicyPool.sol/IPolicyPool.json +38 -0
  19. package/build/contracts/interfaces/IPolicyPoolComponent.sol/IPolicyPoolComponent.json +19 -0
  20. package/build/contracts/mocks/FixedRateVault.sol/FixedRateVault.json +2 -2
  21. package/build/contracts/mocks/ForwardProxy.sol/ForwardProxy.json +2 -2
  22. package/build/contracts/mocks/InterfaceIdCalculator.sol/InterfaceIdCalculator.json +180 -0
  23. package/build/contracts/mocks/PolicyHolderMock.sol/PolicyHolderMock.json +28 -2
  24. package/build/contracts/mocks/PolicyPoolComponentMock.sol/PolicyPoolComponentMock.json +21 -2
  25. package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMock.json +115 -2
  26. package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMockForward.json +2 -2
  27. package/build/contracts/mocks/RiskModuleMock.sol/RiskModuleMock.json +111 -2
  28. package/build/contracts/mocks/TestCurrency.sol/TestCurrency.json +2 -2
  29. package/build/contracts/mocks/TestNFT.sol/TestNFT.json +2 -2
  30. package/contracts/AccessManager.sol +31 -2
  31. package/contracts/ERC4626AssetManager.sol +8 -2
  32. package/contracts/EToken.sol +129 -60
  33. package/contracts/LPManualWhitelist.sol +18 -2
  34. package/contracts/LiquidityThresholdAssetManager.sol +28 -12
  35. package/contracts/Policy.sol +5 -3
  36. package/contracts/PolicyPool.sol +221 -29
  37. package/contracts/PolicyPoolComponent.sol +36 -25
  38. package/contracts/PremiumsAccount.sol +220 -32
  39. package/contracts/Reserve.sol +130 -19
  40. package/contracts/RiskModule.sol +53 -20
  41. package/contracts/SignedQuoteRiskModule.sol +310 -0
  42. package/contracts/TimeScaled.sol +19 -15
  43. package/contracts/TrustfulRiskModule.sol +107 -6
  44. package/contracts/dependencies/WadRayMath.sol +126 -0
  45. package/contracts/interfaces/IAccessManager.sol +68 -13
  46. package/contracts/interfaces/IAssetManager.sol +69 -2
  47. package/contracts/interfaces/IEToken.sol +4 -1
  48. package/contracts/interfaces/ILPWhitelist.sol +17 -0
  49. package/contracts/interfaces/IPolicyPool.sol +19 -1
  50. package/contracts/interfaces/IPolicyPoolComponent.sol +5 -1
  51. package/contracts/interfaces/IRiskModule.sol +67 -4
  52. package/contracts/mocks/InterfaceIdCalculator.sol +32 -0
  53. package/contracts/mocks/PolicyHolderMock.sol +21 -0
  54. package/contracts/mocks/PolicyPoolComponentMock.sol +10 -0
  55. package/contracts/mocks/PolicyPoolMock.sol +31 -0
  56. package/contracts/mocks/RiskModuleMock.sol +7 -1
  57. package/js/deploy.js +734 -0
  58. package/js/test-utils.js +184 -69
  59. package/package.json +4 -2
  60. package/scripts/change-pragma.sh +19 -0
  61. package/scripts/deploySmokeTest-fork.sh +53 -0
  62. package/scripts/deploySmokeTest.sh +51 -0
  63. package/scripts/storageLayout.js +33 -0
  64. package/scripts/utils.sh +65 -0
  65. package/contracts/WadRayMath.sol +0 -135
@@ -1,135 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.0;
3
-
4
- /**
5
- * @title WadRayMath library
6
- * @author Aave / Ensuro
7
- * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays
8
- * (decimals with 27 digits)
9
- * @custom:security-contact security@ensuro.co
10
- **/
11
-
12
- library WadRayMath {
13
- uint256 internal constant WAD = 1e18;
14
- uint256 internal constant HALF_WAD = WAD / 2;
15
-
16
- uint256 internal constant RAY = 1e27;
17
- uint256 internal constant HALF_RAY = RAY / 2;
18
-
19
- uint256 internal constant WAD_RAY_RATIO = 1e9;
20
-
21
- /**
22
- * @return One ray, 1e27
23
- **/
24
- function ray() internal pure returns (uint256) {
25
- return RAY;
26
- }
27
-
28
- /**
29
- * @return One wad, 1e18
30
- **/
31
-
32
- function wad() internal pure returns (uint256) {
33
- return WAD;
34
- }
35
-
36
- /**
37
- * @return Half ray, 1e27/2
38
- **/
39
- function halfRay() internal pure returns (uint256) {
40
- return HALF_RAY;
41
- }
42
-
43
- /**
44
- * @return Half ray, 1e18/2
45
- **/
46
- function halfWad() internal pure returns (uint256) {
47
- return HALF_WAD;
48
- }
49
-
50
- /**
51
- * @dev Multiplies two wad, rounding half up to the nearest wad
52
- * @param a Wad
53
- * @param b Wad
54
- * @return The result of a*b, in wad
55
- **/
56
- function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {
57
- if (a == 0 || b == 0) {
58
- return 0;
59
- }
60
-
61
- require(a <= (type(uint256).max - HALF_WAD) / b, "wadMul: Math Multiplication Overflow");
62
-
63
- return (a * b + HALF_WAD) / WAD;
64
- }
65
-
66
- /**
67
- * @dev Divides two wad, rounding half up to the nearest wad
68
- * @param a Wad
69
- * @param b Wad
70
- * @return The result of a/b, in wad
71
- **/
72
- function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
73
- require(b != 0, "wadDiv: Division by zero");
74
- uint256 halfB = b / 2;
75
-
76
- require(a <= (type(uint256).max - halfB) / WAD, "wadDiv: Math Multiplication Overflow");
77
-
78
- return (a * WAD + halfB) / b;
79
- }
80
-
81
- /**
82
- * @dev Multiplies two ray, rounding half up to the nearest ray
83
- * @param a Ray
84
- * @param b Ray
85
- * @return The result of a*b, in ray
86
- **/
87
- function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {
88
- if (a == 0 || b == 0) {
89
- return 0;
90
- }
91
-
92
- require(a <= (type(uint256).max - HALF_RAY) / b, "rayMul: Math Multiplication Overflow");
93
-
94
- return (a * b + HALF_RAY) / RAY;
95
- }
96
-
97
- /**
98
- * @dev Divides two ray, rounding half up to the nearest ray
99
- * @param a Ray
100
- * @param b Ray
101
- * @return The result of a/b, in ray
102
- **/
103
- function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {
104
- require(b != 0, "rayDiv: Division by zero");
105
- uint256 halfB = b / 2;
106
-
107
- require(a <= (type(uint256).max - halfB) / RAY, "rayDiv: Math Multiplication Overflow");
108
-
109
- return (a * RAY + halfB) / b;
110
- }
111
-
112
- /**
113
- * @dev Casts ray down to wad
114
- * @param a Ray
115
- * @return a casted to wad, rounded half up to the nearest wad
116
- **/
117
- function rayToWad(uint256 a) internal pure returns (uint256) {
118
- uint256 halfRatio = WAD_RAY_RATIO / 2;
119
- uint256 result = halfRatio + a;
120
- require(result >= halfRatio, "rayToWad: Math Addition Overflow");
121
-
122
- return result / WAD_RAY_RATIO;
123
- }
124
-
125
- /**
126
- * @dev Converts wad up to ray
127
- * @param a Wad
128
- * @return a converted in ray
129
- **/
130
- function wadToRay(uint256 a) internal pure returns (uint256) {
131
- uint256 result = a * WAD_RAY_RATIO;
132
- require(result / WAD_RAY_RATIO == a, "wadToRad: Math Multiplication Overflow");
133
- return result;
134
- }
135
- }