Move functions out of Forwarder.sol

This commit is contained in:
Amir Bandeali 2018-07-07 23:23:22 -07:00
parent 8314bbbbac
commit f1613d36ac
12 changed files with 35 additions and 42 deletions

View File

@ -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()
{}
}

View File

@ -40,5 +40,4 @@ contract MixinConstants is
ZRX_ASSET_DATA = _zrxAssetData;
WETH_ASSET_DATA = _wethAssetData;
}
}
}

View File

@ -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

View File

@ -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.

View File

@ -63,4 +63,4 @@ contract IExpectedResults {
public
view
returns (LibFillResults.FillResults memory totalFillResults);
}
}

View File

@ -27,4 +27,4 @@ import "./IExpectedResults.sol";
contract IForwarder is
IForwarderCore,
IExpectedResults
{}
{}

View File

@ -76,4 +76,4 @@ contract IForwarderCore {
public
payable
returns (LibFillResults.FillResults memory totalFillResults);
}
}

View File

@ -39,4 +39,4 @@ contract MExpectedResults is
internal
view
returns (LibFillResults.FillResults memory fillResults);
}
}

View File

@ -60,4 +60,4 @@ contract MFees {
internal
pure
returns (bool);
}
}

View File

@ -89,4 +89,4 @@ contract MForwarderCore is
)
internal
returns (LibFillResults.FillResults memory totalFillResults);
}
}

View File

@ -39,4 +39,4 @@ contract MMarketBuyZrx {
)
internal
returns (LibFillResults.FillResults memory totalFillResults);
}
}

View File

@ -43,4 +43,4 @@ contract MTransfer {
address to
)
internal;
}
}