View Source: contracts/core/claims/Processor.sol
↗ Extends: IClaimsProcessor, Recoverable
Processor
The claims processor contract allows policyholders to file a claim and get instant payouts during the claim period.
There is a lag period before a policy begins coverage.
After the next day's UTC EOD timestamp, policies take effect and are valid until the expiration period.
Check ProtoUtilV1.NS_COVERAGE_LAG and PolicyAdmin.getCoverageLag
for more information on the lag configuration.
If a claim isn't made during the claim period, it isn't valid and there is no payout.
- constructor(IStore store)
- claim(address cxToken, bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 amount)
- validate(address cxToken, bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 amount)
- getClaimExpiryDate(bytes32 coverKey, bytes32 productKey)
- setClaimPeriod(bytes32 coverKey, uint256 value)
- setBlacklist(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, address[] accounts, bool[] statuses)
- isBlacklisted(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, address account)
- version()
- getName()
Constructs this contract
function (IStore store) public nonpayable Recoverable
Arguments
Name | Type | Description |
---|---|---|
store | IStore | Provide an implementation of IStore |
Source Code
constructor(IStore store) Recoverable(store) {}
Enables a policyholder to receive a payout redeeming cxTokens. Only when the active cover is marked as "Incident Happened" and has "Claimable" status is the payout made.
function claim(address cxToken, bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 amount) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
cxToken | address | Provide the address of the claim token that you're using for this claim. |
coverKey | bytes32 | Enter the key of the cover you're claiming |
productKey | bytes32 | Enter the key of the product you're claiming |
incidentDate | uint256 | Enter the active cover's date of incident |
amount | uint256 | Enter the amount of cxTokens you want to transfer |
Source Code
function claim(
address cxToken,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate,
uint256 amount
) external override nonReentrant {
validate(cxToken, coverKey, productKey, incidentDate, amount);
IERC20(cxToken).ensureTransferFrom(msg.sender, address(this), amount);
ICxToken(cxToken).burn(amount);
IVault vault = s.getVault(coverKey);
address finalReporter = s.getReporterInternal(coverKey, productKey, incidentDate);
uint256 stablecoinPrecision = s.getStablecoinPrecisionInternal();
uint256 payout = (amount * stablecoinPrecision) / ProtoUtilV1.CXTOKEN_PRECISION;
require(payout > 0, "Invalid payout");
s.addClaimPayoutsInternal(coverKey, productKey, incidentDate, payout);
// @suppress-zero-value-check Checked side effects. If the claim platform fee is zero
// or a very small number, platform fee becomes zero due to data loss.
uint256 platformFee = (payout * s.getPlatformCoverFeeRateInternal()) / ProtoUtilV1.MULTIPLIER;
// @suppress-zero-value-check Checked side effects. If the claim reporter commission rate is zero
// or a very small number, reporterFee fee becomes zero due to data loss.
uint256 reporterFee = (platformFee * s.getClaimReporterCommissionInternal()) / ProtoUtilV1.MULTIPLIER;
require(payout >= platformFee, "Invalid platform fee");
uint256 claimed = payout - platformFee;
// @suppress-zero-value-check If the platform fee rate was 100%,
// "claimed" can be zero
if (claimed > 0) {
vault.transferGovernance(coverKey, msg.sender, claimed);
}
if (reporterFee > 0) {
vault.transferGovernance(coverKey, finalReporter, reporterFee);
}
if (platformFee - reporterFee > 0) {
// @suppress-subtraction The following (or above) subtraction can cause
// an underflow if `getClaimReporterCommissionInternal` is greater than 100%.
vault.transferGovernance(coverKey, s.getTreasuryAddressInternal(), platformFee - reporterFee);
}
s.updateStateAndLiquidityInternal(coverKey);
emit Claimed(cxToken, coverKey, productKey, incidentDate, msg.sender, finalReporter, amount, reporterFee, platformFee, claimed);
}
Validates a given claim
function validate(address cxToken, bytes32 coverKey, bytes32 productKey, uint256 incidentDate, uint256 amount) public view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
cxToken | address | Provide the address of the claim token that you're using for this claim. |
coverKey | bytes32 | Enter the key of the cover you're validating the claim for |
productKey | bytes32 | Enter the key of the product you're validating the claim for |
incidentDate | uint256 | Enter the active cover's date of incident |
amount | uint256 |
Returns
If the given claim is valid and can result in a successful payout, returns true.
Source Code
function validate(
address cxToken,
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate,
uint256 amount
) public view override returns (bool) {
s.mustNotBePaused();
s.mustBeValidClaim(msg.sender, coverKey, productKey, cxToken, incidentDate, amount);
require(isBlacklisted(coverKey, productKey, incidentDate, msg.sender) == false, "Access denied");
require(amount > 0, "Enter an amount");
require(s.getClaimReporterCommissionInternal() <= ProtoUtilV1.MULTIPLIER, "Invalid claim reporter fee");
require(s.getPlatformCoverFeeRateInternal() <= ProtoUtilV1.MULTIPLIER, "Invalid platform fee rate");
return true;
}
Returns claim expiration date. Even if the policy was still valid, it cannot be claimed after the claims expiry date. Warning: this function does not validate the cover key supplied.
function getClaimExpiryDate(bytes32 coverKey, bytes32 productKey) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the key of the cover you're checking |
productKey | bytes32 | Enter the key of the product you're checking |
Source Code
function getClaimExpiryDate(bytes32 coverKey, bytes32 productKey) external view override returns (uint256) {
return s.getUintByKeys(ProtoUtilV1.NS_CLAIM_EXPIRY_TS, coverKey, productKey);
}
Sets the cover's claim period using its key. If no cover key is specified, the value specified here will be used as a fallback. Covers without a specified claim period default to the fallback value.
function setClaimPeriod(bytes32 coverKey, uint256 value) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the coverKey you want to set the claim period for |
value | uint256 | Enter a claim period you want to set |
Source Code
ction setClaimPeriod(bytes32 coverKey, uint256 value) external override nonReentrant {
s.mustNotBePaused();
AccessControlLibV1.mustBeCoverManager(s);
require(value > 0, "Please specify value");
uint256 previous;
if (coverKey > 0) {
previous = s.getUintByKeys(ProtoUtilV1.NS_CLAIM_PERIOD, coverKey);
s.setUintByKeys(ProtoUtilV1.NS_CLAIM_PERIOD, coverKey, value);
emit ClaimPeriodSet(coverKey, previous, value);
return;
}
previous = s.getUintByKey(ProtoUtilV1.NS_CLAIM_PERIOD);
s.setUintByKey(ProtoUtilV1.NS_CLAIM_PERIOD, value);
emit ClaimPeriodSet(coverKey, previous, value);
}
Accounts that are on a blacklist can't claim their cxTokens.
Cover managers can stop an account from claiming their cover by putting it on the blacklist.
Usually, this happens when we suspect a policyholder is the attacker.
After performing KYC, we might be able to lift the blacklist.
function setBlacklist(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, address[] accounts, bool[] statuses) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the cover key |
productKey | bytes32 | Enter the product key |
incidentDate | uint256 | Enter the incident date of the cover |
accounts | address[] | Enter list of accounts you want to blacklist |
statuses | bool[] | Enter true if you want to blacklist. False if you want to remove from the blacklist. |
Source Code
ction setBlacklist(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate,
address[] calldata accounts,
bool[] calldata statuses
) external override nonReentrant {
// @suppress-zero-value-check Checked
require(accounts.length > 0, "Invalid accounts");
require(accounts.length == statuses.length, "Invalid args");
s.mustNotBePaused();
AccessControlLibV1.mustBeCoverManager(s);
s.mustBeSupportedProductOrEmpty(coverKey, productKey);
s.mustBeValidIncidentDate(coverKey, productKey, incidentDate);
for (uint256 i = 0; i < accounts.length; i++) {
s.setAddressBooleanByKey(CoverUtilV1.getBlacklistKeyInternal(coverKey, productKey, incidentDate), accounts[i], statuses[i]);
emit BlacklistSet(coverKey, productKey, incidentDate, accounts[i], statuses[i]);
}
}
Check to see if an account is blacklisted/banned from making a claim.
function isBlacklisted(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, address account) public view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the cover key |
productKey | bytes32 | |
incidentDate | uint256 | Enter the incident date of this cover |
account | address | Enter the account to see if it is blacklisted |
Source Code
ction isBlacklisted(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate,
address account
) public view override returns (bool) {
return s.getAddressBooleanByKey(CoverUtilV1.getBlacklistKeyInternal(coverKey, productKey, incidentDate), account);
}
Version number of this contract
function version() external pure
returns(bytes32)
Arguments
Name | Type | Description |
---|
Source Code
ction version() external pure override returns (bytes32) {
return "v0.1";
}
Name of this contract
function getName() external pure
returns(bytes32)
Arguments
Name | Type | Description |
---|
Source Code
ction getName() external pure override returns (bytes32) {
return ProtoUtilV1.CNAME_CLAIMS_PROCESSOR;
}
}
- 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