View Source: contracts/libraries/GovernanceUtilV1.sol
GovernanceUtilV1
- getReportingPeriodInternal(IStore s, bytes32 coverKey)
- getReportingBurnRateInternal(IStore s)
- getGovernanceReporterCommissionInternal(IStore s)
- getPlatformCoverFeeRateInternal(IStore s)
- getClaimReporterCommissionInternal(IStore s)
- getMinReportingStakeInternal(IStore s, bytes32 coverKey)
- getResolutionTimestampInternal(IStore s, bytes32 coverKey, bytes32 productKey)
- getReporterInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- getStakesInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- _getReporterKey(bytes32 coverKey, bytes32 productKey)
- _getIncidentOccurredStakesKey(bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- _getClaimPayoutsKey(bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- _getReassurancePayoutKey(bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- _getIndividualIncidentOccurredStakeKey(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, address account)
- _getDisputerKey(bytes32 coverKey, bytes32 productKey)
- _getFalseReportingStakesKey(bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- _getIndividualFalseReportingStakeKey(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, address account)
- getStakesOfInternal(IStore s, address account, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- getResolutionInfoForInternal(IStore s, address account, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- getUnstakeInfoForInternal(IStore s, address account, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- getReportingUnstakenAmountInternal(IStore s, address account, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- updateUnstakeDetailsInternal(IStore s, address account, bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 originalStake, uint256 reward, uint256 burned, uint256 reporterFee)
- _updateProductStatusBeforeResolutionInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- addAttestationInternal(IStore s, bytes32 coverKey, bytes32 productKey, address who, uint256 incidentDate, uint256 stake)
- getAttestationInternal(IStore s, bytes32 coverKey, bytes32 productKey, address who, uint256 incidentDate)
- addRefutationInternal(IStore s, bytes32 coverKey, bytes32 productKey, address who, uint256 incidentDate, uint256 stake)
- getHasDisputeKeyInternal(bytes32 coverKey, bytes32 productKey)
- getHasFinalizedKeyInternal(bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- getRefutationInternal(IStore s, bytes32 coverKey, bytes32 productKey, address who, uint256 incidentDate)
- getCoolDownPeriodInternal(IStore s, bytes32 coverKey)
- getResolutionDeadlineInternal(IStore s, bytes32 coverKey, bytes32 productKey)
- addClaimPayoutsInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 claimed)
- getClaimPayoutsInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- getReassurancePayoutInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- addReassurancePayoutInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 capitalized)
- getReassuranceTransferrableInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- mustNotExceedNpmThreshold(uint256 amount)
Gets the reporting period for the given cover. Warning: this function does not validate the input arguments.
function getReportingPeriodInternal(IStore s, bytes32 coverKey) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 |
Source Code
function getReportingPeriodInternal(IStore s, bytes32 coverKey) external view returns (uint256) {
return s.getUintByKeys(ProtoUtilV1.NS_GOVERNANCE_REPORTING_PERIOD, coverKey);
}
Gets the NPM stake burn rate (upon resolution) for the given cover. Warning: this function does not validate the input arguments.
function getReportingBurnRateInternal(IStore s) public view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
Source Code
function getReportingBurnRateInternal(IStore s) public view returns (uint256) {
return s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTING_BURN_RATE);
}
Gets the "valid" reporter's NPM commission rate (upon each unstake claim invoked by individual "valid" stakers) for the given cover. Warning: this function does not validate the input arguments.
function getGovernanceReporterCommissionInternal(IStore s) public view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
Source Code
function getGovernanceReporterCommissionInternal(IStore s) public view returns (uint256) {
return s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTER_COMMISSION);
}
Gets the protocol's NPM commission rate (upon each unstake claim invoked by individual "valid" stakers) for the given cover. Warning: this function does not validate the input arguments.
function getPlatformCoverFeeRateInternal(IStore s) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
Source Code
function getPlatformCoverFeeRateInternal(IStore s) external view returns (uint256) {
return s.getUintByKey(ProtoUtilV1.NS_COVER_PLATFORM_FEE);
}
Gets the "valid" reporter's stablecoin commission rate on protocol's earnings (upon each claim payout received by claimants) for the given cover. Warning: this function does not validate the input arguments.
function getClaimReporterCommissionInternal(IStore s) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
Source Code
function getClaimReporterCommissionInternal(IStore s) external view returns (uint256) {
return s.getUintByKey(ProtoUtilV1.NS_CLAIM_REPORTER_COMMISSION);
}
Gets the minimum units of NPM tokens required to report the supplied cover. Warning: this function does not validate the input arguments.
function getMinReportingStakeInternal(IStore s, bytes32 coverKey) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
Source Code
function getMinReportingStakeInternal(IStore s, bytes32 coverKey) external view returns (uint256) {
uint256 fb = s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTING_MIN_FIRST_STAKE);
uint256 custom = s.getUintByKeys(ProtoUtilV1.NS_GOVERNANCE_REPORTING_MIN_FIRST_STAKE, coverKey);
return custom > 0 ? custom : fb;
}
Gets a cover's resolution timestamp. Warning: this function does not validate the cover and product key supplied.
function getResolutionTimestampInternal(IStore s, bytes32 coverKey, bytes32 productKey) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
Source Code
function getResolutionTimestampInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey
) external view returns (uint256) {
return s.getUintByKeys(ProtoUtilV1.NS_GOVERNANCE_RESOLUTION_TS, coverKey, productKey);
}
Gets the given cover incident's reporter.
Note that this keeps changing between "first reporter"
and "candidate reporter" until resolution is achieved.
Read More
Warning: this function does not validate the cover and product key supplied.
function getReporterInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) external view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 |
Source Code
function getReporterInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) external view returns (address) {
CoverUtilV1.ProductStatus status = s.getProductStatusOfInternal(coverKey, productKey, incidentDate);
bool incidentHappened = status == CoverUtilV1.ProductStatus.IncidentHappened || status == CoverUtilV1.ProductStatus.Claimable;
bytes32 prefix = incidentHappened ? ProtoUtilV1.NS_GOVERNANCE_REPORTING_WITNESS_YES : ProtoUtilV1.NS_GOVERNANCE_REPORTING_WITNESS_NO;
return s.getAddressByKeys(prefix, coverKey, productKey);
}
Returns stakes of the given cover product's incident. Warning: this function does not validate the input arguments.
function getStakesInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) public view
returns(yes uint256, no uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 | Enter incident date |
Source Code
function getStakesInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) public view returns (uint256 yes, uint256 no) {
yes = s.getUintByKey(_getIncidentOccurredStakesKey(coverKey, productKey, incidentDate));
no = s.getUintByKey(_getFalseReportingStakesKey(coverKey, productKey, incidentDate));
}
Hash key of the reporter for the given cover product. Warning: this function does not validate the input arguments.
function _getReporterKey(bytes32 coverKey, bytes32 productKey) private pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
Source Code
function _getReporterKey(bytes32 coverKey, bytes32 productKey) private pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_REPORTING_WITNESS_YES, coverKey, productKey));
}
Hash key of the stakes added under Incident Happened
camp for the given cover product.
Warning: this function does not validate the input arguments.
function _getIncidentOccurredStakesKey(bytes32 coverKey, bytes32 productKey, uint256 incidentDate) private pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 |
Source Code
function _getIncidentOccurredStakesKey(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) private pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_REPORTING_WITNESS_YES, coverKey, productKey, incidentDate));
}
Hash key of the claims payout given for the supplied cover product. Warning: this function does not validate the input arguments.
function _getClaimPayoutsKey(bytes32 coverKey, bytes32 productKey, uint256 incidentDate) private pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 |
Source Code
function _getClaimPayoutsKey(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) private pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_CLAIM_PAYOUTS, coverKey, productKey, incidentDate));
}
Hash key of the reassurance payout granted for the supplied cover product. Warning: this function does not validate the input arguments.
function _getReassurancePayoutKey(bytes32 coverKey, bytes32 productKey, uint256 incidentDate) private pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 |
Source Code
function _getReassurancePayoutKey(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) private pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_COVER_REASSURANCE_PAYOUT, coverKey, productKey, incidentDate));
}
Hash key of an individual's stakes added under Incident Happened
camp for the given cover product.
Warning: this function does not validate the input arguments.
function _getIndividualIncidentOccurredStakeKey(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, address account) private pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 | |
account | address |
Source Code
function _getIndividualIncidentOccurredStakeKey(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate,
address account
) private pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_REPORTING_STAKE_OWNED_YES, coverKey, productKey, incidentDate, account));
}
Hash key of the "candidate reporter" for the supplied cover product. Warning: this function does not validate the input arguments.
function _getDisputerKey(bytes32 coverKey, bytes32 productKey) private pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
Source Code
function _getDisputerKey(bytes32 coverKey, bytes32 productKey) private pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_REPORTING_WITNESS_NO, coverKey, productKey));
}
Hash key of the stakes added under False Reporting
camp for the given cover product.
Warning: this function does not validate the input arguments.
function _getFalseReportingStakesKey(bytes32 coverKey, bytes32 productKey, uint256 incidentDate) private pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 |
Source Code
function _getFalseReportingStakesKey(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) private pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_REPORTING_WITNESS_NO, coverKey, productKey, incidentDate));
}
Hash key of an individual's stakes added under False Reporting
camp for the given cover product.
Warning: this function does not validate the input arguments.
function _getIndividualFalseReportingStakeKey(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, address account) private pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 | |
account | address |
Source Code
function _getIndividualFalseReportingStakeKey(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate,
address account
) private pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_REPORTING_STAKE_OWNED_NO, coverKey, productKey, incidentDate, account));
}
Returns stakes of the given account for a cover product's incident. Warning: this function does not validate the input arguments.
function getStakesOfInternal(IStore s, address account, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) public view
returns(yes uint256, no uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
account | address | Specify the account to get stakes |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 | Enter incident date |
Source Code
function getStakesOfInternal(
IStore s,
address account,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) public view returns (uint256 yes, uint256 no) {
yes = s.getUintByKey(_getIndividualIncidentOccurredStakeKey(coverKey, productKey, incidentDate, account));
no = s.getUintByKey(_getIndividualFalseReportingStakeKey(coverKey, productKey, incidentDate, account));
}
Returns resolution info of the given account for a cover product's incident. Warning: this function does not validate the input arguments.
function getResolutionInfoForInternal(IStore s, address account, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) public view
returns(totalStakeInWinningCamp uint256, totalStakeInLosingCamp uint256, myStakeInWinningCamp uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
account | address | Specify the account to get stakes |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 | Enter incident date |
Source Code
function getResolutionInfoForInternal(
IStore s,
address account,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
)
public
view
returns (
uint256 totalStakeInWinningCamp,
uint256 totalStakeInLosingCamp,
uint256 myStakeInWinningCamp
)
{
(uint256 yes, uint256 no) = getStakesInternal(s, coverKey, productKey, incidentDate);
(uint256 myYes, uint256 myNo) = getStakesOfInternal(s, account, coverKey, productKey, incidentDate);
CoverUtilV1.ProductStatus decision = s.getProductStatusOfInternal(coverKey, productKey, incidentDate);
bool incidentHappened = decision == CoverUtilV1.ProductStatus.IncidentHappened || decision == CoverUtilV1.ProductStatus.Claimable;
totalStakeInWinningCamp = incidentHappened ? yes : no;
totalStakeInLosingCamp = incidentHappened ? no : yes;
myStakeInWinningCamp = incidentHappened ? myYes : myNo;
}
Returns unstake info of the given account for a cover product's incident. Warning: this function does not validate the input arguments.
function getUnstakeInfoForInternal(IStore s, address account, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) external view
returns(info struct IUnstakable.UnstakeInfoType)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
account | address | Specify the account to get stakes |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 | Enter incident date |
Source Code
function getUnstakeInfoForInternal(
IStore s,
address account,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) external view returns (IUnstakable.UnstakeInfoType memory info) {
(info.totalStakeInWinningCamp, info.totalStakeInLosingCamp, info.myStakeInWinningCamp) = getResolutionInfoForInternal(s, account, coverKey, productKey, incidentDate);
info.unstaken = getReportingUnstakenAmountInternal(s, account, coverKey, productKey, incidentDate);
require(info.myStakeInWinningCamp > 0, "Nothing to unstake");
uint256 rewardRatio = (info.myStakeInWinningCamp * ProtoUtilV1.MULTIPLIER) / info.totalStakeInWinningCamp;
uint256 reward = 0;
// Incident dates are reset when a reporting is finalized.
// This check ensures only the people who come to unstake
// before the finalization will receive rewards
if (s.getActiveIncidentDateInternal(coverKey, productKey) == incidentDate) {
// slither-disable-next-line divide-before-multiply
reward = (info.totalStakeInLosingCamp * rewardRatio) / ProtoUtilV1.MULTIPLIER;
}
require(getReportingBurnRateInternal(s) + getGovernanceReporterCommissionInternal(s) <= ProtoUtilV1.MULTIPLIER, "Invalid configuration");
info.toBurn = (reward * getReportingBurnRateInternal(s)) / ProtoUtilV1.MULTIPLIER;
info.toReporter = (reward * getGovernanceReporterCommissionInternal(s)) / ProtoUtilV1.MULTIPLIER;
info.myReward = reward - info.toBurn - info.toReporter;
}
Returns NPM already unstaken by the specified account for a cover incident. Warning: this function does not validate the input arguments.
function getReportingUnstakenAmountInternal(IStore s, address account, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) public view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
account | address | Specify the account to get stakes |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 | Enter incident date |
Source Code
function getReportingUnstakenAmountInternal(
IStore s,
address account,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) public view returns (uint256) {
bytes32 k = keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_UNSTAKEN, coverKey, productKey, incidentDate, account));
return s.getUintByKey(k);
}
function updateUnstakeDetailsInternal(IStore s, address account, bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 originalStake, uint256 reward, uint256 burned, uint256 reporterFee) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
account | address | |
coverKey | bytes32 | |
productKey | bytes32 | |
incidentDate | uint256 | |
originalStake | uint256 | |
reward | uint256 | |
burned | uint256 | |
reporterFee | uint256 |
Source Code
function updateUnstakeDetailsInternal(
IStore s,
address account,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate,
uint256 originalStake,
uint256 reward,
uint256 burned,
uint256 reporterFee
) external {
// Unstake timestamp of the account
bytes32 k = keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_UNSTAKE_TS, coverKey, productKey, incidentDate, account));
s.setUintByKey(k, block.timestamp); // solhint-disable-line
// Last unstake timestamp
k = keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_UNSTAKE_TS, coverKey, productKey, incidentDate));
s.setUintByKey(k, block.timestamp); // solhint-disable-line
// ---------------------------------------------------------------------
// Amount unstaken by the account
k = keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_UNSTAKEN, coverKey, productKey, incidentDate, account));
s.setUintByKey(k, originalStake);
// Amount unstaken by everyone
k = keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_UNSTAKEN, coverKey, productKey, incidentDate));
s.addUintByKey(k, originalStake);
// ---------------------------------------------------------------------
if (reward > 0) {
// Reward received by the account
k = keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_UNSTAKE_REWARD, coverKey, productKey, incidentDate, account));
s.setUintByKey(k, reward);
// Total reward received
k = keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_UNSTAKE_REWARD, coverKey, productKey, incidentDate));
s.addUintByKey(k, reward);
}
// ---------------------------------------------------------------------
if (burned > 0) {
// Total burned
k = keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_UNSTAKE_BURNED, coverKey, productKey, incidentDate));
s.addUintByKey(k, burned);
}
if (reporterFee > 0) {
// Total fee paid to the final reporter
k = keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_UNSTAKE_REPORTER_FEE, coverKey, productKey, incidentDate));
s.addUintByKey(k, reporterFee);
}
}
function _updateProductStatusBeforeResolutionInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) private nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
productKey | bytes32 | |
incidentDate | uint256 |
Source Code
function _updateProductStatusBeforeResolutionInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) private {
require(incidentDate > 0, "Invalid incident date");
uint256 yes = s.getUintByKey(_getIncidentOccurredStakesKey(coverKey, productKey, incidentDate));
uint256 no = s.getUintByKey(_getFalseReportingStakesKey(coverKey, productKey, incidentDate));
if (no > yes) {
s.setStatusInternal(coverKey, productKey, incidentDate, CoverUtilV1.ProductStatus.FalseReporting);
return;
}
s.setStatusInternal(coverKey, productKey, incidentDate, CoverUtilV1.ProductStatus.IncidentHappened);
}
Adds attestation to an incident report
function addAttestationInternal(IStore s, bytes32 coverKey, bytes32 productKey, address who, uint256 incidentDate, uint256 stake) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
productKey | bytes32 | |
who | address | |
incidentDate | uint256 | |
stake | uint256 |
Source Code
function addAttestationInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
address who,
uint256 incidentDate,
uint256 stake
) external {
mustNotExceedNpmThreshold(stake);
// Add individual stake of the reporter
s.addUintByKey(_getIndividualIncidentOccurredStakeKey(coverKey, productKey, incidentDate, who), stake);
// All "incident happened" camp witnesses combined
uint256 currentStake = s.getUintByKey(_getIncidentOccurredStakesKey(coverKey, productKey, incidentDate));
// No has reported yet, this is the first report
if (currentStake == 0) {
s.setAddressByKey(_getReporterKey(coverKey, productKey), who);
}
s.addUintByKey(_getIncidentOccurredStakesKey(coverKey, productKey, incidentDate), stake);
_updateProductStatusBeforeResolutionInternal(s, coverKey, productKey, incidentDate);
s.updateStateAndLiquidityInternal(coverKey);
}
Returns sum total of NPM staken under Incident Happened
camp.
Warning: this function does not validate the input arguments.
function getAttestationInternal(IStore s, bytes32 coverKey, bytes32 productKey, address who, uint256 incidentDate) external view
returns(myStake uint256, totalStake uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
who | address | Specify the account to get attestation info |
incidentDate | uint256 | Enter incident date |
Source Code
function getAttestationInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
address who,
uint256 incidentDate
) external view returns (uint256 myStake, uint256 totalStake) {
myStake = s.getUintByKey(_getIndividualIncidentOccurredStakeKey(coverKey, productKey, incidentDate, who));
totalStake = s.getUintByKey(_getIncidentOccurredStakesKey(coverKey, productKey, incidentDate));
}
Adds refutation to an incident report
function addRefutationInternal(IStore s, bytes32 coverKey, bytes32 productKey, address who, uint256 incidentDate, uint256 stake) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
productKey | bytes32 | |
who | address | |
incidentDate | uint256 | |
stake | uint256 |
Source Code
function addRefutationInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
address who,
uint256 incidentDate,
uint256 stake
) external {
mustNotExceedNpmThreshold(stake);
s.addUintByKey(_getIndividualFalseReportingStakeKey(coverKey, productKey, incidentDate, who), stake);
uint256 currentStake = s.getUintByKey(_getFalseReportingStakesKey(coverKey, productKey, incidentDate));
if (currentStake == 0) {
// The first reporter who disputed
s.setAddressByKey(_getDisputerKey(coverKey, productKey), who);
s.setBoolByKey(getHasDisputeKeyInternal(coverKey, productKey), true);
}
s.addUintByKey(_getFalseReportingStakesKey(coverKey, productKey, incidentDate), stake);
_updateProductStatusBeforeResolutionInternal(s, coverKey, productKey, incidentDate);
s.updateStateAndLiquidityInternal(coverKey);
}
Hash key of the "has dispute flag" for the specified cover product. Warning: this function does not validate the input arguments.
function getHasDisputeKeyInternal(bytes32 coverKey, bytes32 productKey) public pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
Source Code
function getHasDisputeKeyInternal(bytes32 coverKey, bytes32 productKey) public pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_REPORTING_HAS_A_DISPUTE, coverKey, productKey));
}
Hash key of the "has finalized flag" for the specified cover product. Warning: this function does not validate the input arguments.
function getHasFinalizedKeyInternal(bytes32 coverKey, bytes32 productKey, uint256 incidentDate) public pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 | Enter incident date |
Source Code
function getHasFinalizedKeyInternal(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) public pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_REPORTING_FINALIZATION, coverKey, productKey, incidentDate));
}
Returns sum total of NPM staken under False Reporting
camp.
Warning: this function does not validate the input arguments.
function getRefutationInternal(IStore s, bytes32 coverKey, bytes32 productKey, address who, uint256 incidentDate) external view
returns(myStake uint256, totalStake uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
who | address | Specify the account to get attestation info |
incidentDate | uint256 | Enter incident date |
Source Code
function getRefutationInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
address who,
uint256 incidentDate
) external view returns (uint256 myStake, uint256 totalStake) {
myStake = s.getUintByKey(_getIndividualFalseReportingStakeKey(coverKey, productKey, incidentDate, who));
totalStake = s.getUintByKey(_getFalseReportingStakesKey(coverKey, productKey, incidentDate));
}
Returns cooldown period. Cooldown period is a defense against collusion and last-block attacks. Warning: this function does not validate the input arguments.
function getCoolDownPeriodInternal(IStore s, bytes32 coverKey) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
Source Code
function getCoolDownPeriodInternal(IStore s, bytes32 coverKey) external view returns (uint256) {
uint256 fromKey = s.getUintByKeys(ProtoUtilV1.NS_RESOLUTION_COOL_DOWN_PERIOD, coverKey);
uint256 fallbackValue = s.getUintByKey(ProtoUtilV1.NS_RESOLUTION_COOL_DOWN_PERIOD);
return fromKey > 0 ? fromKey : fallbackValue;
}
The date and time prior to which a governance administrator may still initiate a "emergency resolution." Warning: this function does not validate the cover and product key supplied.
function getResolutionDeadlineInternal(IStore s, bytes32 coverKey, bytes32 productKey) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
Source Code
function getResolutionDeadlineInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey
) external view returns (uint256) {
return s.getUintByKeys(ProtoUtilV1.NS_RESOLUTION_DEADLINE, coverKey, productKey);
}
function addClaimPayoutsInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 claimed) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
productKey | bytes32 | |
incidentDate | uint256 | |
claimed | uint256 |
Source Code
function addClaimPayoutsInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate,
uint256 claimed
) external {
s.addUintByKey(_getClaimPayoutsKey(coverKey, productKey, incidentDate), claimed);
}
Returns the total amount of payouts awarded to claimants for this incident. Warning: this function does not validate the input arguments.
function getClaimPayoutsInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) public view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 | Enter incident date |
Source Code
function getClaimPayoutsInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) public view returns (uint256) {
return s.getUintByKey(_getClaimPayoutsKey(coverKey, productKey, incidentDate));
}
Returns the total amount of reassurance granted to vault for this incident. Warning: this function does not validate the input arguments.
function getReassurancePayoutInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) public view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 | Enter incident date |
Source Code
function getReassurancePayoutInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) public view returns (uint256) {
return s.getUintByKey(_getReassurancePayoutKey(coverKey, productKey, incidentDate));
}
function addReassurancePayoutInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 capitalized) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
productKey | bytes32 | |
incidentDate | uint256 | |
capitalized | uint256 |
Source Code
function addReassurancePayoutInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate,
uint256 capitalized
) external {
s.addUintByKey(_getReassurancePayoutKey(coverKey, productKey, incidentDate), capitalized);
}
Returns the remaining reassurance amount that can be transferred to the vault following the claim period but prior to finalisation. Warning: this function does not validate the input arguments.
function getReassuranceTransferrableInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 | Enter incident date |
Source Code
function getReassuranceTransferrableInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) external view returns (uint256) {
uint256 reassuranceRate = s.getReassuranceRateInternal(coverKey);
uint256 available = s.getReassuranceAmountInternal(coverKey);
uint256 reassurancePaid = getReassurancePayoutInternal(s, coverKey, productKey, incidentDate);
uint256 totalReassurance = available + reassurancePaid;
uint256 claimsPaid = getClaimPayoutsInternal(s, coverKey, productKey, incidentDate);
uint256 principal = claimsPaid <= totalReassurance ? claimsPaid : totalReassurance;
uint256 transferAmount = (principal * reassuranceRate) / ProtoUtilV1.MULTIPLIER;
return transferAmount - reassurancePaid;
}
function mustNotExceedNpmThreshold(uint256 amount) public pure
Arguments
Name | Type | Description |
---|---|---|
amount | uint256 |
Source Code
function mustNotExceedNpmThreshold(uint256 amount) public pure {
require(amount <= ProtoUtilV1.MAX_NPM_STAKE * 1 ether, "NPM stake is above threshold");
}
- 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