Skip to content

Latest commit

 

History

History
432 lines (366 loc) · 14.3 KB

Witness.md

File metadata and controls

432 lines (366 loc) · 14.3 KB

Witness Contract (Witness.sol)

View Source: contracts/core/governance/Witness.sol

↗ Extends: Recoverable, IWitness ↘ Derived Contracts: Reporter

Witness

The witeness contract enables NPM tokenholders to participate in an active cover incident.

The participants can choose to support an incident by attesting or they can also disagree by refuting the incident. In both cases, the tokenholders can choose to submit any amount of NEP stake during the (7 day, configurable) reporting period.

After the reporting period, whichever side loses, loses all their tokens. While each witness and reporter on the winning side will proportionately receive a portion of these tokens as a reward, some forfeited tokens are burned too.

Warning:

Please carefully check the cover rules, cover exclusions, and standard exclusion in detail before you interact with the Governance contract(s). Your entire stake will be forfeited if resolution does not go in your favor. You will be able to unstake and receive back your NPM only if:

  • incident resolution is in your favor
  • after reporting period ends

    By using this contract directly via a smart contract call, through an explorer service such as Etherscan, using an SDK and/or API, or in any other way, you are completely aware, fully understand, and accept the risk that you may lose all of your stake.

Functions

attest

Support the reported incident by staking your NPM token. Your tokens will be frozen until the incident is fully resolved.

Ensure that you not only thoroughly comprehend the terms, exclusion, standard exclusion, etc of the policy, but that you also have all the necessary proof to verify that the requirement has been met.

function attest(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 stake) external nonpayable nonReentrant 

Arguments

Name Type Description
coverKey bytes32 Enter the key of the active cover
productKey bytes32
incidentDate uint256 Enter the active cover's date of incident
stake uint256 Enter the amount of NPM tokens you wish to stake. Note that you cannot unstake this amount if the decision was not in your favor.
Source Code
function attest(
    bytes32 coverKey,
    bytes32 productKey,
    uint256 incidentDate,
    uint256 stake
  ) external override nonReentrant {
    s.mustNotBePaused();
    s.mustBeSupportedProductOrEmpty(coverKey, productKey);
    s.mustBeReportingOrDisputed(coverKey, productKey);
    s.mustBeValidIncidentDate(coverKey, productKey, incidentDate);
    s.mustBeDuringReportingPeriod(coverKey, productKey);

    require(stake > 0, "Enter a stake");

    s.addAttestationInternal(coverKey, productKey, msg.sender, incidentDate, stake);

    s.getNpmTokenInstanceInternal().ensureTransferFrom(msg.sender, address(s.getResolutionContract()), stake);

    emit Attested(coverKey, productKey, msg.sender, incidentDate, stake);
  }

refute

Reject the reported incident by staking your NPM token. Your tokens will be frozen until the incident is fully resolved.

Ensure that you not only thoroughly comprehend the terms, exclusion, standard exclusion, etc of the policy, but that you also have all the necessary proof to verify that the requirement has NOT been met.

function refute(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 stake) external nonpayable nonReentrant 

Arguments

Name Type Description
coverKey bytes32 Enter the key of the active cover
productKey bytes32
incidentDate uint256 Enter the active cover's date of incident
stake uint256 Enter the amount of NPM tokens you wish to stake. Note that you cannot unstake this amount if the decision was not in your favor.
Source Code
function refute(
    bytes32 coverKey,
    bytes32 productKey,
    uint256 incidentDate,
    uint256 stake
  ) external override nonReentrant {
    s.mustNotBePaused();
    s.mustBeSupportedProductOrEmpty(coverKey, productKey);
    s.mustHaveDispute(coverKey, productKey);
    s.mustBeValidIncidentDate(coverKey, productKey, incidentDate);
    s.mustBeDuringReportingPeriod(coverKey, productKey);

    require(stake > 0, "Enter a stake");

    s.addRefutationInternal(coverKey, productKey, msg.sender, incidentDate, stake);

    s.getNpmTokenInstanceInternal().ensureTransferFrom(msg.sender, address(s.getResolutionContract()), stake);

    emit Refuted(coverKey, productKey, msg.sender, incidentDate, stake);
  }

getStatus

Gets the status of a given cover Warning: this function does not validate the input arguments.

function getStatus(bytes32 coverKey, bytes32 productKey) external view
returns(uint256)

Arguments

Name Type Description
coverKey bytes32 Enter the key of the cover you'd like to check the status of
productKey bytes32

Returns

Returns the cover status as an integer. For more, check the enum ProductStatus on CoverUtilV1 library.

Source Code
function getStatus(bytes32 coverKey, bytes32 productKey) external view override returns (uint256) {
    return uint256(s.getProductStatusInternal(coverKey, productKey));
  }

isCoverNormal

Gets the status of products in a given cover

function isCoverNormal(bytes32 coverKey) external view
returns(bool)

Arguments

Name Type Description
coverKey bytes32 Enter the key of the cover you'd like to check the status of

Returns

Returns the cover status as an bool.

Source Code
function isCoverNormal(bytes32 coverKey) external view returns (bool) {
    return s.isCoverNormalInternal(coverKey);
  }

getStakes

Gets the stakes of each side of a given cover governance pool Warning: this function does not validate the input arguments.

function getStakes(bytes32 coverKey, bytes32 productKey, uint256 incidentDate) external view
returns(uint256, uint256)

Arguments

Name Type Description
coverKey bytes32 Enter the key of the cover you'd like to check the stakes of
productKey bytes32
incidentDate uint256 Enter the active cover's date of incident

Returns

Returns an array of integers --> [yes, no]

Source Code
function getStakes(
    bytes32 coverKey,
    bytes32 productKey,
    uint256 incidentDate
  ) external view override returns (uint256, uint256) {
    return s.getStakesInternal(coverKey, productKey, incidentDate);
  }

getStakesOf

Gets the stakes of each side of a given cover governance pool for the specified account. Warning: this function does not validate the input arguments.

function getStakesOf(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, address account) external view
returns(uint256, uint256)

Arguments

Name Type Description
coverKey bytes32 Enter the key of the cover you'd like to check the stakes of
productKey bytes32
incidentDate uint256 Enter the active cover's date of incident
account address Enter the account you'd like to get the stakes of

Returns

Returns an array of integers --> [yes, no]

Source Code
function getStakesOf(
    bytes32 coverKey,
    bytes32 productKey,
    uint256 incidentDate,
    address account
  ) external view override returns (uint256, uint256) {
    return s.getStakesOfInternal(account, coverKey, productKey, incidentDate);
  }

Contracts