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

[Draft] Vaults UX suggestions #893

Open
wants to merge 57 commits into
base: feat-immutable-operator-in-vault
Choose a base branch
from

Conversation

DiRaiks
Copy link
Contributor

@DiRaiks DiRaiks commented Dec 6, 2024

A short summary of the changes.

Context

  • It would be very convenient to have a view on VaultHub that will allow us to get Vaults by the Owner's address
    • Why is it necessary - in theory, there can be a lot of Vaults. To display all the user's Vaults on the UI, we need to get all the Vaults and then make a request for each one to get the Owner's address
  • View on maxMintableShares - external - to show how much stETH Vault allows to mint
  • canMint(uint256 depositSize) - a view that will return how much you can mint from the deposit amount - an exact number.
    • Needed when calculating the amount and for sending the number to the mint() method
  • canWithdraw() - similar to canMint
  • Deposit ETH/WETH
  • Withdrawal ETH/WETH
  • Mint stETH/wstETH
  • Burn + Permit

Problem

What problem this PR solves, link relevant issue if it exists

Solution

Your proposed solution

@DiRaiks DiRaiks requested a review from a team as a code owner December 6, 2024 11:34
@DiRaiks DiRaiks marked this pull request as draft December 6, 2024 11:34
contracts/0.8.25/vaults/Dashboard.sol Outdated Show resolved Hide resolved
contracts/0.8.25/vaults/VaultHub.sol Outdated Show resolved Hide resolved
contracts/0.8.25/vaults/Dashboard.sol Outdated Show resolved Hide resolved
@@ -159,6 +233,15 @@ contract Dashboard is AccessControlEnumerable {
_withdraw(_recipient, _ether);
}

