Skip to content

Latest commit

 

History

History
1581 lines (1250 loc) · 46 KB

CoverUtilV1.md

File metadata and controls

1581 lines (1250 loc) · 46 KB

CoverUtilV1.sol

View Source: contracts/libraries/CoverUtilV1.sol

CoverUtilV1

Enums

ProductStatus

enum ProductStatus {
 Normal,
 Stopped,
 IncidentHappened,
 FalseReporting,
 Claimable
}

Contract Members

Constants & Variables

uint256 public constant REASSURANCE_WEIGHT_FALLBACK_VALUE;
uint256 public constant COVER_LAG_FALLBACK_VALUE;

Functions

getCoverOwnerInternal

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);
  }

getCoverCreationFeeInfoInternal

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);
  }

getMinCoverCreationStakeInternal

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);
  }

getCoverCreationDateInternal

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);
  }

getMinStakeToAddLiquidityInternal

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);
  }

getClaimPeriodInternal

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;
  }

getCoverPoolSummaryInternal

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);
  }

getReassuranceWeightInternal

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;
  }

getReassuranceAmountInternal

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));
  }

getReassuranceRateInternal

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;
  }

getReassuranceKeyInternal

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));
  }

getReassuranceRateKeyInternal

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));
  }

getReassuranceWeightKeyInternal

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));
  }

isCoverNormalInternal

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;
  }

getProductStatusInternal

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);
  }

getProductStatusOfInternal

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);
  }

getProductStatusOfKeyInternal

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));
  }

getCoverLiquidityStakeKeyInternal

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));
  }

getLastDepositHeightKeyInternal

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));
  }

getCoverLiquidityStakeIndividualKeyInternal

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));
  }

getBlacklistKeyInternal

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));
  }

getTotalLiquidityUnderProtectionInternal

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);
    }
  }

_getProducts

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);
  }

getActiveLiquidityUnderProtectionInternal

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;
  }

_getCurrentCommitment

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();
    }
  }

_getFutureCommitments

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();
      }
    }
  }

setStatusInternal

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));
  }

getExpiryDateInternal

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);
  }

_getNextMonthEndDate

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);
  }

_getMonthEndDate

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);
  }

getCxTokenByExpiryDateInternal

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);
  }

checkIfProductRequiresWhitelistInternal

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);
  }

checkIfRequiresWhitelistInternal

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);
  }

supportsProductsInternal

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);
  }

isValidProductInternal

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);
  }

isActiveProductInternal

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;
  }

disablePolicyInternal

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);
  }

isPolicyDisabledInternal

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);
  }

getPolicyDisabledKeyInternal

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));
  }

getActiveIncidentDateInternal

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);
  }

getCoverageLagInternal

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;
  }

Contracts