Rewards

This contract controls the ETH Rewards earned by mevEth

State Variables

protocolBalance

ProtocolBalance struct to account for the protocol fees and rewards.

ProtocolBalance public protocolBalance;

mevEth

The address of the MevEth contract.

address public mevEth;

protocolFeeTo

The address that protocol fees are sent to.

address public protocolFeeTo;

Functions

constructor

Construction sets authority, MevEth, and averageFeeRewardsPerBlock.

constructor(address authority, address _mevEth, address _protocolFeeTo) Auth(authority);

Parameters

NameTypeDescription
authorityaddressThe address of the controlling admin authority.
_mevEthaddressThe address of the WETH contract to use for deposits.
_protocolFeeToaddressThe address that protocol fees are sent to.

payRewards

Function to pay rewards to the MevEth contract

Only callable by an operator.

function payRewards() external onlyOperator;

fees

View function to return the fees balance of the protocol

function fees() external view returns (uint128);

Returns

NameTypeDescription
<none>uint128uint128 fees balance of the protocol

rewards

View function to return the rewards balance of the protocol

function rewards() external view returns (uint128);

Returns

NameTypeDescription
<none>uint128uint128 rewards balance of the protocol

sendFees

Function to collect the fees owed to the prorotocol.

function sendFees() external onlyAdmin;

setProtocolFeeTo

function setProtocolFeeTo(address newProtocolFeeTo) external onlyAdmin;

logRewards

Function to log rewards, updating the protocol balance. Once all balances are updated, the RewardsCollected event is emitted.

Operators are tracking the RewardPayment events to calculate the protocolFeesOwed. The logRewards function is then called to update the fees and rewards within the protocol balance. Validators associated with the MEV Protocol set the block builder's address as the feeRecepient for the block. The block builder attaches a transaction to the end of the block sending the MEV rewards to the MevEthShareVault. This then emits the RewardPayment event, allowing the offchain operators to track the protocolFeesOwed. This approach trusts that the operators are acting honestly and the protocolFeesOwed is accurately calculated.

function logRewards(uint128 protocolFeesOwed) external onlyOperator;

recoverToken

Function to recover tokens sent to the contract.

This function is only callable by an admin.

function recoverToken(address token, address recipient, uint256 amount) external onlyAdmin;

setNewMevEth

Function to set a new mevEth address.

function setNewMevEth(address newMevEth) external onlyAdmin;

payValidatorWithdraw

Function to pay MevEth when withdrawing funds from a validator

This function is only callable by an admin and emits an event for offchain validator registry tracking.

function payValidatorWithdraw() external onlyOperator;

receive

Function to receive ETH.

All Ether sent to the contract is handled as a MevPayment.

receive() external payable;

Events

RewardPayment

Event emitted when a reward payment is made

event RewardPayment(uint256 indexed blockNumber, address indexed coinbase, uint256 indexed amount);

RewardsCollected

Event emitted when the protocol balance is updated during logRewards

event RewardsCollected(uint256 indexed protocolFeesOwed, uint256 indexed rewardsOwed);

TokenRecovered

Event emitted when a tokens are recovered from the contract.

event TokenRecovered(address indexed recipient, address indexed token, uint256 indexed amount);

ProtocolFeeToUpdated

Event emitted when the protocolFeeTo address is updated.

event ProtocolFeeToUpdated(address indexed newProtocolFeeTo);

FeesSent

Event emitted when the protocol fees are sent to the protocolFeeTo address.

event FeesSent(uint256 indexed feesSent);

RewardsPaid

Event emitted when rewards are paid to the MevEth contract.

event RewardsPaid(uint256 indexed rewards);

MevEthUpdated

Event emitted when the mevEth address is updated.

event MevEthUpdated(address indexed meveth);

ValidatorWithdraw

Event emitted when funds representing a validator withdrawal are sent to the MevEth contract.

event ValidatorWithdraw(address sender, uint256 amount);

Structs

ProtocolBalance

Struct to account for the protocol fees and rewards.

struct ProtocolBalance {
    uint128 fees;
    uint128 rewards;
}

Was this page helpful?