Remove zrxAssetData param to ensure that it is always in sync with zrxToken

This commit is contained in:
Amir Bandeali
2019-08-28 11:06:46 -07:00
parent bde6278781
commit 1a833d9dfb
4 changed files with 9 additions and 37 deletions

View File

@@ -25,7 +25,7 @@ contract MixinConstants is
MixinDeploymentConstants MixinDeploymentConstants
{ {
// TODO: Reevaluate this variable // TODO: Reevaluate this variable
uint96 constant internal PERCENTAGE_DENOMINATOR = 100; // 10**18 uint8 constant internal PERCENTAGE_DENOMINATOR = 100;
// The upper 16 bytes represent the pool id, so this would be pool id 1. See MixinStakinPool for more information. // The upper 16 bytes represent the pool id, so this would be pool id 1. See MixinStakinPool for more information.
bytes32 constant internal INITIAL_POOL_ID = 0x0000000000000000000000000000000100000000000000000000000000000000; bytes32 constant internal INITIAL_POOL_ID = 0x0000000000000000000000000000000100000000000000000000000000000000;

View File

@@ -54,12 +54,6 @@ interface IZrxVault {
address erc20ProxyAddress address erc20ProxyAddress
); );
/// @dev Emitted when the Zrx Asset Data is changed.
/// @param zrxAssetData New Zrx Asset Data.
event ZrxAssetDataChanged(
bytes zrxAssetData
);
/// @dev Sets the ERC20 proxy. /// @dev Sets the ERC20 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.
@@ -67,13 +61,6 @@ interface IZrxVault {
function setErc20Proxy(address erc20ProxyAddress) function setErc20Proxy(address erc20ProxyAddress)
external; external;
/// @dev Sets the Zrx Asset Data.
/// Note that only the contract owner can call this.
/// Note that this can only be called when *not* in Catastrophic Failure mode.
/// @param _zrxAssetData Zrx asset data for the ERC20 Proxy.
function setZrxAssetData(bytes calldata _zrxAssetData)
external;
/// @dev Deposit an `amount` of Zrx Tokens from `owner` into the vault. /// @dev Deposit an `amount` of Zrx Tokens 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 Catastrophic Failure mode. /// Note that this can only be called when *not* in Catastrophic Failure mode.
@@ -90,7 +77,7 @@ interface IZrxVault {
function withdrawFrom(address owner, uint256 amount) function withdrawFrom(address owner, uint256 amount)
external; external;
/// @dev Withdraw ALL Zrx Tokens to `owner` from the vault. /// @dev Withdraw all of sender's ZRX from vault from the vault.
/// Note that this can only be called when *in* Catastrophic Failure mode. /// Note that this can only be called when *in* Catastrophic Failure mode.
/// @param owner of Zrx Tokens. /// @param owner of Zrx Tokens.
function withdrawAllFrom(address owner) function withdrawAllFrom(address owner)

View File

@@ -21,6 +21,7 @@ pragma solidity ^0.5.9;
import "../interfaces/IZrxVault.sol"; import "../interfaces/IZrxVault.sol";
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol"; import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetProxy.sol"; import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetProxy.sol";
import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetData.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol"; import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "./MixinVaultCore.sol"; import "./MixinVaultCore.sol";
@@ -37,7 +38,6 @@ contract ZrxVault is
IZrxVault, IZrxVault,
MixinVaultCore MixinVaultCore
{ {
using LibSafeMath for uint256; using LibSafeMath for uint256;
// mapping from Owner to ZRX balance // mapping from Owner to ZRX balance
@@ -55,17 +55,18 @@ contract ZrxVault is
/// @dev Constructor. /// @dev Constructor.
/// @param erc20ProxyAddress Address of the 0x ERC20 Proxy. /// @param erc20ProxyAddress Address of the 0x ERC20 Proxy.
/// @param zrxTokenAddress Address of the Zrx Token. /// @param zrxTokenAddress Address of the Zrx Token.
/// @param _zrxAssetData Zrx asset data for the ERC20 Proxy.
constructor( constructor(
address erc20ProxyAddress, address erc20ProxyAddress,
address zrxTokenAddress, address zrxTokenAddress
bytes memory _zrxAssetData
) )
public public
{ {
erc20Proxy = IAssetProxy(erc20ProxyAddress); erc20Proxy = IAssetProxy(erc20ProxyAddress);
zrxToken = IERC20Token(zrxTokenAddress); zrxToken = IERC20Token(zrxTokenAddress);
zrxAssetData = _zrxAssetData; zrxAssetData = abi.encodeWithSelector(
IAssetData(address(0)).ERC20Token.selector,
zrxTokenAddress
);
} }
/// @dev Sets the ERC20 proxy. /// @dev Sets the ERC20 proxy.
@@ -81,19 +82,6 @@ contract ZrxVault is
emit Erc20ProxyChanged(erc20ProxyAddress); emit Erc20ProxyChanged(erc20ProxyAddress);
} }
/// @dev Sets the Zrx Asset Data.
/// Note that only the contract owner can call this.
/// Note that this can only be called when *not* in Catastrophic Failure mode.
/// @param _zrxAssetData Zrx asset data for the ERC20 Proxy.
function setZrxAssetData(bytes calldata _zrxAssetData)
external
onlyOwner
onlyNotInCatastrophicFailure
{
zrxAssetData = _zrxAssetData;
emit ZrxAssetDataChanged(_zrxAssetData);
}
/// @dev Deposit an `amount` of Zrx Tokens from `owner` into the vault. /// @dev Deposit an `amount` of Zrx Tokens 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 Catastrophic Failure mode. /// Note that this can only be called when *not* in Catastrophic Failure mode.
@@ -132,7 +120,7 @@ contract ZrxVault is
_withdrawFrom(owner, amount); _withdrawFrom(owner, amount);
} }
/// @dev Withdraw ALL Zrx Tokens to `owner` from the vault. /// @dev Withdraw all of sender's ZRX from vault from the vault.
/// Note that this can only be called when *in* Catastrophic Failure mode. /// Note that this can only be called when *in* Catastrophic Failure mode.
/// @param owner of Zrx Tokens. /// @param owner of Zrx Tokens.
function withdrawAllFrom(address owner) function withdrawAllFrom(address owner)

View File

@@ -1,7 +1,6 @@
import { ERC20ProxyContract } from '@0x/contracts-asset-proxy'; import { ERC20ProxyContract } from '@0x/contracts-asset-proxy';
import { artifacts as erc20Artifacts, DummyERC20TokenContract } from '@0x/contracts-erc20'; import { artifacts as erc20Artifacts, DummyERC20TokenContract } from '@0x/contracts-erc20';
import { constants as testUtilsConstants, LogDecoder, txDefaults } from '@0x/contracts-test-utils'; import { constants as testUtilsConstants, LogDecoder, txDefaults } from '@0x/contracts-test-utils';
import { assetDataUtils } from '@0x/order-utils';
import { SignatureType } from '@0x/types'; import { SignatureType } from '@0x/types';
import { BigNumber, logUtils } from '@0x/utils'; import { BigNumber, logUtils } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper'; import { Web3Wrapper } from '@0x/web3-wrapper';
@@ -100,7 +99,6 @@ export class StakingWrapper {
} }
public async deployAndConfigureContractsAsync(): Promise<void> { public async deployAndConfigureContractsAsync(): Promise<void> {
// deploy zrx vault // deploy zrx vault
const zrxAssetData = assetDataUtils.encodeERC20AssetData(this._zrxTokenContract.address);
this._zrxVaultContractIfExists = await ZrxVaultContract.deployFrom0xArtifactAsync( this._zrxVaultContractIfExists = await ZrxVaultContract.deployFrom0xArtifactAsync(
artifacts.ZrxVault, artifacts.ZrxVault,
this._provider, this._provider,
@@ -108,7 +106,6 @@ export class StakingWrapper {
artifacts, artifacts,
this._erc20ProxyContract.address, this._erc20ProxyContract.address,
this._zrxTokenContract.address, this._zrxTokenContract.address,
zrxAssetData,
); );
// deploy reward vault // deploy reward vault
this._rewardVaultContractIfExists = await StakingPoolRewardVaultContract.deployFrom0xArtifactAsync( this._rewardVaultContractIfExists = await StakingPoolRewardVaultContract.deployFrom0xArtifactAsync(