-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathCoverBase.sol
More file actions
112 lines (96 loc) · 3.51 KB
/
CoverBase.sol
File metadata and controls
112 lines (96 loc) · 3.51 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Neptune Mutual Protocol (https://neptunemutual.com)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "../../interfaces/IStore.sol";
import "../../interfaces/ICover.sol";
import "../../libraries/CoverLibV1.sol";
import "../Recoverable.sol";
/**
* @title Base Cover Contract
*
*/
abstract contract CoverBase is ICover, Recoverable {
using CoverLibV1 for IStore;
using StoreKeyUtil for IStore;
using ValidationLibV1 for IStore;
/**
* @dev Constructs this smart contract
* @param store Provide the address of an eternal storage contract to use.
* This contract must be a member of the Protocol for write access to the storage
*
*/
constructor(IStore store) Recoverable(store) {} // solhint-disable-line
/**
* @dev Initializes this contract
*
* @custom:warning Warning:
*
* This is a one-time setup. The stablecoin contract address can't be updated once set.
*
* @custom:suppress-address-trust-issue This instance of stablecoin can be trusted because of the ACL requirement.
* @custom:suppress-initialization Can only be initialized once by a cover manager
*
* @param stablecoin Provide the address of the token this cover will be quoted against.
* @param friendlyName Enter a description or ENS name of your liquidity token.
*
*/
function initialize(address stablecoin, bytes32 friendlyName) external override nonReentrant {
s.mustNotBePaused();
AccessControlLibV1.mustBeCoverManager(s);
require(s.getAddressByKey(ProtoUtilV1.CNS_COVER_STABLECOIN) == address(0), "Already initialized");
s.initializeCoverInternal(stablecoin, friendlyName);
emit CoverInitialized(stablecoin, friendlyName);
}
/**
* @dev Sets the cover creation fee
*
* @param value Enter the cover creation fee in NPM token units
*/
function setCoverCreationFee(uint256 value) external override nonReentrant {
require(value > 0, "Please specify value");
s.mustNotBePaused();
AccessControlLibV1.mustBeCoverManager(s);
uint256 previous = s.setCoverCreationFeeInternal(value);
emit CoverCreationFeeSet(previous, value);
}
/**
* @dev Sets minimum stake to create a new cover
*
* @param value Enter the minimum cover creation stake in NPM token units
*/
function setMinCoverCreationStake(uint256 value) external override nonReentrant {
require(value > 0, "Please specify value");
s.mustNotBePaused();
AccessControlLibV1.mustBeCoverManager(s);
uint256 previous = s.setMinCoverCreationStakeInternal(value);
emit MinCoverCreationStakeSet(previous, value);
}
/**
* @dev Sets minimum stake to add liquidity
*
* @custom:note Please note that liquidity providers can remove 100% stake
* and exit their NPM stake position whenever they want to, provided they do it during
* a "withdrawal window".
*
* @param value Enter the minimum stake to add liquidity.
*/
function setMinStakeToAddLiquidity(uint256 value) external override nonReentrant {
// require(value > 0, "Please specify value"); // <-- ZERO value is allowed now
s.mustNotBePaused();
AccessControlLibV1.mustBeCoverManager(s);
uint256 previous = s.setMinStakeToAddLiquidityInternal(value);
emit MinStakeToAddLiquiditySet(previous, value);
}
/**
* @dev Version number of this contract
*/
function version() external pure override returns (bytes32) {
return "v0.1";
}
/**
* @dev Name of this contract
*/
function getName() external pure override returns (bytes32) {
return ProtoUtilV1.CNAME_COVER;
}
}