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

Staking Router: fix typos, add base precision to Lido views #508

Merged
merged 4 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions contracts/0.4.24/Lido.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ contract Lido is StETHPermit, AragonApp {
bytes32 public constant STAKING_CONTROL_ROLE = keccak256("STAKING_CONTROL_ROLE");
bytes32 public constant MANAGE_PROTOCOL_CONTRACTS_ROLE = keccak256("MANAGE_PROTOCOL_CONTRACTS_ROLE");
bytes32 public constant BURN_ROLE = keccak256("BURN_ROLE");
bytes32 public constant SET_EL_REWARDS_VAULT_ROLE = keccak256("SET_EL_REWARDS_VAULT_ROLE");
bytes32 public constant SET_EL_REWARDS_WITHDRAWAL_LIMIT_ROLE = keccak256("SET_EL_REWARDS_WITHDRAWAL_LIMIT_ROLE");

uint256 private constant DEPOSIT_SIZE = 32 ether;
Expand Down Expand Up @@ -599,18 +598,22 @@ contract Lido is StETHPermit, AragonApp {
/**
* @notice Returns current staking rewards fee rate
* @return totalFee total rewards fee in base precision
* @return basePrecision base precision number, which constitutes 100% fee
*/
function getFee() public view returns (uint96 totalFee) {
(, , totalFee, ) = getStakingRouter().getStakingRewardsDistribution();
function getFee() public view returns (uint96 totalFee, uint256 basePrecision) {
(, , totalFee, basePrecision) = getStakingRouter().getStakingRewardsDistribution();
}

/**
* @notice Returns current fee distribution proportion
* @return modulesFee modules summary fee in base precision
* @return treasuryFee treasury fee in base precision
* @return basePrecision base precision number, which constitutes 100% fee
*/
function getFeeDistribution() public view returns (uint96 modulesFee, uint96 treasuryFee) {
(, uint96[] memory moduleFees, uint96 totalFee, ) = getStakingRouter().getStakingRewardsDistribution();
function getFeeDistribution() public view returns (uint96 modulesFee, uint96 treasuryFee, uint256 basePrecision) {
uint96[] memory moduleFees;
uint96 totalFee;
(, moduleFees, totalFee, basePrecision) = getStakingRouter().getStakingRewardsDistribution();
for (uint256 i; i < moduleFees.length; ++i) {
modulesFee += moduleFees[i];
}
Expand Down Expand Up @@ -757,7 +760,7 @@ contract Lido is StETHPermit, AragonApp {
_burnShares(withdrawalQueueAddress, sharesToBurn);
}

/// @dev calculate the amout of rewards and distribute it
/// @dev calculate the amount of rewards and distribute it
function _processRewards(
uint256 _preBeaconBalance,
uint256 _postBeaconBalance,
Expand Down Expand Up @@ -902,14 +905,12 @@ contract Lido is StETHPermit, AragonApp {
require(recipients.length == modulesFees.length, "WRONG_RECIPIENTS_INPUT");

if (totalFee > 0) {
uint256 shares2mint = _totalRewards
.mul(totalFee)
.mul(_getTotalShares())
uint256 shares2mint =
_totalRewards.mul(totalFee).mul(_getTotalShares())
.div(
_getTotalPooledEther()
.mul(precisionPoints)
.sub(_totalRewards.mul(totalFee))
);
(_getTotalPooledEther().mul(precisionPoints))
.sub(_totalRewards.mul(totalFee))
);
_mintShares(address(this), shares2mint);

uint256 treasuryReward = shares2mint;
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.4.24/interfaces/IStETH.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>

// SPDX-License-Identifier: GPL-3.0

Expand Down
2 changes: 1 addition & 1 deletion contracts/0.4.24/interfaces/IStakingModule.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.4.24;
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.4.24/interfaces/IStakingRouter.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>

// SPDX-License-Identifier: GPL-3.0

Expand Down
2 changes: 1 addition & 1 deletion contracts/0.4.24/lib/Math64.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>

// SPDX-License-Identifier: MIT

Expand Down
2 changes: 1 addition & 1 deletion contracts/0.4.24/lib/SigningKeysStats.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

// See contracts/COMPILERS.md
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.4.24/lib/StakeLimitUtils.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>

// SPDX-License-Identifier: GPL-3.0

Expand Down
3 changes: 1 addition & 2 deletions contracts/0.4.24/nos/NodeOperatorsRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

// See contracts/COMPILERS.md
Expand Down Expand Up @@ -210,7 +210,6 @@ contract NodeOperatorsRegistry is INodeOperatorsRegistry, AragonApp, IStakingMod
operator.name = _name;
operator.rewardAddress = _rewardAddress;

emit NodeOperatorAdded(id);
emit NodeOperatorAdded(id, _name, _rewardAddress, 0);
}

Expand Down
3 changes: 1 addition & 2 deletions contracts/0.4.24/nos/test_helpers/ERC721Mock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.4.24;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

/* See contracts/COMPILERS.md */
Expand Down
4 changes: 1 addition & 3 deletions contracts/0.4.24/test_helpers/StakeLimitUtilsMock.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

// SPDX-FileCopyrightText: 2022 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.4.24;
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.8.9/BeaconChainDepositor.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

// See contracts/COMPILERS.md
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.8.9/CommitteeQuorum.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.9;

Expand Down
7 changes: 3 additions & 4 deletions contracts/0.8.9/DepositSecurityModule.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: 2021 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

/* See contracts/COMPILERS.md */
Expand Down Expand Up @@ -292,7 +291,7 @@ contract DepositSecurityModule {
}

/**
* Pauses deposits for module given that both conditions are satisfied (reverts otherwise):
* Pauses deposits for staking module given that both conditions are satisfied (reverts otherwise):
*
* 1. The function is called by the guardian with index guardianIndex OR sig
* is a valid signature by the guardian with index guardianIndex of the data
Expand Down Expand Up @@ -337,7 +336,7 @@ contract DepositSecurityModule {
}

/**
* Unpauses deposits for module
* Unpauses deposits for staking module
*
* Only callable by the owner.
*/
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.8.9/LidoOracleNew.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.9;

Expand Down
2 changes: 1 addition & 1 deletion contracts/0.8.9/ReportEpochChecker.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.9;

Expand Down
18 changes: 9 additions & 9 deletions contracts/0.8.9/StakingRouter.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>

// SPDX-License-Identifier: GPL-3.0

Expand Down Expand Up @@ -97,7 +97,7 @@ contract StakingRouter is IStakingRouter, AccessControlEnumerable, BeaconChainDe

constructor(address _depositContract) BeaconChainDepositor(_depositContract) {
/// @dev lock version in implementation to avoid initialize() call
/// DEFAULT_ADMIN_ROLE will remain unset, i.e. no ability to add new members ro roles
/// DEFAULT_ADMIN_ROLE will remain unset, i.e. no ability to add new members or roles
_setContractVersion(type(uint256).max);
}

Expand Down Expand Up @@ -177,7 +177,7 @@ contract StakingRouter is IStakingRouter, AccessControlEnumerable, BeaconChainDe
}

/**
* @notice update staking module params
* @notice Update staking module params
* @param _stakingModuleId staking module id
* @param _targetShare target total stake share
* @param _stakingModuleFee fee of the staking module taken from the consensus layer rewards
Expand Down Expand Up @@ -208,7 +208,7 @@ contract StakingRouter is IStakingRouter, AccessControlEnumerable, BeaconChainDe


/**
* @notice Returns all registred staking modules
* @notice Returns all registered staking modules
*/
function getStakingModules() external view returns (StakingModule[] memory res) {
uint256 stakingModulesCount = getStakingModulesCount();
Expand Down Expand Up @@ -243,8 +243,8 @@ contract StakingRouter is IStakingRouter, AccessControlEnumerable, BeaconChainDe
/**
* @dev Returns staking module by index
*/
function getStakingModuleByIndex(uint256 _stakingModuleIdndex) external view returns (StakingModule memory) {
return _getStakingModuleByIndex(_stakingModuleIdndex);
function getStakingModuleByIndex(uint256 _stakingModuleIndex) external view returns (StakingModule memory) {
return _getStakingModuleByIndex(_stakingModuleIndex);
}

/**
Expand Down Expand Up @@ -355,11 +355,12 @@ contract StakingRouter is IStakingRouter, AccessControlEnumerable, BeaconChainDe
}

/**
* @notice return shares table
* @notice Return shares table
*
* @return recipients recipients list
* @return stakingModuleFees fee of each recipient
* @return totalFee total fee to mint for each staking module and treasury
* @return precisionPoints base precision number, which constitutes 100% fee
*/
function getStakingRewardsDistribution()
external
Expand Down Expand Up @@ -390,7 +391,7 @@ contract StakingRouter is IStakingRouter, AccessControlEnumerable, BeaconChainDe
recipients[rewardedStakingModulesCount] = address(stakingModuleCache[i].stakingModuleAddress);
stakingModuleFee = uint96((stakingModuleKeysShare * stakingModuleCache[i].stakingModuleFee) / TOTAL_BASIS_POINTS);
/// @dev if the staking module has the `Stopped` status for some reason, then
/// the staking module's rewards go to the treasure, so that the DAO has ability
/// the staking module's rewards go to the treasury, so that the DAO has ability
/// to manage them (e.g. to compensate the staking module in case of an error, etc.)
if (stakingModuleCache[i].status != StakingModuleStatus.Stopped) {
stakingModuleFees[rewardedStakingModulesCount] = stakingModuleFee;
Expand Down Expand Up @@ -471,7 +472,6 @@ contract StakingRouter is IStakingRouter, AccessControlEnumerable, BeaconChainDe
}
}
_transferBalanceEthToLido();
// return keysCount;
}

/// @dev transfer all remaining balance to Lido contract
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.8.9/ValidatorExitBus.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.9;

Expand Down
2 changes: 1 addition & 1 deletion contracts/0.8.9/WithdrawalVault.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>

// SPDX-License-Identifier: GPL-3.0

Expand Down
3 changes: 1 addition & 2 deletions contracts/0.8.9/interfaces/ISelfOwnedStETHBurner.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.9;
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.8.9/interfaces/IStakingModule.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.9;
Expand Down
3 changes: 1 addition & 2 deletions contracts/0.8.9/interfaces/IStakingRouter.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

/* See contracts/COMPILERS.md */
Expand Down
3 changes: 1 addition & 2 deletions contracts/0.8.9/lib/Math.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: MIT

// See contracts/COMPILERS.md
Expand Down
3 changes: 1 addition & 2 deletions contracts/0.8.9/proxy/OssifiableProxy.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

/* See contracts/COMPILERS.md */
Expand Down
3 changes: 1 addition & 2 deletions contracts/0.8.9/test_helpers/BeaconChainDepositorMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

/* See contracts/COMPILERS.md */
Expand Down
4 changes: 2 additions & 2 deletions contracts/0.8.9/test_helpers/LidoOracleNewMock.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

/* See contracts/COMPILERS.md */
pragma solidity 0.8.9;

import "../LidoOracleNew.sol";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

/* See contracts/COMPILERS.md */
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.8.9/test_helpers/ModuleSolo.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

// See contracts/COMPILERS.md
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.8.9/test_helpers/StakingModuleMock.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>

// SPDX-License-Identifier: GPL-3.0

Expand Down
4 changes: 1 addition & 3 deletions contracts/0.8.9/test_helpers/StakingRouterMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

/* See contracts/COMPILERS.md */
Expand All @@ -17,4 +16,3 @@ contract StakingRouterMock is StakingRouter {
return _getStakingModuleIndexById(uint24(_stakingModuleId));
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

/* See contracts/COMPILERS.md */
Expand Down
3 changes: 1 addition & 2 deletions contracts/0.8.9/test_helpers/ValidatorExitBusMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.9;
Expand Down
3 changes: 1 addition & 2 deletions contracts/common/lib/Math256.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>

// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: MIT

// See contracts/COMPILERS.md
Expand Down
2 changes: 1 addition & 1 deletion contracts/common/lib/MinFirstAllocationStrategy.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-FileCopyrightText: 2023 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

/* See contracts/COMPILERS.md */
Expand Down
2 changes: 1 addition & 1 deletion lib/abi/Lido.json

Large diffs are not rendered by default.

Loading