Removed unnecessary sloads in MixinStakingPoolMakers
This commit is contained in:
parent
5a225795e1
commit
2869dd3bac
@ -130,6 +130,7 @@ contract MixinCumulativeRewards is
|
|||||||
/// @dev Returns info on most recent cumulative reward.
|
/// @dev Returns info on most recent cumulative reward.
|
||||||
function _getMostRecentCumulativeRewardInfo(bytes32 poolId)
|
function _getMostRecentCumulativeRewardInfo(bytes32 poolId)
|
||||||
internal
|
internal
|
||||||
|
view
|
||||||
returns (IStructs.CumulativeRewardInfo memory)
|
returns (IStructs.CumulativeRewardInfo memory)
|
||||||
{
|
{
|
||||||
// fetch the last epoch at which we stored a cumulative reward for this pool
|
// fetch the last epoch at which we stored a cumulative reward for this pool
|
||||||
|
@ -103,16 +103,6 @@ contract MixinStakingPool is
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Returns the unique id that will be assigned to the next pool that is created.
|
|
||||||
/// @return Pool id.
|
|
||||||
function getNextStakingPoolId()
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (bytes32)
|
|
||||||
{
|
|
||||||
return nextPoolId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Returns a staking pool
|
/// @dev Returns a staking pool
|
||||||
/// @param poolId Unique id of pool.
|
/// @param poolId Unique id of pool.
|
||||||
function getStakingPool(bytes32 poolId)
|
function getStakingPool(bytes32 poolId)
|
||||||
@ -162,6 +152,7 @@ contract MixinStakingPool is
|
|||||||
uint32 newOperatorShare
|
uint32 newOperatorShare
|
||||||
)
|
)
|
||||||
private
|
private
|
||||||
|
pure
|
||||||
{
|
{
|
||||||
// sanity checks
|
// sanity checks
|
||||||
if (newOperatorShare > PPM_DENOMINATOR) {
|
if (newOperatorShare > PPM_DENOMINATOR) {
|
||||||
|
@ -144,17 +144,6 @@ contract MixinStakingPoolMakers is
|
|||||||
return poolJoinedByMakerAddress[makerAddress].confirmed;
|
return poolJoinedByMakerAddress[makerAddress].confirmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Returns the current number of makers in a given pool.
|
|
||||||
/// @param poolId Unique id of pool.
|
|
||||||
/// @return Size of pool.
|
|
||||||
function getNumberOfMakersInStakingPool(bytes32 poolId)
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (uint256)
|
|
||||||
{
|
|
||||||
return poolById[poolId].numberOfMakers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Adds a maker to a staking pool. Note that this is only callable by the pool operator.
|
/// @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.
|
/// Note also that the maker must have previously called joinStakingPoolAsMaker.
|
||||||
/// @param poolId Unique id of pool.
|
/// @param poolId Unique id of pool.
|
||||||
@ -165,6 +154,9 @@ contract MixinStakingPoolMakers is
|
|||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
|
// cache pool for use throughout this function
|
||||||
|
IStructs.Pool memory pool = poolById[poolId];
|
||||||
|
|
||||||
// Is the maker already in a pool?
|
// Is the maker already in a pool?
|
||||||
if (isMakerAssignedToStakingPool(makerAddress)) {
|
if (isMakerAssignedToStakingPool(makerAddress)) {
|
||||||
LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError(
|
LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError(
|
||||||
@ -176,7 +168,7 @@ contract MixinStakingPoolMakers is
|
|||||||
|
|
||||||
// Is the maker trying to join this pool; or are they the operator?
|
// Is the maker trying to join this pool; or are they the operator?
|
||||||
bytes32 makerPendingPoolId = poolJoinedByMakerAddress[makerAddress].poolId;
|
bytes32 makerPendingPoolId = poolJoinedByMakerAddress[makerAddress].poolId;
|
||||||
if (makerPendingPoolId != poolId && makerAddress != poolById[poolId].operator) {
|
if (makerPendingPoolId != poolId && makerAddress != pool.operator) {
|
||||||
LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError(
|
LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError(
|
||||||
LibStakingRichErrors.MakerPoolAssignmentErrorCodes.MakerAddressNotPendingAdd,
|
LibStakingRichErrors.MakerPoolAssignmentErrorCodes.MakerAddressNotPendingAdd,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@ -185,7 +177,7 @@ contract MixinStakingPoolMakers is
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Is the pool already full?
|
// Is the pool already full?
|
||||||
if (getNumberOfMakersInStakingPool(poolId) == maximumMakersInPool) {
|
if (pool.numberOfMakers == maximumMakersInPool) {
|
||||||
LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError(
|
LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError(
|
||||||
LibStakingRichErrors.MakerPoolAssignmentErrorCodes.PoolIsFull,
|
LibStakingRichErrors.MakerPoolAssignmentErrorCodes.PoolIsFull,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@ -199,7 +191,7 @@ contract MixinStakingPoolMakers is
|
|||||||
confirmed: true
|
confirmed: true
|
||||||
});
|
});
|
||||||
poolJoinedByMakerAddress[makerAddress] = poolJoinStatus;
|
poolJoinedByMakerAddress[makerAddress] = poolJoinStatus;
|
||||||
poolById[poolId].numberOfMakers = uint256(poolById[poolId].numberOfMakers).safeAdd(1).downcastToUint32();
|
poolById[poolId].numberOfMakers = uint256(pool.numberOfMakers).safeAdd(1).downcastToUint32();
|
||||||
|
|
||||||
// Maker has been added to the pool
|
// Maker has been added to the pool
|
||||||
emit MakerAddedToStakingPool(
|
emit MakerAddedToStakingPool(
|
||||||
|
@ -44,10 +44,10 @@ contract MixinStakingPoolModifiers is
|
|||||||
/// @param poolId Pool sender must be operator of.
|
/// @param poolId Pool sender must be operator of.
|
||||||
/// @param makerAddress Address of a maker in the pool.
|
/// @param makerAddress Address of a maker in the pool.
|
||||||
modifier onlyStakingPoolOperatorOrMaker(bytes32 poolId, address makerAddress) {
|
modifier onlyStakingPoolOperatorOrMaker(bytes32 poolId, address makerAddress) {
|
||||||
address operator;
|
address operator = poolById[poolId].operator;
|
||||||
if (
|
if (
|
||||||
msg.sender != makerAddress &&
|
msg.sender != operator &&
|
||||||
msg.sender != (operator = poolById[poolId].operator)
|
msg.sender != makerAddress
|
||||||
) {
|
) {
|
||||||
LibRichErrors.rrevert(
|
LibRichErrors.rrevert(
|
||||||
LibStakingRichErrors.OnlyCallableByPoolOperatorOrMakerError(
|
LibStakingRichErrors.OnlyCallableByPoolOperatorOrMakerError(
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
||||||
"abis": "./generated-artifacts/@(EthVault|IEthVault|IStaking|IStakingEvents|IStakingPoolRewardVault|IStakingProxy|IStorage|IStorageInit|IStructs|IVaultCore|IZrxVault|LibFixedMath|LibFixedMathRichErrors|LibProxy|LibSafeDowncast|LibStakingRichErrors|MixinConstants|MixinCumulativeRewards|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinParams|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakeStorage|MixinStakingPool|MixinStakingPoolRewardVault|MixinStakingPoolRewards|MixinStorage|MixinVaultCore|ReadOnlyProxy|Staking|StakingPoolRewardVault|StakingProxy|TestCobbDouglas|TestCumulativeRewardTracking|TestInitTarget|TestLibFixedMath|TestLibProxy|TestLibProxyReceiver|TestLibSafeDowncast|TestProtocolFees|TestProtocolFeesERC20Proxy|TestStaking|TestStakingProxy|TestStorageLayout|ZrxVault).json"
|
"abis": "./generated-artifacts/@(EthVault|IEthVault|IStaking|IStakingEvents|IStakingPoolRewardVault|IStakingProxy|IStorage|IStorageInit|IStructs|IVaultCore|IZrxVault|LibFixedMath|LibFixedMathRichErrors|LibProxy|LibSafeDowncast|LibStakingRichErrors|MixinConstants|MixinCumulativeRewards|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinParams|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakeStorage|MixinStakingPool|MixinStakingPoolMakers|MixinStakingPoolModifiers|MixinStakingPoolRewards|MixinStorage|MixinVaultCore|ReadOnlyProxy|Staking|StakingPoolRewardVault|StakingProxy|TestCobbDouglas|TestCumulativeRewardTracking|TestInitTarget|TestLibFixedMath|TestLibProxy|TestLibProxyReceiver|TestLibSafeDowncast|TestProtocolFees|TestProtocolFeesERC20Proxy|TestStaking|TestStakingProxy|TestStorageLayout|ZrxVault).json"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user