View Source: contracts/core/delegates/VaultDelegateBase.sol
↗ Extends: IVaultDelegate, Recoverable ↘ Derived Contracts: VaultDelegateWithFlashLoan
VaultDelegateBase
The vault delegate base contract includes pre and post hooks. The hooks are accessible only to vault contracts.
- constructor(IStore store)
- preTransferGovernance(address caller, bytes32 coverKey, address , uint256 )
- postTransferGovernance(address caller, bytes32 coverKey, address , uint256 )
- preTransferToStrategy(address caller, IERC20 token, bytes32 coverKey, bytes32 strategyName, uint256 amount)
- postTransferToStrategy(address caller, IERC20 , bytes32 coverKey, bytes32 strategyName, uint256 )
- preReceiveFromStrategy(address caller, IERC20 , bytes32 coverKey, bytes32 strategyName, uint256 )
- postReceiveFromStrategy(address caller, IERC20 token, bytes32 coverKey, bytes32 strategyName, uint256 amount)
- preAddLiquidity(address caller, bytes32 coverKey, uint256 amount, uint256 npmStakeToAdd)
- postAddLiquidity(address , bytes32 coverKey, uint256 , uint256 )
- accrueInterestImplementation(address caller, bytes32 coverKey)
- preRemoveLiquidity(address caller, bytes32 coverKey, uint256 podsToRedeem, uint256 npmStakeToRemove, bool exit)
- postRemoveLiquidity(address , bytes32 coverKey, uint256 , uint256 , bool )
- calculatePodsImplementation(bytes32 coverKey, uint256 stablecoinIn)
- calculateLiquidityImplementation(bytes32 coverKey, uint256 podsToBurn)
- getStablecoinBalanceOfImplementation(bytes32 coverKey)
- getInfoImplementation(bytes32 coverKey, address you)
- version()
- getName()
Constructs this contract
function (IStore store) internal nonpayable Recoverable
Arguments
Name | Type | Description |
---|---|---|
store | IStore | Provide the store contract instance |
Source Code
constructor(IStore store) Recoverable(store) {}
This hook runs before transferGovernance
implementation on vault(s).
function preTransferGovernance(address caller, bytes32 coverKey, address , uint256 ) external nonpayable nonReentrant
returns(stablecoin address)
Arguments
Name | Type | Description |
---|---|---|
caller | address | Enter your msg.sender value. |
coverKey | bytes32 | Provide your vault's cover key. |
address | caller Enter your msg.sender value. | |
uint256 | caller Enter your msg.sender value. |
Returns
stablecoin Returns address of the protocol stablecoin if the hook validation passes.
Source Code
function preTransferGovernance(
address caller,
bytes32 coverKey,
address, /*to*/
uint256 /*amount*/
) external override nonReentrant returns (address stablecoin) {
// @suppress-zero-value-check This function does not transfer any values
s.mustNotBePaused();
s.mustBeProtocolMember(caller);
s.mustBeProtocolMember(msg.sender);
s.senderMustBeVaultContract(coverKey);
s.callerMustBeClaimsProcessorContract(caller);
stablecoin = s.getStablecoin();
}
This hook runs after transferGovernance
implementation on vault(s)
and performs cleanup and/or validation if needed.
function postTransferGovernance(address caller, bytes32 coverKey, address , uint256 ) external view
Arguments
Name | Type | Description |
---|---|---|
caller | address | Enter your msg.sender value. |
coverKey | bytes32 | Provide your vault's cover key. |
address | caller Enter your msg.sender value. | |
uint256 | caller Enter your msg.sender value. |
Source Code
function postTransferGovernance(
address caller,
bytes32 coverKey,
address, /*to*/
uint256 /*amount*/
) external view override {
s.mustNotBePaused();
s.mustBeProtocolMember(caller);
s.mustBeProtocolMember(msg.sender);
s.senderMustBeVaultContract(coverKey);
s.callerMustBeClaimsProcessorContract(caller);
}
This hook runs before transferToStrategy
implementation on vault(s)
function preTransferToStrategy(address caller, IERC20 token, bytes32 coverKey, bytes32 strategyName, uint256 amount) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
caller | address | Enter your msg.sender value |
token | IERC20 | Provide the ERC20 token you'd like to transfer to the given strategy |
coverKey | bytes32 | Provide your vault's cover key |
strategyName | bytes32 | Enter the strategy name |
amount | uint256 | Enter the amount to transfer |
Source Code
function preTransferToStrategy(
address caller,
IERC20 token,
bytes32 coverKey,
bytes32 strategyName,
uint256 amount
) external override nonReentrant {
// @suppress-zero-value-check Checked
s.mustNotBePaused();
s.mustBeProtocolMember(caller);
s.mustBeProtocolMember(msg.sender);
s.senderMustBeVaultContract(coverKey);
s.callerMustBeSpecificStrategyContract(caller, strategyName);
s.preTransferToStrategyInternal(token, coverKey, strategyName, amount);
}
This hook runs after transferToStrategy
implementation on vault(s)
and performs cleanup and/or validation if needed.
function postTransferToStrategy(address caller, IERC20 , bytes32 coverKey, bytes32 strategyName, uint256 ) external view
Arguments
Name | Type | Description |
---|---|---|
caller | address | Enter your msg.sender value |
IERC20 | caller Enter your msg.sender value | |
coverKey | bytes32 | Enter the coverKey |
strategyName | bytes32 | Enter the strategy name |
uint256 | caller Enter your msg.sender value |
Source Code
function postTransferToStrategy(
address caller,
IERC20, /*token*/
bytes32 coverKey,
bytes32 strategyName,
uint256 /*amount*/
) external view override {
s.mustNotBePaused();
s.mustBeProtocolMember(caller);
s.mustBeProtocolMember(msg.sender);
s.senderMustBeVaultContract(coverKey);
s.callerMustBeSpecificStrategyContract(caller, strategyName);
}
This hook runs before receiveFromStrategy
implementation on vault(s)
function preReceiveFromStrategy(address caller, IERC20 , bytes32 coverKey, bytes32 strategyName, uint256 ) external nonpayable nonReentrant
Arguments
Name | Type | Description |
---|---|---|
caller | address | Enter your msg.sender value |
IERC20 | caller Enter your msg.sender value | |
coverKey | bytes32 | Provide your vault's cover key |
strategyName | bytes32 | Enter the strategy name |
uint256 | caller Enter your msg.sender value |
Source Code
function preReceiveFromStrategy(
address caller,
IERC20, /*token*/
bytes32 coverKey,
bytes32 strategyName,
uint256 /*amount*/
) external override nonReentrant {
// @suppress-zero-value-check This function does not transfer any tokens
s.mustNotBePaused();
s.mustBeProtocolMember(caller);
s.mustBeProtocolMember(msg.sender);
s.senderMustBeVaultContract(coverKey);
s.callerMustBeSpecificStrategyContract(caller, strategyName);
}
This hook runs after receiveFromStrategy
implementation on vault(s)
and performs cleanup and/or validation if needed.
function postReceiveFromStrategy(address caller, IERC20 token, bytes32 coverKey, bytes32 strategyName, uint256 amount) external nonpayable
returns(income uint256, loss uint256)
Arguments
Name | Type | Description |
---|---|---|
caller | address | Enter your msg.sender value |
token | IERC20 | Enter the token your vault received from strategy |
coverKey | bytes32 | Enter the coverKey |
strategyName | bytes32 | Enter the strategy name |
amount | uint256 | Enter the amount received |
Source Code
function postReceiveFromStrategy(
address caller,
IERC20 token,
bytes32 coverKey,
bytes32 strategyName,
uint256 amount
) external override returns (uint256 income, uint256 loss) {
// @suppress-zero-value-check This call does not perform any transfers
s.mustNotBePaused();
s.mustBeProtocolMember(caller);
s.mustBeProtocolMember(msg.sender);
s.senderMustBeVaultContract(coverKey);
s.callerMustBeSpecificStrategyContract(caller, strategyName);
(income, loss) = s.postReceiveFromStrategyInternal(token, coverKey, strategyName, amount);
}
This hook runs before addLiquidity
implementation on vault(s)
function preAddLiquidity(address caller, bytes32 coverKey, uint256 amount, uint256 npmStakeToAdd) external nonpayable nonReentrant
returns(podsToMint uint256, previousNpmStake uint256)
Arguments
Name | Type | Description |
---|---|---|
caller | address | |
coverKey | bytes32 | Enter the cover key |
amount | uint256 | Enter the amount of liquidity token to supply. |
npmStakeToAdd | uint256 | Enter the amount of NPM token to stake. |
Source Code
function preAddLiquidity(
address caller,
bytes32 coverKey,
uint256 amount,
uint256 npmStakeToAdd
) external override nonReentrant returns (uint256 podsToMint, uint256 previousNpmStake) {
// @suppress-zero-value-check This call does not transfer any tokens
s.mustNotBePaused();
s.mustBeProtocolMember(msg.sender);
s.senderMustBeVaultContract(coverKey);
s.mustEnsureAllProductsAreNormal(coverKey);
ValidationLibV1.mustNotExceedStablecoinThreshold(s, amount);
GovernanceUtilV1.mustNotExceedNpmThreshold(npmStakeToAdd);
address pod = msg.sender;
(podsToMint, previousNpmStake) = s.preAddLiquidityInternal(coverKey, pod, caller, amount, npmStakeToAdd);
}
This hook runs after addLiquidity
implementation on vault(s)
and performs cleanup and/or validation if needed.
function postAddLiquidity(address , bytes32 coverKey, uint256 , uint256 ) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
address | coverKey Enter the coverKey | |
coverKey | bytes32 | Enter the coverKey |
uint256 | coverKey Enter the coverKey | |
uint256 | coverKey Enter the coverKey |
Source Code
function postAddLiquidity(
address, /*caller*/
bytes32 coverKey,
uint256, /*amount*/
uint256 /*npmStakeToAdd*/
) external override {
// @suppress-zero-value-check This function does not transfer any tokens
s.mustNotBePaused();
s.mustBeProtocolMember(msg.sender);
s.senderMustBeVaultContract(coverKey);
s.mustEnsureAllProductsAreNormal(coverKey);
s.updateStateAndLiquidity(coverKey);
}
This implemention enables liquidity manages to accrue interests on a vault before withdrawals are allowed.
function accrueInterestImplementation(address caller, bytes32 coverKey) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
caller | address | Enter your msg.sender value |
coverKey | bytes32 | Provide your vault's cover key |
Source Code
function accrueInterestImplementation(address caller, bytes32 coverKey) external override {
s.mustNotBePaused();
s.senderMustBeVaultContract(coverKey);
AccessControlLibV1.callerMustBeLiquidityManager(s, caller);
s.accrueInterestInternal(coverKey);
}
This hook runs before removeLiquidity
implementation on vault(s)
function preRemoveLiquidity(address caller, bytes32 coverKey, uint256 podsToRedeem, uint256 npmStakeToRemove, bool exit) external nonpayable nonReentrant
returns(stablecoin address, stablecoinToRelease uint256)
Arguments
Name | Type | Description |
---|---|---|
caller | address | Enter your msg.sender value |
coverKey | bytes32 | Enter the cover key |
podsToRedeem | uint256 | Enter the amount of pods to redeem |
npmStakeToRemove | uint256 | Enter the amount of NPM stake to remove. |
exit | bool | If this is set to true, LPs can remove their entire NPM stake during a withdrawal period. No restriction. |
Source Code
function preRemoveLiquidity(
address caller,
bytes32 coverKey,
uint256 podsToRedeem,
uint256 npmStakeToRemove,
bool exit
) external override nonReentrant returns (address stablecoin, uint256 stablecoinToRelease) {
// @suppress-zero-value-check This call does not transfer any tokens
s.mustNotBePaused();
s.mustBeProtocolMember(msg.sender);
s.senderMustBeVaultContract(coverKey);
s.mustMaintainBlockHeightOffset(coverKey);
s.mustEnsureAllProductsAreNormal(coverKey);
s.mustBeDuringWithdrawalPeriod(coverKey);
s.mustHaveNoBalanceInStrategies(coverKey, stablecoin);
s.mustBeAccrued(coverKey);
address pod = msg.sender; // The sender is vault contract
return s.preRemoveLiquidityInternal(coverKey, pod, caller, podsToRedeem, npmStakeToRemove, exit);
}
This hook runs after removeLiquidity
implementation on vault(s)
and performs cleanup and/or validation if needed.
function postRemoveLiquidity(address , bytes32 coverKey, uint256 , uint256 , bool ) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
address | coverKey Enter the coverKey | |
coverKey | bytes32 | Enter the coverKey |
uint256 | coverKey Enter the coverKey | |
uint256 | coverKey Enter the coverKey | |
bool | coverKey Enter the coverKey |
Source Code
function postRemoveLiquidity(
address, /*caller*/
bytes32 coverKey,
uint256, /*podsToRedeem*/
uint256, /*npmStakeToRemove*/
bool /*exit*/
) external override {
// @suppress-zero-value-check The uint values are not used and therefore not checked
s.mustNotBePaused();
s.mustBeProtocolMember(msg.sender);
s.senderMustBeVaultContract(coverKey);
s.updateStateAndLiquidity(coverKey);
}
Calculates the amount of PODs to mint for the given amount of stablecoin
function calculatePodsImplementation(bytes32 coverKey, uint256 stablecoinIn) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the cover for which you want to calculate PODs |
stablecoinIn | uint256 | Enter the amount in the stablecoin units |
Returns
Returns the units of PODs to be minted if this stablecoin liquidity was supplied. Be warned that this value may change based on the cover vault's usage.
Source Code
function calculatePodsImplementation(bytes32 coverKey, uint256 stablecoinIn) external view override returns (uint256) {
s.senderMustBeVaultContract(coverKey);
address pod = msg.sender;
return s.calculatePodsInternal(coverKey, pod, stablecoinIn);
}
Calculates the amount of stablecoin units to receive for the given amount of PODs to redeem
function calculateLiquidityImplementation(bytes32 coverKey, uint256 podsToBurn) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the cover for which you want to calculate PODs |
podsToBurn | uint256 | Enter the amount in the POD units to redeem |
Returns
Returns the units of stablecoins to redeem if the specified PODs were burned. Be warned that this value may change based on the cover's vault usage.
Source Code
function calculateLiquidityImplementation(bytes32 coverKey, uint256 podsToBurn) external view override returns (uint256) {
s.senderMustBeVaultContract(coverKey);
address pod = msg.sender;
return s.calculateLiquidityInternal(coverKey, pod, podsToBurn);
}
Returns the stablecoin balance of this vault This also includes amounts lent out in lending strategies by this vault Warning: this function does not validate the cover key supplied.
function getStablecoinBalanceOfImplementation(bytes32 coverKey) external view
returns(uint256)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the cover for which you want to get the stablecoin balance |
Source Code
function getStablecoinBalanceOfImplementation(bytes32 coverKey) external view override returns (uint256) {
s.senderMustBeVaultContract(coverKey);
return s.getStablecoinOwnedByVaultInternal(coverKey);
}
Gets information of a given vault by the cover key Warning: this function does not validate the cover key and account supplied.
function getInfoImplementation(bytes32 coverKey, address you) external view
returns(struct IVault.VaultInfoType)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Specify cover key to obtain the info of |
you | address | The address for which the info will be customized |
Source Code
function getInfoImplementation(bytes32 coverKey, address you) external view override returns (IVault.VaultInfoType memory) {
s.senderMustBeVaultContract(coverKey);
address pod = msg.sender;
return s.getInfoInternal(coverKey, pod, you);
}
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_VAULT_DELEGATE;
}
- 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