/**
* @notice Withdraws stETH tokens from the staking vault to wrapped ether. Approvals for the passed amounts should be done before.
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, didn't get what it should do. RN, ether is still on the dashboard contract. Should it be transferred to msg.sender or some other recepient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@folkyatina The idea is to send to the fundByWeth method the amount of WETH that needs to be "unwrap" to the ETH and then fund Vault
WETH withdraw method https://github.com/gnosis/canonical-weth/blob/master/contracts/WETH9.sol#L38

Now I understand that it seems that this code will not work correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

contracts/0.8.25/vaults/Dashboard.sol Outdated Show resolved Hide resolved
contracts/0.8.25/vaults/Dashboard.sol Outdated Show resolved Hide resolved
@tamtamchik tamtamchik added solidity issues/tasks related to smart contract code next-upgrade Things to pickup for the next protocol upgrade vaults labels Dec 12, 2024
@DiRaiks DiRaiks changed the base branch from feat/vaults to feat-immutable-operator-in-vault December 17, 2024 13:03
Copy link

github-actions bot commented Dec 17, 2024

badge

Hardhat Unit Tests Coverage Summary

Filename                                                       Stmts    Miss  Cover    Missing
-----------------------------------------------------------  -------  ------  -------  ------------------------------------------------------------------------------
contracts/0.4.24/Lido.sol                                        184      11  94.02%   719-769
contracts/0.4.24/StETH.sol                                        72       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                   512       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                                   85      81  4.71%    114-481
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      11  0.00%    26-55
contracts/0.8.25/vaults/BeaconChainDepositLogistics.sol           21       2  90.48%   57, 60
contracts/0.8.25/vaults/Dashboard.sol                             81       2  97.53%   161, 468
contracts/0.8.25/vaults/Delegation.sol                            82      30  63.41%   207-312, 337-341
contracts/0.8.25/vaults/StakingVault.sol                          75       0  100.00%
contracts/0.8.25/vaults/VaultFactory.sol                          19       0  100.00%
contracts/0.8.25/vaults/VaultHub.sol                             147     108  26.53%   108-117, 141, 157, 163, 183-452
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                        128       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                                   20       0  100.00%
contracts/0.8.9/OracleDaemonConfig.sol                            28       0  100.00%
contracts/0.8.9/StakingRouter.sol                                316       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      22  0.00%    88-172
contracts/0.8.9/lib/UnstructuredRefStorage.sol                     2       0  100.00%
contracts/0.8.9/oracle/AccountingOracle.sol                      190       2  98.95%   154-155
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      218      56  74.31%   195, 232, 273-324, 413-441, 495-507, 558-561, 569, 578, 586, 697, 702-747, 802
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                                                           3498     441  87.39%

Diff against master

Filename                                                       Stmts    Miss  Cover
-----------------------------------------------------------  -------  ------  --------
contracts/0.4.24/Lido.sol                                        -28     +11  -5.98%
contracts/0.8.25/Accounting.sol                                  +85     +81  +4.71%
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     +11  +100.00%
contracts/0.8.25/vaults/BeaconChainDepositLogistics.sol          +21      +2  +90.48%
contracts/0.8.25/vaults/Dashboard.sol                            +81      +2  +97.53%
contracts/0.8.25/vaults/Delegation.sol                           +82     +30  +63.41%
contracts/0.8.25/vaults/StakingVault.sol                         +75       0  +100.00%
contracts/0.8.25/vaults/VaultFactory.sol                         +19       0  +100.00%
contracts/0.8.25/vaults/VaultHub.sol                            +147    +108  +26.53%
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                                   +2       0  +100.00%
contracts/0.8.9/lib/PositiveTokenRebaseLimiter.sol                 0     +22  -100.00%
contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol      -14     +56  -25.69%
TOTAL                                                           +482    +323  -8.70%

Results for commit: 3d5fbb8

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

contracts/0.8.25/vaults/Dashboard.sol Fixed Show fixed Hide fixed
contracts/0.8.25/vaults/Dashboard.sol Fixed Show fixed Hide fixed
contracts/0.8.25/vaults/Dashboard.sol Fixed Show fixed Hide fixed
contracts/0.8.25/vaults/Dashboard.sol Fixed Show fixed Hide fixed
contracts/0.8.25/vaults/Dashboard.sol Fixed Show fixed Hide fixed
contracts/0.8.25/vaults/Dashboard.sol Fixed Show fixed Hide fixed
contracts/0.8.25/vaults/Dashboard.sol Fixed Show fixed Hide fixed
tamtamchik and others added 2 commits December 17, 2024 18:23
…estions

# Conflicts:
#	package.json
#	test/0.8.25/vaults/dashboard/dashboard.test.ts
#	yarn.lock
contracts/0.8.25/vaults/Dashboard.sol Fixed Show fixed Hide fixed
Comment on lines 305 to 314
function mintWstETH(
address _recipient,
uint256 _tokens
) external payable virtual onlyRole(DEFAULT_ADMIN_ROLE) fundAndProceed {
_mint(address(this), _tokens);

stETH.approve(address(wstETH), _tokens);
uint256 wstETHAmount = wstETH.wrap(_tokens);
wstETH.transfer(_recipient, wstETHAmount);
}

Check warning

Code scanning / Slither

Unused return Medium

contracts/0.8.25/vaults/Dashboard.sol Fixed Show fixed Hide fixed
contracts/0.8.25/vaults/Dashboard.sol Fixed Show fixed Hide fixed
contracts/0.8.25/vaults/Dashboard.sol Fixed Show fixed Hide fixed
contracts/0.8.25/vaults/Dashboard.sol Fixed Show fixed Hide fixed
Copy link
Member

@tamtamchik tamtamchik left a comment

Choose a reason for hiding this comment

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

Approved.

However, there are a couple of naming suggestions to consider.

PS. Please note that at the moment, tests are failing because managementDue is being removed in the target branch, causing the tests not to work. T_T

* @notice Funds the staking vault with wrapped ether. Approvals for the passed amounts should be done before.
* @param _wethAmount Amount of wrapped ether to fund the staking vault with
*/
function fundByWeth(uint256 _wethAmount) external virtual onlyRole(DEFAULT_ADMIN_ROLE) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
function fundByWeth(uint256 _wethAmount) external virtual onlyRole(DEFAULT_ADMIN_ROLE) {
function fundWeth(uint256 _wethAmount) external virtual onlyRole(DEFAULT_ADMIN_ROLE) {

* @param _recipient Address of the recipient
* @param _ether Amount of ether to withdraw
*/
function withdrawToWeth(address _recipient, uint256 _ether) external virtual onlyRole(DEFAULT_ADMIN_ROLE) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
function withdrawToWeth(address _recipient, uint256 _ether) external virtual onlyRole(DEFAULT_ADMIN_ROLE) {
function withdrawWeth(address _recipient, uint256 _ether) external virtual onlyRole(DEFAULT_ADMIN_ROLE) {

@tamtamchik tamtamchik marked this pull request as ready for review December 20, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next-upgrade Things to pickup for the next protocol upgrade solidity issues/tasks related to smart contract code vaults
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants