@ensuro/core 2.7.0 → 2.8.0-beta1

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 (77) hide show
  1. package/README.md +11 -5
  2. package/contracts/AccessManager.sol +3 -13
  3. package/contracts/EToken.sol +29 -95
  4. package/contracts/LPManualWhitelist.sol +11 -26
  5. package/contracts/LiquidityThresholdAssetManager.sol +10 -21
  6. package/contracts/Policy.sol +6 -17
  7. package/contracts/PolicyPool.sol +23 -75
  8. package/contracts/PolicyPoolComponent.sol +9 -32
  9. package/contracts/PremiumsAccount.sol +16 -47
  10. package/contracts/Reserve.sol +10 -16
  11. package/contracts/RiskModule.sol +22 -80
  12. package/contracts/SignedBucketRiskModule.sol +18 -80
  13. package/contracts/SignedQuoteRiskModule.sol +13 -44
  14. package/contracts/TieredSignedQuoteRiskModule.sol +7 -13
  15. package/contracts/TimeScaled.sol +8 -39
  16. package/contracts/TrustfulRiskModule.sol +13 -48
  17. package/contracts/interfaces/IAccessManager.sol +2 -11
  18. package/contracts/interfaces/IEToken.sol +1 -5
  19. package/contracts/interfaces/ILPWhitelist.sol +2 -10
  20. package/contracts/interfaces/IPolicyHolder.sol +2 -11
  21. package/contracts/interfaces/IPremiumsAccount.sol +1 -5
  22. package/contracts/migration/LPManualWhitelistV20.sol +3 -15
  23. package/contracts/migration/LPManualWhitelistV20Upgraded.sol +1 -5
  24. package/contracts/mocks/FixedRateVault.sol +1 -6
  25. package/contracts/mocks/PolicyHolderMock.sol +3 -13
  26. package/contracts/mocks/PolicyPoolComponentMock.sol +1 -3
  27. package/contracts/mocks/PolicyPoolMock.sol +8 -28
  28. package/contracts/mocks/RiskModuleMock.sol +3 -16
  29. package/contracts/mocks/TestNFT.sol +1 -1
  30. package/js/deploy.js +44 -39
  31. package/js/test-utils.js +30 -19
  32. package/js/utils.js +62 -29
  33. package/package.json +1 -1
  34. package/scripts/utils.sh +23 -12
  35. package/build/contracts/AccessManager.sol/AccessManager.json +0 -618
  36. package/build/contracts/ERC4626AssetManager.sol/ERC4626AssetManager.json +0 -238
  37. package/build/contracts/EToken.sol/EToken.json +0 -1277
  38. package/build/contracts/LPManualWhitelist.sol/LPManualWhitelist.json +0 -647
  39. package/build/contracts/LiquidityThresholdAssetManager.sol/LiquidityThresholdAssetManager.json +0 -222
  40. package/build/contracts/Policy.sol/Policy.json +0 -10
  41. package/build/contracts/PolicyPool.sol/PolicyPool.json +0 -1416
  42. package/build/contracts/PolicyPoolComponent.sol/PolicyPoolComponent.json +0 -332
  43. package/build/contracts/PremiumsAccount.sol/PremiumsAccount.json +0 -970
  44. package/build/contracts/Reserve.sol/Reserve.json +0 -403
  45. package/build/contracts/RiskModule.sol/RiskModule.json +0 -559
  46. package/build/contracts/SignedBucketRiskModule.sol/SignedBucketRiskModule.json +0 -1262
  47. package/build/contracts/SignedQuoteRiskModule.sol/SignedQuoteRiskModule.json +0 -1110
  48. package/build/contracts/TieredSignedQuoteRiskModule.sol/TieredSignedQuoteRiskModule.json +0 -1316
  49. package/build/contracts/TimeScaled.sol/TimeScaled.json +0 -10
  50. package/build/contracts/TrustfulRiskModule.sol/TrustfulRiskModule.json +0 -984
  51. package/build/contracts/dependencies/ERC1967Proxy.sol/ERC1967Proxy.json +0 -64
  52. package/build/contracts/dependencies/IERC20Metadata.sol/IERC20Metadata.json +0 -233
  53. package/build/contracts/dependencies/WadRayMath.sol/WadRayMath.json +0 -10
  54. package/build/contracts/interfaces/IAccessManager.sol/IAccessManager.json +0 -343
  55. package/build/contracts/interfaces/IAssetManager.sol/IAssetManager.json +0 -128
  56. package/build/contracts/interfaces/IEToken.sol/IEToken.json +0 -460
  57. package/build/contracts/interfaces/ILPWhitelist.sol/ILPWhitelist.json +0 -103
  58. package/build/contracts/interfaces/IPolicyHolder.sol/IPolicyHolder.json +0 -108
  59. package/build/contracts/interfaces/IPolicyPool.sol/IPolicyPool.json +0 -501
  60. package/build/contracts/interfaces/IPolicyPoolComponent.sol/IPolicyPoolComponent.json +0 -43
  61. package/build/contracts/interfaces/IPremiumsAccount.sol/IPremiumsAccount.json +0 -315
  62. package/build/contracts/interfaces/IRiskModule.sol/IRiskModule.json +0 -165
  63. package/build/contracts/migration/LPManualWhitelistV20.sol/LPManualWhitelistV20.json +0 -481
  64. package/build/contracts/migration/LPManualWhitelistV20Upgraded.sol/LPManualWhitelistV20Upgraded.json +0 -492
  65. package/build/contracts/mocks/FixedRateVault.sol/FixedRateVault.json +0 -736
  66. package/build/contracts/mocks/ForwardProxy.sol/ForwardProxy.json +0 -43
  67. package/build/contracts/mocks/IMintableERC20.sol/IMintableERC20.json +0 -47
  68. package/build/contracts/mocks/InterfaceIdCalculator.sol/InterfaceIdCalculator.json +0 -180
  69. package/build/contracts/mocks/PolicyHolderMock.sol/PolicyHolderMock.json +0 -319
  70. package/build/contracts/mocks/PolicyPoolComponentMock.sol/PolicyPoolComponentMock.json +0 -54
  71. package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMock.json +0 -721
  72. package/build/contracts/mocks/PolicyPoolMock.sol/PolicyPoolMockForward.json +0 -92
  73. package/build/contracts/mocks/RiskModuleMock.sol/RiskModuleMock.json +0 -783
  74. package/build/contracts/mocks/TestCurrency.sol/TestCurrency.json +0 -343
  75. package/build/contracts/mocks/TestNFT.sol/TestNFT.json +0 -388
  76. package/contracts/dependencies/ERC1967Proxy.sol +0 -19
  77. package/contracts/dependencies/IERC20Metadata.sol +0 -19
@@ -75,15 +75,7 @@ contract SignedBucketRiskModule is RiskModule {
75
75
  uint256 exposureLimit_,
76
76
  address wallet_
77
77
  ) public initializer {
78
- __RiskModule_init(
79
- name_,
80
- collRatio_,
81
- ensuroPpFee_,
82
- srRoc_,
83
- maxPayoutPerPolicy_,
84
- exposureLimit_,
85
- wallet_
86
- );
78
+ __RiskModule_init(name_, collRatio_, ensuroPpFee_, srRoc_, maxPayoutPerPolicy_, exposureLimit_, wallet_);
87
79
  }
88
80
 
89
81
  function _checkSignature(
@@ -98,12 +90,7 @@ contract SignedBucketRiskModule is RiskModule {
98
90
  uint40 quoteValidUntil
99
91
  ) internal view {
100
92
  if (!_creationIsOpen)
101
- _policyPool.access().checkComponentRole(
102
- address(this),
103
- POLICY_CREATOR_ROLE,
104
- _msgSender(),
105
- false
106
- );
93
+ _policyPool.access().checkComponentRole(address(this), POLICY_CREATOR_ROLE, _msgSender(), false);
107
94
  require(quoteValidUntil >= block.timestamp, "Quote expired");
108
95
 
109
96
  /**
@@ -116,16 +103,7 @@ contract SignedBucketRiskModule is RiskModule {
116
103
  * - quoteValidUntil: the maximum validity of the quote
117
104
  */
118
105
  bytes32 quoteHash = ECDSA.toEthSignedMessageHash(
119
- abi.encodePacked(
120
- address(this),
121
- payout,
122
- premium,
123
- lossProb,
124
- expiration,
125
- policyData,
126
- bucketId,
127
- quoteValidUntil
128
- )
106
+ abi.encodePacked(address(this), payout, premium, lossProb, expiration, policyData, bucketId, quoteValidUntil)
129
107
  );
130
108
  address signer = ECDSA.recover(quoteHash, quoteSignatureR, quoteSignatureVS);
131
109
  _policyPool.access().checkComponentRole(address(this), PRICER_ROLE, signer, false);
@@ -141,7 +119,7 @@ contract SignedBucketRiskModule is RiskModule {
141
119
  address payer,
142
120
  address onBehalfOf
143
121
  ) internal returns (Policy.PolicyData memory createdPolicy) {
144
- uint96 internalId = uint96(uint256(policyData) % 2**96);
122
+ uint96 internalId = uint96(uint256(policyData) % 2 ** 96);
145
123
  createdPolicy = _newPolicyWithParams(
146
124
  payout,
147
125
  premium,
@@ -202,17 +180,7 @@ contract SignedBucketRiskModule is RiskModule {
202
180
  quoteSignatureVS,
203
181
  quoteValidUntil
204
182
  );
205
- return
206
- _newPolicySigned(
207
- payout,
208
- premium,
209
- lossProb,
210
- expiration,
211
- policyData,
212
- bucketId,
213
- _msgSender(),
214
- onBehalfOf
215
- );
183
+ return _newPolicySigned(payout, premium, lossProb, expiration, policyData, bucketId, _msgSender(), onBehalfOf);
216
184
  }
217
185
 
218
186
  /**
@@ -261,17 +229,7 @@ contract SignedBucketRiskModule is RiskModule {
261
229
  quoteSignatureVS,
262
230
  quoteValidUntil
263
231
  );
264
- return
265
- _newPolicySigned(
266
- payout,
267
- premium,
268
- lossProb,
269
- expiration,
270
- policyData,
271
- bucketId,
272
- _msgSender(),
273
- onBehalfOf
274
- ).id;
232
+ return _newPolicySigned(payout, premium, lossProb, expiration, policyData, bucketId, _msgSender(), onBehalfOf).id;
275
233
  }
276
234
 
277
235
  /**
@@ -334,24 +292,13 @@ contract SignedBucketRiskModule is RiskModule {
334
292
  quoteSignatureVS,
335
293
  quoteValidUntil
336
294
  );
337
- return
338
- _newPolicySigned(
339
- payout,
340
- premium,
341
- lossProb,
342
- expiration,
343
- policyData,
344
- bucketId,
345
- onBehalfOf,
346
- onBehalfOf
347
- ).id;
295
+ return _newPolicySigned(payout, premium, lossProb, expiration, policyData, bucketId, onBehalfOf, onBehalfOf).id;
348
296
  }
349
297
 
350
- function resolvePolicy(Policy.PolicyData calldata policy, uint256 payout)
351
- external
352
- onlyComponentRole(RESOLVER_ROLE)
353
- whenNotPaused
354
- {
298
+ function resolvePolicy(
299
+ Policy.PolicyData calldata policy,
300
+ uint256 payout
301
+ ) external onlyComponentRole(RESOLVER_ROLE) whenNotPaused {
355
302
  _policyPool.resolvePolicy(policy, payout);
356
303
  }
357
304
 
@@ -365,14 +312,11 @@ contract SignedBucketRiskModule is RiskModule {
365
312
  * @param bucketId Group identifier for the policies that will have these parameters
366
313
  * @param params_ The parameters of the new bucket.
367
314
  */
368
- function setBucketParams(uint256 bucketId, Params calldata params_)
369
- external
370
- onlyGlobalOrComponentRole2(LEVEL1_ROLE, LEVEL2_ROLE)
371
- {
372
- require(
373
- bucketId != 0,
374
- "SignedBucketRiskModule: bucketId can't be zero, set default RM parameters"
375
- );
315
+ function setBucketParams(
316
+ uint256 bucketId,
317
+ Params calldata params_
318
+ ) external onlyGlobalOrComponentRole2(LEVEL1_ROLE, LEVEL2_ROLE) {
319
+ require(bucketId != 0, "SignedBucketRiskModule: bucketId can't be zero, set default RM parameters");
376
320
  _buckets[bucketId] = PackedParams({
377
321
  moc: _wadTo4(params_.moc),
378
322
  jrCollRatio: _wadTo4(params_.jrCollRatio),
@@ -398,14 +342,8 @@ contract SignedBucketRiskModule is RiskModule {
398
342
  *
399
343
  * @param bucketId Group identifier for the policies that will have these parameters
400
344
  */
401
- function deleteBucket(uint256 bucketId)
402
- external
403
- onlyGlobalOrComponentRole2(LEVEL1_ROLE, LEVEL2_ROLE)
404
- {
405
- require(
406
- bucketId != 0,
407
- "SignedBucketRiskModule: bucketId can't be zero, set default RM parameters"
408
- );
345
+ function deleteBucket(uint256 bucketId) external onlyGlobalOrComponentRole2(LEVEL1_ROLE, LEVEL2_ROLE) {
346
+ require(bucketId != 0, "SignedBucketRiskModule: bucketId can't be zero, set default RM parameters");
409
347
  delete _buckets[bucketId];
410
348
  emit BucketDeleted(bucketId);
411
349
  }
@@ -58,15 +58,7 @@ contract SignedQuoteRiskModule is RiskModule {
58
58
  uint256 exposureLimit_,
59
59
  address wallet_
60
60
  ) public initializer {
61
- __RiskModule_init(
62
- name_,
63
- collRatio_,
64
- ensuroPpFee_,
65
- srRoc_,
66
- maxPayoutPerPolicy_,
67
- exposureLimit_,
68
- wallet_
69
- );
61
+ __RiskModule_init(name_, collRatio_, ensuroPpFee_, srRoc_, maxPayoutPerPolicy_, exposureLimit_, wallet_);
70
62
  }
71
63
 
72
64
  function _newPolicySigned(
@@ -82,12 +74,7 @@ contract SignedQuoteRiskModule is RiskModule {
82
74
  address onBehalfOf
83
75
  ) internal returns (Policy.PolicyData memory createdPolicy) {
84
76
  if (!_creationIsOpen)
85
- _policyPool.access().checkComponentRole(
86
- address(this),
87
- POLICY_CREATOR_ROLE,
88
- _msgSender(),
89
- false
90
- );
77
+ _policyPool.access().checkComponentRole(address(this), POLICY_CREATOR_ROLE, _msgSender(), false);
91
78
  require(quoteValidUntil >= block.timestamp, "Quote expired");
92
79
 
93
80
  /**
@@ -100,29 +87,13 @@ contract SignedQuoteRiskModule is RiskModule {
100
87
  * - quoteValidUntil: the maximum validity of the quote
101
88
  */
102
89
  bytes32 quoteHash = ECDSA.toEthSignedMessageHash(
103
- abi.encodePacked(
104
- address(this),
105
- payout,
106
- premium,
107
- lossProb,
108
- expiration,
109
- policyData,
110
- quoteValidUntil
111
- )
90
+ abi.encodePacked(address(this), payout, premium, lossProb, expiration, policyData, quoteValidUntil)
112
91
  );
113
92
  address signer = ECDSA.recover(quoteHash, quoteSignatureR, quoteSignatureVS);
114
93
  _policyPool.access().checkComponentRole(address(this), PRICER_ROLE, signer, false);
115
- uint96 internalId = uint96(uint256(policyData) % 2**96);
94
+ uint96 internalId = uint96(uint256(policyData) % 2 ** 96);
116
95
 
117
- createdPolicy = _newPolicy(
118
- payout,
119
- premium,
120
- lossProb,
121
- expiration,
122
- payer,
123
- onBehalfOf,
124
- internalId
125
- );
96
+ createdPolicy = _newPolicy(payout, premium, lossProb, expiration, payer, onBehalfOf, internalId);
126
97
  emit NewSignedPolicy(createdPolicy.id, policyData);
127
98
  return createdPolicy;
128
99
  }
@@ -285,19 +256,17 @@ contract SignedQuoteRiskModule is RiskModule {
285
256
  ).id;
286
257
  }
287
258
 
288
- function resolvePolicy(Policy.PolicyData calldata policy, uint256 payout)
289
- external
290
- onlyComponentRole(RESOLVER_ROLE)
291
- whenNotPaused
292
- {
259
+ function resolvePolicy(
260
+ Policy.PolicyData calldata policy,
261
+ uint256 payout
262
+ ) external onlyComponentRole(RESOLVER_ROLE) whenNotPaused {
293
263
  _policyPool.resolvePolicy(policy, payout);
294
264
  }
295
265
 
296
- function resolvePolicyFullPayout(Policy.PolicyData calldata policy, bool customerWon)
297
- external
298
- onlyComponentRole(RESOLVER_ROLE)
299
- whenNotPaused
300
- {
266
+ function resolvePolicyFullPayout(
267
+ Policy.PolicyData calldata policy,
268
+ bool customerWon
269
+ ) external onlyComponentRole(RESOLVER_ROLE) whenNotPaused {
301
270
  _policyPool.resolvePolicyFullPayout(policy, customerWon);
302
271
  }
303
272
 
@@ -62,22 +62,16 @@ contract TieredSignedQuoteRiskModule is SignedQuoteRiskModule {
62
62
  * @param lossProb The loss probability of the new bucket.
63
63
  * @param params_ The parameters of the new bucket.
64
64
  */
65
- function pushBucket(uint256 lossProb, Params calldata params_)
66
- external
67
- onlyGlobalOrComponentRole2(LEVEL1_ROLE, LEVEL2_ROLE)
68
- {
65
+ function pushBucket(
66
+ uint256 lossProb,
67
+ Params calldata params_
68
+ ) external onlyGlobalOrComponentRole2(LEVEL1_ROLE, LEVEL2_ROLE) {
69
69
  uint256 newBucket = 0;
70
70
  if (_buckets.lossProbs[0] != 0) {
71
- for (
72
- newBucket = 1;
73
- newBucket < MAX_BUCKETS && _buckets.lossProbs[newBucket] != 0;
74
- newBucket++
75
- ) {} // solhint-disable-line no-empty-blocks
71
+ // solhint-disable-next-line no-empty-blocks
72
+ for (newBucket = 1; newBucket < MAX_BUCKETS && _buckets.lossProbs[newBucket] != 0; newBucket++) {}
76
73
  require(newBucket < MAX_BUCKETS, "No more than 4 buckets accepted");
77
- require(
78
- lossProb > uint256(_buckets.lossProbs[newBucket - 1]),
79
- "lossProb <= last lossProb - reset instead"
80
- );
74
+ require(lossProb > uint256(_buckets.lossProbs[newBucket - 1]), "lossProb <= last lossProb - reset instead");
81
75
  }
82
76
  _buckets.lossProbs[newBucket] = lossProb.toUint64();
83
77
  _bucketParams[newBucket] = PackedParams({
@@ -35,11 +35,7 @@ library TimeScaled {
35
35
  }
36
36
  }
37
37
 
38
- function getScale(ScaledAmount storage scaledAmount, uint256 interestRate)
39
- internal
40
- view
41
- returns (uint256)
42
- {
38
+ function getScale(ScaledAmount storage scaledAmount, uint256 interestRate) internal view returns (uint256) {
43
39
  uint32 now_ = uint32(block.timestamp);
44
40
  if (scaledAmount.lastUpdate >= now_) {
45
41
  return scaledAmount.scale;
@@ -51,16 +47,8 @@ library TimeScaled {
51
47
  );
52
48
  }
53
49
 
54
- function getScaledAmount(ScaledAmount storage scaledAmount, uint256 interestRate)
55
- internal
56
- view
57
- returns (uint256)
58
- {
59
- return
60
- uint256(scaledAmount.amount)
61
- .wadToRay()
62
- .rayMul(getScale(scaledAmount, interestRate))
63
- .rayToWad();
50
+ function getScaledAmount(ScaledAmount storage scaledAmount, uint256 interestRate) internal view returns (uint256) {
51
+ return uint256(scaledAmount.amount).wadToRay().rayMul(getScale(scaledAmount, interestRate)).rayToWad();
64
52
  }
65
53
 
66
54
  function init(ScaledAmount storage scaledAmount) internal {
@@ -69,11 +57,7 @@ library TimeScaled {
69
57
  scaledAmount.lastUpdate = uint32(block.timestamp);
70
58
  }
71
59
 
72
- function scaleAmount(ScaledAmount storage scaledAmount, uint256 toScale)
73
- internal
74
- view
75
- returns (uint256)
76
- {
60
+ function scaleAmount(ScaledAmount storage scaledAmount, uint256 toScale) internal view returns (uint256) {
77
61
  return toScale.wadToRay().rayDiv(uint256(scaledAmount.scale)).rayToWad();
78
62
  }
79
63
 
@@ -85,22 +69,14 @@ library TimeScaled {
85
69
  return toScale.wadToRay().rayDiv(getScale(scaledAmount, interestRate)).rayToWad();
86
70
  }
87
71
 
88
- function add(
89
- ScaledAmount storage scaledAmount,
90
- uint256 amount,
91
- uint256 interestRate
92
- ) internal returns (uint256) {
72
+ function add(ScaledAmount storage scaledAmount, uint256 amount, uint256 interestRate) internal returns (uint256) {
93
73
  updateScale(scaledAmount, interestRate);
94
74
  uint256 scaledAdd = scaleAmount(scaledAmount, amount);
95
75
  scaledAmount.amount += scaledAdd.toUint96();
96
76
  return scaledAdd;
97
77
  }
98
78
 
99
- function sub(
100
- ScaledAmount storage scaledAmount,
101
- uint256 amount,
102
- uint256 interestRate
103
- ) internal returns (uint256) {
79
+ function sub(ScaledAmount storage scaledAmount, uint256 amount, uint256 interestRate) internal returns (uint256) {
104
80
  updateScale(scaledAmount, interestRate);
105
81
  uint256 scaledSub = scaleAmount(scaledAmount, amount);
106
82
  scaledAmount.amount -= scaledSub.toUint96();
@@ -111,21 +87,14 @@ library TimeScaled {
111
87
  return scaledSub;
112
88
  }
113
89
 
114
- function discreteChange(
115
- ScaledAmount storage scaledAmount,
116
- int256 amount,
117
- uint256 interestRate
118
- ) internal {
90
+ function discreteChange(ScaledAmount storage scaledAmount, int256 amount, uint256 interestRate) internal {
119
91
  if (scaledAmount.amount == 0) {
120
92
  add(scaledAmount, uint256(amount), interestRate);
121
93
  return;
122
94
  }
123
95
  updateScale(scaledAmount, interestRate);
124
96
  uint256 newScaledAmount = uint256(int256(getScaledAmount(scaledAmount, interestRate)) + amount);
125
- scaledAmount.scale = newScaledAmount
126
- .wadToRay()
127
- .rayDiv(uint256(scaledAmount.amount).wadToRay())
128
- .toUint112();
97
+ scaledAmount.scale = newScaledAmount.wadToRay().rayDiv(uint256(scaledAmount.amount).wadToRay()).toUint112();
129
98
  require(scaledAmount.scale >= MIN_SCALE, "Scale too small, can lead to rounding errors");
130
99
  }
131
100
 
@@ -20,9 +20,7 @@ contract TrustfulRiskModule is RiskModule {
20
20
 
21
21
  /// @custom:oz-upgrades-unsafe-allow constructor
22
22
  // solhint-disable-next-line no-empty-blocks
23
- constructor(IPolicyPool policyPool_, IPremiumsAccount premiumsAccount_)
24
- RiskModule(policyPool_, premiumsAccount_)
25
- {} // solhint-disable-line no-empty-blocks
23
+ constructor(IPolicyPool policyPool_, IPremiumsAccount premiumsAccount_) RiskModule(policyPool_, premiumsAccount_) {}
26
24
 
27
25
  /**
28
26
  * @dev Initializes the RiskModule
@@ -43,15 +41,7 @@ contract TrustfulRiskModule is RiskModule {
43
41
  uint256 exposureLimit_,
44
42
  address wallet_
45
43
  ) public initializer {
46
- __RiskModule_init(
47
- name_,
48
- collRatio_,
49
- ensuroPpFee_,
50
- srRoc_,
51
- maxPayoutPerPolicy_,
52
- exposureLimit_,
53
- wallet_
54
- );
44
+ __RiskModule_init(name_, collRatio_, ensuroPpFee_, srRoc_, maxPayoutPerPolicy_, exposureLimit_, wallet_);
55
45
  }
56
46
 
57
47
  /**
@@ -79,16 +69,7 @@ contract TrustfulRiskModule is RiskModule {
79
69
  address onBehalfOf,
80
70
  uint96 internalId
81
71
  ) external whenNotPaused onlyComponentRole(PRICER_ROLE) returns (uint256) {
82
- return
83
- _newPolicy(
84
- payout,
85
- premium,
86
- lossProb,
87
- expiration,
88
- _getPayer(onBehalfOf, premium),
89
- onBehalfOf,
90
- internalId
91
- ).id;
72
+ return _newPolicy(payout, premium, lossProb, expiration, _getPayer(onBehalfOf, premium), onBehalfOf, internalId).id;
92
73
  }
93
74
 
94
75
  /**
@@ -115,22 +96,8 @@ contract TrustfulRiskModule is RiskModule {
115
96
  uint40 expiration,
116
97
  address onBehalfOf,
117
98
  uint96 internalId
118
- )
119
- external
120
- whenNotPaused
121
- onlyComponentRole(PRICER_ROLE)
122
- returns (Policy.PolicyData memory createdPolicy)
123
- {
124
- return
125
- _newPolicy(
126
- payout,
127
- premium,
128
- lossProb,
129
- expiration,
130
- _getPayer(onBehalfOf, premium),
131
- onBehalfOf,
132
- internalId
133
- );
99
+ ) external whenNotPaused onlyComponentRole(PRICER_ROLE) returns (Policy.PolicyData memory createdPolicy) {
100
+ return _newPolicy(payout, premium, lossProb, expiration, _getPayer(onBehalfOf, premium), onBehalfOf, internalId);
134
101
  }
135
102
 
136
103
  function _getPayer(address onBehalfOf, uint256 premium) internal view returns (address payer) {
@@ -165,11 +132,10 @@ contract TrustfulRiskModule is RiskModule {
165
132
  * @param policy The policy previously created (from {NewPolicy} event)
166
133
  * @param payout The payout to transfer to the policy holder
167
134
  */
168
- function resolvePolicy(Policy.PolicyData calldata policy, uint256 payout)
169
- external
170
- onlyComponentRole(RESOLVER_ROLE)
171
- whenNotPaused
172
- {
135
+ function resolvePolicy(
136
+ Policy.PolicyData calldata policy,
137
+ uint256 payout
138
+ ) external onlyComponentRole(RESOLVER_ROLE) whenNotPaused {
173
139
  _policyPool.resolvePolicy(policy, payout);
174
140
  }
175
141
 
@@ -187,11 +153,10 @@ contract TrustfulRiskModule is RiskModule {
187
153
  * @param customerWon If true, policy.payout is transferred to the policy holder. If false, the policy is resolved
188
154
  * without payout and can't be longer claimed.
189
155
  */
190
- function resolvePolicyFullPayout(Policy.PolicyData calldata policy, bool customerWon)
191
- external
192
- onlyComponentRole(RESOLVER_ROLE)
193
- whenNotPaused
194
- {
156
+ function resolvePolicyFullPayout(
157
+ Policy.PolicyData calldata policy,
158
+ bool customerWon
159
+ ) external onlyComponentRole(RESOLVER_ROLE) whenNotPaused {
195
160
  _policyPool.resolvePolicyFullPayout(policy, customerWon);
196
161
  }
197
162
 
@@ -108,11 +108,7 @@ interface IAccessManager is IAccessControlUpgradeable {
108
108
  * @param role2 Another role such as `keccak256("GUARDIAN_ROLE")` that's global
109
109
  * @param account The user address for who we want to verify the permission
110
110
  */
111
- function checkRole2(
112
- bytes32 role1,
113
- bytes32 role2,
114
- address account
115
- ) external view;
111
+ function checkRole2(bytes32 role1, bytes32 role2, address account) external view;
116
112
 
117
113
  /**
118
114
  * @dev Checks if a user has been granted a given component role and reverts if it doesn't
@@ -122,12 +118,7 @@ interface IAccessManager is IAccessControlUpgradeable {
122
118
  * @param alsoGlobal If true, it will accept not only the component role, but also the (global) `role` itself.
123
119
  * If false, only the component role is accepted
124
120
  */
125
- function checkComponentRole(
126
- address component,
127
- bytes32 role,
128
- address account,
129
- bool alsoGlobal
130
- ) external view;
121
+ function checkComponentRole(address component, bytes32 role, address account, bool alsoGlobal) external view;
131
122
 
132
123
  /**
133
124
  * @dev Checks if a user has been granted any of the two component roles specified and reverts if it doesn't
@@ -67,11 +67,7 @@ interface IEToken is IERC20 {
67
67
  * @param policyInterestRate The annualized interest rate that was paid for the `scrAmount`, must be the same that was
68
68
  * sent in `lockScr` call.
69
69
  */
70
- function unlockScr(
71
- uint256 scrAmount,
72
- uint256 policyInterestRate,
73
- int256 adjustment
74
- ) external;
70
+ function unlockScr(uint256 scrAmount, uint256 policyInterestRate, int256 adjustment) external;
75
71
 
76
72
  /**
77
73
  * @dev Registers a deposit of liquidity in the pool. Called from the PolicyPool, assumes the amount has already been
@@ -16,11 +16,7 @@ interface ILPWhitelist {
16
16
  * @param amount The amount of the deposit
17
17
  * @return true if `provider` deposit is accepted, false if not
18
18
  */
19
- function acceptsDeposit(
20
- IEToken etoken,
21
- address provider,
22
- uint256 amount
23
- ) external view returns (bool);
19
+ function acceptsDeposit(IEToken etoken, address provider, uint256 amount) external view returns (bool);
24
20
 
25
21
  /**
26
22
  * @dev Indicates whether or not the eTokens can be transferred from `providerFrom` to `providerTo`
@@ -46,9 +42,5 @@ interface ILPWhitelist {
46
42
  * @param amount The amount of the withdrawal
47
43
  * @return true if `provider` withdraw request is accepted, false if not
48
44
  */
49
- function acceptsWithdrawal(
50
- IEToken etoken,
51
- address provider,
52
- uint256 amount
53
- ) external view returns (bool);
45
+ function acceptsWithdrawal(IEToken etoken, address provider, uint256 amount) external view returns (bool);
54
46
  }
@@ -18,11 +18,7 @@ interface IPolicyHolder is IERC721Receiver {
18
18
  *
19
19
  * The selector can be obtained in Solidity with `IPolicyPool.onPolicyExpired.selector`.
20
20
  */
21
- function onPolicyExpired(
22
- address operator,
23
- address from,
24
- uint256 policyId
25
- ) external returns (bytes4);
21
+ function onPolicyExpired(address operator, address from, uint256 policyId) external returns (bytes4);
26
22
 
27
23
  /**
28
24
  * @dev Whenever an Policy is resolved with payout > 0, this function is called
@@ -33,10 +29,5 @@ interface IPolicyHolder is IERC721Receiver {
33
29
  *
34
30
  * The selector can be obtained in Solidity with `IPolicyPool.onPayoutReceived.selector`.
35
31
  */
36
- function onPayoutReceived(
37
- address operator,
38
- address from,
39
- uint256 policyId,
40
- uint256 amount
41
- ) external returns (bytes4);
32
+ function onPayoutReceived(address operator, address from, uint256 policyId, uint256 amount) external returns (bytes4);
42
33
  }
@@ -39,11 +39,7 @@ interface IPremiumsAccount {
39
39
  * @param policy The policy that was resolved
40
40
  * @param payout The amount that has to be transferred to `policyHolder`
41
41
  */
42
- function policyResolvedWithPayout(
43
- address policyHolder,
44
- Policy.PolicyData memory policy,
45
- uint256 payout
46
- ) external;
42
+ function policyResolvedWithPayout(address policyHolder, Policy.PolicyData memory policy, uint256 payout) external;
47
43
 
48
44
  /**
49
45
  * @dev The PremiumsAccount is notified that the policy has expired, unlocks the SCR and earns the pure premium.
@@ -30,10 +30,7 @@ abstract contract LPManualWhitelistV20 is ILPWhitelist, PolicyPoolComponent {
30
30
  __PolicyPoolComponent_init();
31
31
  }
32
32
 
33
- function whitelistAddress(address provider, bool whitelisted)
34
- external
35
- onlyComponentRole(LP_WHITELIST_ROLE)
36
- {
33
+ function whitelistAddress(address provider, bool whitelisted) external onlyComponentRole(LP_WHITELIST_ROLE) {
37
34
  if (_whitelisted[provider] != whitelisted) {
38
35
  _whitelisted[provider] = whitelisted;
39
36
  emit LPWhitelisted(provider, whitelisted);
@@ -47,20 +44,11 @@ abstract contract LPManualWhitelistV20 is ILPWhitelist, PolicyPoolComponent {
47
44
  return super.supportsInterface(interfaceId) || interfaceId == type(ILPWhitelist).interfaceId;
48
45
  }
49
46
 
50
- function acceptsDeposit(
51
- IEToken,
52
- address provider,
53
- uint256
54
- ) external view override returns (bool) {
47
+ function acceptsDeposit(IEToken, address provider, uint256) external view override returns (bool) {
55
48
  return _whitelisted[provider];
56
49
  }
57
50
 
58
- function acceptsTransfer(
59
- IEToken,
60
- address,
61
- address providerTo,
62
- uint256
63
- ) external view override returns (bool) {
51
+ function acceptsTransfer(IEToken, address, address providerTo, uint256) external view override returns (bool) {
64
52
  return _whitelisted[providerTo];
65
53
  }
66
54
 
@@ -15,11 +15,7 @@ import {LPManualWhitelistV20} from "./LPManualWhitelistV20.sol";
15
15
  contract LPManualWhitelistV20Upgraded is LPManualWhitelistV20 {
16
16
  constructor(IPolicyPool policyPool_) LPManualWhitelistV20(policyPool_) {}
17
17
 
18
- function acceptsWithdrawal(
19
- IEToken etk,
20
- address provider,
21
- uint256 amount
22
- ) external view override returns (bool) {
18
+ function acceptsWithdrawal(IEToken etk, address provider, uint256 amount) external view override returns (bool) {
23
19
  return this.acceptsDeposit(etk, provider, amount);
24
20
  }
25
21
  }
@@ -33,12 +33,7 @@ contract FixedRateVault is ERC4626 {
33
33
  /**
34
34
  * @dev Deposit/mint common workflow.
35
35
  */
36
- function _deposit(
37
- address caller,
38
- address receiver,
39
- uint256 assets,
40
- uint256 shares
41
- ) internal virtual override {
36
+ function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual override {
42
37
  require(!_broken, "Vault is broken");
43
38
  _totalAssets.add(assets, _interestRate);
44
39
  super._deposit(caller, receiver, assets, shares);
@@ -20,12 +20,7 @@ contract PolicyHolderMock is IPolicyHolder {
20
20
  PolicyExpired
21
21
  }
22
22
 
23
- event NotificationReceived(
24
- NotificationKind kind,
25
- uint256 policyId,
26
- address operator,
27
- address from
28
- );
23
+ event NotificationReceived(NotificationKind kind, uint256 policyId, address operator, address from);
29
24
 
30
25
  constructor() {
31
26
  fail = false;
@@ -65,8 +60,7 @@ contract PolicyHolderMock is IPolicyHolder {
65
60
  revert(0, 0)
66
61
  }
67
62
  if (notImplemented) return false;
68
- return
69
- interfaceId == type(IPolicyHolder).interfaceId || interfaceId == type(IERC165).interfaceId;
63
+ return interfaceId == type(IPolicyHolder).interfaceId || interfaceId == type(IERC165).interfaceId;
70
64
  }
71
65
 
72
66
  function onERC721Received(
@@ -91,11 +85,7 @@ contract PolicyHolderMock is IPolicyHolder {
91
85
  return IERC721Receiver.onERC721Received.selector;
92
86
  }
93
87
 
94
- function onPolicyExpired(
95
- address operator,
96
- address from,
97
- uint256 policyId_
98
- ) external override returns (bytes4) {
88
+ function onPolicyExpired(address operator, address from, uint256 policyId_) external override returns (bytes4) {
99
89
  if (fail)
100
90
  if (emptyRevert)
101
91
  assembly {