View Source: contracts/libraries/ValidationLibV1.sol
ValidationLibV1
- mustNotBePaused(IStore s)
- mustEnsureAllProductsAreNormal(IStore s, bytes32 coverKey)
- mustHaveNormalProductStatus(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeValidCoverKey(IStore s, bytes32 coverKey)
- mustSupportProducts(IStore s, bytes32 coverKey)
- mustBeValidProduct(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeActiveProduct(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeCoverOwner(IStore s, bytes32 coverKey, address sender)
- mustBeCoverOwnerOrCoverContract(IStore s, bytes32 coverKey, address sender)
- senderMustBeCoverOwnerOrAdmin(IStore s, bytes32 coverKey)
- senderMustBePolicyContract(IStore s)
- senderMustBePolicyManagerContract(IStore s)
- senderMustBeCoverContract(IStore s)
- senderMustBeVaultContract(IStore s, bytes32 coverKey)
- senderMustBeGovernanceContract(IStore s)
- senderMustBeClaimsProcessorContract(IStore s)
- callerMustBeClaimsProcessorContract(IStore s, address caller)
- senderMustBeStrategyContract(IStore s)
- callerMustBeStrategyContract(IStore s, address caller)
- callerMustBeSpecificStrategyContract(IStore s, address caller, bytes32 strategyName)
- _getIsActiveStrategyKey(address strategyAddress)
- _getIsDisabledStrategyKey(address strategyAddress)
- senderMustBeProtocolMember(IStore s)
- mustBeReporting(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeDisputed(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeClaimable(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeClaimingOrDisputed(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeReportingOrDisputed(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeBeforeResolutionDeadline(IStore s, bytes32 coverKey, bytes32 productKey)
- mustNotHaveResolutionDeadline(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeAfterResolutionDeadline(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeAfterFinalization(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- mustBeValidIncidentDate(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- mustHaveDispute(IStore s, bytes32 coverKey, bytes32 productKey)
- mustNotHaveDispute(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeDuringReportingPeriod(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeAfterReportingPeriod(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeValidCxToken(IStore s, bytes32 coverKey, bytes32 productKey, address cxToken, uint256 incidentDate)
- mustBeValidClaim(IStore s, address account, bytes32 coverKey, bytes32 productKey, address cxToken, uint256 incidentDate, uint256 amount)
- mustNotHaveUnstaken(IStore s, address account, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- validateUnstakeWithoutClaim(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- validateUnstakeWithClaim(IStore s, bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- mustBeDuringClaimPeriod(IStore s, bytes32 coverKey, bytes32 productKey)
- mustBeAfterClaimExpiry(IStore s, bytes32 coverKey, bytes32 productKey)
- senderMustBeWhitelistedCoverCreator(IStore s)
- senderMustBeWhitelistedIfRequired(IStore s, bytes32 coverKey, bytes32 productKey, address sender)
- mustBeSupportedProductOrEmpty(IStore s, bytes32 coverKey, bytes32 productKey)
- mustNotHavePolicyDisabled(IStore s, bytes32 coverKey, bytes32 productKey)
- mustMaintainStablecoinThreshold(IStore s, uint256 amount)
- mustMaintainProposalThreshold(IStore s, uint256 amount)
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");
}
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");
}
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");
}
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");
}
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");
}
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");
}
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");
}
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");
}
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");
}
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);
}
}
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);
}
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);
}
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);
}
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");
}
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);
}
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);
}
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);
}
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");
}
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");
}
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");
}
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));
}
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));
}
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");
}
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");
}
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");
}
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");
}
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");
}
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");
}
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
}
}
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");
}
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
}
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");
}
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");
}
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");
}
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");
}
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
}
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
}
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");
}
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");
}
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");
}
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);
}
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);
}
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
}
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
}
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");
}
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");
}
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);
}
}
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");
}
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");
}
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");
}
- 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