EIPs Explained

ERC-7535 · Final · ERC · 2023-10-12

ERC-7535: Native Asset ERC-4626 Tokenized Vault

The ERC-4626 vault interface, unchanged, but with native ETH as the underlying asset, so ETH vaults and liquid staking tokens work with existing ERC-4626 tooling.

What problem does it solve?

ERC-4626 standardised yield-bearing vaults: you deposit an ERC-20 asset and get ERC-20 shares back. But ETH itself is not an ERC-20 token, so a vault that holds raw ETH (for example a liquid staking token) either had to wrap it as WETH first or invent its own interface.

ERC-7535 keeps the exact ERC-4626 function signatures and events and only changes the behaviour needed to accept native ETH. Integrators that already understand ERC-4626 can support ETH vaults with minimal changes.

How it works

A compliant vault implements all of ERC-4626 with these overrides:

  • asset() returns 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE, the placeholder address for native ETH defined in ERC-7528.
  • deposit(assets, receiver) is payable. The amount deposited is msg.value; the assets argument may be ignored. It must revert if the whole msg.value cannot be deposited.
  • mint(shares, receiver) is payable and must revert if msg.value is not enough. If the caller sends too much, the vault decides whether to refund or keep the excess.
  • All "assets" amounts are in wei. Outgoing transfers in withdraw/redeem send ETH instead of calling ERC-20 transfer, and there is no approve/transferFrom step for the asset.
  • Events (Deposit, Withdraw) are identical to ERC-4626.

A vault whose asset is wrapped ETH (an ERC-20) is a normal ERC-4626 vault and must not claim ERC-7535.

Sample code

Depositing ETH into a 7535 vault and redeeming later (ethers v6):

import { Contract, Wallet, JsonRpcProvider, parseEther } from "ethers";

const NATIVE = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
const signer = new Wallet(process.env.PRIVATE_KEY!, new JsonRpcProvider(process.env.RPC_URL));
const vault = new Contract(vaultAddress, [
  "function asset() view returns (address)",
  "function previewDeposit(uint256) view returns (uint256)",
  "function deposit(uint256 assets, address receiver) payable returns (uint256)",
  "function redeem(uint256 shares, address receiver, address owner) returns (uint256)",
], signer);

if ((await vault.asset()) !== NATIVE) throw new Error("not a native-ETH vault");

const amount = parseEther("1");
console.log("expected shares:", await vault.previewDeposit(amount));
await (await vault.deposit(amount, signer.address, { value: amount })).wait();

Minimal shape of the deposit side in Solidity:

function deposit(uint256 /*assets*/, address receiver) public payable returns (uint256 shares) {
    shares = previewDeposit(msg.value);
    _mint(receiver, shares);
    emit Deposit(msg.sender, receiver, msg.value, shares);
}

Things to know

  • Status is Final.
  • Sending ETH out with call opens reentrancy paths that trusted ERC-20 transfers do not. Use reentrancy guards and follow checks-effects-interactions.
  • ETH can be forced into any contract (for example via SELFDESTRUCT), so do not base share accounting on address(this).balance alone without considering that.
  • The spec itself suggests general multi-asset systems should prefer WETH plus plain ERC-4626, and reserve ERC-7535 for ETH-only products such as liquid staking tokens.
  • Inherit all ERC-4626 security advice, including protection against share-inflation ("donation") attacks on empty vaults.

#vault #defi #eth #erc4626 #staking

Details

Authors
Joey Santoro (@joeysantoro)
Status
Final
Type
Standards Track / ERC
Created
2023-10-12
Requires

Machine-readable: Markdown · JSON