Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Vaults #874

Draft
wants to merge 336 commits into
base: master
Choose a base branch
from
Draft

feat: Vaults #874

wants to merge 336 commits into from

Conversation

tamtamchik
Copy link
Member

@tamtamchik tamtamchik commented Nov 17, 2024

❗ 🚧 Under construction 🚧 ❗

Staking Vaults

New way of isolated staking, through separate vaults, with optional stETH liquidity

tamtamchik and others added 30 commits September 16, 2024 17:04
chore: add vaults reporting to accounting
Vault fees and oracle reports refactoring
@folkyatina folkyatina changed the base branch from master to develop November 27, 2024 07:48
@folkyatina folkyatina changed the base branch from develop to master November 27, 2024 07:48
@TheDZhon TheDZhon self-requested a review November 27, 2024 08:05
Copy link
Contributor

@TheDZhon TheDZhon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘€

.github/workflows/analyse.yml Outdated Show resolved Hide resolved
.github/workflows/coverage.yml Outdated Show resolved Hide resolved
.github/workflows/tests-integration-holesky-devnet-0.yml Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's restore it later

contracts/0.4.24/Lido.sol Outdated Show resolved Hide resolved
contracts/0.4.24/Lido.sol Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ maybe we need to postpone unlocks for vaults if bunker enabled

contracts/0.4.24/Lido.sol Outdated Show resolved Hide resolved
contracts/0.4.24/Lido.sol Outdated Show resolved Hide resolved
contracts/0.4.24/Lido.sol Outdated Show resolved Hide resolved
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slither found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link

github-actions bot commented Nov 27, 2024

badge

Hardhat Unit Tests Coverage Summary

Filename                                                       Stmts    Miss  Cover    Missing
-----------------------------------------------------------  -------  ------  -------  ------------------------------------------------------
contracts/0.4.24/Lido.sol                                        176      39  77.84%   391-397, 500-508, 609-647, 704-754, 904, 929-934, 1013
contracts/0.4.24/StETH.sol                                        79       0  100.00%
contracts/0.4.24/StETHPermit.sol                                  15       0  100.00%
contracts/0.4.24/lib/Packed64x4.sol                                5       0  100.00%
contracts/0.4.24/lib/SigningKeys.sol                              36       0  100.00%
contracts/0.4.24/lib/StakeLimitUtils.sol                          37       0  100.00%
contracts/0.4.24/nos/NodeOperatorsRegistry.sol                   485       0  100.00%
contracts/0.4.24/oracle/LegacyOracle.sol                          72       0  100.00%
contracts/0.4.24/utils/Pausable.sol                                9       0  100.00%
contracts/0.4.24/utils/Versioned.sol                               5       0  100.00%
contracts/0.6.12/WstETH.sol                                       17       0  100.00%
contracts/0.8.25/Accounting.sol                                   83      81  2.41%    109-476
contracts/0.8.25/interfaces/ILido.sol                              0       0  100.00%
contracts/0.8.25/interfaces/IOracleReportSanityChecker.sol         0       0  100.00%
contracts/0.8.25/interfaces/IPostTokenRebaseReceiver.sol           0       0  100.00%
contracts/0.8.25/interfaces/IStakingRouter.sol                     0       0  100.00%
contracts/0.8.25/interfaces/IWithdrawalQueue.sol                   0       0  100.00%
contracts/0.8.25/utils/Versioned.sol                              11       5  54.55%   35-37, 49-50
contracts/0.8.25/vaults/StakingVault.sol                          67      46  31.34%   83-105, 113, 126-185, 195-206
contracts/0.8.25/vaults/VaultBeaconChainDepositor.sol             21      19  9.52%    47-93
contracts/0.8.25/vaults/VaultDashboard.sol                        33      20  39.39%   35, 60-138
contracts/0.8.25/vaults/VaultFactory.sol                          18       0  100.00%
contracts/0.8.25/vaults/VaultHub.sol                             133     100  24.81%   86-94, 118, 132, 138, 158-414
contracts/0.8.25/vaults/VaultStaffRoom.sol                        48      37  22.92%   50-57, 67, 89-177
contracts/0.8.25/vaults/interfaces/IBeaconProxy.sol                0       0  100.00%
contracts/0.8.25/vaults/interfaces/IHubVault.sol                   0       0  100.00%
contracts/0.8.25/vaults/interfaces/IReportReceiver.sol             0       0  100.00%
contracts/0.8.25/vaults/interfaces/IStakingVault.sol               0       0  100.00%
contracts/0.8.4/WithdrawalsManagerProxy.sol                       61       0  100.00%
contracts/0.8.9/BeaconChainDepositor.sol                          21       2  90.48%   48, 51
contracts/0.8.9/Burner.sol                                        72       0  100.00%
contracts/0.8.9/DepositSecurityModule.sol                        104       0  100.00%
contracts/0.8.9/EIP712StETH.sol                                   16       0  100.00%
contracts/0.8.9/LidoExecutionLayerRewardsVault.sol                16       0  100.00%
contracts/0.8.9/LidoLocator.sol                                   19       0  100.00%
contracts/0.8.9/OracleDaemonConfig.sol                            28       0  100.00%
contracts/0.8.9/StakingRouter.sol                                303       0  100.00%
contracts/0.8.9/WithdrawalQueue.sol                               88       0  100.00%
contracts/0.8.9/WithdrawalQueueBase.sol                          146       0  100.00%
contracts/0.8.9/WithdrawalQueueERC721.sol                         89       0  100.00%
contracts/0.8.9/WithdrawalVault.sol                               21       0  100.00%
contracts/0.8.9/lib/Math.sol                                       4       0  100.00%
contracts/0.8.9/lib/PositiveTokenRebaseLimiter.sol                22       0  100.00%
contracts/0.8.9/lib/UnstructuredRefStorage.sol                     2       0  100.00%
contracts/0.8.9/oracle/AccountingOracle.sol                      171       1  99.42%   674
contracts/0.8.9/oracle/BaseOracle.sol                             89       1  98.88%   397
contracts/0.8.9/oracle/HashConsensus.sol                         263       1  99.62%   1005
contracts/0.8.9/oracle/ValidatorsExitBusOracle.sol                91      91  0.00%    96-461
contracts/0.8.9/proxy/OssifiableProxy.sol                         17       0  100.00%
contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol      155       0  100.00%
contracts/0.8.9/utils/DummyEmptyContract.sol                       0       0  100.00%
contracts/0.8.9/utils/PausableUntil.sol                           31       0  100.00%
contracts/0.8.9/utils/Versioned.sol                               11       0  100.00%
contracts/0.8.9/utils/access/AccessControl.sol                    23       0  100.00%
contracts/0.8.9/utils/access/AccessControlEnumerable.sol           9       0  100.00%
contracts/testnets/sepolia/SepoliaDepositAdapter.sol              21      21  0.00%    49-100
TOTAL                                                           3243     464  85.69%

