HyperEVM Development · L1 Precompiles & Interop · 6/8
HyperEVM Contract Challenge
Test your knowledge of yield vault share-based accounting, deposit/withdrawal mechanics, and ERC-4626 vault patterns.
1. In a share-based vault, how many shares should be minted for the very first deposit of 1000 USDC?
For the first deposit, shares are minted 1:1 with the deposit amount. When totalShares is 0, shares = depositAmount. So 1000 USDC = 1000 shares.
2. A vault has totalAssets=11000 and totalShares=10000 (after yield accrual). If a new user deposits 1100 USDC, how many shares do they receive?
shares = (depositAmount * totalShares) / totalAssets = (1100 * 10000) / 11000 = 1000 shares. The share price is 1.1, so 1100 USDC buys 1000 shares.
3. What should the share price return when the vault has zero total shares?
When totalShares is 0 (empty vault), the share price defaults to 1.0 (par value). This ensures the first depositor gets a 1:1 share ratio.
4. A user holds 500 shares in a vault with totalAssets=22000 and totalShares=10000. How much do they receive on withdrawal?
withdrawal = (sharesToBurn * totalAssets) / totalShares = (500 * 22000) / 10000 = 1100 USDC. The share price is 2.2, so 500 shares = 1100 USDC.
5. In vault simulation, what is the correct order of operations between deposits and yields?
The correct sequence is: process deposit[0], then yield[0], then deposit[1], then yield[1], and so on. Yield accrues between deposits, which changes the share price for subsequent depositors.