Skip to main content

VaultCore

VaultCore​

MAX_INT​

uint256 MAX_INT

MAX_UINT​

uint256 MAX_UINT

whenNotRebasePaused​

modifier whenNotRebasePaused()

Verifies that the rebasing is not paused.

whenNotCapitalPaused​

modifier whenNotCapitalPaused()

Verifies that the deposits are not paused.

onlyOusdMetaStrategy​

modifier onlyOusdMetaStrategy()

mint​

function mint(address _asset, uint256 _amount, uint256 _minimumOusdAmount) external

Deposit a supported asset and mint OTokens.

Parameters​

NameTypeDescription
_assetaddressAddress of the asset being deposited
_amountuint256Amount of the asset being deposited
_minimumOusdAmountuint256Minimum OTokens to mint

mintForStrategy​

function mintForStrategy(uint256 _amount) external

Mint OTokens for a Metapool Strategy

Parameters​

NameTypeDescription
_amountuint256Amount of the asset being deposited Notice: can't use nonReentrant modifier since the mint function can call allocate, and that can trigger ConvexOUSDMetaStrategy to call this function while the execution of the mint has not yet completed -> causing a nonReentrant collision. Also important to understand is that this is a limitation imposed by the test suite. Production / mainnet contracts should never be configured in a way where mint/redeem functions that are moving funds between the Vault and end user wallets can influence strategies utilizing this function.

redeem​

function redeem(uint256 _amount, uint256 _minimumUnitAmount) external

Withdraw a supported asset and burn OTokens.

Parameters​

NameTypeDescription
_amountuint256Amount of OTokens to burn
_minimumUnitAmountuint256Minimum stablecoin units to receive in return

_redeem​

function _redeem(uint256 _amount, uint256 _minimumUnitAmount) internal

Withdraw a supported asset and burn OTokens.

Parameters​

NameTypeDescription
_amountuint256Amount of OTokens to burn
_minimumUnitAmountuint256Minimum stablecoin units to receive in return

burnForStrategy​

function burnForStrategy(uint256 _amount) external

Burn OTokens for Metapool Strategy

Notice: can't use nonReentrant modifier since the redeem function could require withdrawal on ConvexOUSDMetaStrategy and that one can call burnForStrategy while the execution of the redeem has not yet completed -> causing a nonReentrant collision.

Also important to understand is that this is a limitation imposed by the test suite. Production / mainnet contracts should never be configured in a way where mint/redeem functions that are moving funds between the Vault and end user wallets can influence strategies utilizing this function.

Parameters​

NameTypeDescription
_amountuint256Amount of OUSD to burn

redeemAll​

function redeemAll(uint256 _minimumUnitAmount) external

Withdraw a supported asset and burn all OTokens.

Parameters​

NameTypeDescription
_minimumUnitAmountuint256Minimum stablecoin units to receive in return

allocate​

function allocate() external

Allocate unallocated funds on Vault to strategies.

_allocate​

function _allocate() internal

Allocate unallocated funds on Vault to strategies.

rebase​

function rebase() external virtual

Calculate the total value of assets held by the Vault and all strategies and update the supply of OTokens.

_rebase​

function _rebase() internal returns (uint256)

Calculate the total value of assets held by the Vault and all strategies and update the supply of OTokens, optionally sending a portion of the yield to the trustee.

Return Values​

NameTypeDescription
[0]uint256totalUnits Total balance of Vault in units

totalValue​

function totalValue() external view virtual returns (uint256 value)

Determine the total value of assets held by the vault and its strategies.

Return Values​

NameTypeDescription
valueuint256Total value in USD/ETH (1e18)

_totalValue​

function _totalValue() internal view virtual returns (uint256 value)

Internal Calculate the total value of the assets held by the vault and its strategies.

Return Values​

NameTypeDescription
valueuint256Total value in USD/ETH (1e18)

_totalValueInVault​

function _totalValueInVault() internal view returns (uint256 value)

Internal to calculate total value of all assets held in Vault.

Return Values​

NameTypeDescription
valueuint256Total value in USD/ETH (1e18)

_totalValueInStrategies​

function _totalValueInStrategies() internal view returns (uint256 value)

Internal to calculate total value of all assets held in Strategies.

Return Values​

NameTypeDescription
valueuint256Total value in USD/ETH (1e18)

_totalValueInStrategy​

