Make deployment constant getters public

This commit is contained in:
Amir Bandeali 2019-09-24 16:43:08 -07:00
parent 85e56706bf
commit 1b159f5ccc
9 changed files with 37 additions and 41 deletions

View File

@ -69,8 +69,8 @@ contract MixinExchangeFees is
// Transfer the protocol fee to this address if it should be paid in // Transfer the protocol fee to this address if it should be paid in
// WETH. // WETH.
if (msg.value == 0) { if (msg.value == 0) {
_getWethAssetProxy().transferFrom( getWethAssetProxy().transferFrom(
_getWethAssetData(), getWethAssetData(),
payerAddress, payerAddress,
address(this), address(this),
protocolFeePaid protocolFeePaid

View File

@ -82,8 +82,8 @@ contract MixinDeploymentConstants {
/// @dev An overridable way to access the deployed WETH contract. /// @dev An overridable way to access the deployed WETH contract.
/// Must be view to allow overrides to access state. /// Must be view to allow overrides to access state.
/// @return wethContract The WETH contract instance. /// @return wethContract The WETH contract instance.
function _getWethContract() function getWethContract()
internal public
view view
returns (IEtherToken wethContract) returns (IEtherToken wethContract)
{ {
@ -94,8 +94,8 @@ contract MixinDeploymentConstants {
/// @dev An overridable way to access the deployed WETH assetData. /// @dev An overridable way to access the deployed WETH assetData.
/// Must be view to allow overrides to access state. /// Must be view to allow overrides to access state.
/// @return wethAssetData The assetData of the configured WETH contract. /// @return wethAssetData The assetData of the configured WETH contract.
function _getWethAssetData() function getWethAssetData()
internal public
view view
returns (bytes memory wethAssetData) returns (bytes memory wethAssetData)
{ {
@ -106,8 +106,8 @@ contract MixinDeploymentConstants {
/// @dev An overridable way to access the deployed WETH assetProxy. /// @dev An overridable way to access the deployed WETH assetProxy.
/// Must be view to allow overrides to access state. /// Must be view to allow overrides to access state.
/// @return wethAssetProxy The assetProxy used to transfer WETH. /// @return wethAssetProxy The assetProxy used to transfer WETH.
function _getWethAssetProxy() function getWethAssetProxy()
internal public
view view
returns (IAssetProxy wethAssetProxy) returns (IAssetProxy wethAssetProxy)
{ {
@ -118,8 +118,8 @@ contract MixinDeploymentConstants {
/// @dev An overridable way to access the deployed zrxVault. /// @dev An overridable way to access the deployed zrxVault.
/// Must be view to allow overrides to access state. /// Must be view to allow overrides to access state.
/// @return zrxVault The zrxVault contract. /// @return zrxVault The zrxVault contract.
function _getZrxVault() function getZrxVault()
internal public
view view
returns (IZrxVault zrxVault) returns (IZrxVault zrxVault)
{ {

View File

@ -50,7 +50,7 @@ contract MixinStake is
address payable owner = msg.sender; address payable owner = msg.sender;
// deposit equivalent amount of ZRX into vault // deposit equivalent amount of ZRX into vault
_getZrxVault().depositFrom(owner, amount); getZrxVault().depositFrom(owner, amount);
// mint stake // mint stake
_incrementCurrentAndNextBalance(_activeStakeByOwner[owner], amount); _incrementCurrentAndNextBalance(_activeStakeByOwner[owner], amount);
@ -96,7 +96,7 @@ contract MixinStake is
currentWithdrawableStake.safeSub(amount); currentWithdrawableStake.safeSub(amount);
// withdraw equivalent amount of ZRX from vault // withdraw equivalent amount of ZRX from vault
_getZrxVault().withdrawFrom(owner, amount); getZrxVault().withdrawFrom(owner, amount);
// emit stake event // emit stake event
emit Unstake( emit Unstake(
@ -211,7 +211,7 @@ contract MixinStake is
// 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 // Synchronizes reward state in the pool that the owner is delegating
// to. // to.
IStructs.StoredBalance memory finalDelegatedStakeToPoolByOwner = IStructs.StoredBalance memory finalDelegatedStakeToPoolByOwner =
_loadSyncedBalance(_delegatedStakeToPoolByOwner[owner][poolId]); _loadSyncedBalance(_delegatedStakeToPoolByOwner[owner][poolId]);
@ -251,7 +251,7 @@ contract MixinStake is
// 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 // synchronizes reward state in the pool that the owner is undelegating
// from // from
IStructs.StoredBalance memory finalDelegatedStakeToPoolByOwner = IStructs.StoredBalance memory finalDelegatedStakeToPoolByOwner =
_loadSyncedBalance(_delegatedStakeToPoolByOwner[owner][poolId]); _loadSyncedBalance(_delegatedStakeToPoolByOwner[owner][poolId]);

View File

@ -92,7 +92,7 @@ contract MixinStakeBalances is
view view
returns (uint256) returns (uint256)
{ {
return _getZrxVault().balanceOf(owner); return getZrxVault().balanceOf(owner);
} }
/// @dev Returns the active stake for a given owner. /// @dev Returns the active stake for a given owner.

View File

@ -184,7 +184,7 @@ contract MixinStakingPoolRewards is
if (operatorReward > 0) { if (operatorReward > 0) {
// Transfer the operator's weth reward to the operator // Transfer the operator's weth reward to the operator
_getWethContract().transfer(pool.operator, operatorReward); getWethContract().transfer(pool.operator, operatorReward);
} }
if (membersReward > 0) { if (membersReward > 0) {
@ -283,7 +283,7 @@ contract MixinStakingPoolRewards is
_decreasePoolRewards(poolId, balance); _decreasePoolRewards(poolId, balance);
// Withdraw the member's WETH balance // Withdraw the member's WETH balance
_getWethContract().transfer(member, balance); getWethContract().transfer(member, balance);
} }
/// @dev Computes the reward balance in ETH of a specific member of a pool. /// @dev Computes the reward balance in ETH of a specific member of a pool.

View File

@ -245,7 +245,7 @@ contract MixinFinalizer is
{ {
uint256 ethBalance = address(this).balance; uint256 ethBalance = address(this).balance;
if (ethBalance != 0) { if (ethBalance != 0) {
_getWethContract().deposit.value(ethBalance)(); getWethContract().deposit.value(ethBalance)();
} }
} }
@ -256,7 +256,7 @@ contract MixinFinalizer is
view view
returns (uint256 wethBalance) returns (uint256 wethBalance)
{ {
wethBalance = _getWethContract().balanceOf(address(this)) wethBalance = getWethContract().balanceOf(address(this))
.safeSub(wethReservedForPoolRewards); .safeSub(wethReservedForPoolRewards);
return wethBalance; return wethBalance;

View File

@ -91,10 +91,6 @@ contract TestProtocolFees is
emit ERC20ProxyTransferFrom(assetData, from, to, amount); emit ERC20ProxyTransferFrom(assetData, from, to, amount);
} }
function getWethAssetData() external view returns (bytes memory) {
return _getWethAssetData();
}
/// @dev Overridden to use test pools. /// @dev Overridden to use test pools.
function getStakingPoolIdOfMaker(address makerAddress) function getStakingPoolIdOfMaker(address makerAddress)
public public
@ -131,8 +127,8 @@ contract TestProtocolFees is
}); });
} }
function _getWethAssetProxy() function getWethAssetProxy()
internal public
view view
returns (IAssetProxy wethAssetProxy) returns (IAssetProxy wethAssetProxy)
{ {

View File

@ -43,8 +43,8 @@ contract TestStaking is
} }
/// @dev Overridden to use testWethAddress; /// @dev Overridden to use testWethAddress;
function _getWethContract() function getWethContract()
internal public
view view
returns (IEtherToken) returns (IEtherToken)
{ {
@ -55,8 +55,8 @@ contract TestStaking is
return IEtherToken(wethAddress); return IEtherToken(wethAddress);
} }
function _getWethAssetData() function getWethAssetData()
internal public
view view
returns (bytes memory) returns (bytes memory)
{ {
@ -67,8 +67,8 @@ contract TestStaking is
); );
} }
function _getWethAssetProxy() function getWethAssetProxy()
internal public
view view
returns (IAssetProxy wethAssetProxy) returns (IAssetProxy wethAssetProxy)
{ {
@ -77,8 +77,8 @@ contract TestStaking is
return wethAssetProxy; return wethAssetProxy;
} }
function _getZrxVault() function getZrxVault()
internal public
view view
returns (IZrxVault zrxVault) returns (IZrxVault zrxVault)
{ {

View File

@ -42,6 +42,14 @@ contract TestStakingNoWETH is
return true; return true;
} }
function getWethContract()
public
view
returns (IEtherToken)
{
return IEtherToken(address(this));
}
function _wrapEth() function _wrapEth()
internal internal
{} {}
@ -53,12 +61,4 @@ contract TestStakingNoWETH is
{ {
return address(this).balance; return address(this).balance;
} }
function _getWethContract()
internal
view
returns (IEtherToken)
{
return IEtherToken(address(this));
}
} }