Releases: stakewise/v3-core
v4.0.0
What's Changed
Base
- Extracted the EIP-712 domain separator calculation from the
_computeDomainSeparator
function in theERC20Upgradeable
contract into theEIP712Utils
library to reduce the size of the vault contract.
Curators
- Added the
BalancedCurator
contract for theMetaVault
. This contract calculates the amounts to deposit or withdraw from the sub-vaults, evenly distributing and allocating assets among them. TheMetaVault
should set this contract as its curator to apply the even distribution logic. - Added the
CuratorsRegistry
contract, 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
CumulativeMerkleDrop
contract, as it is not currently in use. - Removed all
restake
functionality from the vaults, as it is not currently in use. - Removed the
XDaiExchange
contract, as it has been replaced by theTokensConverter
contract.
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
setAdmin
function to change the admin address of the vault. It can only be called by the current admin and emits anAdminUpdated
event. - Added the
donateAssets
function 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 anAssetsDonated
event. - Added the
setFeePercent
function 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
queuedShares
andtotalExitingAssets
functions withgetExitQueueData
, which returns all queuing data for the vault. This change reduces the vault contract's bytecode size. - Added the
fundValidators
function to top up existing validators with ETH/GNO. It can only be called by an address with thevalidatorsManager
role or by providing a validvalidatorsManager
signature. Top-ups are allowed only for validators that have been previously consolidated to a 0x02 validator or registered as a 0x02 validator. Emits aValidatorFunded
event. - Added the
consolidateValidators
function for migrating 0x01 validators to 0x02 validators. It can only be called by an address with thevalidatorsManager
role or by providing a validvalidatorsManager
signature. 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 newConsolidationsChecker
contract. ETH/xDAI must be sent along with the call to cover the consolidation fee, and any unused amount is refunded to the caller. Emits theValidatorConsolidationSubmitted
event. Note: a successful function call does not guarantee successful consolidation at the consensus level. - Added the
withdrawValidators
function to trigger withdrawals from validators. It can only be called by an address with thevalidatorsManager
role or by providing a validvalidatorsManager
signature. ETH/xDAI must be sent with the call to cover the withdrawal fee, and any unused amount is refunded to the caller. Emits theValidatorWithdrawalSubmitted
event. Note: a successful function call does not guarantee a successful withdrawal at the consensus level. - Modified the
registerValidators
function to support registration of both 0x01 and 0x02 validators. It can only be called by an address with thevalidatorsManager
role or by providing a validvalidatorsManager
signature. When registering a 0x02 validator, the amount in Gwei must be specified for each validator. Registration of a 0x01 validator emits aValidatorRegistered
event, while registration of a 0x02 validator emits aV2ValidatorRegistered
event. - Removed the
swapXdaiToGno
function and deprecated theXdaiSwapped
event. DuringGnoVault
initialization, aTokensConverter
contract is created. OnceGnoVault
pulls accumulated xDAI fromOwnMevEscrow
orSharedMevEscrow
, 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 theTokensConverter
and accounted for using thedonateAssets
function. - Migrated the exit queue for
GnoVaults
from theexitingAssets
to theExitQueue
library, similar to the implementation used in ETH vaults. - Extracted the
calculateReceivedAssets
function, used for calculatingOsToken
liquidation and redemption assets, into a separateOsTokenUtils
library to reduce the vault contract's bytecode size.
Genesis Vault
- Deprecated the
GenesisVaultCreated
event, as it will no longer be emitted. Only one instance of the genesis vault exists, and it has already been created. - Removed the
acceptPoolEscrowOwnership
function, as ownership of thePoolEscrow
has already been transferred and the function will not be called in the future. - Removed rewards splitting with the legacy
rETH2
contract.
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
claimer
role that can trigger exits on behalf of splitter shareholders using theenterExitQueueOnBehalf
function. The claimer is managed by the vault admin via thesetClaimer
function. - Added the
claimExitedAssetsOnBehalf
function, which can be called by anyone to withdraw exited assets to the respective shareholder. - Replaced the owner of the
RewardSplitter
with the admin of the vault. - Added the
enterExitQueueOnBehalf
function, allowing anyone to enter the exit queue on behalf of a shareholder.
OsToken Redeemer
This contract is set as the redeemer in OsTokenConfig
and can call redeemOsToken
in the vault. The positionsManager
within the contract is responsible for selecting redeemable positions and proposing them via the proposeRedeemablePositions
function. The contract owner must then either accept the proposed positions using acceptRedeemablePositions
or reject them using denyRedeemablePositions
. A minimum of 3 days must pass between the proposal and acceptance of new redeemable positions.
Once positions are accepted, the oracles calculate the required exit amounts in the vaults and trigger validator exits. For vaults with Pectra support, oracles will wait one day to allow operators to submit the withdrawal transactions before proceeding with exits. After the validators exit and the assets are returned to the vault, the redeemer calls redeemOsTokenPositions
to redeem the approved OsToken
positions.
Full Changelog: v3.0.1...v4.0.0
v3.0.1
v3.0.0
What's Changed
- Added the
EthOsTokenVaultEscrow
andGnoOsTokenVaultEscrow
contracts. 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 usesOsTokenFlashLoans
to 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
enterExitQueue
function will return maxUINT256
as 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
UINT256
is 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
EigenPodOwner
contract is the owner of theEigenPod
and 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
blocklistManager
can 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
updateState
call. 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
redeem
function 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
0
to 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
validatorsRoot
was moved to depositDataRoots. - The
validatorIndex
was moved to depositDataIndexes. - The
keysManager
was moved to getDepositDataManager. - The
setKeysManager
was moved to setDepositDataManager. - The
registerValidator
was moved to registerValidator. - The
registerValidators
was 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