Skip to content

Latest commit

 

History

History
544 lines (445 loc) · 15.7 KB

Reporter.md

File metadata and controls

544 lines (445 loc) · 15.7 KB

Neptune Mutual Governance: Reporter Contract (Reporter.sol)

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

↗ Extends: IReporter, Witness ↘ Derived Contracts: Governance

Reporter

This contract enables any NPM tokenholder to report an incident or dispute a reported incident.
The reporters can submit incidents and/or dispute them as well. When a cover pool is reporting, other tokenholders can also join the reporters achieve a resolution. The reporter who first submits an incident is known as First Reporter whereas the reporter who disputes the reported incident is called Candidate Reporter.

Functions

report

function report(bytes32 coverKey, bytes32 info, uint256 stake) external nonpayable nonReentrant 

Arguments

Name Type Description
coverKey bytes32
info bytes32
stake uint256
Source Code
function report(
    bytes32 coverKey,
    bytes32 info,
    uint256 stake
  ) external override nonReentrant {
    // @suppress-acl Marking this as publicly accessible

    s.mustNotBePaused();
    s.mustHaveNormalCoverStatus(coverKey);

    uint256 incidentDate = block.timestamp; // solhint-disable-line
    require(stake > 0, "Stake insufficient");
    require(stake >= s.getMinReportingStakeInternal(coverKey), "Stake insufficient");

    s.setUintByKeys(ProtoUtilV1.NS_GOVERNANCE_REPORTING_INCIDENT_DATE, coverKey, incidentDate);

    // Set the Resolution Timestamp
    uint256 resolutionDate = block.timestamp + s.getReportingPeriodInternal(coverKey); // solhint-disable-line
    s.setUintByKeys(ProtoUtilV1.NS_GOVERNANCE_RESOLUTION_TS, coverKey, resolutionDate);

    // Update the values
    s.addAttestationInternal(coverKey, msg.sender, incidentDate, stake);

    // Transfer the stake to the resolution contract
    s.npmToken().ensureTransferFrom(msg.sender, address(s.getResolutionContract()), stake);

    emit Reported(coverKey, msg.sender, incidentDate, info, stake, resolutionDate);
    emit Attested(coverKey, msg.sender, incidentDate, stake);
  }

dispute

function dispute(bytes32 coverKey, uint256 incidentDate, bytes32 info, uint256 stake) external nonpayable nonReentrant 

Arguments

Name Type Description
coverKey bytes32
incidentDate uint256
info bytes32
stake uint256
Source Code
function dispute(
    bytes32 coverKey,
    uint256 incidentDate,
    bytes32 info,
    uint256 stake
  ) external override nonReentrant {
    // @suppress-acl Marking this as publicly accessible

    s.mustNotBePaused();
    s.mustNotHaveDispute(coverKey);
    s.mustBeReporting(coverKey);
    s.mustBeValidIncidentDate(coverKey, incidentDate);
    s.mustBeDuringReportingPeriod(coverKey);

    require(stake > 0, "Stake insufficient");
    require(stake >= s.getMinReportingStakeInternal(coverKey), "Stake insufficient");

    s.addDisputeInternal(coverKey, msg.sender, incidentDate, stake);

    // Transfer the stake to the resolution contract
    s.npmToken().ensureTransferFrom(msg.sender, address(s.getResolutionContract()), stake);

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

setFirstReportingStake

function setFirstReportingStake(uint256 value) external nonpayable nonReentrant 

Arguments

Name Type Description
value uint256
Source Code
function setFirstReportingStake(uint256 value) external override nonReentrant {
    s.mustNotBePaused();
    AccessControlLibV1.mustBeCoverManager(s);
    require(value > 0, "Please specify value");

    uint256 previous = s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTING_MIN_FIRST_STAKE);
    s.setUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTING_MIN_FIRST_STAKE, value);

    emit FirstReportingStakeSet(previous, value);
  }

getFirstReportingStake

function getFirstReportingStake() external view
returns(uint256)

Arguments

Name Type Description
Source Code
function getFirstReportingStake() external view override returns (uint256) {
    return s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTING_MIN_FIRST_STAKE);
  }

getFirstReportingStake

function getFirstReportingStake(bytes32 coverKey) external view
returns(uint256)

Arguments

Name Type Description
coverKey bytes32
Source Code
function getFirstReportingStake(bytes32 coverKey) external view override returns (uint256) {
    return s.getMinReportingStakeInternal(coverKey);
  }

setReportingBurnRate

function setReportingBurnRate(uint256 value) external nonpayable nonReentrant 

Arguments

Name Type Description
value uint256
Source Code
function setReportingBurnRate(uint256 value) external override nonReentrant {
    require(value > 0, "Please specify value");

    s.mustNotBePaused();
    AccessControlLibV1.mustBeCoverManager(s);

    uint256 previous = s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTING_BURN_RATE);
    s.setUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTING_BURN_RATE, value);

    emit ReportingBurnRateSet(previous, value);
  }

setReporterCommission

function setReporterCommission(uint256 value) external nonpayable nonReentrant 

Arguments

Name Type Description
value uint256
Source Code
function setReporterCommission(uint256 value) external override nonReentrant {
    s.mustNotBePaused();
    AccessControlLibV1.mustBeCoverManager(s);
    require(value > 0, "Please specify value");

    uint256 previous = s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTER_COMMISSION);
    s.setUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTER_COMMISSION, value);

    emit ReporterCommissionSet(previous, value);
  }

getActiveIncidentDate

function getActiveIncidentDate(bytes32 coverKey) external view
returns(uint256)

Arguments

Name Type Description
coverKey bytes32
Source Code
function getActiveIncidentDate(bytes32 coverKey) external view override returns (uint256) {
    return s.getActiveIncidentDateInternal(coverKey);
  }

getReporter

function getReporter(bytes32 coverKey, uint256 incidentDate) external view
returns(address)

Arguments

Name Type Description
coverKey bytes32
incidentDate uint256
Source Code
function getReporter(bytes32 coverKey, uint256 incidentDate) external view override returns (address) {
    return s.getReporterInternal(coverKey, incidentDate);
  }

getResolutionTimestamp

function getResolutionTimestamp(bytes32 coverKey) external view
returns(uint256)

Arguments

Name Type Description
coverKey bytes32
Source Code
function getResolutionTimestamp(bytes32 coverKey) external view override returns (uint256) {
    return s.getResolutionTimestampInternal(coverKey);
  }

getAttestation

function getAttestation(bytes32 coverKey, address who, uint256 incidentDate) external view
returns(myStake uint256, totalStake uint256)

Arguments

Name Type Description
coverKey bytes32
who address
incidentDate uint256
Source Code
function getAttestation(
    bytes32 coverKey,
    address who,
    uint256 incidentDate
  ) external view override returns (uint256 myStake, uint256 totalStake) {
    return s.getAttestationInternal(coverKey, who, incidentDate);
  }

getDispute

function getDispute(bytes32 coverKey, address who, uint256 incidentDate) external view
returns(myStake uint256, totalStake uint256)

Arguments

Name Type Description
coverKey bytes32
who address
incidentDate uint256
Source Code
function getDispute(
    bytes32 coverKey,
    address who,
    uint256 incidentDate
  ) external view override returns (uint256 myStake, uint256 totalStake) {
    return s.getDisputeInternal(coverKey, who, incidentDate);
  }

Contracts