Make some storage vars public and rename internal vars
This commit is contained in:
@@ -132,7 +132,7 @@ contract MixinExchangeFees is
|
|||||||
/// @dev Returns the total amount of fees collected thus far, in the current epoch.
|
/// @dev Returns the total amount of fees collected thus far, in the current epoch.
|
||||||
/// @return Amount of fees.
|
/// @return Amount of fees.
|
||||||
function getTotalProtocolFeesThisEpoch()
|
function getTotalProtocolFeesThisEpoch()
|
||||||
public
|
external
|
||||||
view
|
view
|
||||||
returns (uint256)
|
returns (uint256)
|
||||||
{
|
{
|
||||||
@@ -140,17 +140,6 @@ contract MixinExchangeFees is
|
|||||||
return address(this).balance.safeAdd(wethBalance);
|
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.
|
/// @dev Withdraws the entire WETH balance of the contract.
|
||||||
function _unwrapWETH()
|
function _unwrapWETH()
|
||||||
internal
|
internal
|
||||||
|
@@ -32,10 +32,9 @@ contract MixinExchangeManager is
|
|||||||
IStakingEvents,
|
IStakingEvents,
|
||||||
MixinStorage
|
MixinStorage
|
||||||
{
|
{
|
||||||
|
|
||||||
/// @dev Asserts that the call is coming from a valid exchange.
|
/// @dev Asserts that the call is coming from a valid exchange.
|
||||||
modifier onlyExchange() {
|
modifier onlyExchange() {
|
||||||
if (!isValidExchangeAddress(msg.sender)) {
|
if (!validExchanges[msg.sender]) {
|
||||||
LibRichErrors.rrevert(LibStakingRichErrors.OnlyCallableByExchangeError(
|
LibRichErrors.rrevert(LibStakingRichErrors.OnlyCallableByExchangeError(
|
||||||
msg.sender
|
msg.sender
|
||||||
));
|
));
|
||||||
@@ -72,15 +71,4 @@ contract MixinExchangeManager is
|
|||||||
validExchanges[addr] = false;
|
validExchanges[addr] = false;
|
||||||
emit ExchangeRemoved(addr);
|
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];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetProxy.sol";
|
import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetProxy.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
||||||
@@ -34,100 +35,99 @@ contract MixinStorage is
|
|||||||
MixinConstants,
|
MixinConstants,
|
||||||
Ownable
|
Ownable
|
||||||
{
|
{
|
||||||
|
|
||||||
// WETH Asset Proxy
|
// WETH Asset Proxy
|
||||||
IAssetProxy internal wethAssetProxy;
|
IAssetProxy public wethAssetProxy;
|
||||||
|
|
||||||
// address of staking contract
|
// address of staking contract
|
||||||
address internal stakingContract;
|
address public stakingContract;
|
||||||
|
|
||||||
// address of read-only proxy
|
// address of read-only proxy
|
||||||
address internal readOnlyProxy;
|
address public readOnlyProxy;
|
||||||
|
|
||||||
// address for read-only proxy to call
|
// address for read-only proxy to call
|
||||||
address internal readOnlyProxyCallee;
|
address public readOnlyProxyCallee;
|
||||||
|
|
||||||
// mapping from Owner to Amount of Active Stake
|
// mapping from Owner to Amount of Active Stake
|
||||||
// (access using _loadAndSyncBalance or _loadUnsyncedBalance)
|
// (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
|
// mapping from Owner to Amount of Inactive Stake
|
||||||
// (access using _loadAndSyncBalance or _loadUnsyncedBalance)
|
// (access using _loadAndSyncBalance or _loadUnsyncedBalance)
|
||||||
mapping (address => IStructs.StoredBalance) internal inactiveStakeByOwner;
|
mapping (address => IStructs.StoredBalance) internal _inactiveStakeByOwner;
|
||||||
|
|
||||||
// mapping from Owner to Amount Delegated
|
// mapping from Owner to Amount Delegated
|
||||||
// (access using _loadAndSyncBalance or _loadUnsyncedBalance)
|
// (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
|
// mapping from Owner to Pool Id to Amount Delegated
|
||||||
// (access using _loadAndSyncBalance or _loadUnsyncedBalance)
|
// (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
|
// mapping from Pool Id to Amount Delegated
|
||||||
// (access using _loadAndSyncBalance or _loadUnsyncedBalance)
|
// (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 from Owner to Amount of Withdrawable Stake
|
||||||
mapping (address => uint256) internal withdrawableStakeByOwner;
|
mapping (address => uint256) internal _withdrawableStakeByOwner;
|
||||||
|
|
||||||
// tracking Pool Id
|
// 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
|
// 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.
|
// 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 from Pool Id to number of makers assigned to that pool
|
||||||
mapping (bytes32 => uint256) internal numMakersByPoolId;
|
mapping (bytes32 => uint256) public numMakersByPoolId;
|
||||||
|
|
||||||
// current epoch
|
// current epoch
|
||||||
uint256 internal currentEpoch = INITIAL_EPOCH;
|
uint256 public currentEpoch = INITIAL_EPOCH;
|
||||||
|
|
||||||
// current epoch start time
|
// current epoch start time
|
||||||
uint256 internal currentEpochStartTimeInSeconds;
|
uint256 public currentEpochStartTimeInSeconds;
|
||||||
|
|
||||||
// fees collected this epoch
|
// fees collected this epoch
|
||||||
mapping (bytes32 => uint256) internal protocolFeesThisEpochByPool;
|
mapping (bytes32 => uint256) public protocolFeesThisEpochByPool;
|
||||||
|
|
||||||
// pools that were active in the current epoch
|
// pools that were active in the current epoch
|
||||||
bytes32[] internal activePoolsThisEpoch;
|
bytes32[] public activePoolsThisEpoch;
|
||||||
|
|
||||||
// mapping from Pool Id to Epoch to Reward Ratio
|
// 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 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 from Pool Id to Epoch
|
||||||
mapping (bytes32 => uint256) internal cumulativeRewardsByPoolLastStored;
|
mapping (bytes32 => uint256) internal _cumulativeRewardsByPoolLastStored;
|
||||||
|
|
||||||
// registered 0x Exchange contracts
|
// registered 0x Exchange contracts
|
||||||
mapping (address => bool) internal validExchanges;
|
mapping (address => bool) public validExchanges;
|
||||||
|
|
||||||
// ZRX vault (stores staked ZRX)
|
// ZRX vault (stores staked ZRX)
|
||||||
IZrxVault internal zrxVault;
|
IZrxVault public zrxVault;
|
||||||
|
|
||||||
// ETH Vault (stores eth balances of stakers and pool operators)
|
// 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)
|
// 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.
|
// Minimum seconds between epochs.
|
||||||
uint256 internal epochDurationInSeconds;
|
uint256 public epochDurationInSeconds;
|
||||||
|
|
||||||
// How much delegated stake is weighted vs operator stake, in ppm.
|
// 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.
|
// 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.
|
// Maximum number of maker addresses allowed to be registered to a pool.
|
||||||
uint256 internal maximumMakersInPool;
|
uint256 public maximumMakersInPool;
|
||||||
|
|
||||||
// Numerator for cobb douglas alpha factor.
|
// Numerator for cobb douglas alpha factor.
|
||||||
uint32 internal cobbDouglasAlphaNumerator;
|
uint32 public cobbDouglasAlphaNumerator;
|
||||||
|
|
||||||
// Denominator for cobb douglas alpha factor.
|
// Denominator for cobb douglas alpha factor.
|
||||||
uint32 internal cobbDouglasAlphaDenomintor;
|
uint32 public cobbDouglasAlphaDenomintor;
|
||||||
}
|
}
|
||||||
|
@@ -42,6 +42,14 @@ interface IEthVault {
|
|||||||
uint256 amount
|
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.
|
/// @dev Deposit an `amount` of ETH from `owner` into the vault.
|
||||||
/// Note that only the Staking contract can call this.
|
/// Note that only the Staking contract can call this.
|
||||||
/// Note that this can only be called when *not* in Catostrophic Failure mode.
|
/// Note that this can only be called when *not* in Catostrophic Failure mode.
|
||||||
@@ -61,11 +69,4 @@ interface IEthVault {
|
|||||||
function withdrawAll()
|
function withdrawAll()
|
||||||
external
|
external
|
||||||
returns (uint256);
|
returns (uint256);
|
||||||
|
|
||||||
/// @dev Returns the balance in ETH of the `owner`
|
|
||||||
/// @return Balance in ETH.
|
|
||||||
function balanceOf(address owner)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (uint256);
|
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
|
||||||
/// @dev This vault manages staking pool rewards.
|
/// @dev This vault manages staking pool rewards.
|
||||||
@@ -99,6 +100,14 @@ interface IStakingPoolRewardVault {
|
|||||||
external
|
external
|
||||||
payable;
|
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)
|
function setEthVault(address ethVaultAddress)
|
||||||
external;
|
external;
|
||||||
|
|
||||||
@@ -173,36 +182,4 @@ interface IStakingPoolRewardVault {
|
|||||||
external
|
external
|
||||||
view
|
view
|
||||||
returns (address payable);
|
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);
|
|
||||||
}
|
}
|
||||||
|
@@ -54,6 +54,21 @@ interface IZrxVault {
|
|||||||
address zrxProxyAddress
|
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.
|
/// @dev Sets the Zrx proxy.
|
||||||
/// Note that only the contract owner can call this.
|
/// Note that only the contract owner can call this.
|
||||||
/// Note that this can only be called when *not* in Catastrophic Failure mode.
|
/// Note that this can only be called when *not* in Catastrophic Failure mode.
|
||||||
@@ -83,11 +98,4 @@ interface IZrxVault {
|
|||||||
function withdrawAllFrom(address owner)
|
function withdrawAllFrom(address owner)
|
||||||
external
|
external
|
||||||
returns (uint256);
|
returns (uint256);
|
||||||
|
|
||||||
/// @dev Returns the balance in Zrx Tokens of the `owner`
|
|
||||||
/// @return Balance in Zrx.
|
|
||||||
function balanceOf(address owner)
|
|
||||||
external
|
|
||||||
view
|
|
||||||
returns (uint256);
|
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ contract MixinStake is
|
|||||||
_depositFromOwnerIntoZrxVault(owner, amount);
|
_depositFromOwnerIntoZrxVault(owner, amount);
|
||||||
|
|
||||||
// mint stake
|
// mint stake
|
||||||
_incrementCurrentAndNextBalance(activeStakeByOwner[owner], amount);
|
_incrementCurrentAndNextBalance(_activeStakeByOwner[owner], amount);
|
||||||
|
|
||||||
// notify
|
// notify
|
||||||
emit Stake(
|
emit Stake(
|
||||||
@@ -71,10 +71,10 @@ contract MixinStake is
|
|||||||
}
|
}
|
||||||
|
|
||||||
// burn inactive stake
|
// burn inactive stake
|
||||||
_decrementCurrentAndNextBalance(inactiveStakeByOwner[owner], amount);
|
_decrementCurrentAndNextBalance(_inactiveStakeByOwner[owner], amount);
|
||||||
|
|
||||||
// update withdrawable field
|
// update withdrawable field
|
||||||
withdrawableStakeByOwner[owner] = currentWithdrawableStake.safeSub(amount);
|
_withdrawableStakeByOwner[owner] = currentWithdrawableStake.safeSub(amount);
|
||||||
|
|
||||||
// withdraw equivalent amount of ZRX from vault
|
// withdraw equivalent amount of ZRX from vault
|
||||||
_withdrawToOwnerFromZrxVault(owner, amount);
|
_withdrawToOwnerFromZrxVault(owner, amount);
|
||||||
@@ -137,7 +137,7 @@ contract MixinStake is
|
|||||||
|
|
||||||
// update withdrawable field, if necessary
|
// update withdrawable field, if necessary
|
||||||
if (from.status == IStructs.StakeStatus.INACTIVE) {
|
if (from.status == IStructs.StakeStatus.INACTIVE) {
|
||||||
withdrawableStakeByOwner[owner] = _computeWithdrawableStake(owner, withdrawableStake);
|
_withdrawableStakeByOwner[owner] = _computeWithdrawableStake(owner, withdrawableStake);
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify
|
// notify
|
||||||
@@ -163,16 +163,16 @@ contract MixinStake is
|
|||||||
private
|
private
|
||||||
{
|
{
|
||||||
// cache amount delegated to pool by owner
|
// 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
|
// 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
|
// 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
|
// 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);
|
_syncRewardsForDelegator(poolId, owner, initDelegatedStakeToPoolByOwner, finalDelegatedStakeToPoolByOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,16 +188,16 @@ contract MixinStake is
|
|||||||
private
|
private
|
||||||
{
|
{
|
||||||
// cache amount delegated to pool by owner
|
// 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
|
// 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
|
// 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
|
// 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);
|
_syncRewardsForDelegator(poolId, owner, initDelegatedStakeToPoolByOwner, finalDelegatedStakeToPoolByOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,11 +212,11 @@ contract MixinStake is
|
|||||||
{
|
{
|
||||||
// lookup status
|
// lookup status
|
||||||
if (status == IStructs.StakeStatus.ACTIVE) {
|
if (status == IStructs.StakeStatus.ACTIVE) {
|
||||||
return activeStakeByOwner[owner];
|
return _activeStakeByOwner[owner];
|
||||||
} else if (status == IStructs.StakeStatus.INACTIVE) {
|
} else if (status == IStructs.StakeStatus.INACTIVE) {
|
||||||
return inactiveStakeByOwner[owner];
|
return _inactiveStakeByOwner[owner];
|
||||||
} else if (status == IStructs.StakeStatus.DELEGATED) {
|
} else if (status == IStructs.StakeStatus.DELEGATED) {
|
||||||
return delegatedStakeByOwner[owner];
|
return _delegatedStakeByOwner[owner];
|
||||||
}
|
}
|
||||||
|
|
||||||
// invalid status
|
// invalid status
|
||||||
|
@@ -52,7 +52,7 @@ contract MixinStakeBalances is
|
|||||||
view
|
view
|
||||||
returns (IStructs.StakeBalance memory balance)
|
returns (IStructs.StakeBalance memory balance)
|
||||||
{
|
{
|
||||||
IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(activeStakeByOwner[owner]);
|
IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(_activeStakeByOwner[owner]);
|
||||||
return IStructs.StakeBalance({
|
return IStructs.StakeBalance({
|
||||||
currentEpochBalance: storedBalance.currentEpochBalance,
|
currentEpochBalance: storedBalance.currentEpochBalance,
|
||||||
nextEpochBalance: storedBalance.nextEpochBalance
|
nextEpochBalance: storedBalance.nextEpochBalance
|
||||||
@@ -67,7 +67,7 @@ contract MixinStakeBalances is
|
|||||||
view
|
view
|
||||||
returns (IStructs.StakeBalance memory balance)
|
returns (IStructs.StakeBalance memory balance)
|
||||||
{
|
{
|
||||||
IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(inactiveStakeByOwner[owner]);
|
IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(_inactiveStakeByOwner[owner]);
|
||||||
return IStructs.StakeBalance({
|
return IStructs.StakeBalance({
|
||||||
currentEpochBalance: storedBalance.currentEpochBalance,
|
currentEpochBalance: storedBalance.currentEpochBalance,
|
||||||
nextEpochBalance: storedBalance.nextEpochBalance
|
nextEpochBalance: storedBalance.nextEpochBalance
|
||||||
@@ -82,7 +82,7 @@ contract MixinStakeBalances is
|
|||||||
view
|
view
|
||||||
returns (uint256)
|
returns (uint256)
|
||||||
{
|
{
|
||||||
return _computeWithdrawableStake(owner, withdrawableStakeByOwner[owner]);
|
return _computeWithdrawableStake(owner, _withdrawableStakeByOwner[owner]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Returns the stake delegated by a given owner.
|
/// @dev Returns the stake delegated by a given owner.
|
||||||
@@ -93,7 +93,7 @@ contract MixinStakeBalances is
|
|||||||
view
|
view
|
||||||
returns (IStructs.StakeBalance memory balance)
|
returns (IStructs.StakeBalance memory balance)
|
||||||
{
|
{
|
||||||
IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(delegatedStakeByOwner[owner]);
|
IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(_delegatedStakeByOwner[owner]);
|
||||||
return IStructs.StakeBalance({
|
return IStructs.StakeBalance({
|
||||||
currentEpochBalance: storedBalance.currentEpochBalance,
|
currentEpochBalance: storedBalance.currentEpochBalance,
|
||||||
nextEpochBalance: storedBalance.nextEpochBalance
|
nextEpochBalance: storedBalance.nextEpochBalance
|
||||||
@@ -109,7 +109,7 @@ contract MixinStakeBalances is
|
|||||||
view
|
view
|
||||||
returns (IStructs.StakeBalance memory balance)
|
returns (IStructs.StakeBalance memory balance)
|
||||||
{
|
{
|
||||||
IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(delegatedStakeToPoolByOwner[owner][poolId]);
|
IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(_delegatedStakeToPoolByOwner[owner][poolId]);
|
||||||
return IStructs.StakeBalance({
|
return IStructs.StakeBalance({
|
||||||
currentEpochBalance: storedBalance.currentEpochBalance,
|
currentEpochBalance: storedBalance.currentEpochBalance,
|
||||||
nextEpochBalance: storedBalance.nextEpochBalance
|
nextEpochBalance: storedBalance.nextEpochBalance
|
||||||
@@ -124,7 +124,7 @@ contract MixinStakeBalances is
|
|||||||
view
|
view
|
||||||
returns (IStructs.StakeBalance memory balance)
|
returns (IStructs.StakeBalance memory balance)
|
||||||
{
|
{
|
||||||
IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(delegatedStakeByPoolId[poolId]);
|
IStructs.StoredBalance memory storedBalance = _loadAndSyncBalance(_delegatedStakeByPoolId[poolId]);
|
||||||
return IStructs.StakeBalance({
|
return IStructs.StakeBalance({
|
||||||
currentEpochBalance: storedBalance.currentEpochBalance,
|
currentEpochBalance: storedBalance.currentEpochBalance,
|
||||||
nextEpochBalance: storedBalance.nextEpochBalance
|
nextEpochBalance: storedBalance.nextEpochBalance
|
||||||
@@ -142,7 +142,7 @@ contract MixinStakeBalances is
|
|||||||
{
|
{
|
||||||
// stake cannot be withdrawn if it has been reallocated for the `next` epoch;
|
// 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`.
|
// 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) {
|
if (storedBalance.currentEpoch == currentEpoch) {
|
||||||
return LibSafeMath.min256(storedBalance.nextEpochBalance, lastStoredWithdrawableStake);
|
return LibSafeMath.min256(storedBalance.nextEpochBalance, lastStoredWithdrawableStake);
|
||||||
} else if (uint256(storedBalance.currentEpoch).safeAdd(1) == currentEpoch) {
|
} else if (uint256(storedBalance.currentEpoch).safeAdd(1) == currentEpoch) {
|
||||||
|
@@ -85,9 +85,9 @@ contract MixinStakeStorage is
|
|||||||
// load from storage
|
// load from storage
|
||||||
balance = balancePtr;
|
balance = balancePtr;
|
||||||
// sync
|
// sync
|
||||||
uint256 currentEpoch = getCurrentEpoch();
|
uint256 currentEpoch_ = currentEpoch;
|
||||||
if (currentEpoch > balance.currentEpoch) {
|
if (currentEpoch > balance.currentEpoch) {
|
||||||
balance.currentEpoch = currentEpoch.downcastToUint32();
|
balance.currentEpoch = currentEpoch_.downcastToUint32();
|
||||||
balance.currentEpochBalance = balance.nextEpochBalance;
|
balance.currentEpochBalance = balance.nextEpochBalance;
|
||||||
}
|
}
|
||||||
return balance;
|
return balance;
|
||||||
|
@@ -37,16 +37,6 @@ contract MixinZrxVault is
|
|||||||
zrxVault = IZrxVault(zrxVaultAddress);
|
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.
|
/// @dev Deposits Zrx Tokens from the `owner` into the vault.
|
||||||
/// @param owner of Zrx Tokens
|
/// @param owner of Zrx Tokens
|
||||||
/// @param amount of tokens to deposit.
|
/// @param amount of tokens to deposit.
|
||||||
@@ -87,6 +77,6 @@ contract MixinZrxVault is
|
|||||||
address(_zrxVault) != address(0),
|
address(_zrxVault) != address(0),
|
||||||
"INVALID_ZRX_VAULT"
|
"INVALID_ZRX_VAULT"
|
||||||
);
|
);
|
||||||
return _zrxVault.balanceOf(owner);
|
return _zrxVault.balances(owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,21 +21,12 @@ pragma experimental ABIEncoderV2;
|
|||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibFractions.sol";
|
import "@0x/contracts-utils/contracts/src/LibFractions.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
|
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
|
||||||
import "../immutable/MixinStorage.sol";
|
|
||||||
import "../immutable/MixinConstants.sol";
|
|
||||||
import "../stake/MixinStakeBalances.sol";
|
import "../stake/MixinStakeBalances.sol";
|
||||||
import "./MixinStakingPoolRewardVault.sol";
|
import "./MixinStakingPoolRewardVault.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinCumulativeRewards is
|
contract MixinCumulativeRewards is
|
||||||
IStakingEvents,
|
|
||||||
MixinConstants,
|
|
||||||
Ownable,
|
|
||||||
MixinStorage,
|
|
||||||
MixinZrxVault,
|
|
||||||
MixinStakingPoolRewardVault,
|
MixinStakingPoolRewardVault,
|
||||||
MixinScheduler,
|
|
||||||
MixinStakeStorage,
|
|
||||||
MixinStakeBalances
|
MixinStakeBalances
|
||||||
{
|
{
|
||||||
using LibSafeMath for uint256;
|
using LibSafeMath for uint256;
|
||||||
@@ -45,7 +36,6 @@ contract MixinCumulativeRewards is
|
|||||||
function _initializeCumulativeRewards(bytes32 poolId)
|
function _initializeCumulativeRewards(bytes32 poolId)
|
||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
uint256 currentEpoch = getCurrentEpoch();
|
|
||||||
// sets the default cumulative reward
|
// sets the default cumulative reward
|
||||||
_forceSetCumulativeReward(
|
_forceSetCumulativeReward(
|
||||||
poolId,
|
poolId,
|
||||||
@@ -78,9 +68,9 @@ contract MixinCumulativeRewards is
|
|||||||
returns (bool)
|
returns (bool)
|
||||||
{
|
{
|
||||||
return (
|
return (
|
||||||
_isCumulativeRewardSet(cumulativeRewardsByPool[poolId][epoch]) && // is there a value to unset
|
_isCumulativeRewardSet(_cumulativeRewardsByPool[poolId][epoch]) && // is there a value to unset
|
||||||
cumulativeRewardsByPoolReferenceCounter[poolId][epoch] == 0 && // no references to this CR
|
_cumulativeRewardsByPoolReferenceCounter[poolId][epoch] == 0 && // no references to this CR
|
||||||
cumulativeRewardsByPoolLastStored[poolId] > epoch // this is *not* the most recent CR
|
_cumulativeRewardsByPoolLastStored[poolId] > epoch // this is *not* the most recent CR
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +85,7 @@ contract MixinCumulativeRewards is
|
|||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
if (_isCumulativeRewardSet(cumulativeRewardsByPool[poolId][epoch])) {
|
if (_isCumulativeRewardSet(_cumulativeRewardsByPool[poolId][epoch])) {
|
||||||
// do nothing; we don't want to override the current value
|
// do nothing; we don't want to override the current value
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -114,7 +104,7 @@ contract MixinCumulativeRewards is
|
|||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
cumulativeRewardsByPool[poolId][epoch] = value;
|
_cumulativeRewardsByPool[poolId][epoch] = value;
|
||||||
_trySetMostRecentCumulativeRewardEpoch(poolId, epoch);
|
_trySetMostRecentCumulativeRewardEpoch(poolId, epoch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +126,7 @@ contract MixinCumulativeRewards is
|
|||||||
function _forceUnsetCumulativeReward(bytes32 poolId, uint256 epoch)
|
function _forceUnsetCumulativeReward(bytes32 poolId, uint256 epoch)
|
||||||
internal
|
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.
|
/// @dev Returns info on most recent cumulative reward.
|
||||||
@@ -145,11 +135,11 @@ contract MixinCumulativeRewards is
|
|||||||
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
|
||||||
uint256 cumulativeRewardsLastStored = cumulativeRewardsByPoolLastStored[poolId];
|
uint256 cumulativeRewardsLastStored = _cumulativeRewardsByPoolLastStored[poolId];
|
||||||
|
|
||||||
// query and return cumulative reward info for this pool
|
// query and return cumulative reward info for this pool
|
||||||
return IStructs.CumulativeRewardInfo({
|
return IStructs.CumulativeRewardInfo({
|
||||||
cumulativeReward: cumulativeRewardsByPool[poolId][cumulativeRewardsLastStored],
|
cumulativeReward: _cumulativeRewardsByPool[poolId][cumulativeRewardsLastStored],
|
||||||
cumulativeRewardEpoch: cumulativeRewardsLastStored
|
cumulativeRewardEpoch: cumulativeRewardsLastStored
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -163,7 +153,7 @@ contract MixinCumulativeRewards is
|
|||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
// check if we should do any work
|
// check if we should do any work
|
||||||
uint256 currentMostRecentEpoch = cumulativeRewardsByPoolLastStored[poolId];
|
uint256 currentMostRecentEpoch = _cumulativeRewardsByPoolLastStored[poolId];
|
||||||
if (epoch == currentMostRecentEpoch) {
|
if (epoch == currentMostRecentEpoch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -189,7 +179,7 @@ contract MixinCumulativeRewards is
|
|||||||
{
|
{
|
||||||
// sanity check that we're not trying to go back in time
|
// sanity check that we're not trying to go back in time
|
||||||
assert(newMostRecentEpoch >= currentMostRecentEpoch);
|
assert(newMostRecentEpoch >= currentMostRecentEpoch);
|
||||||
cumulativeRewardsByPoolLastStored[poolId] = newMostRecentEpoch;
|
_cumulativeRewardsByPoolLastStored[poolId] = newMostRecentEpoch;
|
||||||
|
|
||||||
// unset the previous most recent reward, if it is no longer needed
|
// unset the previous most recent reward, if it is no longer needed
|
||||||
_tryUnsetCumulativeReward(poolId, currentMostRecentEpoch);
|
_tryUnsetCumulativeReward(poolId, currentMostRecentEpoch);
|
||||||
@@ -234,7 +224,7 @@ contract MixinCumulativeRewards is
|
|||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
// add dependency by increasing the reference counter
|
// 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)
|
// set CR to most recent reward (if it is not already set)
|
||||||
_trySetCumulativeReward(
|
_trySetCumulativeReward(
|
||||||
@@ -254,8 +244,8 @@ contract MixinCumulativeRewards is
|
|||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
// remove dependency by decreasing reference counter
|
// remove dependency by decreasing reference counter
|
||||||
uint256 newReferenceCounter = cumulativeRewardsByPoolReferenceCounter[poolId][epoch].safeSub(1);
|
uint256 newReferenceCounter = _cumulativeRewardsByPoolReferenceCounter[poolId][epoch].safeSub(1);
|
||||||
cumulativeRewardsByPoolReferenceCounter[poolId][epoch] = newReferenceCounter;
|
_cumulativeRewardsByPoolReferenceCounter[poolId][epoch] = newReferenceCounter;
|
||||||
|
|
||||||
// clear cumulative reward from state, if it is no longer needed
|
// clear cumulative reward from state, if it is no longer needed
|
||||||
_tryUnsetCumulativeReward(poolId, epoch);
|
_tryUnsetCumulativeReward(poolId, epoch);
|
||||||
@@ -295,7 +285,7 @@ contract MixinCumulativeRewards is
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sanity check begin reward
|
// sanity check begin reward
|
||||||
IStructs.Fraction memory beginReward = cumulativeRewardsByPool[poolId][beginEpoch];
|
IStructs.Fraction memory beginReward = _cumulativeRewardsByPool[poolId][beginEpoch];
|
||||||
if (!_isCumulativeRewardSet(beginReward)) {
|
if (!_isCumulativeRewardSet(beginReward)) {
|
||||||
LibRichErrors.rrevert(
|
LibRichErrors.rrevert(
|
||||||
LibStakingRichErrors.CumulativeRewardIntervalError(
|
LibStakingRichErrors.CumulativeRewardIntervalError(
|
||||||
@@ -308,7 +298,7 @@ contract MixinCumulativeRewards is
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sanity check end reward
|
// sanity check end reward
|
||||||
IStructs.Fraction memory endReward = cumulativeRewardsByPool[poolId][endEpoch];
|
IStructs.Fraction memory endReward = _cumulativeRewardsByPool[poolId][endEpoch];
|
||||||
if (!_isCumulativeRewardSet(endReward)) {
|
if (!_isCumulativeRewardSet(endReward)) {
|
||||||
LibRichErrors.rrevert(
|
LibRichErrors.rrevert(
|
||||||
LibStakingRichErrors.CumulativeRewardIntervalError(
|
LibStakingRichErrors.CumulativeRewardIntervalError(
|
||||||
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -107,9 +107,8 @@ contract MixinStakingPool is
|
|||||||
return poolId;
|
return poolId;
|
||||||
}
|
}
|
||||||
|
|
||||||
function joinStakingPoolAsMaker(
|
// TODO: comment
|
||||||
bytes32 poolId
|
function joinStakingPoolAsMaker(bytes32 poolId)
|
||||||
)
|
|
||||||
external
|
external
|
||||||
{
|
{
|
||||||
// Is the maker already in a pool?
|
// Is the maker already in a pool?
|
||||||
@@ -166,7 +165,7 @@ contract MixinStakingPool is
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Is the pool already full?
|
// Is the pool already full?
|
||||||
if (getNumberOfMakersInStakingPool(poolId) == maximumMakersInPool) {
|
if (numMakersByPoolId[poolId] == maximumMakersInPool) {
|
||||||
LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError(
|
LibRichErrors.rrevert(LibStakingRichErrors.MakerPoolAssignmentError(
|
||||||
LibStakingRichErrors.MakerPoolAssignmentErrorCodes.PoolIsFull,
|
LibStakingRichErrors.MakerPoolAssignmentErrorCodes.PoolIsFull,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -251,27 +250,6 @@ contract MixinStakingPool 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 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.
|
/// @dev Computes the unique id that comes after the input pool id.
|
||||||
/// @param poolId Unique id of pool.
|
/// @param poolId Unique id of pool.
|
||||||
/// @return Next pool id after input pool.
|
/// @return Next pool id after input pool.
|
||||||
|
@@ -32,7 +32,6 @@ contract MixinStakingPoolRewardVault is
|
|||||||
IStakingEvents,
|
IStakingEvents,
|
||||||
MixinStorage
|
MixinStorage
|
||||||
{
|
{
|
||||||
|
|
||||||
/// @dev Asserts that the sender is the operator of the input pool.
|
/// @dev Asserts that the sender is the operator of the input pool.
|
||||||
/// @param poolId Pool sender must be operator of.
|
/// @param poolId Pool sender must be operator of.
|
||||||
modifier onlyStakingPoolOperator(bytes32 poolId) {
|
modifier onlyStakingPoolOperator(bytes32 poolId) {
|
||||||
@@ -78,23 +77,13 @@ contract MixinStakingPoolRewardVault is
|
|||||||
emit StakingPoolRewardVaultChanged(rewardVaultAddress);
|
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).
|
/// @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
|
/// 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.
|
/// share value is greater than the old value.
|
||||||
/// @param poolId Unique Id of pool.
|
/// @param poolId Unique Id of pool.
|
||||||
/// @param newOperatorShare The newly decreased percentage of any rewards owned by the operator.
|
/// @param newOperatorShare The newly decreased percentage of any rewards owned by the operator.
|
||||||
function decreaseStakingPoolOperatorShare(bytes32 poolId, uint32 newOperatorShare)
|
function decreaseStakingPoolOperatorShare(bytes32 poolId, uint32 newOperatorShare)
|
||||||
public
|
external
|
||||||
onlyStakingPoolOperator(poolId)
|
onlyStakingPoolOperator(poolId)
|
||||||
{
|
{
|
||||||
rewardVault.decreaseOperatorShare(poolId, newOperatorShare);
|
rewardVault.decreaseOperatorShare(poolId, newOperatorShare);
|
||||||
|
@@ -40,8 +40,8 @@ contract MixinStakingPoolRewards is
|
|||||||
{
|
{
|
||||||
return _computeRewardBalanceOfDelegator(
|
return _computeRewardBalanceOfDelegator(
|
||||||
poolId,
|
poolId,
|
||||||
_loadUnsyncedBalance(delegatedStakeToPoolByOwner[member][poolId]),
|
_loadUnsyncedBalance(_delegatedStakeToPoolByOwner[member][poolId]),
|
||||||
getCurrentEpoch()
|
currentEpoch
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,8 +59,6 @@ contract MixinStakingPoolRewards is
|
|||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
uint256 currentEpoch = getCurrentEpoch();
|
|
||||||
|
|
||||||
// transfer any rewards from the transient pool vault to the eth vault;
|
// 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.
|
// this must be done before we can modify the owner's portion of the delegator pool.
|
||||||
_transferDelegatorRewardsToEthVault(
|
_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 poolId Unique Id of pool.
|
||||||
/// @param reward to record for delegators.
|
/// @param reward to record for delegators.
|
||||||
/// @param amountOfDelegatedStake the amount of delegated stake that will split this reward.
|
/// @param amountOfDelegatedStake the amount of delegated stake that will split this reward.
|
||||||
@@ -99,12 +97,12 @@ contract MixinStakingPoolRewards is
|
|||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
// cache a storage pointer to the cumulative rewards for `poolId` indexed by epoch.
|
// 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;
|
// 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.
|
// this is the most up-to-date cumulative rewards for this pool.
|
||||||
uint256 cumulativeRewardsLastStored = cumulativeRewardsByPoolLastStored[poolId];
|
uint256 cumulativeRewardsLastStored = _cumulativeRewardsByPoolLastStored[poolId];
|
||||||
IStructs.Fraction memory mostRecentCumulativeRewards = cumulativeRewardsByPoolPtr[cumulativeRewardsLastStored];
|
IStructs.Fraction memory mostRecentCumulativeRewards = _cumulativeRewardsByPoolPtr[cumulativeRewardsLastStored];
|
||||||
|
|
||||||
// compute new cumulative reward
|
// compute new cumulative reward
|
||||||
(uint256 numerator, uint256 denominator) = LibFractions.addFractions(
|
(uint256 numerator, uint256 denominator) = LibFractions.addFractions(
|
||||||
@@ -190,12 +188,12 @@ contract MixinStakingPoolRewards is
|
|||||||
// compute the reward accumulated by the `next` balance;
|
// compute the reward accumulated by the `next` balance;
|
||||||
// this starts at `delegatedStake.currentEpoch + 1` and goes up until the last epoch, during which
|
// 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).
|
// 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(
|
? _computeMemberRewardOverInterval(
|
||||||
poolId,
|
poolId,
|
||||||
unsyncedDelegatedStakeToPoolByOwner.nextEpochBalance,
|
unsyncedDelegatedStakeToPoolByOwner.nextEpochBalance,
|
||||||
unsyncedDelegatedStakeToPoolByOwner.currentEpoch,
|
unsyncedDelegatedStakeToPoolByOwner.currentEpoch,
|
||||||
cumulativeRewardsByPoolLastStored[poolId]
|
_cumulativeRewardsByPoolLastStored[poolId]
|
||||||
)
|
)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
@@ -208,17 +206,17 @@ contract MixinStakingPoolRewards is
|
|||||||
/// A delegator always depends on the cumulative reward for the current epoch.
|
/// 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.
|
/// 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 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.
|
/// @param isDependent is true iff adding a dependency. False, otherwise.
|
||||||
function _setCumulativeRewardDependenciesForDelegator(
|
function _setCumulativeRewardDependenciesForDelegator(
|
||||||
bytes32 poolId,
|
bytes32 poolId,
|
||||||
IStructs.StoredBalance memory delegatedStakeToPoolByOwner,
|
IStructs.StoredBalance memory _delegatedStakeToPoolByOwner,
|
||||||
bool isDependent
|
bool isDependent
|
||||||
)
|
)
|
||||||
private
|
private
|
||||||
{
|
{
|
||||||
// if this delegator is not yet initialized then there's no dependency to unset.
|
// if this delegator is not yet initialized then there's no dependency to unset.
|
||||||
if (!isDependent && !delegatedStakeToPoolByOwner.isInitialized) {
|
if (!isDependent && !_delegatedStakeToPoolByOwner.isInitialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,20 +224,20 @@ contract MixinStakingPoolRewards is
|
|||||||
IStructs.CumulativeRewardInfo memory mostRecentCumulativeRewardInfo = _getMostRecentCumulativeRewardInfo(poolId);
|
IStructs.CumulativeRewardInfo memory mostRecentCumulativeRewardInfo = _getMostRecentCumulativeRewardInfo(poolId);
|
||||||
|
|
||||||
// record dependency on `lastEpoch`
|
// record dependency on `lastEpoch`
|
||||||
if (delegatedStakeToPoolByOwner.currentEpoch > 0 && delegatedStakeToPoolByOwner.currentEpochBalance != 0) {
|
if (_delegatedStakeToPoolByOwner.currentEpoch > 0 && _delegatedStakeToPoolByOwner.currentEpochBalance != 0) {
|
||||||
_addOrRemoveDependencyOnCumulativeReward(
|
_addOrRemoveDependencyOnCumulativeReward(
|
||||||
poolId,
|
poolId,
|
||||||
uint256(delegatedStakeToPoolByOwner.currentEpoch).safeSub(1),
|
uint256(_delegatedStakeToPoolByOwner.currentEpoch).safeSub(1),
|
||||||
mostRecentCumulativeRewardInfo,
|
mostRecentCumulativeRewardInfo,
|
||||||
isDependent
|
isDependent
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// record dependency on current epoch.
|
// record dependency on current epoch.
|
||||||
if (delegatedStakeToPoolByOwner.currentEpochBalance != 0 || delegatedStakeToPoolByOwner.nextEpochBalance != 0) {
|
if (_delegatedStakeToPoolByOwner.currentEpochBalance != 0 || _delegatedStakeToPoolByOwner.nextEpochBalance != 0) {
|
||||||
_addOrRemoveDependencyOnCumulativeReward(
|
_addOrRemoveDependencyOnCumulativeReward(
|
||||||
poolId,
|
poolId,
|
||||||
delegatedStakeToPoolByOwner.currentEpoch,
|
_delegatedStakeToPoolByOwner.currentEpoch,
|
||||||
mostRecentCumulativeRewardInfo,
|
mostRecentCumulativeRewardInfo,
|
||||||
isDependent
|
isDependent
|
||||||
);
|
);
|
||||||
|
@@ -37,27 +37,6 @@ contract MixinScheduler is
|
|||||||
{
|
{
|
||||||
using LibSafeMath for uint256;
|
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.
|
/// @dev Returns the earliest end time in seconds of this epoch.
|
||||||
/// The next epoch can begin once this time is reached.
|
/// The next epoch can begin once this time is reached.
|
||||||
/// Epoch period = [startTimeInSeconds..endTimeInSeconds)
|
/// Epoch period = [startTimeInSeconds..endTimeInSeconds)
|
||||||
@@ -67,7 +46,7 @@ contract MixinScheduler is
|
|||||||
view
|
view
|
||||||
returns (uint256)
|
returns (uint256)
|
||||||
{
|
{
|
||||||
return getCurrentEpochStartTimeInSeconds().safeAdd(epochDurationInSeconds);
|
return currentEpochStartTimeInSeconds.safeAdd(epochDurationInSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Assert scheduler state before initializing it.
|
/// @dev Assert scheduler state before initializing it.
|
||||||
|
@@ -31,7 +31,7 @@ contract EthVault is
|
|||||||
using LibSafeMath for uint256;
|
using LibSafeMath for uint256;
|
||||||
|
|
||||||
// mapping from Owner to ETH balance
|
// mapping from Owner to ETH balance
|
||||||
mapping (address => uint256) internal balances;
|
mapping (address => uint256) public balances;
|
||||||
|
|
||||||
/// @dev Constructor.
|
/// @dev Constructor.
|
||||||
constructor()
|
constructor()
|
||||||
@@ -78,16 +78,6 @@ contract EthVault is
|
|||||||
return totalBalance;
|
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.
|
/// @dev Withdraw an `amount` of ETH to `owner` from the vault.
|
||||||
/// @param owner of ETH.
|
/// @param owner of ETH.
|
||||||
/// @param amount of ETH to withdraw.
|
/// @param amount of ETH to withdraw.
|
||||||
|
@@ -41,7 +41,6 @@ import "../immutable/MixinConstants.sol";
|
|||||||
/// perform withdrawals on behalf of its users.
|
/// perform withdrawals on behalf of its users.
|
||||||
contract StakingPoolRewardVault is
|
contract StakingPoolRewardVault is
|
||||||
IStakingPoolRewardVault,
|
IStakingPoolRewardVault,
|
||||||
IVaultCore,
|
|
||||||
MixinConstants,
|
MixinConstants,
|
||||||
MixinVaultCore
|
MixinVaultCore
|
||||||
{
|
{
|
||||||
@@ -49,10 +48,10 @@ contract StakingPoolRewardVault is
|
|||||||
using LibSafeDowncast for uint256;
|
using LibSafeDowncast for uint256;
|
||||||
|
|
||||||
// mapping from poolId to Pool metadata
|
// mapping from poolId to Pool metadata
|
||||||
mapping (bytes32 => Pool) internal poolById;
|
mapping (bytes32 => Pool) public poolById;
|
||||||
|
|
||||||
// address of ether vault
|
// address of ether vault
|
||||||
IEthVault internal ethVault;
|
IEthVault internal _ethVault;
|
||||||
|
|
||||||
/// @dev Fallback function. This contract is payable, but only by the staking contract.
|
/// @dev Fallback function. This contract is payable, but only by the staking contract.
|
||||||
function ()
|
function ()
|
||||||
@@ -71,7 +70,7 @@ contract StakingPoolRewardVault is
|
|||||||
external
|
external
|
||||||
onlyOwner
|
onlyOwner
|
||||||
{
|
{
|
||||||
ethVault = IEthVault(ethVaultAddress);
|
_ethVault = IEthVault(ethVaultAddress);
|
||||||
emit EthVaultChanged(ethVaultAddress);
|
emit EthVaultChanged(ethVaultAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,50 +242,6 @@ contract StakingPoolRewardVault is
|
|||||||
return poolById[poolId].operatorAddress;
|
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
|
/// @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.
|
/// pool operator and members of the pool based on the pool operator's share.
|
||||||
/// @param pool Pool struct with the balances to increment.
|
/// @param pool Pool struct with the balances to increment.
|
||||||
@@ -326,7 +281,7 @@ contract StakingPoolRewardVault is
|
|||||||
private
|
private
|
||||||
{
|
{
|
||||||
// sanity check on eth vault
|
// sanity check on eth vault
|
||||||
IEthVault _ethVault = ethVault;
|
IEthVault _ethVault = _ethVault;
|
||||||
if (address(_ethVault) == address(0)) {
|
if (address(_ethVault) == address(0)) {
|
||||||
LibRichErrors.rrevert(
|
LibRichErrors.rrevert(
|
||||||
LibStakingRichErrors.EthVaultNotSetError()
|
LibStakingRichErrors.EthVaultNotSetError()
|
||||||
|
@@ -40,31 +40,31 @@ contract ZrxVault is
|
|||||||
using LibSafeMath for uint256;
|
using LibSafeMath for uint256;
|
||||||
|
|
||||||
// mapping from Owner to ZRX balance
|
// mapping from Owner to ZRX balance
|
||||||
mapping (address => uint256) internal balances;
|
mapping (address => uint256) public balances;
|
||||||
|
|
||||||
// Zrx Asset Proxy
|
// Zrx Asset Proxy
|
||||||
IAssetProxy internal zrxAssetProxy;
|
IAssetProxy public zrxAssetProxy;
|
||||||
|
|
||||||
// Zrx Token
|
// Zrx Token
|
||||||
IERC20Token internal zrxToken;
|
IERC20Token internal _zrxToken;
|
||||||
|
|
||||||
// Asset data for the ERC20 Proxy
|
// Asset data for the ERC20 Proxy
|
||||||
bytes internal zrxAssetData;
|
bytes internal _zrxAssetData;
|
||||||
|
|
||||||
/// @dev Constructor.
|
/// @dev Constructor.
|
||||||
/// @param zrxProxyAddress Address of the 0x Zrx Proxy.
|
/// @param zrxProxyAddress Address of the 0x Zrx Proxy.
|
||||||
/// @param zrxTokenAddress Address of the Zrx Token.
|
/// @param _zrxTokenAddress Address of the Zrx Token.
|
||||||
constructor(
|
constructor(
|
||||||
address zrxProxyAddress,
|
address zrxProxyAddress,
|
||||||
address zrxTokenAddress
|
address _zrxTokenAddress
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
zrxAssetProxy = IAssetProxy(zrxProxyAddress);
|
zrxAssetProxy = IAssetProxy(zrxProxyAddress);
|
||||||
zrxToken = IERC20Token(zrxTokenAddress);
|
_zrxToken = IERC20Token(_zrxTokenAddress);
|
||||||
zrxAssetData = abi.encodeWithSelector(
|
_zrxAssetData = abi.encodeWithSelector(
|
||||||
IAssetData(address(0)).ERC20Token.selector,
|
IAssetData(address(0)).ERC20Token.selector,
|
||||||
zrxTokenAddress
|
_zrxTokenAddress
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ contract ZrxVault is
|
|||||||
|
|
||||||
// deposit ZRX from owner
|
// deposit ZRX from owner
|
||||||
zrxAssetProxy.transferFrom(
|
zrxAssetProxy.transferFrom(
|
||||||
zrxAssetData,
|
_zrxAssetData,
|
||||||
owner,
|
owner,
|
||||||
address(this),
|
address(this),
|
||||||
amount
|
amount
|
||||||
@@ -135,16 +135,6 @@ contract ZrxVault is
|
|||||||
return totalBalance;
|
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.
|
/// @dev Withdraw an `amount` of Zrx Tokens to `owner` from the vault.
|
||||||
/// @param owner of Zrx Tokens.
|
/// @param owner of Zrx Tokens.
|
||||||
/// @param amount of Zrx Tokens to withdraw.
|
/// @param amount of Zrx Tokens to withdraw.
|
||||||
@@ -160,7 +150,7 @@ contract ZrxVault is
|
|||||||
emit ZrxWithdrawnFromVault(msg.sender, owner, amount);
|
emit ZrxWithdrawnFromVault(msg.sender, owner, amount);
|
||||||
|
|
||||||
// withdraw ZRX to owner
|
// withdraw ZRX to owner
|
||||||
zrxToken.transfer(
|
_zrxToken.transfer(
|
||||||
owner,
|
owner,
|
||||||
amount
|
amount
|
||||||
);
|
);
|
||||||
|
@@ -55,22 +55,22 @@ contract TestStorageLayout is
|
|||||||
if sub(stakingContract_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(stakingContract_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
slot := add(slot, 1)
|
slot := add(slot, 1)
|
||||||
|
|
||||||
if sub(activeStakeByOwner_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(_activeStakeByOwner_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
slot := add(slot, 1)
|
slot := add(slot, 1)
|
||||||
|
|
||||||
if sub(inactiveStakeByOwner_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(_inactiveStakeByOwner_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
slot := add(slot, 1)
|
slot := add(slot, 1)
|
||||||
|
|
||||||
if sub(delegatedStakeByOwner_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(_delegatedStakeByOwner_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
slot := add(slot, 1)
|
slot := add(slot, 1)
|
||||||
|
|
||||||
if sub(delegatedStakeToPoolByOwner_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(_delegatedStakeToPoolByOwner_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
slot := add(slot, 1)
|
slot := add(slot, 1)
|
||||||
|
|
||||||
if sub(delegatedStakeByPoolId_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(_delegatedStakeByPoolId_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
slot := add(slot, 1)
|
slot := add(slot, 1)
|
||||||
|
|
||||||
if sub(withdrawableStakeByOwner_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(_withdrawableStakeByOwner_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
slot := add(slot, 1)
|
slot := add(slot, 1)
|
||||||
|
|
||||||
if sub(nextPoolId_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(nextPoolId_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
@@ -94,13 +94,13 @@ contract TestStorageLayout is
|
|||||||
if sub(activePoolsThisEpoch_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(activePoolsThisEpoch_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
slot := add(slot, 1)
|
slot := add(slot, 1)
|
||||||
|
|
||||||
if sub(cumulativeRewardsByPool_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(_cumulativeRewardsByPool_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
slot := add(slot, 1)
|
slot := add(slot, 1)
|
||||||
|
|
||||||
if sub(cumulativeRewardsByPoolReferenceCounter_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(_cumulativeRewardsByPoolReferenceCounter_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
slot := add(slot, 1)
|
slot := add(slot, 1)
|
||||||
|
|
||||||
if sub(cumulativeRewardsByPoolLastStored_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(_cumulativeRewardsByPoolLastStored_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
slot := add(slot, 1)
|
slot := add(slot, 1)
|
||||||
|
|
||||||
if sub(validExchanges_slot, slot) { revertIncorrectStorageSlot() }
|
if sub(validExchanges_slot, slot) { revertIncorrectStorageSlot() }
|
||||||
|
@@ -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|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": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@@ -23,7 +23,6 @@ import * as LibStakingRichErrors from '../generated-artifacts/LibStakingRichErro
|
|||||||
import * as MixinConstants from '../generated-artifacts/MixinConstants.json';
|
import * as MixinConstants from '../generated-artifacts/MixinConstants.json';
|
||||||
import * as MixinCumulativeRewards from '../generated-artifacts/MixinCumulativeRewards.json';
|
import * as MixinCumulativeRewards from '../generated-artifacts/MixinCumulativeRewards.json';
|
||||||
import * as MixinDeploymentConstants from '../generated-artifacts/MixinDeploymentConstants.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 MixinExchangeFees from '../generated-artifacts/MixinExchangeFees.json';
|
||||||
import * as MixinExchangeManager from '../generated-artifacts/MixinExchangeManager.json';
|
import * as MixinExchangeManager from '../generated-artifacts/MixinExchangeManager.json';
|
||||||
import * as MixinParams from '../generated-artifacts/MixinParams.json';
|
import * as MixinParams from '../generated-artifacts/MixinParams.json';
|
||||||
@@ -82,7 +81,6 @@ export const artifacts = {
|
|||||||
MixinStakeStorage: MixinStakeStorage as ContractArtifact,
|
MixinStakeStorage: MixinStakeStorage as ContractArtifact,
|
||||||
MixinZrxVault: MixinZrxVault as ContractArtifact,
|
MixinZrxVault: MixinZrxVault as ContractArtifact,
|
||||||
MixinCumulativeRewards: MixinCumulativeRewards as ContractArtifact,
|
MixinCumulativeRewards: MixinCumulativeRewards as ContractArtifact,
|
||||||
MixinEthVault: MixinEthVault as ContractArtifact,
|
|
||||||
MixinStakingPool: MixinStakingPool as ContractArtifact,
|
MixinStakingPool: MixinStakingPool as ContractArtifact,
|
||||||
MixinStakingPoolRewardVault: MixinStakingPoolRewardVault as ContractArtifact,
|
MixinStakingPoolRewardVault: MixinStakingPoolRewardVault as ContractArtifact,
|
||||||
MixinStakingPoolRewards: MixinStakingPoolRewards as ContractArtifact,
|
MixinStakingPoolRewards: MixinStakingPoolRewards as ContractArtifact,
|
||||||
|
@@ -21,7 +21,6 @@ export * from '../generated-wrappers/lib_staking_rich_errors';
|
|||||||
export * from '../generated-wrappers/mixin_constants';
|
export * from '../generated-wrappers/mixin_constants';
|
||||||
export * from '../generated-wrappers/mixin_cumulative_rewards';
|
export * from '../generated-wrappers/mixin_cumulative_rewards';
|
||||||
export * from '../generated-wrappers/mixin_deployment_constants';
|
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_fees';
|
||||||
export * from '../generated-wrappers/mixin_exchange_manager';
|
export * from '../generated-wrappers/mixin_exchange_manager';
|
||||||
export * from '../generated-wrappers/mixin_params';
|
export * from '../generated-wrappers/mixin_params';
|
||||||
|
@@ -34,14 +34,14 @@ blockchainTests('Epochs', env => {
|
|||||||
///// 2/3 Validate Initial Epoch & TimeLock Period /////
|
///// 2/3 Validate Initial Epoch & TimeLock Period /////
|
||||||
{
|
{
|
||||||
// epoch
|
// epoch
|
||||||
const currentEpoch = await stakingApiWrapper.stakingContract.getCurrentEpoch.callAsync();
|
const currentEpoch = await stakingApiWrapper.stakingContract.currentEpoch.callAsync();
|
||||||
expect(currentEpoch).to.be.bignumber.equal(stakingConstants.INITIAL_EPOCH);
|
expect(currentEpoch).to.be.bignumber.equal(stakingConstants.INITIAL_EPOCH);
|
||||||
}
|
}
|
||||||
///// 3/3 Increment Epoch (TimeLock Should Not Increment) /////
|
///// 3/3 Increment Epoch (TimeLock Should Not Increment) /////
|
||||||
await stakingApiWrapper.utils.skipToNextEpochAsync();
|
await stakingApiWrapper.utils.skipToNextEpochAsync();
|
||||||
{
|
{
|
||||||
// epoch
|
// 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));
|
expect(currentEpoch).to.be.bignumber.equal(stakingConstants.INITIAL_EPOCH.plus(1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -21,7 +21,6 @@
|
|||||||
"generated-artifacts/MixinConstants.json",
|
"generated-artifacts/MixinConstants.json",
|
||||||
"generated-artifacts/MixinCumulativeRewards.json",
|
"generated-artifacts/MixinCumulativeRewards.json",
|
||||||
"generated-artifacts/MixinDeploymentConstants.json",
|
"generated-artifacts/MixinDeploymentConstants.json",
|
||||||
"generated-artifacts/MixinEthVault.json",
|
|
||||||
"generated-artifacts/MixinExchangeFees.json",
|
"generated-artifacts/MixinExchangeFees.json",
|
||||||
"generated-artifacts/MixinExchangeManager.json",
|
"generated-artifacts/MixinExchangeManager.json",
|
||||||
"generated-artifacts/MixinParams.json",
|
"generated-artifacts/MixinParams.json",
|
||||||
|
Reference in New Issue
Block a user