Make wethAssetProxy and zrxVault deployment constants
This commit is contained in:
		@@ -56,22 +56,14 @@ contract Staking is
 | 
			
		||||
    /// @dev Initialize storage owned by this contract.
 | 
			
		||||
    ///      This function should not be called directly.
 | 
			
		||||
    ///      The StakingProxy contract will call it in `attachStakingContract()`.
 | 
			
		||||
    /// @param _wethProxyAddress The address that can transfer WETH for fees.
 | 
			
		||||
    /// @param _zrxVaultAddress Address of the ZrxVault contract.
 | 
			
		||||
    function init(
 | 
			
		||||
        address _wethProxyAddress,
 | 
			
		||||
        address _zrxVaultAddress
 | 
			
		||||
    )
 | 
			
		||||
    function init()
 | 
			
		||||
        public
 | 
			
		||||
        onlyAuthorized
 | 
			
		||||
    {
 | 
			
		||||
        // DANGER! When performing upgrades, take care to modify this logic
 | 
			
		||||
        // to prevent accidentally clearing prior state.
 | 
			
		||||
        _initMixinScheduler();
 | 
			
		||||
        _initMixinParams(
 | 
			
		||||
            _wethProxyAddress,
 | 
			
		||||
            _zrxVaultAddress
 | 
			
		||||
        );
 | 
			
		||||
        _initMixinParams();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev This function will fail if the storage layout of this contract deviates from
 | 
			
		||||
 
 | 
			
		||||
@@ -36,23 +36,15 @@ contract StakingProxy is
 | 
			
		||||
    /// @dev Constructor.
 | 
			
		||||
    /// @param _stakingContract Staking contract to delegate calls to.
 | 
			
		||||
    /// @param _readOnlyProxy The address of the read only proxy.
 | 
			
		||||
    /// @param _wethProxyAddress The address that can transfer WETH for fees.
 | 
			
		||||
    /// @param _zrxVaultAddress Address of the ZrxVault contract.
 | 
			
		||||
    constructor(
 | 
			
		||||
        address _stakingContract,
 | 
			
		||||
        address _readOnlyProxy,
 | 
			
		||||
        address _wethProxyAddress,
 | 
			
		||||
        address _zrxVaultAddress
 | 
			
		||||
        address _readOnlyProxy
 | 
			
		||||
    )
 | 
			
		||||
        public
 | 
			
		||||
        MixinStorage()
 | 
			
		||||
    {
 | 
			
		||||
        readOnlyProxy = _readOnlyProxy;
 | 
			
		||||
        _attachStakingContract(
 | 
			
		||||
            _stakingContract,
 | 
			
		||||
            _wethProxyAddress,
 | 
			
		||||
            _zrxVaultAddress
 | 
			
		||||
        );
 | 
			
		||||
        _attachStakingContract(_stakingContract);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Delegates calls to the staking contract, if it is set.
 | 
			
		||||
@@ -70,23 +62,11 @@ contract StakingProxy is
 | 
			
		||||
    /// @dev Attach a staking contract; future calls will be delegated to the staking contract.
 | 
			
		||||
    /// Note that this is callable only by this contract's owner.
 | 
			
		||||
    /// @param _stakingContract Address of staking contract.
 | 
			
		||||
    /// @param _wethProxyAddress The address that can transfer WETH for fees.
 | 
			
		||||
    ///        Use address in storage if NIL_ADDRESS is passed in.
 | 
			
		||||
    /// @param _zrxVaultAddress Address of the ZrxVault contract.
 | 
			
		||||
    ///        Use address in storage if NIL_ADDRESS is passed in.
 | 
			
		||||
    function attachStakingContract(
 | 
			
		||||
        address _stakingContract,
 | 
			
		||||
        address _wethProxyAddress,
 | 
			
		||||
        address _zrxVaultAddress
 | 
			
		||||
    )
 | 
			
		||||
    function attachStakingContract(address _stakingContract)
 | 
			
		||||
        external
 | 
			
		||||
        onlyAuthorized
 | 
			
		||||
    {
 | 
			
		||||
        _attachStakingContract(
 | 
			
		||||
            _stakingContract,
 | 
			
		||||
            _wethProxyAddress == NIL_ADDRESS ? address(wethAssetProxy) : _wethProxyAddress,
 | 
			
		||||
            _zrxVaultAddress == NIL_ADDRESS ? address(zrxVault) : _zrxVaultAddress
 | 
			
		||||
        );
 | 
			
		||||
        _attachStakingContract(_stakingContract);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Detach the current staking contract.
 | 
			
		||||
@@ -202,32 +182,11 @@ contract StakingProxy is
 | 
			
		||||
                    LibStakingRichErrors.InvalidParamValueErrorCode.InvalidMinimumPoolStake
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // ERC20Proxy and Vault contract addresses must always be initialized
 | 
			
		||||
        if (address(wethAssetProxy) == NIL_ADDRESS) {
 | 
			
		||||
            LibRichErrors.rrevert(
 | 
			
		||||
                LibStakingRichErrors.InvalidParamValueError(
 | 
			
		||||
                    LibStakingRichErrors.InvalidParamValueErrorCode.InvalidWethProxyAddress
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (address(zrxVault) == NIL_ADDRESS) {
 | 
			
		||||
            LibRichErrors.rrevert(
 | 
			
		||||
                LibStakingRichErrors.InvalidParamValueError(
 | 
			
		||||
                    LibStakingRichErrors.InvalidParamValueErrorCode.InvalidZrxVaultAddress
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Attach a staking contract; future calls will be delegated to the staking contract.
 | 
			
		||||
    /// @param _stakingContract Address of staking contract.
 | 
			
		||||
    /// @param _wethProxyAddress The address that can transfer WETH for fees.
 | 
			
		||||
    /// @param _zrxVaultAddress Address of the ZrxVault contract.
 | 
			
		||||
    function _attachStakingContract(
 | 
			
		||||
        address _stakingContract,
 | 
			
		||||
        address _wethProxyAddress,
 | 
			
		||||
        address _zrxVaultAddress
 | 
			
		||||
    )
 | 
			
		||||
    function _attachStakingContract(address _stakingContract)
 | 
			
		||||
        internal
 | 
			
		||||
    {
 | 
			
		||||
        // Attach the staking contract
 | 
			
		||||
@@ -236,11 +195,7 @@ contract StakingProxy is
 | 
			
		||||
 | 
			
		||||
        // Call `init()` on the staking contract to initialize storage.
 | 
			
		||||
        (bool didInitSucceed, bytes memory initReturnData) = stakingContract.delegatecall(
 | 
			
		||||
            abi.encodeWithSelector(
 | 
			
		||||
                IStorageInit(0).init.selector,
 | 
			
		||||
                _wethProxyAddress,
 | 
			
		||||
                _zrxVaultAddress
 | 
			
		||||
            )
 | 
			
		||||
            abi.encodeWithSelector(IStorageInit(0).init.selector)
 | 
			
		||||
        );
 | 
			
		||||
        if (!didInitSucceed) {
 | 
			
		||||
            assembly {
 | 
			
		||||
 
 | 
			
		||||
@@ -69,7 +69,7 @@ contract MixinExchangeFees is
 | 
			
		||||
        // Transfer the protocol fee to this address if it should be paid in
 | 
			
		||||
        // WETH.
 | 
			
		||||
        if (msg.value == 0) {
 | 
			
		||||
            wethAssetProxy.transferFrom(
 | 
			
		||||
            _getWethAssetProxy().transferFrom(
 | 
			
		||||
                _getWethAssetData(),
 | 
			
		||||
                payerAddress,
 | 
			
		||||
                address(this),
 | 
			
		||||
 
 | 
			
		||||
@@ -18,11 +18,13 @@
 | 
			
		||||
 | 
			
		||||
pragma solidity ^0.5.9;
 | 
			
		||||
 | 
			
		||||
import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetProxy.sol";
 | 
			
		||||
import "@0x/contracts-erc20/contracts/src/interfaces/IEtherToken.sol";
 | 
			
		||||
import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetData.sol";
 | 
			
		||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
 | 
			
		||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
 | 
			
		||||
import "../libs/LibStakingRichErrors.sol";
 | 
			
		||||
import "../interfaces/IZrxVault.sol";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// solhint-disable separate-by-one-line-in-contract
 | 
			
		||||
@@ -50,6 +52,10 @@ contract MixinDeploymentConstants {
 | 
			
		||||
    // Ropsten & Rinkeby Weth Asset Data
 | 
			
		||||
    // bytes constant internal WETH_ASSET_DATA = hex"f47261b0000000000000000000000000c778417e063141139fce010982780140aa0cd5ab";
 | 
			
		||||
 | 
			
		||||
    // @TODO SET THESE VALUES FOR DEPLOYMENT
 | 
			
		||||
    address constant public WETH_ASSET_PROXY_ADDRESS = address(1);
 | 
			
		||||
    address constant public ZRX_VAULT_ADDRESS = address(1);
 | 
			
		||||
 | 
			
		||||
    /// @dev Ensures that the WETH_ASSET_DATA is correct.
 | 
			
		||||
    constructor()
 | 
			
		||||
        public
 | 
			
		||||
@@ -88,4 +94,22 @@ contract MixinDeploymentConstants {
 | 
			
		||||
        wethAssetData = WETH_ASSET_DATA;
 | 
			
		||||
        return wethAssetData;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function _getWethAssetProxy()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IAssetProxy wethAssetProxy)
 | 
			
		||||
    {
 | 
			
		||||
        wethAssetProxy = IAssetProxy(WETH_ASSET_PROXY_ADDRESS);
 | 
			
		||||
        return wethAssetProxy;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function _getZrxVault()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IZrxVault zrxVault)
 | 
			
		||||
    {
 | 
			
		||||
        zrxVault = IZrxVault(ZRX_VAULT_ADDRESS);
 | 
			
		||||
        return zrxVault;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -33,9 +33,6 @@ contract MixinStorage is
 | 
			
		||||
    MixinConstants,
 | 
			
		||||
    Authorizable
 | 
			
		||||
{
 | 
			
		||||
    // WETH Asset Proxy
 | 
			
		||||
    IAssetProxy public wethAssetProxy;
 | 
			
		||||
 | 
			
		||||
    // address of staking contract
 | 
			
		||||
    address public stakingContract;
 | 
			
		||||
 | 
			
		||||
@@ -101,9 +98,6 @@ contract MixinStorage is
 | 
			
		||||
    // registered 0x Exchange contracts
 | 
			
		||||
    mapping (address => bool) public validExchanges;
 | 
			
		||||
 | 
			
		||||
    // ZRX vault (stores staked ZRX)
 | 
			
		||||
    IZrxVault public zrxVault;
 | 
			
		||||
 | 
			
		||||
    /* Tweakable parameters */
 | 
			
		||||
 | 
			
		||||
    // Minimum seconds between epochs.
 | 
			
		||||
 
 | 
			
		||||
@@ -95,17 +95,13 @@ interface IStakingEvents {
 | 
			
		||||
    /// @param maximumMakersInPool Maximum number of maker addresses allowed to be registered to a pool.
 | 
			
		||||
    /// @param cobbDouglasAlphaNumerator Numerator for cobb douglas alpha factor.
 | 
			
		||||
    /// @param cobbDouglasAlphaDenominator Denominator for cobb douglas alpha factor.
 | 
			
		||||
    /// @param wethProxyAddress The address that can transfer WETH for fees.
 | 
			
		||||
    /// @param zrxVaultAddress Address of the ZrxVault contract.
 | 
			
		||||
    event ParamsSet(
 | 
			
		||||
        uint256 epochDurationInSeconds,
 | 
			
		||||
        uint32 rewardDelegatedStakeWeight,
 | 
			
		||||
        uint256 minimumPoolStake,
 | 
			
		||||
        uint256 maximumMakersInPool,
 | 
			
		||||
        uint256 cobbDouglasAlphaNumerator,
 | 
			
		||||
        uint256 cobbDouglasAlphaDenominator,
 | 
			
		||||
        address wethProxyAddress,
 | 
			
		||||
        address zrxVaultAddress
 | 
			
		||||
        uint256 cobbDouglasAlphaDenominator
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    /// @dev Emitted by MixinStakingPool when a new pool is created.
 | 
			
		||||
 
 | 
			
		||||
@@ -45,15 +45,7 @@ interface IStakingProxy /* is IStaking */
 | 
			
		||||
    /// @dev Attach a staking contract; future calls will be delegated to the staking contract.
 | 
			
		||||
    /// Note that this is callable only by this contract's owner.
 | 
			
		||||
    /// @param _stakingContract Address of staking contract.
 | 
			
		||||
    /// @param _wethProxyAddress The address that can transfer WETH for fees.
 | 
			
		||||
    ///        Use address in storage if NIL_ADDRESS is passed in.
 | 
			
		||||
    /// @param _zrxVaultAddress Address of the ZrxVault contract.
 | 
			
		||||
    ///        Use address in storage if NIL_ADDRESS is passed in.
 | 
			
		||||
    function attachStakingContract(
 | 
			
		||||
        address _stakingContract,
 | 
			
		||||
        address _wethProxyAddress,
 | 
			
		||||
        address _zrxVaultAddress
 | 
			
		||||
    )
 | 
			
		||||
    function attachStakingContract(address _stakingContract)
 | 
			
		||||
        external;
 | 
			
		||||
 | 
			
		||||
    /// @dev Detach the current staking contract.
 | 
			
		||||
 
 | 
			
		||||
@@ -26,11 +26,6 @@ import "../interfaces/IStructs.sol";
 | 
			
		||||
 | 
			
		||||
interface IStorage {
 | 
			
		||||
 | 
			
		||||
    function wethAssetProxy()
 | 
			
		||||
        external
 | 
			
		||||
        view
 | 
			
		||||
        returns (IAssetProxy);
 | 
			
		||||
 | 
			
		||||
    function stakingContract()
 | 
			
		||||
        external
 | 
			
		||||
        view
 | 
			
		||||
@@ -81,11 +76,6 @@ interface IStorage {
 | 
			
		||||
        view
 | 
			
		||||
        returns (bool);
 | 
			
		||||
 | 
			
		||||
    function zrxVault()
 | 
			
		||||
        external
 | 
			
		||||
        view
 | 
			
		||||
        returns (IZrxVault);
 | 
			
		||||
 | 
			
		||||
    function epochDurationInSeconds()
 | 
			
		||||
        external
 | 
			
		||||
        view
 | 
			
		||||
 
 | 
			
		||||
@@ -22,11 +22,6 @@ pragma solidity ^0.5.9;
 | 
			
		||||
interface IStorageInit {
 | 
			
		||||
 | 
			
		||||
    /// @dev Initialize storage owned by this contract.
 | 
			
		||||
    /// @param _wethProxyAddress The address that can transfer WETH for fees.
 | 
			
		||||
    /// @param _zrxVaultAddress Address of the ZrxVault contract.
 | 
			
		||||
    function init(
 | 
			
		||||
        address _wethProxyAddress,
 | 
			
		||||
        address _zrxVaultAddress
 | 
			
		||||
    )
 | 
			
		||||
    function init()
 | 
			
		||||
        external;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -43,8 +43,6 @@ library LibStakingRichErrors {
 | 
			
		||||
        InvalidRewardDelegatedStakeWeight,
 | 
			
		||||
        InvalidMaximumMakersInPool,
 | 
			
		||||
        InvalidMinimumPoolStake,
 | 
			
		||||
        InvalidWethProxyAddress,
 | 
			
		||||
        InvalidZrxVaultAddress,
 | 
			
		||||
        InvalidEpochDuration
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -50,7 +50,7 @@ contract MixinStake is
 | 
			
		||||
        address payable owner = msg.sender;
 | 
			
		||||
 | 
			
		||||
        // deposit equivalent amount of ZRX into vault
 | 
			
		||||
        zrxVault.depositFrom(owner, amount);
 | 
			
		||||
        _getZrxVault().depositFrom(owner, amount);
 | 
			
		||||
 | 
			
		||||
        // mint stake
 | 
			
		||||
        _incrementCurrentAndNextBalance(_activeStakeByOwner[owner], amount);
 | 
			
		||||
@@ -96,7 +96,7 @@ contract MixinStake is
 | 
			
		||||
            currentWithdrawableStake.safeSub(amount);
 | 
			
		||||
 | 
			
		||||
        // withdraw equivalent amount of ZRX from vault
 | 
			
		||||
        zrxVault.withdrawFrom(owner, amount);
 | 
			
		||||
        _getZrxVault().withdrawFrom(owner, amount);
 | 
			
		||||
 | 
			
		||||
        // emit stake event
 | 
			
		||||
        emit Unstake(
 | 
			
		||||
 
 | 
			
		||||
@@ -92,7 +92,7 @@ contract MixinStakeBalances is
 | 
			
		||||
        view
 | 
			
		||||
        returns (uint256)
 | 
			
		||||
    {
 | 
			
		||||
        return zrxVault.balanceOf(owner);
 | 
			
		||||
        return _getZrxVault().balanceOf(owner);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Returns the active stake for a given owner.
 | 
			
		||||
 
 | 
			
		||||
@@ -18,12 +18,9 @@
 | 
			
		||||
 | 
			
		||||
pragma solidity ^0.5.9;
 | 
			
		||||
 | 
			
		||||
import "@0x/contracts-erc20/contracts/src/interfaces/IEtherToken.sol";
 | 
			
		||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
 | 
			
		||||
import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetProxy.sol";
 | 
			
		||||
import "../immutable/MixinStorage.sol";
 | 
			
		||||
import "../interfaces/IStakingEvents.sol";
 | 
			
		||||
import "../interfaces/IZrxVault.sol";
 | 
			
		||||
import "../libs/LibStakingRichErrors.sol";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -40,17 +37,13 @@ contract MixinParams is
 | 
			
		||||
    /// @param _maximumMakersInPool Maximum number of maker addresses allowed to be registered to a pool.
 | 
			
		||||
    /// @param _cobbDouglasAlphaNumerator Numerator for cobb douglas alpha factor.
 | 
			
		||||
    /// @param _cobbDouglasAlphaDenominator Denominator for cobb douglas alpha factor.
 | 
			
		||||
    /// @param _wethProxyAddress The address that can transfer WETH for fees.
 | 
			
		||||
    /// @param _zrxVaultAddress Address of the ZrxVault contract.
 | 
			
		||||
    function setParams(
 | 
			
		||||
        uint256 _epochDurationInSeconds,
 | 
			
		||||
        uint32 _rewardDelegatedStakeWeight,
 | 
			
		||||
        uint256 _minimumPoolStake,
 | 
			
		||||
        uint256 _maximumMakersInPool,
 | 
			
		||||
        uint32 _cobbDouglasAlphaNumerator,
 | 
			
		||||
        uint32 _cobbDouglasAlphaDenominator,
 | 
			
		||||
        address _wethProxyAddress,
 | 
			
		||||
        address _zrxVaultAddress
 | 
			
		||||
        uint32 _cobbDouglasAlphaDenominator
 | 
			
		||||
    )
 | 
			
		||||
        external
 | 
			
		||||
        onlyAuthorized
 | 
			
		||||
@@ -61,9 +54,7 @@ contract MixinParams is
 | 
			
		||||
            _minimumPoolStake,
 | 
			
		||||
            _maximumMakersInPool,
 | 
			
		||||
            _cobbDouglasAlphaNumerator,
 | 
			
		||||
            _cobbDouglasAlphaDenominator,
 | 
			
		||||
            _wethProxyAddress,
 | 
			
		||||
            _zrxVaultAddress
 | 
			
		||||
            _cobbDouglasAlphaDenominator
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -74,8 +65,6 @@ contract MixinParams is
 | 
			
		||||
    /// @return _maximumMakersInPool Maximum number of maker addresses allowed to be registered to a pool.
 | 
			
		||||
    /// @return _cobbDouglasAlphaNumerator Numerator for cobb douglas alpha factor.
 | 
			
		||||
    /// @return _cobbDouglasAlphaDenominator Denominator for cobb douglas alpha factor.
 | 
			
		||||
    /// @return _wethProxyAddress The address that can transfer WETH for fees.
 | 
			
		||||
    /// @return _zrxVaultAddress Address of the ZrxVault contract.
 | 
			
		||||
    function getParams()
 | 
			
		||||
        external
 | 
			
		||||
        view
 | 
			
		||||
@@ -85,9 +74,7 @@ contract MixinParams is
 | 
			
		||||
            uint256 _minimumPoolStake,
 | 
			
		||||
            uint256 _maximumMakersInPool,
 | 
			
		||||
            uint32 _cobbDouglasAlphaNumerator,
 | 
			
		||||
            uint32 _cobbDouglasAlphaDenominator,
 | 
			
		||||
            address _wethProxyAddress,
 | 
			
		||||
            address _zrxVaultAddress
 | 
			
		||||
            uint32 _cobbDouglasAlphaDenominator
 | 
			
		||||
        )
 | 
			
		||||
    {
 | 
			
		||||
        _epochDurationInSeconds = epochDurationInSeconds;
 | 
			
		||||
@@ -96,17 +83,10 @@ contract MixinParams is
 | 
			
		||||
        _maximumMakersInPool = maximumMakersInPool;
 | 
			
		||||
        _cobbDouglasAlphaNumerator = cobbDouglasAlphaNumerator;
 | 
			
		||||
        _cobbDouglasAlphaDenominator = cobbDouglasAlphaDenominator;
 | 
			
		||||
        _wethProxyAddress = address(wethAssetProxy);
 | 
			
		||||
        _zrxVaultAddress = address(zrxVault);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Initialize storage belonging to this mixin.
 | 
			
		||||
    /// @param _wethProxyAddress The address that can transfer WETH for fees.
 | 
			
		||||
    /// @param _zrxVaultAddress Address of the ZrxVault contract.
 | 
			
		||||
    function _initMixinParams(
 | 
			
		||||
        address _wethProxyAddress,
 | 
			
		||||
        address _zrxVaultAddress
 | 
			
		||||
    )
 | 
			
		||||
    function _initMixinParams()
 | 
			
		||||
        internal
 | 
			
		||||
    {
 | 
			
		||||
        // Ensure state is uninitialized.
 | 
			
		||||
@@ -120,9 +100,7 @@ contract MixinParams is
 | 
			
		||||
            100 * MIN_TOKEN_VALUE,         // minimumPoolStake
 | 
			
		||||
            10,                            // maximumMakersInPool
 | 
			
		||||
            1,                             // cobbDouglasAlphaNumerator
 | 
			
		||||
            2,                             // cobbDouglasAlphaDenominator
 | 
			
		||||
            _wethProxyAddress,
 | 
			
		||||
            _zrxVaultAddress
 | 
			
		||||
            2                              // cobbDouglasAlphaDenominator
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -136,9 +114,7 @@ contract MixinParams is
 | 
			
		||||
            minimumPoolStake != 0 &&
 | 
			
		||||
            maximumMakersInPool != 0 &&
 | 
			
		||||
            cobbDouglasAlphaNumerator != 0 &&
 | 
			
		||||
            cobbDouglasAlphaDenominator != 0 &&
 | 
			
		||||
            address(wethAssetProxy) != NIL_ADDRESS &&
 | 
			
		||||
            address(zrxVault) != NIL_ADDRESS
 | 
			
		||||
            cobbDouglasAlphaDenominator != 0
 | 
			
		||||
        ) {
 | 
			
		||||
            LibRichErrors.rrevert(
 | 
			
		||||
                LibStakingRichErrors.InitializationError(
 | 
			
		||||
@@ -155,17 +131,13 @@ contract MixinParams is
 | 
			
		||||
    /// @param _maximumMakersInPool Maximum number of maker addresses allowed to be registered to a pool.
 | 
			
		||||
    /// @param _cobbDouglasAlphaNumerator Numerator for cobb douglas alpha factor.
 | 
			
		||||
    /// @param _cobbDouglasAlphaDenominator Denominator for cobb douglas alpha factor.
 | 
			
		||||
    /// @param _wethProxyAddress The address that can transfer WETH for fees.
 | 
			
		||||
    /// @param _zrxVaultAddress Address of the ZrxVault contract.
 | 
			
		||||
    function _setParams(
 | 
			
		||||
        uint256 _epochDurationInSeconds,
 | 
			
		||||
        uint32 _rewardDelegatedStakeWeight,
 | 
			
		||||
        uint256 _minimumPoolStake,
 | 
			
		||||
        uint256 _maximumMakersInPool,
 | 
			
		||||
        uint32 _cobbDouglasAlphaNumerator,
 | 
			
		||||
        uint32 _cobbDouglasAlphaDenominator,
 | 
			
		||||
        address _wethProxyAddress,
 | 
			
		||||
        address _zrxVaultAddress
 | 
			
		||||
        uint32 _cobbDouglasAlphaDenominator
 | 
			
		||||
    )
 | 
			
		||||
        private
 | 
			
		||||
    {
 | 
			
		||||
@@ -175,8 +147,6 @@ contract MixinParams is
 | 
			
		||||
        maximumMakersInPool = _maximumMakersInPool;
 | 
			
		||||
        cobbDouglasAlphaNumerator = _cobbDouglasAlphaNumerator;
 | 
			
		||||
        cobbDouglasAlphaDenominator = _cobbDouglasAlphaDenominator;
 | 
			
		||||
        wethAssetProxy = IAssetProxy(_wethProxyAddress);
 | 
			
		||||
        zrxVault = IZrxVault(_zrxVaultAddress);
 | 
			
		||||
 | 
			
		||||
        emit ParamsSet(
 | 
			
		||||
            _epochDurationInSeconds,
 | 
			
		||||
@@ -184,9 +154,7 @@ contract MixinParams is
 | 
			
		||||
            _minimumPoolStake,
 | 
			
		||||
            _maximumMakersInPool,
 | 
			
		||||
            _cobbDouglasAlphaNumerator,
 | 
			
		||||
            _cobbDouglasAlphaDenominator,
 | 
			
		||||
            _wethProxyAddress,
 | 
			
		||||
            _zrxVaultAddress
 | 
			
		||||
            _cobbDouglasAlphaDenominator
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -32,15 +32,11 @@ contract TestAssertStorageParams is
 | 
			
		||||
        uint256 maximumMakersInPool;
 | 
			
		||||
        uint32 cobbDouglasAlphaNumerator;
 | 
			
		||||
        uint32 cobbDouglasAlphaDenominator;
 | 
			
		||||
        address wethProxyAddress;
 | 
			
		||||
        address zrxVaultAddress;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    constructor()
 | 
			
		||||
        public
 | 
			
		||||
        StakingProxy(
 | 
			
		||||
            NIL_ADDRESS,
 | 
			
		||||
            NIL_ADDRESS,
 | 
			
		||||
            NIL_ADDRESS,
 | 
			
		||||
            NIL_ADDRESS
 | 
			
		||||
        )
 | 
			
		||||
@@ -55,12 +51,10 @@ contract TestAssertStorageParams is
 | 
			
		||||
        maximumMakersInPool = params.maximumMakersInPool;
 | 
			
		||||
        cobbDouglasAlphaNumerator = params.cobbDouglasAlphaNumerator;
 | 
			
		||||
        cobbDouglasAlphaDenominator = params.cobbDouglasAlphaDenominator;
 | 
			
		||||
        wethAssetProxy = IAssetProxy(params.wethProxyAddress);
 | 
			
		||||
        zrxVault = IZrxVault(params.zrxVaultAddress);
 | 
			
		||||
        _assertValidStorageParams();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function _attachStakingContract(address, address, address)
 | 
			
		||||
    function _attachStakingContract(address)
 | 
			
		||||
        internal
 | 
			
		||||
    {}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -35,9 +35,19 @@ contract TestCumulativeRewardTracking is
 | 
			
		||||
        uint256 epoch
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    constructor(address wethAddress) public TestStaking(wethAddress) {}
 | 
			
		||||
    constructor(
 | 
			
		||||
        address wethAddress,
 | 
			
		||||
        address zrxVaultAddress
 | 
			
		||||
    )
 | 
			
		||||
        public
 | 
			
		||||
        TestStaking(
 | 
			
		||||
            wethAddress,
 | 
			
		||||
            address(0),
 | 
			
		||||
            zrxVaultAddress
 | 
			
		||||
        )
 | 
			
		||||
    {}
 | 
			
		||||
 | 
			
		||||
    function init(address, address) public {}
 | 
			
		||||
    function init() public {}
 | 
			
		||||
 | 
			
		||||
    function _forceSetCumulativeReward(
 | 
			
		||||
        bytes32 poolId,
 | 
			
		||||
 
 | 
			
		||||
@@ -39,13 +39,8 @@ contract TestDelegatorRewards is
 | 
			
		||||
        uint256 membersStake;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    constructor()
 | 
			
		||||
        public
 | 
			
		||||
    {
 | 
			
		||||
        init(
 | 
			
		||||
            address(1),
 | 
			
		||||
            address(1)
 | 
			
		||||
        );
 | 
			
		||||
    constructor() public {
 | 
			
		||||
        init();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    mapping (uint256 => mapping (bytes32 => UnfinalizedPoolReward)) private
 | 
			
		||||
 
 | 
			
		||||
@@ -56,10 +56,7 @@ contract TestFinalizer is
 | 
			
		||||
    )
 | 
			
		||||
        public
 | 
			
		||||
    {
 | 
			
		||||
        init(
 | 
			
		||||
            address(1),
 | 
			
		||||
            address(1)
 | 
			
		||||
        );
 | 
			
		||||
        init();
 | 
			
		||||
        _operatorRewardsReceiver = operatorRewardsReceiver;
 | 
			
		||||
        _membersRewardsReceiver = membersRewardsReceiver;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -35,15 +35,7 @@ contract TestInitTarget is
 | 
			
		||||
    // `address(this)` of the last `init()` call.
 | 
			
		||||
    address private _initThisAddress = address(0);
 | 
			
		||||
 | 
			
		||||
    event InitAddresses(
 | 
			
		||||
        address wethProxyAddress,
 | 
			
		||||
        address zrxVaultAddress          
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    function init(
 | 
			
		||||
        address wethProxyAddress,
 | 
			
		||||
        address zrxVaultAddress           
 | 
			
		||||
    )
 | 
			
		||||
    function init()
 | 
			
		||||
        external
 | 
			
		||||
    {
 | 
			
		||||
        if (SHOULD_REVERT_ADDRESS.balance != 0) {
 | 
			
		||||
@@ -52,10 +44,6 @@ contract TestInitTarget is
 | 
			
		||||
        _initCounter += 1;
 | 
			
		||||
        _initSender = msg.sender;
 | 
			
		||||
        _initThisAddress = address(this);
 | 
			
		||||
        emit InitAddresses(
 | 
			
		||||
            wethProxyAddress,
 | 
			
		||||
            zrxVaultAddress
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function getInitState()
 | 
			
		||||
 
 | 
			
		||||
@@ -44,12 +44,7 @@ contract TestProtocolFees is
 | 
			
		||||
    mapping(address => bytes32) private _makersToTestPoolIds;
 | 
			
		||||
 | 
			
		||||
    constructor(address exchangeAddress) public {
 | 
			
		||||
        init(
 | 
			
		||||
            // Use this contract as the ERC20Proxy.
 | 
			
		||||
            address(this),
 | 
			
		||||
            // vault addresses must be non-zero
 | 
			
		||||
            address(1)
 | 
			
		||||
        );
 | 
			
		||||
        init();
 | 
			
		||||
        validExchanges[exchangeAddress] = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -135,4 +130,13 @@ contract TestProtocolFees is
 | 
			
		||||
            nextEpochBalance: pool.operatorStake
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function _getWethAssetProxy()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IAssetProxy wethAssetProxy)
 | 
			
		||||
    {
 | 
			
		||||
        wethAssetProxy = IAssetProxy(address(this));
 | 
			
		||||
        return wethAssetProxy;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,9 +27,19 @@ contract TestStaking is
 | 
			
		||||
    Staking
 | 
			
		||||
{
 | 
			
		||||
    address public testWethAddress;
 | 
			
		||||
    address public testWethAssetProxyAddress;
 | 
			
		||||
    address public testZrxVaultAddress;
 | 
			
		||||
 | 
			
		||||
    constructor(address wethAddress) public {
 | 
			
		||||
    constructor(
 | 
			
		||||
        address wethAddress,
 | 
			
		||||
        address wethAssetProxyAddress,
 | 
			
		||||
        address zrxVaultAddress
 | 
			
		||||
    )
 | 
			
		||||
        public
 | 
			
		||||
    {
 | 
			
		||||
        testWethAddress = wethAddress;
 | 
			
		||||
        testWethAssetProxyAddress = wethAssetProxyAddress;
 | 
			
		||||
        testZrxVaultAddress = zrxVaultAddress;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Overridden to use testWethAddress;
 | 
			
		||||
@@ -56,4 +66,24 @@ contract TestStaking is
 | 
			
		||||
            wethAddress
 | 
			
		||||
        ); 
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function _getWethAssetProxy()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IAssetProxy wethAssetProxy)
 | 
			
		||||
    {
 | 
			
		||||
        address wethAssetProxyAddress = TestStaking(address(uint160(stakingContract))).testWethAssetProxyAddress();
 | 
			
		||||
        wethAssetProxy = IAssetProxy(wethAssetProxyAddress);
 | 
			
		||||
        return wethAssetProxy;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function _getZrxVault()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
        returns (IZrxVault zrxVault)
 | 
			
		||||
    {
 | 
			
		||||
        address zrxVaultAddress = TestStaking(address(uint160(stakingContract))).testZrxVaultAddress();
 | 
			
		||||
        zrxVault = IZrxVault(zrxVaultAddress);
 | 
			
		||||
        return zrxVault;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -31,22 +31,10 @@ contract TestStakingProxy is
 | 
			
		||||
        public
 | 
			
		||||
        StakingProxy(
 | 
			
		||||
            _stakingContract,
 | 
			
		||||
            NIL_ADDRESS,
 | 
			
		||||
            NIL_ADDRESS,
 | 
			
		||||
            NIL_ADDRESS
 | 
			
		||||
        )
 | 
			
		||||
    {}
 | 
			
		||||
 | 
			
		||||
    function setAddressParams(
 | 
			
		||||
        address _wethProxyAddress,
 | 
			
		||||
        address _zrxVaultAddress        
 | 
			
		||||
    )
 | 
			
		||||
        external
 | 
			
		||||
    {
 | 
			
		||||
        wethAssetProxy = IAssetProxy(_wethProxyAddress);
 | 
			
		||||
        zrxVault = IZrxVault(_zrxVaultAddress);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function _assertValidStorageParams()
 | 
			
		||||
        internal
 | 
			
		||||
        view
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
import { blockchainTests, constants, expect, filterLogsToArguments, randomAddress } from '@0x/contracts-test-utils';
 | 
			
		||||
import { blockchainTests, constants, expect, filterLogsToArguments } from '@0x/contracts-test-utils';
 | 
			
		||||
import { StakingRevertErrors } from '@0x/order-utils';
 | 
			
		||||
import { AuthorizableRevertErrors, BigNumber, StringRevertError } from '@0x/utils';
 | 
			
		||||
 | 
			
		||||
@@ -8,7 +8,6 @@ import {
 | 
			
		||||
    StakingProxyContract,
 | 
			
		||||
    TestAssertStorageParamsContract,
 | 
			
		||||
    TestInitTargetContract,
 | 
			
		||||
    TestInitTargetInitAddressesEventArgs,
 | 
			
		||||
    TestStakingProxyContract,
 | 
			
		||||
    TestStakingProxyStakingContractAttachedToProxyEventArgs,
 | 
			
		||||
} from '../src/';
 | 
			
		||||
@@ -100,9 +99,6 @@ blockchainTests('Migration tests', env => {
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('should set the correct initial params', async () => {
 | 
			
		||||
                const wethProxyAddress = randomAddress();
 | 
			
		||||
                const zrxVaultAddress = randomAddress();
 | 
			
		||||
 | 
			
		||||
                const stakingProxyContractAddress = (await StakingProxyContract.deployFrom0xArtifactAsync(
 | 
			
		||||
                    artifacts.StakingProxy,
 | 
			
		||||
                    env.provider,
 | 
			
		||||
@@ -110,8 +106,6 @@ blockchainTests('Migration tests', env => {
 | 
			
		||||
                    artifacts,
 | 
			
		||||
                    stakingContract.address,
 | 
			
		||||
                    stakingContract.address,
 | 
			
		||||
                    wethProxyAddress,
 | 
			
		||||
                    zrxVaultAddress,
 | 
			
		||||
                )).address;
 | 
			
		||||
 | 
			
		||||
                const stakingProxyContract = new StakingContract(
 | 
			
		||||
@@ -126,8 +120,6 @@ blockchainTests('Migration tests', env => {
 | 
			
		||||
                expect(params[3]).to.bignumber.eq(stakingConstants.DEFAULT_PARAMS.maximumMakersInPool);
 | 
			
		||||
                expect(params[4]).to.bignumber.eq(stakingConstants.DEFAULT_PARAMS.cobbDouglasAlphaNumerator);
 | 
			
		||||
                expect(params[5]).to.bignumber.eq(stakingConstants.DEFAULT_PARAMS.cobbDouglasAlphaDenominator);
 | 
			
		||||
                expect(params[6]).to.eq(wethProxyAddress);
 | 
			
		||||
                expect(params[7]).to.eq(zrxVaultAddress);
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
@@ -141,8 +133,6 @@ blockchainTests('Migration tests', env => {
 | 
			
		||||
            it('throws if not called by an authorized address', async () => {
 | 
			
		||||
                const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
 | 
			
		||||
                    initTargetContract.address,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                    {
 | 
			
		||||
                        from: notAuthorizedAddress,
 | 
			
		||||
                    },
 | 
			
		||||
@@ -152,19 +142,13 @@ blockchainTests('Migration tests', env => {
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('calls init() and attaches the contract', async () => {
 | 
			
		||||
                await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
 | 
			
		||||
                    initTargetContract.address,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                );
 | 
			
		||||
                await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address);
 | 
			
		||||
                await assertInitStateAsync(proxyContract);
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('emits a `StakingContractAttachedToProxy` event', async () => {
 | 
			
		||||
                const receipt = await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
 | 
			
		||||
                    initTargetContract.address,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                );
 | 
			
		||||
                const logsArgs = filterLogsToArguments<TestStakingProxyStakingContractAttachedToProxyEventArgs>(
 | 
			
		||||
                    receipt.logs,
 | 
			
		||||
@@ -179,56 +163,12 @@ blockchainTests('Migration tests', env => {
 | 
			
		||||
 | 
			
		||||
            it('reverts if init() reverts', async () => {
 | 
			
		||||
                await enableInitRevertsAsync();
 | 
			
		||||
                const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
 | 
			
		||||
                    initTargetContract.address,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                );
 | 
			
		||||
                const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address);
 | 
			
		||||
                return expect(tx).to.revertWith(INIT_REVERT_ERROR);
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('calls init with initialized addresses if passed in args are null', async () => {
 | 
			
		||||
                const wethProxyAddress = randomAddress();
 | 
			
		||||
                const zrxVaultAddress = randomAddress();
 | 
			
		||||
                await proxyContract.setAddressParams.awaitTransactionSuccessAsync(wethProxyAddress, zrxVaultAddress);
 | 
			
		||||
                const receipt = await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
 | 
			
		||||
                    initTargetContract.address,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                );
 | 
			
		||||
                const logsArgs = filterLogsToArguments<TestInitTargetInitAddressesEventArgs>(
 | 
			
		||||
                    receipt.logs,
 | 
			
		||||
                    'InitAddresses',
 | 
			
		||||
                );
 | 
			
		||||
                for (const args of logsArgs) {
 | 
			
		||||
                    expect(args.wethProxyAddress).to.eq(wethProxyAddress);
 | 
			
		||||
                    expect(args.zrxVaultAddress).to.eq(zrxVaultAddress);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            it('calls init with passed in addresses if they are not null', async () => {
 | 
			
		||||
                const wethProxyAddress = randomAddress();
 | 
			
		||||
                const zrxVaultAddress = randomAddress();
 | 
			
		||||
                const receipt = await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
 | 
			
		||||
                    initTargetContract.address,
 | 
			
		||||
                    wethProxyAddress,
 | 
			
		||||
                    zrxVaultAddress,
 | 
			
		||||
                );
 | 
			
		||||
                const logsArgs = filterLogsToArguments<TestInitTargetInitAddressesEventArgs>(
 | 
			
		||||
                    receipt.logs,
 | 
			
		||||
                    'InitAddresses',
 | 
			
		||||
                );
 | 
			
		||||
                for (const args of logsArgs) {
 | 
			
		||||
                    expect(args.wethProxyAddress).to.eq(wethProxyAddress);
 | 
			
		||||
                    expect(args.zrxVaultAddress).to.eq(zrxVaultAddress);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('reverts if assertValidStorageParams() fails', async () => {
 | 
			
		||||
                const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
 | 
			
		||||
                    revertAddress,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                );
 | 
			
		||||
                const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(revertAddress);
 | 
			
		||||
                return expect(tx).to.revertWith(STORAGE_PARAMS_REVERT_ERROR);
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
@@ -236,11 +176,7 @@ blockchainTests('Migration tests', env => {
 | 
			
		||||
        blockchainTests.resets('upgrades', async () => {
 | 
			
		||||
            it('modifies prior state', async () => {
 | 
			
		||||
                const proxyContract = await deployStakingProxyAsync(initTargetContract.address);
 | 
			
		||||
                await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
 | 
			
		||||
                    initTargetContract.address,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                    constants.NULL_ADDRESS,
 | 
			
		||||
                );
 | 
			
		||||
                await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address);
 | 
			
		||||
                const initCounter = await initTargetContract.getInitCounter.callAsync({ to: proxyContract.address });
 | 
			
		||||
                expect(initCounter).to.bignumber.eq(2);
 | 
			
		||||
            });
 | 
			
		||||
@@ -249,7 +185,7 @@ blockchainTests('Migration tests', env => {
 | 
			
		||||
 | 
			
		||||
    blockchainTests.resets('Staking.init()', async () => {
 | 
			
		||||
        it('throws if not called by an authorized address', async () => {
 | 
			
		||||
            const tx = stakingContract.init.awaitTransactionSuccessAsync(randomAddress(), randomAddress(), {
 | 
			
		||||
            const tx = stakingContract.init.awaitTransactionSuccessAsync({
 | 
			
		||||
                from: notAuthorizedAddress,
 | 
			
		||||
            });
 | 
			
		||||
            const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddress);
 | 
			
		||||
@@ -257,8 +193,8 @@ blockchainTests('Migration tests', env => {
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        it('throws if already intitialized', async () => {
 | 
			
		||||
            await stakingContract.init.awaitTransactionSuccessAsync(randomAddress(), randomAddress());
 | 
			
		||||
            const tx = stakingContract.init.awaitTransactionSuccessAsync(randomAddress(), randomAddress());
 | 
			
		||||
            await stakingContract.init.awaitTransactionSuccessAsync();
 | 
			
		||||
            const tx = stakingContract.init.awaitTransactionSuccessAsync();
 | 
			
		||||
            const expectedError = new StakingRevertErrors.InitializationError();
 | 
			
		||||
            return expect(tx).to.revertWith(expectedError);
 | 
			
		||||
        });
 | 
			
		||||
@@ -380,26 +316,6 @@ blockchainTests('Migration tests', env => {
 | 
			
		||||
            );
 | 
			
		||||
            expect(tx).to.revertWith(expectedError);
 | 
			
		||||
        });
 | 
			
		||||
        it('reverts if wethAssetProxy is 0', async () => {
 | 
			
		||||
            const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({
 | 
			
		||||
                ...stakingConstants.DEFAULT_PARAMS,
 | 
			
		||||
                wethProxyAddress: constants.NULL_ADDRESS,
 | 
			
		||||
            });
 | 
			
		||||
            const expectedError = new StakingRevertErrors.InvalidParamValueError(
 | 
			
		||||
                StakingRevertErrors.InvalidParamValueErrorCode.InvalidWethProxyAddress,
 | 
			
		||||
            );
 | 
			
		||||
            expect(tx).to.revertWith(expectedError);
 | 
			
		||||
        });
 | 
			
		||||
        it('reverts if zrxVault is 0', async () => {
 | 
			
		||||
            const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({
 | 
			
		||||
                ...stakingConstants.DEFAULT_PARAMS,
 | 
			
		||||
                zrxVaultAddress: constants.NULL_ADDRESS,
 | 
			
		||||
            });
 | 
			
		||||
            const expectedError = new StakingRevertErrors.InvalidParamValueError(
 | 
			
		||||
                StakingRevertErrors.InvalidParamValueErrorCode.InvalidZrxVaultAddress,
 | 
			
		||||
            );
 | 
			
		||||
            expect(tx).to.revertWith(expectedError);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
// tslint:enable:no-unnecessary-type-assertion
 | 
			
		||||
 
 | 
			
		||||
@@ -39,8 +39,6 @@ blockchainTests('Configurable Parameters unit tests', env => {
 | 
			
		||||
                new BigNumber(_params.maximumMakersInPool),
 | 
			
		||||
                new BigNumber(_params.cobbDouglasAlphaNumerator),
 | 
			
		||||
                new BigNumber(_params.cobbDouglasAlphaDenominator),
 | 
			
		||||
                _params.wethProxyAddress,
 | 
			
		||||
                _params.zrxVaultAddress,
 | 
			
		||||
                { from },
 | 
			
		||||
            );
 | 
			
		||||
            // Assert event.
 | 
			
		||||
@@ -53,8 +51,6 @@ blockchainTests('Configurable Parameters unit tests', env => {
 | 
			
		||||
            expect(event.maximumMakersInPool).to.bignumber.eq(_params.maximumMakersInPool);
 | 
			
		||||
            expect(event.cobbDouglasAlphaNumerator).to.bignumber.eq(_params.cobbDouglasAlphaNumerator);
 | 
			
		||||
            expect(event.cobbDouglasAlphaDenominator).to.bignumber.eq(_params.cobbDouglasAlphaDenominator);
 | 
			
		||||
            expect(event.wethProxyAddress).to.eq(_params.wethProxyAddress);
 | 
			
		||||
            expect(event.zrxVaultAddress).to.eq(_params.zrxVaultAddress);
 | 
			
		||||
            // Assert `getParams()`.
 | 
			
		||||
            const actual = await testContract.getParams.callAsync();
 | 
			
		||||
            expect(actual[0]).to.bignumber.eq(_params.epochDurationInSeconds);
 | 
			
		||||
@@ -63,8 +59,6 @@ blockchainTests('Configurable Parameters unit tests', env => {
 | 
			
		||||
            expect(actual[3]).to.bignumber.eq(_params.maximumMakersInPool);
 | 
			
		||||
            expect(actual[4]).to.bignumber.eq(_params.cobbDouglasAlphaNumerator);
 | 
			
		||||
            expect(actual[5]).to.bignumber.eq(_params.cobbDouglasAlphaDenominator);
 | 
			
		||||
            expect(actual[6]).to.eq(_params.wethProxyAddress);
 | 
			
		||||
            expect(actual[7]).to.eq(_params.zrxVaultAddress);
 | 
			
		||||
            return receipt;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -46,7 +46,6 @@ blockchainTests.resets('Testing Rewards', env => {
 | 
			
		||||
            minimumPoolStake: new BigNumber(2),
 | 
			
		||||
            cobbDouglasAlphaNumerator: new BigNumber(1),
 | 
			
		||||
            cobbDouglasAlphaDenominator: new BigNumber(6),
 | 
			
		||||
            zrxVaultAddress: stakingApiWrapper.zrxVaultContract.address,
 | 
			
		||||
        });
 | 
			
		||||
        // setup stakers
 | 
			
		||||
        stakers = actors.slice(0, 2).map(a => new StakerActor(a, stakingApiWrapper));
 | 
			
		||||
 
 | 
			
		||||
@@ -117,8 +117,6 @@ export class StakingApiWrapper {
 | 
			
		||||
                new BigNumber(_params.maximumMakersInPool),
 | 
			
		||||
                new BigNumber(_params.cobbDouglasAlphaNumerator),
 | 
			
		||||
                new BigNumber(_params.cobbDouglasAlphaDenominator),
 | 
			
		||||
                _params.wethProxyAddress,
 | 
			
		||||
                _params.zrxVaultAddress,
 | 
			
		||||
            );
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
@@ -228,22 +226,6 @@ export async function deployAndConfigureContractsAsync(
 | 
			
		||||
        artifacts,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // deploy staking contract
 | 
			
		||||
    const stakingContract = await TestStakingContract.deployFrom0xArtifactAsync(
 | 
			
		||||
        customStakingArtifact !== undefined ? customStakingArtifact : artifacts.TestStaking,
 | 
			
		||||
        env.provider,
 | 
			
		||||
        env.txDefaults,
 | 
			
		||||
        artifacts,
 | 
			
		||||
        wethContract.address,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // deploy read-only proxy
 | 
			
		||||
    const readOnlyProxyContract = await ReadOnlyProxyContract.deployFrom0xArtifactAsync(
 | 
			
		||||
        artifacts.ReadOnlyProxy,
 | 
			
		||||
        env.provider,
 | 
			
		||||
        env.txDefaults,
 | 
			
		||||
        artifacts,
 | 
			
		||||
    );
 | 
			
		||||
    // deploy zrx vault
 | 
			
		||||
    const zrxVaultContract = await ZrxVaultContract.deployFrom0xArtifactAsync(
 | 
			
		||||
        artifacts.ZrxVault,
 | 
			
		||||
@@ -253,6 +235,26 @@ export async function deployAndConfigureContractsAsync(
 | 
			
		||||
        erc20ProxyContract.address,
 | 
			
		||||
        zrxTokenContract.address,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // deploy staking contract
 | 
			
		||||
    const stakingContract = await TestStakingContract.deployFrom0xArtifactAsync(
 | 
			
		||||
        customStakingArtifact !== undefined ? customStakingArtifact : artifacts.TestStaking,
 | 
			
		||||
        env.provider,
 | 
			
		||||
        env.txDefaults,
 | 
			
		||||
        artifacts,
 | 
			
		||||
        wethContract.address,
 | 
			
		||||
        erc20ProxyContract.address,
 | 
			
		||||
        zrxVaultContract.address,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // deploy read-only proxy
 | 
			
		||||
    const readOnlyProxyContract = await ReadOnlyProxyContract.deployFrom0xArtifactAsync(
 | 
			
		||||
        artifacts.ReadOnlyProxy,
 | 
			
		||||
        env.provider,
 | 
			
		||||
        env.txDefaults,
 | 
			
		||||
        artifacts,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // deploy staking proxy
 | 
			
		||||
    const stakingProxyContract = await StakingProxyContract.deployFrom0xArtifactAsync(
 | 
			
		||||
        artifacts.StakingProxy,
 | 
			
		||||
@@ -261,8 +263,6 @@ export async function deployAndConfigureContractsAsync(
 | 
			
		||||
        artifacts,
 | 
			
		||||
        stakingContract.address,
 | 
			
		||||
        readOnlyProxyContract.address,
 | 
			
		||||
        erc20ProxyContract.address,
 | 
			
		||||
        zrxVaultContract.address,
 | 
			
		||||
    );
 | 
			
		||||
    // deploy cobb douglas contract
 | 
			
		||||
    const cobbDouglasContract = await TestCobbDouglasContract.deployFrom0xArtifactAsync(
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
import { constants as testConstants, randomAddress } from '@0x/contracts-test-utils';
 | 
			
		||||
import { constants as testConstants } from '@0x/contracts-test-utils';
 | 
			
		||||
import { BigNumber } from '@0x/utils';
 | 
			
		||||
 | 
			
		||||
const TEN_DAYS = 10 * 24 * 60 * 60;
 | 
			
		||||
@@ -17,8 +17,6 @@ export const constants = {
 | 
			
		||||
        maximumMakersInPool: new BigNumber(10),
 | 
			
		||||
        cobbDouglasAlphaNumerator: new BigNumber(1),
 | 
			
		||||
        cobbDouglasAlphaDenominator: new BigNumber(2),
 | 
			
		||||
        wethProxyAddress: randomAddress(),
 | 
			
		||||
        zrxVaultAddress: randomAddress(),
 | 
			
		||||
    },
 | 
			
		||||
    PPM,
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
import { BlockchainTestsEnvironment, constants, expect, txDefaults } from '@0x/contracts-test-utils';
 | 
			
		||||
import { BlockchainTestsEnvironment, expect, txDefaults } from '@0x/contracts-test-utils';
 | 
			
		||||
import { BigNumber } from '@0x/utils';
 | 
			
		||||
import { DecodedLogEntry, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
@@ -86,6 +86,7 @@ export class CumulativeRewardTrackingSimulation {
 | 
			
		||||
            txDefaults,
 | 
			
		||||
            artifacts,
 | 
			
		||||
            this._stakingApiWrapper.wethContract.address,
 | 
			
		||||
            this._stakingApiWrapper.zrxVaultContract.address,
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -104,8 +105,6 @@ export class CumulativeRewardTrackingSimulation {
 | 
			
		||||
        await this._executeActionsAsync(initActions);
 | 
			
		||||
        await this._stakingApiWrapper.stakingProxyContract.attachStakingContract.awaitTransactionSuccessAsync(
 | 
			
		||||
            this.getTestCumulativeRewardTrackingContract().address,
 | 
			
		||||
            constants.NULL_ADDRESS,
 | 
			
		||||
            constants.NULL_ADDRESS,
 | 
			
		||||
        );
 | 
			
		||||
        const testLogs = await this._executeActionsAsync(testActions);
 | 
			
		||||
        CumulativeRewardTrackingSimulation._assertTestLogs(expectedTestLogs, testLogs);
 | 
			
		||||
 
 | 
			
		||||
@@ -11,8 +11,6 @@ export interface StakingParams {
 | 
			
		||||
    maximumMakersInPool: Numberish;
 | 
			
		||||
    cobbDouglasAlphaNumerator: Numberish;
 | 
			
		||||
    cobbDouglasAlphaDenominator: Numberish;
 | 
			
		||||
    wethProxyAddress: string;
 | 
			
		||||
    zrxVaultAddress: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface StakerBalances {
 | 
			
		||||
 
 | 
			
		||||
@@ -24,8 +24,6 @@ export enum InvalidParamValueErrorCode {
 | 
			
		||||
    InvalidRewardDelegatedStakeWeight,
 | 
			
		||||
    InvalidMaximumMakersInPool,
 | 
			
		||||
    InvalidMinimumPoolStake,
 | 
			
		||||
    InvalidWethProxyAddress,
 | 
			
		||||
    InvalidZrxVaultAddress,
 | 
			
		||||
    InvalidEpochDuration,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user