Skip to main content

GnoMetaVault

Git Source ↗

Inherits: VaultImmutables, Initializable ↗, ReentrancyGuardUpgradeable ↗, VaultAdmin, VaultVersion, VaultFee, VaultState, VaultEnterExit, VaultOsToken, VaultSubVaults, Multicall, IGnoMetaVault

Defines the Meta Vault functionality on Gnosis

State Variables

_version

uint8 private constant _version = 5

_securityDeposit

uint256 private constant _securityDeposit = 1e9

_gnoToken

IERC20 private immutable _gnoToken

__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[50] 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 gnoToken, GnoMetaVaultConstructorArgs memory args)
VaultImmutables(args.keeper, args.vaultsRegistry)
VaultEnterExit(args.exitingAssetsClaimDelay)
VaultOsToken(args.osTokenVaultController, args.osTokenConfig, args.osTokenVaultEscrow)
VaultSubVaults(args.subVaultsRegistryFactory);

Parameters

NameTypeDescription
gnoTokenaddressThe address of the GNO token contract
argsGnoMetaVaultConstructorArgsThe arguments for initializing the GnoMetaVault contract

initialize

Initializes or upgrades the GnoMetaVault contract. Must transfer security deposit during the deployment.

function initialize(bytes calldata params) external virtual override reinitializer(_version);

Parameters

NameTypeDescription
paramsbytesThe encoded parameters for initializing the GnoMetaVault contract

deposit

Deposit GNO to the Vault

function deposit(uint256 assets, address receiver, address referrer)
public
virtual
override
returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256The amount of GNO to deposit
receiveraddressThe address that will receive Vault's shares
referreraddressThe address of the referrer. Set to zero address if not used.

Returns

NameTypeDescription
sharesuint256The number of shares minted

donateAssets

Donate assets to the Vault. Must approve GNO transfer before the call.

function donateAssets(uint256 amount) external override nonReentrant;

Parameters

NameTypeDescription
amountuint256The amount of GNO to donate

vaultId

function vaultId() public pure virtual override(IVaultVersion, VaultVersion) returns (bytes32);

version

Version

function version() public pure virtual override(IVaultVersion, VaultVersion) returns (uint8);

Returns

NameTypeDescription
<none>uint8The version of the Vault implementation contract

_depositToVault

Internal function to deposit assets to the sub-vault

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

Parameters

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

Returns

NameTypeDescription
<none>uint256The amount of vault shares received

_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 override returns (uint256);

Returns

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

_transferVaultAssets

Internal function for transferring assets from the Vault to the receiver

function _transferVaultAssets(address receiver, uint256 assets) internal virtual override nonReentrant;

Parameters

NameTypeDescription
receiveraddressThe address that will receive the assets
assetsuint256The number of assets to transfer

isStateUpdateRequired

Check whether state update is required

function isStateUpdateRequired()
public
view
virtual
override(IVaultState, VaultState, VaultSubVaults)
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(IVaultState, VaultState, VaultSubVaults);

Parameters

NameTypeDescription
harvestParamsIKeeperRewards.HarvestParamsThe parameters for harvesting Keeper rewards

enterExitQueue

Locks shares to the exit queue. The shares continue earning rewards until they will be burned by the Vault.

For ERC-20 vault variants, balanceOf(vault) does not reflect queued exit shares despite the emitted Transfer event.

function enterExitQueue(uint256 shares, address receiver)
public
virtual
override(IVaultEnterExit, VaultEnterExit, VaultOsToken)
returns (uint256 positionTicket);

Parameters

NameTypeDescription
sharesuint256The number of shares to lock
receiveraddressThe address that will receive assets upon withdrawal

Returns

NameTypeDescription
positionTicketuint256The position ticket of the exit queue. Returns uint256 max if no ticket created.

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(IVaultState, VaultState, VaultOsToken);

Parameters

NameTypeDescription
sharesuint256The number of shares to donate

_checkHarvested

Internal method for checking whether the vault is harvested

function _checkHarvested() internal view virtual override(VaultImmutables, VaultSubVaults);

_isCollateralized

Returns whether the vault is collateralized

function _isCollateralized() internal view virtual override(VaultImmutables, VaultSubVaults) returns (bool);

Returns

NameTypeDescription
<none>booltrue if the vault is collateralized

__GnoMetaVault_upgrade

Upgrades the GnoMetaVault contract

function __GnoMetaVault_upgrade() internal onlyInitializing;

__GnoMetaVault_init

Initializes the GnoMetaVault contract

function __GnoMetaVault_init(address _admin, GnoMetaVaultInitParams memory params) internal onlyInitializing;

Parameters

NameTypeDescription
_adminaddressThe address of the admin of the Vault
paramsGnoMetaVaultInitParamsThe parameters for initializing the GnoMetaVault contract