Skip to content

flashburst/protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 manager and during withdrawal period.

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

Arguments

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

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

    s.updateCoverInternal(coverKey, info);
    emit CoverUpdated(coverKey, 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 coverKey, bytes32 info, string tokenName, string tokenSymbol, bool supportsProducts, bool requiresWhitelist, uint256[] values) external nonpayable nonReentrant 
returns(address)

Arguments

Name Type Description
coverKey bytes32 Enter a unique key for this cover
info bytes32 IPFS info of the cover contract
tokenName string
tokenSymbol string
supportsProducts bool Indicates that this cover supports product(s)
requiresWhitelist bool
values uint256[] [0] stakeWithFee Enter the total NPM amount (stake + fee) to transfer to this contract.
Source Code
function addCover(
    bytes32 coverKey,
    bytes32 info,
    string calldata tokenName,
    string calldata tokenSymbol,
    bool supportsProducts,
    bool requiresWhitelist,
    uint256[] calldata values
  ) external override nonReentrant returns (address) {
    // @suppress-acl Can only be called by a whitelisted address
    // @suppress-acl Marking this as publicly accessible
    s.mustNotBePaused();
    s.senderMustBeWhitelistedCoverCreator();

    require(values[0] >= s.getUintByKey(ProtoUtilV1.NS_COVER_CREATION_MIN_STAKE), "Your stake is too low");

    s.addCoverInternal(coverKey, supportsProducts, info, requiresWhitelist, values);

    emit CoverCreated(coverKey, info, tokenName, tokenSymbol, supportsProducts, requiresWhitelist);

    address vault = s.deployVaultInternal(coverKey, tokenName, tokenSymbol);
    emit VaultDeployed(coverKey, vault);

    return vault;
  }

addProduct

function addProduct(bytes32 coverKey, bytes32 productKey, bytes32 info, bool requiresWhitelist, uint256[] values) external nonpayable

Arguments

Name Type Description
coverKey bytes32
productKey bytes32
info bytes32
requiresWhitelist bool
values uint256[]
Source Code
function addProduct(
    bytes32 coverKey,
    bytes32 productKey,
    bytes32 info,
    bool requiresWhitelist,
    uint256[] calldata values
  ) external override {
    s.mustNotBePaused();
    s.senderMustBeCoverOwnerOrAdmin(coverKey);

    s.addProductInternal(coverKey, productKey, info, requiresWhitelist, values);
    emit ProductCreated(coverKey, productKey, info, requiresWhitelist, values);
  }

updateProduct

function updateProduct(bytes32 coverKey, bytes32 productKey, bytes32 info, uint256[] values) external nonpayable

Arguments

Name Type Description
coverKey bytes32
productKey bytes32
info bytes32
values uint256[]
Source Code
function updateProduct(
    bytes32 coverKey,
    bytes32 productKey,
    bytes32 info,
    uint256[] calldata values
  ) external override {
    s.mustNotBePaused();
    s.mustBeSupportedProductOrEmpty(coverKey, productKey);
    s.mustBeCoverManager();
    s.mustBeDuringWithdrawalPeriod(coverKey);

    s.updateProductInternal(coverKey, productKey, info, values);
    emit ProductUpdated(coverKey, productKey, info, values);
  }

stopCover

Enables governance admin to stop a spam cover contract

function stopCover(bytes32 coverKey, bytes32 productKey, string reason) external nonpayable nonReentrant 

Arguments

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

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

updateCoverCreatorWhitelist

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 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 updateCoverCreatorWhitelist(address account, bool status) external override nonReentrant {
    s.mustNotBePaused();
    AccessControlLibV1.mustBeGovernanceAgent(s);

    s.updateCoverCreatorWhitelistInternal(account, status);
    emit CoverCreatorWhitelistUpdated(account, status);
  }

updateCoverUsersWhitelist

function updateCoverUsersWhitelist(bytes32 coverKey, bytes32 productKey, address[] accounts, bool[] statuses) external nonpayable nonReentrant 

Arguments

Name Type Description
coverKey bytes32
productKey bytes32
accounts address[]
statuses bool[]
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);
  }

checkIfWhitelistedCoverCreator

Signifies if a 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);
  }

checkIfWhitelistedUser

Signifies if a 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);
  }

Contracts

[comment]: #solidoc End

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 67.8%
  • Solidity 32.2%