From 7f1afb57b05ba3fe49f8f7d4dbc4e751dcbdc43e Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Sun, 22 Sep 2019 17:29:42 -0700 Subject: [PATCH] Consolidate MixinStakingPool, MixinStakingPoolMakers, and MixinStakingPoolModifiers --- contracts/staking/contracts/src/Staking.sol | 2 - .../contracts/src/fees/MixinExchangeFees.sol | 4 +- .../src/libs/LibStakingRichErrors.sol | 29 +-- .../contracts/src/stake/MixinStake.sol | 2 - .../src/staking_pools/MixinStakingPool.sol | 207 +++++++++++++++++- .../staking_pools/MixinStakingPoolMakers.sol | 206 ----------------- .../MixinStakingPoolModifiers.sol | 65 ------ contracts/staking/package.json | 2 +- contracts/staking/src/artifacts.ts | 4 - contracts/staking/src/wrappers.ts | 2 - contracts/staking/test/pools_test.ts | 3 +- contracts/staking/tsconfig.json | 2 - .../order-utils/src/staking_revert_errors.ts | 17 +- 13 files changed, 213 insertions(+), 332 deletions(-) delete mode 100644 contracts/staking/contracts/src/staking_pools/MixinStakingPoolMakers.sol delete mode 100644 contracts/staking/contracts/src/staking_pools/MixinStakingPoolModifiers.sol diff --git a/contracts/staking/contracts/src/Staking.sol b/contracts/staking/contracts/src/Staking.sol index a4051400d1..e72f4624b1 100644 --- a/contracts/staking/contracts/src/Staking.sol +++ b/contracts/staking/contracts/src/Staking.sol @@ -34,12 +34,10 @@ contract Staking is MixinConstants, Ownable, MixinStorage, - MixinStakingPoolModifiers, MixinExchangeManager, MixinScheduler, MixinParams, MixinStakeStorage, - MixinStakingPoolMakers, MixinStakeBalances, MixinCumulativeRewards, MixinStakingPoolRewards, diff --git a/contracts/staking/contracts/src/fees/MixinExchangeFees.sol b/contracts/staking/contracts/src/fees/MixinExchangeFees.sol index 67f3306e37..c302e7599d 100644 --- a/contracts/staking/contracts/src/fees/MixinExchangeFees.sol +++ b/contracts/staking/contracts/src/fees/MixinExchangeFees.sol @@ -38,11 +38,9 @@ contract MixinExchangeFees is MixinConstants, Ownable, MixinStorage, - MixinStakingPoolModifiers, MixinExchangeManager, MixinScheduler, MixinStakeStorage, - MixinStakingPoolMakers, MixinStakeBalances, MixinCumulativeRewards, MixinStakingPoolRewards, @@ -167,7 +165,7 @@ contract MixinExchangeFees is returns (uint256 membersStake, uint256 weightedStake) { uint256 operatorStake = getStakeDelegatedToPoolByOwner( - _poolById[poolId].operator, + _getStakingPoolOperator(poolId), poolId ).currentEpochBalance; membersStake = totalStake.safeSub(operatorStake); diff --git a/contracts/staking/contracts/src/libs/LibStakingRichErrors.sol b/contracts/staking/contracts/src/libs/LibStakingRichErrors.sol index 5b6954b92e..4ab3412605 100644 --- a/contracts/staking/contracts/src/libs/LibStakingRichErrors.sol +++ b/contracts/staking/contracts/src/libs/LibStakingRichErrors.sol @@ -75,13 +75,9 @@ library LibStakingRichErrors { bytes4 internal constant INSUFFICIENT_BALANCE_ERROR_SELECTOR = 0x84c8b7c9; - // bytes4(keccak256("OnlyCallableByPoolOperatorError(address,address)")) - bytes4 internal constant ONLY_CALLABLE_BY_POOL_OPERATOR_ERROR_SELECTOR = - 0x6cfa0c22; - - // bytes4(keccak256("OnlyCallableByPoolOperatorOrMakerError(address,address,address)")) + // bytes4(keccak256("OnlyCallableByPoolOperatorOrMakerError(address,address)")) bytes4 internal constant ONLY_CALLABLE_BY_POOL_OPERATOR_OR_MAKER_ERROR_SELECTOR = - 0x7d9e1c10; + 0x471c3580; // bytes4(keccak256("MakerPoolAssignmentError(uint8,address,bytes32)")) bytes4 internal constant MAKER_POOL_ASSIGNMENT_ERROR_SELECTOR = @@ -217,35 +213,18 @@ library LibStakingRichErrors { ); } - function OnlyCallableByPoolOperatorError( + function OnlyCallableByPoolOperatorOrMakerError( address senderAddress, address operator ) internal pure returns (bytes memory) - { - return abi.encodeWithSelector( - ONLY_CALLABLE_BY_POOL_OPERATOR_ERROR_SELECTOR, - senderAddress, - operator - ); - } - - function OnlyCallableByPoolOperatorOrMakerError( - address senderAddress, - address operator, - address makerAddress - ) - internal - pure - returns (bytes memory) { return abi.encodeWithSelector( ONLY_CALLABLE_BY_POOL_OPERATOR_OR_MAKER_ERROR_SELECTOR, senderAddress, - operator, - makerAddress + operator ); } diff --git a/contracts/staking/contracts/src/stake/MixinStake.sol b/contracts/staking/contracts/src/stake/MixinStake.sol index 7e9d727510..0c50007155 100644 --- a/contracts/staking/contracts/src/stake/MixinStake.sol +++ b/contracts/staking/contracts/src/stake/MixinStake.sol @@ -32,10 +32,8 @@ contract MixinStake is MixinConstants, Ownable, MixinStorage, - MixinStakingPoolModifiers, MixinScheduler, MixinStakeStorage, - MixinStakingPoolMakers, MixinStakeBalances, MixinCumulativeRewards, MixinStakingPoolRewards, diff --git a/contracts/staking/contracts/src/staking_pools/MixinStakingPool.sol b/contracts/staking/contracts/src/staking_pools/MixinStakingPool.sol index df00a9f000..16fc1c8520 100644 --- a/contracts/staking/contracts/src/staking_pools/MixinStakingPool.sol +++ b/contracts/staking/contracts/src/staking_pools/MixinStakingPool.sol @@ -24,7 +24,6 @@ import "@0x/contracts-utils/contracts/src/LibSafeMath.sol"; import "../libs/LibStakingRichErrors.sol"; import "../interfaces/IStructs.sol"; import "./MixinStakingPoolRewards.sol"; -import "./MixinStakingPoolMakers.sol"; contract MixinStakingPool is @@ -33,15 +32,21 @@ contract MixinStakingPool is MixinConstants, Ownable, MixinStorage, - MixinStakingPoolModifiers, MixinScheduler, MixinStakeStorage, - MixinStakingPoolMakers, MixinStakeBalances, MixinCumulativeRewards, MixinStakingPoolRewards { using LibSafeMath for uint256; + using LibSafeDowncast for uint256; + + /// @dev Asserts that the sender is the operator of the input pool or the input maker. + /// @param poolId Pool sender must be operator of. + modifier onlyStakingPoolOperatorOrMaker(bytes32 poolId) { + _assertSenderIsPoolOperatorOrMaker(poolId); + _; + } /// @dev Create a new staking pool. The sender will be the operator of this pool. /// Note that an operator must be payable. @@ -94,6 +99,7 @@ contract MixinStakingPool is /// @param newOperatorShare The newly decreased percentage of any rewards owned by the operator. function decreaseStakingPoolOperatorShare(bytes32 poolId, uint32 newOperatorShare) external + onlyStakingPoolOperatorOrMaker(poolId) { // load pool and assert that we can decrease uint32 currentOperatorShare = _poolById[poolId].operatorShare; @@ -112,6 +118,110 @@ contract MixinStakingPool is ); } + /// @dev Allows caller to join a staking pool if already assigned. + /// @param poolId Unique id of pool. + function joinStakingPoolAsMaker(bytes32 poolId) + external + { + // Is the maker already in a pool? + address makerAddress = msg.sender; + if (isMakerAssignedToStakingPool(makerAddress)) { + LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError( + LibStakingRichErrors.MakerPoolAssignmentErrorCodes.MakerAddressAlreadyRegistered, + makerAddress, + getStakingPoolIdOfMaker(makerAddress) + )); + } + + IStructs.MakerPoolJoinStatus memory poolJoinStatus = IStructs.MakerPoolJoinStatus({ + poolId: poolId, + confirmed: false + }); + poolJoinedByMakerAddress[makerAddress] = poolJoinStatus; + + // Maker has joined to the pool, awaiting operator confirmation + emit PendingAddMakerToPool( + poolId, + makerAddress + ); + } + + /// @dev Adds a maker to a staking pool. Note that this is only callable by the pool operator. + /// Note also that the maker must have previously called joinStakingPoolAsMaker. + /// @param poolId Unique id of pool. + /// @param makerAddress Address of maker. + function addMakerToStakingPool( + bytes32 poolId, + address makerAddress + ) + external + onlyStakingPoolOperatorOrMaker(poolId) + { + _addMakerToStakingPool(poolId, makerAddress); + } + + /// @dev Removes a maker from a staking pool. Note that this is only callable by the pool operator or maker. + /// Note also that the maker does not have to *agree* to leave the pool; this action is + /// at the sole discretion of the pool operator. + /// @param poolId Unique id of pool. + /// @param makerAddress Address of maker. + function removeMakerFromStakingPool( + bytes32 poolId, + address makerAddress + ) + external + onlyStakingPoolOperatorOrMaker(poolId) + { + bytes32 makerPoolId = getStakingPoolIdOfMaker(makerAddress); + if (makerPoolId != poolId) { + LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError( + LibStakingRichErrors.MakerPoolAssignmentErrorCodes.MakerAddressNotRegistered, + makerAddress, + makerPoolId + )); + } + + // remove the pool and confirmation from the maker status + IStructs.MakerPoolJoinStatus memory poolJoinStatus = IStructs.MakerPoolJoinStatus({ + poolId: NIL_POOL_ID, + confirmed: false + }); + poolJoinedByMakerAddress[makerAddress] = poolJoinStatus; + _poolById[poolId].numberOfMakers = uint256(_poolById[poolId].numberOfMakers).safeSub(1).downcastToUint32(); + + // Maker has been removed from the pool` + emit MakerRemovedFromStakingPool( + poolId, + makerAddress + ); + } + + /// @dev Returns the pool id of the input maker. + /// @param makerAddress Address of maker + /// @return Pool id, nil if maker is not yet assigned to a pool. + function getStakingPoolIdOfMaker(address makerAddress) + public + view + returns (bytes32) + { + if (isMakerAssignedToStakingPool(makerAddress)) { + return poolJoinedByMakerAddress[makerAddress].poolId; + } else { + return NIL_POOL_ID; + } + } + + /// @dev Returns true iff the maker is assigned to a staking pool. + /// @param makerAddress Address of maker + /// @return True iff assigned. + function isMakerAssignedToStakingPool(address makerAddress) + public + view + returns (bool) + { + return poolJoinedByMakerAddress[makerAddress].confirmed; + } + /// @dev Returns a staking pool /// @param poolId Unique id of pool. function getStakingPool(bytes32 poolId) @@ -122,6 +232,75 @@ contract MixinStakingPool is return _poolById[poolId]; } + /// @dev Adds a maker to a staking pool. Note that this is only callable by the pool operator. + /// Note also that the maker must have previously called joinStakingPoolAsMaker. + /// @param poolId Unique id of pool. + /// @param makerAddress Address of maker. + function _addMakerToStakingPool( + bytes32 poolId, + address makerAddress + ) + internal + { + // cache pool for use throughout this function + IStructs.Pool memory pool = _poolById[poolId]; + + // Is the maker already in a pool? + if (isMakerAssignedToStakingPool(makerAddress)) { + LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError( + LibStakingRichErrors.MakerPoolAssignmentErrorCodes.MakerAddressAlreadyRegistered, + makerAddress, + getStakingPoolIdOfMaker(makerAddress) + )); + } + + // Is the maker trying to join this pool; or are they the operator? + bytes32 makerPendingPoolId = poolJoinedByMakerAddress[makerAddress].poolId; + if (makerPendingPoolId != poolId && makerAddress != pool.operator) { + LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError( + LibStakingRichErrors.MakerPoolAssignmentErrorCodes.MakerAddressNotPendingAdd, + makerAddress, + makerPendingPoolId + )); + } + + // Is the pool already full? + // NOTE: If maximumMakersInPool is decreased below the number of makers currently in a pool, + // the pool will no longer be able to add more makers. + if (pool.numberOfMakers >= maximumMakersInPool) { + LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError( + LibStakingRichErrors.MakerPoolAssignmentErrorCodes.PoolIsFull, + makerAddress, + poolId + )); + } + + // Add maker to pool + IStructs.MakerPoolJoinStatus memory poolJoinStatus = IStructs.MakerPoolJoinStatus({ + poolId: poolId, + confirmed: true + }); + poolJoinedByMakerAddress[makerAddress] = poolJoinStatus; + _poolById[poolId].numberOfMakers = uint256(pool.numberOfMakers).safeAdd(1).downcastToUint32(); + + // Maker has been added to the pool + emit MakerAddedToStakingPool( + poolId, + makerAddress + ); + } + + /// @dev return the staking pool operator + /// @param poolId Unique id of pool. + function _getStakingPoolOperator(bytes32 poolId) + internal + view + returns (address operator) + { + operator = _poolById[poolId].operator; + return operator; + } + /// @dev Computes the unique id that comes after the input pool id. /// @param poolId Unique id of pool. /// @return Next pool id after input pool. @@ -140,7 +319,7 @@ contract MixinStakingPool is view returns (bool) { - if (_poolById[poolId].operator == NIL_ADDRESS) { + if (_getStakingPoolOperator(poolId) == NIL_ADDRESS) { // we use the pool's operator as a proxy for its existence LibRichErrors.rrevert( LibStakingRichErrors.PoolExistenceError( @@ -180,4 +359,24 @@ contract MixinStakingPool is )); } } + + /// @dev Asserts that the sender is the operator of the input pool or the input maker. + /// @param poolId Pool sender must be operator of. + function _assertSenderIsPoolOperatorOrMaker(bytes32 poolId) + private + view + { + address operator = _getStakingPoolOperator(poolId); + if ( + msg.sender != operator && + getStakingPoolIdOfMaker(msg.sender) != poolId + ) { + LibRichErrors.rrevert( + LibStakingRichErrors.OnlyCallableByPoolOperatorOrMakerError( + msg.sender, + operator + ) + ); + } + } } diff --git a/contracts/staking/contracts/src/staking_pools/MixinStakingPoolMakers.sol b/contracts/staking/contracts/src/staking_pools/MixinStakingPoolMakers.sol deleted file mode 100644 index 287331c2c9..0000000000 --- a/contracts/staking/contracts/src/staking_pools/MixinStakingPoolMakers.sol +++ /dev/null @@ -1,206 +0,0 @@ -/* - - Copyright 2019 ZeroEx Intl. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ - -pragma solidity ^0.5.9; -pragma experimental ABIEncoderV2; - -import "@0x/contracts-utils/contracts/src/LibSafeMath.sol"; -import "../libs/LibStakingRichErrors.sol"; -import "../libs/LibSafeDowncast.sol"; -import "../interfaces/IStructs.sol"; -import "../interfaces/IStakingEvents.sol"; -import "../immutable/MixinStorage.sol"; -import "./MixinStakingPoolModifiers.sol"; - - -/// @dev This mixin contains logic for staking pools. -contract MixinStakingPoolMakers is - IStakingEvents, - MixinConstants, - Ownable, - MixinStorage, - MixinStakingPoolModifiers -{ - - using LibSafeMath for uint256; - using LibSafeDowncast for uint256; - - /// @dev Allows caller to join a staking pool if already assigned. - /// @param poolId Unique id of pool. - function joinStakingPoolAsMaker( - bytes32 poolId - ) - external - { - // Is the maker already in a pool? - address makerAddress = msg.sender; - if (isMakerAssignedToStakingPool(makerAddress)) { - LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError( - LibStakingRichErrors.MakerPoolAssignmentErrorCodes.MakerAddressAlreadyRegistered, - makerAddress, - getStakingPoolIdOfMaker(makerAddress) - )); - } - - IStructs.MakerPoolJoinStatus memory poolJoinStatus = IStructs.MakerPoolJoinStatus({ - poolId: poolId, - confirmed: false - }); - poolJoinedByMakerAddress[makerAddress] = poolJoinStatus; - - // Maker has joined to the pool, awaiting operator confirmation - emit PendingAddMakerToPool( - poolId, - makerAddress - ); - } - - /// @dev Adds a maker to a staking pool. Note that this is only callable by the pool operator. - /// Note also that the maker must have previously called joinStakingPoolAsMaker. - /// @param poolId Unique id of pool. - /// @param makerAddress Address of maker. - function addMakerToStakingPool( - bytes32 poolId, - address makerAddress - ) - external - onlyStakingPoolOperator(poolId) - { - _addMakerToStakingPool(poolId, makerAddress); - } - - /// @dev Removes a maker from a staking pool. Note that this is only callable by the pool operator or maker. - /// Note also that the maker does not have to *agree* to leave the pool; this action is - /// at the sole discretion of the pool operator. - /// @param poolId Unique id of pool. - /// @param makerAddress Address of maker. - function removeMakerFromStakingPool( - bytes32 poolId, - address makerAddress - ) - external - onlyStakingPoolOperatorOrMaker(poolId, makerAddress) - { - bytes32 makerPoolId = getStakingPoolIdOfMaker(makerAddress); - if (makerPoolId != poolId) { - LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError( - LibStakingRichErrors.MakerPoolAssignmentErrorCodes.MakerAddressNotRegistered, - makerAddress, - makerPoolId - )); - } - - // remove the pool and confirmation from the maker status - IStructs.MakerPoolJoinStatus memory poolJoinStatus = IStructs.MakerPoolJoinStatus({ - poolId: NIL_POOL_ID, - confirmed: false - }); - poolJoinedByMakerAddress[makerAddress] = poolJoinStatus; - _poolById[poolId].numberOfMakers = uint256(_poolById[poolId].numberOfMakers).safeSub(1).downcastToUint32(); - - // Maker has been removed from the pool` - emit MakerRemovedFromStakingPool( - poolId, - makerAddress - ); - } - - /// @dev Returns the pool id of the input maker. - /// @param makerAddress Address of maker - /// @return Pool id, nil if maker is not yet assigned to a pool. - function getStakingPoolIdOfMaker(address makerAddress) - public - view - returns (bytes32) - { - if (isMakerAssignedToStakingPool(makerAddress)) { - return poolJoinedByMakerAddress[makerAddress].poolId; - } else { - return NIL_POOL_ID; - } - } - - /// @dev Returns true iff the maker is assigned to a staking pool. - /// @param makerAddress Address of maker - /// @return True iff assigned. - function isMakerAssignedToStakingPool(address makerAddress) - public - view - returns (bool) - { - return poolJoinedByMakerAddress[makerAddress].confirmed; - } - - /// @dev Adds a maker to a staking pool. Note that this is only callable by the pool operator. - /// Note also that the maker must have previously called joinStakingPoolAsMaker. - /// @param poolId Unique id of pool. - /// @param makerAddress Address of maker. - function _addMakerToStakingPool( - bytes32 poolId, - address makerAddress - ) - internal - { - // cache pool for use throughout this function - IStructs.Pool memory pool = _poolById[poolId]; - - // Is the maker already in a pool? - if (isMakerAssignedToStakingPool(makerAddress)) { - LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError( - LibStakingRichErrors.MakerPoolAssignmentErrorCodes.MakerAddressAlreadyRegistered, - makerAddress, - getStakingPoolIdOfMaker(makerAddress) - )); - } - - // Is the maker trying to join this pool; or are they the operator? - bytes32 makerPendingPoolId = poolJoinedByMakerAddress[makerAddress].poolId; - if (makerPendingPoolId != poolId && makerAddress != pool.operator) { - LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError( - LibStakingRichErrors.MakerPoolAssignmentErrorCodes.MakerAddressNotPendingAdd, - makerAddress, - makerPendingPoolId - )); - } - - // Is the pool already full? - // NOTE: If maximumMakersInPool is decreased below the number of makers currently in a pool, - // the pool will no longer be able to add more makers. - if (pool.numberOfMakers >= maximumMakersInPool) { - LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError( - LibStakingRichErrors.MakerPoolAssignmentErrorCodes.PoolIsFull, - makerAddress, - poolId - )); - } - - // Add maker to pool - IStructs.MakerPoolJoinStatus memory poolJoinStatus = IStructs.MakerPoolJoinStatus({ - poolId: poolId, - confirmed: true - }); - poolJoinedByMakerAddress[makerAddress] = poolJoinStatus; - _poolById[poolId].numberOfMakers = uint256(pool.numberOfMakers).safeAdd(1).downcastToUint32(); - - // Maker has been added to the pool - emit MakerAddedToStakingPool( - poolId, - makerAddress - ); - } -} diff --git a/contracts/staking/contracts/src/staking_pools/MixinStakingPoolModifiers.sol b/contracts/staking/contracts/src/staking_pools/MixinStakingPoolModifiers.sol deleted file mode 100644 index 52ac7b1829..0000000000 --- a/contracts/staking/contracts/src/staking_pools/MixinStakingPoolModifiers.sol +++ /dev/null @@ -1,65 +0,0 @@ -/* - - Copyright 2019 ZeroEx Intl. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ - -pragma solidity ^0.5.9; -pragma experimental ABIEncoderV2; - -import "../immutable/MixinStorage.sol"; - - -contract MixinStakingPoolModifiers is - MixinConstants, - Ownable, - MixinStorage -{ - - /// @dev Asserts that the sender is the operator of the input pool. - /// @param poolId Pool sender must be operator of. - modifier onlyStakingPoolOperator(bytes32 poolId) { - address operator = _poolById[poolId].operator; - if (msg.sender != operator) { - LibRichErrors.rrevert(LibStakingRichErrors.OnlyCallableByPoolOperatorError( - msg.sender, - operator - )); - } - - _; - } - - /// @dev Asserts that the sender is the operator of the input pool or the input maker. - /// @param poolId Pool sender must be operator of. - /// @param makerAddress Address of a maker in the pool. - modifier onlyStakingPoolOperatorOrMaker(bytes32 poolId, address makerAddress) { - address operator = _poolById[poolId].operator; - if ( - msg.sender != operator && - msg.sender != makerAddress - ) { - LibRichErrors.rrevert( - LibStakingRichErrors.OnlyCallableByPoolOperatorOrMakerError( - msg.sender, - operator, - makerAddress - ) - ); - } - - _; - } -} diff --git a/contracts/staking/package.json b/contracts/staking/package.json index f68c4ac585..65dc340614 100644 --- a/contracts/staking/package.json +++ b/contracts/staking/package.json @@ -37,7 +37,7 @@ }, "config": { "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.", - "abis": "./generated-artifacts/@(IStaking|IStakingEvents|IStakingProxy|IStorage|IStorageInit|IStructs|IVaultCore|IZrxVault|LibCobbDouglas|LibFixedMath|LibFixedMathRichErrors|LibProxy|LibSafeDowncast|LibStakingRichErrors|MixinAbstract|MixinConstants|MixinCumulativeRewards|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinFinalizer|MixinParams|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakeStorage|MixinStakingPool|MixinStakingPoolMakers|MixinStakingPoolModifiers|MixinStakingPoolRewards|MixinStorage|MixinVaultCore|ReadOnlyProxy|Staking|StakingProxy|TestAssertStorageParams|TestCobbDouglas|TestCumulativeRewardTracking|TestDelegatorRewards|TestFinalizer|TestInitTarget|TestLibFixedMath|TestLibProxy|TestLibProxyReceiver|TestLibSafeDowncast|TestMixinVaultCore|TestProtocolFees|TestStaking|TestStakingNoWETH|TestStakingProxy|ZrxVault).json" + "abis": "./generated-artifacts/@(IStaking|IStakingEvents|IStakingProxy|IStorage|IStorageInit|IStructs|IVaultCore|IZrxVault|LibCobbDouglas|LibFixedMath|LibFixedMathRichErrors|LibProxy|LibSafeDowncast|LibStakingRichErrors|MixinAbstract|MixinConstants|MixinCumulativeRewards|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinFinalizer|MixinParams|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakeStorage|MixinStakingPool|MixinStakingPoolRewards|MixinStorage|MixinVaultCore|ReadOnlyProxy|Staking|StakingProxy|TestAssertStorageParams|TestCobbDouglas|TestCumulativeRewardTracking|TestDelegatorRewards|TestFinalizer|TestInitTarget|TestLibFixedMath|TestLibProxy|TestLibProxyReceiver|TestLibSafeDowncast|TestMixinVaultCore|TestProtocolFees|TestStaking|TestStakingNoWETH|TestStakingProxy|ZrxVault).json" }, "repository": { "type": "git", diff --git a/contracts/staking/src/artifacts.ts b/contracts/staking/src/artifacts.ts index 011e0f0468..268359a620 100644 --- a/contracts/staking/src/artifacts.ts +++ b/contracts/staking/src/artifacts.ts @@ -32,8 +32,6 @@ import * as MixinStake from '../generated-artifacts/MixinStake.json'; import * as MixinStakeBalances from '../generated-artifacts/MixinStakeBalances.json'; import * as MixinStakeStorage from '../generated-artifacts/MixinStakeStorage.json'; import * as MixinStakingPool from '../generated-artifacts/MixinStakingPool.json'; -import * as MixinStakingPoolMakers from '../generated-artifacts/MixinStakingPoolMakers.json'; -import * as MixinStakingPoolModifiers from '../generated-artifacts/MixinStakingPoolModifiers.json'; import * as MixinStakingPoolRewards from '../generated-artifacts/MixinStakingPoolRewards.json'; import * as MixinStorage from '../generated-artifacts/MixinStorage.json'; import * as MixinVaultCore from '../generated-artifacts/MixinVaultCore.json'; @@ -84,8 +82,6 @@ export const artifacts = { MixinStakeStorage: MixinStakeStorage as ContractArtifact, MixinCumulativeRewards: MixinCumulativeRewards as ContractArtifact, MixinStakingPool: MixinStakingPool as ContractArtifact, - MixinStakingPoolMakers: MixinStakingPoolMakers as ContractArtifact, - MixinStakingPoolModifiers: MixinStakingPoolModifiers as ContractArtifact, MixinStakingPoolRewards: MixinStakingPoolRewards as ContractArtifact, MixinAbstract: MixinAbstract as ContractArtifact, MixinFinalizer: MixinFinalizer as ContractArtifact, diff --git a/contracts/staking/src/wrappers.ts b/contracts/staking/src/wrappers.ts index 641e983bee..067ec7f9fc 100644 --- a/contracts/staking/src/wrappers.ts +++ b/contracts/staking/src/wrappers.ts @@ -30,8 +30,6 @@ export * from '../generated-wrappers/mixin_stake'; export * from '../generated-wrappers/mixin_stake_balances'; export * from '../generated-wrappers/mixin_stake_storage'; export * from '../generated-wrappers/mixin_staking_pool'; -export * from '../generated-wrappers/mixin_staking_pool_makers'; -export * from '../generated-wrappers/mixin_staking_pool_modifiers'; export * from '../generated-wrappers/mixin_staking_pool_rewards'; export * from '../generated-wrappers/mixin_storage'; export * from '../generated-wrappers/mixin_vault_core'; diff --git a/contracts/staking/test/pools_test.ts b/contracts/staking/test/pools_test.ts index 71f6e98163..5e2cafa62b 100644 --- a/contracts/staking/test/pools_test.ts +++ b/contracts/staking/test/pools_test.ts @@ -277,7 +277,7 @@ blockchainTests('Staking Pool Management', env => { expect(poolId).to.be.equal(stakingConstants.INITIAL_POOL_ID); // add maker to pool await maker.joinStakingPoolAsMakerAsync(poolId); - const revertError = new StakingRevertErrors.OnlyCallableByPoolOperatorError( + const revertError = new StakingRevertErrors.OnlyCallableByPoolOperatorOrMakerError( notOperatorAddress, operatorAddress, ); @@ -306,7 +306,6 @@ blockchainTests('Staking Pool Management', env => { const revertError = new StakingRevertErrors.OnlyCallableByPoolOperatorOrMakerError( neitherOperatorNorMakerAddress, operatorAddress, - makerAddress, ); const tx = stakingApiWrapper.stakingContract.removeMakerFromStakingPool.awaitTransactionSuccessAsync( poolId, diff --git a/contracts/staking/tsconfig.json b/contracts/staking/tsconfig.json index fab0abce47..e0349ba978 100644 --- a/contracts/staking/tsconfig.json +++ b/contracts/staking/tsconfig.json @@ -30,8 +30,6 @@ "generated-artifacts/MixinStakeBalances.json", "generated-artifacts/MixinStakeStorage.json", "generated-artifacts/MixinStakingPool.json", - "generated-artifacts/MixinStakingPoolMakers.json", - "generated-artifacts/MixinStakingPoolModifiers.json", "generated-artifacts/MixinStakingPoolRewards.json", "generated-artifacts/MixinStorage.json", "generated-artifacts/MixinVaultCore.json", diff --git a/packages/order-utils/src/staking_revert_errors.ts b/packages/order-utils/src/staking_revert_errors.ts index 698037a989..8588f175ec 100644 --- a/packages/order-utils/src/staking_revert_errors.ts +++ b/packages/order-utils/src/staking_revert_errors.ts @@ -77,22 +77,12 @@ export class InsufficientBalanceError extends RevertError { } } -export class OnlyCallableByPoolOperatorError extends RevertError { +export class OnlyCallableByPoolOperatorOrMakerError extends RevertError { constructor(senderAddress?: string, poolOperatorAddress?: string) { - super( - 'OnlyCallableByPoolOperatorError', - 'OnlyCallableByPoolOperatorError(address senderAddress, address poolOperatorAddress)', - { senderAddress, poolOperatorAddress }, - ); - } -} - -export class OnlyCallableByPoolOperatorOrMakerError extends RevertError { - constructor(senderAddress?: string, poolOperatorAddress?: string, makerAddress?: string) { super( 'OnlyCallableByPoolOperatorOrMakerError', - 'OnlyCallableByPoolOperatorOrMakerError(address senderAddress, address poolOperatorAddress, address makerAddress)', - { senderAddress, poolOperatorAddress, makerAddress }, + 'OnlyCallableByPoolOperatorOrMakerError(address senderAddress, address poolOperatorAddress)', + { senderAddress, poolOperatorAddress }, ); } } @@ -243,7 +233,6 @@ const types = [ MakerPoolAssignmentError, MiscalculatedRewardsError, OnlyCallableByExchangeError, - OnlyCallableByPoolOperatorError, OnlyCallableByPoolOperatorOrMakerError, OnlyCallableByStakingContractError, OnlyCallableIfInCatastrophicFailureError,