Releases: stakewise/v3-core
v4.0.1
v4.0.0
What's Changed
Base
- Extracted the EIP-712 domain separator calculation from the
_computeDomainSeparatorfunction in theERC20Upgradeablecontract into theEIP712Utilslibrary to reduce the size of the vault contract. - Switched from Uniswap inspired
Multicallimplementation to OpenZeppelinAddress.functionDelegateCall
Curators
- Added the
BalancedCuratorcontract for theMetaVault. This contract calculates the amounts to deposit or withdraw from the sub-vaults, evenly distributing and allocating assets among them. TheMetaVaultshould set this contract as its curator to apply the even distribution logic. - Added the
CuratorsRegistrycontract, which keeps track of all registered curator contracts. Any new curator contract must be listed there to be used with theMetaVault.
Removed contracts
- Removed the
CumulativeMerkleDropcontract, as it is not currently in use. - Removed all
restakefunctionality from the vaults, as it is not currently in use. - Removed the
XDaiExchangecontract, as it has been replaced by theTokensConvertercontract.
Vaults
- Extracted all constructor arguments for the vault implementation contracts into structs (e.g.,
EthErc20VaultConstructorArgs) to avoid 'stack too deep' errors during compilation. - Added the
setAdminfunction to change the admin address of the vault. It can only be called by the current admin and emits anAdminUpdatedevent. - Added the
donateAssetsfunction to the vault, allowing anyone to donate ETH/GNO. It can be used to distribute or refund extra ETH/GNO rewards to the vault and emits anAssetsDonatedevent. - Added the
setFeePercentfunction to update the vault's current fee. It can only be called by the vault admin. The fee can be updated once every 3 days and may only be increased by up to 20% at a time. If the initial fee is 0%, the first increase is limited to 1%. - Replaced the
queuedSharesandtotalExitingAssetsfunctions withgetExitQueueData, which returns all queuing data for the vault. This change reduces the vault contract's bytecode size. - The minimum withdrawal delay for private vaults has been removed. For all other vaults, it has been reduced from 24 hours to 15 hours.
- Added the
fundValidatorsfunction to top up existing validators with ETH/GNO. It can only be called by an address with thevalidatorsManagerrole or by providing a validvalidatorsManagersignature. Top-ups are allowed only for validators that have been previously consolidated to a 0x02 validator or registered as a 0x02 validator. Emits aValidatorFundedevent. - Added the
consolidateValidatorsfunction for migrating 0x01 validators to 0x02 validators. It can only be called by an address with thevalidatorsManagerrole or by providing a validvalidatorsManagersignature. If the consolidation targets a validator that was not previously consolidated or registered with a 0x02 withdrawal prefix, oracle signatures must be provided. These signatures are verified using the newConsolidationsCheckercontract. ETH/xDAI must be sent along with the call to cover the consolidation fee, and any unused amount is refunded to the caller. Emits theValidatorConsolidationSubmittedevent. Note: a successful function call does not guarantee successful consolidation at the consensus level. - Added the
withdrawValidatorsfunction to trigger withdrawals from validators. It can only be called by an address with thevalidatorsManagerrole or by providing a validvalidatorsManagersignature. ETH/xDAI must be sent with the call to cover the withdrawal fee, and any unused amount is refunded to the caller. Emits theValidatorWithdrawalSubmittedevent. Note: a successful function call does not guarantee a successful withdrawal at the consensus level. - Modified the
registerValidatorsfunction to support registration of both 0x01 and 0x02 validators. It can only be called by an address with thevalidatorsManagerrole or by providing a validvalidatorsManagersignature. When registering a 0x02 validator, the amount in Gwei must be specified for each validator. Registration of a 0x01 validator emits aValidatorRegisteredevent, while registration of a 0x02 validator emits aV2ValidatorRegisteredevent. - Removed the
swapXdaiToGnofunction and deprecated theXdaiSwappedevent. DuringGnoVaultinitialization, aTokensConvertercontract is created. OnceGnoVaultpulls accumulated xDAI fromOwnMevEscroworSharedMevEscrow, it transfers it to theTokensConverter, converts it to sDAI, and uses CowSwap to swap it for GNO. InupdateState, all converted GNO is pulled back into the vault from theTokensConverterand accounted for using thedonateAssetsfunction. - Migrated the exit queue for
GnoVaultsfrom theexitingAssetsto theExitQueuelibrary, similar to the implementation used in ETH vaults. - Extracted the
calculateReceivedAssetsfunction, used for calculatingOsTokenliquidation and redemption assets, into a separateOsTokenUtilslibrary to reduce the vault contract's bytecode size. - A new
rescueAssetsfunction was added. It can only be called by the vault admin when no validators have been created. This function allows the admin, who has just created the vault, to withdraw an incorrectly created validator whose withdrawal credentials are set to the vault, but whose deposit was made directly to the Beacon chain contract instead of through the vault contract. The function is disabled once the first validator is created using the vault.
Genesis Vault
- Deprecated the
GenesisVaultCreatedevent, as it will no longer be emitted. Only one instance of the genesis vault exists, and it has already been created. - Removed the
acceptPoolEscrowOwnershipfunction, as ownership of thePoolEscrowhas already been transferred and the function will not be called in the future. - Removed rewards splitting with the legacy
rETH2contract.
Meta Vault
Added a new type of vault called MetaVaults. Unlike other vaults, MetaVaults do not register validators directly - instead, they delegate accumulated assets to sub-vaults, which are managed by the vault admin. Each sub-vault must have at least one registered validator, and up to 50 sub-vaults can be added to a MetaVault.
When a sub-vault is removed, all assets allocated to it enter the exit queue. Once the assets exit successfully, they are returned to the MetaVault, and the sub-vault is removed from the list.
Calling the depositToSubVaults function deposits all available assets from the MetaVault into the sub-vaults. The deposit and withdrawal amounts for each sub-vault are determined by the Curator contract, which can be changed by the admin using the setSubVaultsCurator function. By default, the BalancedCurator is used to evenly distribute and withdraw assets across sub-vaults.
In the updateState function, the locked amounts in all sub-vaults are synchronized, and the reward delta is calculated. Before calling updateState on the MetaVault, all sub-vaults must be up-to-date (i.e., updateState must be called on each sub-vault first). During the MetaVault's updateState, assets queued for exit are submitted to the sub-vaults. The curator contract determines the amount to withdraw from each sub-vault.
If a sub-vault is in the process of being removed, the exiting assets will be prioritized to process its exit queue before submitting new exit requests to other sub-vaults. All exit requests to sub-vaults must be claimed using the claimSubVaultsExitedAssets function before calling updateState on the MetaVault.
MetaVaults can be deployed using the EthMetaVaultFactory contract, and currently, only the factory owner is permitted to deploy new MetaVaults.
Reward Splitter
- Added a
claimerrole that can trigger exits on behalf of splitter shareholders using theenterExitQueueOnBehalffunction. The claimer is managed by the vault admin via thesetClaimerfunction. - Added the
claimExitedAssetsOnBehalffunction, which can be called by anyone to withdraw exited assets to the respective shareholder. - Replaced the owner of the
RewardSplitterwith the admin of the vault. - Added the
enterExitQueueOnBehalffunction, allowing anyone to enter the exit queue on behalf of a shareholder.
OsToken Redeemer
The new OsTokenRedeemer contract was introduced to enable OsToken redemptions. This contract is set as the redeemer in OsTokenConfig and can call redeemOsToken in the vault.
OsToken holders can enter the exit queue by locking their OsTokens in the OsTokenRedeemer contract and receiving an exit queue ticket. Once their OsTokens are redeemed for assets (ETH/GNO), they can claim them from the OsTokenRedeemer contract. The process is the same as unstaking ETH/GNO from the vault.
The exit queue is processed as follows:
- Collecting positions: The
PositionsManagercollects redeemable positions from the vaults. These are stakers in the vaults who have minted and sold their OsTokens, or whose LTV is approaching the liquidation threshold. Once all positions are collected, the manager proposes a new root and IPFS hash usingproposeRedeemablePositions. - Review by the redemptions committee: The redemptions committee reviews the proposed redeemable positions. If everything is correct, they approve it by calling
acceptRedeemablePositions. They can also reject the proposal by callingdenyRedeemablePositions. - Executing redemptions: Once the new root has been approved, the queued OsTokens can be redeemed from the vaults using
redeemOsTokenPositions. This function verifies that the position is included in the approved root, burns the OsTokens in the vault, and claims the corresponding assets. The vault must have enough unbonded assets (ETH/GNO) for the redem...
v3.0.1
v3.0.0
What's Changed
- Added the
EthOsTokenVaultEscrowandGnoOsTokenVaultEscrowcontracts. These contracts allow users to request an exit for staked ETH/GNO without immediately burning osETH/osGNO. This feature supports certain DeFi integrations by enabling users to 1) request an exit from the vault without burning osETH/osGNO, and 2) once the unstaked ETH/GNO is ready to be claimed, burn osETH/osGNO and receive the unstaked ETH/GNO in a single transaction. - Added
OsTokenFlashLoans. This contract allows to mint and burn osETH in single transaction (up to 100k osETH). For example, leverage strategy usesOsTokenFlashLoansto mint osETH, supply to Aave, borrow ETH, mint osETH from the vault and return the flashloan. - When user migrates from StakeWise Legacy, we always mint max amount of osTokens to the user in the Genesis Vault.
- Move back to the exit queue processing implemented in V1 vaults
- The
enterExitQueuefunction will return maxUINT256as position ticket in case the vault has no validators and assets vault can be redeemed. - The max possible osToken shares can be minted if max
UINT256is passed to themintOsToken. If no osToken shares can be minted, 0 will be returned.
Audit report
The audit was performed by Sigma Prime and is available here.
New Contributors
Full Changelog: v2.0.1...v3.0.0
v2.0.1
v2.0.0
What's Changed
Gnosis vaults
- New Gnosis vaults were deployed to the Gnosis network. They use the new VaultGnoStaking module. The main differences from the Ethereum vaults are as follows:
- Deposits are made in GNO tokens, and ERC-20 approval must be done before the call.
- Partial and full withdrawals are stored in the contract used to register the validators. They are pulled by the vault during user withdrawals, validator registrations, and state updates.
- 1 GNO, instead of 32 ETH, must be staked for the validator to activate.
- Rewards from transaction fees are received in xDAI and must be swapped using the swapXdaiToGno function. This function performs the transaction through the Balancer pool (which can be updated by the DAO) and uses oracles to verify the correct swap price in the XdaiExchange contract.
Restake vaults
- New Restake vaults were deployed to the Ethereum network. They use the new VaultEthRestaking module. The main differences from the regular Ethereum vaults are as follows:
- The new createEigenPod function creates EigenPod and EigenPodOwner contracts and emits the EigenPodCreated event. The
EigenPodOwnercontract is the owner of theEigenPodand stores the functions to manage it. All the eigen pods can be retrieved using the getEigenPods function. - The new restakeOperatorsManager role was added to the vault. The address assigned to this role can create new eigen pods and delegate or undelegate eigen operators to the eigen pods. This role is assigned to the vault admin by default and can be updated by the vault admin using the setRestakeOperatorsManager function, which emits the RestakeOperatorsManagerUpdated event.
- The new restakeWithdrawalsManager role was added to the vault. The address assigned to this role can verifyWithdrawalCredentials for the eigen pod validators, enter the exit queue in the Eigenlayer using queueWithdrawal, and complete queued withdrawals from the Eigenlayer using completeQueuedWithdrawal. This role is assigned to the vault admin by default and can be updated by the vault admin using the setRestakeWithdrawalsManager function, which emits the RestakeWithdrawalsManagerUpdated event. This role must be assigned to the v3-operator hot wallet to manage the EigenLayer withdrawals.
- The validators registered for the vault must include a withdrawal address that matches one of the eigen pods created for the vault. The withdrawal address is then converted to the withdrawal credentials as seen here.
- The new createEigenPod function creates EigenPod and EigenPodOwner contracts and emits the EigenPodCreated event. The
Blocklist vaults
- New blocklist vaults were deployed to Ethereum and Gnosis. These vaults use the VaultBlocklist module, which keeps track of accounts that cannot stake to the vault. For example, you can block all sanctioned addresses from depositing to your vault.
- The account with the blocklistManager role can manage the blocklist. This role is assigned to the vault admin by default. The vault admin can update the role using the setBlocklistManager function, which emits the BlocklistManagerUpdated event.
- You can use blockedAccounts to check whether an account is blocked. The
blocklistManagercan update the list using the updateBlocklist function. Blocklist updates emit the BlocklistUpdated event.
Exit queue
- The enterExitQueue function now locks the conversion rate between assets and shares at the time of the call, rather than during the
updateStatecall. Shares are burned immediately. The locked assets will not receive rewards after the call but will incur penalties if the vault APY is negative. These penalties will be distributed proportionally to all assets in the vault. Exit positions created before the upgrade will be processed according to the Vault’s V1 logic. - All newly created exit positions now emit the V2ExitQueueEntered event.
- The ExitingAssetsPenalized event is emitted during the updateState call if the vault incurs a penalty. The penalty will be proportionally distributed among all currently exiting assets.
- The claimExitedAssets will not return anything after the upgrade.
- The claimExitedAssets must be used for the exit positions created before and after the vault upgrade to V2.
- The
redeemfunction was removed. All the exits must be submitted using enterExitQueue. - The totalExitingAssets function was added to the vault. It returns the total amount of assets in the exit queue after the upgrade to V2.
- For exit positions created after the upgrade, the getExitQueueIndex function is not needed. You can pass
0to both the calculateExitedAssets and claimExitedAssets functions.
Validators management
- All the logic for managing the vault’s deposit data has been moved to the immutable DepositDataRegistry contract:
- The
validatorsRootwas moved to depositDataRoots. - The
validatorIndexwas moved to depositDataIndexes. - The
keysManagerwas moved to getDepositDataManager. - The
setKeysManagerwas moved to setDepositDataManager. - The
registerValidatorwas moved to registerValidator. - The
registerValidatorswas moved to [registerValidators](https://github.com/stakewise/v3-core/blob/v2.0.0/contracts/interfaces/...
- The
v1.1.0
v1.0.0
What's Changed
- Hats fixes by @tsudmi in #69
- Upgrade openzeppelin lib by @tsudmi in #73
- Decouple ostoken by @tsudmi in #76
- Upload latest halborn audit by @tsudmi in #78
- Update license year by @tsudmi in #79
- Update compiler version by @tsudmi in #80
- Add mainnet contracts by @tsudmi in #81
Full Changelog: https://github.com/stakewise/v3-core/commits/v1.0.0