aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-07-08 14:23:22 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-07-08 14:23:22 +0800
commitf1613d36ac1381a978a97fd0ee7cd7bc95e7d66a (patch)
tree9520b2c87fff3f6759932dcecaf7ca718bb240c6 /packages/contracts
parent8314bbbbac0101831bf8167c01e5ccf46663a2f0 (diff)
downloaddexon-sol-tools-f1613d36ac1381a978a97fd0ee7cd7bc95e7d66a.tar
dexon-sol-tools-f1613d36ac1381a978a97fd0ee7cd7bc95e7d66a.tar.gz
dexon-sol-tools-f1613d36ac1381a978a97fd0ee7cd7bc95e7d66a.tar.bz2
dexon-sol-tools-f1613d36ac1381a978a97fd0ee7cd7bc95e7d66a.tar.lz
dexon-sol-tools-f1613d36ac1381a978a97fd0ee7cd7bc95e7d66a.tar.xz
dexon-sol-tools-f1613d36ac1381a978a97fd0ee7cd7bc95e7d66a.tar.zst
dexon-sol-tools-f1613d36ac1381a978a97fd0ee7cd7bc95e7d66a.zip
Move functions out of Forwarder.sol
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/src/2.0.0/forwarder/Forwarder.sol32
-rw-r--r--packages/contracts/src/2.0.0/forwarder/MixinConstants.sol3
-rw-r--r--packages/contracts/src/2.0.0/forwarder/MixinFees.sol11
-rw-r--r--packages/contracts/src/2.0.0/forwarder/MixinForwarderCore.sol15
-rw-r--r--packages/contracts/src/2.0.0/forwarder/interfaces/IExpectedResults.sol2
-rw-r--r--packages/contracts/src/2.0.0/forwarder/interfaces/IForwarder.sol2
-rw-r--r--packages/contracts/src/2.0.0/forwarder/interfaces/IForwarderCore.sol2
-rw-r--r--packages/contracts/src/2.0.0/forwarder/mixins/MExpectedResults.sol2
-rw-r--r--packages/contracts/src/2.0.0/forwarder/mixins/MFees.sol2
-rw-r--r--packages/contracts/src/2.0.0/forwarder/mixins/MForwarderCore.sol2
-rw-r--r--packages/contracts/src/2.0.0/forwarder/mixins/MMarketBuyZrx.sol2
-rw-r--r--packages/contracts/src/2.0.0/forwarder/mixins/MTransfer.sol2
12 files changed, 35 insertions, 42 deletions
diff --git a/packages/contracts/src/2.0.0/forwarder/Forwarder.sol b/packages/contracts/src/2.0.0/forwarder/Forwarder.sol
index 32b79d582..fc17a4c72 100644
--- a/packages/contracts/src/2.0.0/forwarder/Forwarder.sol
+++ b/packages/contracts/src/2.0.0/forwarder/Forwarder.sol
@@ -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()
+ {}
}
diff --git a/packages/contracts/src/2.0.0/forwarder/MixinConstants.sol b/packages/contracts/src/2.0.0/forwarder/MixinConstants.sol
index 30a1301fc..2b064d579 100644
--- a/packages/contracts/src/2.0.0/forwarder/MixinConstants.sol
+++ b/packages/contracts/src/2.0.0/forwarder/MixinConstants.sol
@@ -40,5 +40,4 @@ contract MixinConstants is
ZRX_ASSET_DATA = _zrxAssetData;
WETH_ASSET_DATA = _wethAssetData;
}
-
-} \ No newline at end of file
+}
diff --git a/packages/contracts/src/2.0.0/forwarder/MixinFees.sol b/packages/contracts/src/2.0.0/forwarder/MixinFees.sol
index e7fb1827d..8ea00a1d5 100644
--- a/packages/contracts/src/2.0.0/forwarder/MixinFees.sol
+++ b/packages/contracts/src/2.0.0/forwarder/MixinFees.sol
@@ -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
diff --git a/packages/contracts/src/2.0.0/forwarder/MixinForwarderCore.sol b/packages/contracts/src/2.0.0/forwarder/MixinForwarderCore.sol
index dc80d109c..eadeaf5ba 100644
--- a/packages/contracts/src/2.0.0/forwarder/MixinForwarderCore.sol
+++ b/packages/contracts/src/2.0.0/forwarder/MixinForwarderCore.sol
@@ -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.
diff --git a/packages/contracts/src/2.0.0/forwarder/interfaces/IExpectedResults.sol b/packages/contracts/src/2.0.0/forwarder/interfaces/IExpectedResults.sol
index 1ea335b6c..89187b750 100644
--- a/packages/contracts/src/2.0.0/forwarder/interfaces/IExpectedResults.sol
+++ b/packages/contracts/src/2.0.0/forwarder/interfaces/IExpectedResults.sol
@@ -63,4 +63,4 @@ contract IExpectedResults {
public
view
returns (LibFillResults.FillResults memory totalFillResults);
-} \ No newline at end of file
+}
diff --git a/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarder.sol b/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarder.sol
index fffce92b1..745dd29a9 100644
--- a/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarder.sol
+++ b/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarder.sol
@@ -27,4 +27,4 @@ import "./IExpectedResults.sol";
contract IForwarder is
IForwarderCore,
IExpectedResults
-{} \ No newline at end of file
+{}
diff --git a/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarderCore.sol b/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarderCore.sol
index 75c8e8c98..7ac2a8af3 100644
--- a/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarderCore.sol
+++ b/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarderCore.sol
@@ -76,4 +76,4 @@ contract IForwarderCore {
public
payable
returns (LibFillResults.FillResults memory totalFillResults);
-} \ No newline at end of file
+}
diff --git a/packages/contracts/src/2.0.0/forwarder/mixins/MExpectedResults.sol b/packages/contracts/src/2.0.0/forwarder/mixins/MExpectedResults.sol
index e4645cb61..cf03bb32e 100644
--- a/packages/contracts/src/2.0.0/forwarder/mixins/MExpectedResults.sol
+++ b/packages/contracts/src/2.0.0/forwarder/mixins/MExpectedResults.sol
@@ -39,4 +39,4 @@ contract MExpectedResults is
internal
view
returns (LibFillResults.FillResults memory fillResults);
-} \ No newline at end of file
+}
diff --git a/packages/contracts/src/2.0.0/forwarder/mixins/MFees.sol b/packages/contracts/src/2.0.0/forwarder/mixins/MFees.sol
index 2a178915f..f332637ea 100644
--- a/packages/contracts/src/2.0.0/forwarder/mixins/MFees.sol
+++ b/packages/contracts/src/2.0.0/forwarder/mixins/MFees.sol
@@ -60,4 +60,4 @@ contract MFees {
internal
pure
returns (bool);
-} \ No newline at end of file
+}
diff --git a/packages/contracts/src/2.0.0/forwarder/mixins/MForwarderCore.sol b/packages/contracts/src/2.0.0/forwarder/mixins/MForwarderCore.sol
index 64c0716a1..4a54e76b1 100644
--- a/packages/contracts/src/2.0.0/forwarder/mixins/MForwarderCore.sol
+++ b/packages/contracts/src/2.0.0/forwarder/mixins/MForwarderCore.sol
@@ -89,4 +89,4 @@ contract MForwarderCore is
)
internal
returns (LibFillResults.FillResults memory totalFillResults);
-} \ No newline at end of file
+}
diff --git a/packages/contracts/src/2.0.0/forwarder/mixins/MMarketBuyZrx.sol b/packages/contracts/src/2.0.0/forwarder/mixins/MMarketBuyZrx.sol
index 16ddf20fd..3501ef001 100644
--- a/packages/contracts/src/2.0.0/forwarder/mixins/MMarketBuyZrx.sol
+++ b/packages/contracts/src/2.0.0/forwarder/mixins/MMarketBuyZrx.sol
@@ -39,4 +39,4 @@ contract MMarketBuyZrx {
)
internal
returns (LibFillResults.FillResults memory totalFillResults);
-} \ No newline at end of file
+}
diff --git a/packages/contracts/src/2.0.0/forwarder/mixins/MTransfer.sol b/packages/contracts/src/2.0.0/forwarder/mixins/MTransfer.sol
index 5deefac53..418a6288b 100644
--- a/packages/contracts/src/2.0.0/forwarder/mixins/MTransfer.sol
+++ b/packages/contracts/src/2.0.0/forwarder/mixins/MTransfer.sol
@@ -43,4 +43,4 @@ contract MTransfer {
address to
)
internal;
-} \ No newline at end of file
+}