Accounting
When a Diamond invests into multiple underlying ERC-4626 vaults (each in its own facet), the Diamond issues its own share token to depositors. Meanwhile, it holds various ERC-4626 share tokens under the hood.
The Diamond calculates (or previews) its total asset value by querying the price per share (or “convert to assets” logic) of each underlying ERC-4626 vault. It then sums up these values to determine its total holdings. Finally, that total value is divided by the Diamond’s own share token supply, giving a price per Diamond share. Deposits or withdrawals from the Diamond are then executed according to this price.
How the Accounting Flows
User Deposits to the Diamond Vault
A user calls deploy()
on the Diamond Vault Facet, sending in some asset (e.g., DAI, ETH, etc.). The Diamond mints an equivalent amount of its own Diamond vault shares to the user based on the current Diamond share price.
Diamond Allocates to Underlying Vault Facets
The Diamond’s off-chain curator decides how to deploy the deposited assets. The Diamond deposits into one or more ERC-4626 vaults (each in a facet), receiving the underlying ERC-4626 share tokens in return. These ERC-4626 share tokens are all held by the Diamond contract (not by the depositor directly).
Periodic Valuation of Underlying
Each ERC-4626 vault has its own way of tracking value (e.g., pricePerShare
, previewRedeem
, or convertToAssets
functions). To calculate the Diamond’s total holdings at any point, the Diamond adds up:
The current balance of the base asset(s) it still holds, plus
The value of all ERC-4626 share tokens it owns (number of shares * vault share price), plus
Any other miscellaneous assets, fees, or yield accrued.
Diamond Share Price
The Diamond’s total net asset value (NAV) is then divided by its total supply of Diamond vault shares. This gives the price per Diamond share. When a user deposits, the number of Diamond shares they receive = (amount deposited / price per Diamond share). Conversely, when a user withdraws, the Diamond burns that many shares and returns the user’s proportionate claim from its underlying assets.
User Withdraws from the Diamond
On withdraw()
, the Diamond calculates how many base assets to return using the current Diamond share price.
If needed, the Diamond can redeem some of its ERC-4626 shares from the underlying vaults to free up liquidity.
The user’s Diamond shares are burned, and the user receives the corresponding value in the base asset.
Last updated