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

[Vaults] feat: Dashboard UX updates #915

Open
wants to merge 13 commits into
base: feat/vaults
Choose a base branch
from

Conversation

DiRaiks
Copy link
Contributor

@DiRaiks DiRaiks commented Jan 9, 2025

A short summary of the changes.

Context

General

  • Fixed file imports.

Dashboard Contract

  • Added LidoLocator for retrieving stETH and wstETH contract addresses.
  • Implemented initial approval for stETH to wstETH.
  • Renamed getMintableShares to projectedMintableShares.
  • Updated mintWstETH to utilize the initial approval of stETH.
  • Updated burnWstETH to align with changes in the _burn method.
  • Updated burnWithPermit to align with changes in the _burn method.
  • Updated burnWstETHWithPermit to align with changes in the _burn method.
  • renamed burn -> burnShares
  • renamed mint -> mintShares
  • Refactored burn/fund methods to accommodate changes in _burn/_fund:
    • _fund now takes value as an argument.
    • _burn now accepts _sender and _amountOfShares as arguments.
      • Depending on the _sender type, either transferShares or transferSharesFrom is executed.
      • transferShares is used if the operation originates from the Dashboard contract to avoid additional stETH approvals.

Delegation Contract

  • Updated constructor interface to align with changes in the Dashboard contract.
  • Adjusted fund/burn methods to account for updates to _burn/_fund in the Dashboard contract.

Testing

  • Added tests for Permit functionality when the shares-to-stETH ratio is not 1:1 (e.g., 1 share = 0.5 stETH, 1 share = 2 stETH).
  • Added tests to verify LidoLocator setup in the constructor.

Additional Notes

  • The Permit mechanism with stETH during rebalancing of the shares-to-stETH ratio will still use the value of stETH tokens. As a result, the values passed to the burnWithPermit method and those signed in the Permit may differ. To address this, the StETHPermit contract would need updates, but this could introduce unnecessary overhead.

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 January 9, 2025 09:49
contracts/0.8.25/vaults/Dashboard.sol Outdated Show resolved Hide resolved
function _burn(uint256 _amountOfShares) internal {
STETH.transferSharesFrom(msg.sender, address(vaultHub), _amountOfShares);
function _burn(address _sender, uint256 _amountOfShares) internal {
if (_sender == address(this)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We might be able to skip this check, hear me out. I check steth code.
You need to set infinity steth allowance to address(this) at contract init.
This will allow you to call transferSharesFrom with _sender==address(this).

Copy link
Member

Choose a reason for hiding this comment

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

Infinity steth allowance looks acceptable to me here. However, the condition also does not bother me much.
I need feedback from more experienced individuals (like AP or EM) because having an unlimited allowance doesn’t seem safu.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like we have woo wide permissions for the contact when adding infinity steth allowance, so better stick with original code.

test/0.8.25/vaults/dashboard/dashboard.test.ts Outdated Show resolved Hide resolved

uint256 stETHAmount = WSTETH.unwrap(_amountOfWstETH);
uint256 sharesAmount = STETH.getSharesByPooledEth(stETHAmount);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? Isn't _amountOfWstETH already the same as sharesAmount?

Copy link
Member

@tamtamchik tamtamchik Jan 10, 2025

Choose a reason for hiding this comment

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

It seems that using _amountOfWstETH is the correct approach. However, we need to conduct a test with small numbers to check for rounding issues.

function _burn(uint256 _amountOfShares) internal {
STETH.transferSharesFrom(msg.sender, address(vaultHub), _amountOfShares);
function _burn(address _sender, uint256 _amountOfShares) internal {
if (_sender == address(this)) {
Copy link
Member

Choose a reason for hiding this comment

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

Infinity steth allowance looks acceptable to me here. However, the condition also does not bother me much.
I need feedback from more experienced individuals (like AP or EM) because having an unlimited allowance doesn’t seem safu.

test/0.8.25/vaults/dashboard/dashboard.test.ts Outdated Show resolved Hide resolved
test/0.8.25/vaults/dashboard/dashboard.test.ts Outdated Show resolved Hide resolved
test/0.8.25/vaults/delegation/delegation.test.ts Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jan 10, 2025

badge

Hardhat Unit Tests Coverage Summary

Filename                                                       Stmts    Miss  Cover    Missing
-----------------------------------------------------------  -------  ------  -------  ------------------------------------------------------------------------------
contracts/0.4.24/Lido.sol                                        197      11  94.42%   740-789
contracts/0.4.24/StETH.sol                                        77       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                                   90      86  4.44%    114-487
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/vaults/BeaconChainDepositLogistics.sol           21       2  90.48%   57, 60
contracts/0.8.25/vaults/Dashboard.sol                             84       0  100.00%
contracts/0.8.25/vaults/Delegation.sol                            73       1  98.63%   344
contracts/0.8.25/vaults/StakingVault.sol                          68       0  100.00%
contracts/0.8.25/vaults/VaultFactory.sol                          22       0  100.00%
contracts/0.8.25/vaults/VaultHub.sol                             151     113  25.17%   124-137, 196-503, 517
contracts/0.8.25/vaults/interfaces/IBeaconProxy.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                                                           3504     409  88.33%

Diff against master

Filename                                                       Stmts    Miss  Cover
-----------------------------------------------------------  -------  ------  --------
contracts/0.4.24/Lido.sol                                        -15     +11  -5.58%
contracts/0.4.24/StETH.sol                                        +5       0  +100.00%
contracts/0.8.25/Accounting.sol                                  +90     +86  +4.44%
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/vaults/BeaconChainDepositLogistics.sol          +21      +2  +90.48%
contracts/0.8.25/vaults/Dashboard.sol                            +84       0  +100.00%
contracts/0.8.25/vaults/Delegation.sol                           +73      +1  +98.63%
contracts/0.8.25/vaults/StakingVault.sol                         +68       0  +100.00%
contracts/0.8.25/vaults/VaultFactory.sol                         +22       0  +100.00%
contracts/0.8.25/vaults/VaultHub.sol                            +151    +113  +25.17%
contracts/0.8.25/vaults/interfaces/IBeaconProxy.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                                                           +488    +291  -7.76%

Results for commit: 186e266

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

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.

3 participants