feat: vault hub solvency tests#1028
Conversation
Hardhat Unit Tests Coverage SummaryDetailsDiff against masterResults for commit: 9e7f14a Minimum allowed coverage is ♻️ This comment has been updated with latest results |
| depositContract = new DepositContract__MockForStakingVault(); | ||
|
|
||
| lido = new LidoMock(7810237 * 10 ** 18, 9365361 * 10 ** 18, 0); | ||
| LidoLocatorMock lidoLocator = new LidoLocatorMock(depositor, accounting, treasury); |
There was a problem hiding this comment.
Why do we need a mock here? Can't we use the real one?
There was a problem hiding this comment.
The real object includes many members and extra methods, but we only need three of them, so using a mock here is, in my view, the simplest solution.
|
|
||
| uint256 valuationThreshold = (_stakingVault.valuation() * (TOTAL_BASIS_POINTS - socket.rebalanceThresholdBP)) / | ||
| TOTAL_BASIS_POINTS; | ||
| if (valuationThreshold < lido.getPooledEthByShares(socket.sharesMinted)) { |
There was a problem hiding this comment.
We need to allow it to go to the unhealthy state and then, on the next interaction, force rebalance and disconnect.
There was a problem hiding this comment.
can't do this because forceRebalance function reverts if vault is in a bad dept state
| console2.log("Total shares burned", totalSharesBurned); | ||
| console2.log("Shares leftover", sharesLeftover); | ||
|
|
||
| assertEq(totalSharesMinted, totalSharesBurned + sharesLeftover); |
There was a problem hiding this comment.
🤔 maybe assert vault valuation is enough to cover minted shares
dry914
left a comment
There was a problem hiding this comment.
Overall, it looks solid — great job!
A short summary of the changes.
Context
Create solvency tests for VaultHub
Problem
The VaultHub with connected vaults has a complex state. Solvency tests can help to find issues (if they exist) by repeating many operations with random parameteres.
Solution
These tests create and connect Vault to the VaultHub in a random time and then call mint/burn/rebalance/receive_rewards/receive_penalty operations on them. At the same time simulate core protocol staking and rewards mechanism.