01

How many assets is one share?

Deposit tokens in a DeFi vault and you receive vault share tokens instead. When the vault earns a return, the number of shares stays the same while each share represents more assets. ERC-4626 is a standard that makes such vaults handle deposits, withdrawals, and conversions the same way.

This guide shows with hypothetical calculations how ERC-4626 vaults set the conversion between shares and assets. It explains how preview and convert functions differ, how an inflation attack manipulates the rate in an empty vault to take other depositors' assets, and what to check before using a vault.

02

Calculating the conversion rate

As Ethereum.org's page on ERC-4626 explains, a vault accepts one underlying asset and issues share tokens in return. A share's value is broadly the vault's total assets divided by total shares outstanding. With total assets of 1,050,000 and 1,000,000 shares, one share is worth 1.05 of the asset.

Depositing 10,000 at that point yields about 9,524 shares. If the vault later earns a return and total assets grow, the share count stays the same but the assets received on redemption increase. If the vault loses money, each share's value falls.

03

Preview versus convert

ERC-4626 defines preview functions such as previewDeposit and previewRedeem alongside conversion functions such as convertToShares and convertToAssets. The standard says the conversion functions must not include fees charged against vault assets, while preview functions show what you would actually receive now, fees included.

If a displayed share value is based on the conversion functions, the amount actually received on redemption may be lower by any withdrawal fee. The standard also requires rounding in the vault's favor, so very small amounts may yield slightly less than expected.

04

A hypothetical inflation attack

OpenZeppelin's ERC-4626 documentation describes an attack in which, while a vault is empty, an attacker deposits a tiny amount and then donates tokens directly to the vault to push the conversion rate sharply higher. The table simplifies the mechanism in a hypothetical example.

An inflation attack on an empty vault (hypothetical)
StepTotal assetsTotal sharesValue of one shareWhat happens
1. Attacker deposits 1111Receives 1 share
2. Attacker transfers 10,000 directly to the vault10,001110,001Assets rise with no new shares
3. Victim deposits 20,00030,0012≈ 15,00020,000 ÷ 10,001 ≈ 1.9998 rounds down to 1 share
4. Attacker redeems 1 share≈ 15,0001≈ 15,000Attacker put in 10,001 and takes out about 15,000

The victim deposits 20,000 but gets a share worth about 15,000, losing about 5,000 that the attacker gains. Rounding in the share calculation is the heart of the attack.

05

Defenses

OpenZeppelin's documentation describes adding virtual shares and assets to the calculation, a virtual offset, which greatly reduces what such an attack can gain. Operators also seed a vault with an initial deposit at launch so it never sits empty.

As a user, be especially careful about being the first to deposit a large amount into a newly created vault with almost no assets. Checking the shares you would receive with previewDeposit, and using an interface that lets you set a minimum number of shares, helps prevent such losses.

The same caution applies after a vault has been drained, for example when most depositors leave after an incident. A vault returning to near-empty can be exposed in the same way as a brand-new one.

06

Checks before using a vault

Before depositing in an ERC-4626 vault, work through these items.

  1. Look at the vault's total assets and total shares to see whether it is a new, nearly empty vault.
  2. Before depositing, check the shares you would receive with previewDeposit; before redeeming, check assets with previewRedeem.
  3. See whether there are deposit, withdrawal, or performance fees and whether displayed values include them.
  4. Find where the vault deploys assets, and the risks and audit history of that strategy.
  5. Check the official documentation for upgrade powers and withdrawal limits on the vault contract.
07

What the standard does not guarantee

ERC-4626 standardizes the interface; it does not guarantee that a vault manages assets safely. If a vault lends deposits to another protocol or supplies liquidity, that protocol's risks flow straight into the share value.

Some vaults limit how much can be withdrawn at once, or need time to recall deployed assets, so immediate redemption may not be possible. Functions such as maxWithdraw and maxRedeem in the standard show the current withdrawal limit.

Nick's note: I thought the receipt was the coin

When I moved coins into yield products without any routine, I treated the token I got back as the same thing as what I deposited, just with interest attached. I never looked at how many assets one share was actually worth, or how that rate was calculated.

Working through the inflation attack in this article changed that. The share price of a vault is a formula over its balance, and in an empty or thin vault that formula can be bent by someone donating tokens at the right moment. Nothing about the label on the receipt warns you.

Now, before depositing anywhere, I call the vault's preview function or read it on a block explorer and compare it with what I expect to receive. If I cannot find the conversion rate, I do not deposit.

09

Scope of the example

The amounts and attack steps here are simplified hypothetical examples. Real vaults differ in defenses, fees, and strategies, and attack conditions depend on the implementation.

When checking, use the ERC-4626 standard, OpenZeppelin's documentation, and each vault's current official material and audits with their revision dates in mind. Treat the numbers as material for your own judgment, not as trading signals.