Skip to content

Latest commit

 

History

History
410 lines (338 loc) · 12.6 KB

CoverReassurance.md

File metadata and controls

410 lines (338 loc) · 12.6 KB

Cover Reassurance (CoverReassurance.sol)

View Source: contracts/core/lifecycle/CoverReassurance.sol

↗ Extends: ICoverReassurance, Recoverable

CoverReassurance

A covered project can add reassurance fund to exhibit coverage support for their project. This reduces the cover fee and increases the confidence of liquidity providers. A portion of the reassurance fund is awarded to liquidity providers in the event of a cover incident.

Functions

function (IStore store) public nonpayable Recoverable 

Arguments

Name Type Description
store IStore
Source Code
constructor(IStore store) Recoverable(store) {}

addReassurance

Adds reassurance to the specified cover contract

function addReassurance(bytes32 coverKey, address onBehalfOf, uint256 amount) external nonpayable nonReentrant 

Arguments

Name Type Description
coverKey bytes32 Enter the cover key
onBehalfOf address Enter the account on behalf of which you are adding reassurance.
amount uint256 Enter the amount you would like to supply
Source Code
function addReassurance(
    bytes32 coverKey,
    address onBehalfOf,
    uint256 amount
  ) external override nonReentrant {
    s.mustNotBePaused();
    s.mustBeValidCoverKey(coverKey);
    s.mustBeCoverOwnerOrCoverContract(coverKey, msg.sender);

    require(amount > 0, "Provide valid amount");

    IERC20 stablecoin = IERC20(s.getStablecoin());

    s.addUintByKey(CoverUtilV1.getReassuranceKey(coverKey), amount);

    stablecoin.ensureTransferFrom(msg.sender, address(this), amount);

    // Do not update state during cover creation
    // s.updateStateAndLiquidity(coverKey);

    emit ReassuranceAdded(coverKey, onBehalfOf, amount);
  }

setWeight

Sets the reassurance weight as a percentage value.

function setWeight(bytes32 coverKey, uint256 weight) external nonpayable nonReentrant 

Arguments

Name Type Description
coverKey bytes32 Enter the cover key for which you want to set the weight. You can provide 0x as cover key if you want to set reassurance weight globally.
weight uint256 Enter the weight value as percentage (see ProtoUtilV1.MULTIPLIER). You can't exceed 100%.
Source Code
function setWeight(bytes32 coverKey, uint256 weight) external override nonReentrant {
    s.mustNotBePaused();
    AccessControlLibV1.mustBeLiquidityManager(s);
    s.mustBeValidCoverKey(coverKey);

    require(weight > 0 && weight <= ProtoUtilV1.MULTIPLIER, "Please specify weight");

    s.setUintByKey(CoverUtilV1.getReassuranceWeightKey(coverKey), weight);

    s.updateStateAndLiquidity(coverKey);

    emit WeightSet(coverKey, weight);
  }

capitalizePool

Capitalizes the cover liquidity pool (or Vault) with whichever is less between 25% of the suffered loss or 25% of the reassurance pool balance.

This function can only be invoked if the specified cover was "claimable" and after "claim period" is over.

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

Arguments

Name Type Description
coverKey bytes32 Enter the cover key that has suffered capital depletion or loss.
productKey bytes32 Enter the product key that has suffered capital depletion or loss.
incidentDate uint256 Enter the date of the incident report.
Source Code
function capitalizePool(
    bytes32 coverKey,
    bytes32 productKey,
    uint256 incidentDate
  ) external override nonReentrant {
    require(incidentDate > 0, "Please specify incident date");

    s.mustNotBePaused();
    AccessControlLibV1.mustBeLiquidityManager(s);
    s.mustBeSupportedProductOrEmpty(coverKey, productKey);
    s.mustBeValidIncidentDate(coverKey, productKey, incidentDate);
    s.mustBeAfterResolutionDeadline(coverKey, productKey);
    s.mustBeClaimable(coverKey, productKey);
    s.mustBeAfterClaimExpiry(coverKey, productKey);

    IVault vault = s.getVault(coverKey);
    IERC20 stablecoin = IERC20(s.getStablecoin());

    uint256 toTransfer = s.getReassuranceTransferrableInternal(coverKey, productKey, incidentDate);

    require(toTransfer > 0, "Nothing to capitalize");

    stablecoin.ensureTransfer(address(vault), toTransfer);
    s.subtractUintByKey(CoverUtilV1.getReassuranceKey(coverKey), toTransfer);
    s.addReassurancePayoutInternal(coverKey, productKey, incidentDate, toTransfer);

    emit PoolCapitalized(coverKey, productKey, incidentDate, toTransfer);
  }

getReassurance

Gets the reassurance amount of the specified cover contract Warning: this function does not validate the cover key supplied.

function getReassurance(bytes32 coverKey) external view
returns(uint256)

Arguments

Name Type Description
coverKey bytes32 Enter the cover key
Source Code
function getReassurance(bytes32 coverKey) external view override returns (uint256) {
    return s.getReassuranceAmountInternal(coverKey);
  }

version

Version number of this contract

function version() external pure
returns(bytes32)

Arguments

Name Type Description
Source Code
function version() external pure override returns (bytes32) {
    return "v0.1";
  }

getName

Name of this contract

function getName() external pure
returns(bytes32)

Arguments

Name Type Description
Source Code
function getName() external pure override returns (bytes32) {
    return ProtoUtilV1.CNAME_COVER_REASSURANCE;
  }

Contracts