Merge pull request #2222 from 0xProject/feat/3.0/remove-weth-asset-proxy
Remove wethAssetProxy and wethAssetData from staking contracts
This commit is contained in:
commit
1b5fa15c8c
@ -56,11 +56,13 @@ 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(
|
require(
|
||||||
getWethAssetData(),
|
getWethContract().transferFrom(
|
||||||
payerAddress,
|
payerAddress,
|
||||||
address(this),
|
address(this),
|
||||||
protocolFeePaid
|
protocolFeePaid
|
||||||
|
),
|
||||||
|
"WETH_TRANSFER_FAILED"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
pragma solidity ^0.5.9;
|
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-erc20/contracts/src/interfaces/IEtherToken.sol";
|
||||||
import "../interfaces/IZrxVault.sol";
|
import "../interfaces/IZrxVault.sol";
|
||||||
|
|
||||||
@ -37,17 +36,7 @@ contract MixinDeploymentConstants {
|
|||||||
// Ropsten & Rinkeby WETH9 Address
|
// Ropsten & Rinkeby WETH9 Address
|
||||||
// address constant private WETH_ADDRESS = address(0xc778417e063141139fce010982780140aa0cd5ab);
|
// address constant private WETH_ADDRESS = address(0xc778417e063141139fce010982780140aa0cd5ab);
|
||||||
|
|
||||||
// Mainnet Weth Asset Data
|
|
||||||
bytes constant private WETH_ASSET_DATA = hex"f47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
|
|
||||||
|
|
||||||
// Kovan Weth Asset Data
|
|
||||||
// bytes constant private WETH_ASSET_DATA = hex"f47261b0000000000000000000000000d0a1e359811322d97991e03f863a0c30c2cf029c";
|
|
||||||
|
|
||||||
// Ropsten & Rinkeby Weth Asset Data
|
|
||||||
// bytes constant private WETH_ASSET_DATA = hex"f47261b0000000000000000000000000c778417e063141139fce010982780140aa0cd5ab";
|
|
||||||
|
|
||||||
// @TODO SET THESE VALUES FOR DEPLOYMENT
|
// @TODO SET THESE VALUES FOR DEPLOYMENT
|
||||||
address constant private WETH_ASSET_PROXY_ADDRESS = address(1);
|
|
||||||
address constant private ZRX_VAULT_ADDRESS = address(1);
|
address constant private ZRX_VAULT_ADDRESS = address(1);
|
||||||
|
|
||||||
/// @dev An overridable way to access the deployed WETH contract.
|
/// @dev An overridable way to access the deployed WETH contract.
|
||||||
@ -62,30 +51,6 @@ contract MixinDeploymentConstants {
|
|||||||
return wethContract;
|
return wethContract;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev An overridable way to access the deployed WETH assetData.
|
|
||||||
/// Must be view to allow overrides to access state.
|
|
||||||
/// @return wethAssetData The assetData of the configured WETH contract.
|
|
||||||
function getWethAssetData()
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (bytes memory wethAssetData)
|
|
||||||
{
|
|
||||||
wethAssetData = WETH_ASSET_DATA;
|
|
||||||
return wethAssetData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev An overridable way to access the deployed WETH assetProxy.
|
|
||||||
/// Must be view to allow overrides to access state.
|
|
||||||
/// @return wethAssetProxy The assetProxy used to transfer WETH.
|
|
||||||
function getWethAssetProxy()
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (IAssetProxy wethAssetProxy)
|
|
||||||
{
|
|
||||||
wethAssetProxy = IAssetProxy(WETH_ASSET_PROXY_ADDRESS);
|
|
||||||
return wethAssetProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @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.
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetProxy.sol";
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
import "@0x/contracts-utils/contracts/src/LibRichErrors.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/Authorizable.sol";
|
import "@0x/contracts-utils/contracts/src/Authorizable.sol";
|
||||||
import "./MixinConstants.sol";
|
import "./MixinConstants.sol";
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetProxy.sol";
|
|
||||||
import "../interfaces/IZrxVault.sol";
|
import "../interfaces/IZrxVault.sol";
|
||||||
import "../interfaces/IStructs.sol";
|
import "../interfaces/IStructs.sol";
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@ contract TestCumulativeRewardTracking is
|
|||||||
public
|
public
|
||||||
TestStaking(
|
TestStaking(
|
||||||
wethAddress,
|
wethAddress,
|
||||||
address(0),
|
|
||||||
zrxVaultAddress
|
zrxVaultAddress
|
||||||
)
|
)
|
||||||
{}
|
{}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetProxy.sol";
|
|
||||||
import "../src/interfaces/IStructs.sol";
|
import "../src/interfaces/IStructs.sol";
|
||||||
import "./TestStakingNoWETH.sol";
|
import "./TestStakingNoWETH.sol";
|
||||||
|
|
||||||
@ -34,7 +33,6 @@ contract TestProtocolFees is
|
|||||||
}
|
}
|
||||||
|
|
||||||
event ERC20ProxyTransferFrom(
|
event ERC20ProxyTransferFrom(
|
||||||
bytes assetData,
|
|
||||||
address from,
|
address from,
|
||||||
address to,
|
address to,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
@ -81,14 +79,15 @@ contract TestProtocolFees is
|
|||||||
|
|
||||||
/// @dev The ERC20Proxy `transferFrom()` function.
|
/// @dev The ERC20Proxy `transferFrom()` function.
|
||||||
function transferFrom(
|
function transferFrom(
|
||||||
bytes calldata assetData,
|
|
||||||
address from,
|
address from,
|
||||||
address to,
|
address to,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
external
|
external
|
||||||
|
returns (bool)
|
||||||
{
|
{
|
||||||
emit ERC20ProxyTransferFrom(assetData, from, to, amount);
|
emit ERC20ProxyTransferFrom(from, to, amount);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Overridden to use test pools.
|
/// @dev Overridden to use test pools.
|
||||||
@ -127,12 +126,11 @@ contract TestProtocolFees is
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWethAssetProxy()
|
function getWethContract()
|
||||||
public
|
public
|
||||||
view
|
view
|
||||||
returns (IAssetProxy wethAssetProxy)
|
returns (IEtherToken wethContract)
|
||||||
{
|
{
|
||||||
wethAssetProxy = IAssetProxy(address(this));
|
return IEtherToken(address(this));
|
||||||
return wethAssetProxy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,18 +28,15 @@ contract TestStaking is
|
|||||||
Staking
|
Staking
|
||||||
{
|
{
|
||||||
address public testWethAddress;
|
address public testWethAddress;
|
||||||
address public testWethAssetProxyAddress;
|
|
||||||
address public testZrxVaultAddress;
|
address public testZrxVaultAddress;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
address wethAddress,
|
address wethAddress,
|
||||||
address wethAssetProxyAddress,
|
|
||||||
address zrxVaultAddress
|
address zrxVaultAddress
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
testWethAddress = wethAddress;
|
testWethAddress = wethAddress;
|
||||||
testWethAssetProxyAddress = wethAssetProxyAddress;
|
|
||||||
testZrxVaultAddress = zrxVaultAddress;
|
testZrxVaultAddress = zrxVaultAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,28 +53,6 @@ contract TestStaking is
|
|||||||
return IEtherToken(wethAddress);
|
return IEtherToken(wethAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWethAssetData()
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (bytes memory)
|
|
||||||
{
|
|
||||||
address wethAddress = TestStaking(address(uint160(stakingContract))).testWethAddress();
|
|
||||||
return abi.encodeWithSelector(
|
|
||||||
IAssetData(address(0)).ERC20Token.selector,
|
|
||||||
wethAddress
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getWethAssetProxy()
|
|
||||||
public
|
|
||||||
view
|
|
||||||
returns (IAssetProxy wethAssetProxy)
|
|
||||||
{
|
|
||||||
address wethAssetProxyAddress = TestStaking(address(uint160(stakingContract))).testWethAssetProxyAddress();
|
|
||||||
wethAssetProxy = IAssetProxy(wethAssetProxyAddress);
|
|
||||||
return wethAssetProxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getZrxVault()
|
function getZrxVault()
|
||||||
public
|
public
|
||||||
view
|
view
|
||||||
|
@ -43,16 +43,8 @@ contract TestStorageLayoutAndConstants is
|
|||||||
view
|
view
|
||||||
{
|
{
|
||||||
require(
|
require(
|
||||||
getWethAssetData().equals(abi.encodeWithSelector(
|
address(getWethContract()) != address(0),
|
||||||
IAssetData(address(0)).ERC20Token.selector,
|
"WETH_MUST_BE_SET"
|
||||||
getWethContract()
|
|
||||||
)),
|
|
||||||
"INVALID_WETH_ASSET_DATA"
|
|
||||||
);
|
|
||||||
|
|
||||||
require(
|
|
||||||
address(getWethAssetProxy()) != address(0),
|
|
||||||
"WETH_ASSET_PROXY_MUST_BE_SET"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
require(
|
require(
|
||||||
|
@ -28,7 +28,6 @@ blockchainTests('Protocol Fees unit tests', env => {
|
|||||||
let exchangeAddress: string;
|
let exchangeAddress: string;
|
||||||
let notExchangeAddress: string;
|
let notExchangeAddress: string;
|
||||||
let testContract: TestProtocolFeesContract;
|
let testContract: TestProtocolFeesContract;
|
||||||
let wethAssetData: string;
|
|
||||||
let minimumStake: BigNumber;
|
let minimumStake: BigNumber;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
@ -46,7 +45,6 @@ blockchainTests('Protocol Fees unit tests', env => {
|
|||||||
exchangeAddress,
|
exchangeAddress,
|
||||||
);
|
);
|
||||||
|
|
||||||
wethAssetData = await testContract.getWethAssetData.callAsync();
|
|
||||||
minimumStake = (await testContract.getParams.callAsync())[2];
|
minimumStake = (await testContract.getParams.callAsync())[2];
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -230,7 +228,6 @@ blockchainTests('Protocol Fees unit tests', env => {
|
|||||||
);
|
);
|
||||||
expect(logsArgs.length).to.eq(1);
|
expect(logsArgs.length).to.eq(1);
|
||||||
for (const args of logsArgs) {
|
for (const args of logsArgs) {
|
||||||
expect(args.assetData).to.eq(wethAssetData);
|
|
||||||
expect(args.from).to.eq(fromAddress);
|
expect(args.from).to.eq(fromAddress);
|
||||||
expect(args.to).to.eq(testContract.address);
|
expect(args.to).to.eq(testContract.address);
|
||||||
expect(args.amount).to.bignumber.eq(amount);
|
expect(args.amount).to.bignumber.eq(amount);
|
||||||
|
@ -243,7 +243,6 @@ export async function deployAndConfigureContractsAsync(
|
|||||||
env.txDefaults,
|
env.txDefaults,
|
||||||
artifacts,
|
artifacts,
|
||||||
wethContract.address,
|
wethContract.address,
|
||||||
erc20ProxyContract.address,
|
|
||||||
zrxVaultContract.address,
|
zrxVaultContract.address,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user