Skip to content

Latest commit

 

History

History
268 lines (239 loc) · 9.63 KB

Finalization.md

File metadata and controls

268 lines (239 loc) · 9.63 KB

Finalization Contract (Finalization.sol)

View Source: contracts/core/governance/resolution/Finalization.sol

↗ Extends: Recoverable, IFinalization ↘ Derived Contracts: Resolvable

Finalization

This contract allows governance agents "finalize" a resolved cover product after the claim period. When a cover product is finalized, it resets back to normal state where tokenholders can again supply liquidity and purchase policies.

Functions

finalize

Finalizes a cover pool or a product contract. Once finalized, the cover resets back to the normal state.

function finalize(bytes32 coverKey, bytes32 productKey, uint256 incidentDate) external nonpayable nonReentrant 

Arguments

Name Type Description
coverKey bytes32 Enter the cover key you want to finalize
productKey bytes32 Enter the product key you want to finalize
incidentDate uint256 Enter the date of this incident reporting
Source Code
function finalize(
    bytes32 coverKey,
    bytes32 productKey,
    uint256 incidentDate
  ) external override nonReentrant {
    require(incidentDate > 0, "Please specify incident date");

    s.mustNotBePaused();
    AccessControlLibV1.mustBeGovernanceAgent(s);

    s.mustBeSupportedProductOrEmpty(coverKey, productKey);
    s.mustBeValidIncidentDate(coverKey, productKey, incidentDate);
    s.mustBeClaimingOrDisputed(coverKey, productKey);
    s.mustBeAfterResolutionDeadline(coverKey, productKey);
    s.mustBeAfterClaimExpiry(coverKey, productKey);

    // The reassurance capital (if available) needs to be transferred before this cover can be finalized.
    uint256 transferable = s.getReassuranceTransferrableInternal(coverKey, productKey, incidentDate);
    require(transferable == 0, "Pool must be capitalized");

    _finalize(coverKey, productKey, incidentDate);
  }

_finalize

function _finalize(bytes32 coverKey, bytes32 productKey, uint256 incidentDate) internal nonpayable

Arguments

Name Type Description
coverKey bytes32
productKey bytes32
incidentDate uint256
Source Code
function _finalize(
    bytes32 coverKey,
    bytes32 productKey,
    uint256 incidentDate
  ) internal {
    s.setBoolByKey(GovernanceUtilV1.getHasFinalizedKeyInternal(coverKey, productKey, incidentDate), true);

    // Deleting latest incident date resets this product
    s.deleteUintByKeys(ProtoUtilV1.NS_GOVERNANCE_REPORTING_INCIDENT_DATE, coverKey, productKey);
    s.deleteUintByKeys(ProtoUtilV1.NS_GOVERNANCE_RESOLUTION_TS, coverKey, productKey);
    s.deleteUintByKeys(ProtoUtilV1.NS_CLAIM_BEGIN_TS, coverKey, productKey);
    s.deleteUintByKeys(ProtoUtilV1.NS_CLAIM_EXPIRY_TS, coverKey, productKey);

    s.deleteAddressByKeys(ProtoUtilV1.NS_GOVERNANCE_REPORTING_WITNESS_YES, coverKey, productKey);
    s.deleteAddressByKeys(ProtoUtilV1.NS_GOVERNANCE_REPORTING_WITNESS_NO, coverKey, productKey);
    s.deleteUintByKeys(ProtoUtilV1.NS_RESOLUTION_DEADLINE, coverKey, productKey);
    s.deleteBoolByKey(GovernanceUtilV1.getHasDisputeKeyInternal(coverKey, productKey));

    // @warning: do not uncomment these lines as these vales are required to enable unstaking any time after finalization
    // s.deleteAddressByKey(keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_REPORTING_WITNESS_YES, coverKey, productKey, incidentDate)));
    // s.deleteAddressByKey(keccak256(abi.encodePacked(ProtoUtilV1.NS_GOVERNANCE_REPORTING_WITNESS_NO, coverKey, productKey, incidentDate)));

    s.updateStateAndLiquidityInternal(coverKey);
    emit Finalized(coverKey, productKey, msg.sender, incidentDate);
  }

Contracts