View Source: contracts/libraries/StrategyLibV1.sol
StrategyLibV1
Events
event StrategyAdded(address indexed strategy);
- _deleteStrategy(IStore s, address toFind)
- _getIsActiveStrategyKey(address strategyAddress)
- disableStrategyInternal(IStore s, address toFind)
- addStrategiesInternal(IStore s, address[] strategies)
- getLendingPeriodsInternal(IStore s, bytes32 coverKey)
- setLendingPeriodsInternal(IStore s, bytes32 coverKey, uint256 lendingPeriod, uint256 withdrawalWindow)
- getLendingPeriodKey(bytes32 coverKey, bool ignoreMissingKey)
- getWithdrawalWindowKey(bytes32 coverKey, bool ignoreMissingKey)
- _addStrategy(IStore s, address deployedOn)
- getDisabledStrategiesInternal(IStore s)
- getActiveStrategiesInternal(IStore s)
function _deleteStrategy(IStore s, address toFind) private nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
toFind | address |
Source Code
function _deleteStrategy(IStore s, address toFind) private {
bytes32 key = ProtoUtilV1.NS_LENDING_STRATEGY_ACTIVE;
uint256 pos = s.getAddressArrayItemPosition(key, toFind);
require(pos > 1, "Invalid strategy");
s.deleteAddressArrayItem(key, toFind);
s.setBoolByKey(_getIsActiveStrategyKey(toFind), false);
}
function _getIsActiveStrategyKey(address strategyAddress) private pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
strategyAddress | address |
Source Code
function _getIsActiveStrategyKey(address strategyAddress) private pure returns (bytes32) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_LENDING_STRATEGY_ACTIVE, strategyAddress));
}
function disableStrategyInternal(IStore s, address toFind) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
toFind | address |
Source Code
function disableStrategyInternal(IStore s, address toFind) external {
// @suppress-address-trust-issue Check caller.
_deleteStrategy(s, toFind);
s.setAddressArrayByKey(ProtoUtilV1.NS_LENDING_STRATEGY_DISABLED, toFind);
}
function addStrategiesInternal(IStore s, address[] strategies) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
strategies | address[] |
Source Code
function addStrategiesInternal(IStore s, address[] memory strategies) external {
for (uint256 i = 0; i < strategies.length; i++) {
address strategy = strategies[i];
_addStrategy(s, strategy);
}
}
function getLendingPeriodsInternal(IStore s, bytes32 coverKey) external view
returns(lendingPeriod uint256, withdrawalWindow uint256)
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 |
Source Code
function getLendingPeriodsInternal(IStore s, bytes32 coverKey) external view returns (uint256 lendingPeriod, uint256 withdrawalWindow) {
lendingPeriod = s.getUintByKey(getLendingPeriodKey(coverKey, true));
withdrawalWindow = s.getUintByKey(getWithdrawalWindowKey(coverKey, true));
if (lendingPeriod == 0) {
lendingPeriod = s.getUintByKey(getLendingPeriodKey(0, true));
withdrawalWindow = s.getUintByKey(getWithdrawalWindowKey(0, true));
}
}
function setLendingPeriodsInternal(IStore s, bytes32 coverKey, uint256 lendingPeriod, uint256 withdrawalWindow) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
coverKey | bytes32 | |
lendingPeriod | uint256 | |
withdrawalWindow | uint256 |
Source Code
function setLendingPeriodsInternal(
IStore s,
bytes32 coverKey,
uint256 lendingPeriod,
uint256 withdrawalWindow
) external {
s.setUintByKey(getLendingPeriodKey(coverKey, true), lendingPeriod);
s.setUintByKey(getWithdrawalWindowKey(coverKey, true), withdrawalWindow);
}
function getLendingPeriodKey(bytes32 coverKey, bool ignoreMissingKey) public pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | |
ignoreMissingKey | bool |
Source Code
function getLendingPeriodKey(bytes32 coverKey, bool ignoreMissingKey) public pure returns (bytes32) {
if (ignoreMissingKey == false) {
require(coverKey > 0, "Invalid Cover Key");
}
if (coverKey > 0) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_COVER_LIQUIDITY_LENDING_PERIOD, coverKey));
}
return ProtoUtilV1.NS_COVER_LIQUIDITY_LENDING_PERIOD;
}
function getWithdrawalWindowKey(bytes32 coverKey, bool ignoreMissingKey) public pure
returns(bytes32)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | |
ignoreMissingKey | bool |
Source Code
function getWithdrawalWindowKey(bytes32 coverKey, bool ignoreMissingKey) public pure returns (bytes32) {
if (ignoreMissingKey == false) {
require(coverKey > 0, "Invalid Cover Key");
}
if (coverKey > 0) {
return keccak256(abi.encodePacked(ProtoUtilV1.NS_COVER_LIQUIDITY_WITHDRAWAL_WINDOW, coverKey));
}
return ProtoUtilV1.NS_COVER_LIQUIDITY_WITHDRAWAL_WINDOW;
}
function _addStrategy(IStore s, address deployedOn) private nonpayable
Arguments
Name | Type | Description |
---|---|---|
s | IStore | |
deployedOn | address |
Source Code
function _addStrategy(IStore s, address deployedOn) private {
ILendingStrategy strategy = ILendingStrategy(deployedOn);
require(strategy.getWeight() <= ProtoUtilV1.MULTIPLIER, "Weight too much");
s.setBoolByKey(_getIsActiveStrategyKey(deployedOn), true);
s.setAddressArrayByKey(ProtoUtilV1.NS_LENDING_STRATEGY_ACTIVE, deployedOn);
emit StrategyAdded(deployedOn);
}
function getDisabledStrategiesInternal(IStore s) external view
returns(strategies address[])
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function getDisabledStrategiesInternal(IStore s) external view returns (address[] memory strategies) {
return s.getAddressArrayByKey(ProtoUtilV1.NS_LENDING_STRATEGY_DISABLED);
}
function getActiveStrategiesInternal(IStore s) external view
returns(strategies address[])
Arguments
Name | Type | Description |
---|---|---|
s | IStore |
Source Code
function getActiveStrategiesInternal(IStore s) external view returns (address[] memory strategies) {
return s.getAddressArrayByKey(ProtoUtilV1.NS_LENDING_STRATEGY_ACTIVE);
}
- AaveStrategy
- AccessControl
- AccessControlLibV1
- Address
- BaseLibV1
- BokkyPooBahsDateTimeLibrary
- BondPool
- BondPoolBase
- BondPoolLibV1
- CompoundStrategy
- Context
- Controller
- Cover
- CoverBase
- CoverLibV1
- CoverProvision
- CoverReassurance
- CoverStake
- CoverUtilV1
- cxToken
- cxTokenFactory
- cxTokenFactoryLibV1
- Destroyable
- ERC165
- ERC20
- FakeAaveLendingPool
- FakeCompoundERC20Delegator
- FakeRecoverable
- FakeStore
- FakeToken
- FakeUniswapPair
- FakeUniswapV2FactoryLike
- FakeUniswapV2PairLike
- FakeUniswapV2RouterLike
- Finalization
- Governance
- GovernanceUtilV1
- IAaveV2LendingPoolLike
- IAccessControl
- IBondPool
- IClaimsProcessor
- ICommission
- ICompoundERC20DelegatorLike
- ICover
- ICoverProvision
- ICoverReassurance
- ICoverStake
- ICxToken
- ICxTokenFactory
- IERC165
- IERC20
- IERC20Detailed
- IERC20Metadata
- IERC3156FlashBorrower
- IERC3156FlashLender
- IFinalization
- IGovernance
- ILendingStrategy
- ILiquidityEngine
- IMember
- IPausable
- IPolicy
- IPolicyAdmin
- IPriceDiscovery
- IProtocol
- IRecoverable
- IReporter
- IResolution
- IResolvable
- IStakingPools
- IStore
- IUniswapV2FactoryLike
- IUniswapV2PairLike
- IUniswapV2RouterLike
- IUnstakable
- IVault
- IVaultFactory
- IWitness
- LiquidityEngine
- MaliciousToken
- Migrations
- MockCxToken
- MockCxTokenPolicy
- MockCxTokenStore
- MockProcessorStore
- MockProcessorStoreLib
- MockProtocol
- MockStore
- MockVault
- NTransferUtilV2
- NTransferUtilV2Intermediate
- Ownable
- Pausable
- Policy
- PolicyAdmin
- PolicyHelperV1
- PriceDiscovery
- PriceLibV1
- Processor
- ProtoBase
- Protocol
- ProtoUtilV1
- Recoverable
- ReentrancyGuard
- RegistryLibV1
- Reporter
- Resolution
- Resolvable
- RoutineInvokerLibV1
- SafeERC20
- StakingPoolBase
- StakingPoolCoreLibV1
- StakingPoolInfo
- StakingPoolLibV1
- StakingPoolReward
- StakingPools
- Store
- StoreBase
- StoreKeyUtil
- StrategyLibV1
- Strings
- Unstakable
- ValidationLibV1
- Vault
- VaultBase
- VaultFactory
- VaultFactoryLibV1
- VaultLibV1
- WithFlashLoan
- Witness