Interactive Learn

ERC-4626 Core Mechanics and Security Invariants

v0.1.0Available

Block-composed Learn

How ERC-4626 Moves Value

Learning progress is session-only in this preview.
Chapter 1 · Section 1

Four Operations, Two Fixed Quantities

Do not memorize the function names—ask what the user specifies

ERC-4626 provides two ways to enter a Vault and two ways to exit it.

You do not need to memorize all four functions separately. For each function, ask one simple question:

Does the user specify the amount of assets, or the number of shares?

With deposit, the user specifies how many assets enter the Vault. The Vault calculates how many shares to mint.

With mint, the user specifies how many shares they want to receive. The Vault calculates how many assets are required.

With withdraw, the user specifies how many assets they want to receive. The Vault calculates how many shares must be burned.

With redeem, the user specifies how many shares they want to burn. The Vault calculates how many assets are returned.

The four state-changing ERC-4626 operationsOriginal educational adaptation authored for TraceFi from the ERC-4626 interface.
IERC4626.solSolidity · Read-only
  1. function deposit(uint256 assets, address receiver)
  2. external returns (uint256 shares);
  3. function mint(uint256 shares, address receiver)
  4. external returns (uint256 assets);
  5. function withdraw(
  6. uint256 assets,
  7. address receiver,
  8. address owner
  9. ) external returns (uint256 shares);
  10. function redeem(
  11. uint256 shares,
  12. address receiver,
  13. address owner
  14. ) external returns (uint256 assets);
Loading IERC4626.sol source

The first parameter shows which quantity the user specifies:

deposit and withdraw receive an asset amount. mint and redeem receive a share amount.

The receiver is the address that receives the output.

In withdraw and redeem, the owner identifies the account whose shares will be burned.

Fixed input versus calculated output

deposit: The user specifies the assets entering the Vault. The Vault calculates the shares minted.

mint: The user specifies the shares to receive. The Vault calculates the assets required.

withdraw: The user specifies the assets to receive. The Vault calculates the shares burned.

redeem: The user specifies the shares to burn. The Vault calculates the assets returned.