Skip to main content

VaultState

Git Source ↗

Inherits: VaultImmutables, Initializable ↗, VaultFee, IVaultState

Defines Vault's state manipulation

State Variables​

_totalShares​

uint128 internal _totalShares

_totalAssets​

uint128 internal _totalAssets

_queuedShares​

uint128 internal _queuedShares

_unclaimedAssets​

uint128 internal _unclaimedAssets

_exitQueue​

ExitQueue.History internal _exitQueue

_exitRequests​

mapping(bytes32 => uint256) internal _exitRequests

_balances​

mapping(address => uint256) internal _balances

_capacity​

uint256 private _capacity

_totalExitingAssets​

uint128 internal _totalExitingAssets

_totalExitingTickets​

uint128 internal _totalExitingTickets

_totalExitedTickets​

uint256 internal _totalExitedTickets

_donatedAssets​

uint256 internal _donatedAssets

__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[47] private __gap

Functions​

totalShares​

Function for retrieving total shares

function totalShares() external view override returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of shares in existence

totalAssets​

Total assets in the Vault

function totalAssets() external view override returns (uint256);

Returns

NameTypeDescription
<none>uint256The total amount of the underlying asset that is "managed" by Vault

getExitQueueData​

Get exit queue data

function getExitQueueData()
external
view
override
returns (
uint128 queuedShares,
uint128 unclaimedAssets,
uint128 totalExitingTickets,
uint128 totalExitingAssets,
uint256 totalTickets
);

Returns

NameTypeDescription
queuedSharesuint128The number of shares in the exit queue
unclaimedAssetsuint128The amount of unclaimed assets in the exit queue
totalExitingTicketsuint128The total number of exiting tickets
totalExitingAssetsuint128The total amount of exiting assets
totalTicketsuint256The total number of tickets in the exit queue

getShares​

Returns the number of shares held by an account

function getShares(address account) external view override returns (uint256);

Parameters

NameTypeDescription
accountaddressThe account for which to look up the number of shares it has, i.e. its balance

Returns

NameTypeDescription
<none>uint256The number of shares held by the account

convertToShares​

Converts assets to shares

function convertToShares(uint256 assets) public view override returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256The amount of assets to convert to shares

Returns

NameTypeDescription
sharesuint256The amount of shares that the Vault would exchange for the amount of assets provided

convertToAssets​

Converts shares to assets

function convertToAssets(uint256 shares) public view override returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256The amount of shares to convert to assets

Returns

NameTypeDescription
assetsuint256The amount of assets that the Vault would exchange for the amount of shares provided

donateShares​

Donates shares to the Vault by burning them from the caller, increasing the value per share for remaining holders

function donateShares(uint256 shares) public virtual override;

Parameters

NameTypeDescription
sharesuint256The number of shares to donate

capacity​

The Vault's capacity

function capacity() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount after which the Vault stops accepting deposits

withdrawableAssets​

Total assets available in the Vault. They can be staked or withdrawn.

function withdrawableAssets() public view override returns (uint256);

Returns

NameTypeDescription
<none>uint256The total amount of withdrawable assets

isStateUpdateRequired​

Check whether state update is required

function isStateUpdateRequired() external view virtual override 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 harvestParams) public virtual override;

Parameters

NameTypeDescription
harvestParamsIKeeperRewards.HarvestParamsThe parameters for harvesting Keeper rewards

_processTotalAssetsDelta​

Internal function for processing rewards and penalties

function _processTotalAssetsDelta(int256 totalAssetsDelta) internal virtual;

Parameters

NameTypeDescription
totalAssetsDeltaint256The number of assets earned or lost

_updateExitQueue​

Internal function that must be used to process exit queue

Make sure that sufficient time passed between exit queue updates (at least 12 hours). Currently it's restricted by the keeper's harvest interval

function _updateExitQueue() internal virtual returns (uint256 burnedShares);

Returns

NameTypeDescription
burnedSharesuint256The total amount of burned shares

_mintShares​

Internal function for minting shares

function _mintShares(address owner, uint256 shares) internal virtual;

Parameters

NameTypeDescription
owneraddressThe address of the owner to mint shares to
sharesuint256The number of shares to mint

_burnShares​

Internal function for burning shares

function _burnShares(address owner, uint256 shares) internal virtual;

Parameters

NameTypeDescription
owneraddressThe address of the owner to burn shares for
sharesuint256The number of shares to burn

_convertToShares​

Internal conversion function (from assets to shares) with support for rounding direction.

function _convertToShares(uint256 assets, Math.Rounding rounding) internal view returns (uint256 shares);

_harvestAssets​

Internal function for harvesting Vaults' new assets

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

Returns

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

_vaultAssets​

Internal function for retrieving the total assets stored in the Vault. NB! Assets can be forcibly sent to the vault, the returned value must be used with caution

function _vaultAssets() internal view virtual returns (uint256);

Returns

NameTypeDescription
<none>uint256The total amount of assets stored in the Vault

__VaultState_init​

Initializes the VaultState contract

function __VaultState_init(uint256 capacity_) internal onlyInitializing;

Parameters

NameTypeDescription
capacity_uint256The amount after which the Vault stops accepting deposits

__VaultState_upgrade​

Upgrades the VaultState contract

function __VaultState_upgrade() internal onlyInitializing;