function _totalValueInStrategy(address _strategyAddr) internal view returns (uint256 value)

Internal to calculate total value of all assets held by strategy.

Parameters​

NameTypeDescription
_strategyAddraddressAddress of the strategy

Return Values​

NameTypeDescription
valueuint256Total value in USD/ETH (1e18)

checkBalance​

function checkBalance(address _asset) external view returns (uint256)

Get the balance of an asset held in Vault and all strategies.

Parameters​

NameTypeDescription
_assetaddressAddress of asset

Return Values​

NameTypeDescription
[0]uint256uint256 Balance of asset in decimals of asset

_checkBalance​

function _checkBalance(address _asset) internal view virtual returns (uint256 balance)

Get the balance of an asset held in Vault and all strategies.

Parameters​

NameTypeDescription
_assetaddressAddress of asset

Return Values​

NameTypeDescription
balanceuint256Balance of asset in decimals of asset

calculateRedeemOutputs​

function calculateRedeemOutputs(uint256 _amount) external view returns (uint256[])

Calculate the outputs for a redeem function, i.e. the mix of coins that will be returned

_calculateRedeemOutputs​

function _calculateRedeemOutputs(uint256 _amount) internal view returns (uint256[] outputs)

Calculate the outputs for a redeem function, i.e. the mix of coins that will be returned.

Return Values​

NameTypeDescription
outputsuint256[]Array of amounts respective to the supported assets

priceUnitMint​

function priceUnitMint(address asset) external view returns (uint256 price)

Returns the total price in 18 digit units for a given asset. Never goes above 1, since that is how we price mints.

Parameters​

NameTypeDescription
assetaddressaddress of the asset

Return Values​

NameTypeDescription
priceuint256uint256: unit (USD / ETH) price for 1 unit of the asset, in 18 decimal fixed

priceUnitRedeem​

function priceUnitRedeem(address asset) external view returns (uint256 price)

Returns the total price in 18 digit unit for a given asset. Never goes below 1, since that is how we price redeems

Parameters​

NameTypeDescription
assetaddressAddress of the asset

Return Values​

NameTypeDescription
priceuint256uint256: unit (USD / ETH) price for 1 unit of the asset, in 18 decimal fixed

_toUnits​

function _toUnits(uint256 _raw, address _asset) internal view returns (uint256)

Convert a quantity of a token into 1e18 fixed decimal "units" in the underlying base (USD/ETH) used by the vault. Price is not taken into account, only quantity.

Examples of this conversion:

  • 1e18 DAI becomes 1e18 units (same decimals)
  • 1e6 USDC becomes 1e18 units (decimal conversion)
  • 1e18 rETH becomes 1.2e18 units (exchange rate conversion)

Parameters​

NameTypeDescription
_rawuint256Quantity of asset
_assetaddressCore Asset address

Return Values​

NameTypeDescription
[0]uint256value 1e18 normalized quantity of units

_toUnitPrice​

function _toUnitPrice(address _asset, bool isMint) internal view returns (uint256 price)

Returns asset's unit price accounting for different asset types and takes into account the context in which that price exists -

  • mint or redeem.

Note: since we are returning the price of the unit and not the one of the asset (see comment above how 1 rETH exchanges for 1.2 units) we need to make the Oracle price adjustment as well since we are pricing the units and not the assets.

The price also snaps to a "full unit price" in case a mint or redeem action would be unfavourable to the protocol.

_getDecimals​

function _getDecimals(address _asset) internal view returns (uint256 decimals)

getAssetCount​

function getAssetCount() public view returns (uint256)

Return the number of assets supported by the Vault.

getAssetConfig​

function getAssetConfig(address _asset) public view returns (struct VaultStorage.Asset config)

Gets the vault configuration of a supported asset.

getAllAssets​

function getAllAssets() external view returns (address[])

Return all vault asset addresses in order

getStrategyCount​

function getStrategyCount() external view returns (uint256)

Return the number of strategies active on the Vault.

getAllStrategies​

function getAllStrategies() external view returns (address[])

Return the array of all strategies

isSupportedAsset​

function isSupportedAsset(address _asset) external view returns (bool)

Returns whether the vault supports the asset

Parameters​

NameTypeDescription
_assetaddressaddress of the asset

Return Values​

NameTypeDescription
[0]booltrue if supported

fallback​

fallback() external payable

This is a catch all for all functions not declared in core

Falldown to the admin implementation