View Source: contracts/libraries/CoverUtilV1.sol
CoverUtilV1
Enums
enum ProductStatus {
Normal,
Stopped,
IncidentHappened,
FalseReporting,
Claimable
}
Constants & Variables
uint256 public constant REASSURANCE_WEIGHT_FALLBACK_VALUE;
uint256 public constant COVER_LAG_FALLBACK_VALUE;
- getCoverOwnerInternal(IStore s, bytes32 coverKey)
- getCoverCreationFeeInfoInternal(IStore s)
- getMinCoverCreationStakeInternal(IStore s)
- getCoverCreationDateInternal(IStore s, bytes32 coverKey)
- getMinStakeToAddLiquidityInternal(IStore s)
- getClaimPeriodInternal(IStore s, bytes32 coverKey)
- getCoverPoolSummaryInternal(IStore s, bytes32 coverKey, bytes32 productKey)
- getReassuranceWeightInternal(IStore s, bytes32 coverKey)
- getReassuranceAmountInternal(IStore s, bytes32 coverKey)
- getReassuranceRateInternal(IStore s, bytes32 coverKey)
- getReassuranceKeyInternal(bytes32 coverKey)
- getReassuranceRateKeyInternal(bytes32 coverKey)
- getReassuranceWeightKeyInternal(bytes32 coverKey)
- isCoverNormalInternal(IStore s, bytes32 coverKey)
- getProductStatusInternal(IStore s, bytes32 coverKey, bytes32 productKey)
- getProductStatusOfInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- getProductStatusOfKeyInternal(bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- getCoverLiquidityStakeKeyInternal(bytes32 coverKey)
- getLastDepositHeightKeyInternal(bytes32 coverKey)
- getCoverLiquidityStakeIndividualKeyInternal(bytes32 coverKey, address account)
- getBlacklistKeyInternal(bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- getTotalLiquidityUnderProtectionInternal(IStore s, bytes32 coverKey, uint256 precision)
- _getProducts(IStore s, bytes32 coverKey)
- getActiveLiquidityUnderProtectionInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 adjustPrecision)
- _getCurrentCommitment(IStore s, bytes32 coverKey, bytes32 productKey)
- _getFutureCommitments(IStore s, bytes32 coverKey, bytes32 productKey, uint256 excludedExpiryDate)
- setStatusInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate, enum CoverUtilV1.ProductStatus status)
- getExpiryDateInternal(uint256 today, uint256 coverDuration)
- _getNextMonthEndDate(uint256 date, uint256 monthsToAdd)
- _getMonthEndDate(uint256 date)
- getCxTokenByExpiryDateInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 expiryDate)
- checkIfProductRequiresWhitelistInternal(IStore s, bytes32 coverKey, bytes32 productKey)
- checkIfRequiresWhitelistInternal(IStore s, bytes32 coverKey)
- supportsProductsInternal(IStore s, bytes32 coverKey)
- isValidProductInternal(IStore s, bytes32 coverKey, bytes32 productKey)
- isActiveProductInternal(IStore s, bytes32 coverKey, bytes32 productKey)
- disablePolicyInternal(IStore s, bytes32 coverKey, bytes32 productKey, bool status)
- isPolicyDisabledInternal(IStore s, bytes32 coverKey, bytes32 productKey)
- getPolicyDisabledKeyInternal(bytes32 coverKey, bytes32 productKey)
- getActiveIncidentDateInternal(IStore s, bytes32 coverKey, bytes32 productKey)
- getCoverageLagInternal(IStore s, bytes32 coverKey)
Returns the given cover's owner. Warning: this function does not validate the cover key supplied.
function getCoverOwnerInternal(IStore s, bytes32 coverKey) external view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
Source Code
function getCoverOwnerInternal(IStore s, bytes32 coverKey) external view returns (address) {
return s.getAddressByKeys(ProtoUtilV1.NS_COVER_OWNER, coverKey);
}
Returns cover creation fee information.
function getCoverCreationFeeInfoInternal(IStore s) external view
returns(fee uint256, minCoverCreationStake uint256, minStakeToAddLiquidity uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
Returns
fee Returns the amount of NPM tokens you need to pay to create a new cover
Source Code
function getCoverCreationFeeInfoInternal(IStore s)
external
view
returns (
uint256 fee,
uint256 minCoverCreationStake,
uint256 minStakeToAddLiquidity
)
{
fee = s.getUintByKey(ProtoUtilV1.NS_COVER_CREATION_FEE);
minCoverCreationStake = getMinCoverCreationStakeInternal(s);
minStakeToAddLiquidity = getMinStakeToAddLiquidityInternal(s);
}
Returns minimum NPM stake to create a new cover.
function getMinCoverCreationStakeInternal(IStore s) public view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
Source Code
function getMinCoverCreationStakeInternal(IStore s) public view returns (uint256) {
return s.getUintByKey(ProtoUtilV1.NS_COVER_CREATION_MIN_STAKE);
}
Returns a cover's creation date Warning: this function does not validate the cover key supplied.
function getCoverCreationDateInternal(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 getCoverCreationDateInternal(IStore s, bytes32 coverKey) external view returns (uint256) {
return s.getUintByKeys(ProtoUtilV1.NS_COVER_CREATION_DATE, coverKey);
}
Returns minimum NPM stake to add liquidity.
function getMinStakeToAddLiquidityInternal(IStore s) public view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
Source Code
function getMinStakeToAddLiquidityInternal(IStore s) public view returns (uint256) {
return s.getUintByKey(ProtoUtilV1.NS_COVER_LIQUIDITY_MIN_STAKE);
}
Gets claim period/duration of the given cover. Warning: this function does not validate the cover key supplied.
function getClaimPeriodInternal(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 getClaimPeriodInternal(IStore s, bytes32 coverKey) external view returns (uint256) {
uint256 fromKey = s.getUintByKeys(ProtoUtilV1.NS_CLAIM_PERIOD, coverKey);
uint256 fallbackValue = s.getUintByKey(ProtoUtilV1.NS_CLAIM_PERIOD);
return fromKey > 0 ? fromKey : fallbackValue;
}
Returns a summary of the given cover pool. Warning: this function does not validate the cover key supplied.
function getCoverPoolSummaryInternal(IStore s, bytes32 coverKey, bytes32 productKey) external view
returns(summary struct IPolicy.CoverPoolSummaryType)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
productKey | bytes32 |
Source Code
function getCoverPoolSummaryInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey
) external view returns (IPolicy.CoverPoolSummaryType memory summary) {
uint256 precision = s.getStablecoinPrecisionInternal();
summary.totalAmountInPool = s.getStablecoinOwnedByVaultInternal(coverKey); // precision: stablecoin
summary.totalCommitment = getActiveLiquidityUnderProtectionInternal(s, coverKey, productKey, precision); // <-- adjusted precision
summary.reassuranceAmount = getReassuranceAmountInternal(s, coverKey); // precision: stablecoin
summary.reassurancePoolWeight = getReassuranceWeightInternal(s, coverKey);
summary.productCount = s.countBytes32ArrayByKeys(ProtoUtilV1.NS_COVER_PRODUCT, coverKey);
summary.leverage = s.getUintByKeys(ProtoUtilV1.NS_COVER_LEVERAGE_FACTOR, coverKey);
summary.productCapitalEfficiency = s.getUintByKeys(ProtoUtilV1.NS_COVER_PRODUCT_EFFICIENCY, coverKey, productKey);
}
Gets the reassurance weight of a given cover key. Warning: this function does not validate the cover key supplied.
function getReassuranceWeightInternal(IStore s, bytes32 coverKey) public view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Provide store instance |
coverKey | bytes32 | Enter the cover for which you want to obtain the reassurance weight for. |
Returns
If reassurance weight value wasn't set for the specified cover pool,
the global value will be returned.
If global value, too, isn't available, a fallback value of REASSURANCE_WEIGHT_FALLBACK_VALUE
is returned.
Source Code
function getReassuranceWeightInternal(IStore s, bytes32 coverKey) public view returns (uint256) {
uint256 setForTheCoverPool = s.getUintByKey(getReassuranceWeightKeyInternal(coverKey));
if (setForTheCoverPool > 0) {
return setForTheCoverPool;
}
// Globally set value: not set for any specific cover
uint256 setGlobally = s.getUintByKey(getReassuranceWeightKeyInternal(0));
if (setGlobally > 0) {
return setGlobally;
}
return REASSURANCE_WEIGHT_FALLBACK_VALUE;
}
Gets the reassurance amount of the specified cover contract Warning: this function does not validate the cover key supplied.
function getReassuranceAmountInternal(IStore s, bytes32 coverKey) public view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | Enter the cover key |
Source Code
function getReassuranceAmountInternal(IStore s, bytes32 coverKey) public view returns (uint256) {
return s.getUintByKey(getReassuranceKeyInternal(coverKey));
}
Returns reassurance rate of the specified cover key. When a cover is finalized after claims payout, a portion of the reassurance fund (if available) is transferred to the cover liquidity pool. If the reassurance rate is 25%, either 25% of the reassurance pool or 25% of the suffered loss is transferred prior to finalization, whichever is less. Warning: this function does not validate the cover key supplied.
function getReassuranceRateInternal(IStore s, bytes32 coverKey) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store |
coverKey | bytes32 | Enter cover key |
Source Code
function getReassuranceRateInternal(IStore s, bytes32 coverKey) external view returns (uint256) {
uint256 rate = s.getUintByKey(getReassuranceRateKeyInternal(coverKey));
if (rate > 0) {
return rate;
}
// Default: 25%
return 2500;
}
Hash key of the reassurance for the given cover. Warning: this function does not validate the cover key supplied.
function getReassuranceKeyInternal(bytes32 coverKey) public pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
Source Code
function getReassuranceKeyInternal(bytes32 coverKey) public pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_COVER_REASSURANCE, coverKey));
}
Hash key of the reassurance rate for the given cover. Warning: this function does not validate the cover key supplied.
function getReassuranceRateKeyInternal(bytes32 coverKey) public pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
Source Code
function getReassuranceRateKeyInternal(bytes32 coverKey) public pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_COVER_REASSURANCE_RATE, coverKey));
}
Hash key of the reassurance weight for the given cover. Warning: this function does not validate the cover key supplied.
function getReassuranceWeightKeyInternal(bytes32 coverKey) public pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
Source Code
function getReassuranceWeightKeyInternal(bytes32 coverKey) public pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_COVER_REASSURANCE_WEIGHT, coverKey));
}
Indicates whether the specified cover and all associated products are "normal".
function isCoverNormalInternal(IStore s, bytes32 coverKey) external view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
Returns
Returns false if any associated product isn't normal.
Source Code
function isCoverNormalInternal(IStore s, bytes32 coverKey) external view returns (bool) {
uint256 incidentDate;
bool supportsProducts = supportsProductsInternal(s, coverKey);
if (supportsProducts == false) {
incidentDate = getActiveIncidentDateInternal(s, coverKey, ProtoUtilV1.PRODUCT_KEY_INTENTIONALLY_EMPTY);
return getProductStatusOfInternal(s, coverKey, ProtoUtilV1.PRODUCT_KEY_INTENTIONALLY_EMPTY, incidentDate) == ProductStatus.Normal;
}
bytes32[] memory products = _getProducts(s, coverKey);
for (uint256 i = 0; i < products.length; i++) {
incidentDate = getActiveIncidentDateInternal(s, coverKey, products[i]);
bool isNormal = getProductStatusOfInternal(s, coverKey, products[i], incidentDate) == ProductStatus.Normal;
if (!isNormal) {
return false;
}
}
return true;
}
Gets product status of the given cover product. 0 - normal 1 - stopped, can not purchase covers or add liquidity 2 - reporting, incident happened 3 - reporting, false reporting 4 - claimable, claims accepted for payout Warning: this function does not validate the cover and product key supplied.
function getProductStatusInternal(IStore s, bytes32 coverKey, bytes32 productKey) public view
returns(enum CoverUtilV1.ProductStatus)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
Source Code
function getProductStatusInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey
) public view returns (ProductStatus) {
uint256 incidentDate = getActiveIncidentDateInternal(s, coverKey, productKey);
return getProductStatusOfInternal(s, coverKey, productKey, incidentDate);
}
Returns current status a given cover product as ProductStatus
.
Warning: this function does not validate the cover and product key supplied.
function getProductStatusOfInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) public view
returns(enum CoverUtilV1.ProductStatus)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 |
Source Code
function getProductStatusOfInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) public view returns (ProductStatus) {
uint256 value = s.getUintByKey(getProductStatusOfKeyInternal(coverKey, productKey, incidentDate));
return ProductStatus(value);
}
Hash key of the product status of (the given cover, product, and incident date) for historical significance. This must not be reset during finalization. Warning: this function does not validate the input arguments.
function getProductStatusOfKeyInternal(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 getProductStatusOfKeyInternal(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) public pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_COVER_STATUS, coverKey, productKey, incidentDate));
}
Hash key of the stakes (collectively added by liquidity providers) of the given cover. Warning: this function does not validate the cover key supplied.
function getCoverLiquidityStakeKeyInternal(bytes32 coverKey) external pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
Source Code
function getCoverLiquidityStakeKeyInternal(bytes32 coverKey) external pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_COVER_LIQUIDITY_STAKE, coverKey));
}
Hash key of the last stablecoin deposit of the given cover. There must be a couple of block heights as an offset before withdrawal can be performed (even during a withdrawal window). Warning: this function does not validate the cover key supplied.
function getLastDepositHeightKeyInternal(bytes32 coverKey) external pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
Source Code
function getLastDepositHeightKeyInternal(bytes32 coverKey) external pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_VAULT_DEPOSIT_HEIGHTS, coverKey));
}
Hash key of the individual stake (added by an LP) for the given cover and account. Warning: this function does not validate the input arguments.
function getCoverLiquidityStakeIndividualKeyInternal(bytes32 coverKey, address account) external pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
account | address | Enter the account to obtain the hash key |
Source Code
function getCoverLiquidityStakeIndividualKeyInternal(bytes32 coverKey, address account) external pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_COVER_LIQUIDITY_STAKE, coverKey, account));
}
Hash key of the blacklisted accounts for the given cover. Blacklisted accounts are forbidden to receive claims payout. Warning: this function does not validate the input arguments.
function getBlacklistKeyInternal(bytes32 coverKey, bytes32 productKey, uint256 incidentDate) external pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
incidentDate | uint256 | Enter the trigger incident date |
Source Code
function getBlacklistKeyInternal(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) external pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_COVER_CLAIM_BLACKLIST, coverKey, productKey, incidentDate));
}
Returns the total liquidity committed/under active protection. If the cover is a diversified pool, returns sum total of all products' commitments. Simply put, commitments are the "totalSupply" of cxTokens that haven't yet expired. Note that cxTokens can be precise to 18 decimal places. If the protocol's stablecoin has a different precision, you must tell this function explicitly when you call it.
function getTotalLiquidityUnderProtectionInternal(IStore s, bytes32 coverKey, uint256 precision) external view
returns(total uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
precision | uint256 | Specify the protocol stablecoin precision. |
Source Code
function getTotalLiquidityUnderProtectionInternal(
IStore s,
bytes32 coverKey,
uint256 precision
) external view returns (uint256 total) {
bool supportsProducts = supportsProductsInternal(s, coverKey);
if (supportsProducts == false) {
return getActiveLiquidityUnderProtectionInternal(s, coverKey, ProtoUtilV1.PRODUCT_KEY_INTENTIONALLY_EMPTY, precision);
}
bytes32[] memory products = _getProducts(s, coverKey);
for (uint256 i = 0; i < products.length; i++) {
total += getActiveLiquidityUnderProtectionInternal(s, coverKey, products[i], precision);
}
}
function _getProducts(IStore s, bytes32 coverKey) private view
returns(products bytes32[])
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 |
Source Code
function _getProducts(IStore s, bytes32 coverKey) private view returns (bytes32[] memory products) {
return s.getBytes32ArrayByKeys(ProtoUtilV1.NS_COVER_PRODUCT, coverKey);
}
Returns the total liquidity committed/under active protection. If the cover is a diversified pool, you must a provide product key. Simply put, commitments are the "totalSupply" of cxTokens that haven't yet expired. Note that cxTokens are precise to 18 decimal places. If the protocol's stablecoin has a different precision, you must tell this function explicitly when you call it.
function getActiveLiquidityUnderProtectionInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 adjustPrecision) public view
returns(total uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
adjustPrecision | uint256 | Specify the protocol stablecoin precision. |
Source Code
function getActiveLiquidityUnderProtectionInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 adjustPrecision
) public view returns (uint256 total) {
(uint256 current, uint256 expiryDate) = _getCurrentCommitment(s, coverKey, productKey);
uint256 future = _getFutureCommitments(s, coverKey, productKey, expiryDate);
total = current + future;
// @caution:
// Adjusting precision results in truncation and data loss.
//
// Can also open a can of worms if the protocol stablecoin
// address needs to be updated in the future.
total = (total * adjustPrecision) / ProtoUtilV1.CXTOKEN_PRECISION;
}
Gets current commitment of a given cover product.
If there is no incident, should return zero.
function _getCurrentCommitment(IStore s, bytes32 coverKey, bytes32 productKey) private view
returns(amount uint256, expiryDate uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
Returns
amount The current commitment amount.
Source Code
function _getCurrentCommitment(
IStore s,
bytes32 coverKey,
bytes32 productKey
) private view returns (uint256 amount, uint256 expiryDate) {
uint256 incidentDateIfAny = getActiveIncidentDateInternal(s, coverKey, productKey);
// There isn't any incident for this cover
// and therefore no need to pay
if (incidentDateIfAny == 0) {
return (0, 0);
}
expiryDate = _getMonthEndDate(incidentDateIfAny);
ICxToken cxToken = ICxToken(getCxTokenByExpiryDateInternal(s, coverKey, productKey, expiryDate));
if (address(cxToken) != address(0)) {
amount = cxToken.totalSupply();
}
}
Gets future commitment of a given cover product.
function _getFutureCommitments(IStore s, bytes32 coverKey, bytes32 productKey, uint256 excludedExpiryDate) private view
returns(sum uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
excludedExpiryDate | uint256 | Enter expiry date (from current commitment) to exclude |
Returns
sum The total commitment amount.
Source Code
function _getFutureCommitments(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 excludedExpiryDate
) private view returns (uint256 sum) {
for (uint256 i = 0; i <= ProtoUtilV1.MAX_POLICY_DURATION; i++) {
uint256 expiryDate = _getNextMonthEndDate(block.timestamp, i); // solhint-disable-line
if (expiryDate == excludedExpiryDate || expiryDate <= block.timestamp) {
// solhint-disable-previous-line
continue;
}
ICxToken cxToken = ICxToken(getCxTokenByExpiryDateInternal(s, coverKey, productKey, expiryDate));
if (address(cxToken) != address(0)) {
sum += cxToken.totalSupply();
}
}
}
Sets the current status of a given cover 0 - normal 1 - stopped, can not purchase covers or add liquidity 2 - reporting, incident happened 3 - reporting, false reporting 4 - claimable, claims accepted for payout
function setStatusInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate, enum CoverUtilV1.ProductStatus status) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
productKey | bytes32 | |
incidentDate | uint256 | |
status | enum CoverUtilV1.ProductStatus |
Source Code
function setStatusInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate,
ProductStatus status
) external {
s.setUintByKey(getProductStatusOfKeyInternal(coverKey, productKey, incidentDate), uint256(status));
}
Gets the expiry date based on cover duration
function getExpiryDateInternal(uint256 today, uint256 coverDuration) external pure
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
today | uint256 | Enter the current timestamp |
coverDuration | uint256 | Enter the number of months to cover. Accepted values: 1-3. |
Source Code
function getExpiryDateInternal(uint256 today, uint256 coverDuration) external pure returns (uint256) {
// Get the day of the month
(, , uint256 day) = BokkyPooBahsDateTimeLibrary.timestampToDate(today);
// Cover duration of 1 month means current month
// unless today is the 25th calendar day or later
uint256 monthToAdd = coverDuration - 1;
if (day >= 25) {
// Add one month
monthToAdd += 1;
}
return _getNextMonthEndDate(today, monthToAdd);
}
function _getNextMonthEndDate(uint256 date, uint256 monthsToAdd) private pure
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
date | uint256 | |
monthsToAdd | uint256 |
Source Code
function _getNextMonthEndDate(uint256 date, uint256 monthsToAdd) private pure returns (uint256) {
uint256 futureDate = BokkyPooBahsDateTimeLibrary.addMonths(date, monthsToAdd);
return _getMonthEndDate(futureDate);
}
function _getMonthEndDate(uint256 date) private pure
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
date | uint256 |
Source Code
function _getMonthEndDate(uint256 date) private pure returns (uint256) {
// Get the year and month from the date
(uint256 year, uint256 month, ) = BokkyPooBahsDateTimeLibrary.timestampToDate(date);
// Count the total number of days of that month and year
uint256 daysInMonth = BokkyPooBahsDateTimeLibrary._getDaysInMonth(year, month);
// Get the month end date
return BokkyPooBahsDateTimeLibrary.timestampFromDateTime(year, month, daysInMonth, 23, 59, 59);
}
Returns the given cover product's cxToken by its expiry date (if available). Warning: this function does not validate the input arguments.
function getCxTokenByExpiryDateInternal(IStore s, bytes32 coverKey, bytes32 productKey, uint256 expiryDate) public view
returns(cxToken address)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | Specify store instance |
coverKey | bytes32 | Enter cover key |
productKey | bytes32 | Enter product key |
expiryDate | uint256 | Enter cxToken's expiry date |
Source Code
function getCxTokenByExpiryDateInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
uint256 expiryDate
) public view returns (address cxToken) {
bytes32 k = keccak256(abi.encodePacked(ProtoUtilV1.NS_COVER_CXTOKEN, coverKey, productKey, expiryDate));
cxToken = s.getAddress(k);
}
function checkIfProductRequiresWhitelistInternal(IStore s, bytes32 coverKey, bytes32 productKey) external view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
productKey | bytes32 |
Source Code
function checkIfProductRequiresWhitelistInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey
) external view returns (bool) {
return s.getBoolByKeys(ProtoUtilV1.NS_COVER_REQUIRES_WHITELIST, coverKey, productKey);
}
function checkIfRequiresWhitelistInternal(IStore s, bytes32 coverKey) external view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 |
Source Code
function checkIfRequiresWhitelistInternal(IStore s, bytes32 coverKey) external view returns (bool) {
return s.getBoolByKeys(ProtoUtilV1.NS_COVER_REQUIRES_WHITELIST, coverKey);
}
function supportsProductsInternal(IStore s, bytes32 coverKey) public view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 |
Source Code
function supportsProductsInternal(IStore s, bytes32 coverKey) public view returns (bool) {
return s.getBoolByKeys(ProtoUtilV1.NS_COVER_SUPPORTS_PRODUCTS, coverKey);
}
function isValidProductInternal(IStore s, bytes32 coverKey, bytes32 productKey) external view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
productKey | bytes32 |
Source Code
function isValidProductInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey
) external view returns (bool) {
return s.getBoolByKeys(ProtoUtilV1.NS_COVER_PRODUCT, coverKey, productKey);
}
function isActiveProductInternal(IStore s, bytes32 coverKey, bytes32 productKey) external view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
productKey | bytes32 |
Source Code
function isActiveProductInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey
) external view returns (bool) {
return s.getUintByKeys(ProtoUtilV1.NS_COVER_PRODUCT, coverKey, productKey) == 1;
}
function disablePolicyInternal(IStore s, bytes32 coverKey, bytes32 productKey, bool status) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
productKey | bytes32 | |
status | bool |
Source Code
function disablePolicyInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey,
bool status
) external {
bytes32 key = getPolicyDisabledKeyInternal(coverKey, productKey);
s.setBoolByKey(key, status);
}
function isPolicyDisabledInternal(IStore s, bytes32 coverKey, bytes32 productKey) external view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
productKey | bytes32 |
Source Code
function isPolicyDisabledInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey
) external view returns (bool) {
bytes32 key = getPolicyDisabledKeyInternal(coverKey, productKey);
return s.getBoolByKey(key);
}
Hash key of the "disabled policy flag" for the given cover product. Warning: this function does not validate the cover and product key supplied.
function getPolicyDisabledKeyInternal(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 getPolicyDisabledKeyInternal(bytes32 coverKey, bytes32 productKey) public pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_POLICY_DISABLED, coverKey, productKey));
}
Gets the latest and "active" incident date of a cover product. Note that after "resolve" is invoked, incident date is reset. Warning: this function does not validate the cover and product key supplied.
function getActiveIncidentDateInternal(IStore s, bytes32 coverKey, bytes32 productKey) public 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 getActiveIncidentDateInternal(
IStore s,
bytes32 coverKey,
bytes32 productKey
) public view returns (uint256) {
return s.getUintByKeys(ProtoUtilV1.NS_GOVERNANCE_REPORTING_INCIDENT_DATE, coverKey, productKey);
}
function getCoverageLagInternal(IStore s, bytes32 coverKey) internal view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 |
Source Code
function getCoverageLagInternal(IStore s, bytes32 coverKey) internal view returns (uint256) {
uint256 custom = s.getUintByKeys(ProtoUtilV1.NS_COVERAGE_LAG, coverKey);
// Custom means set for this exact cover
if (custom > 0) {
return custom;
}
// Global means set for all covers (without specifying a cover key)
uint256 global = s.getUintByKey(ProtoUtilV1.NS_COVERAGE_LAG);
if (global > 0) {
return global;
}
// Fallback means the default option
return COVER_LAG_FALLBACK_VALUE;
}
- 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