EIPs Explained

ERC-7540 · Final · ERC · 2023-10-18

ERC-7540: Asynchronous ERC-4626 Tokenized Vaults

Extends ERC-4626 vaults with request-then-claim flows for deposits and redemptions, so vaults whose assets settle with a delay (RWAs, staking, cross-chain) can still use the standard vault interface.

What problem does it solve?

ERC-4626 assumes deposits and redemptions happen instantly: call deposit, get shares in the same transaction. Many real products cannot work that way. Real-world asset funds settle off-chain, liquid staking tokens have unstaking queues, cross-chain and undercollateralised lending need time. These protocols had to invent custom interfaces.

ERC-7540 keeps the ERC-4626 interface but adds an asynchronous Request step in front of it.

How it works

A Request moves through three states:

  1. Pending: the user calls requestDeposit(assets, controller, owner) (assets are transferred in) or requestRedeem(shares, controller, owner) (shares leave the owner's custody).
  2. Claimable: the vault processes the request, by its own rules and timing.
  3. Claimed: the controller calls the normal ERC-4626 deposit/mint (to receive shares) or redeem/withdraw (to receive assets).

Key rules:

  • A vault may make only deposits, only redemptions, or both asynchronous. The other side stays synchronous ERC-4626.
  • Requests must not skip Claimable: the vault never pushes tokens; the user always pulls with a claim call.
  • pendingDepositRequest, claimableDepositRequest, pendingRedeemRequest and claimableRedeemRequest show amounts per (requestId, controller).
  • The preview* functions must revert for async flows, because the final exchange rate is unknown until the claim.
  • There is no requestMint or requestWithdraw: only the input amount is certain at request time.
  • Operators (setOperator, isOperator) can manage requests on behalf of a controller.
  • Overloads deposit(assets, receiver, controller) and mint(shares, receiver, controller) are required.
  • ERC-165 support is mandatory. Interface IDs: 0xe3bc4e65 (operator methods), 0xce3bbe50 (async deposit), 0x620ee8e4 (async redeem). Vaults must also implement ERC-7575 (0x2f0a18c5).

Sample code

Request, then claim later (ethers v6):

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

const provider = new JsonRpcProvider(process.env.RPC_URL);
const user = new Wallet(process.env.PRIVATE_KEY!, provider);
const vault = new Contract(vaultAddress, [
  "function requestDeposit(uint256 assets, address controller, address owner) returns (uint256)",
  "function claimableDepositRequest(uint256 requestId, address controller) view returns (uint256)",
  "function deposit(uint256 assets, address receiver, address controller) returns (uint256)",
  "function supportsInterface(bytes4) view returns (bool)",
], user);

if (!(await vault.supportsInterface("0xce3bbe50"))) throw new Error("deposits are synchronous");

const amount = parseUnits("1000", 6);              // asset must be approved to the vault first
await (await vault.requestDeposit(amount, user.address, user.address)).wait();

// ... later, once the vault has fulfilled the request
const claimable = await vault.claimableDepositRequest(0n, user.address);
if (claimable > 0n) await (await vault.deposit(claimable, user.address, user.address)).wait();

Things to know

  • Final standard, used for tokenised real-world asset and similar vaults.
  • requestId may be 0 for every request, in which case requests are tracked only by controller. If non-zero, all requests with the same id share one fulfilment and exchange rate.
  • There is no "Claimable" event; integrators poll the view functions.
  • Cancellation is out of scope here; see the draft ERC-7887.
  • Approving an operator gives it control over both your vault assets and shares. Only approve contracts you trust.
  • Pending requests can get stuck if the vault never fulfils them; users trust the vault's fulfilment and pricing logic.

#vault #defi #erc-4626 #async #rwa

Details

Authors
Jeroen Offerijns (@hieronx), Alina Sinelnikova (@ilinzweilin), Vikram Arun (@vikramarun), Joey Santoro (@joeysantoro), Farhaan Ali (@0xfarhaan), João Martins (@0xTimepunk)
Status
Final
Type
Standards Track / ERC
Created
2023-10-18
Requires
Required by

Machine-readable: Markdown · JSON