Section 4 of 18
Build
+15 LynxVault: pricePerShare and Share Issuance
What You Are Building
Two questions every vault must answer. If a user holds N shares, how much underlying do they own? If a user deposits X underlying, how many shares should they receive? These are mirror images of each other and they both depend on totalAssets().
This section implements _shareValue, _issueSharesForAmount, _totalAssets, and the public pricePerShare. Get the rounding wrong on either of the first two and the vault either dilutes existing depositors or hands the new depositor more than they deserve. Both have happened in production; the historical incidents are the subject of section 5.
Your Code
Solution.sol
Loading editor...
Requirements
Write your implementation, then click Run Tests. Tests execute on the server.
Sign up free — keep reading + earn 15 Lynx
Zealynx Academy is free. Track your progress, earn Lynx, and climb the leaderboard.
Sign up free to continueAlready have an account? Log in