View Source: contracts/libraries/ProtoUtilV1.sol
ProtoUtilV1
Constants & Variables
uint256 public constant MAX_POLICY_DURATION;
bytes32 public constant KEY_INTENTIONALLY_EMPTY;
bytes32 public constant PRODUCT_KEY_INTENTIONALLY_EMPTY;
uint256 public constant MULTIPLIER;
uint256 public constant MAX_LIQUIDITY;
uint256 public constant MAX_PROPOSAL_AMOUNT;
uint256 public constant MAX_NPM_STAKE;
uint256 public constant NPM_PRECISION;
uint256 public constant CXTOKEN_PRECISION;
uint256 public constant POD_PRECISION;
bytes32 public constant CNS_CORE;
bytes32 public constant CNS_NPM;
bytes32 public constant CNS_COVER;
bytes32 public constant CNS_UNISWAP_V2_ROUTER;
bytes32 public constant CNS_UNISWAP_V2_FACTORY;
bytes32 public constant CNS_PRICE_DISCOVERY;
bytes32 public constant CNS_TREASURY;
bytes32 public constant CNS_NPM_PRICE_ORACLE;
bytes32 public constant CNS_COVER_REASSURANCE;
bytes32 public constant CNS_POOL_BOND;
bytes32 public constant CNS_COVER_POLICY;
bytes32 public constant CNS_COVER_POLICY_MANAGER;
bytes32 public constant CNS_COVER_POLICY_ADMIN;
bytes32 public constant CNS_COVER_STAKE;
bytes32 public constant CNS_COVER_VAULT;
bytes32 public constant CNS_COVER_VAULT_DELEGATE;
bytes32 public constant CNS_COVER_STABLECOIN;
bytes32 public constant CNS_COVER_CXTOKEN_FACTORY;
bytes32 public constant CNS_COVER_VAULT_FACTORY;
bytes32 public constant CNS_BOND_POOL;
bytes32 public constant CNS_STAKING_POOL;
bytes32 public constant CNS_LIQUIDITY_ENGINE;
bytes32 public constant CNS_STRATEGY_AAVE;
bytes32 public constant CNS_STRATEGY_COMPOUND;
bytes32 public constant CNS_GOVERNANCE;
bytes32 public constant CNS_GOVERNANCE_RESOLUTION;
bytes32 public constant CNS_CLAIM_PROCESSOR;
bytes32 public constant CNS_BURNER;
bytes32 public constant NS_MEMBERS;
bytes32 public constant NS_CONTRACTS;
bytes32 public constant NS_COVER;
bytes32 public constant NS_COVER_PRODUCT;
bytes32 public constant NS_COVER_PRODUCT_EFFICIENCY;
bytes32 public constant NS_COVER_CREATION_DATE;
bytes32 public constant NS_COVER_CREATION_FEE;
bytes32 public constant NS_COVER_CREATION_MIN_STAKE;
bytes32 public constant NS_COVER_REASSURANCE;
bytes32 public constant NS_COVER_REASSURANCE_PAYOUT;
bytes32 public constant NS_COVER_REASSURANCE_WEIGHT;
bytes32 public constant NS_COVER_REASSURANCE_RATE;
bytes32 public constant NS_COVER_LEVERAGE_FACTOR;
bytes32 public constant NS_COVER_CREATION_FEE_EARNING;
bytes32 public constant NS_COVER_INFO;
bytes32 public constant NS_COVER_OWNER;
bytes32 public constant NS_COVER_SUPPORTS_PRODUCTS;
bytes32 public constant NS_VAULT_STRATEGY_OUT;
bytes32 public constant NS_VAULT_LENDING_INCOMES;
bytes32 public constant NS_VAULT_LENDING_LOSSES;
bytes32 public constant NS_VAULT_DEPOSIT_HEIGHTS;
bytes32 public constant NS_COVER_LIQUIDITY_LENDING_PERIOD;
bytes32 public constant NS_COVER_LIQUIDITY_MAX_LENDING_RATIO;
bytes32 public constant NS_COVER_LIQUIDITY_WITHDRAWAL_WINDOW;
bytes32 public constant NS_COVER_LIQUIDITY_MIN_STAKE;
bytes32 public constant NS_COVER_LIQUIDITY_STAKE;
bytes32 public constant NS_COVER_LIQUIDITY_COMMITTED;
bytes32 public constant NS_COVER_STABLECOIN_NAME;
bytes32 public constant NS_COVER_REQUIRES_WHITELIST;
bytes32 public constant NS_COVER_HAS_FLASH_LOAN;
bytes32 public constant NS_COVER_LIQUIDITY_FLASH_LOAN_FEE;
bytes32 public constant NS_COVER_LIQUIDITY_FLASH_LOAN_FEE_PROTOCOL;
bytes32 public constant NS_COVERAGE_LAG;
bytes32 public constant NS_COVER_POLICY_RATE_FLOOR;
bytes32 public constant NS_COVER_POLICY_RATE_CEILING;
bytes32 public constant NS_POLICY_DISABLED;
bytes32 public constant NS_POLICY_LAST_PURCHASE_ID;
bytes32 public constant NS_COVER_STAKE;
bytes32 public constant NS_COVER_STAKE_OWNED;
bytes32 public constant NS_COVER_STATUS;
bytes32 public constant NS_COVER_CXTOKEN;
bytes32 public constant NS_VAULT_TOKEN_NAME;
bytes32 public constant NS_VAULT_TOKEN_SYMBOL;
bytes32 public constant NS_COVER_CREATOR_WHITELIST;
bytes32 public constant NS_COVER_USER_WHITELIST;
bytes32 public constant NS_COVER_CLAIM_BLACKLIST;
bytes32 public constant NS_GOVERNANCE_RESOLUTION_TS;
bytes32 public constant NS_GOVERNANCE_UNSTAKEN;
bytes32 public constant NS_GOVERNANCE_UNSTAKE_TS;
bytes32 public constant NS_GOVERNANCE_UNSTAKE_REWARD;
bytes32 public constant NS_GOVERNANCE_UNSTAKE_BURNED;
bytes32 public constant NS_GOVERNANCE_UNSTAKE_REPORTER_FEE;
bytes32 public constant NS_GOVERNANCE_REPORTING_MIN_FIRST_STAKE;
bytes32 public constant NS_GOVERNANCE_REPORTING_INCIDENT_DATE;
bytes32 public constant NS_GOVERNANCE_REPORTING_PERIOD;
bytes32 public constant NS_GOVERNANCE_REPORTING_WITNESS_YES;
bytes32 public constant NS_GOVERNANCE_REPORTING_HAS_A_DISPUTE;
bytes32 public constant NS_GOVERNANCE_REPORTING_FINALIZATION;
bytes32 public constant NS_GOVERNANCE_REPORTING_WITNESS_NO;
bytes32 public constant NS_GOVERNANCE_REPORTING_STAKE_OWNED_YES;
bytes32 public constant NS_GOVERNANCE_REPORTING_STAKE_OWNED_NO;
bytes32 public constant NS_GOVERNANCE_REPORTING_BURN_RATE;
bytes32 public constant NS_GOVERNANCE_REPORTER_COMMISSION;
bytes32 public constant NS_CLAIM_PERIOD;
bytes32 public constant NS_CLAIM_PAYOUTS;
bytes32 public constant NS_CLAIM_BEGIN_TS;
bytes32 public constant NS_CLAIM_EXPIRY_TS;
bytes32 public constant NS_RESOLUTION_DEADLINE;
bytes32 public constant NS_RESOLUTION_COOL_DOWN_PERIOD;
bytes32 public constant NS_COVER_PLATFORM_FEE;
bytes32 public constant NS_CLAIM_REPORTER_COMMISSION;
bytes32 public constant NS_LAST_LIQUIDITY_STATE_UPDATE;
bytes32 public constant NS_LIQUIDITY_STATE_UPDATE_INTERVAL;
bytes32 public constant NS_LENDING_STRATEGY_ACTIVE;
bytes32 public constant NS_LENDING_STRATEGY_DISABLED;
bytes32 public constant NS_LENDING_STRATEGY_WITHDRAWAL_START;
bytes32 public constant NS_ACCRUAL_INVOCATION;
bytes32 public constant NS_LENDING_STRATEGY_WITHDRAWAL_END;
bytes32 public constant CNAME_PROTOCOL;
bytes32 public constant CNAME_TREASURY;
bytes32 public constant CNAME_POLICY;
bytes32 public constant CNAME_POLICY_ADMIN;
bytes32 public constant CNAME_BOND_POOL;
bytes32 public constant CNAME_STAKING_POOL;
bytes32 public constant CNAME_CLAIMS_PROCESSOR;
bytes32 public constant CNAME_COVER;
bytes32 public constant CNAME_GOVERNANCE;
bytes32 public constant CNAME_RESOLUTION;
bytes32 public constant CNAME_VAULT_FACTORY;
bytes32 public constant CNAME_CXTOKEN_FACTORY;
bytes32 public constant CNAME_COVER_STAKE;
bytes32 public constant CNAME_COVER_REASSURANCE;
bytes32 public constant CNAME_LIQUIDITY_VAULT;
bytes32 public constant CNAME_VAULT_DELEGATE;
bytes32 public constant CNAME_LIQUIDITY_ENGINE;
- getProtocol(IStore s)
- getProtocolAddress(IStore s)
- getContract(IStore s, bytes32 name, bytes32 key)
- isProtocolMember(IStore s, address contractAddress)
- mustBeProtocolMember(IStore s, address contractAddress)
- mustBeExactContract(IStore s, bytes32 name, bytes32 key, address sender)
- senderMustBeExactContract(IStore s, bytes32 name)
- callerMustBeExactContract(IStore s, bytes32 name, address caller)
- npmToken(IStore s)
- getNpmTokenAddress(IStore s)
- getUniswapV2Router(IStore s)
- getUniswapV2Factory(IStore s)
- getNpmPriceOracle(IStore s)
- getTreasury(IStore s)
- getStablecoin(IStore s)
- getStablecoinPrecision(IStore s)
- getBurnAddress(IStore s)
function getProtocol(IStore s) external view
returns(contract IProtocol)
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function getProtocol(IStore s) external view returns (IProtocol) {
return IProtocol(getProtocolAddress(s));
}
function getProtocolAddress(IStore s) public view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function getProtocolAddress(IStore s) public view returns (address) {
return s.getAddressByKey(CNS_CORE);
}
function getContract(IStore s, bytes32 name, bytes32 key) public view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
name | bytes32 | |
key | bytes32 |
Source Code
function getContract(
IStore s,
bytes32 name,
bytes32 key
) public view returns (address) {
if (key > 0) {
return s.getAddressByKeys(NS_CONTRACTS, name, key);
}
return s.getAddressByKeys(NS_CONTRACTS, name);
}
function isProtocolMember(IStore s, address contractAddress) public view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
contractAddress | address |
Source Code
function isProtocolMember(IStore s, address contractAddress) public view returns (bool) {
return s.getBoolByKeys(ProtoUtilV1.NS_MEMBERS, contractAddress);
}
Reverts if the caller is one of the protocol members.
function mustBeProtocolMember(IStore s, address contractAddress) external view
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
contractAddress | address |
Source Code
function mustBeProtocolMember(IStore s, address contractAddress) external view {
bool isMember = isProtocolMember(s, contractAddress);
require(isMember, "Not a protocol member");
}
Ensures that the sender matches with the exact contract having the specified name.
function mustBeExactContract(IStore s, bytes32 name, bytes32 key, address sender) public view
Arguments
Name | Type | Description |
---|---|---|
s | IStore | ender Enter the msg.sender value |
name | bytes32 | Enter the name of the contract |
key | bytes32 | |
sender | address | Enter the msg.sender value |
Source Code
function mustBeExactContract(
IStore s,
bytes32 name,
bytes32 key,
address sender
) public view {
address contractAddress = getContract(s, name, key);
require(sender == contractAddress, "Access denied");
}
Ensures that the sender matches with the exact contract having the specified name.
function senderMustBeExactContract(IStore s, bytes32 name) external view
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
name | bytes32 | Enter the name of the contract |
Source Code
function senderMustBeExactContract(IStore s, bytes32 name) external view {
return callerMustBeExactContract(s, name, msg.sender);
}
Ensures that the sender matches with the exact contract having the specified name.
function callerMustBeExactContract(IStore s, bytes32 name, address caller) public view
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
name | bytes32 | Enter the name of the contract |
caller | address |
Source Code
function callerMustBeExactContract(
IStore s,
bytes32 name,
address caller
) public view {
return mustBeExactContract(s, name, ProtoUtilV1.KEY_INTENTIONALLY_EMPTY, caller);
}
function npmToken(IStore s) external view
returns(contract IERC20)
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function npmToken(IStore s) external view returns (IERC20) {
return IERC20(getNpmTokenAddress(s));
}
function getNpmTokenAddress(IStore s) public view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function getNpmTokenAddress(IStore s) public view returns (address) {
address npm = s.getAddressByKey(CNS_NPM);
return npm;
}
function getUniswapV2Router(IStore s) external view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function getUniswapV2Router(IStore s) external view returns (address) {
return s.getAddressByKey(CNS_UNISWAP_V2_ROUTER);
}
function getUniswapV2Factory(IStore s) external view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function getUniswapV2Factory(IStore s) external view returns (address) {
return s.getAddressByKey(CNS_UNISWAP_V2_FACTORY);
}
function getNpmPriceOracle(IStore s) external view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function getNpmPriceOracle(IStore s) external view returns (address) {
return s.getAddressByKey(CNS_NPM_PRICE_ORACLE);
}
function getTreasury(IStore s) external view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function getTreasury(IStore s) external view returns (address) {
return s.getAddressByKey(CNS_TREASURY);
}
function getStablecoin(IStore s) public view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function getStablecoin(IStore s) public view returns (address) {
return s.getAddressByKey(CNS_COVER_STABLECOIN);
}
function getStablecoinPrecision(IStore s) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function getStablecoinPrecision(IStore s) external view returns (uint256) {
return 10**IERC20Detailed(getStablecoin(s)).decimals();
}
function getBurnAddress(IStore s) external view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function getBurnAddress(IStore s) external view returns (address) {
return s.getAddressByKey(CNS_BURNER);
}
- 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