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.
- https://docs.neptunemutual.com/sdk/cover-assurance
- https://docs.neptunemutual.com/definitions/cover-products
- constructor(IStore store)
- addReassurance(bytes32 coverKey, address onBehalfOf, uint256 amount)
- setWeight(bytes32 coverKey, uint256 weight)
- capitalizePool(bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- getReassurance(bytes32 coverKey)
- version()
- getName()
function (IStore store) public nonpayable Recoverable
Arguments
Name | Type | Description |
---|---|---|
store | IStore |
Source Code
constructor(IStore store) Recoverable(store) {}
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);
}
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);
}
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);
}
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 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";
}
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;
}
- 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
- FakeCompoundDaiDelegator
- FakePriceOracle
- FakeRecoverable
- FakeStore
- FakeToken
- FakeUniswapPair
- FakeUniswapV2FactoryLike
- FakeUniswapV2PairLike
- FakeUniswapV2RouterLike
- FaultyAaveLendingPool
- FaultyCompoundDaiDelegator
- 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