Skip to content

V3-Prelude updates since initial audit #270

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

Draft
wants to merge 74 commits into
base: v3-prelude-audit-report
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
7ceaac3
rewards manager contract
vvalecha519 Feb 19, 2025
4c4ec40
small improvements and started testing
vvalecha519 Feb 20, 2025
6014973
add end block for rewards calculated
vvalecha519 Feb 20, 2025
530261a
undo pranking
vvalecha519 Feb 20, 2025
adc2381
more tests ready for audit
vvalecha519 Feb 20, 2025
f5ca203
cummulative merkle
vvalecha519 Feb 21, 2025
502ad67
add pausing feature
vvalecha519 Feb 21, 2025
a671e5b
add modifier
vvalecha519 Feb 21, 2025
af87f6a
make pretty
vvalecha519 Feb 21, 2025
28c8efc
add whitelisted user can only claim
vvalecha519 Feb 24, 2025
ff1da11
delete old rewards manager
vvalecha519 Feb 24, 2025
9b18792
fix comment
vvalecha519 Feb 24, 2025
982625e
fixed tessting and fixed small bug
vvalecha519 Feb 25, 2025
4ffd0d7
fix l1 and l2
vvalecha519 Mar 10, 2025
68fb3c6
fix 11-i5
vvalecha519 Mar 10, 2025
7750f09
add more functions to EtherFiViewer
seongyun-ko Mar 11, 2025
60cbd9c
update blockno to timestamp
vvalecha519 Mar 24, 2025
4172e90
update role name
vvalecha519 Mar 24, 2025
2d94cb8
Merge pull request #230 from etherfi-protocol/v2.49
seongyun-ko Mar 26, 2025
a632d15
Add files via upload
seongyun-ko Mar 26, 2025
c581e1a
Merge pull request #247 from etherfi-protocol/seongyun-ko-patch-5
seongyun-ko Mar 26, 2025
1628650
Rename EtherFi - Instant Withdrawal Merge into v2.49.pdf to 2025.03.2…
seongyun-ko Mar 26, 2025
fd6fe79
Merge pull request #248 from etherfi-protocol/seongyun-ko-patch-6
seongyun-ko Mar 26, 2025
e51e4b2
Rename EtherFi - v2.49.pdf to 2025.03.26 - Certora - EtherFi - v2.49.pdf
seongyun-ko Mar 26, 2025
18150d1
Merge pull request #250 from etherfi-protocol/seongyun-ko-patch-8
vvalecha519 Mar 26, 2025
ddebd4c
deploy script
vvalecha519 Apr 5, 2025
c7cacbe
add audit
vvalecha519 Apr 7, 2025
1bef169
add roles md
vvalecha519 Apr 8, 2025
977bdb1
make pretty
vvalecha519 Apr 8, 2025
d99eae1
add another role
vvalecha519 Apr 9, 2025
2ad476a
add event for delay change
vvalecha519 Apr 9, 2025
231bef4
verify bytecode
vvalecha519 Apr 11, 2025
11d0ab1
merge master
vvalecha519 Apr 11, 2025
b31a2d5
rename audit and delete file
vvalecha519 Apr 15, 2025
e3688af
Merge pull request #236 from etherfi-protocol/vaibhav/cummulative-mer…
vvalecha519 Apr 15, 2025
f3181ec
fix EtherFiNodesManager_splitBalanceInExecutionLayer
seongyun-ko Apr 18, 2025
e42921d
Revert "fix invalid call in splitBalanceInExecutionLayer"
solipsis May 1, 2025
7979b02
Merge pull request #246 from etherfi-protocol/slashing-2.49-recovery
seongyun-ko May 1, 2025
8bdaa62
Merge branch 'master' into v2.49
seongyun-ko May 1, 2025
194f81d
Merge pull request #258 from etherfi-protocol/v2.49
seongyun-ko May 1, 2025
2b8f113
update README
seongyun-ko May 2, 2025
15d05d8
Merge pull request #260 from etherfi-protocol/syko/feature/update-readme
seongyun-ko May 2, 2025
85515e6
Delete script/deploys/DeployEETH.s.sol
seongyun-ko May 27, 2025
7c403c1
Update DeployEtherFiViewer.s.sol
seongyun-ko May 27, 2025
05e4783
Update DeployEtherFiViewer.s.sol
seongyun-ko May 27, 2025
c31ddcb
Update DeployEtherFiViewer.s.sol
seongyun-ko May 27, 2025
6e1ea49
automate remainder and fix tests
vvalecha519 May 29, 2025
3666d0e
Merge pull request #265 from etherfi-protocol/vaibhav/fix-compliation…
vvalecha519 May 29, 2025
ad70513
deprecate non validator spinup tasks
vvalecha519 Jun 16, 2025
7251e96
make eth claimable by non-admin
vvalecha519 Jun 16, 2025
31177e0
change address to bb address
vvalecha519 Jun 16, 2025
e0fe153
rename to validator approval instead of validatorManagement
vvalecha519 Jun 16, 2025
6d5a033
add test to make sure the oracle changes work
vvalecha519 Jun 18, 2025
539792d
re-add removed event for compatibility
solipsis Jun 18, 2025
d8cc6b1
add 'EtherFiNode_withdrawableBalanceInExecutionLayer'
seongyun-ko Jun 19, 2025
cb3b46c
Merge branch 'master' into syko/feature/update_viewer
seongyun-ko Jun 19, 2025
fad49c2
Merge pull request #263 from etherfi-protocol/syko/feature/update_viewer
seongyun-ko Jun 19, 2025
3d00d11
Merge pull request #268 from etherfi-protocol/vaibhav/add-wd-claimer-…
vvalecha519 Jun 27, 2025
f45a635
wip better validator test setup
solipsis Jun 27, 2025
78c8ac9
debugging tests
solipsis Jun 27, 2025
9d2e6fe
update forge-std version
solipsis Jun 27, 2025
7106834
finish validator helper
solipsis Jun 27, 2025
6d0806c
linking tests
solipsis Jun 28, 2025
4bb269c
cleanup
solipsis Jun 29, 2025
298c5cf
more test cleanup
solipsis Jun 29, 2025
e6b643b
add transfer event when eth is sweeped
vvalecha519 Jun 23, 2025
eb6ea94
Merge pull request #269 from etherfi-protocol/vaibhav/sweep-event
vvalecha519 Jul 2, 2025
150ff6e
merge with master
solipsis Jul 3, 2025
ad6485f
update validator helper test
solipsis Jul 3, 2025
950fbf0
Merge branch 'wip-v3-prelude' of github.com:etherfi-protocol/smart-co…
solipsis Jul 3, 2025
23fc891
update weETH changes to be consistent with other v3-prelude upgrades
solipsis Jul 4, 2025
2c8bc93
add event for transferring eth from EtherFiNode
solipsis Jul 4, 2025
7146add
add new role for validator confirmations in liquidity pool
solipsis Jul 4, 2025
6aca5fe
disambiguate deposit_data_root and deposit_root
solipsis Jul 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/claim_remainder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: test

