Skip to main content

ERC-4626 Vault Analyzer

Spec-exact vault math simulator and on-chain vault reader — all client-side

Vault state & deposit

Math follows EIP-4626 exactly: mint/deposit round shares down, withdraw rounds assets up, redeem rounds assets down — computed in BigInt with the virtual-share offsets OpenZeppelin uses.

Shares minted (deposit, round-down)

1000

Assets back on redeem (round-down)

1000

Round-trip dust lost

0 wei

Assets needed (withdraw, round-up)

1000

Share price (assets/share ×10¹⁸)

1000000000000000000

Growth & fee drag

Gross after horizon

1080.0000

Fee drag

0.1600

Net

1079.8400

Inflation attack illustration

First-depositor scenario: attacker mints 1 share, donates 10 tokens directly to the vault to inflate the share price, then you deposit 1,000 tokens.

Your shares received

0.000000000000000199

Attacker's gain on your 1,000

5

Mitigations: virtual share offsets (the simulator inputs above), seeding the vault before openings, and dead shares. The offsets round dust away from the attacker's arithmetic.

About the Vault Calculator

ERC-4626 standardized yield vaults: one interface for deposit, mint, withdraw, redeem, accounting, and previews — so vaults compose like tokens. But the spec’s integer math is where integrations break: four rounding directions (mint/deposit round shares down, withdraw rounds assets up, redeem rounds assets down), virtual-share offsets against the inflation attack, and share prices that shift with every harvest.

This analyzer gives you both halves of vault math. The simulator computes EIP-4626 conversions in exact BigInt arithmetic with configurable virtual offsets — shares minted, round-trip dust, withdraw costs, share price — plus growth and management-fee drag over a horizon, and a worked inflation-attack illustration. The on-chain reader pulls any live vault through the standard interface (asset, totals, convertTo probes, share price) with plain read-only eth_calls across 21 EVM chains or your own RPC.

How to use

  1. Simulator: set the vault state (total assets, total supply, decimals, offsets) and your deposit.
  2. Read the minted shares, redeem-back assets, and round-trip dust — all with spec rounding.
  3. Set APR, horizon, and fee to see gross vs net growth of the position.
  4. Read on-chain: pick a chain, paste a vault address, and get live totals and share price.

Frequently Asked Questions

How does ERC-4626 rounding work? ▾

Four rules from the spec: previewDeposit and previewMint round shares DOWN in favor of the vault (you never receive more shares than earned); previewWithdraw rounds the required shares UP (you never pay less than owed); previewRedeem rounds assets DOWN. The simulator implements all four in exact integer math, so the round-trip dust it shows is precisely what the spec permits a vault to keep.

What is the ERC-4626 inflation attack? ▾

The first depositor attack: an attacker mints 1 share, donates tokens directly to the vault to inflate assets-per-share, then waits for a victim whose large deposit rounds to nearly zero shares. The attacker redeems their 1 share for a cut of the victim’s deposit. Defenses: virtual share offsets (OpenZeppelin’s default DECIMALS_OFFSET math, simulated above), seeding the vault at deployment, or dead shares. Deposits after meaningful liquidity exists are not exposed.

How is vault share price calculated? ▾

Share price is totalAssets divided by totalSupply — assets per share, independent of token decimals. This reader reports it scaled by 10^18 for precision. A rising share price is the vault’s yield accruing; a falling one means losses or accounting issues. Compare convertToShares(100) against 100 / price as a sanity check for spec compliance.

Can this tool move my funds? ▾

No. The reader sends only eth_call requests — protocol-level reads that cannot mutate state — to the standard ERC-4626 view functions. The simulator is pure local arithmetic. No wallet is connected and nothing is signed.