View Source: contracts/core/policy/PolicyAdmin.sol
↗ Extends: IPolicyAdmin, Recoverable
PolicyAdmin
The policy admin contract enables the owner (governance) to set the policy rate and fee info.
- constructor(IStore store)
- setPolicyRatesByKey(bytes32 coverKey, uint256 floor, uint256 ceiling)
- setCoverageLag(bytes32 coverKey, uint256 window)
- getPolicyRates(bytes32 coverKey)
- getCoverageLag(bytes32 coverKey)
- version()
- getName()
Constructs this contract
function (IStore store) public nonpayable Recoverable Arguments
| Name | Type | Description |
|---|---|---|
| store | IStore | Provide the store contract instance |
Source Code
constructor(IStore store) Recoverable(store) {}Sets policy rates for the given cover key. This feature is only accessible by cover manager.
function setPolicyRatesByKey(bytes32 coverKey, uint256 floor, uint256 ceiling) external nonpayable nonReentrant Arguments
| Name | Type | Description |
|---|---|---|
| coverKey | bytes32 | |
| floor | uint256 | The lowest cover fee rate for this cover |
| ceiling | uint256 | The highest cover fee rate for this cover |
Source Code
function setPolicyRatesByKey(
bytes32 coverKey,
uint256 floor,
uint256 ceiling
) external override nonReentrant {
s.mustNotBePaused();
AccessControlLibV1.mustBeCoverManager(s);
require(floor > 0, "Please specify floor");
require(ceiling > floor, "Invalid ceiling");
if (coverKey > 0) {
s.mustBeValidCoverKey(coverKey);
s.setUintByKeys(ProtoUtilV1.NS_COVER_POLICY_RATE_FLOOR, coverKey, floor);
s.setUintByKeys(ProtoUtilV1.NS_COVER_POLICY_RATE_CEILING, coverKey, ceiling);
} else {
s.setUintByKey(ProtoUtilV1.NS_COVER_POLICY_RATE_FLOOR, floor);
s.setUintByKey(ProtoUtilV1.NS_COVER_POLICY_RATE_CEILING, ceiling);
}
s.updateStateAndLiquidity(coverKey);
emit CoverPolicyRateSet(coverKey, floor, ceiling);
}The coverage of a policy begins at the EOD timestamp of the policy purchase date plus the coverage lag. Coverage lag is a specified time period that can be set globally or on a per-cover basis to delay the start of coverage. This allows us to defend against time-based opportunistic attacks, which occur when an attacker purchases coverage after an incident has occurred but before the incident has been reported.
function setCoverageLag(bytes32 coverKey, uint256 window) external nonpayableArguments
| Name | Type | Description |
|---|---|---|
| coverKey | bytes32 | |
| window | uint256 |
Source Code
function setCoverageLag(bytes32 coverKey, uint256 window) external override {
require(window >= 1 days, "Enter at least 1 day");
s.mustNotBePaused();
AccessControlLibV1.mustBeCoverManager(s);
if (coverKey > 0) {
s.mustBeValidCoverKey(coverKey);
s.setUintByKeys(ProtoUtilV1.NS_COVERAGE_LAG, coverKey, window);
emit CoverageLagSet(coverKey, window);
return;
}
s.setUintByKey(ProtoUtilV1.NS_COVERAGE_LAG, window);
emit CoverageLagSet(coverKey, window);
}Gets the cover policy rates for the given cover key Warning: this function does not validate the cover key supplied.
function getPolicyRates(bytes32 coverKey) external view
returns(floor uint256, ceiling uint256)Arguments
| Name | Type | Description |
|---|---|---|
| coverKey | bytes32 |
Source Code
function getPolicyRates(bytes32 coverKey) external view override returns (uint256 floor, uint256 ceiling) {
return s.getPolicyRatesInternal(coverKey);
}Gets the policy lag for the given cover key Warning: this function does not validate the cover key supplied.
function getCoverageLag(bytes32 coverKey) external view
returns(uint256)Arguments
| Name | Type | Description |
|---|---|---|
| coverKey | bytes32 |
Source Code
function getCoverageLag(bytes32 coverKey) external view override returns (uint256) {
return s.getCoverageLagInternal(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_POLICY_ADMIN;
}- 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