Move functions out of Forwarder.sol
This commit is contained in:
parent
8314bbbbac
commit
f1613d36ac
@ -25,11 +25,9 @@ import "./MixinConstants.sol";
|
||||
import "./MixinMarketBuyZrx.sol";
|
||||
import "./MixinExpectedResults.sol";
|
||||
import "./MixinTransfer.sol";
|
||||
import "../utils/Ownable/Ownable.sol";
|
||||
|
||||
|
||||
contract Forwarder is
|
||||
Ownable,
|
||||
MixinConstants,
|
||||
MixinExpectedResults,
|
||||
MixinFees,
|
||||
@ -37,7 +35,6 @@ contract Forwarder is
|
||||
MixinTransfer,
|
||||
MixinForwarderCore
|
||||
{
|
||||
uint256 constant internal MAX_UINT = 2**256 - 1;
|
||||
|
||||
constructor (
|
||||
address _exchange,
|
||||
@ -48,7 +45,6 @@ contract Forwarder is
|
||||
bytes memory _wethAssetData
|
||||
)
|
||||
public
|
||||
Ownable()
|
||||
MixinConstants(
|
||||
_exchange,
|
||||
_etherToken,
|
||||
@ -56,30 +52,6 @@ contract Forwarder is
|
||||
_zrxAssetData,
|
||||
_wethAssetData
|
||||
)
|
||||
{
|
||||
setERC20ProxyApproval(_erc20AssetProxyId);
|
||||
}
|
||||
|
||||
/// @dev Default payabale function, this allows us to withdraw WETH
|
||||
function ()
|
||||
public
|
||||
payable
|
||||
{
|
||||
require(
|
||||
msg.sender == address(ETHER_TOKEN),
|
||||
"DEFAULT_FUNCTION_WETH_CONTRACT_ONLY"
|
||||
);
|
||||
}
|
||||
|
||||
/// @dev Sets the allowances to the proxy for this contract
|
||||
function setERC20ProxyApproval(bytes4 erc20AssetProxyId)
|
||||
public
|
||||
onlyOwner
|
||||
{
|
||||
address proxyAddress = EXCHANGE.getAssetProxy(erc20AssetProxyId);
|
||||
if (proxyAddress != address(0)) {
|
||||
ETHER_TOKEN.approve(proxyAddress, MAX_UINT);
|
||||
ZRX_TOKEN.approve(proxyAddress, MAX_UINT);
|
||||
}
|
||||
}
|
||||
MixinForwarderCore()
|
||||
{}
|
||||
}
|
||||
|
@ -40,5 +40,4 @@ contract MixinConstants is
|
||||
ZRX_ASSET_DATA = _zrxAssetData;
|
||||
WETH_ASSET_DATA = _wethAssetData;
|
||||
}
|
||||
|
||||
}
|
@ -33,6 +33,17 @@ contract MixinFees is
|
||||
uint16 constant public MAX_FEE = 1000; // 10%
|
||||
uint16 constant public ALLOWABLE_EXCHANGE_PERCENTAGE = 9500; // 95%
|
||||
|
||||
/// @dev Default payabale function, this allows us to withdraw WETH
|
||||
function ()
|
||||
public
|
||||
payable
|
||||
{
|
||||
require(
|
||||
msg.sender == address(ETHER_TOKEN),
|
||||
"DEFAULT_FUNCTION_WETH_CONTRACT_ONLY"
|
||||
);
|
||||
}
|
||||
|
||||
/// @dev Pays the feeRecipient feeProportion of the total takerEthAmount, denominated in ETH
|
||||
/// @param takerEthAmount The total amount that was transacted in WETH, fees are calculated from this value.
|
||||
/// @param feeProportion The proportion of fees
|
||||
|
@ -39,8 +39,19 @@ contract MixinForwarderCore is
|
||||
MTransfer,
|
||||
MForwarderCore
|
||||
{
|
||||
bytes4 public constant ERC20_DATA_ID = bytes4(keccak256("ERC20Token(address)"));
|
||||
bytes4 public constant ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256,bytes)"));
|
||||
bytes4 constant internal ERC20_DATA_ID = bytes4(keccak256("ERC20Token(address)"));
|
||||
bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256,bytes)"));
|
||||
uint256 constant internal MAX_UINT = 2**256 - 1;
|
||||
|
||||
constructor ()
|
||||
public
|
||||
{
|
||||
address proxyAddress = EXCHANGE.getAssetProxy(ERC20_DATA_ID);
|
||||
if (proxyAddress != address(0)) {
|
||||
ETHER_TOKEN.approve(proxyAddress, MAX_UINT);
|
||||
ZRX_TOKEN.approve(proxyAddress, MAX_UINT);
|
||||
}
|
||||
}
|
||||
|
||||
/// @dev Market sells ETH for ERC20 tokens, performing fee abstraction if required. This does not support ERC721 tokens. This function is payable
|
||||
/// and will convert all incoming ETH into WETH and perform the trade on behalf of the caller.
|
||||
|
Loading…
x
Reference in New Issue
Block a user