Skip to content

Commit

Permalink
Add readme and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
kanewallmann committed Apr 3, 2024
1 parent 8b440c7 commit 4e2e2ae
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 90 deletions.
68 changes: 13 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,24 @@
## Foundry
## ERC4626-Wrapped rETH

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
This project comprises two components: wrETH and rETHERC4626.

Foundry consists of:
rETH (the native liquid staking token of the Rocket Pool Protocol) is a non-rebasing token, it's value is determined
by the amount of ETH backing the supply which increases as validators earn rewards from the protocol.

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
wrETH is a rebasing token. wrETH accepts rETH tokens and mints their equivalent ETH quantity in wrETH. When the
protocol rate of rETH updates each day, wrETH is rebased to match. In this way, 1 wrETH is always equivalent to
1 ETH in value. wrETH can be burned to recover the equivalent value in the underlying rETH tokens.

## Documentation
This ERC-4626 vault uses wrETH as it's underlying token. It further wraps wrETH to provide another non-rebasing
variant of rETH that is compliant with the ERC-4626 standard (wwrETH). The underlying token is wrETH but because
wrETH is equivalent in value to ETH, the `asset` values shown can be thought of as ETH.

https://book.getfoundry.sh/

## Usage

### Build

```shell
$ forge build
```
rETH cannot itself be an ERC-4626 vault because it cannot accept deposits of the underlying token (ETH) on an L2 due
to the unknown available deposit limit on the deposit pool on L1. So this abstraction is necessary in order to
maintain compliance with ERC-4626.

### Test

```shell
$ forge test
```

### Format

```shell
$ forge fmt
```

### Gas Snapshots

```shell
$ forge snapshot
```

### Anvil

```shell
$ anvil
```

### Deploy

```shell
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
```

### Cast

```shell
$ cast <subcommand>
```

### Help

```shell
$ forge --help
$ anvil --help
$ cast --help
```
12 changes: 0 additions & 12 deletions script/Counter.s.sol

This file was deleted.

21 changes: 1 addition & 20 deletions src/WRETHVault.sol → src/RETHERC4626.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,9 @@ import "openzeppelin-contracts/contracts/token/ERC20/extensions/ERC4626.sol";
import "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import "./interface/IWRETH.sol";

/*
rETH is a non-rebasing token, it's value is determined by the amount of ETH backing the supply which increases
as validators earn rewards from the protocol.
wrETH is a rebasing token. wrETH accepts rETH tokens and mints their equivalent ETH quantity in wrETH. When the
protocol rate of rETH updates each day, wrETH is rebased to match. In this way, 1 wrETH is always equivalent to
1 ETH in value. wrETH can be burned to recover the equivalent value in the underlying rETH tokens.
This ERC-4626 vault uses wrETH as it's underlying token. It further wraps wrETH to provide another non-rebasing
variant of rETH that is compliant with the ERC-4626 standard (wwrETH). The underlying token is wrETH but because
wrETH is equivalent in value to ETH, the `asset` values shown can be thought of as ETH.
rETH cannot itself be an ERC-4626 vault because it cannot accept deposits of the underlying token (ETH) on an L2 due
to the unknown available deposit limit on the deposit pool on L1. So this abstraction is necessary in order to
maintain compliance with ERC-4626.
*/

/// @author Kane Wallmann (Rocket Pool)
/// @notice An ERC-4626 implementation for wrETH that supports transparent minting/burning of wrETH from rETH
contract WRETHVault is ERC4626 {
contract RETHERC4626 is ERC4626 {
using Math for uint256;

IERC20 immutable public rETH;
Expand Down
6 changes: 3 additions & 3 deletions test/Vault.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import "../lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol";
import "../src/WRETH.sol";
import "../src/mock/MockRETH.sol";
import "../src/mock/MockOracle.sol";
import "../src/WRETHVault.sol";
import "../src/RETHERC4626.sol";

/// @dev Tests for the ERC-4626 vault
contract VaultTest is Test {
MockRETH public rETH;
WRETH public wrETH;
MockOracle public oracle;
WRETHVault public vault;
RETHERC4626 public vault;

address public alice = vm.addr(1);
address public bob = vm.addr(2);
Expand All @@ -24,7 +24,7 @@ contract VaultTest is Test {
oracle = new MockOracle(1 ether);
rETH = new MockRETH();
wrETH = new WRETH(IERC20(address(rETH)), oracle);
vault = new WRETHVault(wrETH);
vault = new RETHERC4626(wrETH);
}

//
Expand Down

0 comments on commit 4e2e2ae

Please sign in to comment.