Skip to main content
Technology & EngineeringWeb3 Development36 lines

ERC-4626 Vault Share Accounting

Review vault asset/share conversion, preview rounding, fee behavior and defensive invariant tests against ERC-4626.

Quick Summary8 lines
Use this skill to reason about a tokenized vault's accounting before integrating or changing it. Record the underlying asset, asset decimals, share decimals, implementation version, fee model and supported token behavior. Never infer safety from interface conformance alone.

## Key Points

- [ERC-4626 specification](https://eips.ethereum.org/EIPS/eip-4626)
- [OpenZeppelin vault guidance](https://docs.openzeppelin.com/contracts/5.x/erc4626)
skilldb get web3-development-skills/erc4626-share-accountingFull skill: 36 lines
Paste into your CLAUDE.md or agent config

ERC-4626 Vault Share Accounting

Use this skill to reason about a tokenized vault's accounting before integrating or changing it. Record the underlying asset, asset decimals, share decimals, implementation version, fee model and supported token behavior. Never infer safety from interface conformance alone.

Map quantities and methods

Keep conversion functions separate from previews. Conversions describe idealized asset/share relationships under the standard's assumptions; operation previews account for the relevant operation and fees. Read the standard for each method's rounding and limits rather than applying one formula everywhere.

For valid matching operations in the same transaction without intervening state changes, check the standard's directional guarantees: previewDeposit returns no more shares than deposit mints, and previewRedeem returns no more assets than redeem sends. previewMint returns no fewer assets than mint takes, and previewWithdraw returns no fewer shares than withdraw burns. convertToShares and convertToAssets round down. Inspect maximum operation methods separately: a plausible preview does not mean a user's limit allows execution.

Use integer arithmetic with explicit rounding. Record whether totalAssets includes idle funds, strategy positions, accrued yield and fees. Do not substitute the vault token balance for totalAssets without checking the implementation's accounting model.

Examine adverse states

Test the empty vault, the first deposit, tiny deposits, large donations, losses, yield accrual and very different asset/share decimals. Donation-driven exchange-rate changes can cause severe rounding loss in insufficiently protected vaults. Evaluate the chosen mitigation, such as virtual assets/shares and a decimals offset, against its actual implementation.

Specify the policy for fee-on-transfer, rebasing or otherwise unusual assets. Reject unsupported behavior explicitly instead of assuming a standard transfer amount arrived. Review reentrancy, allowances, receiver ownership and external strategy calls separately from arithmetic.

Verify operation relationships

For an unchanged state and caller conditions, compare previews with actual deposits, mints, withdrawals and redemptions using the guarantees in the standard. Bound permitted rounding differences in smallest units. Do not expect quote equality across a transaction that changes exchange rate, fees or limits.

Create invariant tests for conservation, supply changes and no unauthorized balance movement. Fuzz small values, near-boundary values and successive deposit/redeem sequences. A round trip may lose fees or rounding units; it must not create unexplained value for an ordinary user.

Report each test's asset behavior and implementation version. Deliver a method matrix, worked arithmetic example and failing traces for any violated invariant. Use an isolated test deployment for experiments; this procedure does not authorize moving live funds or replacing a production contract.

References

Install this skill directly: skilldb add web3-development-skills

Get CLI access →