View Source: contracts/core/liquidity/VaultStrategy.sol
↗ Extends: VaultLiquidity ↘ Derived Contracts: WithFlashLoan
VaultStrategy
Constants & Variables
uint256 private _transferToStrategyEntry;
uint256 private _receiveFromStrategyEntry;
- transferToStrategy(IERC20 token, bytes32 coverKey, bytes32 strategyName, uint256 amount)
- receiveFromStrategy(IERC20 token, bytes32 coverKey, bytes32 strategyName, uint256 amount)
Transfers tokens to strategy contract(s).
Uses the hooks preTransferToStrategy
and postTransferToStrategy
on the vault delegate contract.
function transferToStrategy(IERC20 token, bytes32 coverKey, bytes32 strategyName, uint256 amount) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
token | IERC20 | |
coverKey | bytes32 | |
strategyName | bytes32 | |
amount | uint256 |
Source Code
function transferToStrategy(
IERC20 token,
bytes32 coverKey,
bytes32 strategyName,
uint256 amount
) external override {
require(address(token) != address(0), "Invalid token to transfer");
require(coverKey == key, "Forbidden");
require(strategyName > 0, "Invalid strategy");
require(amount > 0, "Please specify amount");
// Reentrancy check
require(_transferToStrategyEntry == 0, "Access is denied");
_transferToStrategyEntry = 1;
/******************************************************************************************
PRE
******************************************************************************************/
delegate().preTransferToStrategy(msg.sender, token, coverKey, strategyName, amount);
/******************************************************************************************
BODY
******************************************************************************************/
token.ensureTransfer(msg.sender, amount);
/******************************************************************************************
POST
******************************************************************************************/
delegate().postTransferToStrategy(msg.sender, token, coverKey, strategyName, amount);
emit StrategyTransfer(address(token), msg.sender, strategyName, amount);
_transferToStrategyEntry = 0;
}
Receives tokens from strategy contract(s).
Uses the hooks preReceiveFromStrategy
and postReceiveFromStrategy
on the vault delegate contract.
function receiveFromStrategy(IERC20 token, bytes32 coverKey, bytes32 strategyName, uint256 amount) external nonpayable
Arguments
Name | Type | Description |
---|---|---|
token | IERC20 | |
coverKey | bytes32 | |
strategyName | bytes32 | |
amount | uint256 |
Source Code
function receiveFromStrategy(
IERC20 token,
bytes32 coverKey,
bytes32 strategyName,
uint256 amount
) external override {
require(coverKey == key, "Forbidden");
require(_receiveFromStrategyEntry == 0, "Access is denied");
require(amount > 0, "Please specify amount");
_receiveFromStrategyEntry = 1;
/******************************************************************************************
PRE
******************************************************************************************/
delegate().preReceiveFromStrategy(msg.sender, token, coverKey, strategyName, amount);
/******************************************************************************************
BODY
******************************************************************************************/
token.ensureTransferFrom(msg.sender, address(this), amount);
/******************************************************************************************
POST
******************************************************************************************/
(uint256 income, uint256 loss) = delegate().postReceiveFromStrategy(msg.sender, token, coverKey, strategyName, amount);
emit StrategyReceipt(address(token), msg.sender, strategyName, amount, income, loss);
_receiveFromStrategyEntry = 0;
}
- 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
- FakeCompoundStablecoinDelegator
- FakePriceOracle
- FakeRecoverable
- FakeStore
- FakeToken
- FakeUniswapPair
- FakeUniswapV2FactoryLike
- FakeUniswapV2PairLike
- FakeUniswapV2RouterLike
- FaultyAaveLendingPool
- FaultyCompoundStablecoinDelegator
- 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