Updated dependency ordering using a linearizer script, which is now here: https://github.com/hysz/SmartContractLinearizer
This commit is contained in:
@@ -31,14 +31,18 @@ import "./core/MixinRewards.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract Staking is
|
contract Staking is
|
||||||
|
IStakingEvents,
|
||||||
|
MixinDeploymentConstants,
|
||||||
|
MixinConstants,
|
||||||
|
MixinStorage,
|
||||||
MixinEpoch,
|
MixinEpoch,
|
||||||
MixinExchange,
|
|
||||||
MixinZrxVault,
|
|
||||||
MixinRewardVault,
|
MixinRewardVault,
|
||||||
|
MixinZrxVault,
|
||||||
|
MixinExchange,
|
||||||
MixinStakeBalances,
|
MixinStakeBalances,
|
||||||
MixinStake,
|
|
||||||
MixinPools,
|
MixinPools,
|
||||||
MixinRewards,
|
MixinRewards,
|
||||||
|
MixinStake,
|
||||||
MixinFees
|
MixinFees
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@@ -23,8 +23,8 @@ import "./interfaces/IStakingProxy.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract StakingProxy is
|
contract StakingProxy is
|
||||||
IStakingProxy,
|
MixinStorage,
|
||||||
MixinStorage
|
IStakingProxy
|
||||||
{
|
{
|
||||||
address constant NIL_ADDRESS = 0x0000000000000000000000000000000000000000;
|
address constant NIL_ADDRESS = 0x0000000000000000000000000000000000000000;
|
||||||
|
|
||||||
|
@@ -25,9 +25,7 @@ import "../immutable/MixinStorage.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract MixinExchange is
|
contract MixinExchange is
|
||||||
// interfaces
|
|
||||||
IStakingEvents,
|
IStakingEvents,
|
||||||
// immutables
|
|
||||||
MixinConstants,
|
MixinConstants,
|
||||||
MixinStorage
|
MixinStorage
|
||||||
{
|
{
|
||||||
|
@@ -32,17 +32,12 @@ import "../interfaces/IStructs.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract MixinFees is
|
contract MixinFees is
|
||||||
// interfaces
|
|
||||||
IStakingEvents,
|
IStakingEvents,
|
||||||
IStructs,
|
|
||||||
// immutables
|
|
||||||
MixinConstants,
|
MixinConstants,
|
||||||
MixinStorage,
|
MixinStorage,
|
||||||
// standalones
|
|
||||||
MixinEpoch,
|
MixinEpoch,
|
||||||
MixinExchange,
|
|
||||||
MixinRewardVault,
|
MixinRewardVault,
|
||||||
// staking logic
|
MixinExchange,
|
||||||
MixinStakeBalances,
|
MixinStakeBalances,
|
||||||
MixinPools
|
MixinPools
|
||||||
{
|
{
|
||||||
@@ -91,7 +86,7 @@ contract MixinFees is
|
|||||||
{
|
{
|
||||||
// Step 1 - compute total fees this epoch
|
// Step 1 - compute total fees this epoch
|
||||||
uint256 numberOfActivePoolIds = activePoolIdsThisEpoch.length;
|
uint256 numberOfActivePoolIds = activePoolIdsThisEpoch.length;
|
||||||
ActivePool[] memory activePoolIds = new ActivePool[](activePoolIdsThisEpoch.length);
|
IStructs.ActivePool[] memory activePoolIds = new IStructs.ActivePool[](activePoolIdsThisEpoch.length);
|
||||||
uint256 totalFees = 0;
|
uint256 totalFees = 0;
|
||||||
for (uint i = 0; i != numberOfActivePoolIds; i++) {
|
for (uint i = 0; i != numberOfActivePoolIds; i++) {
|
||||||
activePoolIds[i].poolId = activePoolIdsThisEpoch[i];
|
activePoolIds[i].poolId = activePoolIdsThisEpoch[i];
|
||||||
|
@@ -33,12 +33,9 @@ import "./MixinRewardVault.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract MixinPools is
|
contract MixinPools is
|
||||||
// interfaces
|
|
||||||
IStakingEvents,
|
IStakingEvents,
|
||||||
// immutables
|
|
||||||
MixinConstants,
|
MixinConstants,
|
||||||
MixinStorage,
|
MixinStorage,
|
||||||
// standalone
|
|
||||||
MixinRewardVault
|
MixinRewardVault
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -63,7 +60,7 @@ contract MixinPools is
|
|||||||
nextPoolId = _computeNextPoolId(poolId);
|
nextPoolId = _computeNextPoolId(poolId);
|
||||||
|
|
||||||
//
|
//
|
||||||
Pool memory pool = Pool({
|
IStructs.Pool memory pool = IStructs.Pool({
|
||||||
operatorAddress: operatorAddress,
|
operatorAddress: operatorAddress,
|
||||||
operatorShare: operatorShare
|
operatorShare: operatorShare
|
||||||
});
|
});
|
||||||
@@ -125,7 +122,7 @@ contract MixinPools is
|
|||||||
view
|
view
|
||||||
returns (bytes32 approvalHash)
|
returns (bytes32 approvalHash)
|
||||||
{
|
{
|
||||||
StakingPoolApproval memory approval = StakingPoolApproval({
|
IStructs.StakingPoolApproval memory approval = IStructs.StakingPoolApproval({
|
||||||
poolId: poolId,
|
poolId: poolId,
|
||||||
makerAddress: makerAddress
|
makerAddress: makerAddress
|
||||||
});
|
});
|
||||||
@@ -182,7 +179,7 @@ contract MixinPools is
|
|||||||
function _getPool(bytes32 poolId)
|
function _getPool(bytes32 poolId)
|
||||||
internal
|
internal
|
||||||
view
|
view
|
||||||
returns (Pool memory pool)
|
returns (IStructs.Pool memory pool)
|
||||||
{
|
{
|
||||||
pool = poolById[poolId];
|
pool = poolById[poolId];
|
||||||
return pool;
|
return pool;
|
||||||
|
@@ -22,18 +22,15 @@ import "../libs/LibSafeMath.sol";
|
|||||||
import "../libs/LibRewardMath.sol";
|
import "../libs/LibRewardMath.sol";
|
||||||
import "../immutable/MixinStorage.sol";
|
import "../immutable/MixinStorage.sol";
|
||||||
import "../immutable/MixinConstants.sol";
|
import "../immutable/MixinConstants.sol";
|
||||||
import "../interfaces/IStakingEvents.sol";
|
|
||||||
import "./MixinStakeBalances.sol";
|
import "./MixinStakeBalances.sol";
|
||||||
import "./MixinRewardVault.sol";
|
import "./MixinRewardVault.sol";
|
||||||
import "./MixinPools.sol";
|
import "./MixinPools.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinRewards is
|
contract MixinRewards is
|
||||||
// immutables
|
|
||||||
MixinConstants,
|
MixinConstants,
|
||||||
MixinStorage,
|
MixinStorage,
|
||||||
// standalones
|
|
||||||
MixinRewardVault,
|
MixinRewardVault,
|
||||||
// logic
|
|
||||||
MixinStakeBalances,
|
MixinStakeBalances,
|
||||||
MixinPools
|
MixinPools
|
||||||
{
|
{
|
||||||
|
@@ -30,16 +30,12 @@ import "./MixinStakeBalances.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract MixinStake is
|
contract MixinStake is
|
||||||
// interfaces
|
|
||||||
IStakingEvents,
|
IStakingEvents,
|
||||||
// immutables
|
|
||||||
MixinConstants,
|
MixinConstants,
|
||||||
MixinStorage,
|
MixinStorage,
|
||||||
// standalone
|
|
||||||
MixinEpoch,
|
MixinEpoch,
|
||||||
MixinZrxVault,
|
|
||||||
MixinRewardVault,
|
MixinRewardVault,
|
||||||
// logic
|
MixinZrxVault,
|
||||||
MixinStakeBalances
|
MixinStakeBalances
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -268,7 +264,7 @@ contract MixinStake is
|
|||||||
function _timelockStake(address owner, uint256 amount)
|
function _timelockStake(address owner, uint256 amount)
|
||||||
private
|
private
|
||||||
{
|
{
|
||||||
(Timelock memory ownerTimelock,) = _getSynchronizedTimelock(owner);
|
(IStructs.Timelock memory ownerTimelock,) = _getSynchronizedTimelock(owner);
|
||||||
uint96 downcastAmount = amount._downcastToUint96();
|
uint96 downcastAmount = amount._downcastToUint96();
|
||||||
ownerTimelock.total += downcastAmount;
|
ownerTimelock.total += downcastAmount;
|
||||||
timelockedStakeByOwner[owner] = ownerTimelock;
|
timelockedStakeByOwner[owner] = ownerTimelock;
|
||||||
@@ -277,7 +273,7 @@ contract MixinStake is
|
|||||||
function _syncTimelockedStake(address owner)
|
function _syncTimelockedStake(address owner)
|
||||||
private
|
private
|
||||||
{
|
{
|
||||||
(Timelock memory ownerTimelock, bool isOutOfSync) = _getSynchronizedTimelock(owner);
|
(IStructs.Timelock memory ownerTimelock, bool isOutOfSync) = _getSynchronizedTimelock(owner);
|
||||||
if (!isOutOfSync) {
|
if (!isOutOfSync) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -119,7 +119,7 @@ contract MixinStakeBalances is
|
|||||||
view
|
view
|
||||||
returns (uint256)
|
returns (uint256)
|
||||||
{
|
{
|
||||||
(Timelock memory timelock,) = _getSynchronizedTimelock(owner);
|
(IStructs.Timelock memory timelock,) = _getSynchronizedTimelock(owner);
|
||||||
return timelock.total;
|
return timelock.total;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ contract MixinStakeBalances is
|
|||||||
view
|
view
|
||||||
returns (uint256)
|
returns (uint256)
|
||||||
{
|
{
|
||||||
(Timelock memory timelock,) = _getSynchronizedTimelock(owner);
|
(IStructs.Timelock memory timelock,) = _getSynchronizedTimelock(owner);
|
||||||
return timelock.lockedAt;
|
return timelock.lockedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,7 +25,6 @@ import "../interfaces/IStructs.sol";
|
|||||||
|
|
||||||
|
|
||||||
contract MixinStorage is
|
contract MixinStorage is
|
||||||
IStructs,
|
|
||||||
MixinConstants
|
MixinConstants
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -46,7 +45,7 @@ contract MixinStorage is
|
|||||||
mapping (address => uint256) activeStakeByOwner;
|
mapping (address => uint256) activeStakeByOwner;
|
||||||
|
|
||||||
// mapping from Owner to Amount Timelocked
|
// mapping from Owner to Amount Timelocked
|
||||||
mapping (address => Timelock) timelockedStakeByOwner;
|
mapping (address => IStructs.Timelock) timelockedStakeByOwner;
|
||||||
|
|
||||||
// mapping from Owner to Amount Delegated
|
// mapping from Owner to Amount Delegated
|
||||||
mapping (address => uint256) delegatedStakeByOwner;
|
mapping (address => uint256) delegatedStakeByOwner;
|
||||||
@@ -64,7 +63,7 @@ contract MixinStorage is
|
|||||||
bytes32 nextPoolId = INITIAL_POOL_ID;
|
bytes32 nextPoolId = INITIAL_POOL_ID;
|
||||||
|
|
||||||
// mapping from Pool Id to Pool
|
// mapping from Pool Id to Pool
|
||||||
mapping (bytes32 => Pool) poolById;
|
mapping (bytes32 => IStructs.Pool) poolById;
|
||||||
|
|
||||||
// mapping from Maker Address to Pool Id
|
// mapping from Maker Address to Pool Id
|
||||||
// A Maker can only hold a single token
|
// A Maker can only hold a single token
|
||||||
|
@@ -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)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user