Skip to main content

VaultSubVaults

Git Source ↗

Inherits: VaultImmutables, Initializable ↗, VaultState, IVaultSubVaults

Defines the functionality for managing the Vault sub-vaults

State Variables

_subVaultsRegistryFactory

Note: oz-upgrades-unsafe-allow: state-variable-immutable

address private immutable _subVaultsRegistryFactory

__deprecated__subVaultsCurator

Deprecated: moved to SubVaultsRegistry

address private __deprecated__subVaultsCurator

__deprecated__ejectingSubVault

Deprecated: moved to SubVaultsRegistry

address private __deprecated__ejectingSubVault

__deprecated__subVaults

Deprecated: moved to SubVaultsRegistry

EnumerableSet.AddressSet private __deprecated__subVaults

__deprecated__subVaultsExits

Deprecated: moved to SubVaultsRegistry

mapping(address vault => DoubleEndedQueue.Bytes32Deque) private __deprecated__subVaultsExits

__deprecated__subVaultsStates

Deprecated: moved to SubVaultsRegistry

mapping(address vault => ISubVaultsRegistry.SubVaultState state) private __deprecated__subVaultsStates

__deprecated__subVaultsRewardsNonce

Deprecated: moved to SubVaultsRegistry

uint128 private __deprecated__subVaultsRewardsNonce

__deprecated__subVaultsTotalAssets

Deprecated: moved to SubVaultsRegistry

uint128 private __deprecated__subVaultsTotalAssets

__deprecated__totalProcessedExitQueueTickets

Deprecated: moved to SubVaultsRegistry

uint256 private __deprecated__totalProcessedExitQueueTickets

__deprecated__ejectingSubVaultShares

Deprecated: moved to SubVaultsRegistry

uint256 private __deprecated__ejectingSubVaultShares

subVaultsRegistry

Returns the address of the SubVaultsRegistry contract

address public override subVaultsRegistry

__gap

This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain. See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps

uint256[49] private __gap

Functions

constructor

Constructor

Since the immutable variable value is stored in the bytecode, its value would be shared among all proxies pointing to a given contract instead of each proxy’s storage.

Note: oz-upgrades-unsafe-allow: constructor

constructor(address subVaultsRegistryFactory) ;

Parameters

NameTypeDescription
subVaultsRegistryFactoryaddressThe address of the factory used to deploy SubVaultsRegistry contract

depositToSubVault

Function to deposit assets to a sub vault. Can only be called by SubVaultsRegistry contract.

function depositToSubVault(address vault, uint256 assets) external override returns (uint256);

Parameters

NameTypeDescription
vaultaddressThe address of the sub-vault
assetsuint256The amount of assets to deposit

Returns

NameTypeDescription
<none>uint256shares The amount of vault shares received

enterSubVaultExitQueue

Function to enter sub-vault exit queue. Can only be called by SubVaultsRegistry contract.

function enterSubVaultExitQueue(address vault, uint256 shares) external override returns (uint256 positionTicket);

Parameters

NameTypeDescription
vaultaddressThe address of the sub-vault
sharesuint256The amount of shares to exit

Returns

NameTypeDescription
positionTicketuint256The position ticket in the exit queue

claimSubVaultExitedAssets

Function to claim exited assets from a sub-vault. Can only be called by SubVaultsRegistry contract.

function claimSubVaultExitedAssets(address vault, uint256 positionTicket, uint256 timestamp, uint256 exitQueueIndex)
external
override;

Parameters

NameTypeDescription
vaultaddressThe address of the sub-vault
positionTicketuint256The position ticket in the exit queue
timestampuint256The timestamp of the exit request
exitQueueIndexuint256The index of the exit queue

mintSubVaultOsToken

Function to mint osToken for a sub-vault. Can only be called by SubVaultsRegistry contract.

function mintSubVaultOsToken(address vault, address receiver, uint256 osTokenShares) external override;

Parameters

NameTypeDescription
vaultaddressThe address of the sub-vault
receiveraddressThe address that will receive the minted osToken shares
osTokenSharesuint256The amount of osToken shares to mint

redeemSubVaultOsToken

Function to redeem osToken from a sub-vault. Can only be called by SubVaultsRegistry contract.

function redeemSubVaultOsToken(address vault, address redeemer, uint256 osTokenShares)
external
override
returns (uint256 assets);

Parameters

NameTypeDescription
vaultaddressThe address of the sub-vault
redeemeraddressThe address of the OsToken redeemer
osTokenSharesuint256The amount of osToken shares to redeem

Returns

NameTypeDescription
assetsuint256The amount of assets redeemed

isStateUpdateRequired

Check whether state update is required

function isStateUpdateRequired() public view virtual override(IVaultState, VaultState) returns (bool);

Returns

NameTypeDescription
<none>booltrue if state update is required, false otherwise

updateState

Updates the total amount of assets in the Vault and its exit queue

function updateState(IKeeperRewards.HarvestParams calldata) public virtual override(IVaultState, VaultState);

Parameters

NameTypeDescription
<none>IKeeperRewards.HarvestParams

_harvestAssets

Internal function for harvesting Vaults' new assets

function _harvestAssets(IKeeperRewards.HarvestParams calldata)
internal
pure
override
returns (int256 totalAssetsDelta, bool harvested);

Returns

NameTypeDescription
totalAssetsDeltaint256The total assets delta after harvest
harvestedbooltrue when the rewards were harvested, false otherwise

_checkHarvested

Internal method for checking whether the vault is harvested

function _checkHarvested() internal view virtual override;

_isCollateralized

Returns whether the vault is collateralized

function _isCollateralized() internal view virtual override returns (bool);

Returns

NameTypeDescription
<none>booltrue if the vault is collateralized

_depositToVault

Internal function to deposit assets to the sub-vault

function _depositToVault(address vault, uint256 assets) internal virtual returns (uint256);

Parameters

NameTypeDescription
vaultaddressThe address of the vault
assetsuint256The amount of assets to deposit

Returns

NameTypeDescription
<none>uint256The amount of vault shares received

_checkSubVaultsRegistry

Internal function to check if the caller is the SubVaultsRegistry

function _checkSubVaultsRegistry() private view;

__VaultSubVaults_init

Initializes the VaultSubVaults contract

function __VaultSubVaults_init(address curator) internal onlyInitializing;

Parameters

NameTypeDescription
curatoraddressThe address of initial sub-vaults curator

__VaultSubVaults_upgrade

Upgrades the VaultSubVaults contract by upgrading the SubVaultsRegistry proxy to the latest implementation

function __VaultSubVaults_upgrade() internal onlyInitializing;