View Source: contracts/core/governance/resolution/Resolvable.sol
↗ Extends: Finalization, IResolvable ↘ Derived Contracts: Unstakable
Resolvable
Enables governance agents to resolve a contract undergoing reporting. Has a cool-down period of 24-hours (or as overridden) during when governance admins can perform emergency resolution to defend against governance attacks.
- resolve(bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- emergencyResolve(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, bool decision)
- _resolve(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, bool decision, bool emergency)
- configureCoolDownPeriod(bytes32 coverKey, uint256 period)
- closeReport(bytes32 coverKey, bytes32 productKey, uint256 incidentDate)
- getCoolDownPeriod(bytes32 coverKey)
- getResolutionDeadline(bytes32 coverKey, bytes32 productKey)
Marks as a cover as "resolved" after the reporting period. A resolution has a (configurable) 24-hour cooldown period that enables governance admins to revese decision in case of attack or mistake.
function resolve(bytes32 coverKey, bytes32 productKey, uint256 incidentDate) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the cover key you want to resolve |
productKey | bytes32 | Enter the product key you want to resolve |
incidentDate | uint256 | Enter the date of this incident reporting |
Source Code
function resolve(
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.mustBeReportingOrDisputed(coverKey, productKey);
s.mustBeAfterReportingPeriod(coverKey, productKey);
s.mustNotHaveResolutionDeadline(coverKey, productKey);
bool decision = s.getProductStatusOfInternal(coverKey, productKey, incidentDate) == CoverUtilV1.ProductStatus.IncidentHappened;
_resolve(coverKey, productKey, incidentDate, decision, false);
}
Enables governance admins to perform emergency resolution.
function emergencyResolve(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, bool decision) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the cover key on which you want to perform emergency resolve |
productKey | bytes32 | Enter the product key on which you want to perform emergency resolve |
incidentDate | uint256 | Enter the date of this incident reporting |
decision | bool |
Source Code
function emergencyResolve(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate,
bool decision
) external override nonReentrant {
require(incidentDate > 0, "Please specify incident date");
s.mustNotBePaused();
AccessControlLibV1.mustBeGovernanceAdmin(s);
s.mustBeSupportedProductOrEmpty(coverKey, productKey);
s.mustBeValidIncidentDate(coverKey, productKey, incidentDate);
s.mustBeAfterReportingPeriod(coverKey, productKey);
s.mustBeBeforeResolutionDeadline(coverKey, productKey);
_resolve(coverKey, productKey, incidentDate, decision, true);
}
function _resolve(bytes32 coverKey, bytes32 productKey, uint256 incidentDate, bool decision, bool emergency) private nonpayable
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | |
productKey | bytes32 | |
incidentDate | uint256 | |
decision | bool | |
emergency | bool |
Source Code
function _resolve(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate,
bool decision,
bool emergency
) private {
// A grace period given to a governance admin(s) to defend
// against a concensus attack(s).
uint256 cooldownPeriod = s.getCoolDownPeriodInternal(coverKey);
// The timestamp until when a governance admin is allowed
// to perform emergency resolution.
// After this timestamp, the cover has to be claimable
// or finalized
uint256 deadline = s.getResolutionDeadlineInternal(coverKey, productKey);
// A cover, when being resolved, will either directly go to finalization or have a claim period.
//
// Decision: False Reporting
// 1. A governance admin can still overwrite, override, or reverse this decision before `deadline`.
// 2. After the deadline and before finalization, the NPM holders
// who staked for `False Reporting` camp can withdraw the original stake + reward.
// 3. After finalization, the NPM holders who staked for this camp will only be able to receive
// back the original stake. No rewards.
//
// Decision: Claimable
//
// 1. A governance admin can still overwrite, override, or reverse this decision before `deadline`.
// 2. All policyholders must claim during the `Claim Period`. Otherwise, claims are not valid.
// 3. After the deadline and before finalization, the NPM holders
// who staked for `Incident Happened` camp can withdraw the original stake + reward.
// 4. After finalization, the NPM holders who staked for this camp will only be able to receive
// back the original stake. No rewards.
CoverUtilV1.ProductStatus status = decision ? CoverUtilV1.ProductStatus.Claimable : CoverUtilV1.ProductStatus.FalseReporting;
// Status can change during `Emergency Resolution` attempt(s)
s.setStatusInternal(coverKey, productKey, incidentDate, status);
if (deadline == 0) {
// Deadline can't be before claim begin date.
// In other words, once a cover becomes claimable, emergency resolution
// can not be performed any longer
deadline = block.timestamp + cooldownPeriod; // solhint-disable-line
s.setUintByKeys(ProtoUtilV1.NS_RESOLUTION_DEADLINE, coverKey, productKey, deadline);
}
// Claim begins when deadline timestamp is passed
uint256 claimBeginsFrom = decision ? deadline + 1 : 0;
// Claim expires after the period specified by the cover creator.
uint256 claimExpiresAt = decision ? claimBeginsFrom + s.getClaimPeriod(coverKey) : 0;
s.setUintByKeys(ProtoUtilV1.NS_CLAIM_BEGIN_TS, coverKey, productKey, claimBeginsFrom);
s.setUintByKeys(ProtoUtilV1.NS_CLAIM_EXPIRY_TS, coverKey, productKey, claimExpiresAt);
s.updateStateAndLiquidity(coverKey);
emit Resolved(coverKey, productKey, incidentDate, deadline, decision, emergency, claimBeginsFrom, claimExpiresAt);
}
Allows a governance admin to add or update resolution cooldown period for a given cover.
function configureCoolDownPeriod(bytes32 coverKey, uint256 period) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Provide a coverKey or leave it empty. If empty, the cooldown period is set as fallback value. Covers that do not have customized cooldown period will infer to the fallback value. |
period | uint256 | Enter the cooldown period duration |
Source Code
function configureCoolDownPeriod(bytes32 coverKey, uint256 period) external override nonReentrant {
s.mustNotBePaused();
AccessControlLibV1.mustBeGovernanceAdmin(s);
require(period > 0, "Please specify period");
if (coverKey > 0) {
s.setUintByKeys(ProtoUtilV1.NS_RESOLUTION_COOL_DOWN_PERIOD, coverKey, period);
} else {
s.setUintByKey(ProtoUtilV1.NS_RESOLUTION_COOL_DOWN_PERIOD, period);
}
emit CooldownPeriodConfigured(coverKey, period);
}
Enables governance admins to perform a emergency resolution to close a report.
The status is set to False Reporting
and the cover is made available to be finalized
function closeReport(bytes32 coverKey, bytes32 productKey, uint256 incidentDate) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the cover key you want to resolve |
productKey | bytes32 | Enter the product key you want to resolve |
incidentDate | uint256 | Enter the date of this incident reporting |
Source Code
function closeReport(
bytes32 coverKey,
bytes32 productKey,
uint256 incidentDate
) external override nonReentrant {
require(incidentDate > 0, "Please specify incident date");
s.mustNotBePaused();
AccessControlLibV1.mustBeGovernanceAdmin(s);
s.mustBeSupportedProductOrEmpty(coverKey, productKey);
s.mustBeValidIncidentDate(coverKey, productKey, incidentDate);
s.mustBeDuringReportingPeriod(coverKey, productKey);
s.mustNotHaveResolutionDeadline(coverKey, productKey);
// solhint-disable-next-line not-rely-on-time
s.setUintByKeys(ProtoUtilV1.NS_GOVERNANCE_RESOLUTION_TS, coverKey, productKey, block.timestamp);
// solhint-disable-next-line not-rely-on-time
s.setUintByKeys(ProtoUtilV1.NS_RESOLUTION_DEADLINE, coverKey, productKey, block.timestamp);
_resolve(coverKey, productKey, incidentDate, false, true);
_finalize(coverKey, productKey, incidentDate);
emit ReportClosed(coverKey, productKey, msg.sender, incidentDate);
}
Gets the cooldown period of a given cover Warning: this function does not validate the cover key supplied.
function getCoolDownPeriod(bytes32 coverKey) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 |
Source Code
function getCoolDownPeriod(bytes32 coverKey) external view override returns (uint256) {
return s.getCoolDownPeriodInternal(coverKey);
}
Gets the resolution deadline of a given cover product Warning: this function does not validate the cover and product key supplied.
function getResolutionDeadline(bytes32 coverKey, bytes32 productKey) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | |
productKey | bytes32 |
Source Code
function getResolutionDeadline(bytes32 coverKey, bytes32 productKey) external view override returns (uint256) {
return s.getResolutionDeadlineInternal(coverKey, productKey);
}
- 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