Diff against master

Filename                                                       Stmts    Miss  Cover
-----------------------------------------------------------  -------  ------  --------
contracts/0.4.24/Lido.sol                                        -36     +39  -22.16%
contracts/0.4.24/StETH.sol                                        +7       0  +100.00%
contracts/0.8.25/Accounting.sol                                  +83     +81  +2.41%
contracts/0.8.25/interfaces/ILido.sol                              0       0  +100.00%
contracts/0.8.25/interfaces/IOracleReportSanityChecker.sol         0       0  +100.00%
contracts/0.8.25/interfaces/IPostTokenRebaseReceiver.sol           0       0  +100.00%
contracts/0.8.25/interfaces/IStakingRouter.sol                     0       0  +100.00%
contracts/0.8.25/interfaces/IWithdrawalQueue.sol                   0       0  +100.00%
contracts/0.8.25/utils/Versioned.sol                             +11      +5  +54.55%
contracts/0.8.25/vaults/StakingVault.sol                         +67     +46  +31.34%
contracts/0.8.25/vaults/VaultBeaconChainDepositor.sol            +21     +19  +9.52%
contracts/0.8.25/vaults/VaultDashboard.sol                       +33     +20  +39.39%
contracts/0.8.25/vaults/VaultFactory.sol                         +18       0  +100.00%
contracts/0.8.25/vaults/VaultHub.sol                            +133    +100  +24.81%
contracts/0.8.25/vaults/VaultStaffRoom.sol                       +48     +37  +22.92%
contracts/0.8.25/vaults/interfaces/IBeaconProxy.sol                0       0  +100.00%
contracts/0.8.25/vaults/interfaces/IHubVault.sol                   0       0  +100.00%
contracts/0.8.25/vaults/interfaces/IReportReceiver.sol             0       0  +100.00%
contracts/0.8.25/vaults/interfaces/IStakingVault.sol               0       0  +100.00%
contracts/0.8.9/Burner.sol                                        +1       0  +100.00%
contracts/0.8.9/LidoLocator.sol                                   +1       0  +100.00%
contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol      -16       0  +100.00%
TOTAL                                                           +371    +347  -10.24%

Results for commit: 6286561

Minimum allowed coverage is 95%

♻️ This comment has been updated with latest results

Copy link
Contributor

@TheDZhon TheDZhon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘€

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe restore later

@@ -0,0 +1,482 @@
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>

Comment on lines +9 to +16
import {ILidoLocator} from "../common/interfaces/ILidoLocator.sol";
import {IBurner} from "../common/interfaces/IBurner.sol";
import {IPostTokenRebaseReceiver} from "./interfaces/IPostTokenRebaseReceiver.sol";
import {IStakingRouter} from "./interfaces/IStakingRouter.sol";
import {IOracleReportSanityChecker} from "./interfaces/IOracleReportSanityChecker.sol";
import {IWithdrawalQueue} from "./interfaces/IWithdrawalQueue.sol";
import {ILido} from "./interfaces/ILido.sol";
import {ReportValues} from "contracts/common/interfaces/ReportValues.sol";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not embedded in the file here? (Lido contract has embedded ones)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of consistency: let's use one way or another


/// @title Lido Accounting contract
/// @author folkyatina
/// @notice contract is responsible for handling oracle reports
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// @notice contract is responsible for handling oracle reports
/// @notice contract is responsible for handling accounting oracle reports

/// @notice contract is responsible for handling oracle reports
/// calculating all the state changes that is required to apply the report
/// and distributing calculated values to relevant parts of the protocol
contract Accounting is VaultHub {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surprising to see that Accounting is VaultHub

ReportValues memory _report,
PreReportState memory _pre,
CalculatedValues memory _update,
uint256 _simulatedShareRate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint256 _simulatedShareRate
uint256 _withdrawalShareRate

let's unify naming

}

// Distribute protocol fee (treasury & node operators)
if (_update.sharesToMintAsFees > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this name might be misleading, should be named smth 'sharesToMintAsLidoV2ProtocolFees'


_updateVaults(
_report.vaultValues,
_report.netCashFlows,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdim 'cashflows'

_update.vaultsTreasuryFeeShares
);

_notifyObserver(_contracts.postTokenRebaseReceiver, _report, _pre, _update);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_notifyObserver(_contracts.postTokenRebaseReceiver, _report, _pre, _update);
_notifyRebaseObserver(_contracts.postTokenRebaseReceiver, _report, _pre, _update);

}
}

/// @dev mints treasury rewards
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only for Lido V2 protocol fee though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants