Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

neptune-mutual-archived/protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neptune Mutual Cover

Protocol

Anyone who has NPM tokens can create a cover contract. To avoid spam, questionable, and confusing cover contracts, a creator has to burn 1000 NPM tokens. Additionally, the contract creator also needs to stake 4000 NPM tokens or more. The higher the sake, the more visibility the contract gets if there are multiple cover contracts with the same name or similar terms.

Read More

[comment]: #solidoc Start

Cover Contract (Cover.sol)

View Source: contracts/core/lifecycle/Cover.sol

↗ Extends: CoverBase

Cover

The cover contract facilitates you create and update covers

Functions

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) {}

updateCover

Updates the cover contract. This feature is accessible only to the cover owner or protocol owner (governance).

function updateCover(bytes32 key, bytes32 info) external nonpayable nonReentrant 

Arguments

Name Type Description
key bytes32 Enter the cover key
info bytes32 Enter a new IPFS URL to update
Source Code
function updateCover(bytes32 key, bytes32 info) external override nonReentrant {
    s.mustNotBePaused();
    s.mustBeValidCover(key);

    if (AccessControlLibV1.hasAccess(s, AccessControlLibV1.NS_ROLES_ADMIN, msg.sender) == false) {
      s.mustBeCoverOwner(key, msg.sender);
    }

    require(s.getBytes32ByKeys(ProtoUtilV1.NS_COVER_INFO, key) != info, "Duplicate content");

    s.updateCoverInternal(key, info);
    emit CoverUpdated(key, info);
  }

addCover

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

As the cover creator, you will earn a portion of all cover fees generated in this pool.

Read the documentation to learn more about the fees:
https://docs.neptunemutual.com/covers/contract-creators

function addCover(bytes32 key, bytes32 info, address reassuranceToken, uint256[] values) external nonpayable nonReentrant 

Arguments

Name Type Description
key bytes32 Enter a unique key for this cover
info bytes32 IPFS info of the cover contract
reassuranceToken address Optional. Token added as an reassurance of this cover.

Reassurance tokens can be added by a project to demonstrate coverage support for their own project. This helps bring the cover fee down and enhances liquidity provider confidence. Along with the NPM tokens, the reassurance tokens are rewarded as a support to the liquidity providers when a cover incident occurs.
values uint256[] [0] minStakeToReport A cover creator can override default min NPM stake to avoid spam reports
Source Code
function addCover(
    bytes32 key,
    bytes32 info,
    address reassuranceToken,
    uint256[] memory values
  ) external override nonReentrant {
    // @suppress-acl Can only be called by a whitelisted address
    // @suppress-acl Marking this as publicly accessible
    // @suppress-address-trust-issue The reassuranceToken can only be the stablecoin supported by the protocol for this version.
    s.mustNotBePaused();
    s.senderMustBeWhitelisted();

    require(values[0] >= s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTING_MIN_FIRST_STAKE), "Min NPM stake too low");
    require(reassuranceToken == s.getStablecoin(), "Invalid reassurance token");

    s.addCoverInternal(key, info, reassuranceToken, values);
    emit CoverCreated(key, info);
  }

stopCover

Enables governance admin to stop a spam cover contract

function stopCover(bytes32 key, string reason) external nonpayable nonReentrant 

Arguments

Name Type Description
key bytes32 Enter the cover key you want to stop
reason string Provide a reason to stop this cover
Source Code
function stopCover(bytes32 key, string memory reason) external override nonReentrant {
    s.mustNotBePaused();
    s.mustBeValidCover(key);
    AccessControlLibV1.mustBeGovernanceAdmin(s);

    s.stopCoverInternal(key);
    emit CoverStopped(key, msg.sender, reason);
  }

updateWhitelist

Adds or removes an account to the whitelist. For the first version of the protocol, a cover creator has to be whitelisted before they can call the addCover function.

function updateWhitelist(address account, bool status) external nonpayable nonReentrant 

Arguments

Name Type Description
account address Enter the address of the cover creator
status bool Set this to true if you want to add to or false to remove from the whitelist
Source Code
function updateWhitelist(address account, bool status) external override nonReentrant {
    s.mustNotBePaused();
    AccessControlLibV1.mustBeCoverManager(s);

    s.updateWhitelistInternal(account, status);
    emit WhitelistUpdated(account, status);
  }

checkIfWhitelisted

Signifies if a given account is whitelisted

function checkIfWhitelisted(address account) external view
returns(bool)

Arguments

Name Type Description
account address
Source Code
function checkIfWhitelisted(address account) external view override returns (bool) {
    return s.getAddressBooleanByKey(ProtoUtilV1.NS_COVER_WHITELIST, account);
  }

Contracts

[comment]: #solidoc End

About

Neptune Mutual Cover Protocol

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •