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.
- attest(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 stake)
- refute(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 stake)
- getStatus(bytes32 coverKey, bytes32 productKey)
- isCoverNormal(bytes32 coverKey)
- getStakes(bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- getStakesOf(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, address account)
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);
}
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);
}
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));
}
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);
}
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);
}
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);
}
- 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