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

fix: remove redundant code (OZ N-01) #1133

Open
wants to merge 1 commit into
base: horizon-oz2/l03-provision-grief
Choose a base branch
from
Open
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
33 changes: 7 additions & 26 deletions packages/horizon/contracts/staking/HorizonStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
address verifier,
uint256 shares
) external override notPaused returns (bytes32) {
return _undelegate(ThawRequestType.Delegation, serviceProvider, verifier, shares, msg.sender);
return _undelegate(serviceProvider, verifier, shares);
}

/// @inheritdoc IHorizonStakingMain
Expand All @@ -304,15 +304,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
address verifier,
uint256 nThawRequests
) external override notPaused {
_withdrawDelegated(
ThawRequestType.Delegation,
serviceProvider,
verifier,
address(0),
address(0),
0,
nThawRequests
);
_withdrawDelegated(serviceProvider, verifier, address(0), address(0), 0, nThawRequests);
}

/// @inheritdoc IHorizonStakingMain
Expand All @@ -327,7 +319,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
require(newServiceProvider != address(0), HorizonStakingInvalidServiceProviderZeroAddress());
require(newVerifier != address(0), HorizonStakingInvalidVerifierZeroAddress());
_withdrawDelegated(
ThawRequestType.Delegation,
oldServiceProvider,
oldVerifier,
newServiceProvider,
Expand Down Expand Up @@ -358,7 +349,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {

/// @inheritdoc IHorizonStakingMain
function undelegate(address serviceProvider, uint256 shares) external override notPaused {
_undelegate(ThawRequestType.Delegation, serviceProvider, SUBGRAPH_DATA_SERVICE_ADDRESS, shares, msg.sender);
_undelegate(serviceProvider, SUBGRAPH_DATA_SERVICE_ADDRESS, shares);
}

/// @inheritdoc IHorizonStakingMain
Expand Down Expand Up @@ -913,20 +904,12 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
* invalidated.
* @dev Note that delegation that is caught thawing when the pool is invalidated will be completely lost! However delegation shares
* that were not thawing will be preserved.
* @param _requestType The type of thaw request (Provision or Delegation).
* @param _serviceProvider The service provider address
* @param _verifier The verifier address
* @param _shares The amount of shares to undelegate
* @param _beneficiary The beneficiary address
* @return The ID of the thaw request
*/
function _undelegate(
ThawRequestType _requestType,
address _serviceProvider,
address _verifier,
uint256 _shares,
address _beneficiary
) private returns (bytes32) {
function _undelegate(address _serviceProvider, address _verifier, uint256 _shares) private returns (bytes32) {
require(_shares > 0, HorizonStakingInvalidZeroShares());
DelegationPoolInternal storage pool = _getDelegationPool(_serviceProvider, _verifier);
DelegationInternal storage delegation = pool.delegators[msg.sender];
Expand Down Expand Up @@ -958,10 +941,10 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
}

bytes32 thawRequestId = _createThawRequest(
_requestType,
ThawRequestType.Delegation,
_serviceProvider,
_verifier,
_beneficiary,
msg.sender,
thawingShares,
thawingUntil,
pool.thawingNonce
Expand All @@ -978,7 +961,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
* will attempt to fulfill all thaw requests until the first one that is not yet expired is found.
* @dev If the delegation pool was completely slashed before withdrawing, calling this function will fulfill
* the thaw requests with an amount equal to zero.
* @param _requestType The type of thaw request (Provision or Delegation).
* @param _serviceProvider The service provider address
* @param _verifier The verifier address
* @param _newServiceProvider The new service provider address
Expand All @@ -987,7 +969,6 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
* @param _nThawRequests The number of thaw requests to fulfill. Set to 0 to fulfill all thaw requests.
*/
function _withdrawDelegated(
ThawRequestType _requestType,
address _serviceProvider,
address _verifier,
address _newServiceProvider,
Expand All @@ -1008,7 +989,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
uint256 tokensThawing = pool.tokensThawing;

FulfillThawRequestsParams memory params = FulfillThawRequestsParams({
requestType: _requestType,
requestType: ThawRequestType.Delegation,
serviceProvider: _serviceProvider,
verifier: _verifier,
owner: msg.sender,
Expand Down