Update visibility, events, and naming in vaults
This commit is contained in:
@@ -33,7 +33,6 @@ contract Staking is
|
||||
MixinStakingPool,
|
||||
MixinExchangeFees
|
||||
{
|
||||
|
||||
// this contract can receive ETH
|
||||
// solhint-disable no-empty-blocks
|
||||
function ()
|
||||
|
@@ -32,22 +32,17 @@ pragma solidity ^0.5.9;
|
||||
/// state in the staking contract.
|
||||
interface IVaultCore {
|
||||
|
||||
/// @dev Emitted when the Staking contract is changed.
|
||||
/// @param stakingContractAddress Address of the new Staking contract.
|
||||
event StakingContractChanged(
|
||||
address stakingContractAddress
|
||||
);
|
||||
/// @dev Emmitted whenever a StakingProxy is set in a vault.
|
||||
event StakingProxySet(address stakingProxyAddress);
|
||||
|
||||
/// @dev Emitted when the Staking contract is put into Catastrophic Failure Mode
|
||||
/// @param sender Address of sender (`msg.sender`)
|
||||
event InCatastrophicFailureMode(
|
||||
address sender
|
||||
);
|
||||
event InCatastrophicFailureMode(address sender);
|
||||
|
||||
/// @dev Sets the address of the Staking Contract.
|
||||
/// @dev Sets the address of the StakingProxy contract.
|
||||
/// Note that only the contract owner can call this function.
|
||||
/// @param _stakingContractAddress Address of Staking contract.
|
||||
function setStakingContract(address payable _stakingContractAddress)
|
||||
/// @param _stakingContractAddress Address of Staking proxy contract.
|
||||
function setStakingProxy(address payable _stakingProxyAddress)
|
||||
external;
|
||||
|
||||
/// @dev Vault enters into Catastrophic Failure Mode.
|
||||
|
@@ -48,16 +48,13 @@ interface IZrxVault {
|
||||
uint256 amount
|
||||
);
|
||||
|
||||
/// @dev Emitted when the Zrx Proxy is changed.
|
||||
/// @param zrxProxyAddress Address of the new ERC20 proxy.
|
||||
event ZrxProxyChanged(
|
||||
address zrxProxyAddress
|
||||
);
|
||||
/// @dev Emitted whenever the ZRX AssetProxy is set.
|
||||
event ZrxProxySet(address zrxProxyAddress);
|
||||
|
||||
/// @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.
|
||||
/// @param zrxProxyAddress Address of the 0x Zrx Asset Proxy.
|
||||
/// @param zrxProxyAddress Address of the 0x Zrx Proxy.
|
||||
function setZrxProxy(address zrxProxyAddress)
|
||||
external;
|
||||
|
||||
|
@@ -34,8 +34,9 @@ contract EthVault is
|
||||
mapping (address => uint256) internal _balances;
|
||||
|
||||
/// @dev Constructor.
|
||||
constructor()
|
||||
constructor(address _stakingProxyAddress)
|
||||
public
|
||||
MixinVaultCore(_stakingProxyAddress)
|
||||
{} // solhint-disable-line no-empty-blocks
|
||||
|
||||
/// @dev Deposit an `amount` of ETH from `owner` into the vault.
|
||||
|
@@ -40,20 +40,21 @@ contract MixinVaultCore is
|
||||
IVaultCore
|
||||
{
|
||||
// Address of staking contract
|
||||
address payable internal stakingContractAddress;
|
||||
address payable public stakingProxyAddress;
|
||||
|
||||
// True iff vault has been set to Catastrophic Failure Mode
|
||||
bool internal isInCatastrophicFailure;
|
||||
bool public isInCatastrophicFailure;
|
||||
|
||||
/// @dev Constructor.
|
||||
constructor() public {
|
||||
stakingContractAddress = 0x0000000000000000000000000000000000000000;
|
||||
isInCatastrophicFailure = false;
|
||||
constructor(address _stakingProxyAddress)
|
||||
public
|
||||
{
|
||||
_setStakingProxy(_stakingProxyAddress);
|
||||
}
|
||||
|
||||
/// @dev Asserts that the sender (`msg.sender`) is the staking contract.
|
||||
modifier onlyStakingContract {
|
||||
if (msg.sender != stakingContractAddress) {
|
||||
modifier onlyStakingProxy {
|
||||
if (msg.sender != stakingProxyAddress) {
|
||||
LibRichErrors.rrevert(LibStakingRichErrors.OnlyCallableByStakingContractError(
|
||||
msg.sender
|
||||
));
|
||||
@@ -77,15 +78,14 @@ contract MixinVaultCore is
|
||||
_;
|
||||
}
|
||||
|
||||
/// @dev Sets the address of the Staking Contract.
|
||||
/// @dev Sets the address of the StakingProxy contract.
|
||||
/// Note that only the contract owner can call this function.
|
||||
/// @param _stakingContractAddress Address of Staking contract.
|
||||
function setStakingContract(address payable _stakingContractAddress)
|
||||
/// @param _stakingContractAddress Address of Staking proxy contract.
|
||||
function setStakingProxy(address payable _stakingProxyAddress)
|
||||
external
|
||||
onlyOwner
|
||||
{
|
||||
stakingContractAddress = _stakingContractAddress;
|
||||
emit StakingContractChanged(stakingContractAddress);
|
||||
_setStakingProxy(_stakingProxyContract);
|
||||
}
|
||||
|
||||
/// @dev Vault enters into Catastrophic Failure Mode.
|
||||
@@ -98,4 +98,13 @@ contract MixinVaultCore is
|
||||
isInCatastrophicFailure = true;
|
||||
emit InCatastrophicFailureMode(msg.sender);
|
||||
}
|
||||
|
||||
/// @dev Sets the address of the StakingProxy contract.
|
||||
/// @param _stakingContractAddress Address of Staking proxy contract.
|
||||
function _setStakingProxy(address payable _stakingProxyAddress)
|
||||
internal
|
||||
{
|
||||
stakingProxyAddress = _stakingProxyAddress;
|
||||
emit StakingProxySet(_stakingProxyAddress);
|
||||
}
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ contract StakingPoolRewardVault is
|
||||
function ()
|
||||
external
|
||||
payable
|
||||
onlyStakingContract
|
||||
onlyStakingProxy
|
||||
onlyNotInCatastrophicFailure
|
||||
{
|
||||
emit RewardDeposited(UNKNOWN_STAKING_POOL_ID, msg.value);
|
||||
@@ -89,7 +89,7 @@ contract StakingPoolRewardVault is
|
||||
bool operatorOnly
|
||||
)
|
||||
external
|
||||
onlyStakingContract
|
||||
onlyStakingProxy
|
||||
returns (
|
||||
uint256 operatorPortion,
|
||||
uint256 membersPortion
|
||||
@@ -110,7 +110,7 @@ contract StakingPoolRewardVault is
|
||||
uint256 amount
|
||||
)
|
||||
external
|
||||
onlyStakingContract
|
||||
onlyStakingProxy
|
||||
{
|
||||
if (amount == 0) {
|
||||
return;
|
||||
@@ -144,7 +144,7 @@ contract StakingPoolRewardVault is
|
||||
uint256 amount
|
||||
)
|
||||
external
|
||||
onlyStakingContract
|
||||
onlyStakingProxy
|
||||
{
|
||||
if (amount == 0) {
|
||||
return;
|
||||
@@ -178,7 +178,7 @@ contract StakingPoolRewardVault is
|
||||
uint32 operatorShare
|
||||
)
|
||||
external
|
||||
onlyStakingContract
|
||||
onlyStakingProxy
|
||||
onlyNotInCatastrophicFailure
|
||||
{
|
||||
// operator share must be a valid fraction
|
||||
@@ -214,7 +214,7 @@ contract StakingPoolRewardVault is
|
||||
/// @param newOperatorShare The newly decreased percentage of any rewards owned by the operator.
|
||||
function decreaseOperatorShare(bytes32 poolId, uint32 newOperatorShare)
|
||||
external
|
||||
onlyStakingContract
|
||||
onlyStakingProxy
|
||||
onlyNotInCatastrophicFailure
|
||||
{
|
||||
uint32 oldOperatorShare = poolById[poolId].operatorShare;
|
||||
|
@@ -52,15 +52,18 @@ contract ZrxVault is
|
||||
bytes internal _zrxAssetData;
|
||||
|
||||
/// @dev Constructor.
|
||||
/// @param zrxProxyAddress Address of the 0x Zrx Proxy.
|
||||
/// @param _stakingProxyAddress Address of StakingProxy contract.
|
||||
/// @param _zrxProxyAddress Address of the 0x Zrx Proxy.
|
||||
/// @param _zrxTokenAddress Address of the Zrx Token.
|
||||
constructor(
|
||||
address zrxProxyAddress,
|
||||
address _stakingProxyAddress,
|
||||
address _zrxProxyAddress,
|
||||
address _zrxTokenAddress
|
||||
)
|
||||
public
|
||||
MixinVaultCore(_stakingProxyAddress)
|
||||
{
|
||||
zrxAssetProxy = IAssetProxy(zrxProxyAddress);
|
||||
zrxAssetProxy = IAssetProxy(_zrxProxyAddress);
|
||||
_zrxToken = IERC20Token(_zrxTokenAddress);
|
||||
_zrxAssetData = abi.encodeWithSelector(
|
||||
IAssetData(address(0)).ERC20Token.selector,
|
||||
@@ -71,14 +74,14 @@ contract ZrxVault is
|
||||
/// @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.
|
||||
/// @param zrxProxyAddress Address of the 0x Zrx Proxy.
|
||||
function setZrxProxy(address zrxProxyAddress)
|
||||
/// @param _zrxProxyAddress Address of the 0x Zrx Proxy.
|
||||
function setZrxProxy(address _zrxProxyAddress)
|
||||
external
|
||||
onlyOwner
|
||||
onlyNotInCatastrophicFailure
|
||||
{
|
||||
zrxAssetProxy = IAssetProxy(zrxProxyAddress);
|
||||
emit ZrxProxyChanged(zrxProxyAddress);
|
||||
zrxAssetProxy = IAssetProxy(_zrxProxyAddress);
|
||||
emit ZrxProxySet(_zrxProxyAddress);
|
||||
}
|
||||
|
||||
/// @dev Deposit an `amount` of Zrx Tokens from `owner` into the vault.
|
||||
@@ -88,7 +91,7 @@ contract ZrxVault is
|
||||
/// @param amount of Zrx Tokens to deposit.
|
||||
function depositFrom(address owner, uint256 amount)
|
||||
external
|
||||
onlyStakingContract
|
||||
onlyStakingProxy
|
||||
onlyNotInCatastrophicFailure
|
||||
{
|
||||
// update balance
|
||||
@@ -113,7 +116,7 @@ contract ZrxVault is
|
||||
/// @param amount of Zrx Tokens to withdraw.
|
||||
function withdrawFrom(address owner, uint256 amount)
|
||||
external
|
||||
onlyStakingContract
|
||||
onlyStakingProxy
|
||||
onlyNotInCatastrophicFailure
|
||||
{
|
||||
_withdrawFrom(owner, amount);
|
||||
|
Reference in New Issue
Block a user