diff --git a/contracts/staking/contracts/src/fees/MixinExchangeFees.sol b/contracts/staking/contracts/src/fees/MixinExchangeFees.sol index 4bf3b229a9..5b8befac37 100644 --- a/contracts/staking/contracts/src/fees/MixinExchangeFees.sol +++ b/contracts/staking/contracts/src/fees/MixinExchangeFees.sol @@ -132,7 +132,7 @@ contract MixinExchangeFees is /// @dev Returns the total amount of fees collected thus far, in the current epoch. /// @return Amount of fees. function getTotalProtocolFeesThisEpoch() - public + external view returns (uint256) { @@ -140,17 +140,6 @@ contract MixinExchangeFees is return address(this).balance.safeAdd(wethBalance); } - /// @dev Returns the amount of fees attributed to the input pool. - /// @param poolId Pool Id to query. - /// @return Amount of fees. - function getProtocolFeesThisEpochByPool(bytes32 poolId) - public - view - returns (uint256) - { - return protocolFeesThisEpochByPool[poolId]; - } - /// @dev Withdraws the entire WETH balance of the contract. function _unwrapWETH() internal diff --git a/contracts/staking/contracts/src/fees/MixinExchangeManager.sol b/contracts/staking/contracts/src/fees/MixinExchangeManager.sol index 806d1b8c8b..8aef521db8 100644 --- a/contracts/staking/contracts/src/fees/MixinExchangeManager.sol +++ b/contracts/staking/contracts/src/fees/MixinExchangeManager.sol @@ -32,10 +32,9 @@ contract MixinExchangeManager is IStakingEvents, MixinStorage { - /// @dev Asserts that the call is coming from a valid exchange. modifier onlyExchange() { - if (!isValidExchangeAddress(msg.sender)) { + if (!validExchanges[msg.sender]) { LibRichErrors.rrevert(LibStakingRichErrors.OnlyCallableByExchangeError( msg.sender )); @@ -72,15 +71,4 @@ contract MixinExchangeManager is validExchanges[addr] = false; emit ExchangeRemoved(addr); } - - /// @dev Returns true iff the address is a valid exchange. - /// @param addr Address of exchange contract. - /// @return True iff input address is a valid exchange. - function isValidExchangeAddress(address addr) - public - view - returns (bool) - { - return validExchanges[addr]; - } } diff --git a/contracts/staking/contracts/src/immutable/MixinStorage.sol b/contracts/staking/contracts/src/immutable/MixinStorage.sol index ff0b07d68c..85d5f64182 100644 --- a/contracts/staking/contracts/src/immutable/MixinStorage.sol +++ b/contracts/staking/contracts/src/immutable/MixinStorage.sol @@ -17,6 +17,7 @@ */ pragma solidity ^0.5.9; +pragma experimental ABIEncoderV2; import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetProxy.sol"; import "@0x/contracts-utils/contracts/src/LibRichErrors.sol"; @@ -34,100 +35,99 @@ contract MixinStorage is MixinConstants, Ownable { - // WETH Asset Proxy - IAssetProxy internal wethAssetProxy; + IAssetProxy public wethAssetProxy; // address of staking contract - address internal stakingContract; + address public stakingContract; // address of read-only proxy - address internal readOnlyProxy; + address public readOnlyProxy; // address for read-only proxy to call - address internal readOnlyProxyCallee; + address public readOnlyProxyCallee; // mapping from Owner to Amount of Active Stake // (access using _loadAndSyncBalance or _loadUnsyncedBalance) - mapping (address => IStructs.StoredBalance) internal activeStakeByOwner; + mapping (address => IStructs.StoredBalance) internal _activeStakeByOwner; // mapping from Owner to Amount of Inactive Stake // (access using _loadAndSyncBalance or _loadUnsyncedBalance) - mapping (address => IStructs.StoredBalance) internal inactiveStakeByOwner; + mapping (address => IStructs.StoredBalance) internal _inactiveStakeByOwner; // mapping from Owner to Amount Delegated // (access using _loadAndSyncBalance or _loadUnsyncedBalance) - mapping (address => IStructs.StoredBalance) internal delegatedStakeByOwner; + mapping (address => IStructs.StoredBalance) internal _delegatedStakeByOwner; // mapping from Owner to Pool Id to Amount Delegated // (access using _loadAndSyncBalance or _loadUnsyncedBalance) - mapping (address => mapping (bytes32 => IStructs.StoredBalance)) internal delegatedStakeToPoolByOwner; + mapping (address => mapping (bytes32 => IStructs.StoredBalance)) internal _delegatedStakeToPoolByOwner; // mapping from Pool Id to Amount Delegated // (access using _loadAndSyncBalance or _loadUnsyncedBalance) - mapping (bytes32 => IStructs.StoredBalance) internal delegatedStakeByPoolId; + mapping (bytes32 => IStructs.StoredBalance) internal _delegatedStakeByPoolId; // mapping from Owner to Amount of Withdrawable Stake - mapping (address => uint256) internal withdrawableStakeByOwner; + mapping (address => uint256) internal _withdrawableStakeByOwner; // tracking Pool Id - bytes32 internal nextPoolId = INITIAL_POOL_ID; + bytes32 public nextPoolId = INITIAL_POOL_ID; // mapping from Maker Address to a struct representing the pool the maker has joined and // whether the operator of that pool has subsequently added the maker. - mapping (address => IStructs.MakerPoolJoinStatus) internal poolJoinedByMakerAddress; + mapping (address => IStructs.MakerPoolJoinStatus) public poolJoinedByMakerAddress; // mapping from Pool Id to number of makers assigned to that pool - mapping (bytes32 => uint256) internal numMakersByPoolId; + mapping (bytes32 => uint256) public numMakersByPoolId; // current epoch - uint256 internal currentEpoch = INITIAL_EPOCH; + uint256 public currentEpoch = INITIAL_EPOCH; // current epoch start time - uint256 internal currentEpochStartTimeInSeconds; + uint256 public currentEpochStartTimeInSeconds; // fees collected this epoch - mapping (bytes32 => uint256) internal protocolFeesThisEpochByPool; + mapping (bytes32 => uint256) public protocolFeesThisEpochByPool; // pools that were active in the current epoch - bytes32[] internal activePoolsThisEpoch; + bytes32[] public activePoolsThisEpoch; // mapping from Pool Id to Epoch to Reward Ratio - mapping (bytes32 => mapping (uint256 => IStructs.Fraction)) internal cumulativeRewardsByPool; + mapping (bytes32 => mapping (uint256 => IStructs.Fraction)) internal _cumulativeRewardsByPool; // mapping from Pool Id to Epoch to Cumulative Rewards Reference Counter - mapping (bytes32 => mapping (uint256 => uint256)) internal cumulativeRewardsByPoolReferenceCounter; + mapping (bytes32 => mapping (uint256 => uint256)) internal _cumulativeRewardsByPoolReferenceCounter; // mapping from Pool Id to Epoch - mapping (bytes32 => uint256) internal cumulativeRewardsByPoolLastStored; + mapping (bytes32 => uint256) internal _cumulativeRewardsByPoolLastStored; // registered 0x Exchange contracts - mapping (address => bool) internal validExchanges; + mapping (address => bool) public validExchanges; // ZRX vault (stores staked ZRX) - IZrxVault internal zrxVault; + IZrxVault public zrxVault; // ETH Vault (stores eth balances of stakers and pool operators) - IEthVault internal ethVault; + IEthVault public ethVault; // Rebate Vault (stores rewards for pools before they are moved to the eth vault on a per-user basis) - IStakingPoolRewardVault internal rewardVault; + IStakingPoolRewardVault public rewardVault; // Minimum seconds between epochs. - uint256 internal epochDurationInSeconds; + uint256 public epochDurationInSeconds; // How much delegated stake is weighted vs operator stake, in ppm. - uint32 internal rewardDelegatedStakeWeight; + uint32 public rewardDelegatedStakeWeight; // Minimum amount of stake required in a pool to collect rewards. - uint256 internal minimumPoolStake; + uint256 public minimumPoolStake; // Maximum number of maker addresses allowed to be registered to a pool. - uint256 internal maximumMakersInPool; + uint256 public maximumMakersInPool; // Numerator for cobb douglas alpha factor. - uint32 internal cobbDouglasAlphaNumerator; + uint32 public cobbDouglasAlphaNumerator; // Denominator for cobb douglas alpha factor. - uint32 internal cobbDouglasAlphaDenomintor; + uint32 public cobbDouglasAlphaDenomintor; } diff --git a/contracts/staking/contracts/src/interfaces/IEthVault.sol b/contracts/staking/contracts/src/interfaces/IEthVault.sol index 8867557b65..e8a239911a 100644 --- a/contracts/staking/contracts/src/interfaces/IEthVault.sol +++ b/contracts/staking/contracts/src/interfaces/IEthVault.sol @@ -42,6 +42,14 @@ interface IEthVault { uint256 amount ); + /// @dev Gets the owner's ZRX balance in the vault. + /// @param owner Address of ZRX owner. + /// @return ZRX balance of owner in vault. + function balances(address owner) + external + view + returns (uint256); + /// @dev Deposit an `amount` of ETH from `owner` into the vault. /// Note that only the Staking contract can call this. /// Note that this can only be called when *not* in Catostrophic Failure mode. @@ -61,11 +69,4 @@ interface IEthVault { function withdrawAll() external returns (uint256); - - /// @dev Returns the balance in ETH of the `owner` - /// @return Balance in ETH. - function balanceOf(address owner) - external - view - returns (uint256); } diff --git a/contracts/staking/contracts/src/interfaces/IStakingPoolRewardVault.sol b/contracts/staking/contracts/src/interfaces/IStakingPoolRewardVault.sol index 3e14983c48..fba78e8ecb 100644 --- a/contracts/staking/contracts/src/interfaces/IStakingPoolRewardVault.sol +++ b/contracts/staking/contracts/src/interfaces/IStakingPoolRewardVault.sol @@ -17,6 +17,7 @@ */ pragma solidity ^0.5.9; +pragma experimental ABIEncoderV2; /// @dev This vault manages staking pool rewards. @@ -99,6 +100,14 @@ interface IStakingPoolRewardVault { external payable; + /// @dev Gets the pool information that corresponds to a poolId. + /// @param poolId Unique Id of pool. + /// @return Pool information. + function poolById(bytes32 poolId) + external + view + returns (Pool memory); + function setEthVault(address ethVaultAddress) external; @@ -173,36 +182,4 @@ interface IStakingPoolRewardVault { external view returns (address payable); - - /// @dev Returns the total balance of a pool. - /// @param poolId Unique Id of pool. - /// @return Balance in ETH. - function balanceOf(bytes32 poolId) - external - view - returns (uint256); - - /// @dev Returns the balance of a pool operator. - /// @param poolId Unique Id of pool. - /// @return Balance in ETH. - function balanceOfOperator(bytes32 poolId) - external - view - returns (uint256); - - /// @dev Returns the balance co-owned by members of a pool. - /// @param poolId Unique Id of pool. - /// @return Balance in ETH. - function balanceOfMembers(bytes32 poolId) - external - view - returns (uint256); - - /// @dev Returns the operator share of a pool's balance. - /// @param poolId Unique Id of pool. - /// @return Operator share (integer out of 100) - function getOperatorShare(bytes32 poolId) - external - view - returns (uint256); } diff --git a/contracts/staking/contracts/src/interfaces/IZrxVault.sol b/contracts/staking/contracts/src/interfaces/IZrxVault.sol index 62aeaf34dd..7221d504b5 100644 --- a/contracts/staking/contracts/src/interfaces/IZrxVault.sol +++ b/contracts/staking/contracts/src/interfaces/IZrxVault.sol @@ -54,6 +54,21 @@ interface IZrxVault { address zrxProxyAddress ); + /// @dev Gets the address of the AssetProxy contract used to transfer ZRX. + /// @return Address of the AssetProxy contract used to transfer ZRX. + function zrxAssetProxy() + external + view + returns (address); + + /// @dev Gets the owner's ZRX balance in the vault. + /// @param owner Address of ZRX owner. + /// @return ZRX balance of owner in vault. + function balances(address owner) + external + view + returns (uint256); + /// @dev Sets the Zrx proxy. /// Note that only the contract owner can call this. /// Note that this can only be called when *not* in Catastrophic Failure mode. @@ -83,11 +98,4 @@ interface IZrxVault { function withdrawAllFrom(address owner) external returns (uint256); - - /// @dev Returns the balance in Zrx Tokens of the `owner` - /// @return Balance in Zrx. - function balanceOf(address owner) - external - view - returns (uint256); } diff --git a/contracts/staking/contracts/src/stake/MixinStake.sol b/contracts/staking/contracts/src/stake/MixinStake.sol index b50beeabd4..7920cbf2d2 100644 --- a/contracts/staking/contracts/src/stake/MixinStake.sol +++ b/contracts/staking/contracts/src/stake/MixinStake.sol @@ -42,7 +42,7 @@ contract MixinStake is _depositFromOwnerIntoZrxVault(owner, amount); // mint stake - _incrementCurrentAndNextBalance(activeStakeByOwner[owner], amount); + _incrementCurrentAndNextBalance(_activeStakeByOwner[owner], amount); // notify emit Stake( @@ -71,10 +71,10 @@ contract MixinStake is } // burn inactive stake - _decrementCurrentAndNextBalance(inactiveStakeByOwner[owner], amount); + _decrementCurrentAndNextBalance(_inactiveStakeByOwner[owner], amount); // update withdrawable field - withdrawableStakeByOwner[owner] = currentWithdrawableStake.safeSub(amount); + _withdrawableStakeByOwner[owner] = currentWithdrawableStake.safeSub(amount); // withdraw equivalent amount of ZRX from vault _withdrawToOwnerFromZrxVault(owner, amount); @@ -137,7 +137,7 @@ contract MixinStake is // update withdrawable field, if necessary if (from.status == IStructs.StakeStatus.INACTIVE) { - withdrawableStakeByOwner[owner] = _computeWithdrawableStake(owner, withdrawableStake); + _withdrawableStakeByOwner[owner] = _computeWithdrawableStake(owner, withdrawableStake); } // notify @@ -163,16 +163,16 @@ contract MixinStake is private { // cache amount delegated to pool by owner - IStructs.StoredBalance memory initDelegatedStakeToPoolByOwner = _loadUnsyncedBalance(delegatedStakeToPoolByOwner[owner][poolId]); + IStructs.StoredBalance memory initDelegatedStakeToPoolByOwner = _loadUnsyncedBalance(_delegatedStakeToPoolByOwner[owner][poolId]); // increment how much stake the owner has delegated to the input pool - _incrementNextBalance(delegatedStakeToPoolByOwner[owner][poolId], amount); + _incrementNextBalance(_delegatedStakeToPoolByOwner[owner][poolId], amount); // increment how much stake has been delegated to pool - _incrementNextBalance(delegatedStakeByPoolId[poolId], amount); + _incrementNextBalance(_delegatedStakeByPoolId[poolId], amount); // synchronizes reward state in the pool that the staker is delegating to - IStructs.StoredBalance memory finalDelegatedStakeToPoolByOwner = _loadAndSyncBalance(delegatedStakeToPoolByOwner[owner][poolId]); + IStructs.StoredBalance memory finalDelegatedStakeToPoolByOwner = _loadAndSyncBalance(_delegatedStakeToPoolByOwner[owner][poolId]); _syncRewardsForDelegator(poolId, owner, initDelegatedStakeToPoolByOwner, finalDelegatedStakeToPoolByOwner); } @@ -188,16 +188,16 @@ contract MixinStake is private { // cache amount delegated to pool by owner - IStructs.StoredBalance memory initDelegatedStakeToPoolByOwner = _loadUnsyncedBalance(delegatedStakeToPoolByOwner[owner][poolId]); + IStructs.StoredBalance memory initDelegatedStakeToPoolByOwner = _loadUnsyncedBalance(_delegatedStakeToPoolByOwner[owner][poolId]); // decrement how much stake the owner has delegated to the input pool - _decrementNextBalance(delegatedStakeToPoolByOwner[owner][poolId], amount); + _decrementNextBalance(_delegatedStakeToPoolByOwner[owner][poolId], amount); // decrement how much stake has been delegated to pool - _decrementNextBalance(delegatedStakeByPoolId[poolId], amount); + _decrementNextBalance(_delegatedStakeByPoolId[poolId], amount); // synchronizes reward state in the pool that the staker is undelegating from - IStructs.StoredBalance memory finalDelegatedStakeToPoolByOwner = _loadAndSyncBalance(delegatedStakeToPoolByOwner[owner][poolId]); + IStructs.StoredBalance memory finalDelegatedStakeToPoolByOwner = _loadAndSyncBalance(_delegatedStakeToPoolByOwner[owner][poolId]); _syncRewardsForDelegator(poolId, owner, initDelegatedStakeToPoolByOwner, finalDelegatedStakeToPoolByOwner); } @@ -212,11 +212,11 @@ contract MixinStake is { // lookup status if (status == IStructs.StakeStatus.ACTIVE) { - return activeStakeByOwner[owner]; + return _activeStakeByOwner[owner]; } else if (status == IStructs.StakeStatus.INACTIVE) { - return inactiveStakeByOwner[owner]; + return _inactiveStakeByOwner[owner]; } else if (status == IStructs.StakeStatus.DELEGATED) { - return delegatedStakeByOwner[owner]; + return _delegatedStakeByOwner[owner]; } // invalid status diff --git a/contracts/staking/contracts/src/stake/MixinStakeBalances.sol b/contracts/staking/contracts/src/stake/MixinStakeBalances.sol index 8e84caf7e4..e896bfd7ba 100644 --- a/contracts/staking/contracts/src/stake/MixinStakeBalances.sol +++ b/contracts/staking/contracts/src/stake/MixinStakeBalances.sol @@ -52,7 +52,7 @@ contract MixinStakeBalances is view returns (IStructs.StakeBalance memory balance) { - IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(activeStakeByOwner[owner]); + IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(_activeStakeByOwner[owner]); return IStructs.StakeBalance({ currentEpochBalance: storedBalance.currentEpochBalance, nextEpochBalance: storedBalance.nextEpochBalance @@ -67,7 +67,7 @@ contract MixinStakeBalances is view returns (IStructs.StakeBalance memory balance) { - IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(inactiveStakeByOwner[owner]); + IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(_inactiveStakeByOwner[owner]); return IStructs.StakeBalance({ currentEpochBalance: storedBalance.currentEpochBalance, nextEpochBalance: storedBalance.nextEpochBalance @@ -82,7 +82,7 @@ contract MixinStakeBalances is view returns (uint256) { - return _computeWithdrawableStake(owner, withdrawableStakeByOwner[owner]); + return _computeWithdrawableStake(owner, _withdrawableStakeByOwner[owner]); } /// @dev Returns the stake delegated by a given owner. @@ -93,7 +93,7 @@ contract MixinStakeBalances is view returns (IStructs.StakeBalance memory balance) { - IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(delegatedStakeByOwner[owner]); + IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(_delegatedStakeByOwner[owner]); return IStructs.StakeBalance({ currentEpochBalance: storedBalance.currentEpochBalance, nextEpochBalance: storedBalance.nextEpochBalance @@ -109,7 +109,7 @@ contract MixinStakeBalances is view returns (IStructs.StakeBalance memory balance) { - IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(delegatedStakeToPoolByOwner[owner][poolId]); + IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(_delegatedStakeToPoolByOwner[owner][poolId]); return IStructs.StakeBalance({ currentEpochBalance: storedBalance.currentEpochBalance, nextEpochBalance: storedBalance.nextEpochBalance @@ -124,7 +124,7 @@ contract MixinStakeBalances is view returns (IStructs.StakeBalance memory balance) { - IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(delegatedStakeByPoolId[poolId]); + IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(_delegatedStakeByPoolId[poolId]); return IStructs.StakeBalance({ currentEpochBalance: storedBalance.currentEpochBalance, nextEpochBalance: storedBalance.nextEpochBalance @@ -142,7 +142,7 @@ contract MixinStakeBalances is { // stake cannot be withdrawn if it has been reallocated for the `next` epoch; // so the upper bound of withdrawable stake is always limited by the value of `next`. - IStructs.StoredBalance memory storedBalance = _loadUnsyncedBalance(inactiveStakeByOwner[owner]); + IStructs.StoredBalance memory storedBalance = _loadUnsyncedBalance(_inactiveStakeByOwner[owner]); if (storedBalance.currentEpoch == currentEpoch) { return LibSafeMath.min256(storedBalance.nextEpochBalance, lastStoredWithdrawableStake); } else if (uint256(storedBalance.currentEpoch).safeAdd(1) == currentEpoch) { diff --git a/contracts/staking/contracts/src/stake/MixinStakeStorage.sol b/contracts/staking/contracts/src/stake/MixinStakeStorage.sol index 2e5895d1ca..729bd572e9 100644 --- a/contracts/staking/contracts/src/stake/MixinStakeStorage.sol +++ b/contracts/staking/contracts/src/stake/MixinStakeStorage.sol @@ -85,9 +85,9 @@ contract MixinStakeStorage is // load from storage balance = balancePtr; // sync - uint256 currentEpoch = getCurrentEpoch(); + uint256 currentEpoch_ = currentEpoch; if (currentEpoch > balance.currentEpoch) { - balance.currentEpoch = currentEpoch.downcastToUint32(); + balance.currentEpoch = currentEpoch_.downcastToUint32(); balance.currentEpochBalance = balance.nextEpochBalance; } return balance; diff --git a/contracts/staking/contracts/src/stake/MixinZrxVault.sol b/contracts/staking/contracts/src/stake/MixinZrxVault.sol index b9c5746069..05acc9600e 100644 --- a/contracts/staking/contracts/src/stake/MixinZrxVault.sol +++ b/contracts/staking/contracts/src/stake/MixinZrxVault.sol @@ -37,16 +37,6 @@ contract MixinZrxVault is zrxVault = IZrxVault(zrxVaultAddress); } - /// @dev Return the current Zrx Vault - /// @return Zrx Vault - function getZrxVault() - public - view - returns (address) - { - return address(zrxVault); - } - /// @dev Deposits Zrx Tokens from the `owner` into the vault. /// @param owner of Zrx Tokens /// @param amount of tokens to deposit. @@ -87,6 +77,6 @@ contract MixinZrxVault is address(_zrxVault) != address(0), "INVALID_ZRX_VAULT" ); - return _zrxVault.balanceOf(owner); + return _zrxVault.balances(owner); } } diff --git a/contracts/staking/contracts/src/staking_pools/MixinCumulativeRewards.sol b/contracts/staking/contracts/src/staking_pools/MixinCumulativeRewards.sol index 8e19176efc..12b38f0f26 100644 --- a/contracts/staking/contracts/src/staking_pools/MixinCumulativeRewards.sol +++ b/contracts/staking/contracts/src/staking_pools/MixinCumulativeRewards.sol @@ -21,21 +21,12 @@ pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/LibFractions.sol"; import "@0x/contracts-utils/contracts/src/LibSafeMath.sol"; -import "../immutable/MixinStorage.sol"; -import "../immutable/MixinConstants.sol"; import "../stake/MixinStakeBalances.sol"; import "./MixinStakingPoolRewardVault.sol"; contract MixinCumulativeRewards is - IStakingEvents, - MixinConstants, - Ownable, - MixinStorage, - MixinZrxVault, MixinStakingPoolRewardVault, - MixinScheduler, - MixinStakeStorage, MixinStakeBalances { using LibSafeMath for uint256; @@ -45,7 +36,6 @@ contract MixinCumulativeRewards is function _initializeCumulativeRewards(bytes32 poolId) internal { - uint256 currentEpoch = getCurrentEpoch(); // sets the default cumulative reward _forceSetCumulativeReward( poolId, @@ -78,9 +68,9 @@ contract MixinCumulativeRewards is returns (bool) { return ( - _isCumulativeRewardSet(cumulativeRewardsByPool[poolId][epoch]) && // is there a value to unset - cumulativeRewardsByPoolReferenceCounter[poolId][epoch] == 0 && // no references to this CR - cumulativeRewardsByPoolLastStored[poolId] > epoch // this is *not* the most recent CR + _isCumulativeRewardSet(_cumulativeRewardsByPool[poolId][epoch]) && // is there a value to unset + _cumulativeRewardsByPoolReferenceCounter[poolId][epoch] == 0 && // no references to this CR + _cumulativeRewardsByPoolLastStored[poolId] > epoch // this is *not* the most recent CR ); } @@ -95,7 +85,7 @@ contract MixinCumulativeRewards is ) internal { - if (_isCumulativeRewardSet(cumulativeRewardsByPool[poolId][epoch])) { + if (_isCumulativeRewardSet(_cumulativeRewardsByPool[poolId][epoch])) { // do nothing; we don't want to override the current value return; } @@ -114,7 +104,7 @@ contract MixinCumulativeRewards is ) internal { - cumulativeRewardsByPool[poolId][epoch] = value; + _cumulativeRewardsByPool[poolId][epoch] = value; _trySetMostRecentCumulativeRewardEpoch(poolId, epoch); } @@ -136,7 +126,7 @@ contract MixinCumulativeRewards is function _forceUnsetCumulativeReward(bytes32 poolId, uint256 epoch) internal { - cumulativeRewardsByPool[poolId][epoch] = IStructs.Fraction({numerator: 0, denominator: 0}); + _cumulativeRewardsByPool[poolId][epoch] = IStructs.Fraction({numerator: 0, denominator: 0}); } /// @dev Returns info on most recent cumulative reward. @@ -145,11 +135,11 @@ contract MixinCumulativeRewards is returns (IStructs.CumulativeRewardInfo memory) { // fetch the last epoch at which we stored a cumulative reward for this pool - uint256 cumulativeRewardsLastStored = cumulativeRewardsByPoolLastStored[poolId]; + uint256 cumulativeRewardsLastStored = _cumulativeRewardsByPoolLastStored[poolId]; // query and return cumulative reward info for this pool return IStructs.CumulativeRewardInfo({ - cumulativeReward: cumulativeRewardsByPool[poolId][cumulativeRewardsLastStored], + cumulativeReward: _cumulativeRewardsByPool[poolId][cumulativeRewardsLastStored], cumulativeRewardEpoch: cumulativeRewardsLastStored }); } @@ -163,7 +153,7 @@ contract MixinCumulativeRewards is internal { // check if we should do any work - uint256 currentMostRecentEpoch = cumulativeRewardsByPoolLastStored[poolId]; + uint256 currentMostRecentEpoch = _cumulativeRewardsByPoolLastStored[poolId]; if (epoch == currentMostRecentEpoch) { return; } @@ -189,7 +179,7 @@ contract MixinCumulativeRewards is { // sanity check that we're not trying to go back in time assert(newMostRecentEpoch >= currentMostRecentEpoch); - cumulativeRewardsByPoolLastStored[poolId] = newMostRecentEpoch; + _cumulativeRewardsByPoolLastStored[poolId] = newMostRecentEpoch; // unset the previous most recent reward, if it is no longer needed _tryUnsetCumulativeReward(poolId, currentMostRecentEpoch); @@ -234,7 +224,7 @@ contract MixinCumulativeRewards is internal { // add dependency by increasing the reference counter - cumulativeRewardsByPoolReferenceCounter[poolId][epoch] = cumulativeRewardsByPoolReferenceCounter[poolId][epoch].safeAdd(1); + _cumulativeRewardsByPoolReferenceCounter[poolId][epoch] = _cumulativeRewardsByPoolReferenceCounter[poolId][epoch].safeAdd(1); // set CR to most recent reward (if it is not already set) _trySetCumulativeReward( @@ -254,8 +244,8 @@ contract MixinCumulativeRewards is internal { // remove dependency by decreasing reference counter - uint256 newReferenceCounter = cumulativeRewardsByPoolReferenceCounter[poolId][epoch].safeSub(1); - cumulativeRewardsByPoolReferenceCounter[poolId][epoch] = newReferenceCounter; + uint256 newReferenceCounter = _cumulativeRewardsByPoolReferenceCounter[poolId][epoch].safeSub(1); + _cumulativeRewardsByPoolReferenceCounter[poolId][epoch] = newReferenceCounter; // clear cumulative reward from state, if it is no longer needed _tryUnsetCumulativeReward(poolId, epoch); @@ -295,7 +285,7 @@ contract MixinCumulativeRewards is } // sanity check begin reward - IStructs.Fraction memory beginReward = cumulativeRewardsByPool[poolId][beginEpoch]; + IStructs.Fraction memory beginReward = _cumulativeRewardsByPool[poolId][beginEpoch]; if (!_isCumulativeRewardSet(beginReward)) { LibRichErrors.rrevert( LibStakingRichErrors.CumulativeRewardIntervalError( @@ -308,7 +298,7 @@ contract MixinCumulativeRewards is } // sanity check end reward - IStructs.Fraction memory endReward = cumulativeRewardsByPool[poolId][endEpoch]; + IStructs.Fraction memory endReward = _cumulativeRewardsByPool[poolId][endEpoch]; if (!_isCumulativeRewardSet(endReward)) { LibRichErrors.rrevert( LibStakingRichErrors.CumulativeRewardIntervalError( diff --git a/contracts/staking/contracts/src/staking_pools/MixinEthVault.sol b/contracts/staking/contracts/src/staking_pools/MixinEthVault.sol deleted file mode 100644 index e342597802..0000000000 --- a/contracts/staking/contracts/src/staking_pools/MixinEthVault.sol +++ /dev/null @@ -1,48 +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; - -import "../immutable/MixinStorage.sol"; - - -/// @dev This mixin contains logic for managing and interfacing with the Eth Vault. -/// (see vaults/EthVault.sol). -contract MixinEthVault is - MixinStorage -{ - - /// @dev Set the Eth Vault. - /// @param ethVaultAddress Address of the Eth Vault. - function setEthVault(address ethVaultAddress) - external - onlyOwner - { - ethVault = IEthVault(ethVaultAddress); - } - - /// @dev Return the current Eth Vault - /// @return Eth Vault - function getEthVault() - public - view - returns (address) - { - return address(ethVault); - } -} diff --git a/contracts/staking/contracts/src/staking_pools/MixinStakingPool.sol b/contracts/staking/contracts/src/staking_pools/MixinStakingPool.sol index 0121e220b7..5972ae88b2 100644 --- a/contracts/staking/contracts/src/staking_pools/MixinStakingPool.sol +++ b/contracts/staking/contracts/src/staking_pools/MixinStakingPool.sol @@ -107,9 +107,8 @@ contract MixinStakingPool is return poolId; } - function joinStakingPoolAsMaker( - bytes32 poolId - ) + // TODO: comment + function joinStakingPoolAsMaker(bytes32 poolId) external { // Is the maker already in a pool? @@ -166,7 +165,7 @@ contract MixinStakingPool is } // Is the pool already full? - if (getNumberOfMakersInStakingPool(poolId) == maximumMakersInPool) { + if (numMakersByPoolId[poolId] == maximumMakersInPool) { LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError( LibStakingRichErrors.MakerPoolAssignmentErrorCodes.PoolIsFull, makerAddress, @@ -251,27 +250,6 @@ contract MixinStakingPool is 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 numMakersByPoolId[poolId]; - } - - /// @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 Computes the unique id that comes after the input pool id. /// @param poolId Unique id of pool. /// @return Next pool id after input pool. diff --git a/contracts/staking/contracts/src/staking_pools/MixinStakingPoolRewardVault.sol b/contracts/staking/contracts/src/staking_pools/MixinStakingPoolRewardVault.sol index 4162943b72..d13c99d17c 100644 --- a/contracts/staking/contracts/src/staking_pools/MixinStakingPoolRewardVault.sol +++ b/contracts/staking/contracts/src/staking_pools/MixinStakingPoolRewardVault.sol @@ -32,7 +32,6 @@ contract MixinStakingPoolRewardVault is IStakingEvents, 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) { @@ -78,23 +77,13 @@ contract MixinStakingPoolRewardVault is emit StakingPoolRewardVaultChanged(rewardVaultAddress); } - /// @dev Returns the staking pool reward vault - /// @return Address of reward vault. - function getStakingPoolRewardVault() - public - view - returns (address) - { - return address(rewardVault); - } - /// @dev Decreases the operator share for the given pool (i.e. increases pool rewards for members). /// Note that this is only callable by the pool operator, and will revert if the new operator /// share value is greater than the old value. /// @param poolId Unique Id of pool. /// @param newOperatorShare The newly decreased percentage of any rewards owned by the operator. function decreaseStakingPoolOperatorShare(bytes32 poolId, uint32 newOperatorShare) - public + external onlyStakingPoolOperator(poolId) { rewardVault.decreaseOperatorShare(poolId, newOperatorShare); diff --git a/contracts/staking/contracts/src/staking_pools/MixinStakingPoolRewards.sol b/contracts/staking/contracts/src/staking_pools/MixinStakingPoolRewards.sol index 7ca1eade44..081b1309ac 100644 --- a/contracts/staking/contracts/src/staking_pools/MixinStakingPoolRewards.sol +++ b/contracts/staking/contracts/src/staking_pools/MixinStakingPoolRewards.sol @@ -40,8 +40,8 @@ contract MixinStakingPoolRewards is { return _computeRewardBalanceOfDelegator( poolId, - _loadUnsyncedBalance(delegatedStakeToPoolByOwner[member][poolId]), - getCurrentEpoch() + _loadUnsyncedBalance(_delegatedStakeToPoolByOwner[member][poolId]), + currentEpoch ); } @@ -59,8 +59,6 @@ contract MixinStakingPoolRewards is ) internal { - uint256 currentEpoch = getCurrentEpoch(); - // transfer any rewards from the transient pool vault to the eth vault; // this must be done before we can modify the owner's portion of the delegator pool. _transferDelegatorRewardsToEthVault( @@ -85,7 +83,7 @@ contract MixinStakingPoolRewards is ); } - /// @dev Records a reward for delegators. This adds to the `cumulativeRewardsByPool`. + /// @dev Records a reward for delegators. This adds to the `_cumulativeRewardsByPool`. /// @param poolId Unique Id of pool. /// @param reward to record for delegators. /// @param amountOfDelegatedStake the amount of delegated stake that will split this reward. @@ -99,12 +97,12 @@ contract MixinStakingPoolRewards is internal { // cache a storage pointer to the cumulative rewards for `poolId` indexed by epoch. - mapping (uint256 => IStructs.Fraction) storage cumulativeRewardsByPoolPtr = cumulativeRewardsByPool[poolId]; + mapping (uint256 => IStructs.Fraction) storage _cumulativeRewardsByPoolPtr = _cumulativeRewardsByPool[poolId]; // fetch the last epoch at which we stored an entry for this pool; // this is the most up-to-date cumulative rewards for this pool. - uint256 cumulativeRewardsLastStored = cumulativeRewardsByPoolLastStored[poolId]; - IStructs.Fraction memory mostRecentCumulativeRewards = cumulativeRewardsByPoolPtr[cumulativeRewardsLastStored]; + uint256 cumulativeRewardsLastStored = _cumulativeRewardsByPoolLastStored[poolId]; + IStructs.Fraction memory mostRecentCumulativeRewards = _cumulativeRewardsByPoolPtr[cumulativeRewardsLastStored]; // compute new cumulative reward (uint256 numerator, uint256 denominator) = LibFractions.addFractions( @@ -190,12 +188,12 @@ contract MixinStakingPoolRewards is // compute the reward accumulated by the `next` balance; // this starts at `delegatedStake.currentEpoch + 1` and goes up until the last epoch, during which // rewards were accumulated. This is at most the most recently finalized epoch (current epoch - 1). - uint256 rewardsAccumulatedAfterLastStoredEpoch = (cumulativeRewardsByPoolLastStored[poolId] > unsyncedDelegatedStakeToPoolByOwner.currentEpoch) + uint256 rewardsAccumulatedAfterLastStoredEpoch = (_cumulativeRewardsByPoolLastStored[poolId] > unsyncedDelegatedStakeToPoolByOwner.currentEpoch) ? _computeMemberRewardOverInterval( poolId, unsyncedDelegatedStakeToPoolByOwner.nextEpochBalance, unsyncedDelegatedStakeToPoolByOwner.currentEpoch, - cumulativeRewardsByPoolLastStored[poolId] + _cumulativeRewardsByPoolLastStored[poolId] ) : 0; @@ -208,17 +206,17 @@ contract MixinStakingPoolRewards is /// A delegator always depends on the cumulative reward for the current epoch. /// They will also depend on the previous epoch's reward, if they are already staked with the input pool. /// @param poolId Unique id of pool. - /// @param delegatedStakeToPoolByOwner Amount of stake the member has delegated to the pool. + /// @param _delegatedStakeToPoolByOwner Amount of stake the member has delegated to the pool. /// @param isDependent is true iff adding a dependency. False, otherwise. function _setCumulativeRewardDependenciesForDelegator( bytes32 poolId, - IStructs.StoredBalance memory delegatedStakeToPoolByOwner, + IStructs.StoredBalance memory _delegatedStakeToPoolByOwner, bool isDependent ) private { // if this delegator is not yet initialized then there's no dependency to unset. - if (!isDependent && !delegatedStakeToPoolByOwner.isInitialized) { + if (!isDependent && !_delegatedStakeToPoolByOwner.isInitialized) { return; } @@ -226,20 +224,20 @@ contract MixinStakingPoolRewards is IStructs.CumulativeRewardInfo memory mostRecentCumulativeRewardInfo = _getMostRecentCumulativeRewardInfo(poolId); // record dependency on `lastEpoch` - if (delegatedStakeToPoolByOwner.currentEpoch > 0 && delegatedStakeToPoolByOwner.currentEpochBalance != 0) { + if (_delegatedStakeToPoolByOwner.currentEpoch > 0 && _delegatedStakeToPoolByOwner.currentEpochBalance != 0) { _addOrRemoveDependencyOnCumulativeReward( poolId, - uint256(delegatedStakeToPoolByOwner.currentEpoch).safeSub(1), + uint256(_delegatedStakeToPoolByOwner.currentEpoch).safeSub(1), mostRecentCumulativeRewardInfo, isDependent ); } // record dependency on current epoch. - if (delegatedStakeToPoolByOwner.currentEpochBalance != 0 || delegatedStakeToPoolByOwner.nextEpochBalance != 0) { + if (_delegatedStakeToPoolByOwner.currentEpochBalance != 0 || _delegatedStakeToPoolByOwner.nextEpochBalance != 0) { _addOrRemoveDependencyOnCumulativeReward( poolId, - delegatedStakeToPoolByOwner.currentEpoch, + _delegatedStakeToPoolByOwner.currentEpoch, mostRecentCumulativeRewardInfo, isDependent ); diff --git a/contracts/staking/contracts/src/sys/MixinScheduler.sol b/contracts/staking/contracts/src/sys/MixinScheduler.sol index e215a2bcd4..4145d43cb0 100644 --- a/contracts/staking/contracts/src/sys/MixinScheduler.sol +++ b/contracts/staking/contracts/src/sys/MixinScheduler.sol @@ -37,27 +37,6 @@ contract MixinScheduler is { using LibSafeMath for uint256; - /// @dev Returns the current epoch. - /// @return Epoch. - function getCurrentEpoch() - public - view - returns (uint256) - { - return currentEpoch; - } - - /// @dev Returns the start time in seconds of the current epoch. - /// Epoch period = [startTimeInSeconds..endTimeInSeconds) - /// @return Time in seconds. - function getCurrentEpochStartTimeInSeconds() - public - view - returns (uint256) - { - return currentEpochStartTimeInSeconds; - } - /// @dev Returns the earliest end time in seconds of this epoch. /// The next epoch can begin once this time is reached. /// Epoch period = [startTimeInSeconds..endTimeInSeconds) @@ -67,7 +46,7 @@ contract MixinScheduler is view returns (uint256) { - return getCurrentEpochStartTimeInSeconds().safeAdd(epochDurationInSeconds); + return currentEpochStartTimeInSeconds.safeAdd(epochDurationInSeconds); } /// @dev Assert scheduler state before initializing it. diff --git a/contracts/staking/contracts/src/vaults/EthVault.sol b/contracts/staking/contracts/src/vaults/EthVault.sol index a4707d70e1..fc8b69c6d7 100644 --- a/contracts/staking/contracts/src/vaults/EthVault.sol +++ b/contracts/staking/contracts/src/vaults/EthVault.sol @@ -31,7 +31,7 @@ contract EthVault is using LibSafeMath for uint256; // mapping from Owner to ETH balance - mapping (address => uint256) internal balances; + mapping (address => uint256) public balances; /// @dev Constructor. constructor() @@ -78,16 +78,6 @@ contract EthVault is return totalBalance; } - /// @dev Returns the balance in ETH of the `owner` - /// @return Balance in ETH. - function balanceOf(address owner) - external - view - returns (uint256) - { - return balances[owner]; - } - /// @dev Withdraw an `amount` of ETH to `owner` from the vault. /// @param owner of ETH. /// @param amount of ETH to withdraw. diff --git a/contracts/staking/contracts/src/vaults/StakingPoolRewardVault.sol b/contracts/staking/contracts/src/vaults/StakingPoolRewardVault.sol index 1c4c70cd43..d0b5d59432 100644 --- a/contracts/staking/contracts/src/vaults/StakingPoolRewardVault.sol +++ b/contracts/staking/contracts/src/vaults/StakingPoolRewardVault.sol @@ -41,7 +41,6 @@ import "../immutable/MixinConstants.sol"; /// perform withdrawals on behalf of its users. contract StakingPoolRewardVault is IStakingPoolRewardVault, - IVaultCore, MixinConstants, MixinVaultCore { @@ -49,10 +48,10 @@ contract StakingPoolRewardVault is using LibSafeDowncast for uint256; // mapping from poolId to Pool metadata - mapping (bytes32 => Pool) internal poolById; + mapping (bytes32 => Pool) public poolById; // address of ether vault - IEthVault internal ethVault; + IEthVault internal _ethVault; /// @dev Fallback function. This contract is payable, but only by the staking contract. function () @@ -71,7 +70,7 @@ contract StakingPoolRewardVault is external onlyOwner { - ethVault = IEthVault(ethVaultAddress); + _ethVault = IEthVault(ethVaultAddress); emit EthVaultChanged(ethVaultAddress); } @@ -243,50 +242,6 @@ contract StakingPoolRewardVault is return poolById[poolId].operatorAddress; } - /// @dev Returns the total balance of a pool. - /// @param poolId Unique Id of pool. - /// @return Balance in ETH. - function balanceOf(bytes32 poolId) - external - view - returns (uint256) - { - return poolById[poolId].operatorBalance + poolById[poolId].membersBalance; - } - - /// @dev Returns the balance of a pool operator. - /// @param poolId Unique Id of pool. - /// @return Balance in ETH. - function balanceOfOperator(bytes32 poolId) - external - view - returns (uint256) - { - return poolById[poolId].operatorBalance; - } - - /// @dev Returns the balance co-owned by members of a pool. - /// @param poolId Unique Id of pool. - /// @return Balance in ETH. - function balanceOfMembers(bytes32 poolId) - external - view - returns (uint256) - { - return poolById[poolId].membersBalance; - } - - /// @dev Returns the operator share of a pool's balance. - /// @param poolId Unique Id of pool. - /// @return Operator share (integer out of 100) - function getOperatorShare(bytes32 poolId) - external - view - returns (uint256) - { - return poolById[poolId].operatorShare; - } - /// @dev Increments a balances in a Pool struct, splitting the input amount between the /// pool operator and members of the pool based on the pool operator's share. /// @param pool Pool struct with the balances to increment. @@ -326,7 +281,7 @@ contract StakingPoolRewardVault is private { // sanity check on eth vault - IEthVault _ethVault = ethVault; + IEthVault _ethVault = _ethVault; if (address(_ethVault) == address(0)) { LibRichErrors.rrevert( LibStakingRichErrors.EthVaultNotSetError() diff --git a/contracts/staking/contracts/src/vaults/ZrxVault.sol b/contracts/staking/contracts/src/vaults/ZrxVault.sol index efb01e3951..a51a4dcb46 100644 --- a/contracts/staking/contracts/src/vaults/ZrxVault.sol +++ b/contracts/staking/contracts/src/vaults/ZrxVault.sol @@ -40,31 +40,31 @@ contract ZrxVault is using LibSafeMath for uint256; // mapping from Owner to ZRX balance - mapping (address => uint256) internal balances; + mapping (address => uint256) public balances; // Zrx Asset Proxy - IAssetProxy internal zrxAssetProxy; + IAssetProxy public zrxAssetProxy; // Zrx Token - IERC20Token internal zrxToken; + IERC20Token internal _zrxToken; // Asset data for the ERC20 Proxy - bytes internal zrxAssetData; + bytes internal _zrxAssetData; /// @dev Constructor. /// @param zrxProxyAddress Address of the 0x Zrx Proxy. - /// @param zrxTokenAddress Address of the Zrx Token. + /// @param _zrxTokenAddress Address of the Zrx Token. constructor( address zrxProxyAddress, - address zrxTokenAddress + address _zrxTokenAddress ) public { zrxAssetProxy = IAssetProxy(zrxProxyAddress); - zrxToken = IERC20Token(zrxTokenAddress); - zrxAssetData = abi.encodeWithSelector( + _zrxToken = IERC20Token(_zrxTokenAddress); + _zrxAssetData = abi.encodeWithSelector( IAssetData(address(0)).ERC20Token.selector, - zrxTokenAddress + _zrxTokenAddress ); } @@ -99,7 +99,7 @@ contract ZrxVault is // deposit ZRX from owner zrxAssetProxy.transferFrom( - zrxAssetData, + _zrxAssetData, owner, address(this), amount @@ -135,16 +135,6 @@ contract ZrxVault is return totalBalance; } - /// @dev Returns the balance in Zrx Tokens of the `owner` - /// @return Balance in Zrx. - function balanceOf(address owner) - external - view - returns (uint256) - { - return balances[owner]; - } - /// @dev Withdraw an `amount` of Zrx Tokens to `owner` from the vault. /// @param owner of Zrx Tokens. /// @param amount of Zrx Tokens to withdraw. @@ -160,7 +150,7 @@ contract ZrxVault is emit ZrxWithdrawnFromVault(msg.sender, owner, amount); // withdraw ZRX to owner - zrxToken.transfer( + _zrxToken.transfer( owner, amount ); diff --git a/contracts/staking/contracts/test/TestStorageLayout.sol b/contracts/staking/contracts/test/TestStorageLayout.sol index 8b2d17c40f..5603773c02 100644 --- a/contracts/staking/contracts/test/TestStorageLayout.sol +++ b/contracts/staking/contracts/test/TestStorageLayout.sol @@ -55,22 +55,22 @@ contract TestStorageLayout is if sub(stakingContract_slot, slot) { revertIncorrectStorageSlot() } slot := add(slot, 1) - if sub(activeStakeByOwner_slot, slot) { revertIncorrectStorageSlot() } + if sub(_activeStakeByOwner_slot, slot) { revertIncorrectStorageSlot() } slot := add(slot, 1) - if sub(inactiveStakeByOwner_slot, slot) { revertIncorrectStorageSlot() } + if sub(_inactiveStakeByOwner_slot, slot) { revertIncorrectStorageSlot() } slot := add(slot, 1) - if sub(delegatedStakeByOwner_slot, slot) { revertIncorrectStorageSlot() } + if sub(_delegatedStakeByOwner_slot, slot) { revertIncorrectStorageSlot() } slot := add(slot, 1) - if sub(delegatedStakeToPoolByOwner_slot, slot) { revertIncorrectStorageSlot() } + if sub(_delegatedStakeToPoolByOwner_slot, slot) { revertIncorrectStorageSlot() } slot := add(slot, 1) - if sub(delegatedStakeByPoolId_slot, slot) { revertIncorrectStorageSlot() } + if sub(_delegatedStakeByPoolId_slot, slot) { revertIncorrectStorageSlot() } slot := add(slot, 1) - if sub(withdrawableStakeByOwner_slot, slot) { revertIncorrectStorageSlot() } + if sub(_withdrawableStakeByOwner_slot, slot) { revertIncorrectStorageSlot() } slot := add(slot, 1) if sub(nextPoolId_slot, slot) { revertIncorrectStorageSlot() } @@ -94,13 +94,13 @@ contract TestStorageLayout is if sub(activePoolsThisEpoch_slot, slot) { revertIncorrectStorageSlot() } slot := add(slot, 1) - if sub(cumulativeRewardsByPool_slot, slot) { revertIncorrectStorageSlot() } + if sub(_cumulativeRewardsByPool_slot, slot) { revertIncorrectStorageSlot() } slot := add(slot, 1) - if sub(cumulativeRewardsByPoolReferenceCounter_slot, slot) { revertIncorrectStorageSlot() } + if sub(_cumulativeRewardsByPoolReferenceCounter_slot, slot) { revertIncorrectStorageSlot() } slot := add(slot, 1) - if sub(cumulativeRewardsByPoolLastStored_slot, slot) { revertIncorrectStorageSlot() } + if sub(_cumulativeRewardsByPoolLastStored_slot, slot) { revertIncorrectStorageSlot() } slot := add(slot, 1) if sub(validExchanges_slot, slot) { revertIncorrectStorageSlot() } diff --git a/contracts/staking/package.json b/contracts/staking/package.json index 490419276e..c8047b42c6 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/@(EthVault|IEthVault|IStaking|IStakingEvents|IStakingPoolRewardVault|IStakingProxy|IStorageInit|IStructs|IVaultCore|IZrxVault|LibFixedMath|LibFixedMathRichErrors|LibProxy|LibSafeDowncast|LibStakingRichErrors|MixinConstants|MixinCumulativeRewards|MixinDeploymentConstants|MixinEthVault|MixinExchangeFees|MixinExchangeManager|MixinParams|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakeStorage|MixinStakingPool|MixinStakingPoolRewardVault|MixinStakingPoolRewards|MixinStorage|MixinVaultCore|MixinZrxVault|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|IStorageInit|IStructs|IVaultCore|IZrxVault|LibFixedMath|LibFixedMathRichErrors|LibProxy|LibSafeDowncast|LibStakingRichErrors|MixinConstants|MixinCumulativeRewards|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinParams|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakeStorage|MixinStakingPool|MixinStakingPoolRewardVault|MixinStakingPoolRewards|MixinStorage|MixinVaultCore|MixinZrxVault|ReadOnlyProxy|Staking|StakingPoolRewardVault|StakingProxy|TestCobbDouglas|TestCumulativeRewardTracking|TestInitTarget|TestLibFixedMath|TestLibProxy|TestLibProxyReceiver|TestLibSafeDowncast|TestProtocolFees|TestProtocolFeesERC20Proxy|TestStaking|TestStakingProxy|TestStorageLayout|ZrxVault).json" }, "repository": { "type": "git", diff --git a/contracts/staking/src/artifacts.ts b/contracts/staking/src/artifacts.ts index 1c0bbe1114..4b69db6333 100644 --- a/contracts/staking/src/artifacts.ts +++ b/contracts/staking/src/artifacts.ts @@ -23,7 +23,6 @@ import * as LibStakingRichErrors from '../generated-artifacts/LibStakingRichErro import * as MixinConstants from '../generated-artifacts/MixinConstants.json'; import * as MixinCumulativeRewards from '../generated-artifacts/MixinCumulativeRewards.json'; import * as MixinDeploymentConstants from '../generated-artifacts/MixinDeploymentConstants.json'; -import * as MixinEthVault from '../generated-artifacts/MixinEthVault.json'; import * as MixinExchangeFees from '../generated-artifacts/MixinExchangeFees.json'; import * as MixinExchangeManager from '../generated-artifacts/MixinExchangeManager.json'; import * as MixinParams from '../generated-artifacts/MixinParams.json'; @@ -82,7 +81,6 @@ export const artifacts = { MixinStakeStorage: MixinStakeStorage as ContractArtifact, MixinZrxVault: MixinZrxVault as ContractArtifact, MixinCumulativeRewards: MixinCumulativeRewards as ContractArtifact, - MixinEthVault: MixinEthVault as ContractArtifact, MixinStakingPool: MixinStakingPool as ContractArtifact, MixinStakingPoolRewardVault: MixinStakingPoolRewardVault as ContractArtifact, MixinStakingPoolRewards: MixinStakingPoolRewards as ContractArtifact, diff --git a/contracts/staking/src/wrappers.ts b/contracts/staking/src/wrappers.ts index 19693381bc..bf37aac9aa 100644 --- a/contracts/staking/src/wrappers.ts +++ b/contracts/staking/src/wrappers.ts @@ -21,7 +21,6 @@ export * from '../generated-wrappers/lib_staking_rich_errors'; export * from '../generated-wrappers/mixin_constants'; export * from '../generated-wrappers/mixin_cumulative_rewards'; export * from '../generated-wrappers/mixin_deployment_constants'; -export * from '../generated-wrappers/mixin_eth_vault'; export * from '../generated-wrappers/mixin_exchange_fees'; export * from '../generated-wrappers/mixin_exchange_manager'; export * from '../generated-wrappers/mixin_params'; diff --git a/contracts/staking/test/epoch_test.ts b/contracts/staking/test/epoch_test.ts index 0d1a6f51a7..e32df331fb 100644 --- a/contracts/staking/test/epoch_test.ts +++ b/contracts/staking/test/epoch_test.ts @@ -34,14 +34,14 @@ blockchainTests('Epochs', env => { ///// 2/3 Validate Initial Epoch & TimeLock Period ///// { // epoch - const currentEpoch = await stakingApiWrapper.stakingContract.getCurrentEpoch.callAsync(); + const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch.callAsync(); expect(currentEpoch).to.be.bignumber.equal(stakingConstants.INITIAL_EPOCH); } ///// 3/3 Increment Epoch (TimeLock Should Not Increment) ///// await stakingApiWrapper.utils.skipToNextEpochAsync(); { // epoch - const currentEpoch = await stakingApiWrapper.stakingContract.getCurrentEpoch.callAsync(); + const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch.callAsync(); expect(currentEpoch).to.be.bignumber.equal(stakingConstants.INITIAL_EPOCH.plus(1)); } }); diff --git a/contracts/staking/tsconfig.json b/contracts/staking/tsconfig.json index 4c4584f4de..b39277ef77 100644 --- a/contracts/staking/tsconfig.json +++ b/contracts/staking/tsconfig.json @@ -21,7 +21,6 @@ "generated-artifacts/MixinConstants.json", "generated-artifacts/MixinCumulativeRewards.json", "generated-artifacts/MixinDeploymentConstants.json", - "generated-artifacts/MixinEthVault.json", "generated-artifacts/MixinExchangeFees.json", "generated-artifacts/MixinExchangeManager.json", "generated-artifacts/MixinParams.json",