Core
mevETHmevETH
Contract that allows deposit of ETH, for a Liquid Staking Receipt (LSR) in return.
LSR is represented through an ERC4626 token and interface.
State Variables
stakingPaused
Inidicates if staking is paused.
initialized
Indicates if contract is initialized.
feeDenominator
withdraw fee denominator
pendingStakingModuleCommittedTimestamp
Timestamp when pending staking module update can be finalized.
pendingMevEthShareVaultCommittedTimestamp
Timestamp when pending mevEthShareVault update can be finalized.
MODULE_UPDATE_TIME_DELAY
Time delay before staking module or share vault can be finalized.
MAX_DEPOSIT
Max amount of ETH that can be deposited.
MIN_DEPOSIT
Min amount of ETH that can be deposited.
MIN_WITHDRAWAL
Min amount of ETH that can be withdrawn via the queue.
mevEthShareVault
The address of the MevEthShareVault.
pendingMevEthShareVault
The address of the pending MevEthShareVault when a new vault has been committed but not finalized.
stakingModule
The staking module used to stake Ether.
pendingStakingModule
The pending staking module when a new module has been committed but not finalized.
WETH9
WETH Implementation used by MevEth.
lastRewards
Last rewards payment by block number
fraction
Struct used to accounting the ETH staked within MevEth.
CREAM_TO_MEV_ETH_PERCENT
The percent out of 1000 crETH2 can be redeemed for as mevEth
creamToken
The canonical address of the crETH2 address
lastDeposit
Sandwich protection mapping of last user deposits by block number
depositedValidators
Deposited validators mapping to prevent double deposits
queueLength
The length of the withdrawal queue.
requestsFinalisedUntil
mark the latest withdrawal request that was finalised
withdrawalAmountQueued
Withdrawal amount queued
withdrawalQueue
The mapping representing the withdrawal queue.
The index in the queue is the key, and the value is the WithdrawalTicket.
Functions
constructor
Construction creates mevETH token, sets authority and weth address.
Pending staking module and committed timestamp will both be zero on deployment.
Parameters
Name | Type | Description |
---|---|---|
authority | address | Address of the controlling admin authority. |
weth | address | Address of the WETH contract to use for deposits. |
calculateNeededEtherBuffer
Calculate the needed Ether buffer required when creating a new validator.
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The required Ether buffer. |
init
Initializes the MevEth contract, setting the staking module and share vault addresses.
This function can only be called once and is protected by the onlyAdmin modifier.
Parameters
Name | Type | Description |
---|---|---|
initialShareVault | address | The initial share vault set during initialization. |
initialStakingModule | address | The initial staking module set during initialization. |
_stakingUnpaused
Ensures that staking is not paused when invoking a specific function.
This check is used on the createValidator, deposit and mint functions.
pauseStaking
Pauses staking on the MevEth contract.
This function is only callable by addresses with the admin role.
unpauseStaking
Unauses staking on the MevEth contract.
This function is only callable by addresses with the admin role.
commitUpdateStakingModule
Starts the process to update the staking module. To finalize the update, the MODULE_UPDATE_TIME_DELAY must elapse and thefinalizeUpdateStakingModule function must be called.
This function is only callable by addresses with the admin role.
Parameters
Name | Type | Description |
---|---|---|
newModule | IStakingModule | The new staking module. |
finalizeUpdateStakingModule
Finalizes the staking module update if a pending staking module exists.
This function is only callable by addresses with the admin role.
cancelUpdateStakingModule
Cancels a pending staking module update.
This function is only callable by addresses with the admin role.
commitUpdateMevEthShareVault
Starts the process to update the share vault. To finalize the update, the MODULE_UPDATE_TIME_DELAY must elapse and the finalizeUpdateStakingModule function must be called.
This function is only callable by addresses with the admin role
Parameters
Name | Type | Description |
---|---|---|
newMevEthShareVault | address | The new share vault |
finalizeUpdateMevEthShareVault
Finalizes the share vault update if a pending share vault exists.
This function is only callable by addresses with the admin role.
cancelUpdateMevEthShareVault
Cancels a pending share vault update.
This function is only callable by addresses with the admin role.
createValidator
This function passes through the needed Ether to the Staking module, and the assosiated credentials with it
This function is only callable by addresses with the operator role and if staking is unpaused
Parameters
Name | Type | Description |
---|---|---|
newData | IStakingModule.ValidatorData | The data needed to create a new validator |
latestDepositRoot | bytes32 |
grantRewards
Grants rewards updating the fraction.elastic.
called from validator rewards updates
grantValidatorWithdraw
Allows the MevEthShareVault or the staking module to withdraw validator funds from the contract.
Before updating the fraction, the withdrawal queue is processed, which pays out any pending withdrawals.
This function is only callable by the MevEthShareVault or the staking module.
claim
Claim Finalised Withdrawal Ticket
Parameters
Name | Type | Description |
---|---|---|
withdrawalId | uint256 | Unique ID of the withdrawal ticket |
processWithdrawalQueue
Processes the withdrawal queue, reserving any pending withdrawals with the contract's available balance.
setMinWithdrawal
asset
The underlying asset of the mevEth contract
Returns
Name | Type | Description |
---|---|---|
assetTokenAddress | address | The address of the asset token |
totalAssets
The total amount of assets controlled by the mevEth contract
Returns
Name | Type | Description |
---|---|---|
totalManagedAssets | uint256 | The amount of eth controlled by the mevEth contract |
convertToShares
Function to convert a specified amount of assets to shares based on the elastic and base.
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets to convert to shares |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The value of the given assets in shares |
convertToAssets
Function to convert a specified amount of shares to assets based on the elastic and base.
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares to convert to assets |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The value of the given shares in assets |
maxDeposit
Function to indicate the maximum deposit possible.
Returns
Name | Type | Description |
---|---|---|
maxAssets | uint256 | The maximum amount of assets that can be deposited. |
previewDeposit
Function to simulate the amount of shares that would be minted for a given deposit at the current ratio.
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets that would be deposited |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares that would be minted, under ideal conditions only |
_deposit
internal deposit function to process Weth or Eth deposits
Parameters
Name | Type | Description |
---|---|---|
receiver | address | The address user whom should receive the mevEth out |
assets | uint256 | The amount of assets to deposit |
shares | uint256 | The amount of shares that should be minted |
deposit
Function to deposit assets into the mevEth contract
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of WETH which should be deposited |
receiver | address | The address user whom should receive the mevEth out |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares minted |
maxMint
Function to indicate the maximum amount of shares that can be minted at the current ratio.
Returns
Name | Type | Description |
---|---|---|
maxShares | uint256 | The maximum amount of shares that can be minted |
previewMint
Function to simulate the amount of assets that would be required to mint a given amount of shares at the current ratio.
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares that would be minted |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets that would be required, under ideal conditions only |
mint
Function to mint shares of the mevEth contract
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares that should be minted |
receiver | address | The address user whom should receive the mevEth out |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets deposited |
maxWithdraw
Function to indicate the maximum amount of assets that can be withdrawn at the current state.
Parameters
Name | Type | Description |
---|---|---|
owner | address | The address in question of who would be withdrawing |
Returns
Name | Type | Description |
---|---|---|
maxAssets | uint256 | The maximum amount of assets that can be withdrawn |
previewWithdraw
Function to simulate the amount of shares that would be allocated for a specified amount of assets.
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets that would be withdrawn |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares that would be burned, under ideal conditions only |
_withdraw
Function to withdraw assets from the mevEth contract
Parameters
Name | Type | Description |
---|---|---|
useQueue | bool | Flag whether to use the withdrawal queue |
receiver | address | The address user whom should receive the mevEth out |
owner | address | The address of the owner of the mevEth |
assets | uint256 | The amount of assets that should be withdrawn |
shares | uint256 | shares that will be burned |
_updateAllowance
internal function to update allowance for withdraws if necessary
Parameters
Name | Type | Description |
---|---|---|
owner | address | owner of tokens |
shares | uint256 | amount of shares to update |
withdraw
Withdraw assets if balance is available
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets that should be withdrawn |
receiver | address | The address user whom should receive the mevEth out |
owner | address | The address of the owner of the mevEth |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares burned |
withdrawQueue
Withdraw assets or open queue ticket for claim depending on balance available
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets that should be withdrawn |
receiver | address | The address user whom should receive the mevEth out |
owner | address | The address of the owner of the mevEth |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares burned |
maxRedeem
Function to simulate the maximum amount of shares that can be redeemed by the owner.
Parameters
Name | Type | Description |
---|---|---|
owner | address | The address in question of who would be redeeming their shares |
Returns
Name | Type | Description |
---|---|---|
maxShares | uint256 | The maximum amount of shares they could redeem |
previewRedeem
Function to simulate the amount of assets that would be withdrawn for a specified amount of shares.
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares that would be burned |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets that would be withdrawn, under ideal conditions only |
redeem
Function to redeem shares from the mevEth contract
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares that should be burned |
receiver | address | The address user whom should receive the wETH out |
owner | address | The address of the owner of the mevEth |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets withdrawn |
max
Returns the largest of two numbers.
min
Returns the smallest of two numbers.
redeemCream
Redeem Cream staked eth tokens for mevETH at a fixed ratio
Parameters
Name | Type | Description |
---|---|---|
creamAmount | uint256 | The amount of Cream tokens to redeem |
receive
Only Weth withdraw is defined for the behaviour. Deposits should be directed to deposit / mint. Rewards via grantRewards and validator withdraws via grantValidatorWithdraw.
transfer
transferFrom
Events
MevEthInitialized
Event emitted when the MevEth is successfully initialized.
StakingPaused
Emitted when staking is paused.
StakingUnpaused
Emitted when staking is unpaused.
StakingModuleUpdateCommitted
Event emitted when a new staking module is committed. The MODULE_UPDATE_TIME_DELAY must elapse before the staking module update can be finalized.
StakingModuleUpdateFinalized
Event emitted when a new staking module is finalized.
StakingModuleUpdateCanceled
Event emitted when a new pending module update is canceled.
MevEthShareVaultUpdateCommitted
Event emitted when a new share vault is committed. To finalize the update, the MODULE_UPDATE_TIME_DELAY must elapse and the finalizeUpdateMevEthShareVault function must be called.
MevEthShareVaultUpdateFinalized
Event emitted when a new share vault is finalized.
MevEthShareVaultUpdateCanceled
Event emitted when a new pending share vault update is canceled.
ValidatorCreated
Event emitted when a new validator is created
Rewards
Event emitted when rewards are granted.
ValidatorWithdraw
Emitted when validator withdraw funds are received.
WithdrawalQueueOpened
Event emitted when a withdrawal ticket is added to the queue.
WithdrawalQueueClosed
CreamRedeemed
Structs
Fraction
Central struct used for share accounting + math.
WithdrawalTicket
Struct representing a withdrawal ticket which is added to the withdrawal queue.