View Source: contracts/core/lifecycle/Cover.sol
↗ Extends: CoverBase
Cover
The cover contract enables you to manage onchain covers.
- constructor(IStore store)
- addCover(struct ICover.AddCoverArgs args)
- addCovers(struct ICover.AddCoverArgs[] args)
- updateCover(bytes32 coverKey, string info)
- addProduct(struct ICover.AddProductArgs args)
- addProducts(struct ICover.AddProductArgs[] args)
- updateProduct(struct ICover.UpdateProductArgs args)
- disablePolicy(bytes32 coverKey, bytes32 productKey, bool status, string reason)
- updateCoverCreatorWhitelist(address[] accounts, bool[] statuses)
- updateCoverUsersWhitelist(bytes32 coverKey, bytes32 productKey, address[] accounts, bool[] statuses)
- checkIfWhitelistedCoverCreator(address account)
- checkIfWhitelistedUser(bytes32 coverKey, bytes32 productKey, address account)
Constructs this contract
function (IStore store) public nonpayable CoverBase
Arguments
Name | Type | Description |
---|---|---|
store | IStore | Enter the store |
Source Code
constructor(IStore store) CoverBase(store) {}
Adds a new coverage pool or cover contract.
To add a new cover, you need to pay cover creation fee
and stake minimum amount of NPM in the Vault.
Through the governance portal, projects will be able redeem
the full cover fee at a later date.
Apply for Fee Redemption
https://docs.neptunemutual.com/covers/cover-fee-redemption
Read the documentation to learn more about the fees:
https://docs.neptunemutual.com/covers/contract-creators
function addCover(struct ICover.AddCoverArgs args) public nonpayable nonReentrant
returns(address)
Arguments
Name | Type | Description |
---|---|---|
args | struct ICover.AddCoverArgs |
Source Code
function addCover(AddCoverArgs calldata args) public override nonReentrant returns (address) {
s.mustNotBePaused();
s.senderMustBeWhitelistedCoverCreator();
require(args.stakeWithFee >= s.getUintByKey(ProtoUtilV1.NS_COVER_CREATION_MIN_STAKE), "Your stake is too low");
s.addCoverInternal(args);
emit CoverCreated(args.coverKey, args.info, args.tokenName, args.tokenSymbol, args.supportsProducts, args.requiresWhitelist);
return s.deployVaultInternal(args.coverKey, args.tokenName, args.tokenSymbol);
}
function addCovers(struct ICover.AddCoverArgs[] args) external nonpayable
returns(vaults address[])
Arguments
Name | Type | Description |
---|---|---|
args | struct ICover.AddCoverArgs[] |
Source Code
function addCovers(AddCoverArgs[] calldata args) external override returns (address[] memory vaults) {
vaults = new address[](args.length + 1);
for (uint256 i = 0; i < args.length; i++) {
vaults[i] = addCover(args[i]);
}
}
Updates the cover contract. This feature is accessible only to the cover manager during withdrawal period.
function updateCover(bytes32 coverKey, string info) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the cover key |
info | string | IPFS hash. Check out the documentation for more info. |
Source Code
function updateCover(bytes32 coverKey, string calldata info) external override nonReentrant {
s.mustNotBePaused();
s.mustEnsureAllProductsAreNormal(coverKey);
AccessControlLibV1.mustBeCoverManager(s);
s.mustBeDuringWithdrawalPeriod(coverKey);
require(keccak256(bytes(s.getStringByKeys(ProtoUtilV1.NS_COVER_INFO, coverKey))) != keccak256(bytes(info)), "Duplicate content");
s.updateCoverInternal(coverKey, info);
emit CoverUpdated(coverKey, info);
}
Adds a product under a diversified cover pool
function addProduct(struct ICover.AddProductArgs args) public nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
args | struct ICover.AddProductArgs |
Source Code
function addProduct(AddProductArgs calldata args) public override nonReentrant {
// @suppress-zero-value-check The uint values are validated in the function `addProductInternal`
s.mustNotBePaused();
s.senderMustBeWhitelistedCoverCreator();
s.senderMustBeCoverOwnerOrAdmin(args.coverKey);
s.addProductInternal(args);
emit ProductCreated(args.coverKey, args.productKey, args.info);
}
function addProducts(struct ICover.AddProductArgs[] args) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
args | struct ICover.AddProductArgs[] |
Source Code
function addProducts(AddProductArgs[] calldata args) external override {
for (uint256 i = 0; i < args.length; i++) {
addProduct(args[i]);
}
}
Updates a cover product. This feature is accessible only to the cover manager during withdrawal period.
function updateProduct(struct ICover.UpdateProductArgs args) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
args | struct ICover.UpdateProductArgs |
Source Code
function updateProduct(UpdateProductArgs calldata args) external override nonReentrant {
// @suppress-zero-value-check The uint values are validated in the function `updateProductInternal`
s.mustNotBePaused();
s.mustBeSupportedProductOrEmpty(args.coverKey, args.productKey);
AccessControlLibV1.mustBeCoverManager(s);
s.mustBeDuringWithdrawalPeriod(args.coverKey);
s.updateProductInternal(args);
emit ProductUpdated(args.coverKey, args.productKey, args.info);
}
Allows disabling and enabling the purchase of policy for a product or cover. This function enables governance admin to disable or enable the purchase of policy for a product or cover. A cover contract when stopped restricts new policy purchases and frees up liquidity as policies expires.
- The policy purchases can be disabled and later enabled after current policies expire and liquidity is withdrawn.
- The policy purchases can be disabled temporarily to allow liquidity providers a chance to exit.
function disablePolicy(bytes32 coverKey, bytes32 productKey, bool status, string reason) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the cover key you want to disable policy purchases |
productKey | bytes32 | Enter the product key you want to disable policy purchases |
status | bool | Set this to true if you disable or false to enable policy purchases |
reason | string | Provide a reason to disable the policy purchases |
Source Code
function disablePolicy(
bytes32 coverKey,
bytes32 productKey,
bool status,
string calldata reason
) external override nonReentrant {
s.mustNotBePaused();
AccessControlLibV1.mustBeCoverManager(s);
s.mustBeSupportedProductOrEmpty(coverKey, productKey);
require(status != s.isPolicyDisabledInternal(coverKey, productKey), status ? "Already disabled" : "Already enabled");
s.disablePolicyInternal(coverKey, productKey, status);
emit ProductStateUpdated(coverKey, productKey, msg.sender, status, reason);
}
Adds or removes an account to the cover creator whitelist.
For the first version of the protocol, a cover creator has to be whitelisted
before they can call the addCover
function.
function updateCoverCreatorWhitelist(address[] accounts, bool[] statuses) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
accounts | address[] | Enter list of address of cover creators |
statuses | bool[] | Set this to true if you want to add to or false to remove from the whitelist |
Source Code
function updateCoverCreatorWhitelist(address[] calldata accounts, bool[] calldata statuses) external override nonReentrant {
require(accounts.length > 0, "Please specify an account");
require(accounts.length == statuses.length, "Invalid args");
s.mustNotBePaused();
AccessControlLibV1.mustBeCoverManager(s);
for (uint256 i = 0; i < accounts.length; i++) {
s.updateCoverCreatorWhitelistInternal(accounts[i], statuses[i]);
emit CoverCreatorWhitelistUpdated(accounts[i], statuses[i]);
}
}
Adds or removes an account from the cover user whitelist. Whitelisting is an optional feature cover creators can enable. When a cover requires whitelist, you must add accounts to the cover user whitelist before they are able to purchase policies.
function updateCoverUsersWhitelist(bytes32 coverKey, bytes32 productKey, address[] accounts, bool[] statuses) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
accounts | address[] | Enter a list of accounts you would like to update the whitelist statuses of. |
statuses | bool[] | Enter respective statuses of the specified whitelisted accounts. |
Source Code
function updateCoverUsersWhitelist(
bytes32 coverKey,
bytes32 productKey,
address[] calldata accounts,
bool[] calldata statuses
) external override nonReentrant {
s.mustNotBePaused();
s.mustBeSupportedProductOrEmpty(coverKey, productKey);
s.senderMustBeCoverOwnerOrAdmin(coverKey);
s.updateCoverUsersWhitelistInternal(coverKey, productKey, accounts, statuses);
}
Signifies if the given account is a whitelisted cover creator
function checkIfWhitelistedCoverCreator(address account) external view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
account | address |
Source Code
function checkIfWhitelistedCoverCreator(address account) external view override returns (bool) {
return s.getAddressBooleanByKey(ProtoUtilV1.NS_COVER_CREATOR_WHITELIST, account);
}
Signifies if the given account is a whitelisted user
function checkIfWhitelistedUser(bytes32 coverKey, bytes32 productKey, address account) external view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | |
productKey | bytes32 | |
account | address |
Source Code
function checkIfWhitelistedUser(
bytes32 coverKey,
bytes32 productKey,
address account
) external view override returns (bool) {
return s.getAddressBooleanByKeys(ProtoUtilV1.NS_COVER_USER_WHITELIST, coverKey, productKey, account);
}
- AaveStrategy
- AccessControl
- AccessControlLibV1
- Address
- BaseLibV1
- BokkyPooBahsDateTimeLibrary
- BondPool
- BondPoolBase
- BondPoolLibV1
- CompoundStrategy
- Context
- Cover
- CoverBase
- CoverLibV1
- CoverReassurance
- CoverStake
- CoverUtilV1
- cxToken
- cxTokenFactory
- cxTokenFactoryLibV1
- Delayable
- Destroyable
- ERC165
- ERC20
- FakeAaveLendingPool
- FakeCompoundStablecoinDelegator
- FakePriceOracle
- FakeRecoverable
- FakeStore
- FakeToken
- FakeUniswapPair
- FakeUniswapV2FactoryLike
- FakeUniswapV2PairLike
- FakeUniswapV2RouterLike
- FaultyAaveLendingPool
- FaultyCompoundStablecoinDelegator
- Finalization
- ForceEther
- Governance
- GovernanceUtilV1
- IAaveV2LendingPoolLike
- IAccessControl
- IBondPool
- IClaimsProcessor
- ICompoundERC20DelegatorLike
- ICover
- ICoverReassurance
- ICoverStake
- ICxToken
- ICxTokenFactory
- IERC165
- IERC20
- IERC20Detailed
- IERC20Metadata
- IERC3156FlashBorrower
- IERC3156FlashLender
- IFinalization
- IGovernance
- ILendingStrategy
- ILiquidityEngine
- IMember
- INeptuneRouterV1
- InvalidStrategy
- IPausable
- IPolicy
- IPolicyAdmin
- IPriceOracle
- IProtocol
- IRecoverable
- IReporter
- IResolution
- IResolvable
- IStakingPools
- IStore
- IStoreLike
- IUniswapV2FactoryLike
- IUniswapV2PairLike
- IUniswapV2RouterLike
- IUnstakable
- IVault
- IVaultDelegate
- IVaultFactory
- IWitness
- LiquidityEngine
- MaliciousToken
- MockAccessControlUser
- MockCoverUtilUser
- MockCxToken
- MockCxTokenPolicy
- MockCxTokenStore
- MockFlashBorrower
- MockLiquidityEngineUser
- MockProcessorStore
- MockProcessorStoreLib
- MockProtocol
- MockRegistryClient
- MockStore
- MockStoreKeyUtilUser
- MockValidationLibUser
- MockVault
- MockVaultLibUser
- NeptuneRouterV1
- NPM
- NpmDistributor
- NTransferUtilV2
- NTransferUtilV2Intermediate
- Ownable
- Pausable
- Policy
- PolicyAdmin
- PolicyHelperV1
- PoorMansERC20
- POT
- PriceLibV1
- Processor
- ProtoBase
- Protocol
- ProtoUtilV1
- Recoverable
- ReentrancyGuard
- RegistryLibV1
- Reporter
- Resolution
- Resolvable
- RoutineInvokerLibV1
- SafeERC20
- StakingPoolBase
- StakingPoolCoreLibV1
- StakingPoolInfo
- StakingPoolLibV1
- StakingPoolReward
- StakingPools
- Store
- StoreBase
- StoreKeyUtil
- StrategyLibV1
- Strings
- TimelockController
- Unstakable
- ValidationLibV1
- Vault
- VaultBase
- VaultDelegate
- VaultDelegateBase
- VaultDelegateWithFlashLoan
- VaultFactory
- VaultFactoryLibV1
- VaultLibV1
- VaultLiquidity
- VaultStrategy
- WithFlashLoan
- WithPausability
- WithRecovery
- Witness