-
Notifications
You must be signed in to change notification settings - Fork 93
Native staking changes #2024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Native staking changes #2024
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 18 additions & 33 deletions
51
contracts/contracts/strategies/NativeStaking/FeeAccumulator.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +1,40 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import { Address } from "@openzeppelin/contracts/utils/Address.sol"; | ||
|
|
||
| import { Governable } from "../../governance/Governable.sol"; | ||
| import { IWETH9 } from "../../interfaces/IWETH9.sol"; | ||
|
|
||
| /** | ||
| * @title Fee Accumulator for Native Staking SSV Strategy | ||
| * @notice This contract is setup to receive fees from processing transactions on the beacon chain | ||
| * which includes priority fees and any MEV rewards. | ||
| * It does NOT include swept ETH from consensus rewards or withdrawals. | ||
| * @notice Receives execution rewards which includes tx fees and | ||
| * MEV rewards like tx priority and tx ordering. | ||
| * It does NOT include swept ETH from beacon chain consensus rewards or full validator withdrawals. | ||
| * @author Origin Protocol Inc | ||
| */ | ||
| contract FeeAccumulator is Governable { | ||
| /// @notice The address the WETH is sent to on `collect` which is the Native Staking Strategy | ||
| address public immutable COLLECTOR; | ||
| /// @notice The address of the Wrapped ETH (WETH) token contract | ||
| address public immutable WETH_TOKEN_ADDRESS; | ||
|
|
||
| error CallerNotCollector(address caller, address expectedCaller); | ||
|
|
||
| // For future use | ||
| uint256[50] private __gap; | ||
| /// @notice The address of the Native Staking Strategy | ||
| address public immutable STRATEGY; | ||
|
|
||
| /** | ||
| * @param _collector Address of the contract that collects the fees | ||
| * @param _weth Address of the Wrapped ETH (WETH) token contract | ||
| * @param _strategy Address of the Native Staking Strategy | ||
| */ | ||
| constructor(address _collector, address _weth) { | ||
| COLLECTOR = _collector; | ||
| WETH_TOKEN_ADDRESS = _weth; | ||
| constructor(address _strategy) { | ||
| STRATEGY = _strategy; | ||
| } | ||
|
|
||
| /** | ||
| * @dev Asserts that the caller is the collector | ||
| * @notice sends all ETH in this FeeAccumulator contract to the Native Staking Strategy. | ||
| * @return eth The amount of execution rewards that were sent to the Native Staking Strategy | ||
| */ | ||
| function _assertIsCollector() internal view { | ||
| if (msg.sender != COLLECTOR) { | ||
| revert CallerNotCollector(msg.sender, COLLECTOR); | ||
| } | ||
| } | ||
| function collect() external returns (uint256 eth) { | ||
| require(msg.sender == STRATEGY, "Caller is not the Strategy"); | ||
|
|
||
| /** | ||
| * @notice Converts ETH to WETH and sends the WETH to the collector | ||
| * @return weth The amount of WETH sent to the collector | ||
| */ | ||
| function collect() external returns (uint256 weth) { | ||
| _assertIsCollector(); | ||
| weth = address(this).balance; | ||
| if (weth > 0) { | ||
| IWETH9(WETH_TOKEN_ADDRESS).deposit{ value: weth }(); | ||
| IWETH9(WETH_TOKEN_ADDRESS).transfer(COLLECTOR, weth); | ||
| eth = address(this).balance; | ||
| if (eth > 0) { | ||
| // Send the ETH to the Native Staking Strategy | ||
| Address.sendValue(payable(STRATEGY), eth); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.