aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/exchange
diff options
context:
space:
mode:
Diffstat (limited to 'contracts/exchange')
-rw-r--r--contracts/exchange/compiler.json15
-rw-r--r--contracts/exchange/contracts/examples/ExchangeWrapper.sol100
-rw-r--r--contracts/exchange/contracts/examples/Validator.sol56
-rw-r--r--contracts/exchange/contracts/examples/Wallet.sol65
-rw-r--r--contracts/exchange/contracts/examples/Whitelist.sol136
-rw-r--r--contracts/exchange/contracts/src/Exchange.sol (renamed from contracts/exchange/contracts/exchange/Exchange.sol)2
-rw-r--r--contracts/exchange/contracts/src/MixinAssetProxyDispatcher.sol (renamed from contracts/exchange/contracts/exchange/MixinAssetProxyDispatcher.sol)4
-rw-r--r--contracts/exchange/contracts/src/MixinExchangeCore.sol (renamed from contracts/exchange/contracts/exchange/MixinExchangeCore.sol)10
-rw-r--r--contracts/exchange/contracts/src/MixinMatchOrders.sol (renamed from contracts/exchange/contracts/exchange/MixinMatchOrders.sol)10
-rw-r--r--contracts/exchange/contracts/src/MixinSignatureValidator.sol (renamed from contracts/exchange/contracts/exchange/MixinSignatureValidator.sol)8
-rw-r--r--contracts/exchange/contracts/src/MixinTransactions.sol (renamed from contracts/exchange/contracts/exchange/MixinTransactions.sol)4
-rw-r--r--contracts/exchange/contracts/src/MixinWrapperFunctions.sol (renamed from contracts/exchange/contracts/exchange/MixinWrapperFunctions.sol)10
-rw-r--r--contracts/exchange/contracts/src/interfaces/IAssetProxyDispatcher.sol37
-rw-r--r--contracts/exchange/contracts/src/interfaces/IExchange.sol38
-rw-r--r--contracts/exchange/contracts/src/interfaces/IExchangeCore.sol60
-rw-r--r--contracts/exchange/contracts/src/interfaces/IMatchOrders.sol44
-rw-r--r--contracts/exchange/contracts/src/interfaces/ISignatureValidator.sol57
-rw-r--r--contracts/exchange/contracts/src/interfaces/ITransactions.sol35
-rw-r--r--contracts/exchange/contracts/src/interfaces/IValidator.sol37
-rw-r--r--contracts/exchange/contracts/src/interfaces/IWallet.sol35
-rw-r--r--contracts/exchange/contracts/src/interfaces/IWrapperFunctions.sol160
-rw-r--r--contracts/exchange/contracts/src/mixins/MAssetProxyDispatcher.sol (renamed from contracts/exchange/contracts/exchange/mixins/MAssetProxyDispatcher.sol)2
-rw-r--r--contracts/exchange/contracts/src/mixins/MExchangeCore.sol (renamed from contracts/exchange/contracts/exchange/mixins/MExchangeCore.sol)6
-rw-r--r--contracts/exchange/contracts/src/mixins/MMatchOrders.sol (renamed from contracts/exchange/contracts/exchange/mixins/MMatchOrders.sol)6
-rw-r--r--contracts/exchange/contracts/src/mixins/MSignatureValidator.sol (renamed from contracts/exchange/contracts/exchange/mixins/MSignatureValidator.sol)2
-rw-r--r--contracts/exchange/contracts/src/mixins/MTransactions.sol (renamed from contracts/exchange/contracts/exchange/mixins/MTransactions.sol)2
-rw-r--r--contracts/exchange/contracts/src/mixins/MWrapperFunctions.sol (renamed from contracts/exchange/contracts/exchange/mixins/MWrapperFunctions.sol)6
-rw-r--r--contracts/exchange/contracts/test/TestAssetProxyDispatcher.sol2
-rw-r--r--contracts/exchange/contracts/test/TestExchangeInternals.sol2
-rw-r--r--contracts/exchange/contracts/test/TestSignatureValidator.sol4
-rw-r--r--contracts/exchange/contracts/test/TestStaticCallReceiver.sol2
-rw-r--r--contracts/exchange/package.json6
-rw-r--r--contracts/exchange/src/artifacts/index.ts26
-rw-r--r--contracts/exchange/src/wrappers/index.ts13
-rw-r--r--contracts/exchange/test/signature_validator.ts7
-rw-r--r--contracts/exchange/test/transactions.ts7
-rw-r--r--contracts/exchange/tsconfig.json15
37 files changed, 977 insertions, 54 deletions
diff --git a/contracts/exchange/compiler.json b/contracts/exchange/compiler.json
index ac4d85f3a..e53fce0ec 100644
--- a/contracts/exchange/compiler.json
+++ b/contracts/exchange/compiler.json
@@ -20,9 +20,22 @@
},
"contracts": [
"Exchange",
+ "IAssetProxyDispatcher",
+ "IExchange",
+ "IExchangeCore",
+ "IMatchOrders",
+ "ISignatureValidator",
+ "ITransactions",
+ "IValidator",
+ "IWallet",
+ "IWrapperFunctions",
"TestAssetProxyDispatcher",
"TestExchangeInternals",
"TestSignatureValidator",
- "TestStaticCallReceiver"
+ "TestStaticCallReceiver",
+ "ExchangeWrapper",
+ "Validator",
+ "Wallet",
+ "Whitelist"
]
}
diff --git a/contracts/exchange/contracts/examples/ExchangeWrapper.sol b/contracts/exchange/contracts/examples/ExchangeWrapper.sol
new file mode 100644
index 000000000..604f614b5
--- /dev/null
+++ b/contracts/exchange/contracts/examples/ExchangeWrapper.sol
@@ -0,0 +1,100 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity 0.4.24;
+pragma experimental ABIEncoderV2;
+
+import "../src/interfaces/IExchange.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+
+
+contract ExchangeWrapper {
+
+ // Exchange contract.
+ // solhint-disable-next-line var-name-mixedcase
+ IExchange internal EXCHANGE;
+
+ constructor (address _exchange)
+ public
+ {
+ EXCHANGE = IExchange(_exchange);
+ }
+
+ /// @dev Cancels all orders created by sender with a salt less than or equal to the targetOrderEpoch
+ /// and senderAddress equal to this contract.
+ /// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled.
+ /// @param salt Arbitrary value to gaurantee uniqueness of 0x transaction hash.
+ /// @param makerSignature Proof that maker wishes to call this function with given params.
+ function cancelOrdersUpTo(
+ uint256 targetOrderEpoch,
+ uint256 salt,
+ bytes makerSignature
+ )
+ external
+ {
+ address makerAddress = msg.sender;
+
+ // Encode arguments into byte array.
+ bytes memory data = abi.encodeWithSelector(
+ EXCHANGE.cancelOrdersUpTo.selector,
+ targetOrderEpoch
+ );
+
+ // Call `cancelOrdersUpTo` via `executeTransaction`.
+ EXCHANGE.executeTransaction(
+ salt,
+ makerAddress,
+ data,
+ makerSignature
+ );
+ }
+
+ /// @dev Fills an order using `msg.sender` as the taker.
+ /// @param order Order struct containing order specifications.
+ /// @param takerAssetFillAmount Desired amount of takerAsset to sell.
+ /// @param salt Arbitrary value to gaurantee uniqueness of 0x transaction hash.
+ /// @param orderSignature Proof that order has been created by maker.
+ /// @param takerSignature Proof that taker wishes to call this function with given params.
+ function fillOrder(
+ LibOrder.Order memory order,
+ uint256 takerAssetFillAmount,
+ uint256 salt,
+ bytes memory orderSignature,
+ bytes memory takerSignature
+ )
+ public
+ {
+ address takerAddress = msg.sender;
+
+ // Encode arguments into byte array.
+ bytes memory data = abi.encodeWithSelector(
+ EXCHANGE.fillOrder.selector,
+ order,
+ takerAssetFillAmount,
+ orderSignature
+ );
+
+ // Call `fillOrder` via `executeTransaction`.
+ EXCHANGE.executeTransaction(
+ salt,
+ takerAddress,
+ data,
+ takerSignature
+ );
+ }
+}
diff --git a/contracts/exchange/contracts/examples/Validator.sol b/contracts/exchange/contracts/examples/Validator.sol
new file mode 100644
index 000000000..98a10d37f
--- /dev/null
+++ b/contracts/exchange/contracts/examples/Validator.sol
@@ -0,0 +1,56 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity 0.4.24;
+
+import "../src/interfaces/IValidator.sol";
+
+
+contract Validator is
+ IValidator
+{
+
+ // The single valid signer for this wallet.
+ // solhint-disable-next-line var-name-mixedcase
+ address internal VALID_SIGNER;
+
+ /// @dev constructs a new `Validator` with a single valid signer.
+ /// @param validSigner The sole, valid signer.
+ constructor (address validSigner) public {
+ VALID_SIGNER = validSigner;
+ }
+
+ /// @dev Verifies that a signature is valid. `signer` must match `VALID_SIGNER`.
+ /// @param hash Message hash that is signed.
+ /// @param signerAddress Address that should have signed the given hash.
+ /// @param signature Proof of signing.
+ /// @return Validity of signature.
+ // solhint-disable no-unused-vars
+ function isValidSignature(
+ bytes32 hash,
+ address signerAddress,
+ bytes signature
+ )
+ external
+ view
+ returns (bool isValid)
+ {
+ return (signerAddress == VALID_SIGNER);
+ }
+ // solhint-enable no-unused-vars
+}
diff --git a/contracts/exchange/contracts/examples/Wallet.sol b/contracts/exchange/contracts/examples/Wallet.sol
new file mode 100644
index 000000000..17e3dd5cc
--- /dev/null
+++ b/contracts/exchange/contracts/examples/Wallet.sol
@@ -0,0 +1,65 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity 0.4.24;
+
+import "../src/interfaces/IWallet.sol";
+import "@0x/contracts-utils/contracts/src/LibBytes.sol";
+
+
+contract Wallet is
+ IWallet
+{
+ using LibBytes for bytes;
+
+ // The owner of this wallet.
+ // solhint-disable-next-line var-name-mixedcase
+ address internal WALLET_OWNER;
+
+ /// @dev constructs a new `Wallet` with a single owner.
+ /// @param walletOwner The owner of this wallet.
+ constructor (address walletOwner) public {
+ WALLET_OWNER = walletOwner;
+ }
+
+ /// @dev Validates an EIP712 signature.
+ /// The signer must match the owner of this wallet.
+ /// @param hash Message hash that is signed.
+ /// @param eip712Signature Proof of signing.
+ /// @return Validity of signature.
+ function isValidSignature(
+ bytes32 hash,
+ bytes eip712Signature
+ )
+ external
+ view
+ returns (bool isValid)
+ {
+ require(
+ eip712Signature.length == 65,
+ "LENGTH_65_REQUIRED"
+ );
+
+ uint8 v = uint8(eip712Signature[0]);
+ bytes32 r = eip712Signature.readBytes32(1);
+ bytes32 s = eip712Signature.readBytes32(33);
+ address recoveredAddress = ecrecover(hash, v, r, s);
+ isValid = WALLET_OWNER == recoveredAddress;
+ return isValid;
+ }
+}
diff --git a/contracts/exchange/contracts/examples/Whitelist.sol b/contracts/exchange/contracts/examples/Whitelist.sol
new file mode 100644
index 000000000..a9db1bb82
--- /dev/null
+++ b/contracts/exchange/contracts/examples/Whitelist.sol
@@ -0,0 +1,136 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity 0.4.24;
+pragma experimental ABIEncoderV2;
+
+import "../src/interfaces/IExchange.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-utils/contracts/src/Ownable.sol";
+
+
+contract Whitelist is
+ Ownable
+{
+
+ // Mapping of address => whitelist status.
+ mapping (address => bool) public isWhitelisted;
+
+ // Exchange contract.
+ // solhint-disable var-name-mixedcase
+ IExchange internal EXCHANGE;
+ bytes internal TX_ORIGIN_SIGNATURE;
+ // solhint-enable var-name-mixedcase
+
+ byte constant internal VALIDATOR_SIGNATURE_BYTE = "\x05";
+
+ constructor (address _exchange)
+ public
+ {
+ EXCHANGE = IExchange(_exchange);
+ TX_ORIGIN_SIGNATURE = abi.encodePacked(address(this), VALIDATOR_SIGNATURE_BYTE);
+ }
+
+ /// @dev Adds or removes an address from the whitelist.
+ /// @param target Address to add or remove from whitelist.
+ /// @param isApproved Whitelist status to assign to address.
+ function updateWhitelistStatus(
+ address target,
+ bool isApproved
+ )
+ external
+ onlyOwner
+ {
+ isWhitelisted[target] = isApproved;
+ }
+
+ /// @dev Verifies signer is same as signer of current Ethereum transaction.
+ /// NOTE: This function can currently be used to validate signatures coming from outside of this contract.
+ /// Extra safety checks can be added for a production contract.
+ /// @param signerAddress Address that should have signed the given hash.
+ /// @param signature Proof of signing.
+ /// @return Validity of order signature.
+ // solhint-disable no-unused-vars
+ function isValidSignature(
+ bytes32 hash,
+ address signerAddress,
+ bytes signature
+ )
+ external
+ view
+ returns (bool isValid)
+ {
+ // solhint-disable-next-line avoid-tx-origin
+ return signerAddress == tx.origin;
+ }
+ // solhint-enable no-unused-vars
+
+ /// @dev Fills an order using `msg.sender` as the taker.
+ /// The transaction will revert if both the maker and taker are not whitelisted.
+ /// Orders should specify this contract as the `senderAddress` in order to gaurantee
+ /// that both maker and taker have been whitelisted.
+ /// @param order Order struct containing order specifications.
+ /// @param takerAssetFillAmount Desired amount of takerAsset to sell.
+ /// @param salt Arbitrary value to gaurantee uniqueness of 0x transaction hash.
+ /// @param orderSignature Proof that order has been created by maker.
+ function fillOrderIfWhitelisted(
+ LibOrder.Order memory order,
+ uint256 takerAssetFillAmount,
+ uint256 salt,
+ bytes memory orderSignature
+ )
+ public
+ {
+ address takerAddress = msg.sender;
+
+ // This contract must be the entry point for the transaction.
+ require(
+ // solhint-disable-next-line avoid-tx-origin
+ takerAddress == tx.origin,
+ "INVALID_SENDER"
+ );
+
+ // Check if maker is on the whitelist.
+ require(
+ isWhitelisted[order.makerAddress],
+ "MAKER_NOT_WHITELISTED"
+ );
+
+ // Check if taker is on the whitelist.
+ require(
+ isWhitelisted[takerAddress],
+ "TAKER_NOT_WHITELISTED"
+ );
+
+ // Encode arguments into byte array.
+ bytes memory data = abi.encodeWithSelector(
+ EXCHANGE.fillOrder.selector,
+ order,
+ takerAssetFillAmount,
+ orderSignature
+ );
+
+ // Call `fillOrder` via `executeTransaction`.
+ EXCHANGE.executeTransaction(
+ salt,
+ takerAddress,
+ data,
+ TX_ORIGIN_SIGNATURE
+ );
+ }
+}
diff --git a/contracts/exchange/contracts/exchange/Exchange.sol b/contracts/exchange/contracts/src/Exchange.sol
index 87a7fbe4e..541750518 100644
--- a/contracts/exchange/contracts/exchange/Exchange.sol
+++ b/contracts/exchange/contracts/src/Exchange.sol
@@ -19,7 +19,7 @@
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibConstants.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibConstants.sol";
import "./MixinExchangeCore.sol";
import "./MixinSignatureValidator.sol";
import "./MixinWrapperFunctions.sol";
diff --git a/contracts/exchange/contracts/exchange/MixinAssetProxyDispatcher.sol b/contracts/exchange/contracts/src/MixinAssetProxyDispatcher.sol
index 521b8c4ac..c55d6aaec 100644
--- a/contracts/exchange/contracts/exchange/MixinAssetProxyDispatcher.sol
+++ b/contracts/exchange/contracts/src/MixinAssetProxyDispatcher.sol
@@ -18,9 +18,9 @@
pragma solidity ^0.4.24;
-import "@0x/contracts-utils/contracts/utils/Ownable.sol";
+import "@0x/contracts-utils/contracts/src/Ownable.sol";
import "./mixins/MAssetProxyDispatcher.sol";
-import "@0x/contracts-interfaces/contracts/protocol/AssetProxy/IAssetProxy.sol";
+import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetProxy.sol";
contract MixinAssetProxyDispatcher is
diff --git a/contracts/exchange/contracts/exchange/MixinExchangeCore.sol b/contracts/exchange/contracts/src/MixinExchangeCore.sol
index ef72195f5..2e4f717c9 100644
--- a/contracts/exchange/contracts/exchange/MixinExchangeCore.sol
+++ b/contracts/exchange/contracts/src/MixinExchangeCore.sol
@@ -19,11 +19,11 @@
pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;
-import "@0x/contracts-utils/contracts/utils/ReentrancyGuard.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibConstants.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibFillResults.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibOrder.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibMath.sol";
+import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibConstants.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
import "./mixins/MExchangeCore.sol";
import "./mixins/MSignatureValidator.sol";
import "./mixins/MTransactions.sol";
diff --git a/contracts/exchange/contracts/exchange/MixinMatchOrders.sol b/contracts/exchange/contracts/src/MixinMatchOrders.sol
index 9ec8d3654..e84842793 100644
--- a/contracts/exchange/contracts/exchange/MixinMatchOrders.sol
+++ b/contracts/exchange/contracts/src/MixinMatchOrders.sol
@@ -14,11 +14,11 @@
pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;
-import "@0x/contracts-utils/contracts/utils/ReentrancyGuard.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibConstants.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibMath.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibOrder.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibFillResults.sol";
+import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibConstants.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
import "./mixins/MExchangeCore.sol";
import "./mixins/MMatchOrders.sol";
import "./mixins/MTransactions.sol";
diff --git a/contracts/exchange/contracts/exchange/MixinSignatureValidator.sol b/contracts/exchange/contracts/src/MixinSignatureValidator.sol
index 91e47bb11..421ec666a 100644
--- a/contracts/exchange/contracts/exchange/MixinSignatureValidator.sol
+++ b/contracts/exchange/contracts/src/MixinSignatureValidator.sol
@@ -18,12 +18,12 @@
pragma solidity ^0.4.24;
-import "@0x/contracts-utils/contracts/utils/LibBytes.sol";
-import "@0x/contracts-utils/contracts/utils/ReentrancyGuard.sol";
+import "@0x/contracts-utils/contracts/src/LibBytes.sol";
+import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
import "./mixins/MSignatureValidator.sol";
import "./mixins/MTransactions.sol";
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/IWallet.sol";
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/IValidator.sol";
+import "./interfaces/IWallet.sol";
+import "./interfaces/IValidator.sol";
contract MixinSignatureValidator is
diff --git a/contracts/exchange/contracts/exchange/MixinTransactions.sol b/contracts/exchange/contracts/src/MixinTransactions.sol
index 40d4e6f36..6b9b06b0d 100644
--- a/contracts/exchange/contracts/exchange/MixinTransactions.sol
+++ b/contracts/exchange/contracts/src/MixinTransactions.sol
@@ -17,10 +17,10 @@
*/
pragma solidity ^0.4.24;
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibExchangeErrors.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibExchangeErrors.sol";
import "./mixins/MSignatureValidator.sol";
import "./mixins/MTransactions.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibEIP712.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibEIP712.sol";
contract MixinTransactions is
diff --git a/contracts/exchange/contracts/exchange/MixinWrapperFunctions.sol b/contracts/exchange/contracts/src/MixinWrapperFunctions.sol
index e5a512d7c..911107422 100644
--- a/contracts/exchange/contracts/exchange/MixinWrapperFunctions.sol
+++ b/contracts/exchange/contracts/src/MixinWrapperFunctions.sol
@@ -19,11 +19,11 @@
pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;
-import "@0x/contracts-utils/contracts/utils/ReentrancyGuard.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibMath.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibOrder.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibFillResults.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibAbiEncoder.sol";
+import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibAbiEncoder.sol";
import "./mixins/MExchangeCore.sol";
import "./mixins/MWrapperFunctions.sol";
diff --git a/contracts/exchange/contracts/src/interfaces/IAssetProxyDispatcher.sol b/contracts/exchange/contracts/src/interfaces/IAssetProxyDispatcher.sol
new file mode 100644
index 000000000..b73881c07
--- /dev/null
+++ b/contracts/exchange/contracts/src/interfaces/IAssetProxyDispatcher.sol
@@ -0,0 +1,37 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity ^0.4.24;
+
+
+contract IAssetProxyDispatcher {
+
+ /// @dev Registers an asset proxy to its asset proxy id.
+ /// Once an asset proxy is registered, it cannot be unregistered.
+ /// @param assetProxy Address of new asset proxy to register.
+ function registerAssetProxy(address assetProxy)
+ external;
+
+ /// @dev Gets an asset proxy.
+ /// @param assetProxyId Id of the asset proxy.
+ /// @return The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered.
+ function getAssetProxy(bytes4 assetProxyId)
+ external
+ view
+ returns (address);
+}
diff --git a/contracts/exchange/contracts/src/interfaces/IExchange.sol b/contracts/exchange/contracts/src/interfaces/IExchange.sol
new file mode 100644
index 000000000..866e4c194
--- /dev/null
+++ b/contracts/exchange/contracts/src/interfaces/IExchange.sol
@@ -0,0 +1,38 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity ^0.4.24;
+pragma experimental ABIEncoderV2;
+
+import "./IExchangeCore.sol";
+import "./IMatchOrders.sol";
+import "./ISignatureValidator.sol";
+import "./ITransactions.sol";
+import "./IAssetProxyDispatcher.sol";
+import "./IWrapperFunctions.sol";
+
+
+// solhint-disable no-empty-blocks
+contract IExchange is
+ IExchangeCore,
+ IMatchOrders,
+ ISignatureValidator,
+ ITransactions,
+ IAssetProxyDispatcher,
+ IWrapperFunctions
+{}
diff --git a/contracts/exchange/contracts/src/interfaces/IExchangeCore.sol b/contracts/exchange/contracts/src/interfaces/IExchangeCore.sol
new file mode 100644
index 000000000..f87abb2ad
--- /dev/null
+++ b/contracts/exchange/contracts/src/interfaces/IExchangeCore.sol
@@ -0,0 +1,60 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity ^0.4.24;
+pragma experimental ABIEncoderV2;
+
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
+
+
+contract IExchangeCore {
+
+ /// @dev Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch
+ /// and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress).
+ /// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled.
+ function cancelOrdersUpTo(uint256 targetOrderEpoch)
+ external;
+
+ /// @dev Fills the input order.
+ /// @param order Order struct containing order specifications.
+ /// @param takerAssetFillAmount Desired amount of takerAsset to sell.
+ /// @param signature Proof that order has been created by maker.
+ /// @return Amounts filled and fees paid by maker and taker.
+ function fillOrder(
+ LibOrder.Order memory order,
+ uint256 takerAssetFillAmount,
+ bytes memory signature
+ )
+ public
+ returns (LibFillResults.FillResults memory fillResults);
+
+ /// @dev After calling, the order can not be filled anymore.
+ /// @param order Order struct containing order specifications.
+ function cancelOrder(LibOrder.Order memory order)
+ public;
+
+ /// @dev Gets information about an order: status, hash, and amount filled.
+ /// @param order Order to gather information on.
+ /// @return OrderInfo Information about the order and its state.
+ /// See LibOrder.OrderInfo for a complete description.
+ function getOrderInfo(LibOrder.Order memory order)
+ public
+ view
+ returns (LibOrder.OrderInfo memory orderInfo);
+}
diff --git a/contracts/exchange/contracts/src/interfaces/IMatchOrders.sol b/contracts/exchange/contracts/src/interfaces/IMatchOrders.sol
new file mode 100644
index 000000000..fba1da6d9
--- /dev/null
+++ b/contracts/exchange/contracts/src/interfaces/IMatchOrders.sol
@@ -0,0 +1,44 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+pragma solidity ^0.4.24;
+pragma experimental ABIEncoderV2;
+
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
+
+
+contract IMatchOrders {
+
+ /// @dev Match two complementary orders that have a profitable spread.
+ /// Each order is filled at their respective price point. However, the calculations are
+ /// carried out as though the orders are both being filled at the right order's price point.
+ /// The profit made by the left order goes to the taker (who matched the two orders).
+ /// @param leftOrder First order to match.
+ /// @param rightOrder Second order to match.
+ /// @param leftSignature Proof that order was created by the left maker.
+ /// @param rightSignature Proof that order was created by the right maker.
+ /// @return matchedFillResults Amounts filled and fees paid by maker and taker of matched orders.
+ function matchOrders(
+ LibOrder.Order memory leftOrder,
+ LibOrder.Order memory rightOrder,
+ bytes memory leftSignature,
+ bytes memory rightSignature
+ )
+ public
+ returns (LibFillResults.MatchedFillResults memory matchedFillResults);
+}
diff --git a/contracts/exchange/contracts/src/interfaces/ISignatureValidator.sol b/contracts/exchange/contracts/src/interfaces/ISignatureValidator.sol
new file mode 100644
index 000000000..c5a4a57e1
--- /dev/null
+++ b/contracts/exchange/contracts/src/interfaces/ISignatureValidator.sol
@@ -0,0 +1,57 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity ^0.4.24;
+
+
+contract ISignatureValidator {
+
+ /// @dev Approves a hash on-chain using any valid signature type.
+ /// After presigning a hash, the preSign signature type will become valid for that hash and signer.
+ /// @param signerAddress Address that should have signed the given hash.
+ /// @param signature Proof that the hash has been signed by signer.
+ function preSign(
+ bytes32 hash,
+ address signerAddress,
+ bytes signature
+ )
+ external;
+
+ /// @dev Approves/unnapproves a Validator contract to verify signatures on signer's behalf.
+ /// @param validatorAddress Address of Validator contract.
+ /// @param approval Approval or disapproval of Validator contract.
+ function setSignatureValidatorApproval(
+ address validatorAddress,
+ bool approval
+ )
+ external;
+
+ /// @dev Verifies that a signature is valid.
+ /// @param hash Message hash that is signed.
+ /// @param signerAddress Address of signer.
+ /// @param signature Proof of signing.
+ /// @return Validity of order signature.
+ function isValidSignature(
+ bytes32 hash,
+ address signerAddress,
+ bytes memory signature
+ )
+ public
+ view
+ returns (bool isValid);
+}
diff --git a/contracts/exchange/contracts/src/interfaces/ITransactions.sol b/contracts/exchange/contracts/src/interfaces/ITransactions.sol
new file mode 100644
index 000000000..aaaee389f
--- /dev/null
+++ b/contracts/exchange/contracts/src/interfaces/ITransactions.sol
@@ -0,0 +1,35 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+pragma solidity ^0.4.24;
+
+
+contract ITransactions {
+
+ /// @dev Executes an exchange method call in the context of signer.
+ /// @param salt Arbitrary number to ensure uniqueness of transaction hash.
+ /// @param signerAddress Address of transaction signer.
+ /// @param data AbiV2 encoded calldata.
+ /// @param signature Proof of signer transaction by signer.
+ function executeTransaction(
+ uint256 salt,
+ address signerAddress,
+ bytes data,
+ bytes signature
+ )
+ external;
+}
diff --git a/contracts/exchange/contracts/src/interfaces/IValidator.sol b/contracts/exchange/contracts/src/interfaces/IValidator.sol
new file mode 100644
index 000000000..d214e54dd
--- /dev/null
+++ b/contracts/exchange/contracts/src/interfaces/IValidator.sol
@@ -0,0 +1,37 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity ^0.4.24;
+
+
+contract IValidator {
+
+ /// @dev Verifies that a signature is valid.
+ /// @param hash Message hash that is signed.
+ /// @param signerAddress Address that should have signed the given hash.
+ /// @param signature Proof of signing.
+ /// @return Validity of order signature.
+ function isValidSignature(
+ bytes32 hash,
+ address signerAddress,
+ bytes signature
+ )
+ external
+ view
+ returns (bool isValid);
+}
diff --git a/contracts/exchange/contracts/src/interfaces/IWallet.sol b/contracts/exchange/contracts/src/interfaces/IWallet.sol
new file mode 100644
index 000000000..c2db4a5b1
--- /dev/null
+++ b/contracts/exchange/contracts/src/interfaces/IWallet.sol
@@ -0,0 +1,35 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity ^0.4.24;
+
+
+contract IWallet {
+
+ /// @dev Verifies that a signature is valid.
+ /// @param hash Message hash that is signed.
+ /// @param signature Proof of signing.
+ /// @return Validity of order signature.
+ function isValidSignature(
+ bytes32 hash,
+ bytes signature
+ )
+ external
+ view
+ returns (bool isValid);
+}
diff --git a/contracts/exchange/contracts/src/interfaces/IWrapperFunctions.sol b/contracts/exchange/contracts/src/interfaces/IWrapperFunctions.sol
new file mode 100644
index 000000000..b1afc8895
--- /dev/null
+++ b/contracts/exchange/contracts/src/interfaces/IWrapperFunctions.sol
@@ -0,0 +1,160 @@
+/*
+
+ Copyright 2018 ZeroEx Intl.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+pragma solidity ^0.4.24;
+pragma experimental ABIEncoderV2;
+
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
+
+
+contract IWrapperFunctions {
+
+ /// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled.
+ /// @param order LibOrder.Order struct containing order specifications.
+ /// @param takerAssetFillAmount Desired amount of takerAsset to sell.
+ /// @param signature Proof that order has been created by maker.
+ function fillOrKillOrder(
+ LibOrder.Order memory order,
+ uint256 takerAssetFillAmount,
+ bytes memory signature
+ )
+ public
+ returns (LibFillResults.FillResults memory fillResults);
+
+ /// @dev Fills an order with specified parameters and ECDSA signature.
+ /// Returns false if the transaction would otherwise revert.
+ /// @param order LibOrder.Order struct containing order specifications.
+ /// @param takerAssetFillAmount Desired amount of takerAsset to sell.
+ /// @param signature Proof that order has been created by maker.
+ /// @return Amounts filled and fees paid by maker and taker.
+ function fillOrderNoThrow(
+ LibOrder.Order memory order,
+ uint256 takerAssetFillAmount,
+ bytes memory signature
+ )
+ public
+ returns (LibFillResults.FillResults memory fillResults);
+
+ /// @dev Synchronously executes multiple calls of fillOrder.
+ /// @param orders Array of order specifications.
+ /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
+ /// @param signatures Proofs that orders have been created by makers.
+ /// @return Amounts filled and fees paid by makers and taker.
+ function batchFillOrders(
+ LibOrder.Order[] memory orders,
+ uint256[] memory takerAssetFillAmounts,
+ bytes[] memory signatures
+ )
+ public
+ returns (LibFillResults.FillResults memory totalFillResults);
+
+ /// @dev Synchronously executes multiple calls of fillOrKill.
+ /// @param orders Array of order specifications.
+ /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
+ /// @param signatures Proofs that orders have been created by makers.
+ /// @return Amounts filled and fees paid by makers and taker.
+ function batchFillOrKillOrders(
+ LibOrder.Order[] memory orders,
+ uint256[] memory takerAssetFillAmounts,
+ bytes[] memory signatures
+ )
+ public
+ returns (LibFillResults.FillResults memory totalFillResults);
+
+ /// @dev Fills an order with specified parameters and ECDSA signature.
+ /// Returns false if the transaction would otherwise revert.
+ /// @param orders Array of order specifications.
+ /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
+ /// @param signatures Proofs that orders have been created by makers.
+ /// @return Amounts filled and fees paid by makers and taker.
+ function batchFillOrdersNoThrow(
+ LibOrder.Order[] memory orders,
+ uint256[] memory takerAssetFillAmounts,
+ bytes[] memory signatures
+ )
+ public
+ returns (LibFillResults.FillResults memory totalFillResults);
+
+ /// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker.
+ /// @param orders Array of order specifications.
+ /// @param takerAssetFillAmount Desired amount of takerAsset to sell.
+ /// @param signatures Proofs that orders have been created by makers.
+ /// @return Amounts filled and fees paid by makers and taker.
+ function marketSellOrders(
+ LibOrder.Order[] memory orders,
+ uint256 takerAssetFillAmount,
+ bytes[] memory signatures
+ )
+ public
+ returns (LibFillResults.FillResults memory totalFillResults);
+
+ /// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker.
+ /// Returns false if the transaction would otherwise revert.
+ /// @param orders Array of order specifications.
+ /// @param takerAssetFillAmount Desired amount of takerAsset to sell.
+ /// @param signatures Proofs that orders have been signed by makers.
+ /// @return Amounts filled and fees paid by makers and taker.
+ function marketSellOrdersNoThrow(
+ LibOrder.Order[] memory orders,
+ uint256 takerAssetFillAmount,
+ bytes[] memory signatures
+ )
+ public
+ returns (LibFillResults.FillResults memory totalFillResults);
+
+ /// @dev Synchronously executes multiple calls of fillOrder until total amount of makerAsset is bought by taker.
+ /// @param orders Array of order specifications.
+ /// @param makerAssetFillAmount Desired amount of makerAsset to buy.
+ /// @param signatures Proofs that orders have been signed by makers.
+ /// @return Amounts filled and fees paid by makers and taker.
+ function marketBuyOrders(
+ LibOrder.Order[] memory orders,
+ uint256 makerAssetFillAmount,
+ bytes[] memory signatures
+ )
+ public
+ returns (LibFillResults.FillResults memory totalFillResults);
+
+ /// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker.
+ /// Returns false if the transaction would otherwise revert.
+ /// @param orders Array of order specifications.
+ /// @param makerAssetFillAmount Desired amount of makerAsset to buy.
+ /// @param signatures Proofs that orders have been signed by makers.
+ /// @return Amounts filled and fees paid by makers and taker.
+ function marketBuyOrdersNoThrow(
+ LibOrder.Order[] memory orders,
+ uint256 makerAssetFillAmount,
+ bytes[] memory signatures
+ )
+ public
+ returns (LibFillResults.FillResults memory totalFillResults);
+
+ /// @dev Synchronously cancels multiple orders in a single transaction.
+ /// @param orders Array of order specifications.
+ function batchCancelOrders(LibOrder.Order[] memory orders)
+ public;
+
+ /// @dev Fetches information for all passed in orders
+ /// @param orders Array of order specifications.
+ /// @return Array of OrderInfo instances that correspond to each order.
+ function getOrdersInfo(LibOrder.Order[] memory orders)
+ public
+ view
+ returns (LibOrder.OrderInfo[] memory);
+}
diff --git a/contracts/exchange/contracts/exchange/mixins/MAssetProxyDispatcher.sol b/contracts/exchange/contracts/src/mixins/MAssetProxyDispatcher.sol
index 05c2c4c0b..0ae555dda 100644
--- a/contracts/exchange/contracts/exchange/mixins/MAssetProxyDispatcher.sol
+++ b/contracts/exchange/contracts/src/mixins/MAssetProxyDispatcher.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.24;
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/IAssetProxyDispatcher.sol";
+import "../interfaces/IAssetProxyDispatcher.sol";
contract MAssetProxyDispatcher is
diff --git a/contracts/exchange/contracts/exchange/mixins/MExchangeCore.sol b/contracts/exchange/contracts/src/mixins/MExchangeCore.sol
index 122cdc8a0..b5a9c660b 100644
--- a/contracts/exchange/contracts/exchange/mixins/MExchangeCore.sol
+++ b/contracts/exchange/contracts/src/mixins/MExchangeCore.sol
@@ -19,9 +19,9 @@
pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibOrder.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibFillResults.sol";
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchangeCore.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
+import "../interfaces/IExchangeCore.sol";
contract MExchangeCore is
diff --git a/contracts/exchange/contracts/exchange/mixins/MMatchOrders.sol b/contracts/exchange/contracts/src/mixins/MMatchOrders.sol
index 4a056b980..3dcc9f31b 100644
--- a/contracts/exchange/contracts/exchange/mixins/MMatchOrders.sol
+++ b/contracts/exchange/contracts/src/mixins/MMatchOrders.sol
@@ -18,9 +18,9 @@
pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibOrder.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibFillResults.sol";
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/IMatchOrders.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
+import "../interfaces/IMatchOrders.sol";
contract MMatchOrders is
diff --git a/contracts/exchange/contracts/exchange/mixins/MSignatureValidator.sol b/contracts/exchange/contracts/src/mixins/MSignatureValidator.sol
index 6407760d4..c39e84e08 100644
--- a/contracts/exchange/contracts/exchange/mixins/MSignatureValidator.sol
+++ b/contracts/exchange/contracts/src/mixins/MSignatureValidator.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.24;
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/ISignatureValidator.sol";
+import "../interfaces/ISignatureValidator.sol";
contract MSignatureValidator is
diff --git a/contracts/exchange/contracts/exchange/mixins/MTransactions.sol b/contracts/exchange/contracts/src/mixins/MTransactions.sol
index 04dd716d7..04a25ccf3 100644
--- a/contracts/exchange/contracts/exchange/mixins/MTransactions.sol
+++ b/contracts/exchange/contracts/src/mixins/MTransactions.sol
@@ -17,7 +17,7 @@
*/
pragma solidity ^0.4.24;
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/ITransactions.sol";
+import "../interfaces/ITransactions.sol";
contract MTransactions is
diff --git a/contracts/exchange/contracts/exchange/mixins/MWrapperFunctions.sol b/contracts/exchange/contracts/src/mixins/MWrapperFunctions.sol
index 6bf9fd331..df50c6a8e 100644
--- a/contracts/exchange/contracts/exchange/mixins/MWrapperFunctions.sol
+++ b/contracts/exchange/contracts/src/mixins/MWrapperFunctions.sol
@@ -19,9 +19,9 @@
pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibOrder.sol";
-import "@0x/contracts-exchange-libs/contracts/exchange-libs/LibFillResults.sol";
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/IWrapperFunctions.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
+import "../interfaces/IWrapperFunctions.sol";
contract MWrapperFunctions is
diff --git a/contracts/exchange/contracts/test/TestAssetProxyDispatcher.sol b/contracts/exchange/contracts/test/TestAssetProxyDispatcher.sol
index dbd6df148..88155c6ee 100644
--- a/contracts/exchange/contracts/test/TestAssetProxyDispatcher.sol
+++ b/contracts/exchange/contracts/test/TestAssetProxyDispatcher.sol
@@ -18,7 +18,7 @@
pragma solidity 0.4.24;
-import "../exchange/MixinAssetProxyDispatcher.sol";
+import "../src/MixinAssetProxyDispatcher.sol";
contract TestAssetProxyDispatcher is
diff --git a/contracts/exchange/contracts/test/TestExchangeInternals.sol b/contracts/exchange/contracts/test/TestExchangeInternals.sol
index ab3e23f91..dce8e03c0 100644
--- a/contracts/exchange/contracts/test/TestExchangeInternals.sol
+++ b/contracts/exchange/contracts/test/TestExchangeInternals.sol
@@ -19,7 +19,7 @@
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
-import "../exchange/Exchange.sol";
+import "../src/Exchange.sol";
// solhint-disable no-empty-blocks
diff --git a/contracts/exchange/contracts/test/TestSignatureValidator.sol b/contracts/exchange/contracts/test/TestSignatureValidator.sol
index 1e12a2592..2f9523666 100644
--- a/contracts/exchange/contracts/test/TestSignatureValidator.sol
+++ b/contracts/exchange/contracts/test/TestSignatureValidator.sol
@@ -18,8 +18,8 @@
pragma solidity 0.4.24;
-import "../exchange/MixinSignatureValidator.sol";
-import "../exchange/MixinTransactions.sol";
+import "../src/MixinSignatureValidator.sol";
+import "../src/MixinTransactions.sol";
contract TestSignatureValidator is
diff --git a/contracts/exchange/contracts/test/TestStaticCallReceiver.sol b/contracts/exchange/contracts/test/TestStaticCallReceiver.sol
index d08da7303..522887fcb 100644
--- a/contracts/exchange/contracts/test/TestStaticCallReceiver.sol
+++ b/contracts/exchange/contracts/test/TestStaticCallReceiver.sol
@@ -18,7 +18,7 @@
pragma solidity 0.4.24;
-import "@0x/contracts-tokens/contracts/tokens/ERC20Token/IERC20Token.sol";
+import "@0x/contracts-tokens/contracts/ERC20Token/IERC20Token.sol";
// solhint-disable no-unused-vars
diff --git a/contracts/exchange/package.json b/contracts/exchange/package.json
index daaba038f..abe6d7210 100644
--- a/contracts/exchange/package.json
+++ b/contracts/exchange/package.json
@@ -32,7 +32,7 @@
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
},
"config": {
- "abis": "generated-artifacts/@(ERC20Proxy|ERC721Proxy|Exchange|MixinAuthorizable|MultiAssetProxy|TestSignatureValidator|TestAssetProxyDispatcher|TestExchangeInternals|TestStaticCallReceiver).json"
+ "abis": "generated-artifacts/@(ERC20Proxy|ERC721Proxy|Exchange|IAssetProxyDispatcher|IExchange|IExchangeCore|IMatchOrders|ISignatureValidator|ITransactions|IWrapperFunctions|IValidator|IWallet|MixinAuthorizable|MultiAssetProxy|TestSignatureValidator|TestAssetProxyDispatcher|TestExchangeInternals|TestStaticCallReceiver|ExchangeWrapper|Validator|Wallet|Whitelist).json"
},
"repository": {
"type": "git",
@@ -69,10 +69,8 @@
},
"dependencies": {
"@0x/base-contract": "^3.0.13",
- "@0x/contracts-examples": "^1.0.6",
"@0x/contracts-asset-proxy": "^2.2.3",
- "@0x/contracts-interfaces": "^1.0.6",
- "@0x/contracts-libs": "^1.0.6",
+ "@0x/contracts-exchange-libs": "^1.0.6",
"@0x/contracts-multisig": "^1.0.6",
"@0x/contracts-test-utils": "^2.0.1",
"@0x/contracts-tokens": "^1.0.6",
diff --git a/contracts/exchange/src/artifacts/index.ts b/contracts/exchange/src/artifacts/index.ts
index 43dd77e58..798ff17ab 100644
--- a/contracts/exchange/src/artifacts/index.ts
+++ b/contracts/exchange/src/artifacts/index.ts
@@ -1,10 +1,23 @@
import { ContractArtifact } from 'ethereum-types';
import * as Exchange from '../../generated-artifacts/Exchange.json';
+import * as ExchangeWrapper from '../../generated-artifacts/ExchangeWrapper.json';
+import * as IAssetProxyDispatcher from '../../generated-artifacts/IAssetProxyDispatcher.json';
+import * as IExchange from '../../generated-artifacts/IExchange.json';
+import * as IExchangeCore from '../../generated-artifacts/IExchangeCore.json';
+import * as IMatchOrders from '../../generated-artifacts/IMatchOrders.json';
+import * as ISignatureValidator from '../../generated-artifacts/ISignatureValidator.json';
+import * as ITransactions from '../../generated-artifacts/ITransactions.json';
+import * as IValidator from '../../generated-artifacts/IValidator.json';
+import * as IWallet from '../../generated-artifacts/IWallet.json';
+import * as IWrapperFunctions from '../../generated-artifacts/IWrapperFunctions.json';
import * as TestAssetProxyDispatcher from '../../generated-artifacts/TestAssetProxyDispatcher.json';
import * as TestExchangeInternals from '../../generated-artifacts/TestExchangeInternals.json';
import * as TestSignatureValidator from '../../generated-artifacts/TestSignatureValidator.json';
import * as TestStaticCallReceiver from '../../generated-artifacts/TestStaticCallReceiver.json';
+import * as Validator from '../../generated-artifacts/Validator.json';
+import * as Wallet from '../../generated-artifacts/Wallet.json';
+import * as Whitelist from '../../generated-artifacts/Whitelist.json';
export const artifacts = {
Exchange: Exchange as ContractArtifact,
@@ -12,4 +25,17 @@ export const artifacts = {
TestExchangeInternals: TestExchangeInternals as ContractArtifact,
TestSignatureValidator: TestSignatureValidator as ContractArtifact,
TestStaticCallReceiver: TestStaticCallReceiver as ContractArtifact,
+ IExchange: IExchange as ContractArtifact,
+ IExchangeCore: IExchangeCore as ContractArtifact,
+ IMatchOrders: IMatchOrders as ContractArtifact,
+ ISignatureValidator: ISignatureValidator as ContractArtifact,
+ ITransactions: ITransactions as ContractArtifact,
+ IWrapperFunctions: IWrapperFunctions as ContractArtifact,
+ IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact,
+ IValidator: IValidator as ContractArtifact,
+ IWallet: IWallet as ContractArtifact,
+ ExchangeWrapper: ExchangeWrapper as ContractArtifact,
+ Validator: Validator as ContractArtifact,
+ Wallet: Wallet as ContractArtifact,
+ Whitelist: Whitelist as ContractArtifact,
};
diff --git a/contracts/exchange/src/wrappers/index.ts b/contracts/exchange/src/wrappers/index.ts
index 7ff5efca2..86e939b56 100644
--- a/contracts/exchange/src/wrappers/index.ts
+++ b/contracts/exchange/src/wrappers/index.ts
@@ -3,3 +3,16 @@ export * from '../../generated-wrappers/test_asset_proxy_dispatcher';
export * from '../../generated-wrappers/test_exchange_internals';
export * from '../../generated-wrappers/test_signature_validator';
export * from '../../generated-wrappers/test_static_call_receiver';
+export * from '../../generated-wrappers/i_asset_proxy_dispatcher';
+export * from '../../generated-wrappers/i_exchange';
+export * from '../../generated-wrappers/i_exchange_core';
+export * from '../../generated-wrappers/i_match_orders';
+export * from '../../generated-wrappers/i_signature_validator';
+export * from '../../generated-wrappers/i_transactions';
+export * from '../../generated-wrappers/i_wrapper_functions';
+export * from '../../generated-wrappers/i_validator';
+export * from '../../generated-wrappers/i_wallet';
+export * from '../../generated-wrappers/exchange_wrapper';
+export * from '../../generated-wrappers/validator';
+export * from '../../generated-wrappers/wallet';
+export * from '../../generated-wrappers/whitelist';
diff --git a/contracts/exchange/test/signature_validator.ts b/contracts/exchange/test/signature_validator.ts
index c5f9a5683..33b15b394 100644
--- a/contracts/exchange/test/signature_validator.ts
+++ b/contracts/exchange/test/signature_validator.ts
@@ -1,4 +1,3 @@
-import { artifacts as examplesArtifacts, ValidatorContract, WalletContract } from '@0x/contracts-examples';
import {
addressUtils,
chaiSetup,
@@ -23,6 +22,8 @@ import {
TestSignatureValidatorContract,
TestSignatureValidatorSignatureValidatorApprovalEventArgs,
TestStaticCallReceiverContract,
+ ValidatorContract,
+ WalletContract,
} from '../src';
chaiSetup.configure();
@@ -61,13 +62,13 @@ describe('MixinSignatureValidator', () => {
txDefaults,
);
testWallet = await WalletContract.deployFrom0xArtifactAsync(
- examplesArtifacts.Wallet,
+ artifacts.Wallet,
provider,
txDefaults,
signerAddress,
);
testValidator = await ValidatorContract.deployFrom0xArtifactAsync(
- examplesArtifacts.Validator,
+ artifacts.Validator,
provider,
txDefaults,
signerAddress,
diff --git a/contracts/exchange/test/transactions.ts b/contracts/exchange/test/transactions.ts
index 737944600..a1d855631 100644
--- a/contracts/exchange/test/transactions.ts
+++ b/contracts/exchange/test/transactions.ts
@@ -1,5 +1,4 @@
import { ERC20ProxyContract } from '@0x/contracts-asset-proxy';
-import { artifacts as examplesArtifacts, ExchangeWrapperContract, WhitelistContract } from '@0x/contracts-examples';
import {
chaiSetup,
constants,
@@ -22,7 +21,7 @@ import * as chai from 'chai';
import * as _ from 'lodash';
import { ExchangeContract } from '../generated-wrappers/exchange';
-import { artifacts } from '../src/artifacts';
+import { artifacts, ExchangeWrapperContract, WhitelistContract } from '../src/';
import { ERC20Wrapper } from './utils/erc20_wrapper';
import { ExchangeWrapper } from './utils/exchange_wrapper';
@@ -222,7 +221,7 @@ describe('Exchange transactions', () => {
before(async () => {
exchangeWrapperContract = await ExchangeWrapperContract.deployFrom0xArtifactAsync(
- examplesArtifacts.ExchangeWrapper,
+ artifacts.ExchangeWrapper,
provider,
txDefaults,
exchange.address,
@@ -336,7 +335,7 @@ describe('Exchange transactions', () => {
before(async () => {
whitelist = await WhitelistContract.deployFrom0xArtifactAsync(
- examplesArtifacts.Whitelist,
+ artifacts.Whitelist,
provider,
txDefaults,
exchange.address,
diff --git a/contracts/exchange/tsconfig.json b/contracts/exchange/tsconfig.json
index bd3ecbf1e..b0fcd1771 100644
--- a/contracts/exchange/tsconfig.json
+++ b/contracts/exchange/tsconfig.json
@@ -7,11 +7,24 @@
},
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
+ "./generated-artifacts/IAssetProxyDispatcher.json",
+ "./generated-artifacts/IExchange.json",
+ "./generated-artifacts/IExchangeCore.json",
+ "./generated-artifacts/IMatchOrders.json",
+ "./generated-artifacts/ISignatureValidator.json",
+ "./generated-artifacts/ITransactions.json",
+ "./generated-artifacts/IValidator.json",
+ "./generated-artifacts/IWallet.json",
+ "./generated-artifacts/IWrapperFunctions.json",
"./generated-artifacts/Exchange.json",
"./generated-artifacts/TestAssetProxyDispatcher.json",
"./generated-artifacts/TestExchangeInternals.json",
"./generated-artifacts/TestSignatureValidator.json",
- "./generated-artifacts/TestStaticCallReceiver.json"
+ "./generated-artifacts/TestStaticCallReceiver.json",
+ "./generated-artifacts/ExchangeWrapper.json",
+ "./generated-artifacts/Validator.json",
+ "./generated-artifacts/Wallet.json",
+ "./generated-artifacts/Whitelist.json"
],
"exclude": ["./deploy/solc/solc_bin"]
}