@ensuro/core 2.8.0 → 2.8.2
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.
- package/build/contracts/AccessManager.sol/AccessManager.json +618 -0
- package/build/contracts/ERC4626AssetManager.sol/ERC4626AssetManager.json +238 -0
- package/build/contracts/EToken.sol/EToken.json +1287 -0
- package/build/contracts/LPManualWhitelist.sol/LPManualWhitelist.json +657 -0
- package/build/contracts/LiquidityThresholdAssetManager.sol/LiquidityThresholdAssetManager.json +222 -0
- package/build/contracts/Policy.sol/Policy.json +10 -0
- package/build/contracts/PolicyPool.sol/PolicyPool.json +1775 -0
- package/build/contracts/PolicyPoolComponent.sol/PolicyPoolComponent.json +342 -0
- package/build/contracts/PremiumsAccount.sol/PremiumsAccount.json +1142 -0
- package/build/contracts/Reserve.sol/Reserve.json +413 -0
- package/build/contracts/RiskModule.sol/RiskModule.json +589 -0
- package/build/contracts/SignedBucketRiskModule.sol/SignedBucketRiskModule.json +1251 -0
- package/build/contracts/SignedQuoteRiskModule.sol/SignedQuoteRiskModule.json +1145 -0
- package/build/contracts/TimeScaled.sol/TimeScaled.json +10 -0
- package/build/contracts/TrustfulRiskModule.sol/TrustfulRiskModule.json +1143 -0
- package/build/contracts/dependencies/WadRayMath.sol/WadRayMath.json +10 -0
- package/build/contracts/interfaces/IAccessManager.sol/IAccessManager.json +343 -0
- package/build/contracts/interfaces/IAssetManager.sol/IAssetManager.json +128 -0
- package/build/contracts/interfaces/IEToken.sol/IEToken.json +460 -0
- package/build/contracts/interfaces/ILPWhitelist.sol/ILPWhitelist.json +103 -0
- package/build/contracts/interfaces/IPolicyHolder.sol/IPolicyHolder.json +108 -0
- package/build/contracts/interfaces/IPolicyHolderV2.sol/IPolicyHolderV2.json +142 -0
- package/build/contracts/interfaces/IPolicyPool.sol/IPolicyPool.json +820 -0
- package/build/contracts/interfaces/IPolicyPoolComponent.sol/IPolicyPoolComponent.json +43 -0
- package/build/contracts/interfaces/IPremiumsAccount.sol/IPremiumsAccount.json +477 -0
- package/build/contracts/interfaces/IRiskModule.sol/IRiskModule.json +165 -0
- package/build/contracts/migration/LPManualWhitelistV20.sol/LPManualWhitelistV20.json +491 -0
- package/build/contracts/migration/LPManualWhitelistV20Upgraded.sol/LPManualWhitelistV20Upgraded.json +502 -0
- package/build/contracts/mocks/FixedRateVault.sol/FixedRateVault.json +736 -0
- package/build/contracts/mocks/ForwardProxy.sol/ForwardProxy.json +43 -0
- package/build/contracts/mocks/IMintableERC20.sol/IMintableERC20.json +47 -0
- package/build/contracts/mocks/InterfaceIdCalculator.sol/InterfaceIdCalculator.json +193 -0
- package/build/contracts/mocks/PolicyHolderMock.sol/PolicyHolderMock.json +457 -0
- package/build/contracts/mocks/PolicyPoolComponentMock.sol/PolicyPoolComponentMock.json +54 -0
- package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMock.json +929 -0
- package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMockForward.json +92 -0
- package/build/contracts/mocks/RiskModuleMock.sol/RiskModuleMock.json +1316 -0
- package/build/contracts/mocks/TestCurrency.sol/TestCurrency.json +343 -0
- package/build/contracts/mocks/TestNFT.sol/TestNFT.json +388 -0
- package/contracts/Policy.sol +58 -21
- package/contracts/PolicyPool.sol +155 -37
- package/contracts/PolicyPoolComponent.sol +5 -2
- package/contracts/RiskModule.sol +27 -30
- package/contracts/SignedBucketRiskModule.sol +32 -95
- package/contracts/SignedQuoteRiskModule.sol +3 -1
- package/contracts/interfaces/IPolicyHolder.sol +2 -2
- package/contracts/interfaces/IPolicyHolderV2.sol +29 -0
- package/contracts/mocks/PolicyHolderMock.sol +71 -10
- package/js/deploy.js +6 -25
- package/js/utils.js +9 -4
- package/package.json +3 -5
- package/contracts/TieredSignedQuoteRiskModule.sol +0 -159
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
|
|
4
|
-
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
|
|
5
|
-
import {IPolicyPool} from "./interfaces/IPolicyPool.sol";
|
|
6
|
-
import {IPremiumsAccount} from "./interfaces/IPremiumsAccount.sol";
|
|
7
|
-
import {SignedQuoteRiskModule} from "./SignedQuoteRiskModule.sol";
|
|
8
|
-
import {Policy} from "./Policy.sol";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @title Tiered SignedQuote Risk Module
|
|
12
|
-
* @dev Risk Module that for policy creation verifies the different components of the price have been signed by a
|
|
13
|
-
* trusted account (PRICER_ROLE). For the resolution (resolvePolicy), it has to be called by an authorized user.
|
|
14
|
-
*
|
|
15
|
-
* It allows different collaterallization levels for different policy types, by defining tiers or buckets of loss
|
|
16
|
-
* probability.
|
|
17
|
-
*
|
|
18
|
-
* Each bucket's loss probability represents the upper bound of the bucket (inclusive). The global parameters of
|
|
19
|
-
* the contract represent the 100% bucket.
|
|
20
|
-
*
|
|
21
|
-
* @custom:security-contact security@ensuro.co
|
|
22
|
-
* @author Ensuro
|
|
23
|
-
*/
|
|
24
|
-
contract TieredSignedQuoteRiskModule is SignedQuoteRiskModule {
|
|
25
|
-
using SafeCast for uint256;
|
|
26
|
-
|
|
27
|
-
uint8 public constant MAX_BUCKETS = 4;
|
|
28
|
-
|
|
29
|
-
struct PackedBuckets {
|
|
30
|
-
uint64[MAX_BUCKETS] lossProbs;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
PackedBuckets internal _buckets;
|
|
34
|
-
PackedParams[MAX_BUCKETS] internal _bucketParams;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @dev Emitted when a new risk bucket is created.
|
|
38
|
-
* @param lossProb The loss probability of the new bucket.
|
|
39
|
-
* @param params The packed parameters of the new bucket.
|
|
40
|
-
*/
|
|
41
|
-
event NewBucket(uint256 lossProb, Params params);
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @dev Emitted when the risks buckets are reset and only the default one remains
|
|
45
|
-
*/
|
|
46
|
-
event BucketsReset();
|
|
47
|
-
|
|
48
|
-
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
49
|
-
constructor(
|
|
50
|
-
IPolicyPool policyPool_,
|
|
51
|
-
IPremiumsAccount premiumsAccount_,
|
|
52
|
-
bool creationIsOpen_
|
|
53
|
-
) SignedQuoteRiskModule(policyPool_, premiumsAccount_, creationIsOpen_) {} // solhint-disable-line no-empty-blocks
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @dev Adds a new risk bucket with the given loss probability and parameters after the last one.
|
|
57
|
-
*
|
|
58
|
-
* Requirements:
|
|
59
|
-
*
|
|
60
|
-
* - The caller must have the LEVEL1_ROLE or LEVEL2_ROLE
|
|
61
|
-
*
|
|
62
|
-
* @param lossProb The loss probability of the new bucket.
|
|
63
|
-
* @param params_ The parameters of the new bucket.
|
|
64
|
-
*/
|
|
65
|
-
function pushBucket(
|
|
66
|
-
uint256 lossProb,
|
|
67
|
-
Params calldata params_
|
|
68
|
-
) external onlyGlobalOrComponentRole2(LEVEL1_ROLE, LEVEL2_ROLE) {
|
|
69
|
-
uint256 newBucket = 0;
|
|
70
|
-
if (_buckets.lossProbs[0] != 0) {
|
|
71
|
-
// solhint-disable-next-line no-empty-blocks
|
|
72
|
-
for (newBucket = 1; newBucket < MAX_BUCKETS && _buckets.lossProbs[newBucket] != 0; newBucket++) {}
|
|
73
|
-
require(newBucket < MAX_BUCKETS, "No more than 4 buckets accepted");
|
|
74
|
-
require(lossProb > uint256(_buckets.lossProbs[newBucket - 1]), "lossProb <= last lossProb - reset instead");
|
|
75
|
-
}
|
|
76
|
-
_buckets.lossProbs[newBucket] = lossProb.toUint64();
|
|
77
|
-
_bucketParams[newBucket] = PackedParams({
|
|
78
|
-
moc: _wadTo4(params_.moc),
|
|
79
|
-
jrCollRatio: _wadTo4(params_.jrCollRatio),
|
|
80
|
-
collRatio: _wadTo4(params_.collRatio),
|
|
81
|
-
ensuroPpFee: _wadTo4(params_.ensuroPpFee),
|
|
82
|
-
ensuroCocFee: _wadTo4(params_.ensuroCocFee),
|
|
83
|
-
jrRoc: _wadTo4(params_.jrRoc),
|
|
84
|
-
srRoc: _wadTo4(params_.srRoc),
|
|
85
|
-
maxPayoutPerPolicy: type(uint32).max, // unused, but needs to be > 0
|
|
86
|
-
exposureLimit: type(uint32).max, //unused, but needs to be > 0
|
|
87
|
-
maxDuration: type(uint16).max //unused
|
|
88
|
-
});
|
|
89
|
-
if (newBucket < MAX_BUCKETS - 1) {
|
|
90
|
-
_buckets.lossProbs[newBucket + 1] = 0;
|
|
91
|
-
}
|
|
92
|
-
_validatePackedParams(_bucketParams[newBucket]);
|
|
93
|
-
emit NewBucket(lossProb, params_);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function resetBuckets() external onlyGlobalOrComponentRole2(LEVEL1_ROLE, LEVEL2_ROLE) {
|
|
97
|
-
_buckets.lossProbs[0] = 0;
|
|
98
|
-
emit BucketsReset();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @dev returns the risk bucket parameters for the given loss probability
|
|
103
|
-
*/
|
|
104
|
-
function bucketParams(uint256 lossProb) public view returns (Params memory) {
|
|
105
|
-
for (uint256 i = 0; i < MAX_BUCKETS && _buckets.lossProbs[i] != 0; i++) {
|
|
106
|
-
if (lossProb <= _buckets.lossProbs[i]) {
|
|
107
|
-
return _unpackParams(_bucketParams[i]);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return this.params();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function _newPolicy(
|
|
114
|
-
uint256 payout,
|
|
115
|
-
uint256 premium,
|
|
116
|
-
uint256 lossProb,
|
|
117
|
-
uint40 expiration,
|
|
118
|
-
address payer,
|
|
119
|
-
address onBehalfOf,
|
|
120
|
-
uint96 internalId
|
|
121
|
-
) internal override whenNotPaused returns (Policy.PolicyData memory) {
|
|
122
|
-
return
|
|
123
|
-
_newPolicyWithParams(
|
|
124
|
-
payout,
|
|
125
|
-
premium,
|
|
126
|
-
lossProb,
|
|
127
|
-
expiration,
|
|
128
|
-
payer,
|
|
129
|
-
onBehalfOf,
|
|
130
|
-
internalId,
|
|
131
|
-
bucketParams(lossProb)
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function getMinimumPremium(
|
|
136
|
-
uint256 payout,
|
|
137
|
-
uint256 lossProb,
|
|
138
|
-
uint40 expiration
|
|
139
|
-
) public view virtual override returns (uint256) {
|
|
140
|
-
return _getMinimumPremium(payout, lossProb, expiration, bucketParams(lossProb));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* @dev returns the current risk bucket limits
|
|
145
|
-
*/
|
|
146
|
-
function buckets() external view returns (uint256[MAX_BUCKETS] memory result) {
|
|
147
|
-
for (uint256 i = 0; i < MAX_BUCKETS && _buckets.lossProbs[i] > 0; i++) {
|
|
148
|
-
result[i] = _buckets.lossProbs[i];
|
|
149
|
-
}
|
|
150
|
-
return result;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* @dev This empty reserved space is put in place to allow future versions to add new
|
|
155
|
-
* variables without shifting down storage in the inheritance chain.
|
|
156
|
-
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
|
|
157
|
-
*/
|
|
158
|
-
uint256[45] private __gap;
|
|
159
|
-
}
|