on:
schedule:
- cron: "0 0 * * 1"
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
name: Foundry project
runs-on: ubuntu-latest


steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Create logs directory
run: mkdir -p ./release/logs/txns

- name: Run tests
run: forge test --match-test test_handle_remainder
env:
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}

- name: Upload transaction logs
uses: actions/upload-artifact@v4
if: always() # This ensures the step runs even if tests fail
with:
name: transaction-logs
path: ./release/logs/txns/
retention-days: 7 # Keeps artifacts for 7 days
85 changes: 29 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,54 @@
# etherfi-protocol smart-contracts
# ether.fi Liquid Restaking Protocol

Smart Contracts for ether.fi ethereum staking protocol.

From 2024/02/15, we have migrated from our private repo to this public one.
We start with the shallow copy of the latest commit of the private one.

# EtherFi smart contracts setup
## Overview

## Get Started
The ether.fi Liquid Restaking Protocol represents the core infrastructure powering ether.fi's vision of becoming the most secure and efficient liquid staking solution in DeFi. This protocol enables:

### Install Foundry
- **Liquid Staking**: Seamless ETH staking with immediate liquidity through eETH
- **Native Restaking**: Effortless & Secure restaking of staked ETH. Restaking & AVS management is strictly controlled by the Protocol via ether.fi's AVS operator contracts ([link](https://github.com/etherfi-protocol/etherfi-avs-operator)). Restaking rewards are distributed via KING ([link](https://github.com/orgs/King-Protocol/repositories))
- **Massive Integration with DeFi**: Wide integration with DeFi protocols
- **Cross-Chain Capabilities**: Native support for cross-chain staking & bridging of weETH ([link](https://github.com/etherfi-protocol/weETH-cross-chain/))
- **Enterprise-Grade Security**: Rigorous security measures through audits, formal verification, and continuous monitoring

```zsh
curl -L https://foundry.paradigm.xyz | bash
```

### Update Foundry

```zsh
foundryup
```

### Install Submodules
## 🔒 Security

```zsh
git submodule update --init --recursive
```
Security is paramount at ether.fi. Our protocol undergoes:

### Formatter and Linter
- Regular & Continuous audits by industry leaders
- Formal verification through Certora
- Continuous monitoring and testing

Run `yarn` to install `package.json` which includes our formatter and linter. We will switch over to Foundry's sol formatter and linter once released.

### Set your environment variables

Check `.env.example` to see some of the environment variables you should have set in `.env` in order to run some of the commands.
## 🛠️ Development Setup

### Compile Project

```zsh
```bash
# Install & Setup
curl -L https://foundry.paradigm.xyz | bash
git clone https://github.com/etherfi-protocol/smart-contracts.git && cd smart-contracts
git submodule update --init --recursive
forge build
```

### Run Project Tests

```zsh
forge test
```

### Run Project Fork Tests

```zsh
forge test --fork-url <your_rpc_url>>
```

### Run Project Fork Tests

```zsh
certoraRun certora/conf/<contract-name>.conf
# Testing
forge test # Run all tests
forge test --fork-url <your_rpc_url> # Fork testing
certoraRun certora/conf/<contract-name>.conf # Formal verification
```

### Build Troubleshooting Tips
## 📚 Documentation

In case you run into an issue of `forge` not being able to find a compatible version of solidity compiler for one of your contracts/scripts, you may want to install the solidity version manager `svm`. To be able to do so, you will need to have [Rust](https://www.rust-lang.org/tools/install) installed on your system and with it the accompanying package manager `cargo`. Once that is done, to install `svm` run the following command:
- [Protocol Documentation](https://etherfi.gitbook.io/etherfi/)

```zsh
cargo install svm-rs
```

To list the available versions of solidity compiler run:

```zsh
svm list
```
## 📄 License

Make sure the version you need is in this list, or choose the closest one and install it:
ether.fi is open-source and licensed under the [MIT License](LICENSE).

```zsh
svm install "0.7.6"
```
---

<p align="center">Built with ❤️ by the ether.fi team</p>
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/forge-std
Submodule forge-std updated 50 files
+6 −12 .github/workflows/ci.yml
+3 −1 .github/workflows/sync.yml
+193 −0 CONTRIBUTING.md
+19 −3 README.md
+5 −3 foundry.toml
+1 −1 package.json
+12 −1 scripts/vm.py
+16 −9 src/Base.sol
+1 −0 src/Script.sol
+1 −1 src/StdAssertions.sol
+47 −11 src/StdChains.sol
+17 −5 src/StdCheats.sol
+30 −0 src/StdConstants.sol
+18 −3 src/StdInvariant.sol
+104 −0 src/StdJson.sol
+1 −1 src/StdStorage.sol
+104 −0 src/StdToml.sol
+1 −18 src/StdUtils.sol
+1 −0 src/Test.sol
+826 −67 src/Vm.sol
+635 −608 src/console.sol
+1 −1,555 src/console2.sol
+1 −1 src/interfaces/IERC1155.sol
+3 −3 src/interfaces/IERC4626.sol
+72 −0 src/interfaces/IERC6909.sol
+1 −1 src/interfaces/IERC721.sol
+150 −0 src/interfaces/IERC7540.sol
+241 −0 src/interfaces/IERC7575.sol
+0 −234 src/mocks/MockERC20.sol
+0 −235 src/mocks/MockERC721.sol
+693 −4 src/safeconsole.sol
+44 −0 test/CommonBase.t.sol
+1 −5 test/StdAssertions.t.sol
+33 −27 test/StdChains.t.sol
+56 −35 test/StdCheats.t.sol
+38 −0 test/StdConstants.t.sol
+12 −12 test/StdError.t.sol
+1 −1 test/StdJson.t.sol
+4 −14 test/StdMath.t.sol
+33 −8 test/StdStorage.t.sol
+1 −1 test/StdStyle.t.sol
+1 −1 test/StdToml.t.sol
+12 −12 test/StdUtils.t.sol
+9 −6 test/Vm.t.sol
+1 −1 test/compilation/CompilationScript.sol
+1 −1 test/compilation/CompilationScriptBase.sol
+1 −1 test/compilation/CompilationTest.sol
+1 −1 test/compilation/CompilationTestBase.sol
+0 −441 test/mocks/MockERC20.t.sol
+0 −721 test/mocks/MockERC721.t.sol
14 changes: 14 additions & 0 deletions roles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Roles Documentation

| Name | Keccak-256 Value | Address | Role Description |
|------|-----------------|---------|-----------------|
| owner of Role Registry | not a role | 0x9f26d4C958fD811A1F59B01B86Be7dFFc9d20761 (timelock) | upgrade:<br>LiquidityPool<br>EtherFiRedemptionManager<br>EtherFiAdmin<br>CumulativeMerkleRewardsDistributor |
| ETHERFI_ORACLE_EXECUTOR_ADMIN_ROLE | 0xf63b1ce674d2cec0dbfcdcc7e504ce31a335c457c363b9fafb6ca524addf1775 | 0xcD425f44758a08BaAB3C4908f3e3dE5776e45d7a (operating timelock) | setValidatorTaskBatchSize<br>invalidateValidatorManagementTask<br>updateAcceptableRebaseApr<br>updatePostReportWaitTimeInSlots |
| ETHERFI_ORACLE_EXECUTOR_TASK_MANAGER_ROLE | 0xe9d356a03911100a5418b1829f363128136c30112754cb3dbe73b1674abe2ac8 | 0x12582A27E5e19492b4FcD194a60F8f5e1aa31B0F (oracle task executor eoa) | executeTasks<br>executeValidatorManagementTask |
| LIQUIDITY_POOL_ADMIN_ROLE | 0x0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d9 | 0xcD425f44758a08BaAB3C4908f3e3dE5776e45d7a, (operating timelock)<br>0x0EF8fa4760Db8f5Cd4d993f3e3416f30f942D705 (EtherFiAdmin) | batchApproveRegistration<br>registerValidatorSpawner<br>unregisterValidatorSpawner<br>sendExitRequests<br>setFeeRecipient<br>setRestakeBnftDeposits |
| ETHERFI_REWARDS_ROUTER_ADMIN_ROLE | 0x45dab652f6af38e394e24f46b5cac6c2825acb3d0b2d490b914660c6095274da | 0x2aCA71020De61bb532008049e1Bd41E451aE8AdC (L1 contract controller) | recoverERC20<br>recoverERC721 |
| ETHERFI_REDEMPTION_MANAGER_ADMIN_ROLE | 0x1fa5f863eb8a62c868fa7eb98a4e47ded14913e6885050cfd9090d04516345b0 | 0xcD425f44758a08BaAB3C4908f3e3dE5776e45d7a (operating timelock) | setCapacity<br>setRefillRatePerSecond<br>setExitFeeBasisPoints<br>setLowWatermarkInBpsOfTvl<br>setExitFeeSplitToTreasuryInBps |
| WITHDRAW_REQUEST_NFT_ADMIN_ROLE | 0xdf341d2a9af804fa0099198f83a0a0611aa273a03b36d576993f914e695dff2a | 0xcD425f44758a08BaAB3C4908f3e3dE5776e45d7a (operating timelock)<br>0x0EF8fa4760Db8f5Cd4d993f3e3416f30f942D705 (EtherFiAdmin) | finalizeRequests<br>invalidateRequest<br>validateRequest<br>handleRemainder |
| PROTOCOL_PAUSER | 0xe6ff4398839854a2087720a46165c7be195bc9de6f7a3c5a977d3b6917b76af2 | 0x0EF8fa4760Db8f5Cd4d993f3e3416f30f942D705 (EtherFiAdmin), 0x9AF1298993DC1f397973C62A5D47a284CF76844D (Hypernative),<br>0x2aCA71020De61bb532008049e1Bd41E451aE8AdC (Mainnet contract controller) | pause on EtherFiAdmin<br>pauseContract of EtherFiRedemptionManager<br>pauseContract on LiquidityPool<br>pauseContract on WithdrawRequestNFT<br>unpause on CumulativeMerkleRewardsDistributor |
| PROTOCOL_UNPAUSER | 0xb72d40a29b0ca5ab6e0b32830618dfdcae56fae676396ff1f7c3fede659935c8 | 0x0EF8fa4760Db8f5Cd4d993f3e3416f30f942D705 (EtherFiAdmin)<br>0x2aCA71020De61bb532008049e1Bd41E451aE8AdC (Mainnet contract controller) | unPause on EtherFiAdmin<br>unPauseContract of EtherFiRedemptionManager<br>unPauseContract on LiquidityPool<br>unPauseContract on WithdrawRequestNFT<br>unpause on CumulativeMerkleRewardsDistributor |
| CUMULATIVE_MERKLE_REWARDS_DISTRIBUTOR_ADMIN_ROLE | 0xaa26b9baa4a66c7ac933a97b6adb2558a7a6fa699a65e95bb880b1c2156d033b | 0x8D5AAc5d3d5cda4c404fA7ee31B0822B648Bb150 | setPendingMerkleRoot<br>finalizeMerkleRoot<br>setClaimDelay<br>updateWhitelistedRecipient |
43 changes: 43 additions & 0 deletions script/deploys/DeployCumulativeMerkleRewardsDistributor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "forge-std/Script.sol";

import "src/CumulativeMerkleRewardsDistributor.sol";
import "src/UUPSProxy.sol";
import "../../src/helpers/AddressProvider.sol";
import "forge-std/console.sol";

/* Deploy Command
* source .env && forge script ./script/deploys/DeployCumulativeMerkleRewardsDistributor.sol:DeployCumulativeMerkleRewardsDistributor --rpc-url MAINNET_RPC_URL --broadcast --etherscan-api-key $ETHERSCAN_API_KEY --verify --slow -vvvv
*/

contract DeployCumulativeMerkleRewardsDistributor is Script {

AddressProvider public addressProvider;
///////////////////////////////////////
address roleRegistryProxyAddress;
//////////////////////////////////////

function run() external {

address addressProviderAddress = vm.envAddress("CONTRACT_REGISTRY");

vm.startBroadcast();


addressProvider = AddressProvider(addressProviderAddress);
roleRegistryProxyAddress = addressProvider.getContractAddress("RoleRegistry");
address timelockAddress = addressProvider.getContractAddress("EtherFiTimelock");
console2.log("RoleRegistry address:", roleRegistryProxyAddress);

bytes memory initializerData = abi.encodeWithSelector(CumulativeMerkleRewardsDistributor.initialize.selector);
CumulativeMerkleRewardsDistributor cumulativeMerkleRewardsDistributorImplementation = new CumulativeMerkleRewardsDistributor(roleRegistryProxyAddress);
UUPSProxy cumulativeMerkleRewardsDistributorProxy = new UUPSProxy(address(cumulativeMerkleRewardsDistributorImplementation), initializerData);
CumulativeMerkleRewardsDistributor cumulativeMerkleInstance = CumulativeMerkleRewardsDistributor(address(cumulativeMerkleRewardsDistributorProxy));
//cumulativeMerkleInstance.grantRole(keccak256("CUMULATIVE_MERKLE_REWARDS_DISTRIBUTOR_ADMIN_ROLE"), msg.sender);
cumulativeMerkleInstance.transferOwnership(address(timelockAddress));

vm.stopBroadcast();
}
}
Loading
Loading