ERC-4626: Tokenized Vault Standard
ERC-4626 standardises yield-bearing share tokens — a contract that holds a base ERC-20 asset and mints a share token to depositors. As the vault earns yield, each share is redeemable for an increasing amount of the underlying. Aave, Yearn, Sommelier, and most yield-bearing protocols implement this.
Required Interface (Highlights)
| Method | Purpose |
|---|---|
asset() | Underlying token |
totalAssets() | TVL in underlying |
convertToShares / convertToAssets | Pricing |
deposit / mint | Add liquidity, receive shares |
withdraw / redeem | Remove liquidity, burn shares |
Inflation Attack
The famous ERC-4626 vulnerability: attacker deposits 1 wei, donates a large amount directly to the vault, then totalAssets is huge but totalSupply is 1. The next depositor gets 0 shares due to integer truncation. Mitigation: virtual offset (OpenZeppelin pattern) or seed dead shares at deployment.
Neo Equivalent
The Neo C# port uses NEP-17 for the share token + an asset reference. Crucially, it uses NEP-17's onNEP17Payment to auto-deposit when the user sends asset directly to the vault — no separate approve + deposit dance needed. Single transaction UX is built in.
Live on Neo TestNet
Both implementations deployed on Neo N3 TestNet.
| Implementation | TestNet Address | Contract Hash |
|---|---|---|
Solidity (neo-solc) | NMKxbu3BoWHMqsehay8ybt4AX2Akbau7JF | 0xfaf678fd…1f9f810f |
Neo C# (nccs) | NdtwXkP4UYHoaEkfFavBat7fhNpMMaknX8 | 0x0e515ad2…647740c5 |
Verified: vault metadata (symbol, decimals), empty initial state. The C# port uses NEP-27's OnNEP17Payment for auto-deposit when the configured asset transfers in. docs/standards-mirror/deployments/erc-4626/.
