aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/extensions/contracts
diff options
context:
space:
mode:
Diffstat (limited to 'contracts/extensions/contracts')
-rw-r--r--contracts/extensions/contracts/Forwarder/Forwarder.sol50
-rw-r--r--contracts/extensions/contracts/Forwarder/MixinAssets.sol143
-rw-r--r--contracts/extensions/contracts/Forwarder/MixinExchangeWrapper.sol260
-rw-r--r--contracts/extensions/contracts/Forwarder/MixinForwarderCore.sol214
-rw-r--r--contracts/extensions/contracts/Forwarder/MixinWeth.sol113
-rw-r--r--contracts/extensions/contracts/Forwarder/interfaces/IAssets.sol34
-rw-r--r--contracts/extensions/contracts/Forwarder/interfaces/IForwarder.sol30
-rw-r--r--contracts/extensions/contracts/Forwarder/interfaces/IForwarderCore.sol80
-rw-r--r--contracts/extensions/contracts/Forwarder/libs/LibConstants.sol62
-rw-r--r--contracts/extensions/contracts/Forwarder/libs/LibForwarderErrors.sol34
-rw-r--r--contracts/extensions/contracts/Forwarder/mixins/MAssets.sol53
-rw-r--r--contracts/extensions/contracts/Forwarder/mixins/MExchangeWrapper.sol87
-rw-r--r--contracts/extensions/contracts/Forwarder/mixins/MWeth.sol41
-rw-r--r--contracts/extensions/contracts/src/BalanceThresholdFilter/BalanceThresholdFilter.sol (renamed from contracts/extensions/contracts/BalanceThresholdFilter/BalanceThresholdFilter.sol)2
-rw-r--r--contracts/extensions/contracts/src/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol (renamed from contracts/extensions/contracts/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol)4
-rw-r--r--contracts/extensions/contracts/src/BalanceThresholdFilter/MixinExchangeCalldata.sol (renamed from contracts/extensions/contracts/BalanceThresholdFilter/MixinExchangeCalldata.sol)2
-rw-r--r--contracts/extensions/contracts/src/BalanceThresholdFilter/interfaces/IBalanceThresholdFilterCore.sol (renamed from contracts/extensions/contracts/BalanceThresholdFilter/interfaces/IBalanceThresholdFilterCore.sol)0
-rw-r--r--contracts/extensions/contracts/src/BalanceThresholdFilter/interfaces/IThresholdAsset.sol (renamed from contracts/extensions/contracts/BalanceThresholdFilter/interfaces/IThresholdAsset.sol)0
-rw-r--r--contracts/extensions/contracts/src/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol (renamed from contracts/extensions/contracts/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol)2
-rw-r--r--contracts/extensions/contracts/src/BalanceThresholdFilter/mixins/MExchangeCalldata.sol (renamed from contracts/extensions/contracts/BalanceThresholdFilter/mixins/MExchangeCalldata.sol)0
-rw-r--r--contracts/extensions/contracts/src/DutchAuction/DutchAuction.sol (renamed from contracts/extensions/contracts/DutchAuction/DutchAuction.sol)10
-rw-r--r--contracts/extensions/contracts/src/OrderMatcher/MixinAssets.sol (renamed from contracts/extensions/contracts/OrderMatcher/MixinAssets.sol)8
-rw-r--r--contracts/extensions/contracts/src/OrderMatcher/MixinMatchOrders.sol (renamed from contracts/extensions/contracts/OrderMatcher/MixinMatchOrders.sol)6
-rw-r--r--contracts/extensions/contracts/src/OrderMatcher/OrderMatcher.sol (renamed from contracts/extensions/contracts/OrderMatcher/OrderMatcher.sol)2
-rw-r--r--contracts/extensions/contracts/src/OrderMatcher/interfaces/IAssets.sol (renamed from contracts/extensions/contracts/OrderMatcher/interfaces/IAssets.sol)0
-rw-r--r--contracts/extensions/contracts/src/OrderMatcher/interfaces/IMatchOrders.sol (renamed from contracts/extensions/contracts/OrderMatcher/interfaces/IMatchOrders.sol)2
-rw-r--r--contracts/extensions/contracts/src/OrderMatcher/interfaces/IOrderMatcher.sol (renamed from contracts/extensions/contracts/OrderMatcher/interfaces/IOrderMatcher.sol)2
-rw-r--r--contracts/extensions/contracts/src/OrderMatcher/libs/LibConstants.sol (renamed from contracts/extensions/contracts/OrderMatcher/libs/LibConstants.sol)2
-rw-r--r--contracts/extensions/contracts/src/OrderMatcher/mixins/MAssets.sol (renamed from contracts/extensions/contracts/OrderMatcher/mixins/MAssets.sol)0
-rw-r--r--contracts/extensions/contracts/src/OrderValidator/OrderValidator.sol (renamed from contracts/extensions/contracts/OrderValidator/OrderValidator.sol)10
30 files changed, 26 insertions, 1227 deletions
diff --git a/contracts/extensions/contracts/Forwarder/Forwarder.sol b/contracts/extensions/contracts/Forwarder/Forwarder.sol
deleted file mode 100644
index 94dec40ed..000000000
--- a/contracts/extensions/contracts/Forwarder/Forwarder.sol
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-
- 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 "./MixinWeth.sol";
-import "./MixinForwarderCore.sol";
-import "./libs/LibConstants.sol";
-import "./MixinAssets.sol";
-import "./MixinExchangeWrapper.sol";
-
-
-// solhint-disable no-empty-blocks
-contract Forwarder is
- LibConstants,
- MixinWeth,
- MixinAssets,
- MixinExchangeWrapper,
- MixinForwarderCore
-{
- constructor (
- address _exchange,
- bytes memory _zrxAssetData,
- bytes memory _wethAssetData
- )
- public
- LibConstants(
- _exchange,
- _zrxAssetData,
- _wethAssetData
- )
- MixinForwarderCore()
- {}
-}
diff --git a/contracts/extensions/contracts/Forwarder/MixinAssets.sol b/contracts/extensions/contracts/Forwarder/MixinAssets.sol
deleted file mode 100644
index 116cdf267..000000000
--- a/contracts/extensions/contracts/Forwarder/MixinAssets.sol
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-
- 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 "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
-import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
-import "@0x/contracts-tokens/contracts/tokens/ERC20Token/IERC20Token.sol";
-import "@0x/contracts-tokens/contracts/tokens/ERC721Token/IERC721Token.sol";
-import "./libs/LibConstants.sol";
-import "./mixins/MAssets.sol";
-
-
-contract MixinAssets is
- Ownable,
- LibConstants,
- MAssets
-{
- using LibBytes for bytes;
-
- bytes4 constant internal ERC20_TRANSFER_SELECTOR = bytes4(keccak256("transfer(address,uint256)"));
-
- /// @dev Withdraws assets from this contract. The contract requires a ZRX balance in order to
- /// function optimally, and this function allows the ZRX to be withdrawn by owner. It may also be
- /// used to withdraw assets that were accidentally sent to this contract.
- /// @param assetData Byte array encoded for the respective asset proxy.
- /// @param amount Amount of ERC20 token to withdraw.
- function withdrawAsset(
- bytes assetData,
- uint256 amount
- )
- external
- onlyOwner
- {
- transferAssetToSender(assetData, amount);
- }
-
- /// @dev Transfers given amount of asset to sender.
- /// @param assetData Byte array encoded for the respective asset proxy.
- /// @param amount Amount of asset to transfer to sender.
- function transferAssetToSender(
- bytes memory assetData,
- uint256 amount
- )
- internal
- {
- bytes4 proxyId = assetData.readBytes4(0);
-
- if (proxyId == ERC20_DATA_ID) {
- transferERC20Token(assetData, amount);
- } else if (proxyId == ERC721_DATA_ID) {
- transferERC721Token(assetData, amount);
- } else {
- revert("UNSUPPORTED_ASSET_PROXY");
- }
- }
-
- /// @dev Decodes ERC20 assetData and transfers given amount to sender.
- /// @param assetData Byte array encoded for the respective asset proxy.
- /// @param amount Amount of asset to transfer to sender.
- function transferERC20Token(
- bytes memory assetData,
- uint256 amount
- )
- internal
- {
- address token = assetData.readAddress(16);
-
- // Transfer tokens.
- // We do a raw call so we can check the success separate
- // from the return data.
- bool success = token.call(abi.encodeWithSelector(
- ERC20_TRANSFER_SELECTOR,
- msg.sender,
- amount
- ));
- require(
- success,
- "TRANSFER_FAILED"
- );
-
- // Check return data.
- // If there is no return data, we assume the token incorrectly
- // does not return a bool. In this case we expect it to revert
- // on failure, which was handled above.
- // If the token does return data, we require that it is a single
- // value that evaluates to true.
- assembly {
- if returndatasize {
- success := 0
- if eq(returndatasize, 32) {
- // First 64 bytes of memory are reserved scratch space
- returndatacopy(0, 0, 32)
- success := mload(0)
- }
- }
- }
- require(
- success,
- "TRANSFER_FAILED"
- );
- }
-
- /// @dev Decodes ERC721 assetData and transfers given amount to sender.
- /// @param assetData Byte array encoded for the respective asset proxy.
- /// @param amount Amount of asset to transfer to sender.
- function transferERC721Token(
- bytes memory assetData,
- uint256 amount
- )
- internal
- {
- require(
- amount == 1,
- "INVALID_AMOUNT"
- );
- // Decode asset data.
- address token = assetData.readAddress(16);
- uint256 tokenId = assetData.readUint256(36);
-
- // Perform transfer.
- IERC721Token(token).transferFrom(
- address(this),
- msg.sender,
- tokenId
- );
- }
-}
diff --git a/contracts/extensions/contracts/Forwarder/MixinExchangeWrapper.sol b/contracts/extensions/contracts/Forwarder/MixinExchangeWrapper.sol
deleted file mode 100644
index cab26741d..000000000
--- a/contracts/extensions/contracts/Forwarder/MixinExchangeWrapper.sol
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
-
- 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 "./libs/LibConstants.sol";
-import "./mixins/MExchangeWrapper.sol";
-import "@0x/contracts-libs/contracts/libs/LibAbiEncoder.sol";
-import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
-import "@0x/contracts-libs/contracts/libs/LibFillResults.sol";
-import "@0x/contracts-libs/contracts/libs/LibMath.sol";
-
-
-contract MixinExchangeWrapper is
- LibAbiEncoder,
- LibFillResults,
- LibMath,
- LibConstants,
- MExchangeWrapper
-{
- /// @dev Fills the input order.
- /// Returns false if the transaction would otherwise revert.
- /// @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 fillOrderNoThrow(
- LibOrder.Order memory order,
- uint256 takerAssetFillAmount,
- bytes memory signature
- )
- internal
- returns (FillResults memory fillResults)
- {
- // ABI encode calldata for `fillOrder`
- bytes memory fillOrderCalldata = abiEncodeFillOrder(
- order,
- takerAssetFillAmount,
- signature
- );
-
- address exchange = address(EXCHANGE);
-
- // Call `fillOrder` and handle any exceptions gracefully
- assembly {
- let success := call(
- gas, // forward all gas
- exchange, // call address of Exchange contract
- 0, // transfer 0 wei
- add(fillOrderCalldata, 32), // pointer to start of input (skip array length in first 32 bytes)
- mload(fillOrderCalldata), // length of input
- fillOrderCalldata, // write output over input
- 128 // output size is 128 bytes
- )
- if success {
- mstore(fillResults, mload(fillOrderCalldata))
- mstore(add(fillResults, 32), mload(add(fillOrderCalldata, 32)))
- mstore(add(fillResults, 64), mload(add(fillOrderCalldata, 64)))
- mstore(add(fillResults, 96), mload(add(fillOrderCalldata, 96)))
- }
- }
- // fillResults values will be 0 by default if call was unsuccessful
- return fillResults;
- }
-
- /// @dev Synchronously executes multiple calls of fillOrder until total amount of WETH has been sold by taker.
- /// Returns false if the transaction would otherwise revert.
- /// @param orders Array of order specifications.
- /// @param wethSellAmount Desired amount of WETH to sell.
- /// @param signatures Proofs that orders have been signed by makers.
- /// @return Amounts filled and fees paid by makers and taker.
- function marketSellWeth(
- LibOrder.Order[] memory orders,
- uint256 wethSellAmount,
- bytes[] memory signatures
- )
- internal
- returns (FillResults memory totalFillResults)
- {
- bytes memory makerAssetData = orders[0].makerAssetData;
- bytes memory wethAssetData = WETH_ASSET_DATA;
-
- uint256 ordersLength = orders.length;
- for (uint256 i = 0; i != ordersLength; i++) {
-
- // We assume that asset being bought by taker is the same for each order.
- // We assume that asset being sold by taker is WETH for each order.
- orders[i].makerAssetData = makerAssetData;
- orders[i].takerAssetData = wethAssetData;
-
- // Calculate the remaining amount of WETH to sell
- uint256 remainingTakerAssetFillAmount = safeSub(wethSellAmount, totalFillResults.takerAssetFilledAmount);
-
- // Attempt to sell the remaining amount of WETH
- FillResults memory singleFillResults = fillOrderNoThrow(
- orders[i],
- remainingTakerAssetFillAmount,
- signatures[i]
- );
-
- // Update amounts filled and fees paid by maker and taker
- addFillResults(totalFillResults, singleFillResults);
-
- // Stop execution if the entire amount of takerAsset has been sold
- if (totalFillResults.takerAssetFilledAmount >= wethSellAmount) {
- break;
- }
- }
- return 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.
- /// The asset being sold by taker must always be WETH.
- /// @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 marketBuyExactAmountWithWeth(
- LibOrder.Order[] memory orders,
- uint256 makerAssetFillAmount,
- bytes[] memory signatures
- )
- internal
- returns (FillResults memory totalFillResults)
- {
- bytes memory makerAssetData = orders[0].makerAssetData;
- bytes memory wethAssetData = WETH_ASSET_DATA;
-
- uint256 ordersLength = orders.length;
- for (uint256 i = 0; i != ordersLength; i++) {
-
- // We assume that asset being bought by taker is the same for each order.
- // We assume that asset being sold by taker is WETH for each order.
- orders[i].makerAssetData = makerAssetData;
- orders[i].takerAssetData = wethAssetData;
-
- // Calculate the remaining amount of makerAsset to buy
- uint256 remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount);
-
- // Convert the remaining amount of makerAsset to buy into remaining amount
- // of takerAsset to sell, assuming entire amount can be sold in the current order.
- // We round up because the exchange rate computed by fillOrder rounds in favor
- // of the Maker. In this case we want to overestimate the amount of takerAsset.
- uint256 remainingTakerAssetFillAmount = getPartialAmountCeil(
- orders[i].takerAssetAmount,
- orders[i].makerAssetAmount,
- remainingMakerAssetFillAmount
- );
-
- // Attempt to sell the remaining amount of takerAsset
- FillResults memory singleFillResults = fillOrderNoThrow(
- orders[i],
- remainingTakerAssetFillAmount,
- signatures[i]
- );
-
- // Update amounts filled and fees paid by maker and taker
- addFillResults(totalFillResults, singleFillResults);
-
- // Stop execution if the entire amount of makerAsset has been bought
- uint256 makerAssetFilledAmount = totalFillResults.makerAssetFilledAmount;
- if (makerAssetFilledAmount >= makerAssetFillAmount) {
- break;
- }
- }
-
- require(
- makerAssetFilledAmount >= makerAssetFillAmount,
- "COMPLETE_FILL_FAILED"
- );
- return totalFillResults;
- }
-
- /// @dev Buys zrxBuyAmount of ZRX fee tokens, taking into account ZRX fees for each order. This will guarantee
- /// that at least zrxBuyAmount of ZRX is purchased (sometimes slightly over due to rounding issues).
- /// It is possible that a request to buy 200 ZRX will require purchasing 202 ZRX
- /// as 2 ZRX is required to purchase the 200 ZRX fee tokens. This guarantees at least 200 ZRX for future purchases.
- /// The asset being sold by taker must always be WETH.
- /// @param orders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset.
- /// @param zrxBuyAmount Desired amount of ZRX to buy.
- /// @param signatures Proofs that orders have been created by makers.
- /// @return totalFillResults Amounts filled and fees paid by maker and taker.
- function marketBuyExactZrxWithWeth(
- LibOrder.Order[] memory orders,
- uint256 zrxBuyAmount,
- bytes[] memory signatures
- )
- internal
- returns (FillResults memory totalFillResults)
- {
- // Do nothing if zrxBuyAmount == 0
- if (zrxBuyAmount == 0) {
- return totalFillResults;
- }
-
- bytes memory zrxAssetData = ZRX_ASSET_DATA;
- bytes memory wethAssetData = WETH_ASSET_DATA;
- uint256 zrxPurchased = 0;
-
- uint256 ordersLength = orders.length;
- for (uint256 i = 0; i != ordersLength; i++) {
-
- // All of these are ZRX/WETH, so we can drop the respective assetData from calldata.
- orders[i].makerAssetData = zrxAssetData;
- orders[i].takerAssetData = wethAssetData;
-
- // Calculate the remaining amount of ZRX to buy.
- uint256 remainingZrxBuyAmount = safeSub(zrxBuyAmount, zrxPurchased);
-
- // Convert the remaining amount of ZRX to buy into remaining amount
- // of WETH to sell, assuming entire amount can be sold in the current order.
- // We round up because the exchange rate computed by fillOrder rounds in favor
- // of the Maker. In this case we want to overestimate the amount of takerAsset.
- uint256 remainingWethSellAmount = getPartialAmountCeil(
- orders[i].takerAssetAmount,
- safeSub(orders[i].makerAssetAmount, orders[i].takerFee), // our exchange rate after fees
- remainingZrxBuyAmount
- );
-
- // Attempt to sell the remaining amount of WETH.
- FillResults memory singleFillResult = fillOrderNoThrow(
- orders[i],
- remainingWethSellAmount,
- signatures[i]
- );
-
- // Update amounts filled and fees paid by maker and taker.
- addFillResults(totalFillResults, singleFillResult);
- zrxPurchased = safeSub(totalFillResults.makerAssetFilledAmount, totalFillResults.takerFeePaid);
-
- // Stop execution if the entire amount of ZRX has been bought.
- if (zrxPurchased >= zrxBuyAmount) {
- break;
- }
- }
-
- require(
- zrxPurchased >= zrxBuyAmount,
- "COMPLETE_FILL_FAILED"
- );
- return totalFillResults;
- }
-}
diff --git a/contracts/extensions/contracts/Forwarder/MixinForwarderCore.sol b/contracts/extensions/contracts/Forwarder/MixinForwarderCore.sol
deleted file mode 100644
index 11c0147a5..000000000
--- a/contracts/extensions/contracts/Forwarder/MixinForwarderCore.sol
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
-
- 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 "./libs/LibConstants.sol";
-import "./mixins/MWeth.sol";
-import "./mixins/MAssets.sol";
-import "./mixins/MExchangeWrapper.sol";
-import "./interfaces/IForwarderCore.sol";
-import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
-import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
-import "@0x/contracts-libs/contracts/libs/LibFillResults.sol";
-import "@0x/contracts-libs/contracts/libs/LibMath.sol";
-
-
-contract MixinForwarderCore is
- LibFillResults,
- LibMath,
- LibConstants,
- MWeth,
- MAssets,
- MExchangeWrapper,
- IForwarderCore
-{
- using LibBytes for bytes;
-
- /// @dev Constructor approves ERC20 proxy to transfer ZRX and WETH on this contract's behalf.
- constructor ()
- public
- {
- address proxyAddress = EXCHANGE.getAssetProxy(ERC20_DATA_ID);
- require(
- proxyAddress != address(0),
- "UNREGISTERED_ASSET_PROXY"
- );
- ETHER_TOKEN.approve(proxyAddress, MAX_UINT);
- ZRX_TOKEN.approve(proxyAddress, MAX_UINT);
- }
-
- /// @dev Purchases as much of orders' makerAssets as possible by selling up to 95% of transaction's ETH value.
- /// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.
- /// 5% of ETH value is reserved for paying fees to order feeRecipients (in ZRX) and forwarding contract feeRecipient (in ETH).
- /// Any ETH not spent will be refunded to sender.
- /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
- /// @param signatures Proofs that orders have been created by makers.
- /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.
- /// @param feeSignatures Proofs that feeOrders have been created by makers.
- /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.
- /// @param feeRecipient Address that will receive ETH when orders are filled.
- /// @return Amounts filled and fees paid by maker and taker for both sets of orders.
- function marketSellOrdersWithEth(
- LibOrder.Order[] memory orders,
- bytes[] memory signatures,
- LibOrder.Order[] memory feeOrders,
- bytes[] memory feeSignatures,
- uint256 feePercentage,
- address feeRecipient
- )
- public
- payable
- returns (
- FillResults memory orderFillResults,
- FillResults memory feeOrderFillResults
- )
- {
- // Convert ETH to WETH.
- convertEthToWeth();
-
- uint256 wethSellAmount;
- uint256 zrxBuyAmount;
- uint256 makerAssetAmountPurchased;
- if (orders[0].makerAssetData.equals(ZRX_ASSET_DATA)) {
- // Calculate amount of WETH that won't be spent on ETH fees.
- wethSellAmount = getPartialAmountFloor(
- PERCENTAGE_DENOMINATOR,
- safeAdd(PERCENTAGE_DENOMINATOR, feePercentage),
- msg.value
- );
- // Market sell available WETH.
- // ZRX fees are paid with this contract's balance.
- orderFillResults = marketSellWeth(
- orders,
- wethSellAmount,
- signatures
- );
- // The fee amount must be deducted from the amount transfered back to sender.
- makerAssetAmountPurchased = safeSub(orderFillResults.makerAssetFilledAmount, orderFillResults.takerFeePaid);
- } else {
- // 5% of WETH is reserved for filling feeOrders and paying feeRecipient.
- wethSellAmount = getPartialAmountFloor(
- MAX_WETH_FILL_PERCENTAGE,
- PERCENTAGE_DENOMINATOR,
- msg.value
- );
- // Market sell 95% of WETH.
- // ZRX fees are payed with this contract's balance.
- orderFillResults = marketSellWeth(
- orders,
- wethSellAmount,
- signatures
- );
- // Buy back all ZRX spent on fees.
- zrxBuyAmount = orderFillResults.takerFeePaid;
- feeOrderFillResults = marketBuyExactZrxWithWeth(
- feeOrders,
- zrxBuyAmount,
- feeSignatures
- );
- makerAssetAmountPurchased = orderFillResults.makerAssetFilledAmount;
- }
-
- // Transfer feePercentage of total ETH spent on primary orders to feeRecipient.
- // Refund remaining ETH to msg.sender.
- transferEthFeeAndRefund(
- orderFillResults.takerAssetFilledAmount,
- feeOrderFillResults.takerAssetFilledAmount,
- feePercentage,
- feeRecipient
- );
-
- // Transfer purchased assets to msg.sender.
- transferAssetToSender(orders[0].makerAssetData, makerAssetAmountPurchased);
- }
-
- /// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction.
- /// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.
- /// Any ETH not spent will be refunded to sender.
- /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
- /// @param makerAssetFillAmount Desired amount of makerAsset to purchase.
- /// @param signatures Proofs that orders have been created by makers.
- /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.
- /// @param feeSignatures Proofs that feeOrders have been created by makers.
- /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.
- /// @param feeRecipient Address that will receive ETH when orders are filled.
- /// @return Amounts filled and fees paid by maker and taker for both sets of orders.
- function marketBuyOrdersWithEth(
- LibOrder.Order[] memory orders,
- uint256 makerAssetFillAmount,
- bytes[] memory signatures,
- LibOrder.Order[] memory feeOrders,
- bytes[] memory feeSignatures,
- uint256 feePercentage,
- address feeRecipient
- )
- public
- payable
- returns (
- FillResults memory orderFillResults,
- FillResults memory feeOrderFillResults
- )
- {
- // Convert ETH to WETH.
- convertEthToWeth();
-
- uint256 zrxBuyAmount;
- uint256 makerAssetAmountPurchased;
- if (orders[0].makerAssetData.equals(ZRX_ASSET_DATA)) {
- // If the makerAsset is ZRX, it is not necessary to pay fees out of this
- // contracts's ZRX balance because fees are factored into the price of the order.
- orderFillResults = marketBuyExactZrxWithWeth(
- orders,
- makerAssetFillAmount,
- signatures
- );
- // The fee amount must be deducted from the amount transfered back to sender.
- makerAssetAmountPurchased = safeSub(orderFillResults.makerAssetFilledAmount, orderFillResults.takerFeePaid);
- } else {
- // Attemp to purchase desired amount of makerAsset.
- // ZRX fees are payed with this contract's balance.
- orderFillResults = marketBuyExactAmountWithWeth(
- orders,
- makerAssetFillAmount,
- signatures
- );
- // Buy back all ZRX spent on fees.
- zrxBuyAmount = orderFillResults.takerFeePaid;
- feeOrderFillResults = marketBuyExactZrxWithWeth(
- feeOrders,
- zrxBuyAmount,
- feeSignatures
- );
- makerAssetAmountPurchased = orderFillResults.makerAssetFilledAmount;
- }
-
- // Transfer feePercentage of total ETH spent on primary orders to feeRecipient.
- // Refund remaining ETH to msg.sender.
- transferEthFeeAndRefund(
- orderFillResults.takerAssetFilledAmount,
- feeOrderFillResults.takerAssetFilledAmount,
- feePercentage,
- feeRecipient
- );
-
- // Transfer purchased assets to msg.sender.
- transferAssetToSender(orders[0].makerAssetData, makerAssetAmountPurchased);
- }
-}
diff --git a/contracts/extensions/contracts/Forwarder/MixinWeth.sol b/contracts/extensions/contracts/Forwarder/MixinWeth.sol
deleted file mode 100644
index 25a35f47b..000000000
--- a/contracts/extensions/contracts/Forwarder/MixinWeth.sol
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-
- 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 "@0x/contracts-libs/contracts/libs/LibMath.sol";
-import "./libs/LibConstants.sol";
-import "./mixins/MWeth.sol";
-
-
-contract MixinWeth is
- LibMath,
- LibConstants,
- MWeth
-{
- /// @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 Converts message call's ETH value into WETH.
- function convertEthToWeth()
- internal
- {
- require(
- msg.value > 0,
- "INVALID_MSG_VALUE"
- );
- ETHER_TOKEN.deposit.value(msg.value)();
- }
-
- /// @dev Transfers feePercentage of WETH spent on primary orders to feeRecipient.
- /// Refunds any excess ETH to msg.sender.
- /// @param wethSoldExcludingFeeOrders Amount of WETH sold when filling primary orders.
- /// @param wethSoldForZrx Amount of WETH sold when purchasing ZRX required for primary order fees.
- /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.
- /// @param feeRecipient Address that will receive ETH when orders are filled.
- function transferEthFeeAndRefund(
- uint256 wethSoldExcludingFeeOrders,
- uint256 wethSoldForZrx,
- uint256 feePercentage,
- address feeRecipient
- )
- internal
- {
- // Ensure feePercentage is less than 5%.
- require(
- feePercentage <= MAX_FEE_PERCENTAGE,
- "FEE_PERCENTAGE_TOO_LARGE"
- );
-
- // Ensure that no extra WETH owned by this contract has been sold.
- uint256 wethSold = safeAdd(wethSoldExcludingFeeOrders, wethSoldForZrx);
- require(
- wethSold <= msg.value,
- "OVERSOLD_WETH"
- );
-
- // Calculate amount of WETH that hasn't been sold.
- uint256 wethRemaining = safeSub(msg.value, wethSold);
-
- // Calculate ETH fee to pay to feeRecipient.
- uint256 ethFee = getPartialAmountFloor(
- feePercentage,
- PERCENTAGE_DENOMINATOR,
- wethSoldExcludingFeeOrders
- );
-
- // Ensure fee is less than amount of WETH remaining.
- require(
- ethFee <= wethRemaining,
- "INSUFFICIENT_ETH_REMAINING"
- );
-
- // Do nothing if no WETH remaining
- if (wethRemaining > 0) {
- // Convert remaining WETH to ETH
- ETHER_TOKEN.withdraw(wethRemaining);
-
- // Pay ETH to feeRecipient
- if (ethFee > 0) {
- feeRecipient.transfer(ethFee);
- }
-
- // Refund remaining ETH to msg.sender.
- uint256 ethRefund = safeSub(wethRemaining, ethFee);
- if (ethRefund > 0) {
- msg.sender.transfer(ethRefund);
- }
- }
- }
-}
diff --git a/contracts/extensions/contracts/Forwarder/interfaces/IAssets.sol b/contracts/extensions/contracts/Forwarder/interfaces/IAssets.sol
deleted file mode 100644
index cebfd3706..000000000
--- a/contracts/extensions/contracts/Forwarder/interfaces/IAssets.sol
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-
- 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 IAssets {
-
- /// @dev Withdraws assets from this contract. The contract requires a ZRX balance in order to
- /// function optimally, and this function allows the ZRX to be withdrawn by owner. It may also be
- /// used to withdraw assets that were accidentally sent to this contract.
- /// @param assetData Byte array encoded for the respective asset proxy.
- /// @param amount Amount of ERC20 token to withdraw.
- function withdrawAsset(
- bytes assetData,
- uint256 amount
- )
- external;
-}
diff --git a/contracts/extensions/contracts/Forwarder/interfaces/IForwarder.sol b/contracts/extensions/contracts/Forwarder/interfaces/IForwarder.sol
deleted file mode 100644
index 6ce8a1d31..000000000
--- a/contracts/extensions/contracts/Forwarder/interfaces/IForwarder.sol
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-
- 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 "./IForwarderCore.sol";
-import "./IAssets.sol";
-
-
-// solhint-disable no-empty-blocks
-contract IForwarder is
- IForwarderCore,
- IAssets
-{}
diff --git a/contracts/extensions/contracts/Forwarder/interfaces/IForwarderCore.sol b/contracts/extensions/contracts/Forwarder/interfaces/IForwarderCore.sol
deleted file mode 100644
index 7f62722e7..000000000
--- a/contracts/extensions/contracts/Forwarder/interfaces/IForwarderCore.sol
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-
- 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-libs/contracts/libs/LibOrder.sol";
-import "@0x/contracts-libs/contracts/libs/LibFillResults.sol";
-
-
-contract IForwarderCore {
-
- /// @dev Purchases as much of orders' makerAssets as possible by selling up to 95% of transaction's ETH value.
- /// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.
- /// 5% of ETH value is reserved for paying fees to order feeRecipients (in ZRX) and forwarding contract feeRecipient (in ETH).
- /// Any ETH not spent will be refunded to sender.
- /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
- /// @param signatures Proofs that orders have been created by makers.
- /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.
- /// @param feeSignatures Proofs that feeOrders have been created by makers.
- /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.
- /// @param feeRecipient Address that will receive ETH when orders are filled.
- /// @return Amounts filled and fees paid by maker and taker for both sets of orders.
- function marketSellOrdersWithEth(
- LibOrder.Order[] memory orders,
- bytes[] memory signatures,
- LibOrder.Order[] memory feeOrders,
- bytes[] memory feeSignatures,
- uint256 feePercentage,
- address feeRecipient
- )
- public
- payable
- returns (
- LibFillResults.FillResults memory orderFillResults,
- LibFillResults.FillResults memory feeOrderFillResults
- );
-
- /// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction.
- /// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.
- /// Any ETH not spent will be refunded to sender.
- /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
- /// @param makerAssetFillAmount Desired amount of makerAsset to purchase.
- /// @param signatures Proofs that orders have been created by makers.
- /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.
- /// @param feeSignatures Proofs that feeOrders have been created by makers.
- /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.
- /// @param feeRecipient Address that will receive ETH when orders are filled.
- /// @return Amounts filled and fees paid by maker and taker for both sets of orders.
- function marketBuyOrdersWithEth(
- LibOrder.Order[] memory orders,
- uint256 makerAssetFillAmount,
- bytes[] memory signatures,
- LibOrder.Order[] memory feeOrders,
- bytes[] memory feeSignatures,
- uint256 feePercentage,
- address feeRecipient
- )
- public
- payable
- returns (
- LibFillResults.FillResults memory orderFillResults,
- LibFillResults.FillResults memory feeOrderFillResults
- );
-}
diff --git a/contracts/extensions/contracts/Forwarder/libs/LibConstants.sol b/contracts/extensions/contracts/Forwarder/libs/LibConstants.sol
deleted file mode 100644
index 0d2f6e36d..000000000
--- a/contracts/extensions/contracts/Forwarder/libs/LibConstants.sol
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-
- 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 "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol";
-import "@0x/contracts-tokens/contracts/tokens/EtherToken/IEtherToken.sol";
-import "@0x/contracts-tokens/contracts/tokens/ERC20Token/IERC20Token.sol";
-
-
-contract LibConstants {
-
- using LibBytes for bytes;
-
- bytes4 constant internal ERC20_DATA_ID = bytes4(keccak256("ERC20Token(address)"));
- bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256)"));
- uint256 constant internal MAX_UINT = 2**256 - 1;
- uint256 constant internal PERCENTAGE_DENOMINATOR = 10**18;
- uint256 constant internal MAX_FEE_PERCENTAGE = 5 * PERCENTAGE_DENOMINATOR / 100; // 5%
- uint256 constant internal MAX_WETH_FILL_PERCENTAGE = 95 * PERCENTAGE_DENOMINATOR / 100; // 95%
-
- // solhint-disable var-name-mixedcase
- IExchange internal EXCHANGE;
- IEtherToken internal ETHER_TOKEN;
- IERC20Token internal ZRX_TOKEN;
- bytes internal ZRX_ASSET_DATA;
- bytes internal WETH_ASSET_DATA;
- // solhint-enable var-name-mixedcase
-
- constructor (
- address _exchange,
- bytes memory _zrxAssetData,
- bytes memory _wethAssetData
- )
- public
- {
- EXCHANGE = IExchange(_exchange);
- ZRX_ASSET_DATA = _zrxAssetData;
- WETH_ASSET_DATA = _wethAssetData;
-
- address etherToken = _wethAssetData.readAddress(16);
- address zrxToken = _zrxAssetData.readAddress(16);
- ETHER_TOKEN = IEtherToken(etherToken);
- ZRX_TOKEN = IERC20Token(zrxToken);
- }
-}
diff --git a/contracts/extensions/contracts/Forwarder/libs/LibForwarderErrors.sol b/contracts/extensions/contracts/Forwarder/libs/LibForwarderErrors.sol
deleted file mode 100644
index 7a95b78a0..000000000
--- a/contracts/extensions/contracts/Forwarder/libs/LibForwarderErrors.sol
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-
- 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.
-
-*/
-
-// solhint-disable
-pragma solidity ^0.4.24;
-
-
-/// This contract is intended to serve as a reference, but is not actually used for efficiency reasons.
-contract LibForwarderErrors {
- string constant FEE_PERCENTAGE_TOO_LARGE = "FEE_PROPORTION_TOO_LARGE"; // Provided fee percentage greater than 5%.
- string constant INSUFFICIENT_ETH_REMAINING = "INSUFFICIENT_ETH_REMAINING"; // Not enough ETH remaining to pay feeRecipient.
- string constant OVERSOLD_WETH = "OVERSOLD_WETH"; // More WETH sold than provided with current message call.
- string constant COMPLETE_FILL_FAILED = "COMPLETE_FILL_FAILED"; // Desired purchase amount not completely filled (required for ZRX fees only).
- string constant TRANSFER_FAILED = "TRANSFER_FAILED"; // Asset transfer failed.
- string constant UNSUPPORTED_ASSET_PROXY = "UNSUPPORTED_ASSET_PROXY"; // Proxy in assetData not supported.
- string constant DEFAULT_FUNCTION_WETH_CONTRACT_ONLY = "DEFAULT_FUNCTION_WETH_CONTRACT_ONLY"; // Fallback function may only be used for WETH withdrawals.
- string constant INVALID_MSG_VALUE = "INVALID_MSG_VALUE"; // msg.value must be greater than 0.
- string constant INVALID_AMOUNT = "INVALID_AMOUNT"; // Amount must equal 1.
-}
diff --git a/contracts/extensions/contracts/Forwarder/mixins/MAssets.sol b/contracts/extensions/contracts/Forwarder/mixins/MAssets.sol
deleted file mode 100644
index 1757b37fb..000000000
--- a/contracts/extensions/contracts/Forwarder/mixins/MAssets.sol
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-
- 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 "../interfaces/IAssets.sol";
-
-
-contract MAssets is
- IAssets
-{
- /// @dev Transfers given amount of asset to sender.
- /// @param assetData Byte array encoded for the respective asset proxy.
- /// @param amount Amount of asset to transfer to sender.
- function transferAssetToSender(
- bytes memory assetData,
- uint256 amount
- )
- internal;
-
- /// @dev Decodes ERC20 assetData and transfers given amount to sender.
- /// @param assetData Byte array encoded for the respective asset proxy.
- /// @param amount Amount of asset to transfer to sender.
- function transferERC20Token(
- bytes memory assetData,
- uint256 amount
- )
- internal;
-
- /// @dev Decodes ERC721 assetData and transfers given amount to sender.
- /// @param assetData Byte array encoded for the respective asset proxy.
- /// @param amount Amount of asset to transfer to sender.
- function transferERC721Token(
- bytes memory assetData,
- uint256 amount
- )
- internal;
-}
diff --git a/contracts/extensions/contracts/Forwarder/mixins/MExchangeWrapper.sol b/contracts/extensions/contracts/Forwarder/mixins/MExchangeWrapper.sol
deleted file mode 100644
index 143f888b1..000000000
--- a/contracts/extensions/contracts/Forwarder/mixins/MExchangeWrapper.sol
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
-
- 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-libs/contracts/libs/LibOrder.sol";
-import "@0x/contracts-libs/contracts/libs/LibFillResults.sol";
-
-
-contract MExchangeWrapper {
-
- /// @dev Fills the input order.
- /// Returns false if the transaction would otherwise revert.
- /// @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 fillOrderNoThrow(
- LibOrder.Order memory order,
- uint256 takerAssetFillAmount,
- bytes memory signature
- )
- internal
- returns (LibFillResults.FillResults memory fillResults);
-
- /// @dev Synchronously executes multiple calls of fillOrder until total amount of WETH has been sold by taker.
- /// Returns false if the transaction would otherwise revert.
- /// @param orders Array of order specifications.
- /// @param wethSellAmount Desired amount of WETH to sell.
- /// @param signatures Proofs that orders have been signed by makers.
- /// @return Amounts filled and fees paid by makers and taker.
- function marketSellWeth(
- LibOrder.Order[] memory orders,
- uint256 wethSellAmount,
- bytes[] memory signatures
- )
- internal
- 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.
- /// The asset being sold by taker must always be WETH.
- /// @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 marketBuyExactAmountWithWeth(
- LibOrder.Order[] memory orders,
- uint256 makerAssetFillAmount,
- bytes[] memory signatures
- )
- internal
- returns (LibFillResults.FillResults memory totalFillResults);
-
- /// @dev Buys zrxBuyAmount of ZRX fee tokens, taking into account ZRX fees for each order. This will guarantee
- /// that at least zrxBuyAmount of ZRX is purchased (sometimes slightly over due to rounding issues).
- /// It is possible that a request to buy 200 ZRX will require purchasing 202 ZRX
- /// as 2 ZRX is required to purchase the 200 ZRX fee tokens. This guarantees at least 200 ZRX for future purchases.
- /// The asset being sold by taker must always be WETH.
- /// @param orders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset.
- /// @param zrxBuyAmount Desired amount of ZRX to buy.
- /// @param signatures Proofs that orders have been created by makers.
- /// @return totalFillResults Amounts filled and fees paid by maker and taker.
- function marketBuyExactZrxWithWeth(
- LibOrder.Order[] memory orders,
- uint256 zrxBuyAmount,
- bytes[] memory signatures
- )
- internal
- returns (LibFillResults.FillResults memory totalFillResults);
-}
diff --git a/contracts/extensions/contracts/Forwarder/mixins/MWeth.sol b/contracts/extensions/contracts/Forwarder/mixins/MWeth.sol
deleted file mode 100644
index 15d66942f..000000000
--- a/contracts/extensions/contracts/Forwarder/mixins/MWeth.sol
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-
- 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 MWeth {
-
- /// @dev Converts message call's ETH value into WETH.
- function convertEthToWeth()
- internal;
-
- /// @dev Transfers feePercentage of WETH spent on primary orders to feeRecipient.
- /// Refunds any excess ETH to msg.sender.
- /// @param wethSoldExcludingFeeOrders Amount of WETH sold when filling primary orders.
- /// @param wethSoldForZrx Amount of WETH sold when purchasing ZRX required for primary order fees.
- /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.
- /// @param feeRecipient Address that will receive ETH when orders are filled.
- function transferEthFeeAndRefund(
- uint256 wethSoldExcludingFeeOrders,
- uint256 wethSoldForZrx,
- uint256 feePercentage,
- address feeRecipient
- )
- internal;
-}
diff --git a/contracts/extensions/contracts/BalanceThresholdFilter/BalanceThresholdFilter.sol b/contracts/extensions/contracts/src/BalanceThresholdFilter/BalanceThresholdFilter.sol
index 16cacd461..b6e14525d 100644
--- a/contracts/extensions/contracts/BalanceThresholdFilter/BalanceThresholdFilter.sol
+++ b/contracts/extensions/contracts/src/BalanceThresholdFilter/BalanceThresholdFilter.sol
@@ -18,7 +18,7 @@
pragma solidity 0.4.24;
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol";
+import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
import "./interfaces/IThresholdAsset.sol";
import "./MixinBalanceThresholdFilterCore.sol";
diff --git a/contracts/extensions/contracts/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol b/contracts/extensions/contracts/src/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol
index da050bf72..68dabafeb 100644
--- a/contracts/extensions/contracts/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol
+++ b/contracts/extensions/contracts/src/BalanceThresholdFilter/MixinBalanceThresholdFilterCore.sol
@@ -18,8 +18,8 @@
pragma solidity ^0.4.24;
-import "@0x/contracts-libs/contracts/libs/LibExchangeSelectors.sol";
-import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibExchangeSelectors.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
import "./mixins/MBalanceThresholdFilterCore.sol";
import "./MixinExchangeCalldata.sol";
diff --git a/contracts/extensions/contracts/BalanceThresholdFilter/MixinExchangeCalldata.sol b/contracts/extensions/contracts/src/BalanceThresholdFilter/MixinExchangeCalldata.sol
index a15e95a9d..f2c0caa57 100644
--- a/contracts/extensions/contracts/BalanceThresholdFilter/MixinExchangeCalldata.sol
+++ b/contracts/extensions/contracts/src/BalanceThresholdFilter/MixinExchangeCalldata.sol
@@ -20,7 +20,7 @@
pragma solidity ^0.4.24;
import "./mixins/MExchangeCalldata.sol";
-import "@0x/contracts-libs/contracts/libs/LibAddressArray.sol";
+import "@0x/contracts-utils/contracts/src/LibAddressArray.sol";
contract MixinExchangeCalldata is
diff --git a/contracts/extensions/contracts/BalanceThresholdFilter/interfaces/IBalanceThresholdFilterCore.sol b/contracts/extensions/contracts/src/BalanceThresholdFilter/interfaces/IBalanceThresholdFilterCore.sol
index 4a1bf1fb2..4a1bf1fb2 100644
--- a/contracts/extensions/contracts/BalanceThresholdFilter/interfaces/IBalanceThresholdFilterCore.sol
+++ b/contracts/extensions/contracts/src/BalanceThresholdFilter/interfaces/IBalanceThresholdFilterCore.sol
diff --git a/contracts/extensions/contracts/BalanceThresholdFilter/interfaces/IThresholdAsset.sol b/contracts/extensions/contracts/src/BalanceThresholdFilter/interfaces/IThresholdAsset.sol
index f78f9c2de..f78f9c2de 100644
--- a/contracts/extensions/contracts/BalanceThresholdFilter/interfaces/IThresholdAsset.sol
+++ b/contracts/extensions/contracts/src/BalanceThresholdFilter/interfaces/IThresholdAsset.sol
diff --git a/contracts/extensions/contracts/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol b/contracts/extensions/contracts/src/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol
index 074686e8d..1c840136b 100644
--- a/contracts/extensions/contracts/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol
+++ b/contracts/extensions/contracts/src/BalanceThresholdFilter/mixins/MBalanceThresholdFilterCore.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.24;
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol";
+import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
import "../interfaces/IThresholdAsset.sol";
import "../interfaces/IBalanceThresholdFilterCore.sol";
diff --git a/contracts/extensions/contracts/BalanceThresholdFilter/mixins/MExchangeCalldata.sol b/contracts/extensions/contracts/src/BalanceThresholdFilter/mixins/MExchangeCalldata.sol
index 40536d820..40536d820 100644
--- a/contracts/extensions/contracts/BalanceThresholdFilter/mixins/MExchangeCalldata.sol
+++ b/contracts/extensions/contracts/src/BalanceThresholdFilter/mixins/MExchangeCalldata.sol
diff --git a/contracts/extensions/contracts/DutchAuction/DutchAuction.sol b/contracts/extensions/contracts/src/DutchAuction/DutchAuction.sol
index 9c9f3990a..7631880c0 100644
--- a/contracts/extensions/contracts/DutchAuction/DutchAuction.sol
+++ b/contracts/extensions/contracts/src/DutchAuction/DutchAuction.sol
@@ -19,11 +19,11 @@
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol";
-import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
-import "@0x/contracts-tokens/contracts/tokens/ERC20Token/IERC20Token.sol";
-import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
-import "@0x/contracts-utils/contracts/utils/SafeMath/SafeMath.sol";
+import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
+import "@0x/contracts-utils/contracts/src/LibBytes.sol";
+import "@0x/contracts-utils/contracts/src/SafeMath.sol";
contract DutchAuction is
diff --git a/contracts/extensions/contracts/OrderMatcher/MixinAssets.sol b/contracts/extensions/contracts/src/OrderMatcher/MixinAssets.sol
index f0f91cfc0..65b36ea65 100644
--- a/contracts/extensions/contracts/OrderMatcher/MixinAssets.sol
+++ b/contracts/extensions/contracts/src/OrderMatcher/MixinAssets.sol
@@ -18,10 +18,10 @@
pragma solidity ^0.4.24;
-import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
-import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
-import "@0x/contracts-tokens/contracts/tokens/ERC20Token/IERC20Token.sol";
-import "@0x/contracts-tokens/contracts/tokens/ERC721Token/IERC721Token.sol";
+import "@0x/contracts-utils/contracts/src/LibBytes.sol";
+import "@0x/contracts-utils/contracts/src/Ownable.sol";
+import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
+import "@0x/contracts-erc721/contracts/src/interfaces/IERC721Token.sol";
import "./mixins/MAssets.sol";
import "./libs/LibConstants.sol";
diff --git a/contracts/extensions/contracts/OrderMatcher/MixinMatchOrders.sol b/contracts/extensions/contracts/src/OrderMatcher/MixinMatchOrders.sol
index 1787deb59..baf41f650 100644
--- a/contracts/extensions/contracts/OrderMatcher/MixinMatchOrders.sol
+++ b/contracts/extensions/contracts/src/OrderMatcher/MixinMatchOrders.sol
@@ -20,9 +20,9 @@ pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;
import "./libs/LibConstants.sol";
-import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
-import "@0x/contracts-libs/contracts/libs/LibFillResults.sol";
-import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
+import "@0x/contracts-utils/contracts/src/Ownable.sol";
contract MixinMatchOrders is
diff --git a/contracts/extensions/contracts/OrderMatcher/OrderMatcher.sol b/contracts/extensions/contracts/src/OrderMatcher/OrderMatcher.sol
index 4879b7bca..89a7f3c55 100644
--- a/contracts/extensions/contracts/OrderMatcher/OrderMatcher.sol
+++ b/contracts/extensions/contracts/src/OrderMatcher/OrderMatcher.sol
@@ -19,7 +19,7 @@
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
-import "@0x/contracts-utils/contracts/utils/Ownable/Ownable.sol";
+import "@0x/contracts-utils/contracts/src/Ownable.sol";
import "./libs/LibConstants.sol";
import "./MixinMatchOrders.sol";
import "./MixinAssets.sol";
diff --git a/contracts/extensions/contracts/OrderMatcher/interfaces/IAssets.sol b/contracts/extensions/contracts/src/OrderMatcher/interfaces/IAssets.sol
index 9fcc0023a..9fcc0023a 100644
--- a/contracts/extensions/contracts/OrderMatcher/interfaces/IAssets.sol
+++ b/contracts/extensions/contracts/src/OrderMatcher/interfaces/IAssets.sol
diff --git a/contracts/extensions/contracts/OrderMatcher/interfaces/IMatchOrders.sol b/contracts/extensions/contracts/src/OrderMatcher/interfaces/IMatchOrders.sol
index 1443c73b9..7e4a88df8 100644
--- a/contracts/extensions/contracts/OrderMatcher/interfaces/IMatchOrders.sol
+++ b/contracts/extensions/contracts/src/OrderMatcher/interfaces/IMatchOrders.sol
@@ -19,7 +19,7 @@
pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;
-import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
contract IMatchOrders {
diff --git a/contracts/extensions/contracts/OrderMatcher/interfaces/IOrderMatcher.sol b/contracts/extensions/contracts/src/OrderMatcher/interfaces/IOrderMatcher.sol
index 75f26dca6..5e5125dea 100644
--- a/contracts/extensions/contracts/OrderMatcher/interfaces/IOrderMatcher.sol
+++ b/contracts/extensions/contracts/src/OrderMatcher/interfaces/IOrderMatcher.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.24;
-import "@0x/contract-utils/contracts/utils/Ownable/IOwnable.sol";
+import "@0x/contract-utils/contracts/src/interfaces/IOwnable.sol";
import "./IMatchOrders.sol";
import "./IAssets.sol";
diff --git a/contracts/extensions/contracts/OrderMatcher/libs/LibConstants.sol b/contracts/extensions/contracts/src/OrderMatcher/libs/LibConstants.sol
index c1a86a9c7..77b72398f 100644
--- a/contracts/extensions/contracts/OrderMatcher/libs/LibConstants.sol
+++ b/contracts/extensions/contracts/src/OrderMatcher/libs/LibConstants.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.24;
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol";
+import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
contract LibConstants {
diff --git a/contracts/extensions/contracts/OrderMatcher/mixins/MAssets.sol b/contracts/extensions/contracts/src/OrderMatcher/mixins/MAssets.sol
index 6ea7a3290..6ea7a3290 100644
--- a/contracts/extensions/contracts/OrderMatcher/mixins/MAssets.sol
+++ b/contracts/extensions/contracts/src/OrderMatcher/mixins/MAssets.sol
diff --git a/contracts/extensions/contracts/OrderValidator/OrderValidator.sol b/contracts/extensions/contracts/src/OrderValidator/OrderValidator.sol
index 33dd1326c..3297a980f 100644
--- a/contracts/extensions/contracts/OrderValidator/OrderValidator.sol
+++ b/contracts/extensions/contracts/src/OrderValidator/OrderValidator.sol
@@ -19,11 +19,11 @@
pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
-import "@0x/contracts-interfaces/contracts/protocol/Exchange/IExchange.sol";
-import "@0x/contracts-libs/contracts/libs/LibOrder.sol";
-import "@0x/contracts-tokens/contracts/tokens/ERC20Token/IERC20Token.sol";
-import "@0x/contracts-tokens/contracts/tokens/ERC721Token/IERC721Token.sol";
-import "@0x/contracts-utils/contracts/utils/LibBytes/LibBytes.sol";
+import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
+import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
+import "@0x/contracts-erc721/contracts/src/interfaces/IERC721Token.sol";
+import "@0x/contracts-utils/contracts/src/LibBytes.sol";
contract OrderValidator {