Skip to content

Latest commit

 

History

History
1651 lines (1312 loc) · 45.3 KB

ValidationLibV1.md

File metadata and controls

1651 lines (1312 loc) · 45.3 KB

ValidationLibV1.sol

View Source: contracts/libraries/ValidationLibV1.sol

ValidationLibV1

Functions

mustNotBePaused

Reverts if the protocol is paused

function mustNotBePaused(IStore s) public view

Arguments

Name Type Description
s IStore
Source Code
function mustNotBePaused(IStore s) public view {
    address protocol = s.getProtocolAddressInternal();
    require(IPausable(protocol).paused() == false, "Protocol is paused");
  }

mustEnsureAllProductsAreNormal

Reverts if the cover or any of the cover's product is not normal.

function mustEnsureAllProductsAreNormal(IStore s, bytes32 coverKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32 Enter the cover key to check
Source Code
function mustEnsureAllProductsAreNormal(IStore s, bytes32 coverKey) external view {
    require(s.getBoolByKeys(ProtoUtilV1.NS_COVER, coverKey), "Cover does not exist");
    require(s.isCoverNormalInternal(coverKey) == true, "Status not normal");
  }

mustHaveNormalProductStatus

Reverts if the key does not resolve in a valid cover contract or if the cover is under governance.

function mustHaveNormalProductStatus(IStore s, bytes32 coverKey, bytes32 productKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32 Enter the cover key to check
productKey bytes32 Enter the product key to check
Source Code
function mustHaveNormalProductStatus(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) external view {
    require(s.getBoolByKeys(ProtoUtilV1.NS_COVER, coverKey), "Cover does not exist");
    require(s.getProductStatusInternal(coverKey, productKey) == CoverUtilV1.ProductStatus.Normal, "Status not normal");
  }

mustBeValidCoverKey

Reverts if the key does not resolve in a valid cover contract.

function mustBeValidCoverKey(IStore s, bytes32 coverKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32 Enter the cover key to check
Source Code
function mustBeValidCoverKey(IStore s, bytes32 coverKey) external view {
    require(s.getBoolByKeys(ProtoUtilV1.NS_COVER, coverKey), "Cover does not exist");
  }

mustSupportProducts

Reverts if the cover does not support creating products.

function mustSupportProducts(IStore s, bytes32 coverKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32 Enter the cover key to check
Source Code
function mustSupportProducts(IStore s, bytes32 coverKey) external view {
    require(s.supportsProductsInternal(coverKey), "Does not have products");
  }

mustBeValidProduct

Reverts if the key does not resolve in a valid product of a cover contract.

function mustBeValidProduct(IStore s, bytes32 coverKey, bytes32 productKey) public view

Arguments

Name Type Description
s IStore
coverKey bytes32 Enter the cover key to check
productKey bytes32 Enter the cover key to check
Source Code
function mustBeValidProduct(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) public view {
    require(s.isValidProductInternal(coverKey, productKey), "Product does not exist");
  }

mustBeActiveProduct

Reverts if the key resolves in an expired product.

function mustBeActiveProduct(IStore s, bytes32 coverKey, bytes32 productKey) public view

Arguments

Name Type Description
s IStore
coverKey bytes32 Enter the cover key to check
productKey bytes32 Enter the cover key to check
Source Code
function mustBeActiveProduct(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) public view {
    require(s.isActiveProductInternal(coverKey, productKey), "Product retired or deleted");
  }

mustBeCoverOwner

Reverts if the sender is not the cover owner

function mustBeCoverOwner(IStore s, bytes32 coverKey, address sender) public view

Arguments

Name Type Description
s IStore ender The msg.sender value
coverKey bytes32 Enter the cover key to check
sender address The msg.sender value
Source Code
function mustBeCoverOwner(
    IStore s,
    bytes32 coverKey,
    address sender
  ) public view {
    bool isCoverOwner = s.getCoverOwnerInternal(coverKey) == sender;
    require(isCoverOwner, "Forbidden");
  }

mustBeCoverOwnerOrCoverContract

Reverts if the sender is not the cover owner or the cover contract

function mustBeCoverOwnerOrCoverContract(IStore s, bytes32 coverKey, address sender) external view

Arguments

Name Type Description
s IStore ender The msg.sender value
coverKey bytes32 Enter the cover key to check
sender address The msg.sender value
Source Code
function mustBeCoverOwnerOrCoverContract(
    IStore s,
    bytes32 coverKey,
    address sender
  ) external view {
    bool isCoverOwner = s.getCoverOwnerInternal(coverKey) == sender;
    bool isCoverContract = address(s.getCoverContract()) == sender;

    require(isCoverOwner || isCoverContract, "Forbidden");
  }

senderMustBeCoverOwnerOrAdmin

function senderMustBeCoverOwnerOrAdmin(IStore s, bytes32 coverKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
Source Code
function senderMustBeCoverOwnerOrAdmin(IStore s, bytes32 coverKey) external view {
    if (AccessControlLibV1.hasAccessInternal(s, AccessControlLibV1.NS_ROLES_ADMIN, msg.sender) == false) {
      mustBeCoverOwner(s, coverKey, msg.sender);
    }
  }

senderMustBePolicyContract

function senderMustBePolicyContract(IStore s) external view

Arguments

Name Type Description
s IStore
Source Code
function senderMustBePolicyContract(IStore s) external view {
    s.senderMustBeExactContract(ProtoUtilV1.CNS_COVER_POLICY);
  }

senderMustBePolicyManagerContract

function senderMustBePolicyManagerContract(IStore s) external view

Arguments

Name Type Description
s IStore
Source Code
function senderMustBePolicyManagerContract(IStore s) external view {
    s.senderMustBeExactContract(ProtoUtilV1.CNS_COVER_POLICY_MANAGER);
  }

senderMustBeCoverContract

function senderMustBeCoverContract(IStore s) external view

Arguments

Name Type Description
s IStore
Source Code
function senderMustBeCoverContract(IStore s) external view {
    s.senderMustBeExactContract(ProtoUtilV1.CNS_COVER);
  }

senderMustBeVaultContract

function senderMustBeVaultContract(IStore s, bytes32 coverKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
Source Code
function senderMustBeVaultContract(IStore s, bytes32 coverKey) external view {
    address vault = s.getVaultAddress(coverKey);
    require(msg.sender == vault, "Forbidden");
  }

senderMustBeGovernanceContract

function senderMustBeGovernanceContract(IStore s) external view

Arguments

Name Type Description
s IStore
Source Code
function senderMustBeGovernanceContract(IStore s) external view {
    s.senderMustBeExactContract(ProtoUtilV1.CNS_GOVERNANCE);
  }

senderMustBeClaimsProcessorContract

function senderMustBeClaimsProcessorContract(IStore s) external view

Arguments

Name Type Description
s IStore
Source Code
function senderMustBeClaimsProcessorContract(IStore s) external view {
    s.senderMustBeExactContract(ProtoUtilV1.CNS_CLAIM_PROCESSOR);
  }

callerMustBeClaimsProcessorContract

function callerMustBeClaimsProcessorContract(IStore s, address caller) external view

Arguments

Name Type Description
s IStore
caller address
Source Code
function callerMustBeClaimsProcessorContract(IStore s, address caller) external view {
    s.callerMustBeExactContract(ProtoUtilV1.CNS_CLAIM_PROCESSOR, caller);
  }

senderMustBeStrategyContract

function senderMustBeStrategyContract(IStore s) external view

Arguments

Name Type Description
s IStore
Source Code
function senderMustBeStrategyContract(IStore s) external view {
    bool senderIsStrategyContract = s.getBoolByKey(_getIsActiveStrategyKey(msg.sender));
    require(senderIsStrategyContract == true, "Not a strategy contract");
  }

callerMustBeStrategyContract

function callerMustBeStrategyContract(IStore s, address caller) public view

Arguments

Name Type Description
s IStore
caller address
Source Code
function callerMustBeStrategyContract(IStore s, address caller) public view {
    bool isActive = s.getBoolByKey(_getIsActiveStrategyKey(caller));
    bool wasDisabled = s.getBoolByKey(_getIsDisabledStrategyKey(caller));

    require(isActive == true || wasDisabled == true, "Not a strategy contract");
  }

callerMustBeSpecificStrategyContract

function callerMustBeSpecificStrategyContract(IStore s, address caller, bytes32 strategyName) external view

Arguments

Name Type Description
s IStore
caller address
strategyName bytes32
Source Code
function callerMustBeSpecificStrategyContract(
    IStore s,
    address caller,
    bytes32 strategyName
  ) external view {
    callerMustBeStrategyContract(s, caller);
    require(IMember(caller).getName() == strategyName, "Access denied");
  }

_getIsActiveStrategyKey

Hash key of the "active strategy flag". Warning: this function does not validate the input arguments.

function _getIsActiveStrategyKey(address strategyAddress) private pure
returns(bytes32)

Arguments

Name Type Description
strategyAddress address Enter a strategy address
Source Code
function _getIsActiveStrategyKey(address strategyAddress) private pure returns (bytes32) {
    return keccak256(abi.encodePacked(ProtoUtilV1.NS_LENDING_STRATEGY_ACTIVE, strategyAddress));
  }

_getIsDisabledStrategyKey

Hash key of the "disabled strategy flag". Warning: this function does not validate the input arguments.

function _getIsDisabledStrategyKey(address strategyAddress) private pure
returns(bytes32)

Arguments

Name Type Description
strategyAddress address Enter a strategy address
Source Code
function _getIsDisabledStrategyKey(address strategyAddress) private pure returns (bytes32) {
    return keccak256(abi.encodePacked(ProtoUtilV1.NS_LENDING_STRATEGY_DISABLED, strategyAddress));
  }

senderMustBeProtocolMember

function senderMustBeProtocolMember(IStore s) external view

Arguments

Name Type Description
s IStore
Source Code
function senderMustBeProtocolMember(IStore s) external view {
    require(s.isProtocolMemberInternal(msg.sender), "Forbidden");
  }

mustBeReporting

function mustBeReporting(IStore s, bytes32 coverKey, bytes32 productKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustBeReporting(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) external view {
    require(s.getProductStatusInternal(coverKey, productKey) == CoverUtilV1.ProductStatus.IncidentHappened, "Not reporting");
  }

mustBeDisputed

function mustBeDisputed(IStore s, bytes32 coverKey, bytes32 productKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustBeDisputed(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) external view {
    require(s.getProductStatusInternal(coverKey, productKey) == CoverUtilV1.ProductStatus.FalseReporting, "Not disputed");
  }

mustBeClaimable

function mustBeClaimable(IStore s, bytes32 coverKey, bytes32 productKey) public view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustBeClaimable(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) public view {
    require(s.getProductStatusInternal(coverKey, productKey) == CoverUtilV1.ProductStatus.Claimable, "Not claimable");
  }

mustBeClaimingOrDisputed

function mustBeClaimingOrDisputed(IStore s, bytes32 coverKey, bytes32 productKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustBeClaimingOrDisputed(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) external view {
    CoverUtilV1.ProductStatus status = s.getProductStatusInternal(coverKey, productKey);

    bool claiming = status == CoverUtilV1.ProductStatus.Claimable;
    bool falseReporting = status == CoverUtilV1.ProductStatus.FalseReporting;

    require(claiming || falseReporting, "Not claimable nor disputed");
  }

mustBeReportingOrDisputed

function mustBeReportingOrDisputed(IStore s, bytes32 coverKey, bytes32 productKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustBeReportingOrDisputed(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) external view {
    CoverUtilV1.ProductStatus status = s.getProductStatusInternal(coverKey, productKey);
    bool incidentHappened = status == CoverUtilV1.ProductStatus.IncidentHappened;
    bool falseReporting = status == CoverUtilV1.ProductStatus.FalseReporting;

    require(incidentHappened || falseReporting, "Not reported nor disputed");
  }

mustBeBeforeResolutionDeadline

function mustBeBeforeResolutionDeadline(IStore s, bytes32 coverKey, bytes32 productKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustBeBeforeResolutionDeadline(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) external view {
    uint256 deadline = s.getResolutionDeadlineInternal(coverKey, productKey);

    if (deadline > 0) {
      require(block.timestamp < deadline, "Emergency resolution deadline over"); // solhint-disable-line
    }
  }

mustNotHaveResolutionDeadline

function mustNotHaveResolutionDeadline(IStore s, bytes32 coverKey, bytes32 productKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustNotHaveResolutionDeadline(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) external view {
    uint256 deadline = s.getResolutionDeadlineInternal(coverKey, productKey);
    require(deadline == 0, "Resolution already has deadline");
  }

mustBeAfterResolutionDeadline

function mustBeAfterResolutionDeadline(IStore s, bytes32 coverKey, bytes32 productKey) public view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustBeAfterResolutionDeadline(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) public view {
    uint256 deadline = s.getResolutionDeadlineInternal(coverKey, productKey);
    require(deadline > 0 && block.timestamp >= deadline, "Still unresolved"); // solhint-disable-line
  }

mustBeAfterFinalization

function mustBeAfterFinalization(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) public view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
incidentDate uint256
Source Code
function mustBeAfterFinalization(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey,
    uint256 incidentDate
  ) public view {
    require(s.getBoolByKey(GovernanceUtilV1.getHasFinalizedKeyInternal(coverKey, productKey, incidentDate)), "Incident not finalized");
  }

mustBeValidIncidentDate

function mustBeValidIncidentDate(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) public view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
incidentDate uint256
Source Code
function mustBeValidIncidentDate(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey,
    uint256 incidentDate
  ) public view {
    require(s.getActiveIncidentDateInternal(coverKey, productKey) == incidentDate, "Invalid incident date");
  }

mustHaveDispute

function mustHaveDispute(IStore s, bytes32 coverKey, bytes32 productKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustHaveDispute(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) external view {
    bool hasDispute = s.getBoolByKey(GovernanceUtilV1.getHasDisputeKeyInternal(coverKey, productKey));
    require(hasDispute == true, "Not disputed");
  }

mustNotHaveDispute

function mustNotHaveDispute(IStore s, bytes32 coverKey, bytes32 productKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustNotHaveDispute(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) external view {
    bool hasDispute = s.getBoolByKey(GovernanceUtilV1.getHasDisputeKeyInternal(coverKey, productKey));
    require(hasDispute == false, "Already disputed");
  }

mustBeDuringReportingPeriod

function mustBeDuringReportingPeriod(IStore s, bytes32 coverKey, bytes32 productKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustBeDuringReportingPeriod(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) external view {
    require(s.getResolutionTimestampInternal(coverKey, productKey) >= block.timestamp, "Reporting window closed"); // solhint-disable-line
  }

mustBeAfterReportingPeriod

function mustBeAfterReportingPeriod(IStore s, bytes32 coverKey, bytes32 productKey) public view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustBeAfterReportingPeriod(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) public view {
    require(block.timestamp > s.getResolutionTimestampInternal(coverKey, productKey), "Reporting still active"); // solhint-disable-line
  }

mustBeValidCxToken

function mustBeValidCxToken(IStore s, bytes32 coverKey, bytes32 productKey, address cxToken, uint256 incidentDate) public view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
cxToken address
incidentDate uint256
Source Code
function mustBeValidCxToken(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey,
    address cxToken,
    uint256 incidentDate
  ) public view {
    require(s.getBoolByKeys(ProtoUtilV1.NS_COVER_CXTOKEN, cxToken) == true, "Unknown cxToken");

    bytes32 COVER_KEY = ICxToken(cxToken).COVER_KEY(); // solhint-disable-line
    bytes32 PRODUCT_KEY = ICxToken(cxToken).PRODUCT_KEY(); // solhint-disable-line

    require(coverKey == COVER_KEY && productKey == PRODUCT_KEY, "Invalid cxToken");

    uint256 expires = ICxToken(cxToken).expiresOn();
    require(expires > incidentDate, "Invalid or expired cxToken");
  }

mustBeValidClaim

function mustBeValidClaim(IStore s, address account, bytes32 coverKey, bytes32 productKey, address cxToken, uint256 incidentDate, uint256 amount) external view

Arguments

Name Type Description
s IStore
account address
coverKey bytes32
productKey bytes32
cxToken address
incidentDate uint256
amount uint256
Source Code
function mustBeValidClaim(
    IStore s,
    address account,
    bytes32 coverKey,
    bytes32 productKey,
    address cxToken,
    uint256 incidentDate,
    uint256 amount
  ) external view {
    mustBeSupportedProductOrEmpty(s, coverKey, productKey);
    mustBeValidCxToken(s, coverKey, productKey, cxToken, incidentDate);
    mustBeClaimable(s, coverKey, productKey);
    mustBeValidIncidentDate(s, coverKey, productKey, incidentDate);
    mustBeDuringClaimPeriod(s, coverKey, productKey);
    require(ICxToken(cxToken).getClaimablePolicyOf(account) >= amount, "Claim exceeds your coverage");
  }

mustNotHaveUnstaken

function mustNotHaveUnstaken(IStore s, address account, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) public view

Arguments

Name Type Description
s IStore
account address
coverKey bytes32
productKey bytes32
incidentDate uint256
Source Code
function mustNotHaveUnstaken(
    IStore s,
    address account,
    bytes32 coverKey,
    bytes32 productKey,
    uint256 incidentDate
  ) public view {
    uint256 withdrawal = s.getReportingUnstakenAmountInternal(account, coverKey, productKey, incidentDate);
    require(withdrawal == 0, "Already unstaken");
  }

validateUnstakeWithoutClaim

Validates your unstakeWithoutClaim arguments

function validateUnstakeWithoutClaim(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
incidentDate uint256
Source Code
function validateUnstakeWithoutClaim(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey,
    uint256 incidentDate
  ) external view {
    mustNotBePaused(s);
    mustBeSupportedProductOrEmpty(s, coverKey, productKey);
    mustNotHaveUnstaken(s, msg.sender, coverKey, productKey, incidentDate);
    mustBeAfterFinalization(s, coverKey, productKey, incidentDate);
  }

validateUnstakeWithClaim

Validates your unstakeWithClaim arguments

function validateUnstakeWithClaim(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
incidentDate uint256
Source Code
function validateUnstakeWithClaim(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey,
    uint256 incidentDate
  ) external view {
    mustNotBePaused(s);
    mustBeSupportedProductOrEmpty(s, coverKey, productKey);
    mustNotHaveUnstaken(s, msg.sender, coverKey, productKey, incidentDate);

    // If this reporting gets finalized, incident date will become invalid
    // meaning this execution will revert thereby restricting late comers
    // to access this feature. But they can still access `unstake` feature
    // to withdraw their stake.
    mustBeValidIncidentDate(s, coverKey, productKey, incidentDate);

    // Before the deadline, emergency resolution can still happen
    // that may have an impact on the final decision. We, therefore, have to wait.
    mustBeAfterResolutionDeadline(s, coverKey, productKey);
  }

mustBeDuringClaimPeriod

function mustBeDuringClaimPeriod(IStore s, bytes32 coverKey, bytes32 productKey) public view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustBeDuringClaimPeriod(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) public view {
    uint256 beginsFrom = s.getUintByKeys(ProtoUtilV1.NS_CLAIM_BEGIN_TS, coverKey, productKey);
    uint256 expiresAt = s.getUintByKeys(ProtoUtilV1.NS_CLAIM_EXPIRY_TS, coverKey, productKey);

    require(beginsFrom > 0, "Invalid claim begin date");
    require(expiresAt > beginsFrom, "Invalid claim period");

    require(block.timestamp >= beginsFrom, "Claim period hasn't begun"); // solhint-disable-line
    require(block.timestamp <= expiresAt, "Claim period has expired"); // solhint-disable-line
  }

mustBeAfterClaimExpiry

function mustBeAfterClaimExpiry(IStore s, bytes32 coverKey, bytes32 productKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustBeAfterClaimExpiry(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) external view {
    require(block.timestamp > s.getUintByKeys(ProtoUtilV1.NS_CLAIM_EXPIRY_TS, coverKey, productKey), "Claim still active"); // solhint-disable-line
  }

senderMustBeWhitelistedCoverCreator

Reverts if the sender is not whitelisted cover creator.

function senderMustBeWhitelistedCoverCreator(IStore s) external view

Arguments

Name Type Description
s IStore
Source Code
function senderMustBeWhitelistedCoverCreator(IStore s) external view {
    require(s.getAddressBooleanByKey(ProtoUtilV1.NS_COVER_CREATOR_WHITELIST, msg.sender), "Not whitelisted");
  }

senderMustBeWhitelistedIfRequired

function senderMustBeWhitelistedIfRequired(IStore s, bytes32 coverKey, bytes32 productKey, address sender) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
sender address
Source Code
function senderMustBeWhitelistedIfRequired(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey,
    address sender
  ) external view {
    bool supportsProducts = s.supportsProductsInternal(coverKey);
    bool required = supportsProducts ? s.checkIfProductRequiresWhitelistInternal(coverKey, productKey) : s.checkIfRequiresWhitelistInternal(coverKey);

    if (required == false) {
      return;
    }

    require(s.getAddressBooleanByKeys(ProtoUtilV1.NS_COVER_USER_WHITELIST, coverKey, productKey, sender), "You are not whitelisted");
  }

mustBeSupportedProductOrEmpty

function mustBeSupportedProductOrEmpty(IStore s, bytes32 coverKey, bytes32 productKey) public view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustBeSupportedProductOrEmpty(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) public view {
    bool hasProducts = s.supportsProductsInternal(coverKey);

    hasProducts ? require(productKey > 0, "Specify a product") : require(productKey == 0, "Invalid product");

    if (hasProducts) {
      mustBeValidProduct(s, coverKey, productKey);
      mustBeActiveProduct(s, coverKey, productKey);
    }
  }

mustNotHavePolicyDisabled

function mustNotHavePolicyDisabled(IStore s, bytes32 coverKey, bytes32 productKey) external view

Arguments

Name Type Description
s IStore
coverKey bytes32
productKey bytes32
Source Code
function mustNotHavePolicyDisabled(
    IStore s,
    bytes32 coverKey,
    bytes32 productKey
  ) external view {
    require(!s.isPolicyDisabledInternal(coverKey, productKey), "Policy purchase disabled");
  }

mustMaintainStablecoinThreshold

function mustMaintainStablecoinThreshold(IStore s, uint256 amount) external view

Arguments

Name Type Description
s IStore
amount uint256
Source Code
function mustMaintainStablecoinThreshold(IStore s, uint256 amount) external view {
    uint256 stablecoinPrecision = s.getStablecoinPrecisionInternal();

    require(amount >= ProtoUtilV1.MIN_LIQUIDITY * stablecoinPrecision, "Liquidity is below threshold");
    require(amount <= ProtoUtilV1.MAX_LIQUIDITY * stablecoinPrecision, "Liquidity is above threshold");
  }

mustMaintainProposalThreshold

function mustMaintainProposalThreshold(IStore s, uint256 amount) external view

Arguments

Name Type Description
s IStore
amount uint256
Source Code
function mustMaintainProposalThreshold(IStore s, uint256 amount) external view {
    uint256 stablecoinPrecision = s.getStablecoinPrecisionInternal();

    require(amount >= ProtoUtilV1.MIN_PROPOSAL_AMOUNT * stablecoinPrecision, "Proposal is below threshold");
    require(amount <= ProtoUtilV1.MAX_PROPOSAL_AMOUNT * stablecoinPrecision, "Proposal is above threshold");
  }

Contracts