diff --git a/contracts/staking/contracts/src/Staking.sol b/contracts/staking/contracts/src/Staking.sol index 2ede77d769..885c0bd338 100644 --- a/contracts/staking/contracts/src/Staking.sol +++ b/contracts/staking/contracts/src/Staking.sol @@ -31,14 +31,18 @@ import "./core/MixinRewards.sol"; contract Staking is + IStakingEvents, + MixinDeploymentConstants, + MixinConstants, + MixinStorage, MixinEpoch, - MixinExchange, - MixinZrxVault, MixinRewardVault, + MixinZrxVault, + MixinExchange, MixinStakeBalances, - MixinStake, MixinPools, MixinRewards, + MixinStake, MixinFees { diff --git a/contracts/staking/contracts/src/StakingProxy.sol b/contracts/staking/contracts/src/StakingProxy.sol index f2d51e6e1f..0ca19e9d03 100644 --- a/contracts/staking/contracts/src/StakingProxy.sol +++ b/contracts/staking/contracts/src/StakingProxy.sol @@ -23,8 +23,8 @@ import "./interfaces/IStakingProxy.sol"; contract StakingProxy is - IStakingProxy, - MixinStorage + MixinStorage, + IStakingProxy { address constant NIL_ADDRESS = 0x0000000000000000000000000000000000000000; diff --git a/contracts/staking/contracts/src/core/MixinExchange.sol b/contracts/staking/contracts/src/core/MixinExchange.sol index 2f83a641f6..a63c7001c3 100644 --- a/contracts/staking/contracts/src/core/MixinExchange.sol +++ b/contracts/staking/contracts/src/core/MixinExchange.sol @@ -25,9 +25,7 @@ import "../immutable/MixinStorage.sol"; contract MixinExchange is - // interfaces IStakingEvents, - // immutables MixinConstants, MixinStorage { diff --git a/contracts/staking/contracts/src/core/MixinFees.sol b/contracts/staking/contracts/src/core/MixinFees.sol index eb7c06d9ce..6909b71716 100644 --- a/contracts/staking/contracts/src/core/MixinFees.sol +++ b/contracts/staking/contracts/src/core/MixinFees.sol @@ -32,17 +32,12 @@ import "../interfaces/IStructs.sol"; contract MixinFees is - // interfaces IStakingEvents, - IStructs, - // immutables MixinConstants, MixinStorage, - // standalones MixinEpoch, - MixinExchange, MixinRewardVault, - // staking logic + MixinExchange, MixinStakeBalances, MixinPools { @@ -91,7 +86,7 @@ contract MixinFees is { // Step 1 - compute total fees this epoch uint256 numberOfActivePoolIds = activePoolIdsThisEpoch.length; - ActivePool[] memory activePoolIds = new ActivePool[](activePoolIdsThisEpoch.length); + IStructs.ActivePool[] memory activePoolIds = new IStructs.ActivePool[](activePoolIdsThisEpoch.length); uint256 totalFees = 0; for (uint i = 0; i != numberOfActivePoolIds; i++) { activePoolIds[i].poolId = activePoolIdsThisEpoch[i]; diff --git a/contracts/staking/contracts/src/core/MixinPools.sol b/contracts/staking/contracts/src/core/MixinPools.sol index 1351f7ae7a..aebd6a0afb 100644 --- a/contracts/staking/contracts/src/core/MixinPools.sol +++ b/contracts/staking/contracts/src/core/MixinPools.sol @@ -33,12 +33,9 @@ import "./MixinRewardVault.sol"; contract MixinPools is - // interfaces IStakingEvents, - // immutables MixinConstants, MixinStorage, - // standalone MixinRewardVault { @@ -63,7 +60,7 @@ contract MixinPools is nextPoolId = _computeNextPoolId(poolId); // - Pool memory pool = Pool({ + IStructs.Pool memory pool = IStructs.Pool({ operatorAddress: operatorAddress, operatorShare: operatorShare }); @@ -125,7 +122,7 @@ contract MixinPools is view returns (bytes32 approvalHash) { - StakingPoolApproval memory approval = StakingPoolApproval({ + IStructs.StakingPoolApproval memory approval = IStructs.StakingPoolApproval({ poolId: poolId, makerAddress: makerAddress }); @@ -182,7 +179,7 @@ contract MixinPools is function _getPool(bytes32 poolId) internal view - returns (Pool memory pool) + returns (IStructs.Pool memory pool) { pool = poolById[poolId]; return pool; diff --git a/contracts/staking/contracts/src/core/MixinRewards.sol b/contracts/staking/contracts/src/core/MixinRewards.sol index bedbfad1cf..a93aebd4a4 100644 --- a/contracts/staking/contracts/src/core/MixinRewards.sol +++ b/contracts/staking/contracts/src/core/MixinRewards.sol @@ -22,18 +22,15 @@ import "../libs/LibSafeMath.sol"; import "../libs/LibRewardMath.sol"; import "../immutable/MixinStorage.sol"; import "../immutable/MixinConstants.sol"; -import "../interfaces/IStakingEvents.sol"; import "./MixinStakeBalances.sol"; import "./MixinRewardVault.sol"; import "./MixinPools.sol"; + contract MixinRewards is - // immutables MixinConstants, MixinStorage, - // standalones MixinRewardVault, - // logic MixinStakeBalances, MixinPools { diff --git a/contracts/staking/contracts/src/core/MixinStake.sol b/contracts/staking/contracts/src/core/MixinStake.sol index be76f96f99..89d5f3b194 100644 --- a/contracts/staking/contracts/src/core/MixinStake.sol +++ b/contracts/staking/contracts/src/core/MixinStake.sol @@ -30,16 +30,12 @@ import "./MixinStakeBalances.sol"; contract MixinStake is - // interfaces IStakingEvents, - // immutables MixinConstants, MixinStorage, - // standalone MixinEpoch, - MixinZrxVault, MixinRewardVault, - // logic + MixinZrxVault, MixinStakeBalances { @@ -268,7 +264,7 @@ contract MixinStake is function _timelockStake(address owner, uint256 amount) private { - (Timelock memory ownerTimelock,) = _getSynchronizedTimelock(owner); + (IStructs.Timelock memory ownerTimelock,) = _getSynchronizedTimelock(owner); uint96 downcastAmount = amount._downcastToUint96(); ownerTimelock.total += downcastAmount; timelockedStakeByOwner[owner] = ownerTimelock; @@ -277,7 +273,7 @@ contract MixinStake is function _syncTimelockedStake(address owner) private { - (Timelock memory ownerTimelock, bool isOutOfSync) = _getSynchronizedTimelock(owner); + (IStructs.Timelock memory ownerTimelock, bool isOutOfSync) = _getSynchronizedTimelock(owner); if (!isOutOfSync) { return; } diff --git a/contracts/staking/contracts/src/core/MixinStakeBalances.sol b/contracts/staking/contracts/src/core/MixinStakeBalances.sol index f7b080fe37..0b860e9530 100644 --- a/contracts/staking/contracts/src/core/MixinStakeBalances.sol +++ b/contracts/staking/contracts/src/core/MixinStakeBalances.sol @@ -119,7 +119,7 @@ contract MixinStakeBalances is view returns (uint256) { - (Timelock memory timelock,) = _getSynchronizedTimelock(owner); + (IStructs.Timelock memory timelock,) = _getSynchronizedTimelock(owner); return timelock.total; } @@ -128,7 +128,7 @@ contract MixinStakeBalances is view returns (uint256) { - (Timelock memory timelock,) = _getSynchronizedTimelock(owner); + (IStructs.Timelock memory timelock,) = _getSynchronizedTimelock(owner); return timelock.lockedAt; } diff --git a/contracts/staking/contracts/src/immutable/MixinStorage.sol b/contracts/staking/contracts/src/immutable/MixinStorage.sol index 6daf846ae8..d49ec3ce47 100644 --- a/contracts/staking/contracts/src/immutable/MixinStorage.sol +++ b/contracts/staking/contracts/src/immutable/MixinStorage.sol @@ -25,7 +25,6 @@ import "../interfaces/IStructs.sol"; contract MixinStorage is - IStructs, MixinConstants { @@ -46,7 +45,7 @@ contract MixinStorage is mapping (address => uint256) activeStakeByOwner; // mapping from Owner to Amount Timelocked - mapping (address => Timelock) timelockedStakeByOwner; + mapping (address => IStructs.Timelock) timelockedStakeByOwner; // mapping from Owner to Amount Delegated mapping (address => uint256) delegatedStakeByOwner; @@ -64,7 +63,7 @@ contract MixinStorage is bytes32 nextPoolId = INITIAL_POOL_ID; // mapping from Pool Id to Pool - mapping (bytes32 => Pool) poolById; + mapping (bytes32 => IStructs.Pool) poolById; // mapping from Maker Address to Pool Id // A Maker can only hold a single token diff --git a/contracts/staking/contracts/src/libs/LibTimelock.sol b/contracts/staking/contracts/src/libs/LibTimelock.sol deleted file mode 100644 index 6446b7b204..0000000000 --- a/contracts/staking/contracts/src/libs/LibTimelock.sol +++ /dev/null @@ -1,99 +0,0 @@ -/* - - Copyright 2018 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.5; - -import "../interfaces/IStructs.sol"; -import "@0x/contracts-utils/contracts/src/SafeMath.sol"; - - -contract MixinTimelock is - IStructs, - SafeMath -{ - - // Epoch | lockedAt | total | pending | current | timelock() | withdraw() | available() - // 0 | 0 | 0 | 0 | 0 | | | 0 - // 1 | 1 | 5 | 0 | 0 | +5 | | 0 - // 2 | 1 | 5 | 0 | 0 | | | 0 - // 2 | 2 | 15 | 5 | 0 | +10 | | 0 - // 3 | 2 | 15 | 5 | 0 | | | 5 - // 3 | 3 | 30 | 15 | 5 | +15 | | 5 - // 4 | 3 | 30 | 15 | 5 | | | 15 - // 5 | 3 | 30 | 15 | 5 | | | 30 - // 5 | 5 | 30 | 30 | 30 | +0 * | | 30 - // 6 | 6 | 50 | 30 | 30 | +20 | | 30 - // 6 | 6 | 20 | 0 | 0 | | -30 | 0 - // 7 | 6 | 20 | 0 | 0 | | | 0 - // 8 | 6 | 20 | 0 | 0 | | | 20 - - - function _add(Timelock memory timelock, uint256 amount) - internal - returns (uint256) - { - timelock.total += amount; - } - - function _sub(Timelock memory timelock, uint256 amount) - internal - returns (uint256) - { - - } - - - - function _subTimelockedStake(address owner, uint256 amount) - internal - { - - } - - function _addTimelockedStake(address owner, uint256 amount) - internal - { - timelockedStakeByOwner[owner] = safeAdd(timelockedStakeByOwner[owner], amount); - - // update timelock - uint64 currentTimelockPeriod = _getTimelockPeriod(); - Timelock memory timelock = timelocksByOwner[owner]; - - } - - function _getAvailableTimelockedStake(address owner) - internal - returns (uint256) - { - - } - - function _getPendingTimelockedStake(address owner) - internal - returns (uint256) - { - - } - - function _getTotalTimelockedStake(address owner) - internal - returns (uint256) - { - - } -} \ No newline at end of file