Section 2 of 18
Vault: Storage and Constants
What You Are Building
Every later contract in the Vault chain inherits from VaultStorage. Declaring all state up front means each subsequent section can focus on logic instead of bookkeeping, and the cross-section reasoning ("totalDebt must equal the sum of strategies[s].totalDebt across the registry") has a single canonical home.
Compound V2 used the same pattern: CTokenStorage in section 4 declares every state variable the protocol will ever touch; sections 5 through 17 add only behavior. Yearn V2 has fewer contracts than Compound (no separate Comptroller, no separate InterestRateModel), but each contract holds materially more state. By the end of this section the storage layout for the entire vault, including pieces that will not be used until section 16 or 17, is in place.
Your Code
Requirements
Sign up free — keep reading + earn 10 Lynx
Zealynx Academy is free. Track your progress, earn Lynx, and climb the leaderboard.
Sign up free to continueAlready have an account? Log in