Skip to content

Example: ERC4626 Vault contract with share accounting proofs #1163

@Th0rgal

Description

@Th0rgal

Why

ERC4626 (tokenized vault) is the #2 DeFi primitive after AMMs. Share-based accounting (deposit assets → mint shares, burn shares → withdraw assets) is used in lending protocols, yield aggregators, and staking contracts. Key properties:

  • Share/asset exchange rate monotonicity
  • Rounding correctness (no value leakage from rounding)
  • Deposit/withdraw roundtrip bounds

This would complement the AMM example by demonstrating ratio-based arithmetic proofs.

Scope

Minimal vault with:

  • deposit(assets) → mint shares proportional to assets/totalAssets
  • withdraw(shares) → burn shares, return proportional assets
  • totalAssets() / totalSupply() view functions

Key properties:

  • Share price monotonicity: share price never decreases (absent external losses)
  • Roundtrip bounds: withdraw(deposit(x)) returns at least x - 1 (rounding loss bounded)
  • Conservation: totalAssets = sum of all depositor claims
  • No inflation attack: prove first-depositor advantage is bounded (or mitigated by virtual shares)

Effort

2-3 weeks

Acceptance

  • Vault contract defined with specs
  • Core properties proven with zero sorry
  • Differential tests passing

Metadata

Metadata

Assignees

No one assigned

    Labels

    deferredIntentionally deferred until architectural cleanup is complete

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions