Your First 90 DaysAcademy
Fluent Reading · Any Contract, Cold · Week 10 · Checkpoint 21

and Assets Shares

The most common shape in DeFi is two units of account in one contract. Three hundred and four lines of OpenZeppelin's vault, read cold, and every function in it turns out to be a conversion between assets and shares with one decision attached: where the leftover goes.

16 steps~30 min3 nodes for your map
01 · Two units of account

Three hundred and four lines, and the posture changes here. You already own every word this file uses. So read it the way you would read a file nobody prepared for you: imports first, then what it inherits, then what it stores, and only then the functions.

One fact makes the whole file hard, and it is not a keyword. A vault takes one token in and hands back a different token standing for a claim on the pool. Two quantities, assets and shares, and every function below is a conversion between them.

02 · The vault is itself a token

Line 76 reads `is ERC20, IERC4626`. Take the first name literally. This contract is a token, with balances and a total supply of its own, and those balances are the shares. The vault does not point at a share token living somewhere else. It is one.

Line 77 is the statement from checkpoint fourteen, attaching a library's functions to a type so they can be written as if the type owned them. Lines 79 and 80 are the only stored values in the file, and both are `immutable`. Everything else the vault knows, it works out when asked.

03 · Where the totals come from

The constructor takes the underlying token and keeps it on line 108. Line 106 asks that token how many decimals it uses, and line 107 falls back to eighteen when no answer comes back. Line 119 adds an offset on top of it. Line 123 hands the address out.

Then line 128. `totalAssets` is `public view` and its body is a single line, and it is the one reader on this board that keeps nothing of its own. Line 129 is the whole of it. Read what that line actually does before you decide where its number lives.

Line 129 reads `return IERC20(asset()).balanceOf(address(this));`. Where does the number `totalAssets()` hands back come from?
your balance2,400
BANK_DBowner: the bank
you2,400
what the app is actually showing you
BANK_DBowner: the bank
you2,400their pen
you hold a claim. they hold the pen.
your digital life
BANK · you2,400the bank ✍
INSTAGRAM · you2.1M followersMeta ✍
STEAM · you134 gamesValve ✍
AIRLINE · you58,200 milesthe airline ✍
four tables. zero pens that are yours.
BANK_DBowner: the bank
you2,400
DENIED
try both pens
PLATFORM_DBowner: the platform
her · 8 years2,000,000 followers
one automated decision away
BANK_DB · you · 2,400intentcompetencecontinuity
your row stands on all three
FTX_DBowner: FTX
you5 BTC
the backing vault●●●●●
the row stayed. the backing did not.
CARD_DBowner: your bank ✍
TV you never bought−1,100
fraud reversal+1,100
someone holds the pen, so someone can fix it
?_DBowner: nobody
youstill yours?
?
can a table exist that nobody owns?
?
?_DBowner: ̶n̶o̶b̶o̶d̶y̶
you100
no owner, no pen, no trust?
keeper 1
you100
keeper 2
you100
keeper 3
you100
keeper 4
you100
keeper 5
you100
no THE copy, only copies.
keeper 2
you100
keeper 3
you100
keeper 4
you100
keeper 5
you100
your copy
you100
five copies. one of them is yours.
one attacker
one attacker, ten thousand faces.
real machinesburned wattsnext page, sealed
writing costs watts. faking voters buys nothing.
cost paid OUTSIDE: hardware and power
proof of work, burn energy to vote.
page 1you · 100page 2you · 100page 3you · 100page 4you · 100
rewrite one line, break every lock after it.
office lunchtrusted keeperconsensusfive keepers, real cost
the price buys trustlessness. the office already has trust.
?
ownerless ledger
you?
a key, not a login?
nobody owns the table. so who owns your row?
two unitsfour for twowhere it rounds

Three new nodes on your map

two units · four for two · where it rounds · +10 Lynx