Add back balanceOf getters in vaults, remove public variable getters from inherited interfaces
This commit is contained in:
@@ -23,7 +23,6 @@ import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetProxy.sol";
|
||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
||||
import "@0x/contracts-utils/contracts/src/Ownable.sol";
|
||||
import "./MixinConstants.sol";
|
||||
import "../interfaces/IStorage.sol";
|
||||
import "../interfaces/IZrxVault.sol";
|
||||
import "../interfaces/IEthVault.sol";
|
||||
import "../interfaces/IStakingPoolRewardVault.sol";
|
||||
@@ -33,7 +32,6 @@ import "../libs/LibStakingRichErrors.sol";
|
||||
|
||||
// solhint-disable max-states-count, no-empty-blocks
|
||||
contract MixinStorage is
|
||||
IStorage,
|
||||
MixinConstants,
|
||||
Ownable
|
||||
{
|
||||
|
@@ -42,14 +42,6 @@ interface IEthVault {
|
||||
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.
|
||||
/// Note that only the Staking contract can call this.
|
||||
/// Note that this can only be called when *not* in Catostrophic Failure mode.
|
||||
@@ -69,4 +61,11 @@ interface IEthVault {
|
||||
function withdrawAll()
|
||||
external
|
||||
returns (uint256);
|
||||
|
||||
/// @dev Returns the balance in ETH of the `owner`
|
||||
/// @return Balance in ETH.
|
||||
function balanceOf(address owner)
|
||||
external
|
||||
view
|
||||
returns (uint256);
|
||||
}
|
||||
|
@@ -100,14 +100,6 @@ interface IStakingPoolRewardVault {
|
||||
external
|
||||
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)
|
||||
external;
|
||||
|
||||
@@ -182,4 +174,12 @@ interface IStakingPoolRewardVault {
|
||||
external
|
||||
view
|
||||
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);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ import "../interfaces/IStakingPoolRewardVault.sol";
|
||||
import "../interfaces/IStructs.sol";
|
||||
|
||||
|
||||
contract IStorage {
|
||||
interface IStorage {
|
||||
|
||||
function wethAssetProxy()
|
||||
external
|
||||
|
@@ -54,21 +54,6 @@ interface IZrxVault {
|
||||
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.
|
||||
/// Note that only the contract owner can call this.
|
||||
/// Note that this can only be called when *not* in Catastrophic Failure mode.
|
||||
@@ -98,4 +83,11 @@ interface IZrxVault {
|
||||
function withdrawAllFrom(address owner)
|
||||
external
|
||||
returns (uint256);
|
||||
|
||||
/// @dev Returns the balance in Zrx Tokens of the `owner`
|
||||
/// @return Balance in Zrx.
|
||||
function balanceOf(address owner)
|
||||
external
|
||||
view
|
||||
returns (uint256);
|
||||
}
|
||||
|
@@ -86,7 +86,7 @@ contract MixinStakeStorage is
|
||||
balance = balancePtr;
|
||||
// sync
|
||||
uint256 currentEpoch_ = currentEpoch;
|
||||
if (currentEpoch > balance.currentEpoch) {
|
||||
if (currentEpoch_ > balance.currentEpoch) {
|
||||
balance.currentEpoch = currentEpoch_.downcastToUint32();
|
||||
balance.currentEpochBalance = balance.nextEpochBalance;
|
||||
}
|
||||
|
@@ -25,7 +25,6 @@ import "../immutable/MixinStorage.sol";
|
||||
/// @dev This mixin contains logic for managing and interfacing with the Zrx Vault.
|
||||
/// (see vaults/ZrxVault.sol).
|
||||
contract MixinZrxVault is
|
||||
IZrxVault,
|
||||
MixinStorage
|
||||
{
|
||||
/// @dev Set the Zrx Vault.
|
||||
@@ -77,6 +76,6 @@ contract MixinZrxVault is
|
||||
address(_zrxVault) != address(0),
|
||||
"INVALID_ZRX_VAULT"
|
||||
);
|
||||
return _zrxVault.balances(owner);
|
||||
return _zrxVault.balanceOf(owner);
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ contract EthVault is
|
||||
using LibSafeMath for uint256;
|
||||
|
||||
// mapping from Owner to ETH balance
|
||||
mapping (address => uint256) public balances;
|
||||
mapping (address => uint256) internal _balances;
|
||||
|
||||
/// @dev Constructor.
|
||||
constructor()
|
||||
@@ -48,7 +48,7 @@ contract EthVault is
|
||||
{
|
||||
// update balance
|
||||
uint256 amount = msg.value;
|
||||
balances[owner] = balances[owner].safeAdd(msg.value);
|
||||
_balances[owner] = _balances[owner].safeAdd(msg.value);
|
||||
|
||||
// notify
|
||||
emit EthDepositedIntoVault(msg.sender, owner, amount);
|
||||
@@ -71,13 +71,23 @@ contract EthVault is
|
||||
{
|
||||
// get total balance
|
||||
address payable owner = msg.sender;
|
||||
totalBalance = balances[owner];
|
||||
totalBalance = _balances[owner];
|
||||
|
||||
// withdraw ETH to owner
|
||||
_withdrawFrom(owner, 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.
|
||||
/// @param owner of ETH.
|
||||
/// @param amount of ETH to withdraw.
|
||||
@@ -87,7 +97,7 @@ contract EthVault is
|
||||
// update balance
|
||||
// note that this call will revert if trying to withdraw more
|
||||
// than the current balance
|
||||
balances[owner] = balances[owner].safeSub(amount);
|
||||
_balances[owner] = _balances[owner].safeSub(amount);
|
||||
|
||||
// notify
|
||||
emit EthWithdrawnFromVault(msg.sender, owner, amount);
|
||||
|
@@ -242,6 +242,16 @@ contract StakingPoolRewardVault is
|
||||
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 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.
|
||||
/// @param pool Pool struct with the balances to increment.
|
||||
|
@@ -40,7 +40,7 @@ contract ZrxVault is
|
||||
using LibSafeMath for uint256;
|
||||
|
||||
// mapping from Owner to ZRX balance
|
||||
mapping (address => uint256) public balances;
|
||||
mapping (address => uint256) internal _balances;
|
||||
|
||||
// Zrx Asset Proxy
|
||||
IAssetProxy public zrxAssetProxy;
|
||||
@@ -92,7 +92,7 @@ contract ZrxVault is
|
||||
onlyNotInCatastrophicFailure
|
||||
{
|
||||
// update balance
|
||||
balances[owner] = balances[owner].safeAdd(amount);
|
||||
_balances[owner] = _balances[owner].safeAdd(amount);
|
||||
|
||||
// notify
|
||||
emit ZrxDepositedIntoVault(msg.sender, owner, amount);
|
||||
@@ -128,13 +128,23 @@ contract ZrxVault is
|
||||
returns (uint256)
|
||||
{
|
||||
// get total balance
|
||||
uint256 totalBalance = balances[owner];
|
||||
uint256 totalBalance = _balances[owner];
|
||||
|
||||
// withdraw ZRX to owner
|
||||
_withdrawFrom(owner, 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.
|
||||
/// @param owner of Zrx Tokens.
|
||||
/// @param amount of Zrx Tokens to withdraw.
|
||||
@@ -144,7 +154,7 @@ contract ZrxVault is
|
||||
// update balance
|
||||
// note that this call will revert if trying to withdraw more
|
||||
// than the current balance
|
||||
balances[owner] = balances[owner].safeSub(amount);
|
||||
_balances[owner] = _balances[owner].safeSub(amount);
|
||||
|
||||
// notify
|
||||
emit ZrxWithdrawnFromVault(msg.sender, owner, amount);
|
||||
|
Reference in New Issue
Block a user