aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/2.0.0/forwarder/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src/2.0.0/forwarder/interfaces')
-rw-r--r--packages/contracts/src/2.0.0/forwarder/interfaces/IAssets.sol53
-rw-r--r--packages/contracts/src/2.0.0/forwarder/interfaces/IExpectedResults.sol66
-rw-r--r--packages/contracts/src/2.0.0/forwarder/interfaces/IForwarder.sol4
-rw-r--r--packages/contracts/src/2.0.0/forwarder/interfaces/IForwarderCore.sol69
4 files changed, 90 insertions, 102 deletions
diff --git a/packages/contracts/src/2.0.0/forwarder/interfaces/IAssets.sol b/packages/contracts/src/2.0.0/forwarder/interfaces/IAssets.sol
new file mode 100644
index 000000000..27adb1221
--- /dev/null
+++ b/packages/contracts/src/2.0.0/forwarder/interfaces/IAssets.sol
@@ -0,0 +1,53 @@
+/*
+
+ 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 ERC20 tokens 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 tokens that were accidentally sent to this contract.
+ /// @param token Address of ERC20 token to withdraw.
+ /// @param amount Amount of ERC20 token to withdraw.
+ function withdrawERC20(
+ address token,
+ uint256 amount
+ )
+ external;
+
+ function onERC721Received(
+ address,
+ uint256,
+ bytes memory
+ )
+ public
+ pure
+ returns(bytes4);
+
+ function onERC721Received(
+ address,
+ address,
+ uint256,
+ bytes memory
+ )
+ public
+ pure
+ returns(bytes4);
+} \ No newline at end of file
diff --git a/packages/contracts/src/2.0.0/forwarder/interfaces/IExpectedResults.sol b/packages/contracts/src/2.0.0/forwarder/interfaces/IExpectedResults.sol
deleted file mode 100644
index 89187b750..000000000
--- a/packages/contracts/src/2.0.0/forwarder/interfaces/IExpectedResults.sol
+++ /dev/null
@@ -1,66 +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 "../../protocol/Exchange/libs/LibFillResults.sol";
-import "../../protocol/Exchange/libs/LibOrder.sol";
-
-
-contract IExpectedResults {
-
- /// @dev Calculates a total FillResults for buying makerAssetFillAmount over all orders.
- /// Including the fees required to be paid.
- /// @param orders An array of Order struct containing order specifications.
- /// @param makerAssetFillAmount A number representing the amount of this order to fill.
- /// @return totalFillResults Amounts filled and fees paid by maker and taker.
- function calculateMarketBuyResults(
- LibOrder.Order[] memory orders,
- uint256 makerAssetFillAmount
- )
- public
- view
- returns (LibFillResults.FillResults memory totalFillResults);
-
- /// @dev Calculates a FillResults total for selling takerAssetFillAmount over all orders.
- /// Including the fees required to be paid.
- /// @param orders An array of Order struct containing order specifications.
- /// @param takerAssetFillAmount A number representing the amount of this order to fill.
- /// @return totalFillResults Amounts filled and fees paid by maker and taker.
- function calculateMarketSellResults(
- LibOrder.Order[] memory orders,
- uint256 takerAssetFillAmount
- )
- public
- view
- returns (LibFillResults.FillResults memory totalFillResults);
-
- /// @dev Calculates fill results for buyFeeTokens. This handles fees on buying ZRX
- /// so the end result is the expected amount of ZRX (not less after fees).
- /// @param orders An array of Order struct containing order specifications.
- /// @param zrxFillAmount A number representing the amount zrx to buy
- /// @return totalFillResults Expected fill result amounts from buying fees
- function calculateMarketBuyZrxResults(
- LibOrder.Order[] memory orders,
- uint256 zrxFillAmount
- )
- public
- view
- returns (LibFillResults.FillResults memory totalFillResults);
-}
diff --git a/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarder.sol b/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarder.sol
index 745dd29a9..f5a26e2ba 100644
--- a/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarder.sol
+++ b/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarder.sol
@@ -20,11 +20,11 @@ pragma solidity 0.4.24;
pragma experimental ABIEncoderV2;
import "./IForwarderCore.sol";
-import "./IExpectedResults.sol";
+import "./IAssets.sol";
// solhint-disable no-empty-blocks
contract IForwarder is
IForwarderCore,
- IExpectedResults
+ IAssets
{}
diff --git a/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarderCore.sol b/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarderCore.sol
index 7ac2a8af3..3ecbb133b 100644
--- a/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarderCore.sol
+++ b/packages/contracts/src/2.0.0/forwarder/interfaces/IForwarderCore.sol
@@ -25,55 +25,56 @@ import "../../protocol/Exchange/libs/LibFillResults.sol";
contract IForwarderCore {
- /// @dev Market sells ETH for ERC20 tokens, performing fee abstraction if required. This does not support ERC721 tokens. This function is payable
- /// and will convert all incoming ETH into WETH and perform the trade on behalf of the caller.
- /// This function allows for a deduction of a proportion of incoming ETH sent to the feeRecipient.
- /// The caller is sent all tokens from the operation.
- /// If the purchased token amount does not meet an acceptable threshold then this function reverts.
- /// @param orders An array of Order struct containing order specifications.
- /// @param signatures An array of Proof that order has been created by maker.
- /// @param feeOrders An array of Order struct containing order specifications for fees.
- /// @param feeSignatures An array of Proof that order has been created by maker for the fee orders.
- /// @param feeProportion A proportion deducted off the incoming ETH and sent to feeRecipient. The maximum value for this
- /// is 1000, aka 10%. Supports up to 2 decimal places. I.e 0.59% is 59.
- /// @param feeRecipient An address of the fee recipient whom receives feeProportion of ETH.
- /// @return FillResults amounts filled and fees paid by maker and taker.
- function marketSellEthForERC20(
+ /// @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,
- uint16 feeProportion,
+ uint256 feePercentage,
address feeRecipient
)
public
payable
- returns (LibFillResults.FillResults memory totalFillResults);
+ returns (
+ LibFillResults.FillResults memory orderFillResults,
+ LibFillResults.FillResults memory feeOrderFillResults
+ );
- /// @dev Buys the exact amount of assets (ERC20 and ERC721), performing fee abstraction if required.
- /// All order assets must be of the same type. Deducts a proportional fee to fee recipient.
- /// This function is payable and will convert all incoming ETH into WETH and perform the trade on behalf of the caller.
- /// The caller is sent all assets from the fill of orders. This function will revert unless the requested amount of assets are purchased.
- /// Any excess ETH sent will be returned to the caller
- /// @param orders An array of Order struct containing order specifications.
- /// @param signatures An array of Proof that order has been created by maker.
- /// @param feeOrders An array of Order struct containing order specifications for fees.
- /// @param makerTokenFillAmount The amount of maker asset to buy.
- /// @param feeSignatures An array of Proof that order has been created by maker for the fee orders.
- /// @param feeProportion A proportion deducted off the ETH spent and sent to feeRecipient. The maximum value for this
- /// is 1000, aka 10%. Supports up to 2 decimal places. I.e 0.59% is 59.
- /// @param feeRecipient An address of the fee recipient whom receives feeProportion of ETH.
- /// @return FillResults amounts filled and fees paid by maker and taker.
- function marketBuyTokensWithEth(
+ /// @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 makerTokenFillAmount,
- uint16 feeProportion,
+ uint256 feePercentage,
address feeRecipient
)
public
payable
- returns (LibFillResults.FillResults memory totalFillResults);
+ returns (
+ LibFillResults.FillResults memory orderFillResults,
+ LibFillResults.FillResults memory feeOrderFillResults
+ );
}