aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/.solhintignore3
-rw-r--r--packages/contracts/CHANGELOG.json115
-rw-r--r--packages/contracts/README.md26
-rw-r--r--packages/contracts/compiler.json5
-rw-r--r--packages/contracts/contracts/examples/ExchangeWrapper/ExchangeWrapper.sol (renamed from packages/contracts/src/2.0.0/examples/ExchangeWrapper/ExchangeWrapper.sol)0
-rw-r--r--packages/contracts/contracts/examples/Validator/Validator.sol (renamed from packages/contracts/src/2.0.0/examples/Validator/Validator.sol)0
-rw-r--r--packages/contracts/contracts/examples/Wallet/Wallet.sol (renamed from packages/contracts/src/2.0.0/examples/Wallet/Wallet.sol)0
-rw-r--r--packages/contracts/contracts/examples/Whitelist/Whitelist.sol (renamed from packages/contracts/src/2.0.0/examples/Whitelist/Whitelist.sol)0
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/Forwarder.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/Forwarder.sol)0
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/MixinAssets.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/MixinAssets.sol)0
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/MixinExchangeWrapper.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/MixinExchangeWrapper.sol)12
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/MixinForwarderCore.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/MixinForwarderCore.sol)0
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/MixinWeth.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/MixinWeth.sol)0
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/interfaces/IAssets.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/interfaces/IAssets.sol)0
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/interfaces/IForwarder.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/interfaces/IForwarder.sol)0
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/interfaces/IForwarderCore.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/interfaces/IForwarderCore.sol)0
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/libs/LibConstants.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/libs/LibConstants.sol)0
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/libs/LibForwarderErrors.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/libs/LibForwarderErrors.sol)0
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/mixins/MAssets.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/mixins/MAssets.sol)0
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/mixins/MExchangeWrapper.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/mixins/MExchangeWrapper.sol)0
-rw-r--r--packages/contracts/contracts/extensions/Forwarder/mixins/MWeth.sol (renamed from packages/contracts/src/2.0.0/extensions/Forwarder/mixins/MWeth.sol)0
-rw-r--r--packages/contracts/contracts/extensions/OrderValidator/OrderValidator.sol (renamed from packages/contracts/src/2.0.0/extensions/OrderValidator/OrderValidator.sol)0
-rw-r--r--packages/contracts/contracts/multisig/MultiSigWallet.sol (renamed from packages/contracts/src/2.0.0/multisig/MultiSigWallet.sol)0
-rw-r--r--packages/contracts/contracts/multisig/MultiSigWalletWithTimeLock.sol (renamed from packages/contracts/src/2.0.0/multisig/MultiSigWalletWithTimeLock.sol)0
-rw-r--r--packages/contracts/contracts/protocol/AssetProxy/ERC20Proxy.sol (renamed from packages/contracts/src/2.0.0/protocol/AssetProxy/ERC20Proxy.sol)0
-rw-r--r--packages/contracts/contracts/protocol/AssetProxy/ERC721Proxy.sol (renamed from packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol)0
-rw-r--r--packages/contracts/contracts/protocol/AssetProxy/MixinAuthorizable.sol (renamed from packages/contracts/src/2.0.0/protocol/AssetProxy/MixinAuthorizable.sol)0
-rw-r--r--packages/contracts/contracts/protocol/AssetProxy/interfaces/IAssetData.sol (renamed from packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetData.sol)0
-rw-r--r--packages/contracts/contracts/protocol/AssetProxy/interfaces/IAssetProxy.sol (renamed from packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetProxy.sol)0
-rw-r--r--packages/contracts/contracts/protocol/AssetProxy/interfaces/IAuthorizable.sol (renamed from packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAuthorizable.sol)0
-rw-r--r--packages/contracts/contracts/protocol/AssetProxy/libs/LibAssetProxyErrors.sol (renamed from packages/contracts/src/2.0.0/protocol/AssetProxy/libs/LibAssetProxyErrors.sol)0
-rw-r--r--packages/contracts/contracts/protocol/AssetProxy/mixins/MAuthorizable.sol (renamed from packages/contracts/src/2.0.0/protocol/AssetProxy/mixins/MAuthorizable.sol)0
-rw-r--r--packages/contracts/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol (renamed from packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/Exchange.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/Exchange.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/MixinAssetProxyDispatcher.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/MixinExchangeCore.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/MixinMatchOrders.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/MixinSignatureValidator.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/MixinTransactions.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/MixinWrapperFunctions.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/interfaces/IExchange.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchange.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/interfaces/IExchangeCore.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchangeCore.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/interfaces/IMatchOrders.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IMatchOrders.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/interfaces/ISignatureValidator.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ISignatureValidator.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/interfaces/ITransactions.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ITransactions.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/interfaces/IValidator.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IValidator.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/interfaces/IWallet.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWallet.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/interfaces/IWrapperFunctions.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWrapperFunctions.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/libs/LibAbiEncoder.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/libs/LibConstants.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/libs/LibEIP712.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/libs/LibEIP712.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/libs/LibExchangeErrors.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/libs/LibExchangeErrors.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/libs/LibFillResults.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/libs/LibFillResults.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/libs/LibMath.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/libs/LibOrder.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/libs/LibOrder.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/mixins/MAssetProxyDispatcher.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/mixins/MAssetProxyDispatcher.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/mixins/MExchangeCore.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/mixins/MExchangeCore.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/mixins/MMatchOrders.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/mixins/MMatchOrders.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/mixins/MSignatureValidator.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/mixins/MTransactions.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/mixins/MTransactions.sol)0
-rw-r--r--packages/contracts/contracts/protocol/Exchange/mixins/MWrapperFunctions.sol (renamed from packages/contracts/src/2.0.0/protocol/Exchange/mixins/MWrapperFunctions.sol)0
-rw-r--r--packages/contracts/contracts/test/DummyERC20Token/DummyERC20Token.sol (renamed from packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol)0
-rw-r--r--packages/contracts/contracts/test/DummyERC20Token/DummyMultipleReturnERC20Token.sol (renamed from packages/contracts/src/2.0.0/test/DummyERC20Token/DummyMultipleReturnERC20Token.sol)0
-rw-r--r--packages/contracts/contracts/test/DummyERC20Token/DummyNoReturnERC20Token.sol (renamed from packages/contracts/src/2.0.0/test/DummyERC20Token/DummyNoReturnERC20Token.sol)0
-rw-r--r--packages/contracts/contracts/test/DummyERC721Receiver/DummyERC721Receiver.sol (renamed from packages/contracts/src/2.0.0/test/DummyERC721Receiver/DummyERC721Receiver.sol)0
-rw-r--r--packages/contracts/contracts/test/DummyERC721Receiver/InvalidERC721Receiver.sol (renamed from packages/contracts/src/2.0.0/test/DummyERC721Receiver/InvalidERC721Receiver.sol)0
-rw-r--r--packages/contracts/contracts/test/DummyERC721Token/DummyERC721Token.sol (renamed from packages/contracts/src/2.0.0/test/DummyERC721Token/DummyERC721Token.sol)0
-rw-r--r--packages/contracts/contracts/test/ReentrantERC20Token/ReentrantERC20Token.sol (renamed from packages/contracts/src/2.0.0/test/ReentrantERC20Token/ReentrantERC20Token.sol)0
-rw-r--r--packages/contracts/contracts/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol (renamed from packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol)0
-rw-r--r--packages/contracts/contracts/test/TestAssetProxyOwner/TestAssetProxyOwner.sol (renamed from packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol)0
-rw-r--r--packages/contracts/contracts/test/TestConstants/TestConstants.sol (renamed from packages/contracts/src/2.0.0/test/TestConstants/TestConstants.sol)0
-rw-r--r--packages/contracts/contracts/test/TestExchangeInternals/TestExchangeInternals.sol (renamed from packages/contracts/src/2.0.0/test/TestExchangeInternals/TestExchangeInternals.sol)0
-rw-r--r--packages/contracts/contracts/test/TestLibBytes/TestLibBytes.sol (renamed from packages/contracts/src/2.0.0/test/TestLibBytes/TestLibBytes.sol)0
-rw-r--r--packages/contracts/contracts/test/TestLibs/TestLibs.sol (renamed from packages/contracts/src/2.0.0/test/TestLibs/TestLibs.sol)0
-rw-r--r--packages/contracts/contracts/test/TestSignatureValidator/TestSignatureValidator.sol (renamed from packages/contracts/src/2.0.0/test/TestSignatureValidator/TestSignatureValidator.sol)0
-rw-r--r--packages/contracts/contracts/test/TestStaticCallReceiver/TestStaticCallReceiver.sol (renamed from packages/contracts/src/2.0.0/test/TestStaticCallReceiver/TestStaticCallReceiver.sol)0
-rw-r--r--packages/contracts/contracts/tokens/ERC20Token/ERC20Token.sol (renamed from packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol)0
-rw-r--r--packages/contracts/contracts/tokens/ERC20Token/IERC20Token.sol (renamed from packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol)0
-rw-r--r--packages/contracts/contracts/tokens/ERC20Token/MintableERC20Token.sol (renamed from packages/contracts/src/2.0.0/tokens/ERC20Token/MintableERC20Token.sol)0
-rw-r--r--packages/contracts/contracts/tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol (renamed from packages/contracts/src/2.0.0/tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol)0
-rw-r--r--packages/contracts/contracts/tokens/ERC721Token/ERC721Token.sol (renamed from packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol)0
-rw-r--r--packages/contracts/contracts/tokens/ERC721Token/IERC721Receiver.sol (renamed from packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol)0
-rw-r--r--packages/contracts/contracts/tokens/ERC721Token/IERC721Token.sol (renamed from packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol)0
-rw-r--r--packages/contracts/contracts/tokens/ERC721Token/MintableERC721Token.sol (renamed from packages/contracts/src/2.0.0/tokens/ERC721Token/MintableERC721Token.sol)0
-rw-r--r--packages/contracts/contracts/tokens/EtherToken/IEtherToken.sol (renamed from packages/contracts/src/2.0.0/tokens/EtherToken/IEtherToken.sol)0
-rw-r--r--packages/contracts/contracts/tokens/EtherToken/WETH9.sol (renamed from packages/contracts/src/2.0.0/tokens/EtherToken/WETH9.sol)0
-rw-r--r--packages/contracts/contracts/tokens/ZRXToken/ERC20Token_v1.sol (renamed from packages/contracts/src/1.0.0/ERC20Token/ERC20Token_v1.sol)2
-rw-r--r--packages/contracts/contracts/tokens/ZRXToken/Token_v1.sol (renamed from packages/contracts/src/1.0.0/Token/Token_v1.sol)0
-rw-r--r--packages/contracts/contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol (renamed from packages/contracts/src/1.0.0/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol)2
-rw-r--r--packages/contracts/contracts/tokens/ZRXToken/ZRXToken.sol (renamed from packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol)2
-rw-r--r--packages/contracts/contracts/utils/LibBytes/LibBytes.sol (renamed from packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol)0
-rw-r--r--packages/contracts/contracts/utils/Ownable/IOwnable.sol (renamed from packages/contracts/src/2.0.0/utils/Ownable/IOwnable.sol)0
-rw-r--r--packages/contracts/contracts/utils/Ownable/Ownable.sol (renamed from packages/contracts/src/2.0.0/utils/Ownable/Ownable.sol)0
-rw-r--r--packages/contracts/contracts/utils/ReentrancyGuard/ReentrancyGuard.sol (renamed from packages/contracts/src/2.0.0/utils/ReentrancyGuard/ReentrancyGuard.sol)0
-rw-r--r--packages/contracts/contracts/utils/SafeMath/SafeMath.sol (renamed from packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol)0
-rw-r--r--packages/contracts/globals.d.ts6
-rw-r--r--packages/contracts/package.json49
-rw-r--r--packages/contracts/src/1.0.0/Arbitrage/Arbitrage.sol114
-rw-r--r--packages/contracts/src/1.0.0/EtherDelta/AccountLevels.sol11
-rw-r--r--packages/contracts/src/1.0.0/EtherDelta/EtherDelta.sol168
-rw-r--r--packages/contracts/src/1.0.0/Exchange/Exchange_v1.sol602
-rw-r--r--packages/contracts/src/1.0.0/Exchange/IExchange_v1.sol226
-rw-r--r--packages/contracts/src/1.0.0/MultiSigWalletWithTImeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol82
-rw-r--r--packages/contracts/src/1.0.0/Ownable/IOwnable_v1.sol18
-rw-r--r--packages/contracts/src/1.0.0/Ownable/Ownable_v1.sol27
-rw-r--r--packages/contracts/src/1.0.0/SafeMath/SafeMath_v1.sol73
-rw-r--r--packages/contracts/src/1.0.0/TokenRegistry/ITokenRegistery.sol195
-rw-r--r--packages/contracts/src/1.0.0/TokenRegistry/TokenRegistry.sol308
-rw-r--r--packages/contracts/src/1.0.0/TokenTransferProxy/TokenTransferProxy_v1.sol115
-rw-r--r--packages/contracts/src/artifacts/index.ts79
-rw-r--r--packages/contracts/src/wrappers/index.ts34
-rw-r--r--packages/contracts/test/asset_proxy/authorizable.ts10
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts26
-rw-r--r--packages/contracts/test/exchange/core.ts31
-rw-r--r--packages/contracts/test/exchange/dispatcher.ts18
-rw-r--r--packages/contracts/test/exchange/fill_order.ts2
-rw-r--r--packages/contracts/test/exchange/internal.ts10
-rw-r--r--packages/contracts/test/exchange/libs.ts14
-rw-r--r--packages/contracts/test/exchange/match_orders.ts26
-rw-r--r--packages/contracts/test/exchange/signature_validator.ts16
-rw-r--r--packages/contracts/test/exchange/transactions.ts20
-rw-r--r--packages/contracts/test/exchange/wrapper.ts24
-rw-r--r--packages/contracts/test/extensions/forwarder.ts289
-rw-r--r--packages/contracts/test/extensions/order_validator.ts22
-rw-r--r--packages/contracts/test/global_hooks.ts2
-rw-r--r--packages/contracts/test/libraries/lib_bytes.ts12
-rw-r--r--packages/contracts/test/multisig/asset_proxy_owner.ts14
-rw-r--r--packages/contracts/test/multisig/multi_sig_with_time_lock.ts12
-rw-r--r--packages/contracts/test/token_registry.ts255
-rw-r--r--packages/contracts/test/tokens/erc721_token.ts14
-rw-r--r--packages/contracts/test/tokens/unlimited_allowance_token.ts10
-rw-r--r--packages/contracts/test/tokens/weth9.ts (renamed from packages/contracts/test/tokens/ether_token.ts)12
-rw-r--r--packages/contracts/test/tokens/zrx_token.ts12
-rw-r--r--packages/contracts/test/tutorials/arbitrage.ts6
-rw-r--r--packages/contracts/test/utils/address_utils.ts4
-rw-r--r--packages/contracts/test/utils/artifacts.ts69
-rw-r--r--packages/contracts/test/utils/assertions.ts6
-rw-r--r--packages/contracts/test/utils/asset_wrapper.ts6
-rw-r--r--packages/contracts/test/utils/combinatorial_utils.ts2
-rw-r--r--packages/contracts/test/utils/constants.ts4
-rw-r--r--packages/contracts/test/utils/coverage.ts4
-rw-r--r--packages/contracts/test/utils/erc20_wrapper.ts12
-rw-r--r--packages/contracts/test/utils/erc721_wrapper.ts12
-rw-r--r--packages/contracts/test/utils/exchange_wrapper.ts14
-rw-r--r--packages/contracts/test/utils/fill_order_combinatorial_utils.ts16
-rw-r--r--packages/contracts/test/utils/formatters.ts4
-rw-r--r--packages/contracts/test/utils/forwarder_wrapper.ts17
-rw-r--r--packages/contracts/test/utils/log_decoder.ts7
-rw-r--r--packages/contracts/test/utils/match_order_tester.ts6
-rw-r--r--packages/contracts/test/utils/multi_sig_wrapper.ts8
-rw-r--r--packages/contracts/test/utils/order_factory.ts6
-rw-r--r--packages/contracts/test/utils/order_factory_from_scenario.ts8
-rw-r--r--packages/contracts/test/utils/order_utils.ts4
-rw-r--r--packages/contracts/test/utils/profiler.ts4
-rw-r--r--packages/contracts/test/utils/revert_trace.ts4
-rw-r--r--packages/contracts/test/utils/signing_utils.ts2
-rw-r--r--packages/contracts/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts4
-rw-r--r--packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts15
-rw-r--r--packages/contracts/test/utils/token_registry_wrapper.ts66
-rw-r--r--packages/contracts/test/utils/transaction_factory.ts6
-rw-r--r--packages/contracts/test/utils/type_encoding_utils.ts2
-rw-r--r--packages/contracts/test/utils/types.ts4
-rw-r--r--packages/contracts/test/utils/web3_wrapper.ts8
-rw-r--r--packages/contracts/tsconfig.json48
-rw-r--r--packages/contracts/tslint.json2
166 files changed, 853 insertions, 2652 deletions
diff --git a/packages/contracts/.solhintignore b/packages/contracts/.solhintignore
new file mode 100644
index 000000000..1e33ec53b
--- /dev/null
+++ b/packages/contracts/.solhintignore
@@ -0,0 +1,3 @@
+contracts/tokens/ZRXToken/ERC20Token_v1.sol
+contracts/tokens/ZRXToken/Token_v1.sol
+contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol
diff --git a/packages/contracts/CHANGELOG.json b/packages/contracts/CHANGELOG.json
new file mode 100644
index 000000000..3f57a33d6
--- /dev/null
+++ b/packages/contracts/CHANGELOG.json
@@ -0,0 +1,115 @@
+[
+ {
+ "name": "Forwarder",
+ "version": "1.1.0",
+ "changes": [
+ {
+ "note": "Round up when calculating remaining amounts in marketBuy functions",
+ "pr": 1162,
+ "networks": {
+ "1": "0x5468a1dc173652ee28d249c271fa9933144746b1",
+ "3": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
+ "42": "0x17992e4ffb22730138e4b62aaa6367fa9d3699a6"
+ }
+ }
+ ]
+ },
+ {
+ "name": "Forwarder",
+ "version": "1.0.0",
+ "changes": [
+ {
+ "note": "protocol v2 deploy",
+ "networks": {
+ "1": "0x7afc2d5107af94c462a194d2c21b5bdd238709d6",
+ "3": "0x3983e204b12b3c02fb0638caf2cd406a62e0ead3",
+ "42": "0xd85e2fa7e7e252b27b01bf0d65c946959d2f45b8"
+ }
+ }
+ ]
+ },
+ {
+ "name": "OrderValidator",
+ "version": "1.0.0",
+ "changes": [
+ {
+ "note": "protocol v2 deploy",
+ "networks": {
+ "1": "0x9463e518dea6810309563c81d5266c1b1d149138",
+ "3": "0x90431a90516ab49af23a0530e04e8c7836e7122f",
+ "42": "0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d"
+ }
+ }
+ ]
+ },
+ {
+ "name": "Exchange",
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note": "protocol v2 deploy",
+ "networks": {
+ "1": "0x4f833a24e1f95d70f028921e27040ca56e09ab0b",
+ "3": "0x4530c0483a1633c7a1c97d2c53721caff2caaaaf",
+ "42": "0x35dd2932454449b14cee11a94d3674a936d5d7b2"
+ }
+ }
+ ]
+ },
+ {
+ "name": "ERC20Proxy",
+ "version": "1.0.0",
+ "changes": [
+ {
+ "note": "protocol v2 deploy",
+ "networks": {
+ "1": "0x2240dab907db71e64d3e0dba4800c83b5c502d4e",
+ "3": "0xb1408f4c245a23c31b98d2c626777d4c0d766caa",
+ "42": "0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e"
+ }
+ }
+ ]
+ },
+ {
+ "name": "ERC721Proxy",
+ "version": "1.0.0",
+ "changes": [
+ {
+ "note": "protocol v2 deploy",
+ "networks": {
+ "1": "0x208e41fb445f1bb1b6780d58356e81405f3e6127",
+ "3": "0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4",
+ "42": "0x2a9127c745688a165106c11cd4d647d2220af821"
+ }
+ }
+ ]
+ },
+ {
+ "name": "AssetProxyOwner",
+ "version": "1.0.0",
+ "changes": [
+ {
+ "note": "protocol v2 deploy",
+ "networks": {
+ "1": "0x17992e4ffb22730138e4b62aaa6367fa9d3699a6",
+ "3": "0xf5fa5b5fed2727a0e44ac67f6772e97977aa358b",
+ "42": "0x2c824d2882baa668e0d5202b1e7f2922278703f8"
+ }
+ }
+ ]
+ },
+ {
+ "name": "ZRXToken",
+ "version": "1.0.0",
+ "changes": [
+ {
+ "note": "protocol v1 deploy",
+ "networks": {
+ "1": "0xe41d2489571d322189246dafa5ebde1f4699f498",
+ "3": "0xff67881f8d12f372d91baae9752eb3631ff0ed00",
+ "42": "0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa"
+ }
+ }
+ ]
+ }
+]
diff --git a/packages/contracts/README.md b/packages/contracts/README.md
index 33cbdae26..97a2816ff 100644
--- a/packages/contracts/README.md
+++ b/packages/contracts/README.md
@@ -1,32 +1,26 @@
## Contracts
-Smart contracts that implement the 0x protocol. Addresses of the deployed contracts can be found [here](https://0xproject.com/wiki#Deployed-Addresses).
+Smart contracts that implement the 0x protocol. Addresses of the deployed contracts can be found in the 0x [wiki](https://0xproject.com/wiki#Deployed-Addresses) or the [CHANGELOG](./CHANGELOG.json) of this package.
## Usage
-### 2.0.0
+Contracts that make up and interact with version 2.0.0 of the protocol can be found in the [contracts](./contracts) directory. The contents of this directory are broken down into the following subdirectories:
-Contracts that make up and interact with version 2.0.0 of the protocol can be found in the `src/2.0.0` directory. The contents of this directory are broken down into the following subdirectories:
-
-* protocol
+* [protocol](./contracts/protocol)
* This directory contains the contracts that make up version 2.0.0. A full specification can be found [here](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
-* extensions
+* [extensions](./contracts/extensions)
* This directory contains contracts that interact with the 2.0.0 contracts and will be used in production, such as the [Forwarder](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md) contract.
-* examples
+* [examples](./contracts/examples)
* This directory contains example implementations of contracts that interact with the protocol but are _not_ intended for use in production. Examples include [filter](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#filter-contracts) contracts, a [Wallet](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#wallet) contract, and a [Validator](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#validator) contract, among others.
-* tokens
+* [tokens](./contracts/tokens)
* This directory contains implementations of different tokens and token standards, including [wETH](https://weth.io/), ZRX, [ERC20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md), and [ERC721](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md).
-* multisig
+* [multisig](./contracts/multisig)
* This directory contains the [Gnosis MultiSigWallet](https://github.com/gnosis/MultiSigWallet) and a custom extension that adds a timelock to transactions within the MultiSigWallet.
-* utils
+* [utils](./contracts/utils)
* This directory contains libraries and utils that are shared across all of the other directories.
-* test
+* [test](./contracts/test)
* This directory contains mocks and other contracts that are used solely for testing contracts within the other directories.
-### 1.0.0
-
-Contracts that make up version 1.0.0 of the protocol can be found in `src/1.0.0`. These contracts are considered deprecated and will have limited support going forward.
-
## Bug bounty
A bug bounty for the 2.0.0 contracts is ongoing! Instructions can be found [here](https://0xproject.com/wiki#Bug-Bounty).
@@ -107,7 +101,7 @@ TEST_PROVIDER=geth yarn test
###### Code coverage
-In order to see the Solidity code coverage output generated by `@0xproject/sol-cov`, run:
+In order to see the Solidity code coverage output generated by `@0x/sol-cov`, run:
```
yarn test:coverage
diff --git a/packages/contracts/compiler.json b/packages/contracts/compiler.json
index 559b7cd1f..af3980b4e 100644
--- a/packages/contracts/compiler.json
+++ b/packages/contracts/compiler.json
@@ -1,6 +1,6 @@
{
- "artifactsDir": "../migrations/artifacts/development",
- "contractsDir": "src/",
+ "artifactsDir": "./generated-artifacts",
+ "contractsDir": "./contracts",
"compilerSettings": {
"optimizer": {
"enabled": true,
@@ -50,7 +50,6 @@
"TestExchangeInternals",
"TestSignatureValidator",
"TestStaticCallReceiver",
- "TokenRegistry",
"Validator",
"Wallet",
"WETH9",
diff --git a/packages/contracts/src/2.0.0/examples/ExchangeWrapper/ExchangeWrapper.sol b/packages/contracts/contracts/examples/ExchangeWrapper/ExchangeWrapper.sol
index 2fa0e3c5e..2fa0e3c5e 100644
--- a/packages/contracts/src/2.0.0/examples/ExchangeWrapper/ExchangeWrapper.sol
+++ b/packages/contracts/contracts/examples/ExchangeWrapper/ExchangeWrapper.sol
diff --git a/packages/contracts/src/2.0.0/examples/Validator/Validator.sol b/packages/contracts/contracts/examples/Validator/Validator.sol
index 72ed528ba..72ed528ba 100644
--- a/packages/contracts/src/2.0.0/examples/Validator/Validator.sol
+++ b/packages/contracts/contracts/examples/Validator/Validator.sol
diff --git a/packages/contracts/src/2.0.0/examples/Wallet/Wallet.sol b/packages/contracts/contracts/examples/Wallet/Wallet.sol
index b75021a31..b75021a31 100644
--- a/packages/contracts/src/2.0.0/examples/Wallet/Wallet.sol
+++ b/packages/contracts/contracts/examples/Wallet/Wallet.sol
diff --git a/packages/contracts/src/2.0.0/examples/Whitelist/Whitelist.sol b/packages/contracts/contracts/examples/Whitelist/Whitelist.sol
index e4e25038c..e4e25038c 100644
--- a/packages/contracts/src/2.0.0/examples/Whitelist/Whitelist.sol
+++ b/packages/contracts/contracts/examples/Whitelist/Whitelist.sol
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/Forwarder.sol b/packages/contracts/contracts/extensions/Forwarder/Forwarder.sol
index 94dec40ed..94dec40ed 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/Forwarder.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/Forwarder.sol
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/MixinAssets.sol b/packages/contracts/contracts/extensions/Forwarder/MixinAssets.sol
index 43efb5ff3..43efb5ff3 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/MixinAssets.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/MixinAssets.sol
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/MixinExchangeWrapper.sol b/packages/contracts/contracts/extensions/Forwarder/MixinExchangeWrapper.sol
index fea9a53c2..4991c0ea5 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/MixinExchangeWrapper.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/MixinExchangeWrapper.sol
@@ -155,8 +155,10 @@ contract MixinExchangeWrapper is
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
- uint256 remainingTakerAssetFillAmount = getPartialAmountFloor(
+ // 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
@@ -224,7 +226,9 @@ contract MixinExchangeWrapper is
// 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.
- uint256 remainingWethSellAmount = getPartialAmountFloor(
+ // 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
@@ -233,7 +237,7 @@ contract MixinExchangeWrapper is
// Attempt to sell the remaining amount of WETH.
FillResults memory singleFillResult = fillOrderNoThrow(
orders[i],
- safeAdd(remainingWethSellAmount, 1), // we add 1 wei to the fill amount to make up for rounding errors
+ remainingWethSellAmount,
signatures[i]
);
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/MixinForwarderCore.sol b/packages/contracts/contracts/extensions/Forwarder/MixinForwarderCore.sol
index 54487f726..54487f726 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/MixinForwarderCore.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/MixinForwarderCore.sol
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/MixinWeth.sol b/packages/contracts/contracts/extensions/Forwarder/MixinWeth.sol
index d2814a49b..d2814a49b 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/MixinWeth.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/MixinWeth.sol
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/interfaces/IAssets.sol b/packages/contracts/contracts/extensions/Forwarder/interfaces/IAssets.sol
index 1e034c003..1e034c003 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/interfaces/IAssets.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/interfaces/IAssets.sol
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/interfaces/IForwarder.sol b/packages/contracts/contracts/extensions/Forwarder/interfaces/IForwarder.sol
index f5a26e2ba..f5a26e2ba 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/interfaces/IForwarder.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/interfaces/IForwarder.sol
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/interfaces/IForwarderCore.sol b/packages/contracts/contracts/extensions/Forwarder/interfaces/IForwarderCore.sol
index 74c7da01d..74c7da01d 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/interfaces/IForwarderCore.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/interfaces/IForwarderCore.sol
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/libs/LibConstants.sol b/packages/contracts/contracts/extensions/Forwarder/libs/LibConstants.sol
index 704e42ce3..704e42ce3 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/libs/LibConstants.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/libs/LibConstants.sol
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/libs/LibForwarderErrors.sol b/packages/contracts/contracts/extensions/Forwarder/libs/LibForwarderErrors.sol
index fb3ade1db..fb3ade1db 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/libs/LibForwarderErrors.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/libs/LibForwarderErrors.sol
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/mixins/MAssets.sol b/packages/contracts/contracts/extensions/Forwarder/mixins/MAssets.sol
index 9e7f80d97..9e7f80d97 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/mixins/MAssets.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/mixins/MAssets.sol
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/mixins/MExchangeWrapper.sol b/packages/contracts/contracts/extensions/Forwarder/mixins/MExchangeWrapper.sol
index 13c26b03a..13c26b03a 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/mixins/MExchangeWrapper.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/mixins/MExchangeWrapper.sol
diff --git a/packages/contracts/src/2.0.0/extensions/Forwarder/mixins/MWeth.sol b/packages/contracts/contracts/extensions/Forwarder/mixins/MWeth.sol
index 88e77be4e..88e77be4e 100644
--- a/packages/contracts/src/2.0.0/extensions/Forwarder/mixins/MWeth.sol
+++ b/packages/contracts/contracts/extensions/Forwarder/mixins/MWeth.sol
diff --git a/packages/contracts/src/2.0.0/extensions/OrderValidator/OrderValidator.sol b/packages/contracts/contracts/extensions/OrderValidator/OrderValidator.sol
index 8bfde3847..8bfde3847 100644
--- a/packages/contracts/src/2.0.0/extensions/OrderValidator/OrderValidator.sol
+++ b/packages/contracts/contracts/extensions/OrderValidator/OrderValidator.sol
diff --git a/packages/contracts/src/2.0.0/multisig/MultiSigWallet.sol b/packages/contracts/contracts/multisig/MultiSigWallet.sol
index 516e7391c..516e7391c 100644
--- a/packages/contracts/src/2.0.0/multisig/MultiSigWallet.sol
+++ b/packages/contracts/contracts/multisig/MultiSigWallet.sol
diff --git a/packages/contracts/src/2.0.0/multisig/MultiSigWalletWithTimeLock.sol b/packages/contracts/contracts/multisig/MultiSigWalletWithTimeLock.sol
index 9513d3b30..9513d3b30 100644
--- a/packages/contracts/src/2.0.0/multisig/MultiSigWalletWithTimeLock.sol
+++ b/packages/contracts/contracts/multisig/MultiSigWalletWithTimeLock.sol
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC20Proxy.sol b/packages/contracts/contracts/protocol/AssetProxy/ERC20Proxy.sol
index 258443bca..258443bca 100644
--- a/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC20Proxy.sol
+++ b/packages/contracts/contracts/protocol/AssetProxy/ERC20Proxy.sol
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol b/packages/contracts/contracts/protocol/AssetProxy/ERC721Proxy.sol
index 65b664b8b..65b664b8b 100644
--- a/packages/contracts/src/2.0.0/protocol/AssetProxy/ERC721Proxy.sol
+++ b/packages/contracts/contracts/protocol/AssetProxy/ERC721Proxy.sol
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/MixinAuthorizable.sol b/packages/contracts/contracts/protocol/AssetProxy/MixinAuthorizable.sol
index fe9bbf848..fe9bbf848 100644
--- a/packages/contracts/src/2.0.0/protocol/AssetProxy/MixinAuthorizable.sol
+++ b/packages/contracts/contracts/protocol/AssetProxy/MixinAuthorizable.sol
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetData.sol b/packages/contracts/contracts/protocol/AssetProxy/interfaces/IAssetData.sol
index 3e76e38dd..3e76e38dd 100644
--- a/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetData.sol
+++ b/packages/contracts/contracts/protocol/AssetProxy/interfaces/IAssetData.sol
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetProxy.sol b/packages/contracts/contracts/protocol/AssetProxy/interfaces/IAssetProxy.sol
index b25d2d75a..b25d2d75a 100644
--- a/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAssetProxy.sol
+++ b/packages/contracts/contracts/protocol/AssetProxy/interfaces/IAssetProxy.sol
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAuthorizable.sol b/packages/contracts/contracts/protocol/AssetProxy/interfaces/IAuthorizable.sol
index ba1d4aa77..ba1d4aa77 100644
--- a/packages/contracts/src/2.0.0/protocol/AssetProxy/interfaces/IAuthorizable.sol
+++ b/packages/contracts/contracts/protocol/AssetProxy/interfaces/IAuthorizable.sol
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/libs/LibAssetProxyErrors.sol b/packages/contracts/contracts/protocol/AssetProxy/libs/LibAssetProxyErrors.sol
index 1d9a70cc1..1d9a70cc1 100644
--- a/packages/contracts/src/2.0.0/protocol/AssetProxy/libs/LibAssetProxyErrors.sol
+++ b/packages/contracts/contracts/protocol/AssetProxy/libs/LibAssetProxyErrors.sol
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxy/mixins/MAuthorizable.sol b/packages/contracts/contracts/protocol/AssetProxy/mixins/MAuthorizable.sol
index d63fb7f6d..d63fb7f6d 100644
--- a/packages/contracts/src/2.0.0/protocol/AssetProxy/mixins/MAuthorizable.sol
+++ b/packages/contracts/contracts/protocol/AssetProxy/mixins/MAuthorizable.sol
diff --git a/packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol b/packages/contracts/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol
index edb788fab..edb788fab 100644
--- a/packages/contracts/src/2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol
+++ b/packages/contracts/contracts/protocol/AssetProxyOwner/AssetProxyOwner.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/Exchange.sol b/packages/contracts/contracts/protocol/Exchange/Exchange.sol
index ead36009f..ead36009f 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/Exchange.sol
+++ b/packages/contracts/contracts/protocol/Exchange/Exchange.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol b/packages/contracts/contracts/protocol/Exchange/MixinAssetProxyDispatcher.sol
index 87b09b6b3..87b09b6b3 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol
+++ b/packages/contracts/contracts/protocol/Exchange/MixinAssetProxyDispatcher.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol b/packages/contracts/contracts/protocol/Exchange/MixinExchangeCore.sol
index 736dcd0b1..736dcd0b1 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinExchangeCore.sol
+++ b/packages/contracts/contracts/protocol/Exchange/MixinExchangeCore.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol b/packages/contracts/contracts/protocol/Exchange/MixinMatchOrders.sol
index b4f6bdb26..b4f6bdb26 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinMatchOrders.sol
+++ b/packages/contracts/contracts/protocol/Exchange/MixinMatchOrders.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol b/packages/contracts/contracts/protocol/Exchange/MixinSignatureValidator.sol
index 176e28351..176e28351 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinSignatureValidator.sol
+++ b/packages/contracts/contracts/protocol/Exchange/MixinSignatureValidator.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol b/packages/contracts/contracts/protocol/Exchange/MixinTransactions.sol
index 3a76ca202..3a76ca202 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol
+++ b/packages/contracts/contracts/protocol/Exchange/MixinTransactions.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol b/packages/contracts/contracts/protocol/Exchange/MixinWrapperFunctions.sol
index cddff0e5f..cddff0e5f 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol
+++ b/packages/contracts/contracts/protocol/Exchange/MixinWrapperFunctions.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol b/packages/contracts/contracts/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol
index 8db8d6f6c..8db8d6f6c 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol
+++ b/packages/contracts/contracts/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchange.sol b/packages/contracts/contracts/protocol/Exchange/interfaces/IExchange.sol
index b92abba04..b92abba04 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchange.sol
+++ b/packages/contracts/contracts/protocol/Exchange/interfaces/IExchange.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchangeCore.sol b/packages/contracts/contracts/protocol/Exchange/interfaces/IExchangeCore.sol
index 9995e0385..9995e0385 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IExchangeCore.sol
+++ b/packages/contracts/contracts/protocol/Exchange/interfaces/IExchangeCore.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IMatchOrders.sol b/packages/contracts/contracts/protocol/Exchange/interfaces/IMatchOrders.sol
index 73447f3ae..73447f3ae 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IMatchOrders.sol
+++ b/packages/contracts/contracts/protocol/Exchange/interfaces/IMatchOrders.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ISignatureValidator.sol b/packages/contracts/contracts/protocol/Exchange/interfaces/ISignatureValidator.sol
index 1fd0eccf0..1fd0eccf0 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ISignatureValidator.sol
+++ b/packages/contracts/contracts/protocol/Exchange/interfaces/ISignatureValidator.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ITransactions.sol b/packages/contracts/contracts/protocol/Exchange/interfaces/ITransactions.sol
index 4446c55ce..4446c55ce 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/ITransactions.sol
+++ b/packages/contracts/contracts/protocol/Exchange/interfaces/ITransactions.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IValidator.sol b/packages/contracts/contracts/protocol/Exchange/interfaces/IValidator.sol
index 2dd69100c..2dd69100c 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IValidator.sol
+++ b/packages/contracts/contracts/protocol/Exchange/interfaces/IValidator.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWallet.sol b/packages/contracts/contracts/protocol/Exchange/interfaces/IWallet.sol
index c97161ca6..c97161ca6 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWallet.sol
+++ b/packages/contracts/contracts/protocol/Exchange/interfaces/IWallet.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWrapperFunctions.sol b/packages/contracts/contracts/protocol/Exchange/interfaces/IWrapperFunctions.sol
index 56a533646..56a533646 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/interfaces/IWrapperFunctions.sol
+++ b/packages/contracts/contracts/protocol/Exchange/interfaces/IWrapperFunctions.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol b/packages/contracts/contracts/protocol/Exchange/libs/LibAbiEncoder.sol
index 4aad37709..4aad37709 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol
+++ b/packages/contracts/contracts/protocol/Exchange/libs/LibAbiEncoder.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol b/packages/contracts/contracts/protocol/Exchange/libs/LibConstants.sol
index 8d2732cd3..8d2732cd3 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibConstants.sol
+++ b/packages/contracts/contracts/protocol/Exchange/libs/LibConstants.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibEIP712.sol b/packages/contracts/contracts/protocol/Exchange/libs/LibEIP712.sol
index 203edc1fd..203edc1fd 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibEIP712.sol
+++ b/packages/contracts/contracts/protocol/Exchange/libs/LibEIP712.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibExchangeErrors.sol b/packages/contracts/contracts/protocol/Exchange/libs/LibExchangeErrors.sol
index a0f75bc06..a0f75bc06 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibExchangeErrors.sol
+++ b/packages/contracts/contracts/protocol/Exchange/libs/LibExchangeErrors.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibFillResults.sol b/packages/contracts/contracts/protocol/Exchange/libs/LibFillResults.sol
index 659ae9a69..659ae9a69 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibFillResults.sol
+++ b/packages/contracts/contracts/protocol/Exchange/libs/LibFillResults.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol b/packages/contracts/contracts/protocol/Exchange/libs/LibMath.sol
index c0b85ea10..c0b85ea10 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibMath.sol
+++ b/packages/contracts/contracts/protocol/Exchange/libs/LibMath.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibOrder.sol b/packages/contracts/contracts/protocol/Exchange/libs/LibOrder.sol
index 0fe7c2161..0fe7c2161 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibOrder.sol
+++ b/packages/contracts/contracts/protocol/Exchange/libs/LibOrder.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MAssetProxyDispatcher.sol b/packages/contracts/contracts/protocol/Exchange/mixins/MAssetProxyDispatcher.sol
index 0ddfca270..0ddfca270 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MAssetProxyDispatcher.sol
+++ b/packages/contracts/contracts/protocol/Exchange/mixins/MAssetProxyDispatcher.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MExchangeCore.sol b/packages/contracts/contracts/protocol/Exchange/mixins/MExchangeCore.sol
index 742499568..742499568 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MExchangeCore.sol
+++ b/packages/contracts/contracts/protocol/Exchange/mixins/MExchangeCore.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MMatchOrders.sol b/packages/contracts/contracts/protocol/Exchange/mixins/MMatchOrders.sol
index 96fa34bc0..96fa34bc0 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MMatchOrders.sol
+++ b/packages/contracts/contracts/protocol/Exchange/mixins/MMatchOrders.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol b/packages/contracts/contracts/protocol/Exchange/mixins/MSignatureValidator.sol
index 1fe88b908..1fe88b908 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MSignatureValidator.sol
+++ b/packages/contracts/contracts/protocol/Exchange/mixins/MSignatureValidator.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MTransactions.sol b/packages/contracts/contracts/protocol/Exchange/mixins/MTransactions.sol
index 4f61a4945..4f61a4945 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MTransactions.sol
+++ b/packages/contracts/contracts/protocol/Exchange/mixins/MTransactions.sol
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MWrapperFunctions.sol b/packages/contracts/contracts/protocol/Exchange/mixins/MWrapperFunctions.sol
index 4adfbde01..4adfbde01 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/mixins/MWrapperFunctions.sol
+++ b/packages/contracts/contracts/protocol/Exchange/mixins/MWrapperFunctions.sol
diff --git a/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol b/packages/contracts/contracts/test/DummyERC20Token/DummyERC20Token.sol
index 412c5d1ad..412c5d1ad 100644
--- a/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyERC20Token.sol
+++ b/packages/contracts/contracts/test/DummyERC20Token/DummyERC20Token.sol
diff --git a/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyMultipleReturnERC20Token.sol b/packages/contracts/contracts/test/DummyERC20Token/DummyMultipleReturnERC20Token.sol
index 733d4437e..733d4437e 100644
--- a/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyMultipleReturnERC20Token.sol
+++ b/packages/contracts/contracts/test/DummyERC20Token/DummyMultipleReturnERC20Token.sol
diff --git a/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyNoReturnERC20Token.sol b/packages/contracts/contracts/test/DummyERC20Token/DummyNoReturnERC20Token.sol
index e16825a16..e16825a16 100644
--- a/packages/contracts/src/2.0.0/test/DummyERC20Token/DummyNoReturnERC20Token.sol
+++ b/packages/contracts/contracts/test/DummyERC20Token/DummyNoReturnERC20Token.sol
diff --git a/packages/contracts/src/2.0.0/test/DummyERC721Receiver/DummyERC721Receiver.sol b/packages/contracts/contracts/test/DummyERC721Receiver/DummyERC721Receiver.sol
index 6c8371559..6c8371559 100644
--- a/packages/contracts/src/2.0.0/test/DummyERC721Receiver/DummyERC721Receiver.sol
+++ b/packages/contracts/contracts/test/DummyERC721Receiver/DummyERC721Receiver.sol
diff --git a/packages/contracts/src/2.0.0/test/DummyERC721Receiver/InvalidERC721Receiver.sol b/packages/contracts/contracts/test/DummyERC721Receiver/InvalidERC721Receiver.sol
index 309633bf5..309633bf5 100644
--- a/packages/contracts/src/2.0.0/test/DummyERC721Receiver/InvalidERC721Receiver.sol
+++ b/packages/contracts/contracts/test/DummyERC721Receiver/InvalidERC721Receiver.sol
diff --git a/packages/contracts/src/2.0.0/test/DummyERC721Token/DummyERC721Token.sol b/packages/contracts/contracts/test/DummyERC721Token/DummyERC721Token.sol
index ac9068d1d..ac9068d1d 100644
--- a/packages/contracts/src/2.0.0/test/DummyERC721Token/DummyERC721Token.sol
+++ b/packages/contracts/contracts/test/DummyERC721Token/DummyERC721Token.sol
diff --git a/packages/contracts/src/2.0.0/test/ReentrantERC20Token/ReentrantERC20Token.sol b/packages/contracts/contracts/test/ReentrantERC20Token/ReentrantERC20Token.sol
index 99dd47a78..99dd47a78 100644
--- a/packages/contracts/src/2.0.0/test/ReentrantERC20Token/ReentrantERC20Token.sol
+++ b/packages/contracts/contracts/test/ReentrantERC20Token/ReentrantERC20Token.sol
diff --git a/packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol b/packages/contracts/contracts/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol
index ad71fc9a1..ad71fc9a1 100644
--- a/packages/contracts/src/2.0.0/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol
+++ b/packages/contracts/contracts/test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol
diff --git a/packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol b/packages/contracts/contracts/test/TestAssetProxyOwner/TestAssetProxyOwner.sol
index 52c66cb56..52c66cb56 100644
--- a/packages/contracts/src/2.0.0/test/TestAssetProxyOwner/TestAssetProxyOwner.sol
+++ b/packages/contracts/contracts/test/TestAssetProxyOwner/TestAssetProxyOwner.sol
diff --git a/packages/contracts/src/2.0.0/test/TestConstants/TestConstants.sol b/packages/contracts/contracts/test/TestConstants/TestConstants.sol
index 1275d007b..1275d007b 100644
--- a/packages/contracts/src/2.0.0/test/TestConstants/TestConstants.sol
+++ b/packages/contracts/contracts/test/TestConstants/TestConstants.sol
diff --git a/packages/contracts/src/2.0.0/test/TestExchangeInternals/TestExchangeInternals.sol b/packages/contracts/contracts/test/TestExchangeInternals/TestExchangeInternals.sol
index 27187f8f8..27187f8f8 100644
--- a/packages/contracts/src/2.0.0/test/TestExchangeInternals/TestExchangeInternals.sol
+++ b/packages/contracts/contracts/test/TestExchangeInternals/TestExchangeInternals.sol
diff --git a/packages/contracts/src/2.0.0/test/TestLibBytes/TestLibBytes.sol b/packages/contracts/contracts/test/TestLibBytes/TestLibBytes.sol
index 00d861e61..00d861e61 100644
--- a/packages/contracts/src/2.0.0/test/TestLibBytes/TestLibBytes.sol
+++ b/packages/contracts/contracts/test/TestLibBytes/TestLibBytes.sol
diff --git a/packages/contracts/src/2.0.0/test/TestLibs/TestLibs.sol b/packages/contracts/contracts/test/TestLibs/TestLibs.sol
index a10f981fc..a10f981fc 100644
--- a/packages/contracts/src/2.0.0/test/TestLibs/TestLibs.sol
+++ b/packages/contracts/contracts/test/TestLibs/TestLibs.sol
diff --git a/packages/contracts/src/2.0.0/test/TestSignatureValidator/TestSignatureValidator.sol b/packages/contracts/contracts/test/TestSignatureValidator/TestSignatureValidator.sol
index ea3e2de59..ea3e2de59 100644
--- a/packages/contracts/src/2.0.0/test/TestSignatureValidator/TestSignatureValidator.sol
+++ b/packages/contracts/contracts/test/TestSignatureValidator/TestSignatureValidator.sol
diff --git a/packages/contracts/src/2.0.0/test/TestStaticCallReceiver/TestStaticCallReceiver.sol b/packages/contracts/contracts/test/TestStaticCallReceiver/TestStaticCallReceiver.sol
index 41aab01c8..41aab01c8 100644
--- a/packages/contracts/src/2.0.0/test/TestStaticCallReceiver/TestStaticCallReceiver.sol
+++ b/packages/contracts/contracts/test/TestStaticCallReceiver/TestStaticCallReceiver.sol
diff --git a/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol b/packages/contracts/contracts/tokens/ERC20Token/ERC20Token.sol
index 725d304df..725d304df 100644
--- a/packages/contracts/src/2.0.0/tokens/ERC20Token/ERC20Token.sol
+++ b/packages/contracts/contracts/tokens/ERC20Token/ERC20Token.sol
diff --git a/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol b/packages/contracts/contracts/tokens/ERC20Token/IERC20Token.sol
index 258d47393..258d47393 100644
--- a/packages/contracts/src/2.0.0/tokens/ERC20Token/IERC20Token.sol
+++ b/packages/contracts/contracts/tokens/ERC20Token/IERC20Token.sol
diff --git a/packages/contracts/src/2.0.0/tokens/ERC20Token/MintableERC20Token.sol b/packages/contracts/contracts/tokens/ERC20Token/MintableERC20Token.sol
index 9dc924422..9dc924422 100644
--- a/packages/contracts/src/2.0.0/tokens/ERC20Token/MintableERC20Token.sol
+++ b/packages/contracts/contracts/tokens/ERC20Token/MintableERC20Token.sol
diff --git a/packages/contracts/src/2.0.0/tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol b/packages/contracts/contracts/tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol
index 2e5bd4348..2e5bd4348 100644
--- a/packages/contracts/src/2.0.0/tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol
+++ b/packages/contracts/contracts/tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol
diff --git a/packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol b/packages/contracts/contracts/tokens/ERC721Token/ERC721Token.sol
index 530f080c0..530f080c0 100644
--- a/packages/contracts/src/2.0.0/tokens/ERC721Token/ERC721Token.sol
+++ b/packages/contracts/contracts/tokens/ERC721Token/ERC721Token.sol
diff --git a/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol b/packages/contracts/contracts/tokens/ERC721Token/IERC721Receiver.sol
index 8e0e32ab2..8e0e32ab2 100644
--- a/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Receiver.sol
+++ b/packages/contracts/contracts/tokens/ERC721Token/IERC721Receiver.sol
diff --git a/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol b/packages/contracts/contracts/tokens/ERC721Token/IERC721Token.sol
index ac992c80d..ac992c80d 100644
--- a/packages/contracts/src/2.0.0/tokens/ERC721Token/IERC721Token.sol
+++ b/packages/contracts/contracts/tokens/ERC721Token/IERC721Token.sol
diff --git a/packages/contracts/src/2.0.0/tokens/ERC721Token/MintableERC721Token.sol b/packages/contracts/contracts/tokens/ERC721Token/MintableERC721Token.sol
index bc5cd2cc2..bc5cd2cc2 100644
--- a/packages/contracts/src/2.0.0/tokens/ERC721Token/MintableERC721Token.sol
+++ b/packages/contracts/contracts/tokens/ERC721Token/MintableERC721Token.sol
diff --git a/packages/contracts/src/2.0.0/tokens/EtherToken/IEtherToken.sol b/packages/contracts/contracts/tokens/EtherToken/IEtherToken.sol
index 9e2e68766..9e2e68766 100644
--- a/packages/contracts/src/2.0.0/tokens/EtherToken/IEtherToken.sol
+++ b/packages/contracts/contracts/tokens/EtherToken/IEtherToken.sol
diff --git a/packages/contracts/src/2.0.0/tokens/EtherToken/WETH9.sol b/packages/contracts/contracts/tokens/EtherToken/WETH9.sol
index 17876b86d..17876b86d 100644
--- a/packages/contracts/src/2.0.0/tokens/EtherToken/WETH9.sol
+++ b/packages/contracts/contracts/tokens/EtherToken/WETH9.sol
diff --git a/packages/contracts/src/1.0.0/ERC20Token/ERC20Token_v1.sol b/packages/contracts/contracts/tokens/ZRXToken/ERC20Token_v1.sol
index e05ee2d5e..4920c4aac 100644
--- a/packages/contracts/src/1.0.0/ERC20Token/ERC20Token_v1.sol
+++ b/packages/contracts/contracts/tokens/ZRXToken/ERC20Token_v1.sol
@@ -1,6 +1,6 @@
pragma solidity ^0.4.11;
-import { Token_v1 as Token } from "../Token/Token_v1.sol";
+import { Token_v1 as Token } from "./Token_v1.sol";
contract ERC20Token_v1 is Token {
diff --git a/packages/contracts/src/1.0.0/Token/Token_v1.sol b/packages/contracts/contracts/tokens/ZRXToken/Token_v1.sol
index de619fb7e..de619fb7e 100644
--- a/packages/contracts/src/1.0.0/Token/Token_v1.sol
+++ b/packages/contracts/contracts/tokens/ZRXToken/Token_v1.sol
diff --git a/packages/contracts/src/1.0.0/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol b/packages/contracts/contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol
index 46379c43d..bf1b0335a 100644
--- a/packages/contracts/src/1.0.0/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol
+++ b/packages/contracts/contracts/tokens/ZRXToken/UnlimitedAllowanceToken_v1.sol
@@ -18,7 +18,7 @@
pragma solidity ^0.4.11;
-import { ERC20Token_v1 as ERC20Token } from "../ERC20Token/ERC20Token_v1.sol";
+import { ERC20Token_v1 as ERC20Token } from "./ERC20Token_v1.sol";
contract UnlimitedAllowanceToken_v1 is ERC20Token {
diff --git a/packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol b/packages/contracts/contracts/tokens/ZRXToken/ZRXToken.sol
index f4855759c..831e1822c 100644
--- a/packages/contracts/src/2.0.0/tokens/ZRXToken/ZRXToken.sol
+++ b/packages/contracts/contracts/tokens/ZRXToken/ZRXToken.sol
@@ -19,7 +19,7 @@
pragma solidity 0.4.11;
// solhint-disable-next-line max-line-length
-import { UnlimitedAllowanceToken_v1 as UnlimitedAllowanceToken } from "../../../1.0.0/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol";
+import { UnlimitedAllowanceToken_v1 as UnlimitedAllowanceToken } from "./UnlimitedAllowanceToken_v1.sol";
contract ZRXToken is
diff --git a/packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol b/packages/contracts/contracts/utils/LibBytes/LibBytes.sol
index 369f588ad..369f588ad 100644
--- a/packages/contracts/src/2.0.0/utils/LibBytes/LibBytes.sol
+++ b/packages/contracts/contracts/utils/LibBytes/LibBytes.sol
diff --git a/packages/contracts/src/2.0.0/utils/Ownable/IOwnable.sol b/packages/contracts/contracts/utils/Ownable/IOwnable.sol
index 5deb13497..5deb13497 100644
--- a/packages/contracts/src/2.0.0/utils/Ownable/IOwnable.sol
+++ b/packages/contracts/contracts/utils/Ownable/IOwnable.sol
diff --git a/packages/contracts/src/2.0.0/utils/Ownable/Ownable.sol b/packages/contracts/contracts/utils/Ownable/Ownable.sol
index 0c830be68..0c830be68 100644
--- a/packages/contracts/src/2.0.0/utils/Ownable/Ownable.sol
+++ b/packages/contracts/contracts/utils/Ownable/Ownable.sol
diff --git a/packages/contracts/src/2.0.0/utils/ReentrancyGuard/ReentrancyGuard.sol b/packages/contracts/contracts/utils/ReentrancyGuard/ReentrancyGuard.sol
index 9f98a7a16..9f98a7a16 100644
--- a/packages/contracts/src/2.0.0/utils/ReentrancyGuard/ReentrancyGuard.sol
+++ b/packages/contracts/contracts/utils/ReentrancyGuard/ReentrancyGuard.sol
diff --git a/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol b/packages/contracts/contracts/utils/SafeMath/SafeMath.sol
index 2855edb9d..2855edb9d 100644
--- a/packages/contracts/src/2.0.0/utils/SafeMath/SafeMath.sol
+++ b/packages/contracts/contracts/utils/SafeMath/SafeMath.sol
diff --git a/packages/contracts/globals.d.ts b/packages/contracts/globals.d.ts
deleted file mode 100644
index 94e63a32d..000000000
--- a/packages/contracts/globals.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-declare module '*.json' {
- const json: any;
- /* tslint:disable */
- export default json;
- /* tslint:enable */
-}
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 01d04e645..bf9bb4826 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -1,39 +1,38 @@
{
"private": true,
"name": "contracts",
- "version": "2.1.49",
+ "version": "2.1.51",
"engines": {
"node": ">=6.12"
},
"description": "Smart contract components of 0x protocol",
- "main": "index.js",
+ "main": "lib/src/index.js",
"directories": {
"test": "test"
},
"scripts": {
"build": "yarn pre_build && tsc -b",
"build:ci": "yarn build",
- "pre_build": "run-s compile copy_artifacts generate_contract_wrappers",
- "copy_artifacts": "copyfiles -u 4 '../migrations/artifacts/development/**/*' ./lib/artifacts;",
+ "pre_build": "run-s compile generate_contract_wrappers",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s build test",
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
"test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html",
"test:trace": "SOLIDITY_REVERT_TRACE=true run-s build run_mocha",
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit",
- "compile": "sol-compiler --contracts-dir src",
- "clean": "shx rm -rf lib generated_contract_wrappers",
- "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output generated_contract_wrappers --backend ethers",
- "lint": "tslint --project . --exclude **/src/generated_contract_wrappers/**/* --exclude **/lib/**/* && yarn lint-contracts",
+ "compile": "sol-compiler --contracts-dir contracts",
+ "clean": "shx rm -rf lib generated-artifacts generated-wrappers",
+ "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output generated-wrappers --backend ethers",
+ "lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
"coverage:report:text": "istanbul report text",
"coverage:report:html": "istanbul report html && open coverage/index.html",
"profiler:report:html": "istanbul report html && open coverage/index.html",
"coverage:report:lcov": "istanbul report lcov",
"test:circleci": "yarn test",
- "lint-contracts": "solhint src/2.0.0/**/**/**/**/*.sol"
+ "lint-contracts": "solhint contracts/**/**/**/**/*.sol"
},
"config": {
- "abis": "../migrations/artifacts/development/@(AssetProxyOwner|DummyERC20Token|DummyERC721Receiver|DummyERC721Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Proxy|ERC721Proxy|Forwarder|Exchange|ExchangeWrapper|IAssetData|IAssetProxy|InvalidERC721Receiver|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|OrderValidator|ReentrantERC20Token|TestAssetProxyOwner|TestAssetProxyDispatcher|TestConstants|TestExchangeInternals|TestLibBytes|TestLibs|TestSignatureValidator|TestStaticCallReceiver|Validator|Wallet|TokenRegistry|Whitelist|WETH9|ZRXToken).json"
+ "abis": "generated-artifacts/@(AssetProxyOwner|DummyERC20Token|DummyERC721Receiver|DummyERC721Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|ERC20Proxy|ERC721Token|ERC721Proxy|Forwarder|Exchange|ExchangeWrapper|IAssetData|IAssetProxy|InvalidERC721Receiver|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|OrderValidator|ReentrantERC20Token|TestAssetProxyOwner|TestAssetProxyDispatcher|TestConstants|TestExchangeInternals|TestLibBytes|TestLibs|TestSignatureValidator|TestStaticCallReceiver|Validator|Wallet|Whitelist|WETH9|ZRXToken).json"
},
"repository": {
"type": "git",
@@ -46,12 +45,12 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md",
"devDependencies": {
- "@0xproject/abi-gen": "^1.0.13",
- "@0xproject/dev-utils": "^1.0.12",
- "@0xproject/sol-compiler": "^1.1.7",
- "@0xproject/sol-cov": "^2.1.7",
- "@0xproject/subproviders": "^2.0.7",
- "@0xproject/tslint-config": "^1.0.8",
+ "@0x/abi-gen": "^1.0.15",
+ "@0x/dev-utils": "^1.0.14",
+ "@0x/sol-compiler": "^1.1.9",
+ "@0x/sol-cov": "^2.1.9",
+ "@0x/subproviders": "^2.1.1",
+ "@0x/tslint-config": "^1.0.10",
"@types/bn.js": "^4.11.0",
"@types/ethereumjs-abi": "^0.6.0",
"@types/lodash": "4.14.104",
@@ -60,7 +59,6 @@
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1",
- "copyfiles": "^2.0.0",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
@@ -73,19 +71,22 @@
"yargs": "^10.0.3"
},
"dependencies": {
- "@0xproject/base-contract": "^3.0.1",
- "@0xproject/order-utils": "^1.0.7",
- "@0xproject/types": "^1.1.4",
- "@0xproject/typescript-typings": "^3.0.2",
- "@0xproject/utils": "^2.0.2",
- "@0xproject/web3-wrapper": "^3.0.3",
+ "@0x/base-contract": "^3.0.3",
+ "@0x/order-utils": "^2.0.1",
+ "@0x/types": "^1.2.1",
+ "@0x/typescript-typings": "^3.0.4",
+ "@0x/utils": "^2.0.4",
+ "@0x/web3-wrapper": "^3.1.1",
"@types/js-combinatorics": "^0.5.29",
"bn.js": "^4.11.8",
- "ethereum-types": "^1.0.11",
+ "ethereum-types": "^1.1.2",
"ethereumjs-abi": "0.6.5",
"ethereumjs-util": "^5.1.1",
"ethers": "~4.0.4",
"js-combinatorics": "^0.5.3",
"lodash": "^4.17.5"
+ },
+ "publishConfig": {
+ "access": "public"
}
}
diff --git a/packages/contracts/src/1.0.0/Arbitrage/Arbitrage.sol b/packages/contracts/src/1.0.0/Arbitrage/Arbitrage.sol
deleted file mode 100644
index 5054afc2f..000000000
--- a/packages/contracts/src/1.0.0/Arbitrage/Arbitrage.sol
+++ /dev/null
@@ -1,114 +0,0 @@
-pragma solidity ^0.4.19;
-
-import { IExchange_v1 as Exchange } from "../Exchange/IExchange_v1.sol";
-import { EtherDelta } from "../EtherDelta/EtherDelta.sol";
-import { Ownable_v1 as Ownable } from "../Ownable/Ownable_v1.sol";
-import { IToken_v1 as Token } from "../Token/IToken_v1.sol";
-
-/// @title Arbitrage - Facilitates atomic arbitrage of ERC20 tokens between EtherDelta and 0x Exchange contract.
-/// @author Leonid Logvinov - <leo@0xProject.com>
-contract Arbitrage is Ownable {
-
- Exchange exchange;
- EtherDelta etherDelta;
- address proxyAddress;
-
- uint256 constant MAX_UINT = 2**256 - 1;
-
- function Arbitrage(address _exchangeAddress, address _etherDeltaAddress, address _proxyAddress) {
- exchange = Exchange(_exchangeAddress);
- etherDelta = EtherDelta(_etherDeltaAddress);
- proxyAddress = _proxyAddress;
- }
-
- /*
- * Makes token tradeable by setting an allowance for etherDelta and 0x proxy contract.
- * Also sets an allowance for the owner of the contracts therefore allowing to withdraw tokens.
- */
- function setAllowances(address tokenAddress) external onlyOwner {
- Token token = Token(tokenAddress);
- token.approve(address(etherDelta), MAX_UINT);
- token.approve(proxyAddress, MAX_UINT);
- token.approve(owner, MAX_UINT);
- }
-
- /*
- * Because of the limits on the number of local variables in Solidity we need to compress parameters while loosing
- * readability. Scheme of the parameter layout:
- *
- * addresses
- * 0..4 orderAddresses
- * 5 user
- *
- * values
- * 0..5 orderValues
- * 6 fillTakerTokenAmount
- * 7 amountGet
- * 8 amountGive
- * 9 expires
- * 10 nonce
- * 11 amount
-
- * signature
- * exchange then etherDelta
- */
- function makeAtomicTrade(
- address[6] addresses, uint[12] values,
- uint8[2] v, bytes32[2] r, bytes32[2] s
- ) external onlyOwner {
- makeExchangeTrade(addresses, values, v, r, s);
- makeEtherDeltaTrade(addresses, values, v, r, s);
- }
-
- function makeEtherDeltaTrade(
- address[6] addresses, uint[12] values,
- uint8[2] v, bytes32[2] r, bytes32[2] s
- ) internal {
- uint amount = values[11];
- etherDelta.depositToken(
- addresses[2], // tokenGet === makerToken
- values[7] // amountGet
- );
- etherDelta.trade(
- addresses[2], // tokenGet === makerToken
- values[7], // amountGet
- addresses[3], // tokenGive === takerToken
- values[8], // amountGive
- values[9], // expires
- values[10], // nonce
- addresses[5], // user
- v[1],
- r[1],
- s[1],
- amount
- );
- etherDelta.withdrawToken(
- addresses[3], // tokenGive === tokenToken
- values[8] // amountGive
- );
- }
-
- function makeExchangeTrade(
- address[6] addresses, uint[12] values,
- uint8[2] v, bytes32[2] r, bytes32[2] s
- ) internal {
- address[5] memory orderAddresses = [
- addresses[0], // maker
- addresses[1], // taker
- addresses[2], // makerToken
- addresses[3], // takerToken
- addresses[4] // feeRecepient
- ];
- uint[6] memory orderValues = [
- values[0], // makerTokenAmount
- values[1], // takerTokenAmount
- values[2], // makerFee
- values[3], // takerFee
- values[4], // expirationTimestampInSec
- values[5] // salt
- ];
- uint fillTakerTokenAmount = values[6]; // fillTakerTokenAmount
- // Execute Exchange trade. It either succeeds in full or fails and reverts all the changes.
- exchange.fillOrKillOrder(orderAddresses, orderValues, fillTakerTokenAmount, v[0], r[0], s[0]);
- }
-}
diff --git a/packages/contracts/src/1.0.0/EtherDelta/AccountLevels.sol b/packages/contracts/src/1.0.0/EtherDelta/AccountLevels.sol
deleted file mode 100644
index 8d7a930d3..000000000
--- a/packages/contracts/src/1.0.0/EtherDelta/AccountLevels.sol
+++ /dev/null
@@ -1,11 +0,0 @@
-pragma solidity ^0.4.19;
-
-contract AccountLevels {
- //given a user, returns an account level
- //0 = regular user (pays take fee and make fee)
- //1 = market maker silver (pays take fee, no make fee, gets rebate)
- //2 = market maker gold (pays take fee, no make fee, gets entire counterparty's take fee as rebate)
- function accountLevel(address user) constant returns(uint) {
- return 0;
- }
-}
diff --git a/packages/contracts/src/1.0.0/EtherDelta/EtherDelta.sol b/packages/contracts/src/1.0.0/EtherDelta/EtherDelta.sol
deleted file mode 100644
index fe599ca0a..000000000
--- a/packages/contracts/src/1.0.0/EtherDelta/EtherDelta.sol
+++ /dev/null
@@ -1,168 +0,0 @@
-pragma solidity ^0.4.19;
-
-import { SafeMath } from "../SafeMath/SafeMath_v1.sol";
-import { AccountLevels } from "./AccountLevels.sol";
-import { Token } from "../Token/Token_v1.sol";
-
-contract EtherDelta is SafeMath {
- address public admin; //the admin address
- address public feeAccount; //the account that will receive fees
- address public accountLevelsAddr; //the address of the AccountLevels contract
- uint public feeMake; //percentage times (1 ether)
- uint public feeTake; //percentage times (1 ether)
- uint public feeRebate; //percentage times (1 ether)
- mapping (address => mapping (address => uint)) public tokens; //mapping of token addresses to mapping of account balances (token=0 means Ether)
- mapping (address => mapping (bytes32 => bool)) public orders; //mapping of user accounts to mapping of order hashes to booleans (true = submitted by user, equivalent to offchain signature)
- mapping (address => mapping (bytes32 => uint)) public orderFills; //mapping of user accounts to mapping of order hashes to uints (amount of order that has been filled)
-
- event Order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user);
- event Cancel(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s);
- event Trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address get, address give);
- event Deposit(address token, address user, uint amount, uint balance);
- event Withdraw(address token, address user, uint amount, uint balance);
-
- function EtherDelta(address admin_, address feeAccount_, address accountLevelsAddr_, uint feeMake_, uint feeTake_, uint feeRebate_) {
- admin = admin_;
- feeAccount = feeAccount_;
- accountLevelsAddr = accountLevelsAddr_;
- feeMake = feeMake_;
- feeTake = feeTake_;
- feeRebate = feeRebate_;
- }
-
- function() {
- throw;
- }
-
- function changeAdmin(address admin_) {
- if (msg.sender != admin) throw;
- admin = admin_;
- }
-
- function changeAccountLevelsAddr(address accountLevelsAddr_) {
- if (msg.sender != admin) throw;
- accountLevelsAddr = accountLevelsAddr_;
- }
-
- function changeFeeAccount(address feeAccount_) {
- if (msg.sender != admin) throw;
- feeAccount = feeAccount_;
- }
-
- function changeFeeMake(uint feeMake_) {
- if (msg.sender != admin) throw;
- if (feeMake_ > feeMake) throw;
- feeMake = feeMake_;
- }
-
- function changeFeeTake(uint feeTake_) {
- if (msg.sender != admin) throw;
- if (feeTake_ > feeTake || feeTake_ < feeRebate) throw;
- feeTake = feeTake_;
- }
-
- function changeFeeRebate(uint feeRebate_) {
- if (msg.sender != admin) throw;
- if (feeRebate_ < feeRebate || feeRebate_ > feeTake) throw;
- feeRebate = feeRebate_;
- }
-
- function deposit() payable {
- tokens[0][msg.sender] = safeAdd(tokens[0][msg.sender], msg.value);
- Deposit(0, msg.sender, msg.value, tokens[0][msg.sender]);
- }
-
- function withdraw(uint amount) {
- if (tokens[0][msg.sender] < amount) throw;
- tokens[0][msg.sender] = safeSub(tokens[0][msg.sender], amount);
- if (!msg.sender.call.value(amount)()) throw;
- Withdraw(0, msg.sender, amount, tokens[0][msg.sender]);
- }
-
- function depositToken(address token, uint amount) {
- //remember to call Token(address).approve(this, amount) or this contract will not be able to do the transfer on your behalf.
- if (token==0) throw;
- if (!Token(token).transferFrom(msg.sender, this, amount)) throw;
- tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount);
- Deposit(token, msg.sender, amount, tokens[token][msg.sender]);
- }
-
- function withdrawToken(address token, uint amount) {
- if (token==0) throw;
- if (tokens[token][msg.sender] < amount) throw;
- tokens[token][msg.sender] = safeSub(tokens[token][msg.sender], amount);
- if (!Token(token).transfer(msg.sender, amount)) throw;
- Withdraw(token, msg.sender, amount, tokens[token][msg.sender]);
- }
-
- function balanceOf(address token, address user) constant returns (uint) {
- return tokens[token][user];
- }
-
- function order(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce) {
- bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
- orders[msg.sender][hash] = true;
- Order(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender);
- }
-
- function trade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount) {
- //amount is in amountGet terms
- bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
- if (!(
- (orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) &&
- block.number <= expires &&
- safeAdd(orderFills[user][hash], amount) <= amountGet
- )) throw;
- tradeBalances(tokenGet, amountGet, tokenGive, amountGive, user, amount);
- orderFills[user][hash] = safeAdd(orderFills[user][hash], amount);
- Trade(tokenGet, amount, tokenGive, amountGive * amount / amountGet, user, msg.sender);
- }
-
- function tradeBalances(address tokenGet, uint amountGet, address tokenGive, uint amountGive, address user, uint amount) private {
- uint feeMakeXfer = safeMul(amount, feeMake) / (1 ether);
- uint feeTakeXfer = safeMul(amount, feeTake) / (1 ether);
- uint feeRebateXfer = 0;
- if (accountLevelsAddr != 0x0) {
- uint accountLevel = AccountLevels(accountLevelsAddr).accountLevel(user);
- if (accountLevel==1) feeRebateXfer = safeMul(amount, feeRebate) / (1 ether);
- if (accountLevel==2) feeRebateXfer = feeTakeXfer;
- }
- tokens[tokenGet][msg.sender] = safeSub(tokens[tokenGet][msg.sender], safeAdd(amount, feeTakeXfer));
- tokens[tokenGet][user] = safeAdd(tokens[tokenGet][user], safeSub(safeAdd(amount, feeRebateXfer), feeMakeXfer));
- tokens[tokenGet][feeAccount] = safeAdd(tokens[tokenGet][feeAccount], safeSub(safeAdd(feeMakeXfer, feeTakeXfer), feeRebateXfer));
- tokens[tokenGive][user] = safeSub(tokens[tokenGive][user], safeMul(amountGive, amount) / amountGet);
- tokens[tokenGive][msg.sender] = safeAdd(tokens[tokenGive][msg.sender], safeMul(amountGive, amount) / amountGet);
- }
-
- function testTrade(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount, address sender) constant returns(bool) {
- if (!(
- tokens[tokenGet][sender] >= amount &&
- availableVolume(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, user, v, r, s) >= amount
- )) return false;
- return true;
- }
-
- function availableVolume(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) {
- bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
- if (!(
- (orders[user][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == user) &&
- block.number <= expires
- )) return 0;
- uint available1 = safeSub(amountGet, orderFills[user][hash]);
- uint available2 = safeMul(tokens[tokenGive][user], amountGet) / amountGive;
- if (available1<available2) return available1;
- return available2;
- }
-
- function amountFilled(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) constant returns(uint) {
- bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
- return orderFills[user][hash];
- }
-
- function cancelOrder(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, uint8 v, bytes32 r, bytes32 s) {
- bytes32 hash = sha256(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce);
- if (!(orders[msg.sender][hash] || ecrecover(sha3("\x19Ethereum Signed Message:\n32", hash),v,r,s) == msg.sender)) throw;
- orderFills[msg.sender][hash] = amountGet;
- Cancel(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender, v, r, s);
- }
-}
diff --git a/packages/contracts/src/1.0.0/Exchange/Exchange_v1.sol b/packages/contracts/src/1.0.0/Exchange/Exchange_v1.sol
deleted file mode 100644
index 3f8e7368d..000000000
--- a/packages/contracts/src/1.0.0/Exchange/Exchange_v1.sol
+++ /dev/null
@@ -1,602 +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.14;
-
-import { TokenTransferProxy_v1 as TokenTransferProxy } from "../TokenTransferProxy/TokenTransferProxy_v1.sol";
-import { Token_v1 as Token } from "../Token/Token_v1.sol";
-import { SafeMath_v1 as SafeMath } from "../SafeMath/SafeMath_v1.sol";
-
-/// @title Exchange - Facilitates exchange of ERC20 tokens.
-/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
-contract Exchange_v1 is SafeMath {
-
- // Error Codes
- enum Errors {
- ORDER_EXPIRED, // Order has already expired
- ORDER_FULLY_FILLED_OR_CANCELLED, // Order has already been fully filled or cancelled
- ROUNDING_ERROR_TOO_LARGE, // Rounding error too large
- INSUFFICIENT_BALANCE_OR_ALLOWANCE // Insufficient balance or allowance for token transfer
- }
-
- string constant public VERSION = "1.0.0";
- uint16 constant public EXTERNAL_QUERY_GAS_LIMIT = 4999; // Changes to state require at least 5000 gas
-
- address public ZRX_TOKEN_CONTRACT;
- address public TOKEN_TRANSFER_PROXY_CONTRACT;
-
- // Mappings of orderHash => amounts of takerTokenAmount filled or cancelled.
- mapping (bytes32 => uint) public filled;
- mapping (bytes32 => uint) public cancelled;
-
- event LogFill(
- address indexed maker,
- address taker,
- address indexed feeRecipient,
- address makerToken,
- address takerToken,
- uint filledMakerTokenAmount,
- uint filledTakerTokenAmount,
- uint paidMakerFee,
- uint paidTakerFee,
- bytes32 indexed tokens, // keccak256(makerToken, takerToken), allows subscribing to a token pair
- bytes32 orderHash
- );
-
- event LogCancel(
- address indexed maker,
- address indexed feeRecipient,
- address makerToken,
- address takerToken,
- uint cancelledMakerTokenAmount,
- uint cancelledTakerTokenAmount,
- bytes32 indexed tokens,
- bytes32 orderHash
- );
-
- event LogError(uint8 indexed errorId, bytes32 indexed orderHash);
-
- struct Order {
- address maker;
- address taker;
- address makerToken;
- address takerToken;
- address feeRecipient;
- uint makerTokenAmount;
- uint takerTokenAmount;
- uint makerFee;
- uint takerFee;
- uint expirationTimestampInSec;
- bytes32 orderHash;
- }
-
- function Exchange_v1(address _zrxToken, address _tokenTransferProxy) {
- ZRX_TOKEN_CONTRACT = _zrxToken;
- TOKEN_TRANSFER_PROXY_CONTRACT = _tokenTransferProxy;
- }
-
- /*
- * Core exchange functions
- */
-
- /// @dev Fills the input order.
- /// @param orderAddresses Array of order's maker, taker, makerToken, takerToken, and feeRecipient.
- /// @param orderValues Array of order's makerTokenAmount, takerTokenAmount, makerFee, takerFee, expirationTimestampInSec, and salt.
- /// @param fillTakerTokenAmount Desired amount of takerToken to fill.
- /// @param shouldThrowOnInsufficientBalanceOrAllowance Test if transfer will fail before attempting.
- /// @param v ECDSA signature parameter v.
- /// @param r ECDSA signature parameters r.
- /// @param s ECDSA signature parameters s.
- /// @return Total amount of takerToken filled in trade.
- function fillOrder(
- address[5] orderAddresses,
- uint[6] orderValues,
- uint fillTakerTokenAmount,
- bool shouldThrowOnInsufficientBalanceOrAllowance,
- uint8 v,
- bytes32 r,
- bytes32 s)
- public
- returns (uint filledTakerTokenAmount)
- {
- Order memory order = Order({
- maker: orderAddresses[0],
- taker: orderAddresses[1],
- makerToken: orderAddresses[2],
- takerToken: orderAddresses[3],
- feeRecipient: orderAddresses[4],
- makerTokenAmount: orderValues[0],
- takerTokenAmount: orderValues[1],
- makerFee: orderValues[2],
- takerFee: orderValues[3],
- expirationTimestampInSec: orderValues[4],
- orderHash: getOrderHash(orderAddresses, orderValues)
- });
-
- require(order.taker == address(0) || order.taker == msg.sender);
- require(order.makerTokenAmount > 0 && order.takerTokenAmount > 0 && fillTakerTokenAmount > 0);
- require(isValidSignature(
- order.maker,
- order.orderHash,
- v,
- r,
- s
- ));
-
- if (block.timestamp >= order.expirationTimestampInSec) {
- LogError(uint8(Errors.ORDER_EXPIRED), order.orderHash);
- return 0;
- }
-
- uint remainingTakerTokenAmount = safeSub(order.takerTokenAmount, getUnavailableTakerTokenAmount(order.orderHash));
- filledTakerTokenAmount = min256(fillTakerTokenAmount, remainingTakerTokenAmount);
- if (filledTakerTokenAmount == 0) {
- LogError(uint8(Errors.ORDER_FULLY_FILLED_OR_CANCELLED), order.orderHash);
- return 0;
- }
-
- if (isRoundingError(filledTakerTokenAmount, order.takerTokenAmount, order.makerTokenAmount)) {
- LogError(uint8(Errors.ROUNDING_ERROR_TOO_LARGE), order.orderHash);
- return 0;
- }
-
- if (!shouldThrowOnInsufficientBalanceOrAllowance && !isTransferable(order, filledTakerTokenAmount)) {
- LogError(uint8(Errors.INSUFFICIENT_BALANCE_OR_ALLOWANCE), order.orderHash);
- return 0;
- }
-
- uint filledMakerTokenAmount = getPartialAmount(filledTakerTokenAmount, order.takerTokenAmount, order.makerTokenAmount);
- uint paidMakerFee;
- uint paidTakerFee;
- filled[order.orderHash] = safeAdd(filled[order.orderHash], filledTakerTokenAmount);
- require(transferViaTokenTransferProxy(
- order.makerToken,
- order.maker,
- msg.sender,
- filledMakerTokenAmount
- ));
- require(transferViaTokenTransferProxy(
- order.takerToken,
- msg.sender,
- order.maker,
- filledTakerTokenAmount
- ));
- if (order.feeRecipient != address(0)) {
- if (order.makerFee > 0) {
- paidMakerFee = getPartialAmount(filledTakerTokenAmount, order.takerTokenAmount, order.makerFee);
- require(transferViaTokenTransferProxy(
- ZRX_TOKEN_CONTRACT,
- order.maker,
- order.feeRecipient,
- paidMakerFee
- ));
- }
- if (order.takerFee > 0) {
- paidTakerFee = getPartialAmount(filledTakerTokenAmount, order.takerTokenAmount, order.takerFee);
- require(transferViaTokenTransferProxy(
- ZRX_TOKEN_CONTRACT,
- msg.sender,
- order.feeRecipient,
- paidTakerFee
- ));
- }
- }
-
- LogFill(
- order.maker,
- msg.sender,
- order.feeRecipient,
- order.makerToken,
- order.takerToken,
- filledMakerTokenAmount,
- filledTakerTokenAmount,
- paidMakerFee,
- paidTakerFee,
- keccak256(order.makerToken, order.takerToken),
- order.orderHash
- );
- return filledTakerTokenAmount;
- }
-
- /// @dev Cancels the input order.
- /// @param orderAddresses Array of order's maker, taker, makerToken, takerToken, and feeRecipient.
- /// @param orderValues Array of order's makerTokenAmount, takerTokenAmount, makerFee, takerFee, expirationTimestampInSec, and salt.
- /// @param cancelTakerTokenAmount Desired amount of takerToken to cancel in order.
- /// @return Amount of takerToken cancelled.
- function cancelOrder(
- address[5] orderAddresses,
- uint[6] orderValues,
- uint cancelTakerTokenAmount)
- public
- returns (uint)
- {
- Order memory order = Order({
- maker: orderAddresses[0],
- taker: orderAddresses[1],
- makerToken: orderAddresses[2],
- takerToken: orderAddresses[3],
- feeRecipient: orderAddresses[4],
- makerTokenAmount: orderValues[0],
- takerTokenAmount: orderValues[1],
- makerFee: orderValues[2],
- takerFee: orderValues[3],
- expirationTimestampInSec: orderValues[4],
- orderHash: getOrderHash(orderAddresses, orderValues)
- });
-
- require(order.maker == msg.sender);
- require(order.makerTokenAmount > 0 && order.takerTokenAmount > 0 && cancelTakerTokenAmount > 0);
-
- if (block.timestamp >= order.expirationTimestampInSec) {
- LogError(uint8(Errors.ORDER_EXPIRED), order.orderHash);
- return 0;
- }
-
- uint remainingTakerTokenAmount = safeSub(order.takerTokenAmount, getUnavailableTakerTokenAmount(order.orderHash));
- uint cancelledTakerTokenAmount = min256(cancelTakerTokenAmount, remainingTakerTokenAmount);
- if (cancelledTakerTokenAmount == 0) {
- LogError(uint8(Errors.ORDER_FULLY_FILLED_OR_CANCELLED), order.orderHash);
- return 0;
- }
-
- cancelled[order.orderHash] = safeAdd(cancelled[order.orderHash], cancelledTakerTokenAmount);
-
- LogCancel(
- order.maker,
- order.feeRecipient,
- order.makerToken,
- order.takerToken,
- getPartialAmount(cancelledTakerTokenAmount, order.takerTokenAmount, order.makerTokenAmount),
- cancelledTakerTokenAmount,
- keccak256(order.makerToken, order.takerToken),
- order.orderHash
- );
- return cancelledTakerTokenAmount;
- }
-
- /*
- * Wrapper functions
- */
-
- /// @dev Fills an order with specified parameters and ECDSA signature, throws if specified amount not filled entirely.
- /// @param orderAddresses Array of order's maker, taker, makerToken, takerToken, and feeRecipient.
- /// @param orderValues Array of order's makerTokenAmount, takerTokenAmount, makerFee, takerFee, expirationTimestampInSec, and salt.
- /// @param fillTakerTokenAmount Desired amount of takerToken to fill.
- /// @param v ECDSA signature parameter v.
- /// @param r ECDSA signature parameters r.
- /// @param s ECDSA signature parameters s.
- function fillOrKillOrder(
- address[5] orderAddresses,
- uint[6] orderValues,
- uint fillTakerTokenAmount,
- uint8 v,
- bytes32 r,
- bytes32 s)
- public
- {
- require(fillOrder(
- orderAddresses,
- orderValues,
- fillTakerTokenAmount,
- false,
- v,
- r,
- s
- ) == fillTakerTokenAmount);
- }
-
- /// @dev Synchronously executes multiple fill orders in a single transaction.
- /// @param orderAddresses Array of address arrays containing individual order addresses.
- /// @param orderValues Array of uint arrays containing individual order values.
- /// @param fillTakerTokenAmounts Array of desired amounts of takerToken to fill in orders.
- /// @param shouldThrowOnInsufficientBalanceOrAllowance Test if transfers will fail before attempting.
- /// @param v Array ECDSA signature v parameters.
- /// @param r Array of ECDSA signature r parameters.
- /// @param s Array of ECDSA signature s parameters.
- function batchFillOrders(
- address[5][] orderAddresses,
- uint[6][] orderValues,
- uint[] fillTakerTokenAmounts,
- bool shouldThrowOnInsufficientBalanceOrAllowance,
- uint8[] v,
- bytes32[] r,
- bytes32[] s)
- public
- {
- for (uint i = 0; i < orderAddresses.length; i++) {
- fillOrder(
- orderAddresses[i],
- orderValues[i],
- fillTakerTokenAmounts[i],
- shouldThrowOnInsufficientBalanceOrAllowance,
- v[i],
- r[i],
- s[i]
- );
- }
- }
-
- /// @dev Synchronously executes multiple fillOrKill orders in a single transaction.
- /// @param orderAddresses Array of address arrays containing individual order addresses.
- /// @param orderValues Array of uint arrays containing individual order values.
- /// @param fillTakerTokenAmounts Array of desired amounts of takerToken to fill in orders.
- /// @param v Array ECDSA signature v parameters.
- /// @param r Array of ECDSA signature r parameters.
- /// @param s Array of ECDSA signature s parameters.
- function batchFillOrKillOrders(
- address[5][] orderAddresses,
- uint[6][] orderValues,
- uint[] fillTakerTokenAmounts,
- uint8[] v,
- bytes32[] r,
- bytes32[] s)
- public
- {
- for (uint i = 0; i < orderAddresses.length; i++) {
- fillOrKillOrder(
- orderAddresses[i],
- orderValues[i],
- fillTakerTokenAmounts[i],
- v[i],
- r[i],
- s[i]
- );
- }
- }
-
- /// @dev Synchronously executes multiple fill orders in a single transaction until total fillTakerTokenAmount filled.
- /// @param orderAddresses Array of address arrays containing individual order addresses.
- /// @param orderValues Array of uint arrays containing individual order values.
- /// @param fillTakerTokenAmount Desired total amount of takerToken to fill in orders.
- /// @param shouldThrowOnInsufficientBalanceOrAllowance Test if transfers will fail before attempting.
- /// @param v Array ECDSA signature v parameters.
- /// @param r Array of ECDSA signature r parameters.
- /// @param s Array of ECDSA signature s parameters.
- /// @return Total amount of fillTakerTokenAmount filled in orders.
- function fillOrdersUpTo(
- address[5][] orderAddresses,
- uint[6][] orderValues,
- uint fillTakerTokenAmount,
- bool shouldThrowOnInsufficientBalanceOrAllowance,
- uint8[] v,
- bytes32[] r,
- bytes32[] s)
- public
- returns (uint)
- {
- uint filledTakerTokenAmount = 0;
- for (uint i = 0; i < orderAddresses.length; i++) {
- require(orderAddresses[i][3] == orderAddresses[0][3]); // takerToken must be the same for each order
- filledTakerTokenAmount = safeAdd(filledTakerTokenAmount, fillOrder(
- orderAddresses[i],
- orderValues[i],
- safeSub(fillTakerTokenAmount, filledTakerTokenAmount),
- shouldThrowOnInsufficientBalanceOrAllowance,
- v[i],
- r[i],
- s[i]
- ));
- if (filledTakerTokenAmount == fillTakerTokenAmount) break;
- }
- return filledTakerTokenAmount;
- }
-
- /// @dev Synchronously cancels multiple orders in a single transaction.
- /// @param orderAddresses Array of address arrays containing individual order addresses.
- /// @param orderValues Array of uint arrays containing individual order values.
- /// @param cancelTakerTokenAmounts Array of desired amounts of takerToken to cancel in orders.
- function batchCancelOrders(
- address[5][] orderAddresses,
- uint[6][] orderValues,
- uint[] cancelTakerTokenAmounts)
- public
- {
- for (uint i = 0; i < orderAddresses.length; i++) {
- cancelOrder(
- orderAddresses[i],
- orderValues[i],
- cancelTakerTokenAmounts[i]
- );
- }
- }
-
- /*
- * Constant public functions
- */
-
- /// @dev Calculates Keccak-256 hash of order with specified parameters.
- /// @param orderAddresses Array of order's maker, taker, makerToken, takerToken, and feeRecipient.
- /// @param orderValues Array of order's makerTokenAmount, takerTokenAmount, makerFee, takerFee, expirationTimestampInSec, and salt.
- /// @return Keccak-256 hash of order.
- function getOrderHash(address[5] orderAddresses, uint[6] orderValues)
- public
- constant
- returns (bytes32)
- {
- return keccak256(
- address(this),
- orderAddresses[0], // maker
- orderAddresses[1], // taker
- orderAddresses[2], // makerToken
- orderAddresses[3], // takerToken
- orderAddresses[4], // feeRecipient
- orderValues[0], // makerTokenAmount
- orderValues[1], // takerTokenAmount
- orderValues[2], // makerFee
- orderValues[3], // takerFee
- orderValues[4], // expirationTimestampInSec
- orderValues[5] // salt
- );
- }
-
- /// @dev Verifies that an order signature is valid.
- /// @param signer address of signer.
- /// @param hash Signed Keccak-256 hash.
- /// @param v ECDSA signature parameter v.
- /// @param r ECDSA signature parameters r.
- /// @param s ECDSA signature parameters s.
- /// @return Validity of order signature.
- function isValidSignature(
- address signer,
- bytes32 hash,
- uint8 v,
- bytes32 r,
- bytes32 s)
- public
- constant
- returns (bool)
- {
- return signer == ecrecover(
- keccak256("\x19Ethereum Signed Message:\n32", hash),
- v,
- r,
- s
- );
- }
-
- /// @dev Checks if rounding error > 0.1%.
- /// @param numerator Numerator.
- /// @param denominator Denominator.
- /// @param target Value to multiply with numerator/denominator.
- /// @return Rounding error is present.
- function isRoundingError(uint numerator, uint denominator, uint target)
- public
- constant
- returns (bool)
- {
- uint remainder = mulmod(target, numerator, denominator);
- if (remainder == 0) return false; // No rounding error.
-
- uint errPercentageTimes1000000 = safeDiv(
- safeMul(remainder, 1000000),
- safeMul(numerator, target)
- );
- return errPercentageTimes1000000 > 1000;
- }
-
- /// @dev Calculates partial value given a numerator and denominator.
- /// @param numerator Numerator.
- /// @param denominator Denominator.
- /// @param target Value to calculate partial of.
- /// @return Partial value of target.
- function getPartialAmount(uint numerator, uint denominator, uint target)
- public
- constant
- returns (uint)
- {
- return safeDiv(safeMul(numerator, target), denominator);
- }
-
- /// @dev Calculates the sum of values already filled and cancelled for a given order.
- /// @param orderHash The Keccak-256 hash of the given order.
- /// @return Sum of values already filled and cancelled.
- function getUnavailableTakerTokenAmount(bytes32 orderHash)
- public
- constant
- returns (uint)
- {
- return safeAdd(filled[orderHash], cancelled[orderHash]);
- }
-
-
- /*
- * Internal functions
- */
-
- /// @dev Transfers a token using TokenTransferProxy transferFrom function.
- /// @param token Address of token to transferFrom.
- /// @param from Address transfering token.
- /// @param to Address receiving token.
- /// @param value Amount of token to transfer.
- /// @return Success of token transfer.
- function transferViaTokenTransferProxy(
- address token,
- address from,
- address to,
- uint value)
- internal
- returns (bool)
- {
- return TokenTransferProxy(TOKEN_TRANSFER_PROXY_CONTRACT).transferFrom(token, from, to, value);
- }
-
- /// @dev Checks if any order transfers will fail.
- /// @param order Order struct of params that will be checked.
- /// @param fillTakerTokenAmount Desired amount of takerToken to fill.
- /// @return Predicted result of transfers.
- function isTransferable(Order order, uint fillTakerTokenAmount)
- internal
- constant // The called token contracts may attempt to change state, but will not be able to due to gas limits on getBalance and getAllowance.
- returns (bool)
- {
- address taker = msg.sender;
- uint fillMakerTokenAmount = getPartialAmount(fillTakerTokenAmount, order.takerTokenAmount, order.makerTokenAmount);
-
- if (order.feeRecipient != address(0)) {
- bool isMakerTokenZRX = order.makerToken == ZRX_TOKEN_CONTRACT;
- bool isTakerTokenZRX = order.takerToken == ZRX_TOKEN_CONTRACT;
- uint paidMakerFee = getPartialAmount(fillTakerTokenAmount, order.takerTokenAmount, order.makerFee);
- uint paidTakerFee = getPartialAmount(fillTakerTokenAmount, order.takerTokenAmount, order.takerFee);
- uint requiredMakerZRX = isMakerTokenZRX ? safeAdd(fillMakerTokenAmount, paidMakerFee) : paidMakerFee;
- uint requiredTakerZRX = isTakerTokenZRX ? safeAdd(fillTakerTokenAmount, paidTakerFee) : paidTakerFee;
-
- if ( getBalance(ZRX_TOKEN_CONTRACT, order.maker) < requiredMakerZRX
- || getAllowance(ZRX_TOKEN_CONTRACT, order.maker) < requiredMakerZRX
- || getBalance(ZRX_TOKEN_CONTRACT, taker) < requiredTakerZRX
- || getAllowance(ZRX_TOKEN_CONTRACT, taker) < requiredTakerZRX
- ) return false;
-
- if (!isMakerTokenZRX && ( getBalance(order.makerToken, order.maker) < fillMakerTokenAmount // Don't double check makerToken if ZRX
- || getAllowance(order.makerToken, order.maker) < fillMakerTokenAmount)
- ) return false;
- if (!isTakerTokenZRX && ( getBalance(order.takerToken, taker) < fillTakerTokenAmount // Don't double check takerToken if ZRX
- || getAllowance(order.takerToken, taker) < fillTakerTokenAmount)
- ) return false;
- } else if ( getBalance(order.makerToken, order.maker) < fillMakerTokenAmount
- || getAllowance(order.makerToken, order.maker) < fillMakerTokenAmount
- || getBalance(order.takerToken, taker) < fillTakerTokenAmount
- || getAllowance(order.takerToken, taker) < fillTakerTokenAmount
- ) return false;
-
- return true;
- }
-
- /// @dev Get token balance of an address.
- /// @param token Address of token.
- /// @param owner Address of owner.
- /// @return Token balance of owner.
- function getBalance(address token, address owner)
- internal
- constant // The called token contract may attempt to change state, but will not be able to due to an added gas limit.
- returns (uint)
- {
- return Token(token).balanceOf.gas(EXTERNAL_QUERY_GAS_LIMIT)(owner); // Limit gas to prevent reentrancy
- }
-
- /// @dev Get allowance of token given to TokenTransferProxy by an address.
- /// @param token Address of token.
- /// @param owner Address of owner.
- /// @return Allowance of token given to TokenTransferProxy by owner.
- function getAllowance(address token, address owner)
- internal
- constant // The called token contract may attempt to change state, but will not be able to due to an added gas limit.
- returns (uint)
- {
- return Token(token).allowance.gas(EXTERNAL_QUERY_GAS_LIMIT)(owner, TOKEN_TRANSFER_PROXY_CONTRACT); // Limit gas to prevent reentrancy
- }
-}
diff --git a/packages/contracts/src/1.0.0/Exchange/IExchange_v1.sol b/packages/contracts/src/1.0.0/Exchange/IExchange_v1.sol
deleted file mode 100644
index ec4bce7b0..000000000
--- a/packages/contracts/src/1.0.0/Exchange/IExchange_v1.sol
+++ /dev/null
@@ -1,226 +0,0 @@
-pragma solidity ^0.4.19;
-
-contract IExchange_v1 {
-
- // Error Codes
- enum Errors {
- ORDER_EXPIRED, // Order has already expired
- ORDER_FULLY_FILLED_OR_CANCELLED, // Order has already been fully filled or cancelled
- ROUNDING_ERROR_TOO_LARGE, // Rounding error too large
- INSUFFICIENT_BALANCE_OR_ALLOWANCE // Insufficient balance or allowance for token transfer
- }
-
- event LogError(uint8 indexed errorId, bytes32 indexed orderHash);
-
- event LogFill(
- address indexed maker,
- address taker,
- address indexed feeRecipient,
- address makerToken,
- address takerToken,
- uint filledMakerTokenAmount,
- uint filledTakerTokenAmount,
- uint paidMakerFee,
- uint paidTakerFee,
- bytes32 indexed tokens, // keccak256(makerToken, takerToken), allows subscribing to a token pair
- bytes32 orderHash
- );
-
- event LogCancel(
- address indexed maker,
- address indexed feeRecipient,
- address makerToken,
- address takerToken,
- uint cancelledMakerTokenAmount,
- uint cancelledTakerTokenAmount,
- bytes32 indexed tokens,
- bytes32 orderHash
- );
-
- function ZRX_TOKEN_CONTRACT()
- public view
- returns (address);
-
- function TOKEN_TRANSFER_PROXY_CONTRACT()
- public view
- returns (address);
-
- function EXTERNAL_QUERY_GAS_LIMIT()
- public view
- returns (uint16);
-
- function VERSION()
- public view
- returns (string);
-
- function filled(bytes32)
- public view
- returns (uint256);
-
- function cancelled(bytes32)
- public view
- returns (uint256);
-
- /// @dev Calculates the sum of values already filled and cancelled for a given order.
- /// @param orderHash The Keccak-256 hash of the given order.
- /// @return Sum of values already filled and cancelled.
- function getUnavailableTakerTokenAmount(bytes32 orderHash)
- public constant
- returns (uint);
-
- /// @dev Calculates partial value given a numerator and denominator.
- /// @param numerator Numerator.
- /// @param denominator Denominator.
- /// @param target Value to calculate partial of.
- /// @return Partial value of target.
- function getPartialAmount(uint numerator, uint denominator, uint target)
- public constant
- returns (uint);
-
- /// @dev Checks if rounding error > 0.1%.
- /// @param numerator Numerator.
- /// @param denominator Denominator.
- /// @param target Value to multiply with numerator/denominator.
- /// @return Rounding error is present.
- function isRoundingError(uint numerator, uint denominator, uint target)
- public constant
- returns (bool);
-
- /// @dev Calculates Keccak-256 hash of order with specified parameters.
- /// @param orderAddresses Array of order's maker, taker, makerToken, takerToken, and feeRecipient.
- /// @param orderValues Array of order's makerTokenAmount, takerTokenAmount, makerFee, takerFee, expirationTimestampInSec, and salt.
- /// @return Keccak-256 hash of order.
- function getOrderHash(address[5] orderAddresses, uint[6] orderValues)
- public
- constant
- returns (bytes32);
-
- /// @dev Verifies that an order signature is valid.
- /// @param signer address of signer.
- /// @param hash Signed Keccak-256 hash.
- /// @param v ECDSA signature parameter v.
- /// @param r ECDSA signature parameters r.
- /// @param s ECDSA signature parameters s.
- /// @return Validity of order signature.
- function isValidSignature(
- address signer,
- bytes32 hash,
- uint8 v,
- bytes32 r,
- bytes32 s)
- public constant
- returns (bool);
-
- /// @dev Fills the input order.
- /// @param orderAddresses Array of order's maker, taker, makerToken, takerToken, and feeRecipient.
- /// @param orderValues Array of order's makerTokenAmount, takerTokenAmount, makerFee, takerFee, expirationTimestampInSec, and salt.
- /// @param fillTakerTokenAmount Desired amount of takerToken to fill.
- /// @param shouldThrowOnInsufficientBalanceOrAllowance Test if transfer will fail before attempting.
- /// @param v ECDSA signature parameter v.
- /// @param r ECDSA signature parameters r.
- /// @param s ECDSA signature parameters s.
- /// @return Total amount of takerToken filled in trade.
- function fillOrder(
- address[5] orderAddresses,
- uint[6] orderValues,
- uint fillTakerTokenAmount,
- bool shouldThrowOnInsufficientBalanceOrAllowance,
- uint8 v,
- bytes32 r,
- bytes32 s)
- public
- returns (uint filledTakerTokenAmount);
-
- /// @dev Cancels the input order.
- /// @param orderAddresses Array of order's maker, taker, makerToken, takerToken, and feeRecipient.
- /// @param orderValues Array of order's makerTokenAmount, takerTokenAmount, makerFee, takerFee, expirationTimestampInSec, and salt.
- /// @param cancelTakerTokenAmount Desired amount of takerToken to cancel in order.
- /// @return Amount of takerToken cancelled.
- function cancelOrder(
- address[5] orderAddresses,
- uint[6] orderValues,
- uint cancelTakerTokenAmount)
- public
- returns (uint);
-
-
- /// @dev Fills an order with specified parameters and ECDSA signature, throws if specified amount not filled entirely.
- /// @param orderAddresses Array of order's maker, taker, makerToken, takerToken, and feeRecipient.
- /// @param orderValues Array of order's makerTokenAmount, takerTokenAmount, makerFee, takerFee, expirationTimestampInSec, and salt.
- /// @param fillTakerTokenAmount Desired amount of takerToken to fill.
- /// @param v ECDSA signature parameter v.
- /// @param r ECDSA signature parameters r.
- /// @param s ECDSA signature parameters s.
- function fillOrKillOrder(
- address[5] orderAddresses,
- uint[6] orderValues,
- uint fillTakerTokenAmount,
- uint8 v,
- bytes32 r,
- bytes32 s)
- public;
-
- /// @dev Synchronously executes multiple fill orders in a single transaction.
- /// @param orderAddresses Array of address arrays containing individual order addresses.
- /// @param orderValues Array of uint arrays containing individual order values.
- /// @param fillTakerTokenAmounts Array of desired amounts of takerToken to fill in orders.
- /// @param shouldThrowOnInsufficientBalanceOrAllowance Test if transfers will fail before attempting.
- /// @param v Array ECDSA signature v parameters.
- /// @param r Array of ECDSA signature r parameters.
- /// @param s Array of ECDSA signature s parameters.
- function batchFillOrders(
- address[5][] orderAddresses,
- uint[6][] orderValues,
- uint[] fillTakerTokenAmounts,
- bool shouldThrowOnInsufficientBalanceOrAllowance,
- uint8[] v,
- bytes32[] r,
- bytes32[] s)
- public;
-
- /// @dev Synchronously executes multiple fillOrKill orders in a single transaction.
- /// @param orderAddresses Array of address arrays containing individual order addresses.
- /// @param orderValues Array of uint arrays containing individual order values.
- /// @param fillTakerTokenAmounts Array of desired amounts of takerToken to fill in orders.
- /// @param v Array ECDSA signature v parameters.
- /// @param r Array of ECDSA signature r parameters.
- /// @param s Array of ECDSA signature s parameters.
- function batchFillOrKillOrders(
- address[5][] orderAddresses,
- uint[6][] orderValues,
- uint[] fillTakerTokenAmounts,
- uint8[] v,
- bytes32[] r,
- bytes32[] s)
- public;
-
- /// @dev Synchronously executes multiple fill orders in a single transaction until total fillTakerTokenAmount filled.
- /// @param orderAddresses Array of address arrays containing individual order addresses.
- /// @param orderValues Array of uint arrays containing individual order values.
- /// @param fillTakerTokenAmount Desired total amount of takerToken to fill in orders.
- /// @param shouldThrowOnInsufficientBalanceOrAllowance Test if transfers will fail before attempting.
- /// @param v Array ECDSA signature v parameters.
- /// @param r Array of ECDSA signature r parameters.
- /// @param s Array of ECDSA signature s parameters.
- /// @return Total amount of fillTakerTokenAmount filled in orders.
- function fillOrdersUpTo(
- address[5][] orderAddresses,
- uint[6][] orderValues,
- uint fillTakerTokenAmount,
- bool shouldThrowOnInsufficientBalanceOrAllowance,
- uint8[] v,
- bytes32[] r,
- bytes32[] s)
- public
- returns (uint);
-
- /// @dev Synchronously cancels multiple orders in a single transaction.
- /// @param orderAddresses Array of address arrays containing individual order addresses.
- /// @param orderValues Array of uint arrays containing individual order values.
- /// @param cancelTakerTokenAmounts Array of desired amounts of takerToken to cancel in orders.
- function batchCancelOrders(
- address[5][] orderAddresses,
- uint[6][] orderValues,
- uint[] cancelTakerTokenAmounts)
- public;
-}
diff --git a/packages/contracts/src/1.0.0/MultiSigWalletWithTImeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol b/packages/contracts/src/1.0.0/MultiSigWalletWithTImeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol
deleted file mode 100644
index aee722c53..000000000
--- a/packages/contracts/src/1.0.0/MultiSigWalletWithTImeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol
+++ /dev/null
@@ -1,82 +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.10;
-
-import "../../2.0.0/multisig/MultiSigWalletWithTimeLock.sol";
-
-contract MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress is MultiSigWalletWithTimeLock {
-
- address public TOKEN_TRANSFER_PROXY_CONTRACT;
-
- modifier validRemoveAuthorizedAddressTx(uint transactionId) {
- Transaction storage tx = transactions[transactionId];
- require(tx.destination == TOKEN_TRANSFER_PROXY_CONTRACT);
- require(isFunctionRemoveAuthorizedAddress(tx.data));
- _;
- }
-
- /// @dev Contract constructor sets initial owners, required number of confirmations, time lock, and tokenTransferProxy address.
- /// @param _owners List of initial owners.
- /// @param _required Number of required confirmations.
- /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds.
- /// @param _tokenTransferProxy Address of TokenTransferProxy contract.
- function MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress(
- address[] _owners,
- uint _required,
- uint _secondsTimeLocked,
- address _tokenTransferProxy)
- public
- MultiSigWalletWithTimeLock(_owners, _required, _secondsTimeLocked)
- {
- TOKEN_TRANSFER_PROXY_CONTRACT = _tokenTransferProxy;
- }
-
- /// @dev Allows execution of removeAuthorizedAddress without time lock.
- /// @param transactionId Transaction ID.
- function executeRemoveAuthorizedAddress(uint transactionId)
- public
- notExecuted(transactionId)
- fullyConfirmed(transactionId)
- validRemoveAuthorizedAddressTx(transactionId)
- {
- Transaction storage tx = transactions[transactionId];
- tx.executed = true;
- if (tx.destination.call.value(tx.value)(tx.data))
- Execution(transactionId);
- else {
- ExecutionFailure(transactionId);
- tx.executed = false;
- }
- }
-
- /// @dev Compares first 4 bytes of byte array to removeAuthorizedAddress function signature.
- /// @param data Transaction data.
- /// @return Successful if data is a call to removeAuthorizedAddress.
- function isFunctionRemoveAuthorizedAddress(bytes data)
- public
- constant
- returns (bool)
- {
- bytes4 removeAuthorizedAddressSignature = bytes4(sha3("removeAuthorizedAddress(address)"));
- for (uint i = 0; i < 4; i++) {
- require(data[i] == removeAuthorizedAddressSignature[i]);
- }
- return true;
- }
-}
diff --git a/packages/contracts/src/1.0.0/Ownable/IOwnable_v1.sol b/packages/contracts/src/1.0.0/Ownable/IOwnable_v1.sol
deleted file mode 100644
index 7e22d544d..000000000
--- a/packages/contracts/src/1.0.0/Ownable/IOwnable_v1.sol
+++ /dev/null
@@ -1,18 +0,0 @@
-pragma solidity ^0.4.19;
-
-/*
- * Ownable
- *
- * Base contract with an owner.
- * Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
- */
-
-contract IOwnable_v1 {
-
- function owner()
- public view
- returns (address);
-
- function transferOwnership(address newOwner)
- public;
-}
diff --git a/packages/contracts/src/1.0.0/Ownable/Ownable_v1.sol b/packages/contracts/src/1.0.0/Ownable/Ownable_v1.sol
deleted file mode 100644
index c87438fa4..000000000
--- a/packages/contracts/src/1.0.0/Ownable/Ownable_v1.sol
+++ /dev/null
@@ -1,27 +0,0 @@
-pragma solidity ^0.4.11;
-
-/*
- * Ownable
- *
- * Base contract with an owner.
- * Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
- */
-
-contract Ownable_v1 {
- address public owner;
-
- function Ownable_v1() {
- owner = msg.sender;
- }
-
- modifier onlyOwner() {
- require(msg.sender == owner);
- _;
- }
-
- function transferOwnership(address newOwner) onlyOwner {
- if (newOwner != address(0)) {
- owner = newOwner;
- }
- }
-}
diff --git a/packages/contracts/src/1.0.0/SafeMath/SafeMath_v1.sol b/packages/contracts/src/1.0.0/SafeMath/SafeMath_v1.sol
deleted file mode 100644
index 341d611ec..000000000
--- a/packages/contracts/src/1.0.0/SafeMath/SafeMath_v1.sol
+++ /dev/null
@@ -1,73 +0,0 @@
-pragma solidity ^0.4.11;
-
-contract SafeMath_v1 {
- function safeMul(uint a, uint b)
- internal
- constant
- returns (uint256)
- {
- uint c = a * b;
- assert(a == 0 || c / a == b);
- return c;
- }
-
- function safeDiv(uint a, uint b)
- internal
- constant
- returns (uint256)
- {
- uint c = a / b;
- return c;
- }
-
- function safeSub(uint a, uint b)
- internal
- constant
- returns (uint256)
- {
- assert(b <= a);
- return a - b;
- }
-
- function safeAdd(uint a, uint b)
- internal
- constant
- returns (uint256)
- {
- uint c = a + b;
- assert(c >= a);
- return c;
- }
-
- function max64(uint64 a, uint64 b)
- internal
- constant
- returns (uint64)
- {
- return a >= b ? a : b;
- }
-
- function min64(uint64 a, uint64 b)
- internal
- constant
- returns (uint64)
- {
- return a < b ? a : b;
- }
-
- function max256(uint256 a, uint256 b)
- internal
- constant
- returns (uint256)
- {
- return a >= b ? a : b;
- }
-
- function min256(uint256 a, uint256 b)
- internal
- constant
- returns (uint256)
- {
- return a < b ? a : b;
- }
-}
diff --git a/packages/contracts/src/1.0.0/TokenRegistry/ITokenRegistery.sol b/packages/contracts/src/1.0.0/TokenRegistry/ITokenRegistery.sol
deleted file mode 100644
index b8bdaf3b9..000000000
--- a/packages/contracts/src/1.0.0/TokenRegistry/ITokenRegistery.sol
+++ /dev/null
@@ -1,195 +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.21;
-
-import { IOwnable_v1 as IOwnable } from "../Ownable/IOwnable_v1.sol";
-
-/// @title Token Registry - Stores metadata associated with ERC20 tokens. See ERC22 https://github.com/ethereum/EIPs/issues/22
-/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
-contract ITokenRegistery is IOwnable {
-
- event LogAddToken(
- address indexed token,
- string name,
- string symbol,
- uint8 decimals,
- bytes ipfsHash,
- bytes swarmHash
- );
-
- event LogRemoveToken(
- address indexed token,
- string name,
- string symbol,
- uint8 decimals,
- bytes ipfsHash,
- bytes swarmHash
- );
-
- event LogTokenNameChange(
- address indexed token,
- string oldName,
- string newName
- );
-
- event LogTokenSymbolChange(
- address indexed token,
- string oldSymbol,
- string newSymbol
- );
-
- event LogTokenIpfsHashChange(
- address indexed token,
- bytes oldIpfsHash,
- bytes newIpfsHash
- );
-
- event LogTokenSwarmHashChange(
- address indexed token,
- bytes oldSwarmHash,
- bytes newSwarmHash
- );
-
- function tokens(address tokenAddress)
- public view
- returns (
- address token,
- string name,
- string symbol,
- uint8 decimals,
- bytes ipfsHash,
- bytes swarmHash
- );
-
- function tokenAddresses(uint256 index)
- public view
- returns (address);
-
-
- /// @dev Allows owner to add a new token to the registry.
- /// @param _token Address of new token.
- /// @param _name Name of new token.
- /// @param _symbol Symbol for new token.
- /// @param _decimals Number of decimals, divisibility of new token.
- /// @param _ipfsHash IPFS hash of token icon.
- /// @param _swarmHash Swarm hash of token icon.
- function addToken(
- address _token,
- string _name,
- string _symbol,
- uint8 _decimals,
- bytes _ipfsHash,
- bytes _swarmHash)
- public;
-
- /// @dev Allows owner to remove an existing token from the registry.
- /// @param _token Address of existing token.
- function removeToken(address _token, uint _index)
- public;
-
- /// @dev Allows owner to modify an existing token's name.
- /// @param _token Address of existing token.
- /// @param _name New name.
- function setTokenName(address _token, string _name)
- public;
-
- /// @dev Allows owner to modify an existing token's symbol.
- /// @param _token Address of existing token.
- /// @param _symbol New symbol.
- function setTokenSymbol(address _token, string _symbol)
- public;
-
- /// @dev Allows owner to modify an existing token's IPFS hash.
- /// @param _token Address of existing token.
- /// @param _ipfsHash New IPFS hash.
- function setTokenIpfsHash(address _token, bytes _ipfsHash)
- public;
-
- /// @dev Allows owner to modify an existing token's Swarm hash.
- /// @param _token Address of existing token.
- /// @param _swarmHash New Swarm hash.
- function setTokenSwarmHash(address _token, bytes _swarmHash)
- public;
-
- /*
- * Web3 call functions
- */
-
- /// @dev Provides a registered token's address when given the token symbol.
- /// @param _symbol Symbol of registered token.
- /// @return Token's address.
- function getTokenAddressBySymbol(string _symbol)
- public constant
- returns (address);
-
- /// @dev Provides a registered token's address when given the token name.
- /// @param _name Name of registered token.
- /// @return Token's address.
- function getTokenAddressByName(string _name)
- public constant
- returns (address);
-
- /// @dev Provides a registered token's metadata, looked up by address.
- /// @param _token Address of registered token.
- /// @return Token metadata.
- function getTokenMetaData(address _token)
- public constant
- returns (
- address, //tokenAddress
- string, //name
- string, //symbol
- uint8, //decimals
- bytes, //ipfsHash
- bytes //swarmHash
- );
-
- /// @dev Provides a registered token's metadata, looked up by name.
- /// @param _name Name of registered token.
- /// @return Token metadata.
- function getTokenByName(string _name)
- public constant
- returns (
- address, //tokenAddress
- string, //name
- string, //symbol
- uint8, //decimals
- bytes, //ipfsHash
- bytes //swarmHash
- );
-
- /// @dev Provides a registered token's metadata, looked up by symbol.
- /// @param _symbol Symbol of registered token.
- /// @return Token metadata.
- function getTokenBySymbol(string _symbol)
- public constant
- returns (
- address, //tokenAddress
- string, //name
- string, //symbol
- uint8, //decimals
- bytes, //ipfsHash
- bytes //swarmHash
- );
-
- /// @dev Returns an array containing all token addresses.
- /// @return Array of token addresses.
- function getTokenAddresses()
- public constant
- returns (address[]);
-}
diff --git a/packages/contracts/src/1.0.0/TokenRegistry/TokenRegistry.sol b/packages/contracts/src/1.0.0/TokenRegistry/TokenRegistry.sol
deleted file mode 100644
index 7417a10a3..000000000
--- a/packages/contracts/src/1.0.0/TokenRegistry/TokenRegistry.sol
+++ /dev/null
@@ -1,308 +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.11;
-
-import { Ownable_v1 as Ownable } from "../Ownable/Ownable_v1.sol";
-
-/// @title Token Registry - Stores metadata associated with ERC20 tokens. See ERC22 https://github.com/ethereum/EIPs/issues/22
-/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
-contract TokenRegistry is Ownable {
-
- event LogAddToken(
- address indexed token,
- string name,
- string symbol,
- uint8 decimals,
- bytes ipfsHash,
- bytes swarmHash
- );
-
- event LogRemoveToken(
- address indexed token,
- string name,
- string symbol,
- uint8 decimals,
- bytes ipfsHash,
- bytes swarmHash
- );
-
- event LogTokenNameChange(address indexed token, string oldName, string newName);
- event LogTokenSymbolChange(address indexed token, string oldSymbol, string newSymbol);
- event LogTokenIpfsHashChange(address indexed token, bytes oldIpfsHash, bytes newIpfsHash);
- event LogTokenSwarmHashChange(address indexed token, bytes oldSwarmHash, bytes newSwarmHash);
-
- mapping (address => TokenMetadata) public tokens;
- mapping (string => address) tokenBySymbol;
- mapping (string => address) tokenByName;
-
- address[] public tokenAddresses;
-
- struct TokenMetadata {
- address token;
- string name;
- string symbol;
- uint8 decimals;
- bytes ipfsHash;
- bytes swarmHash;
- }
-
- modifier tokenExists(address _token) {
- require(tokens[_token].token != address(0));
- _;
- }
-
- modifier tokenDoesNotExist(address _token) {
- require(tokens[_token].token == address(0));
- _;
- }
-
- modifier nameDoesNotExist(string _name) {
- require(tokenByName[_name] == address(0));
- _;
- }
-
- modifier symbolDoesNotExist(string _symbol) {
- require(tokenBySymbol[_symbol] == address(0));
- _;
- }
-
- modifier addressNotNull(address _address) {
- require(_address != address(0));
- _;
- }
-
-
- /// @dev Allows owner to add a new token to the registry.
- /// @param _token Address of new token.
- /// @param _name Name of new token.
- /// @param _symbol Symbol for new token.
- /// @param _decimals Number of decimals, divisibility of new token.
- /// @param _ipfsHash IPFS hash of token icon.
- /// @param _swarmHash Swarm hash of token icon.
- function addToken(
- address _token,
- string _name,
- string _symbol,
- uint8 _decimals,
- bytes _ipfsHash,
- bytes _swarmHash)
- public
- onlyOwner
- tokenDoesNotExist(_token)
- addressNotNull(_token)
- symbolDoesNotExist(_symbol)
- nameDoesNotExist(_name)
- {
- tokens[_token] = TokenMetadata({
- token: _token,
- name: _name,
- symbol: _symbol,
- decimals: _decimals,
- ipfsHash: _ipfsHash,
- swarmHash: _swarmHash
- });
- tokenAddresses.push(_token);
- tokenBySymbol[_symbol] = _token;
- tokenByName[_name] = _token;
- LogAddToken(
- _token,
- _name,
- _symbol,
- _decimals,
- _ipfsHash,
- _swarmHash
- );
- }
-
- /// @dev Allows owner to remove an existing token from the registry.
- /// @param _token Address of existing token.
- function removeToken(address _token, uint _index)
- public
- onlyOwner
- tokenExists(_token)
- {
- require(tokenAddresses[_index] == _token);
-
- tokenAddresses[_index] = tokenAddresses[tokenAddresses.length - 1];
- tokenAddresses.length -= 1;
-
- TokenMetadata storage token = tokens[_token];
- LogRemoveToken(
- token.token,
- token.name,
- token.symbol,
- token.decimals,
- token.ipfsHash,
- token.swarmHash
- );
- delete tokenBySymbol[token.symbol];
- delete tokenByName[token.name];
- delete tokens[_token];
- }
-
- /// @dev Allows owner to modify an existing token's name.
- /// @param _token Address of existing token.
- /// @param _name New name.
- function setTokenName(address _token, string _name)
- public
- onlyOwner
- tokenExists(_token)
- nameDoesNotExist(_name)
- {
- TokenMetadata storage token = tokens[_token];
- LogTokenNameChange(_token, token.name, _name);
- delete tokenByName[token.name];
- tokenByName[_name] = _token;
- token.name = _name;
- }
-
- /// @dev Allows owner to modify an existing token's symbol.
- /// @param _token Address of existing token.
- /// @param _symbol New symbol.
- function setTokenSymbol(address _token, string _symbol)
- public
- onlyOwner
- tokenExists(_token)
- symbolDoesNotExist(_symbol)
- {
- TokenMetadata storage token = tokens[_token];
- LogTokenSymbolChange(_token, token.symbol, _symbol);
- delete tokenBySymbol[token.symbol];
- tokenBySymbol[_symbol] = _token;
- token.symbol = _symbol;
- }
-
- /// @dev Allows owner to modify an existing token's IPFS hash.
- /// @param _token Address of existing token.
- /// @param _ipfsHash New IPFS hash.
- function setTokenIpfsHash(address _token, bytes _ipfsHash)
- public
- onlyOwner
- tokenExists(_token)
- {
- TokenMetadata storage token = tokens[_token];
- LogTokenIpfsHashChange(_token, token.ipfsHash, _ipfsHash);
- token.ipfsHash = _ipfsHash;
- }
-
- /// @dev Allows owner to modify an existing token's Swarm hash.
- /// @param _token Address of existing token.
- /// @param _swarmHash New Swarm hash.
- function setTokenSwarmHash(address _token, bytes _swarmHash)
- public
- onlyOwner
- tokenExists(_token)
- {
- TokenMetadata storage token = tokens[_token];
- LogTokenSwarmHashChange(_token, token.swarmHash, _swarmHash);
- token.swarmHash = _swarmHash;
- }
-
- /*
- * Web3 call functions
- */
-
- /// @dev Provides a registered token's address when given the token symbol.
- /// @param _symbol Symbol of registered token.
- /// @return Token's address.
- function getTokenAddressBySymbol(string _symbol) constant returns (address) {
- return tokenBySymbol[_symbol];
- }
-
- /// @dev Provides a registered token's address when given the token name.
- /// @param _name Name of registered token.
- /// @return Token's address.
- function getTokenAddressByName(string _name) constant returns (address) {
- return tokenByName[_name];
- }
-
- /// @dev Provides a registered token's metadata, looked up by address.
- /// @param _token Address of registered token.
- /// @return Token metadata.
- function getTokenMetaData(address _token)
- public
- constant
- returns (
- address, //tokenAddress
- string, //name
- string, //symbol
- uint8, //decimals
- bytes, //ipfsHash
- bytes //swarmHash
- )
- {
- TokenMetadata memory token = tokens[_token];
- return (
- token.token,
- token.name,
- token.symbol,
- token.decimals,
- token.ipfsHash,
- token.swarmHash
- );
- }
-
- /// @dev Provides a registered token's metadata, looked up by name.
- /// @param _name Name of registered token.
- /// @return Token metadata.
- function getTokenByName(string _name)
- public
- constant
- returns (
- address, //tokenAddress
- string, //name
- string, //symbol
- uint8, //decimals
- bytes, //ipfsHash
- bytes //swarmHash
- )
- {
- address _token = tokenByName[_name];
- return getTokenMetaData(_token);
- }
-
- /// @dev Provides a registered token's metadata, looked up by symbol.
- /// @param _symbol Symbol of registered token.
- /// @return Token metadata.
- function getTokenBySymbol(string _symbol)
- public
- constant
- returns (
- address, //tokenAddress
- string, //name
- string, //symbol
- uint8, //decimals
- bytes, //ipfsHash
- bytes //swarmHash
- )
- {
- address _token = tokenBySymbol[_symbol];
- return getTokenMetaData(_token);
- }
-
- /// @dev Returns an array containing all token addresses.
- /// @return Array of token addresses.
- function getTokenAddresses()
- public
- constant
- returns (address[])
- {
- return tokenAddresses;
- }
-}
diff --git a/packages/contracts/src/1.0.0/TokenTransferProxy/TokenTransferProxy_v1.sol b/packages/contracts/src/1.0.0/TokenTransferProxy/TokenTransferProxy_v1.sol
deleted file mode 100644
index e3659d8ba..000000000
--- a/packages/contracts/src/1.0.0/TokenTransferProxy/TokenTransferProxy_v1.sol
+++ /dev/null
@@ -1,115 +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.11;
-
-import { Token_v1 as Token } from "../Token/Token_v1.sol";
-import { Ownable_v1 as Ownable } from "../Ownable/Ownable_v1.sol";
-
-/// @title TokenTransferProxy - Transfers tokens on behalf of contracts that have been approved via decentralized governance.
-/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>
-contract TokenTransferProxy_v1 is Ownable {
-
- /// @dev Only authorized addresses can invoke functions with this modifier.
- modifier onlyAuthorized {
- require(authorized[msg.sender]);
- _;
- }
-
- modifier targetAuthorized(address target) {
- require(authorized[target]);
- _;
- }
-
- modifier targetNotAuthorized(address target) {
- require(!authorized[target]);
- _;
- }
-
- mapping (address => bool) public authorized;
- address[] public authorities;
-
- event LogAuthorizedAddressAdded(address indexed target, address indexed caller);
- event LogAuthorizedAddressRemoved(address indexed target, address indexed caller);
-
- /*
- * Public functions
- */
-
- /// @dev Authorizes an address.
- /// @param target Address to authorize.
- function addAuthorizedAddress(address target)
- public
- onlyOwner
- targetNotAuthorized(target)
- {
- authorized[target] = true;
- authorities.push(target);
- LogAuthorizedAddressAdded(target, msg.sender);
- }
-
- /// @dev Removes authorizion of an address.
- /// @param target Address to remove authorization from.
- function removeAuthorizedAddress(address target)
- public
- onlyOwner
- targetAuthorized(target)
- {
- delete authorized[target];
- for (uint i = 0; i < authorities.length; i++) {
- if (authorities[i] == target) {
- authorities[i] = authorities[authorities.length - 1];
- authorities.length -= 1;
- break;
- }
- }
- LogAuthorizedAddressRemoved(target, msg.sender);
- }
-
- /// @dev Calls into ERC20 Token contract, invoking transferFrom.
- /// @param token Address of token to transfer.
- /// @param from Address to transfer token from.
- /// @param to Address to transfer token to.
- /// @param value Amount of token to transfer.
- /// @return Success of transfer.
- function transferFrom(
- address token,
- address from,
- address to,
- uint value)
- public
- onlyAuthorized
- returns (bool)
- {
- return Token(token).transferFrom(from, to, value);
- }
-
- /*
- * Public constant functions
- */
-
- /// @dev Gets all authorized addresses.
- /// @return Array of authorized addresses.
- function getAuthorizedAddresses()
- public
- constant
- returns (address[])
- {
- return authorities;
- }
-}
diff --git a/packages/contracts/src/artifacts/index.ts b/packages/contracts/src/artifacts/index.ts
new file mode 100644
index 000000000..c30972a91
--- /dev/null
+++ b/packages/contracts/src/artifacts/index.ts
@@ -0,0 +1,79 @@
+import { ContractArtifact } from 'ethereum-types';
+
+import * as AssetProxyOwner from '../../generated-artifacts/AssetProxyOwner.json';
+import * as DummyERC20Token from '../../generated-artifacts/DummyERC20Token.json';
+import * as DummyERC721Receiver from '../../generated-artifacts/DummyERC721Receiver.json';
+import * as DummyERC721Token from '../../generated-artifacts/DummyERC721Token.json';
+import * as DummyMultipleReturnERC20Token from '../../generated-artifacts/DummyMultipleReturnERC20Token.json';
+import * as DummyNoReturnERC20Token from '../../generated-artifacts/DummyNoReturnERC20Token.json';
+import * as ERC20Proxy from '../../generated-artifacts/ERC20Proxy.json';
+import * as ERC20Token from '../../generated-artifacts/ERC20Token.json';
+import * as ERC721Proxy from '../../generated-artifacts/ERC721Proxy.json';
+import * as ERC721Token from '../../generated-artifacts/ERC721Token.json';
+import * as Exchange from '../../generated-artifacts/Exchange.json';
+import * as ExchangeWrapper from '../../generated-artifacts/ExchangeWrapper.json';
+import * as Forwarder from '../../generated-artifacts/Forwarder.json';
+import * as IAssetData from '../../generated-artifacts/IAssetData.json';
+import * as IAssetProxy from '../../generated-artifacts/IAssetProxy.json';
+import * as InvalidERC721Receiver from '../../generated-artifacts/InvalidERC721Receiver.json';
+import * as IValidator from '../../generated-artifacts/IValidator.json';
+import * as IWallet from '../../generated-artifacts/IWallet.json';
+import * as MixinAuthorizable from '../../generated-artifacts/MixinAuthorizable.json';
+import * as MultiSigWallet from '../../generated-artifacts/MultiSigWallet.json';
+import * as MultiSigWalletWithTimeLock from '../../generated-artifacts/MultiSigWalletWithTimeLock.json';
+import * as OrderValidator from '../../generated-artifacts/OrderValidator.json';
+import * as ReentrantERC20Token from '../../generated-artifacts/ReentrantERC20Token.json';
+import * as TestAssetProxyDispatcher from '../../generated-artifacts/TestAssetProxyDispatcher.json';
+import * as TestAssetProxyOwner from '../../generated-artifacts/TestAssetProxyOwner.json';
+import * as TestConstants from '../../generated-artifacts/TestConstants.json';
+import * as TestExchangeInternals from '../../generated-artifacts/TestExchangeInternals.json';
+import * as TestLibBytes from '../../generated-artifacts/TestLibBytes.json';
+import * as TestLibs from '../../generated-artifacts/TestLibs.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 WETH9 from '../../generated-artifacts/WETH9.json';
+import * as Whitelist from '../../generated-artifacts/Whitelist.json';
+import * as ZRXToken from '../../generated-artifacts/ZRXToken.json';
+
+export const artifacts = {
+ AssetProxyOwner: AssetProxyOwner as ContractArtifact,
+ DummyERC20Token: DummyERC20Token as ContractArtifact,
+ DummyERC721Receiver: DummyERC721Receiver as ContractArtifact,
+ DummyERC721Token: DummyERC721Token as ContractArtifact,
+ DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact,
+ DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact,
+ ERC20Proxy: ERC20Proxy as ContractArtifact,
+ ERC20Token: ERC20Token as ContractArtifact,
+ ERC721Proxy: ERC721Proxy as ContractArtifact,
+ ERC721Token: ERC721Token as ContractArtifact,
+ Exchange: Exchange as ContractArtifact,
+ ExchangeWrapper: ExchangeWrapper as ContractArtifact,
+ Forwarder: Forwarder as ContractArtifact,
+ IAssetData: IAssetData as ContractArtifact,
+ IAssetProxy: IAssetProxy as ContractArtifact,
+ IValidator: IValidator as ContractArtifact,
+ IWallet: IWallet as ContractArtifact,
+ InvalidERC721Receiver: InvalidERC721Receiver as ContractArtifact,
+ MixinAuthorizable: MixinAuthorizable as ContractArtifact,
+ MultiSigWallet: MultiSigWallet as ContractArtifact,
+ MultiSigWalletWithTimeLock: MultiSigWalletWithTimeLock as ContractArtifact,
+ OrderValidator: OrderValidator as ContractArtifact,
+ ReentrantERC20Token: ReentrantERC20Token as ContractArtifact,
+ TestAssetProxyDispatcher: TestAssetProxyDispatcher as ContractArtifact,
+ TestAssetProxyOwner: TestAssetProxyOwner as ContractArtifact,
+ TestConstants: TestConstants as ContractArtifact,
+ TestExchangeInternals: TestExchangeInternals as ContractArtifact,
+ TestLibBytes: TestLibBytes as ContractArtifact,
+ TestLibs: TestLibs as ContractArtifact,
+ TestSignatureValidator: TestSignatureValidator as ContractArtifact,
+ TestStaticCallReceiver: TestStaticCallReceiver as ContractArtifact,
+ Validator: Validator as ContractArtifact,
+ WETH9: WETH9 as ContractArtifact,
+ Wallet: Wallet as ContractArtifact,
+ Whitelist: Whitelist as ContractArtifact,
+ // Note(albrow): "as any" hack still required here because ZRXToken does not
+ // conform to the v2 artifact type.
+ ZRXToken: (ZRXToken as any) as ContractArtifact,
+};
diff --git a/packages/contracts/src/wrappers/index.ts b/packages/contracts/src/wrappers/index.ts
new file mode 100644
index 000000000..9ca676b56
--- /dev/null
+++ b/packages/contracts/src/wrappers/index.ts
@@ -0,0 +1,34 @@
+export * from '../../generated-wrappers/asset_proxy_owner';
+export * from '../../generated-wrappers/dummy_erc20_token';
+export * from '../../generated-wrappers/dummy_erc721_receiver';
+export * from '../../generated-wrappers/dummy_erc721_token';
+export * from '../../generated-wrappers/dummy_multiple_return_erc20_token';
+export * from '../../generated-wrappers/dummy_no_return_erc20_token';
+export * from '../../generated-wrappers/erc20_proxy';
+export * from '../../generated-wrappers/erc721_proxy';
+export * from '../../generated-wrappers/erc20_token';
+export * from '../../generated-wrappers/erc721_token';
+export * from '../../generated-wrappers/exchange';
+export * from '../../generated-wrappers/exchange_wrapper';
+export * from '../../generated-wrappers/forwarder';
+export * from '../../generated-wrappers/i_asset_data';
+export * from '../../generated-wrappers/i_asset_proxy';
+export * from '../../generated-wrappers/invalid_erc721_receiver';
+export * from '../../generated-wrappers/mixin_authorizable';
+export * from '../../generated-wrappers/multi_sig_wallet';
+export * from '../../generated-wrappers/multi_sig_wallet_with_time_lock';
+export * from '../../generated-wrappers/order_validator';
+export * from '../../generated-wrappers/reentrant_erc20_token';
+export * from '../../generated-wrappers/test_asset_proxy_dispatcher';
+export * from '../../generated-wrappers/test_asset_proxy_owner';
+export * from '../../generated-wrappers/test_constants';
+export * from '../../generated-wrappers/test_exchange_internals';
+export * from '../../generated-wrappers/test_lib_bytes';
+export * from '../../generated-wrappers/test_libs';
+export * from '../../generated-wrappers/test_signature_validator';
+export * from '../../generated-wrappers/test_static_call_receiver';
+export * from '../../generated-wrappers/validator';
+export * from '../../generated-wrappers/wallet';
+export * from '../../generated-wrappers/weth9';
+export * from '../../generated-wrappers/whitelist';
+export * from '../../generated-wrappers/zrx_token';
diff --git a/packages/contracts/test/asset_proxy/authorizable.ts b/packages/contracts/test/asset_proxy/authorizable.ts
index 0c0da46b3..e21af9b81 100644
--- a/packages/contracts/test/asset_proxy/authorizable.ts
+++ b/packages/contracts/test/asset_proxy/authorizable.ts
@@ -1,11 +1,11 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { RevertReason } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { RevertReason } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { MixinAuthorizableContract } from '../../generated_contract_wrappers/mixin_authorizable';
-import { artifacts } from '../utils/artifacts';
+import { MixinAuthorizableContract } from '../../generated-wrappers/mixin_authorizable';
+import { artifacts } from '../../src/artifacts';
import { expectTransactionFailedAsync } from '../utils/assertions';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index 4d70031d1..b8305993e 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -1,19 +1,19 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetDataUtils } from '@0xproject/order-utils';
-import { RevertReason } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { assetDataUtils } from '@0x/order-utils';
+import { RevertReason } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_erc20_token';
-import { DummyERC721ReceiverContract } from '../../generated_contract_wrappers/dummy_erc721_receiver';
-import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_erc721_token';
-import { DummyMultipleReturnERC20TokenContract } from '../../generated_contract_wrappers/dummy_multiple_return_erc20_token';
-import { DummyNoReturnERC20TokenContract } from '../../generated_contract_wrappers/dummy_no_return_erc20_token';
-import { ERC20ProxyContract } from '../../generated_contract_wrappers/erc20_proxy';
-import { ERC721ProxyContract } from '../../generated_contract_wrappers/erc721_proxy';
-import { IAssetProxyContract } from '../../generated_contract_wrappers/i_asset_proxy';
-import { artifacts } from '../utils/artifacts';
+import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
+import { DummyERC721ReceiverContract } from '../../generated-wrappers/dummy_erc721_receiver';
+import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
+import { DummyMultipleReturnERC20TokenContract } from '../../generated-wrappers/dummy_multiple_return_erc20_token';
+import { DummyNoReturnERC20TokenContract } from '../../generated-wrappers/dummy_no_return_erc20_token';
+import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
+import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
+import { IAssetProxyContract } from '../../generated-wrappers/i_asset_proxy';
+import { artifacts } from '../../src/artifacts';
import { expectTransactionFailedAsync, expectTransactionFailedWithoutReasonAsync } from '../utils/assertions';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index acb99eed1..fc8dc5346 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -1,25 +1,22 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
-import { RevertReason, SignatureType, SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
+import { RevertReason, SignatureType, SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
-import {
- DummyERC20TokenContract,
- DummyERC20TokenTransferEventArgs,
-} from '../../generated_contract_wrappers/dummy_erc20_token';
-import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_erc721_token';
-import { DummyNoReturnERC20TokenContract } from '../../generated_contract_wrappers/dummy_no_return_erc20_token';
-import { ERC20ProxyContract } from '../../generated_contract_wrappers/erc20_proxy';
-import { ERC721ProxyContract } from '../../generated_contract_wrappers/erc721_proxy';
-import { ExchangeCancelEventArgs, ExchangeContract } from '../../generated_contract_wrappers/exchange';
-import { ReentrantERC20TokenContract } from '../../generated_contract_wrappers/reentrant_erc20_token';
-import { TestStaticCallReceiverContract } from '../../generated_contract_wrappers/test_static_call_receiver';
-import { artifacts } from '../utils/artifacts';
+import { DummyERC20TokenContract, DummyERC20TokenTransferEventArgs } from '../../generated-wrappers/dummy_erc20_token';
+import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
+import { DummyNoReturnERC20TokenContract } from '../../generated-wrappers/dummy_no_return_erc20_token';
+import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
+import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
+import { ExchangeCancelEventArgs, ExchangeContract } from '../../generated-wrappers/exchange';
+import { ReentrantERC20TokenContract } from '../../generated-wrappers/reentrant_erc20_token';
+import { TestStaticCallReceiverContract } from '../../generated-wrappers/test_static_call_receiver';
+import { artifacts } from '../../src/artifacts';
import { expectTransactionFailedAsync } from '../utils/assertions';
import { getLatestBlockTimestampAsync, increaseTimeAndMineBlockAsync } from '../utils/block_timestamp';
import { chaiSetup } from '../utils/chai_setup';
diff --git a/packages/contracts/test/exchange/dispatcher.ts b/packages/contracts/test/exchange/dispatcher.ts
index a8ae897a8..3d3aa42c2 100644
--- a/packages/contracts/test/exchange/dispatcher.ts
+++ b/packages/contracts/test/exchange/dispatcher.ts
@@ -1,19 +1,19 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetDataUtils } from '@0xproject/order-utils';
-import { AssetProxyId, RevertReason } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { assetDataUtils } from '@0x/order-utils';
+import { AssetProxyId, RevertReason } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_erc20_token';
-import { ERC20ProxyContract } from '../../generated_contract_wrappers/erc20_proxy';
-import { ERC721ProxyContract } from '../../generated_contract_wrappers/erc721_proxy';
+import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
+import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
+import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
import {
TestAssetProxyDispatcherAssetProxyRegisteredEventArgs,
TestAssetProxyDispatcherContract,
-} from '../../generated_contract_wrappers/test_asset_proxy_dispatcher';
-import { artifacts } from '../utils/artifacts';
+} from '../../generated-wrappers/test_asset_proxy_dispatcher';
+import { artifacts } from '../../src/artifacts';
import { expectTransactionFailedAsync } from '../utils/assertions';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
diff --git a/packages/contracts/test/exchange/fill_order.ts b/packages/contracts/test/exchange/fill_order.ts
index b1e08324f..37efaad2b 100644
--- a/packages/contracts/test/exchange/fill_order.ts
+++ b/packages/contracts/test/exchange/fill_order.ts
@@ -1,4 +1,4 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
import * as _ from 'lodash';
import { chaiSetup } from '../utils/chai_setup';
diff --git a/packages/contracts/test/exchange/internal.ts b/packages/contracts/test/exchange/internal.ts
index 156e086af..109be29c6 100644
--- a/packages/contracts/test/exchange/internal.ts
+++ b/packages/contracts/test/exchange/internal.ts
@@ -1,11 +1,11 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { Order, RevertReason, SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { Order, RevertReason, SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { TestExchangeInternalsContract } from '../../generated_contract_wrappers/test_exchange_internals';
-import { artifacts } from '../utils/artifacts';
+import { TestExchangeInternalsContract } from '../../generated-wrappers/test_exchange_internals';
+import { artifacts } from '../../src/artifacts';
import { getRevertReasonOrErrorMessageForSendTransactionAsync } from '../utils/assertions';
import { chaiSetup } from '../utils/chai_setup';
import { bytes32Values, testCombinatoriallyWithReferenceFuncAsync, uint256Values } from '../utils/combinatorial_utils';
diff --git a/packages/contracts/test/exchange/libs.ts b/packages/contracts/test/exchange/libs.ts
index 049b7f37a..503ef0e0f 100644
--- a/packages/contracts/test/exchange/libs.ts
+++ b/packages/contracts/test/exchange/libs.ts
@@ -1,13 +1,13 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
-import { SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
+import { SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
-import { TestConstantsContract } from '../../generated_contract_wrappers/test_constants';
-import { TestLibsContract } from '../../generated_contract_wrappers/test_libs';
+import { TestConstantsContract } from '../../generated-wrappers/test_constants';
+import { TestLibsContract } from '../../generated-wrappers/test_libs';
+import { artifacts } from '../../src/artifacts';
import { addressUtils } from '../utils/address_utils';
-import { artifacts } from '../utils/artifacts';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
import { OrderFactory } from '../utils/order_factory';
diff --git a/packages/contracts/test/exchange/match_orders.ts b/packages/contracts/test/exchange/match_orders.ts
index c6e7b494f..eea9992d9 100644
--- a/packages/contracts/test/exchange/match_orders.ts
+++ b/packages/contracts/test/exchange/match_orders.ts
@@ -1,19 +1,19 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetDataUtils } from '@0xproject/order-utils';
-import { RevertReason } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { assetDataUtils } from '@0x/order-utils';
+import { RevertReason } from '@0x/types';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_erc20_token';
-import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_erc721_token';
-import { ERC20ProxyContract } from '../../generated_contract_wrappers/erc20_proxy';
-import { ERC721ProxyContract } from '../../generated_contract_wrappers/erc721_proxy';
-import { ExchangeContract } from '../../generated_contract_wrappers/exchange';
-import { ReentrantERC20TokenContract } from '../../generated_contract_wrappers/reentrant_erc20_token';
-import { TestExchangeInternalsContract } from '../../generated_contract_wrappers/test_exchange_internals';
-import { artifacts } from '../utils/artifacts';
+import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
+import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
+import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
+import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
+import { ExchangeContract } from '../../generated-wrappers/exchange';
+import { ReentrantERC20TokenContract } from '../../generated-wrappers/reentrant_erc20_token';
+import { TestExchangeInternalsContract } from '../../generated-wrappers/test_exchange_internals';
+import { artifacts } from '../../src/artifacts';
import { expectTransactionFailedAsync } from '../utils/assertions';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts
index 192ed3ca9..756c72766 100644
--- a/packages/contracts/test/exchange/signature_validator.ts
+++ b/packages/contracts/test/exchange/signature_validator.ts
@@ -1,6 +1,6 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetDataUtils, orderHashUtils, signatureUtils } from '@0xproject/order-utils';
-import { RevertReason, SignatureType, SignedOrder } from '@0xproject/types';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { assetDataUtils, orderHashUtils, signatureUtils } from '@0x/order-utils';
+import { RevertReason, SignatureType, SignedOrder } from '@0x/types';
import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
@@ -8,12 +8,12 @@ import ethUtil = require('ethereumjs-util');
import {
TestSignatureValidatorContract,
TestSignatureValidatorSignatureValidatorApprovalEventArgs,
-} from '../../generated_contract_wrappers/test_signature_validator';
-import { TestStaticCallReceiverContract } from '../../generated_contract_wrappers/test_static_call_receiver';
-import { ValidatorContract } from '../../generated_contract_wrappers/validator';
-import { WalletContract } from '../../generated_contract_wrappers/wallet';
+} from '../../generated-wrappers/test_signature_validator';
+import { TestStaticCallReceiverContract } from '../../generated-wrappers/test_static_call_receiver';
+import { ValidatorContract } from '../../generated-wrappers/validator';
+import { WalletContract } from '../../generated-wrappers/wallet';
+import { artifacts } from '../../src/artifacts';
import { addressUtils } from '../utils/address_utils';
-import { artifacts } from '../utils/artifacts';
import { expectContractCallFailedAsync } from '../utils/assertions';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts
index 2bdd96b16..1b5eef295 100644
--- a/packages/contracts/test/exchange/transactions.ts
+++ b/packages/contracts/test/exchange/transactions.ts
@@ -1,16 +1,16 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetDataUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
-import { OrderWithoutExchangeAddress, RevertReason, SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils';
+import { OrderWithoutExchangeAddress, RevertReason, SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_erc20_token';
-import { ERC20ProxyContract } from '../../generated_contract_wrappers/erc20_proxy';
-import { ExchangeContract } from '../../generated_contract_wrappers/exchange';
-import { ExchangeWrapperContract } from '../../generated_contract_wrappers/exchange_wrapper';
-import { WhitelistContract } from '../../generated_contract_wrappers/whitelist';
-import { artifacts } from '../utils/artifacts';
+import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
+import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
+import { ExchangeContract } from '../../generated-wrappers/exchange';
+import { ExchangeWrapperContract } from '../../generated-wrappers/exchange_wrapper';
+import { WhitelistContract } from '../../generated-wrappers/whitelist';
+import { artifacts } from '../../src/artifacts';
import { expectTransactionFailedAsync } from '../utils/assertions';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index aadb5ab59..6b660aac5 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -1,18 +1,18 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
-import { RevertReason, SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
+import { RevertReason, SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_erc20_token';
-import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_erc721_token';
-import { ERC20ProxyContract } from '../../generated_contract_wrappers/erc20_proxy';
-import { ERC721ProxyContract } from '../../generated_contract_wrappers/erc721_proxy';
-import { ExchangeContract } from '../../generated_contract_wrappers/exchange';
-import { ReentrantERC20TokenContract } from '../../generated_contract_wrappers/reentrant_erc20_token';
-import { artifacts } from '../utils/artifacts';
+import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
+import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
+import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
+import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
+import { ExchangeContract } from '../../generated-wrappers/exchange';
+import { ReentrantERC20TokenContract } from '../../generated-wrappers/reentrant_erc20_token';
+import { artifacts } from '../../src/artifacts';
import { expectTransactionFailedAsync } from '../utils/assertions';
import { getLatestBlockTimestampAsync, increaseTimeAndMineBlockAsync } from '../utils/block_timestamp';
import { chaiSetup } from '../utils/chai_setup';
diff --git a/packages/contracts/test/extensions/forwarder.ts b/packages/contracts/test/extensions/forwarder.ts
index 8424d01fd..c006be0fe 100644
--- a/packages/contracts/test/extensions/forwarder.ts
+++ b/packages/contracts/test/extensions/forwarder.ts
@@ -1,17 +1,17 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetDataUtils } from '@0xproject/order-utils';
-import { RevertReason, SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { assetDataUtils } from '@0x/order-utils';
+import { RevertReason, SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
-import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_erc20_token';
-import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_erc721_token';
-import { ExchangeContract } from '../../generated_contract_wrappers/exchange';
-import { ForwarderContract } from '../../generated_contract_wrappers/forwarder';
-import { WETH9Contract } from '../../generated_contract_wrappers/weth9';
-import { artifacts } from '../utils/artifacts';
+import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
+import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
+import { ExchangeContract } from '../../generated-wrappers/exchange';
+import { ForwarderContract } from '../../generated-wrappers/forwarder';
+import { WETH9Contract } from '../../generated-wrappers/weth9';
+import { artifacts } from '../../src/artifacts';
import {
expectContractCreationFailedAsync,
expectTransactionFailedAsync,
@@ -45,6 +45,7 @@ describe(ContractName.Forwarder, () => {
let weth: DummyERC20TokenContract;
let zrxToken: DummyERC20TokenContract;
+ let erc20TokenA: DummyERC20TokenContract;
let erc721Token: DummyERC721TokenContract;
let forwarderContract: ForwarderContract;
let wethContract: WETH9Contract;
@@ -77,7 +78,6 @@ describe(ContractName.Forwarder, () => {
erc20Wrapper = new ERC20Wrapper(provider, usedAddresses, owner);
const numDummyErc20ToDeploy = 3;
- let erc20TokenA;
[erc20TokenA, zrxToken] = await erc20Wrapper.deployDummyTokensAsync(
numDummyErc20ToDeploy,
constants.DUMMY_TOKEN_DECIMALS,
@@ -91,7 +91,7 @@ describe(ContractName.Forwarder, () => {
const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
- wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.EtherToken, provider, txDefaults);
+ wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults);
weth = new DummyERC20TokenContract(wethContract.abi, wethContract.address, provider);
erc20Wrapper.addDummyTokenContract(weth);
@@ -902,6 +902,269 @@ describe(ContractName.Forwarder, () => {
);
expect(forwarderEthBalance).to.be.bignumber.equal(constants.ZERO_AMOUNT);
});
+ it('Should buy slightly greater MakerAsset when exchange rate is rounded', async () => {
+ // The 0x Protocol contracts round the exchange rate in favor of the Maker.
+ // In this case, the taker must round up how much they're going to spend, which
+ // in turn increases the amount of MakerAsset being purchased.
+ // Example:
+ // The taker wants to buy 5 units of the MakerAsset at a rate of 3M/2T.
+ // For every 2 units of TakerAsset, the taker will receive 3 units of MakerAsset.
+ // To purchase 5 units, the taker must spend 10/3 = 3.33 units of TakerAssset.
+ // However, the Taker can only spend whole units.
+ // Spending floor(10/3) = 3 units will yield a profit of Floor(3*3/2) = Floor(4.5) = 4 units of MakerAsset.
+ // Spending ceil(10/3) = 4 units will yield a profit of Floor(4*3/2) = 6 units of MakerAsset.
+ //
+ // The forwarding contract will opt for the second option, which overbuys, to ensure the taker
+ // receives at least the amount of MakerAsset they requested.
+ //
+ // Construct test case using values from example above
+ orderWithoutFee = await orderFactory.newSignedOrderAsync({
+ makerAssetAmount: new BigNumber('30'),
+ takerAssetAmount: new BigNumber('20'),
+ makerAssetData: assetDataUtils.encodeERC20AssetData(erc20TokenA.address),
+ takerAssetData: assetDataUtils.encodeERC20AssetData(weth.address),
+ makerFee: new BigNumber(0),
+ takerFee: new BigNumber(0),
+ });
+ const ordersWithoutFee = [orderWithoutFee];
+ const feeOrders: SignedOrder[] = [];
+ const desiredMakerAssetFillAmount = new BigNumber('5');
+ const makerAssetFillAmount = new BigNumber('6');
+ const ethValue = new BigNumber('4');
+ // Execute test case
+ tx = await forwarderWrapper.marketBuyOrdersWithEthAsync(
+ ordersWithoutFee,
+ feeOrders,
+ desiredMakerAssetFillAmount,
+ {
+ value: ethValue,
+ from: takerAddress,
+ },
+ );
+ // Fetch end balances and construct expected outputs
+ const takerEthBalanceAfter = await web3Wrapper.getBalanceInWeiAsync(takerAddress);
+ const forwarderEthBalance = await web3Wrapper.getBalanceInWeiAsync(forwarderContract.address);
+ const newBalances = await erc20Wrapper.getBalancesAsync();
+ const primaryTakerAssetFillAmount = ethValue;
+ const totalEthSpent = primaryTakerAssetFillAmount.plus(gasPrice.times(tx.gasUsed));
+ // Validate test case
+ expect(makerAssetFillAmount).to.be.bignumber.greaterThan(desiredMakerAssetFillAmount);
+ expect(takerEthBalanceAfter).to.be.bignumber.equal(takerEthBalanceBefore.minus(totalEthSpent));
+ expect(newBalances[makerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][defaultMakerAssetAddress].minus(makerAssetFillAmount),
+ );
+ expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][defaultMakerAssetAddress].plus(makerAssetFillAmount),
+ );
+ expect(newBalances[makerAddress][weth.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][weth.address].plus(primaryTakerAssetFillAmount),
+ );
+ expect(newBalances[forwarderContract.address][weth.address]).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ expect(newBalances[forwarderContract.address][defaultMakerAssetAddress]).to.be.bignumber.equal(
+ constants.ZERO_AMOUNT,
+ );
+ expect(forwarderEthBalance).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ });
+ it('Should buy slightly greater MakerAsset when exchange rate is rounded, and MakerAsset is ZRX', async () => {
+ // See the test case above for a detailed description of this case.
+ // The difference here is that the MakerAsset is ZRX. We expect the same result as above,
+ // but this tests a different code path.
+ //
+ // Construct test case using values from example above
+ orderWithoutFee = await orderFactory.newSignedOrderAsync({
+ makerAssetAmount: new BigNumber('30'),
+ takerAssetAmount: new BigNumber('20'),
+ makerAssetData: zrxAssetData,
+ takerAssetData: assetDataUtils.encodeERC20AssetData(weth.address),
+ makerFee: new BigNumber(0),
+ takerFee: new BigNumber(0),
+ });
+ const ordersWithoutFee = [orderWithoutFee];
+ const feeOrders: SignedOrder[] = [];
+ const desiredMakerAssetFillAmount = new BigNumber('5');
+ const makerAssetFillAmount = new BigNumber('6');
+ const ethValue = new BigNumber('4');
+ // Execute test case
+ tx = await forwarderWrapper.marketBuyOrdersWithEthAsync(
+ ordersWithoutFee,
+ feeOrders,
+ desiredMakerAssetFillAmount,
+ {
+ value: ethValue,
+ from: takerAddress,
+ },
+ );
+ // Fetch end balances and construct expected outputs
+ const takerEthBalanceAfter = await web3Wrapper.getBalanceInWeiAsync(takerAddress);
+ const forwarderEthBalance = await web3Wrapper.getBalanceInWeiAsync(forwarderContract.address);
+ const newBalances = await erc20Wrapper.getBalancesAsync();
+ const primaryTakerAssetFillAmount = ethValue;
+ const totalEthSpent = primaryTakerAssetFillAmount.plus(gasPrice.times(tx.gasUsed));
+ // Validate test case
+ expect(makerAssetFillAmount).to.be.bignumber.greaterThan(desiredMakerAssetFillAmount);
+ expect(takerEthBalanceAfter).to.be.bignumber.equal(takerEthBalanceBefore.minus(totalEthSpent));
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerAssetFillAmount),
+ );
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].plus(makerAssetFillAmount),
+ );
+ expect(newBalances[makerAddress][weth.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][weth.address].plus(primaryTakerAssetFillAmount),
+ );
+ expect(newBalances[forwarderContract.address][weth.address]).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ expect(forwarderEthBalance).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ });
+ it('Should buy slightly greater MakerAsset when exchange rate is rounded (Regression Test)', async () => {
+ // Order taken from a transaction on mainnet that failed due to a rounding error.
+ orderWithoutFee = await orderFactory.newSignedOrderAsync({
+ makerAssetAmount: new BigNumber('268166666666666666666'),
+ takerAssetAmount: new BigNumber('219090625878836371'),
+ makerAssetData: assetDataUtils.encodeERC20AssetData(erc20TokenA.address),
+ takerAssetData: assetDataUtils.encodeERC20AssetData(weth.address),
+ makerFee: new BigNumber(0),
+ takerFee: new BigNumber(0),
+ });
+ const ordersWithoutFee = [orderWithoutFee];
+ const feeOrders: SignedOrder[] = [];
+ // The taker will receive more than the desired amount of makerAsset due to rounding
+ const desiredMakerAssetFillAmount = new BigNumber('5000000000000000000');
+ const ethValue = new BigNumber('4084971271824171');
+ const makerAssetFillAmount = ethValue
+ .times(orderWithoutFee.makerAssetAmount)
+ .dividedToIntegerBy(orderWithoutFee.takerAssetAmount);
+ // Execute test case
+ tx = await forwarderWrapper.marketBuyOrdersWithEthAsync(
+ ordersWithoutFee,
+ feeOrders,
+ desiredMakerAssetFillAmount,
+ {
+ value: ethValue,
+ from: takerAddress,
+ },
+ );
+ // Fetch end balances and construct expected outputs
+ const takerEthBalanceAfter = await web3Wrapper.getBalanceInWeiAsync(takerAddress);
+ const forwarderEthBalance = await web3Wrapper.getBalanceInWeiAsync(forwarderContract.address);
+ const newBalances = await erc20Wrapper.getBalancesAsync();
+ const primaryTakerAssetFillAmount = ethValue;
+ const totalEthSpent = primaryTakerAssetFillAmount.plus(gasPrice.times(tx.gasUsed));
+ // Validate test case
+ expect(makerAssetFillAmount).to.be.bignumber.greaterThan(desiredMakerAssetFillAmount);
+ expect(takerEthBalanceAfter).to.be.bignumber.equal(takerEthBalanceBefore.minus(totalEthSpent));
+ expect(newBalances[makerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][defaultMakerAssetAddress].minus(makerAssetFillAmount),
+ );
+ expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][defaultMakerAssetAddress].plus(makerAssetFillAmount),
+ );
+ expect(newBalances[makerAddress][weth.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][weth.address].plus(primaryTakerAssetFillAmount),
+ );
+ expect(newBalances[forwarderContract.address][weth.address]).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ expect(newBalances[forwarderContract.address][defaultMakerAssetAddress]).to.be.bignumber.equal(
+ constants.ZERO_AMOUNT,
+ );
+ expect(forwarderEthBalance).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ });
+ it('Should buy slightly greater MakerAsset when exchange rate is rounded, and MakerAsset is ZRX (Regression Test)', async () => {
+ // Order taken from a transaction on mainnet that failed due to a rounding error.
+ orderWithoutFee = await orderFactory.newSignedOrderAsync({
+ makerAssetAmount: new BigNumber('268166666666666666666'),
+ takerAssetAmount: new BigNumber('219090625878836371'),
+ makerAssetData: zrxAssetData,
+ takerAssetData: assetDataUtils.encodeERC20AssetData(weth.address),
+ makerFee: new BigNumber(0),
+ takerFee: new BigNumber(0),
+ });
+ const ordersWithoutFee = [orderWithoutFee];
+ const feeOrders: SignedOrder[] = [];
+ // The taker will receive more than the desired amount of makerAsset due to rounding
+ const desiredMakerAssetFillAmount = new BigNumber('5000000000000000000');
+ const ethValue = new BigNumber('4084971271824171');
+ const makerAssetFillAmount = ethValue
+ .times(orderWithoutFee.makerAssetAmount)
+ .dividedToIntegerBy(orderWithoutFee.takerAssetAmount);
+ // Execute test case
+ tx = await forwarderWrapper.marketBuyOrdersWithEthAsync(
+ ordersWithoutFee,
+ feeOrders,
+ desiredMakerAssetFillAmount,
+ {
+ value: ethValue,
+ from: takerAddress,
+ },
+ );
+ // Fetch end balances and construct expected outputs
+ const takerEthBalanceAfter = await web3Wrapper.getBalanceInWeiAsync(takerAddress);
+ const forwarderEthBalance = await web3Wrapper.getBalanceInWeiAsync(forwarderContract.address);
+ const newBalances = await erc20Wrapper.getBalancesAsync();
+ const primaryTakerAssetFillAmount = ethValue;
+ const totalEthSpent = primaryTakerAssetFillAmount.plus(gasPrice.times(tx.gasUsed));
+ // Validate test case
+ expect(makerAssetFillAmount).to.be.bignumber.greaterThan(desiredMakerAssetFillAmount);
+ expect(takerEthBalanceAfter).to.be.bignumber.equal(takerEthBalanceBefore.minus(totalEthSpent));
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerAssetFillAmount),
+ );
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].plus(makerAssetFillAmount),
+ );
+ expect(newBalances[makerAddress][weth.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][weth.address].plus(primaryTakerAssetFillAmount),
+ );
+ expect(newBalances[forwarderContract.address][weth.address]).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ expect(forwarderEthBalance).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ });
+ it('Should buy correct MakerAsset when exchange rate is NOT rounded, and MakerAsset is ZRX (Regression Test)', async () => {
+ // An extra unit of TakerAsset was sent to the exchange contract to account for rounding errors, in Forwarder v1.
+ // Specifically, the takerFillAmount was calculated using Floor(desiredMakerAmount * exchangeRate) + 1
+ // We have since changed this to be Ceil(desiredMakerAmount * exchangeRate)
+ // These calculations produce different results when `desiredMakerAmount * exchangeRate` is an integer.
+ //
+ // This test verifies that `ceil` is sufficient:
+ // Let TakerAssetAmount = MakerAssetAmount * 2
+ // -> exchangeRate = TakerAssetAmount / MakerAssetAmount = (2*MakerAssetAmount)/MakerAssetAmount = 2
+ // .: desiredMakerAmount * exchangeRate is an integer.
+ //
+ // Construct test case using values from example above
+ orderWithoutFee = await orderFactory.newSignedOrderAsync({
+ makerAssetAmount: new BigNumber('30'),
+ takerAssetAmount: new BigNumber('60'),
+ makerAssetData: zrxAssetData,
+ takerAssetData: assetDataUtils.encodeERC20AssetData(weth.address),
+ makerFee: new BigNumber(0),
+ takerFee: new BigNumber(0),
+ });
+ const ordersWithoutFee = [orderWithoutFee];
+ const feeOrders: SignedOrder[] = [];
+ const makerAssetFillAmount = new BigNumber('5');
+ const ethValue = new BigNumber('10');
+ // Execute test case
+ tx = await forwarderWrapper.marketBuyOrdersWithEthAsync(ordersWithoutFee, feeOrders, makerAssetFillAmount, {
+ value: ethValue,
+ from: takerAddress,
+ });
+ // Fetch end balances and construct expected outputs
+ const takerEthBalanceAfter = await web3Wrapper.getBalanceInWeiAsync(takerAddress);
+ const forwarderEthBalance = await web3Wrapper.getBalanceInWeiAsync(forwarderContract.address);
+ const newBalances = await erc20Wrapper.getBalancesAsync();
+ const primaryTakerAssetFillAmount = ethValue;
+ const totalEthSpent = primaryTakerAssetFillAmount.plus(gasPrice.times(tx.gasUsed));
+ // Validate test case
+ expect(takerEthBalanceAfter).to.be.bignumber.equal(takerEthBalanceBefore.minus(totalEthSpent));
+ expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][zrxToken.address].minus(makerAssetFillAmount),
+ );
+ expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
+ erc20Balances[takerAddress][zrxToken.address].plus(makerAssetFillAmount),
+ );
+ expect(newBalances[makerAddress][weth.address]).to.be.bignumber.equal(
+ erc20Balances[makerAddress][weth.address].plus(primaryTakerAssetFillAmount),
+ );
+ expect(newBalances[forwarderContract.address][weth.address]).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ expect(forwarderEthBalance).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ });
});
describe('marketBuyOrdersWithEth with extra fees', () => {
it('should buy an asset and send fee to feeRecipient', async () => {
diff --git a/packages/contracts/test/extensions/order_validator.ts b/packages/contracts/test/extensions/order_validator.ts
index 3a57cfc37..37bd1b0e2 100644
--- a/packages/contracts/test/extensions/order_validator.ts
+++ b/packages/contracts/test/extensions/order_validator.ts
@@ -1,17 +1,17 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
-import { SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
+import { SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_erc20_token';
-import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_erc721_token';
-import { ERC20ProxyContract } from '../../generated_contract_wrappers/erc20_proxy';
-import { ERC721ProxyContract } from '../../generated_contract_wrappers/erc721_proxy';
-import { ExchangeContract } from '../../generated_contract_wrappers/exchange';
-import { OrderValidatorContract } from '../../generated_contract_wrappers/order_validator';
-import { artifacts } from '../utils/artifacts';
+import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
+import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
+import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
+import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
+import { ExchangeContract } from '../../generated-wrappers/exchange';
+import { OrderValidatorContract } from '../../generated-wrappers/order_validator';
+import { artifacts } from '../../src/artifacts';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
import { ERC20Wrapper } from '../utils/erc20_wrapper';
diff --git a/packages/contracts/test/global_hooks.ts b/packages/contracts/test/global_hooks.ts
index cf7c52efd..2e9ac9e21 100644
--- a/packages/contracts/test/global_hooks.ts
+++ b/packages/contracts/test/global_hooks.ts
@@ -1,4 +1,4 @@
-import { env, EnvVars } from '@0xproject/dev-utils';
+import { env, EnvVars } from '@0x/dev-utils';
import { coverage } from './utils/coverage';
import { profiler } from './utils/profiler';
diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts
index 13640a761..b1a389f00 100644
--- a/packages/contracts/test/libraries/lib_bytes.ts
+++ b/packages/contracts/test/libraries/lib_bytes.ts
@@ -1,14 +1,14 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { generatePseudoRandomSalt } from '@0xproject/order-utils';
-import { RevertReason } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { generatePseudoRandomSalt } from '@0x/order-utils';
+import { RevertReason } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import BN = require('bn.js');
import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
-import { TestLibBytesContract } from '../../generated_contract_wrappers/test_lib_bytes';
-import { artifacts } from '../utils/artifacts';
+import { TestLibBytesContract } from '../../generated-wrappers/test_lib_bytes';
+import { artifacts } from '../../src/artifacts';
import { expectContractCallFailedAsync } from '../utils/assertions';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
diff --git a/packages/contracts/test/multisig/asset_proxy_owner.ts b/packages/contracts/test/multisig/asset_proxy_owner.ts
index 299707512..087152316 100644
--- a/packages/contracts/test/multisig/asset_proxy_owner.ts
+++ b/packages/contracts/test/multisig/asset_proxy_owner.ts
@@ -1,6 +1,6 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { RevertReason } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { RevertReason } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
@@ -10,10 +10,10 @@ import {
AssetProxyOwnerExecutionEventArgs,
AssetProxyOwnerExecutionFailureEventArgs,
AssetProxyOwnerSubmissionEventArgs,
-} from '../../generated_contract_wrappers/asset_proxy_owner';
-import { MixinAuthorizableContract } from '../../generated_contract_wrappers/mixin_authorizable';
-import { TestAssetProxyOwnerContract } from '../../generated_contract_wrappers/test_asset_proxy_owner';
-import { artifacts } from '../utils/artifacts';
+} from '../../generated-wrappers/asset_proxy_owner';
+import { MixinAuthorizableContract } from '../../generated-wrappers/mixin_authorizable';
+import { TestAssetProxyOwnerContract } from '../../generated-wrappers/test_asset_proxy_owner';
+import { artifacts } from '../../src/artifacts';
import {
expectContractCallFailedAsync,
expectContractCreationFailedAsync,
diff --git a/packages/contracts/test/multisig/multi_sig_with_time_lock.ts b/packages/contracts/test/multisig/multi_sig_with_time_lock.ts
index 0b17c298b..1c0cb0515 100644
--- a/packages/contracts/test/multisig/multi_sig_with_time_lock.ts
+++ b/packages/contracts/test/multisig/multi_sig_with_time_lock.ts
@@ -1,11 +1,11 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { RevertReason } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { RevertReason } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_erc20_token';
+import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
import {
MultiSigWalletWithTimeLockConfirmationEventArgs,
MultiSigWalletWithTimeLockConfirmationTimeSetEventArgs,
@@ -13,8 +13,8 @@ import {
MultiSigWalletWithTimeLockExecutionEventArgs,
MultiSigWalletWithTimeLockExecutionFailureEventArgs,
MultiSigWalletWithTimeLockSubmissionEventArgs,
-} from '../../generated_contract_wrappers/multi_sig_wallet_with_time_lock';
-import { artifacts } from '../utils/artifacts';
+} from '../../generated-wrappers/multi_sig_wallet_with_time_lock';
+import { artifacts } from '../../src/artifacts';
import { expectTransactionFailedAsync, expectTransactionFailedWithoutReasonAsync } from '../utils/assertions';
import { increaseTimeAndMineBlockAsync } from '../utils/block_timestamp';
import { chaiSetup } from '../utils/chai_setup';
diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts
deleted file mode 100644
index 7cc43be9b..000000000
--- a/packages/contracts/test/token_registry.ts
+++ /dev/null
@@ -1,255 +0,0 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { BigNumber, NULL_BYTES } from '@0xproject/utils';
-import * as chai from 'chai';
-import ethUtil = require('ethereumjs-util');
-import * as _ from 'lodash';
-
-import { TokenRegistryContract } from '../generated_contract_wrappers/token_registry';
-
-import { artifacts } from './utils/artifacts';
-import { expectTransactionFailedWithoutReasonAsync } from './utils/assertions';
-import { chaiSetup } from './utils/chai_setup';
-import { constants } from './utils/constants';
-import { TokenRegWrapper } from './utils/token_registry_wrapper';
-import { provider, txDefaults, web3Wrapper } from './utils/web3_wrapper';
-
-chaiSetup.configure();
-const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
-
-describe('TokenRegistry', () => {
- let owner: string;
- let notOwner: string;
- let tokenReg: TokenRegistryContract;
- let tokenRegWrapper: TokenRegWrapper;
-
- before(async () => {
- await blockchainLifecycle.startAsync();
- });
- after(async () => {
- await blockchainLifecycle.revertAsync();
- });
- before(async () => {
- const accounts = await web3Wrapper.getAvailableAddressesAsync();
- owner = accounts[0];
- notOwner = accounts[1];
- tokenReg = await TokenRegistryContract.deployFrom0xArtifactAsync(artifacts.TokenRegistry, provider, txDefaults);
- tokenRegWrapper = new TokenRegWrapper(tokenReg, provider);
- });
- beforeEach(async () => {
- await blockchainLifecycle.startAsync();
- });
- afterEach(async () => {
- await blockchainLifecycle.revertAsync();
- });
-
- const tokenAddress1 = `0x${ethUtil.setLength(ethUtil.toBuffer('0x1'), 20, false).toString('hex')}`;
- const tokenAddress2 = `0x${ethUtil.setLength(ethUtil.toBuffer('0x2'), 20, false).toString('hex')}`;
-
- const token1 = {
- address: tokenAddress1,
- name: 'testToken1',
- symbol: 'TT1',
- decimals: 18,
- ipfsHash: `0x${ethUtil.sha3('ipfs1').toString('hex')}`,
- swarmHash: `0x${ethUtil.sha3('swarm1').toString('hex')}`,
- };
-
- const token2 = {
- address: tokenAddress2,
- name: 'testToken2',
- symbol: 'TT2',
- decimals: 18,
- ipfsHash: `0x${ethUtil.sha3('ipfs2').toString('hex')}`,
- swarmHash: `0x${ethUtil.sha3('swarm2').toString('hex')}`,
- };
-
- const nullToken = {
- address: constants.NULL_ADDRESS,
- name: '',
- symbol: '',
- decimals: 0,
- ipfsHash: NULL_BYTES,
- swarmHash: NULL_BYTES,
- };
-
- describe('addToken', () => {
- it('should throw when not called by owner', async () => {
- return expectTransactionFailedWithoutReasonAsync(tokenRegWrapper.addTokenAsync(token1, notOwner));
- });
-
- it('should add token metadata when called by owner', async () => {
- await tokenRegWrapper.addTokenAsync(token1, owner);
- const tokenData = await tokenRegWrapper.getTokenMetaDataAsync(token1.address);
- expect(tokenData).to.be.deep.equal(token1);
- });
-
- it('should throw if token already exists', async () => {
- await tokenRegWrapper.addTokenAsync(token1, owner);
-
- return expectTransactionFailedWithoutReasonAsync(tokenRegWrapper.addTokenAsync(token1, owner));
- });
-
- it('should throw if token address is null', async () => {
- return expectTransactionFailedWithoutReasonAsync(tokenRegWrapper.addTokenAsync(nullToken, owner));
- });
-
- it('should throw if name already exists', async () => {
- await tokenRegWrapper.addTokenAsync(token1, owner);
- const duplicateNameToken = _.assign({}, token2, { name: token1.name });
-
- return expectTransactionFailedWithoutReasonAsync(tokenRegWrapper.addTokenAsync(duplicateNameToken, owner));
- });
-
- it('should throw if symbol already exists', async () => {
- await tokenRegWrapper.addTokenAsync(token1, owner);
- const duplicateSymbolToken = _.assign({}, token2, {
- symbol: token1.symbol,
- });
-
- return expectTransactionFailedWithoutReasonAsync(
- tokenRegWrapper.addTokenAsync(duplicateSymbolToken, owner),
- );
- });
- });
-
- describe('after addToken', () => {
- beforeEach(async () => {
- await tokenRegWrapper.addTokenAsync(token1, owner);
- });
-
- describe('getTokenByName', () => {
- it('should return token metadata when given the token name', async () => {
- const tokenData = await tokenRegWrapper.getTokenByNameAsync(token1.name);
- expect(tokenData).to.be.deep.equal(token1);
- });
- });
-
- describe('getTokenBySymbol', () => {
- it('should return token metadata when given the token symbol', async () => {
- const tokenData = await tokenRegWrapper.getTokenBySymbolAsync(token1.symbol);
- expect(tokenData).to.be.deep.equal(token1);
- });
- });
-
- describe('setTokenName', () => {
- it('should throw when not called by owner', async () => {
- return expectTransactionFailedWithoutReasonAsync(
- tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: notOwner }),
- );
- });
-
- it('should change the token name when called by owner', async () => {
- await web3Wrapper.awaitTransactionSuccessAsync(
- await tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, {
- from: owner,
- }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- const [newData, oldData] = await Promise.all([
- tokenRegWrapper.getTokenByNameAsync(token2.name),
- tokenRegWrapper.getTokenByNameAsync(token1.name),
- ]);
-
- const expectedNewData = _.assign({}, token1, { name: token2.name });
- const expectedOldData = nullToken;
- expect(newData).to.be.deep.equal(expectedNewData);
- expect(oldData).to.be.deep.equal(expectedOldData);
- });
-
- it('should throw if the name already exists', async () => {
- await tokenRegWrapper.addTokenAsync(token2, owner);
-
- return expectTransactionFailedWithoutReasonAsync(
- tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: owner }),
- );
- });
-
- it('should throw if token does not exist', async () => {
- return expectTransactionFailedWithoutReasonAsync(
- tokenReg.setTokenName.sendTransactionAsync(nullToken.address, token2.name, { from: owner }),
- );
- });
- });
-
- describe('setTokenSymbol', () => {
- it('should throw when not called by owner', async () => {
- return expectTransactionFailedWithoutReasonAsync(
- tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, {
- from: notOwner,
- }),
- );
- });
-
- it('should change the token symbol when called by owner', async () => {
- await web3Wrapper.awaitTransactionSuccessAsync(
- await tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, { from: owner }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- const [newData, oldData] = await Promise.all([
- tokenRegWrapper.getTokenBySymbolAsync(token2.symbol),
- tokenRegWrapper.getTokenBySymbolAsync(token1.symbol),
- ]);
-
- const expectedNewData = _.assign({}, token1, { symbol: token2.symbol });
- const expectedOldData = nullToken;
- expect(newData).to.be.deep.equal(expectedNewData);
- expect(oldData).to.be.deep.equal(expectedOldData);
- });
-
- it('should throw if the symbol already exists', async () => {
- await tokenRegWrapper.addTokenAsync(token2, owner);
-
- return expectTransactionFailedWithoutReasonAsync(
- tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, {
- from: owner,
- }),
- );
- });
-
- it('should throw if token does not exist', async () => {
- return expectTransactionFailedWithoutReasonAsync(
- tokenReg.setTokenSymbol.sendTransactionAsync(nullToken.address, token2.symbol, {
- from: owner,
- }),
- );
- });
- });
-
- describe('removeToken', () => {
- it('should throw if not called by owner', async () => {
- const index = new BigNumber(0);
- return expectTransactionFailedWithoutReasonAsync(
- tokenReg.removeToken.sendTransactionAsync(token1.address, index, { from: notOwner }),
- );
- });
-
- it('should remove token metadata when called by owner', async () => {
- const index = new BigNumber(0);
- await web3Wrapper.awaitTransactionSuccessAsync(
- await tokenReg.removeToken.sendTransactionAsync(token1.address, index, {
- from: owner,
- }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- const tokenData = await tokenRegWrapper.getTokenMetaDataAsync(token1.address);
- expect(tokenData).to.be.deep.equal(nullToken);
- });
-
- it('should throw if token does not exist', async () => {
- const index = new BigNumber(0);
- return expectTransactionFailedWithoutReasonAsync(
- tokenReg.removeToken.sendTransactionAsync(nullToken.address, index, { from: owner }),
- );
- });
-
- it('should throw if token at given index does not match address', async () => {
- await tokenRegWrapper.addTokenAsync(token2, owner);
- const incorrectIndex = new BigNumber(0);
- return expectTransactionFailedWithoutReasonAsync(
- tokenReg.removeToken.sendTransactionAsync(token2.address, incorrectIndex, { from: owner }),
- );
- });
- });
- });
-});
diff --git a/packages/contracts/test/tokens/erc721_token.ts b/packages/contracts/test/tokens/erc721_token.ts
index e61fd7d51..72407748f 100644
--- a/packages/contracts/test/tokens/erc721_token.ts
+++ b/packages/contracts/test/tokens/erc721_token.ts
@@ -1,19 +1,19 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { RevertReason } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { RevertReason } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import {
DummyERC721ReceiverContract,
DummyERC721ReceiverTokenReceivedEventArgs,
-} from '../../generated_contract_wrappers/dummy_erc721_receiver';
+} from '../../generated-wrappers/dummy_erc721_receiver';
import {
DummyERC721TokenContract,
DummyERC721TokenTransferEventArgs,
-} from '../../generated_contract_wrappers/dummy_erc721_token';
-import { InvalidERC721ReceiverContract } from '../../generated_contract_wrappers/invalid_erc721_receiver';
-import { artifacts } from '../utils/artifacts';
+} from '../../generated-wrappers/dummy_erc721_token';
+import { InvalidERC721ReceiverContract } from '../../generated-wrappers/invalid_erc721_receiver';
+import { artifacts } from '../../src/artifacts';
import { expectTransactionFailedAsync, expectTransactionFailedWithoutReasonAsync } from '../utils/assertions';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
diff --git a/packages/contracts/test/tokens/unlimited_allowance_token.ts b/packages/contracts/test/tokens/unlimited_allowance_token.ts
index 63680fe9b..ea5a50522 100644
--- a/packages/contracts/test/tokens/unlimited_allowance_token.ts
+++ b/packages/contracts/test/tokens/unlimited_allowance_token.ts
@@ -1,10 +1,10 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { RevertReason } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { RevertReason } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
-import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_erc20_token';
-import { artifacts } from '../utils/artifacts';
+import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
+import { artifacts } from '../../src/artifacts';
import { expectContractCallFailedAsync } from '../utils/assertions';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
diff --git a/packages/contracts/test/tokens/ether_token.ts b/packages/contracts/test/tokens/weth9.ts
index a104fc915..9a31dc3f2 100644
--- a/packages/contracts/test/tokens/ether_token.ts
+++ b/packages/contracts/test/tokens/weth9.ts
@@ -1,10 +1,10 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
-import { WETH9Contract } from '../../generated_contract_wrappers/weth9';
-import { artifacts } from '../utils/artifacts';
+import { WETH9Contract } from '../../generated-wrappers/weth9';
+import { artifacts } from '../../src/artifacts';
import { expectInsufficientFundsAsync, expectTransactionFailedWithoutReasonAsync } from '../utils/assertions';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
@@ -29,7 +29,7 @@ describe('EtherToken', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
account = accounts[0];
- etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.EtherToken, provider, {
+ etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, {
gasPrice,
...txDefaults,
});
diff --git a/packages/contracts/test/tokens/zrx_token.ts b/packages/contracts/test/tokens/zrx_token.ts
index a0d77c924..cab62c205 100644
--- a/packages/contracts/test/tokens/zrx_token.ts
+++ b/packages/contracts/test/tokens/zrx_token.ts
@@ -1,10 +1,10 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BlockchainLifecycle } from '@0x/dev-utils';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
-import { ZRXTokenContract } from '../../generated_contract_wrappers/zrx_token';
-import { artifacts } from '../utils/artifacts';
+import { ZRXTokenContract } from '../../generated-wrappers/zrx_token';
+import { artifacts } from '../../src/artifacts';
import { chaiSetup } from '../utils/chai_setup';
import { constants } from '../utils/constants';
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
@@ -29,7 +29,7 @@ describe('ZRXToken', () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
spender = accounts[1];
- zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync(artifacts.ZRX, provider, txDefaults);
+ zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync(artifacts.ZRXToken, provider, txDefaults);
MAX_UINT = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
});
beforeEach(async () => {
diff --git a/packages/contracts/test/tutorials/arbitrage.ts b/packages/contracts/test/tutorials/arbitrage.ts
index 6851483cc..78e0bc238 100644
--- a/packages/contracts/test/tutorials/arbitrage.ts
+++ b/packages/contracts/test/tutorials/arbitrage.ts
@@ -1,8 +1,8 @@
// import { ECSignature, SignedOrder, ZeroEx } from '0x.js';
-// import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
+// import { BlockchainLifecycle, devConstants, web3Factory } from '@0x/dev-utils';
// import { ExchangeContractErrs } from 'ethereum-types';
-// import { BigNumber } from '@0xproject/utils';
-// import { Web3Wrapper } from '@0xproject/web3-wrapper';
+// import { BigNumber } from '@0x/utils';
+// import { Web3Wrapper } from '@0x/web3-wrapper';
// import * as chai from 'chai';
// import ethUtil = require('ethereumjs-util');
// import * as Web3 from 'web3';
diff --git a/packages/contracts/test/utils/address_utils.ts b/packages/contracts/test/utils/address_utils.ts
index 3cf8ec786..634da0c16 100644
--- a/packages/contracts/test/utils/address_utils.ts
+++ b/packages/contracts/test/utils/address_utils.ts
@@ -1,5 +1,5 @@
-import { generatePseudoRandomSalt } from '@0xproject/order-utils';
-import { crypto } from '@0xproject/order-utils/lib/src/crypto';
+import { generatePseudoRandomSalt } from '@0x/order-utils';
+import { crypto } from '@0x/order-utils/lib/src/crypto';
export const addressUtils = {
generatePseudoRandomAddress(): string {
diff --git a/packages/contracts/test/utils/artifacts.ts b/packages/contracts/test/utils/artifacts.ts
deleted file mode 100644
index 53f2a4e4e..000000000
--- a/packages/contracts/test/utils/artifacts.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-import { ContractArtifact } from 'ethereum-types';
-
-import * as AssetProxyOwner from '../../artifacts/AssetProxyOwner.json';
-import * as DummyERC20Token from '../../artifacts/DummyERC20Token.json';
-import * as DummyERC721Receiver from '../../artifacts/DummyERC721Receiver.json';
-import * as DummyERC721Token from '../../artifacts/DummyERC721Token.json';
-import * as DummyMultipleReturnERC20Token from '../../artifacts/DummyMultipleReturnERC20Token.json';
-import * as DummyNoReturnERC20Token from '../../artifacts/DummyNoReturnERC20Token.json';
-import * as ERC20Proxy from '../../artifacts/ERC20Proxy.json';
-import * as ERC721Proxy from '../../artifacts/ERC721Proxy.json';
-import * as Exchange from '../../artifacts/Exchange.json';
-import * as ExchangeWrapper from '../../artifacts/ExchangeWrapper.json';
-import * as Forwarder from '../../artifacts/Forwarder.json';
-import * as IAssetProxy from '../../artifacts/IAssetProxy.json';
-import * as InvalidERC721Receiver from '../../artifacts/InvalidERC721Receiver.json';
-import * as MixinAuthorizable from '../../artifacts/MixinAuthorizable.json';
-import * as MultiSigWallet from '../../artifacts/MultiSigWallet.json';
-import * as MultiSigWalletWithTimeLock from '../../artifacts/MultiSigWalletWithTimeLock.json';
-import * as OrderValidator from '../../artifacts/OrderValidator.json';
-import * as ReentrantERC20Token from '../../artifacts/ReentrantERC20Token.json';
-import * as TestAssetProxyDispatcher from '../../artifacts/TestAssetProxyDispatcher.json';
-import * as TestAssetProxyOwner from '../../artifacts/TestAssetProxyOwner.json';
-import * as TestConstants from '../../artifacts/TestConstants.json';
-import * as TestExchangeInternals from '../../artifacts/TestExchangeInternals.json';
-import * as TestLibBytes from '../../artifacts/TestLibBytes.json';
-import * as TestLibs from '../../artifacts/TestLibs.json';
-import * as TestSignatureValidator from '../../artifacts/TestSignatureValidator.json';
-import * as TestStaticCallReceiver from '../../artifacts/TestStaticCallReceiver.json';
-import * as TokenRegistry from '../../artifacts/TokenRegistry.json';
-import * as Validator from '../../artifacts/Validator.json';
-import * as Wallet from '../../artifacts/Wallet.json';
-import * as EtherToken from '../../artifacts/WETH9.json';
-import * as Whitelist from '../../artifacts/Whitelist.json';
-import * as ZRX from '../../artifacts/ZRXToken.json';
-
-export const artifacts = {
- AssetProxyOwner: (AssetProxyOwner as any) as ContractArtifact,
- DummyERC20Token: (DummyERC20Token as any) as ContractArtifact,
- DummyERC721Receiver: (DummyERC721Receiver as any) as ContractArtifact,
- DummyERC721Token: (DummyERC721Token as any) as ContractArtifact,
- DummyMultipleReturnERC20Token: (DummyMultipleReturnERC20Token as any) as ContractArtifact,
- DummyNoReturnERC20Token: (DummyNoReturnERC20Token as any) as ContractArtifact,
- ERC20Proxy: (ERC20Proxy as any) as ContractArtifact,
- ERC721Proxy: (ERC721Proxy as any) as ContractArtifact,
- Exchange: (Exchange as any) as ContractArtifact,
- ExchangeWrapper: (ExchangeWrapper as any) as ContractArtifact,
- EtherToken: (EtherToken as any) as ContractArtifact,
- Forwarder: (Forwarder as any) as ContractArtifact,
- IAssetProxy: (IAssetProxy as any) as ContractArtifact,
- InvalidERC721Receiver: (InvalidERC721Receiver as any) as ContractArtifact,
- MixinAuthorizable: (MixinAuthorizable as any) as ContractArtifact,
- MultiSigWallet: (MultiSigWallet as any) as ContractArtifact,
- MultiSigWalletWithTimeLock: (MultiSigWalletWithTimeLock as any) as ContractArtifact,
- OrderValidator: (OrderValidator as any) as ContractArtifact,
- ReentrantERC20Token: (ReentrantERC20Token as any) as ContractArtifact,
- TestAssetProxyOwner: (TestAssetProxyOwner as any) as ContractArtifact,
- TestAssetProxyDispatcher: (TestAssetProxyDispatcher as any) as ContractArtifact,
- TestConstants: (TestConstants as any) as ContractArtifact,
- TestLibBytes: (TestLibBytes as any) as ContractArtifact,
- TestLibs: (TestLibs as any) as ContractArtifact,
- TestExchangeInternals: (TestExchangeInternals as any) as ContractArtifact,
- TestSignatureValidator: (TestSignatureValidator as any) as ContractArtifact,
- TestStaticCallReceiver: (TestStaticCallReceiver as any) as ContractArtifact,
- Validator: (Validator as any) as ContractArtifact,
- Wallet: (Wallet as any) as ContractArtifact,
- TokenRegistry: (TokenRegistry as any) as ContractArtifact,
- Whitelist: (Whitelist as any) as ContractArtifact,
- ZRX: (ZRX as any) as ContractArtifact,
-};
diff --git a/packages/contracts/test/utils/assertions.ts b/packages/contracts/test/utils/assertions.ts
index 3361a751a..5b1cedfcc 100644
--- a/packages/contracts/test/utils/assertions.ts
+++ b/packages/contracts/test/utils/assertions.ts
@@ -1,6 +1,6 @@
-import { RevertReason } from '@0xproject/types';
-import { logUtils } from '@0xproject/utils';
-import { NodeType } from '@0xproject/web3-wrapper';
+import { RevertReason } from '@0x/types';
+import { logUtils } from '@0x/utils';
+import { NodeType } from '@0x/web3-wrapper';
import * as chai from 'chai';
import { TransactionReceipt, TransactionReceiptStatus, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
diff --git a/packages/contracts/test/utils/asset_wrapper.ts b/packages/contracts/test/utils/asset_wrapper.ts
index e3a4800c6..4e7696066 100644
--- a/packages/contracts/test/utils/asset_wrapper.ts
+++ b/packages/contracts/test/utils/asset_wrapper.ts
@@ -1,6 +1,6 @@
-import { assetDataUtils } from '@0xproject/order-utils';
-import { AssetProxyId } from '@0xproject/types';
-import { BigNumber, errorUtils } from '@0xproject/utils';
+import { assetDataUtils } from '@0x/order-utils';
+import { AssetProxyId } from '@0x/types';
+import { BigNumber, errorUtils } from '@0x/utils';
import * as _ from 'lodash';
import { AbstractAssetWrapper } from './abstract_asset_wrapper';
diff --git a/packages/contracts/test/utils/combinatorial_utils.ts b/packages/contracts/test/utils/combinatorial_utils.ts
index d72b41f8a..bb1b55b4d 100644
--- a/packages/contracts/test/utils/combinatorial_utils.ts
+++ b/packages/contracts/test/utils/combinatorial_utils.ts
@@ -1,4 +1,4 @@
-import { BigNumber } from '@0xproject/utils';
+import { BigNumber } from '@0x/utils';
import * as combinatorics from 'js-combinatorics';
import { testWithReferenceFuncAsync } from './test_with_reference';
diff --git a/packages/contracts/test/utils/constants.ts b/packages/contracts/test/utils/constants.ts
index b9ba8ccb9..cd21330e9 100644
--- a/packages/contracts/test/utils/constants.ts
+++ b/packages/contracts/test/utils/constants.ts
@@ -1,5 +1,5 @@
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash';
diff --git a/packages/contracts/test/utils/coverage.ts b/packages/contracts/test/utils/coverage.ts
index de29a3ecc..5becfa1b6 100644
--- a/packages/contracts/test/utils/coverage.ts
+++ b/packages/contracts/test/utils/coverage.ts
@@ -1,5 +1,5 @@
-import { devConstants } from '@0xproject/dev-utils';
-import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0xproject/sol-cov';
+import { devConstants } from '@0x/dev-utils';
+import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov';
import * as _ from 'lodash';
let coverageSubprovider: CoverageSubprovider;
diff --git a/packages/contracts/test/utils/erc20_wrapper.ts b/packages/contracts/test/utils/erc20_wrapper.ts
index 526ffe9f8..c281a2abf 100644
--- a/packages/contracts/test/utils/erc20_wrapper.ts
+++ b/packages/contracts/test/utils/erc20_wrapper.ts
@@ -1,13 +1,13 @@
-import { assetDataUtils } from '@0xproject/order-utils';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { assetDataUtils } from '@0x/order-utils';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_erc20_token';
-import { ERC20ProxyContract } from '../../generated_contract_wrappers/erc20_proxy';
+import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
+import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
+import { artifacts } from '../../src/artifacts';
-import { artifacts } from './artifacts';
import { constants } from './constants';
import { ERC20BalancesByOwner } from './types';
import { txDefaults } from './web3_wrapper';
diff --git a/packages/contracts/test/utils/erc721_wrapper.ts b/packages/contracts/test/utils/erc721_wrapper.ts
index 743d10706..3ef4e701d 100644
--- a/packages/contracts/test/utils/erc721_wrapper.ts
+++ b/packages/contracts/test/utils/erc721_wrapper.ts
@@ -1,13 +1,13 @@
-import { generatePseudoRandomSalt } from '@0xproject/order-utils';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { generatePseudoRandomSalt } from '@0x/order-utils';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
-import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_erc721_token';
-import { ERC721ProxyContract } from '../../generated_contract_wrappers/erc721_proxy';
+import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
+import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
+import { artifacts } from '../../src/artifacts';
-import { artifacts } from './artifacts';
import { constants } from './constants';
import { ERC721TokenIdsByOwner } from './types';
import { txDefaults } from './web3_wrapper';
diff --git a/packages/contracts/test/utils/exchange_wrapper.ts b/packages/contracts/test/utils/exchange_wrapper.ts
index 619d43994..c28989d3f 100644
--- a/packages/contracts/test/utils/exchange_wrapper.ts
+++ b/packages/contracts/test/utils/exchange_wrapper.ts
@@ -1,9 +1,9 @@
-import { SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
-import { ExchangeContract } from '../../generated_contract_wrappers/exchange';
+import { ExchangeContract } from '../../generated-wrappers/exchange';
import { formatters } from './formatters';
import { LogDecoder } from './log_decoder';
@@ -212,13 +212,17 @@ export class ExchangeWrapper {
return tx;
}
public async getTakerAssetFilledAmountAsync(orderHashHex: string): Promise<BigNumber> {
- const filledAmount = new BigNumber(await this._exchange.filled.callAsync(orderHashHex));
+ const filledAmount = await this._exchange.filled.callAsync(orderHashHex);
return filledAmount;
}
public async isCancelledAsync(orderHashHex: string): Promise<boolean> {
const isCancelled = await this._exchange.cancelled.callAsync(orderHashHex);
return isCancelled;
}
+ public async getOrderEpochAsync(makerAddress: string, senderAddress: string): Promise<BigNumber> {
+ const orderEpoch = await this._exchange.orderEpoch.callAsync(makerAddress, senderAddress);
+ return orderEpoch;
+ }
public async getOrderInfoAsync(signedOrder: SignedOrder): Promise<OrderInfo> {
const orderInfo = (await this._exchange.getOrderInfo.callAsync(signedOrder)) as OrderInfo;
return orderInfo;
diff --git a/packages/contracts/test/utils/fill_order_combinatorial_utils.ts b/packages/contracts/test/utils/fill_order_combinatorial_utils.ts
index 92d0f4003..8046771f9 100644
--- a/packages/contracts/test/utils/fill_order_combinatorial_utils.ts
+++ b/packages/contracts/test/utils/fill_order_combinatorial_utils.ts
@@ -5,19 +5,19 @@ import {
orderHashUtils,
OrderStateUtils,
OrderValidationUtils,
-} from '@0xproject/order-utils';
-import { AssetProxyId, RevertReason, SignatureType, SignedOrder } from '@0xproject/types';
-import { BigNumber, errorUtils, logUtils } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+} from '@0x/order-utils';
+import { AssetProxyId, RevertReason, SignatureType, SignedOrder } from '@0x/types';
+import { BigNumber, errorUtils, logUtils } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import { LogWithDecodedArgs, Provider, TxData } from 'ethereum-types';
import * as _ from 'lodash';
import 'make-promises-safe';
-import { ExchangeContract, ExchangeFillEventArgs } from '../../generated_contract_wrappers/exchange';
-import { TestLibsContract } from '../../generated_contract_wrappers/test_libs';
+import { ExchangeContract, ExchangeFillEventArgs } from '../../generated-wrappers/exchange';
+import { TestLibsContract } from '../../generated-wrappers/test_libs';
+import { artifacts } from '../../src/artifacts';
-import { artifacts } from './artifacts';
import { expectTransactionFailedAsync } from './assertions';
import { AssetWrapper } from './asset_wrapper';
import { chaiSetup } from './chai_setup';
@@ -392,7 +392,7 @@ export class FillOrderCombinatorialUtils {
);
// 5. If I fill it by X, what are the resulting balances/allowances/filled amounts expected?
- const orderValidationUtils = new OrderValidationUtils(orderFilledCancelledFetcher);
+ const orderValidationUtils = new OrderValidationUtils(orderFilledCancelledFetcher, provider);
const lazyStore = new BalanceAndProxyAllowanceLazyStore(balanceAndProxyAllowanceFetcher);
const exchangeTransferSimulator = new ExchangeTransferSimulator(lazyStore);
diff --git a/packages/contracts/test/utils/formatters.ts b/packages/contracts/test/utils/formatters.ts
index 32e4787d6..813eb45db 100644
--- a/packages/contracts/test/utils/formatters.ts
+++ b/packages/contracts/test/utils/formatters.ts
@@ -1,5 +1,5 @@
-import { SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import { constants } from './constants';
diff --git a/packages/contracts/test/utils/forwarder_wrapper.ts b/packages/contracts/test/utils/forwarder_wrapper.ts
index de247a878..a0bfcfe1d 100644
--- a/packages/contracts/test/utils/forwarder_wrapper.ts
+++ b/packages/contracts/test/utils/forwarder_wrapper.ts
@@ -1,10 +1,10 @@
-import { SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs, TxDataPayable } from 'ethereum-types';
import * as _ from 'lodash';
-import { ForwarderContract } from '../../generated_contract_wrappers/forwarder';
+import { ForwarderContract } from '../../generated-wrappers/forwarder';
import { constants } from './constants';
import { formatters } from './formatters';
@@ -26,9 +26,12 @@ export class ForwarderWrapper {
_.forEach(feeOrders, feeOrder => {
const feeAvailable = feeOrder.makerAssetAmount.minus(feeOrder.takerFee);
if (!remainingFeeAmount.isZero() && feeAvailable.gt(remainingFeeAmount)) {
- wethAmount = wethAmount
- .plus(feeOrder.takerAssetAmount.times(remainingFeeAmount).dividedToIntegerBy(feeAvailable))
- .plus(1);
+ wethAmount = wethAmount.plus(
+ feeOrder.takerAssetAmount
+ .times(remainingFeeAmount)
+ .dividedBy(feeAvailable)
+ .ceil(),
+ );
remainingFeeAmount = new BigNumber(0);
} else if (!remainingFeeAmount.isZero()) {
wethAmount = wethAmount.plus(feeOrder.takerAssetAmount);
diff --git a/packages/contracts/test/utils/log_decoder.ts b/packages/contracts/test/utils/log_decoder.ts
index 144a18dd1..05b0a9204 100644
--- a/packages/contracts/test/utils/log_decoder.ts
+++ b/packages/contracts/test/utils/log_decoder.ts
@@ -1,5 +1,5 @@
-import { AbiDecoder, BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { AbiDecoder, BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import {
AbiDefinition,
ContractArtifact,
@@ -11,7 +11,8 @@ import {
} from 'ethereum-types';
import * as _ from 'lodash';
-import { artifacts } from './artifacts';
+import { artifacts } from '../../src/artifacts';
+
import { constants } from './constants';
export class LogDecoder {
diff --git a/packages/contracts/test/utils/match_order_tester.ts b/packages/contracts/test/utils/match_order_tester.ts
index e0c55b834..6c2c84959 100644
--- a/packages/contracts/test/utils/match_order_tester.ts
+++ b/packages/contracts/test/utils/match_order_tester.ts
@@ -1,6 +1,6 @@
-import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
-import { AssetProxyId, SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
+import { AssetProxyId, SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
diff --git a/packages/contracts/test/utils/multi_sig_wrapper.ts b/packages/contracts/test/utils/multi_sig_wrapper.ts
index e12a58695..74fd3b4d6 100644
--- a/packages/contracts/test/utils/multi_sig_wrapper.ts
+++ b/packages/contracts/test/utils/multi_sig_wrapper.ts
@@ -1,10 +1,10 @@
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BigNumber } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
-import { AssetProxyOwnerContract } from '../../generated_contract_wrappers/asset_proxy_owner';
-import { MultiSigWalletContract } from '../../generated_contract_wrappers/multi_sig_wallet';
+import { AssetProxyOwnerContract } from '../../generated-wrappers/asset_proxy_owner';
+import { MultiSigWalletContract } from '../../generated-wrappers/multi_sig_wallet';
import { LogDecoder } from './log_decoder';
diff --git a/packages/contracts/test/utils/order_factory.ts b/packages/contracts/test/utils/order_factory.ts
index 63a893695..2449d1a8a 100644
--- a/packages/contracts/test/utils/order_factory.ts
+++ b/packages/contracts/test/utils/order_factory.ts
@@ -1,6 +1,6 @@
-import { generatePseudoRandomSalt, orderHashUtils } from '@0xproject/order-utils';
-import { Order, SignatureType, SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { generatePseudoRandomSalt, orderHashUtils } from '@0x/order-utils';
+import { Order, SignatureType, SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import { getLatestBlockTimestampAsync } from './block_timestamp';
import { constants } from './constants';
diff --git a/packages/contracts/test/utils/order_factory_from_scenario.ts b/packages/contracts/test/utils/order_factory_from_scenario.ts
index 8e04db588..60c8606c4 100644
--- a/packages/contracts/test/utils/order_factory_from_scenario.ts
+++ b/packages/contracts/test/utils/order_factory_from_scenario.ts
@@ -1,8 +1,8 @@
-import { assetDataUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
-import { Order } from '@0xproject/types';
-import { BigNumber, errorUtils } from '@0xproject/utils';
+import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils';
+import { Order } from '@0x/types';
+import { BigNumber, errorUtils } from '@0x/utils';
-import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_erc721_token';
+import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
import { constants } from './constants';
import {
diff --git a/packages/contracts/test/utils/order_utils.ts b/packages/contracts/test/utils/order_utils.ts
index 444e27c44..4f7a34011 100644
--- a/packages/contracts/test/utils/order_utils.ts
+++ b/packages/contracts/test/utils/order_utils.ts
@@ -1,5 +1,5 @@
-import { OrderWithoutExchangeAddress, SignedOrder } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { OrderWithoutExchangeAddress, SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import { constants } from './constants';
import { CancelOrder, MatchOrder } from './types';
diff --git a/packages/contracts/test/utils/profiler.ts b/packages/contracts/test/utils/profiler.ts
index 85ee24f22..2c7c1d66c 100644
--- a/packages/contracts/test/utils/profiler.ts
+++ b/packages/contracts/test/utils/profiler.ts
@@ -1,5 +1,5 @@
-import { devConstants } from '@0xproject/dev-utils';
-import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0xproject/sol-cov';
+import { devConstants } from '@0x/dev-utils';
+import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov';
import * as _ from 'lodash';
let profilerSubprovider: ProfilerSubprovider;
diff --git a/packages/contracts/test/utils/revert_trace.ts b/packages/contracts/test/utils/revert_trace.ts
index 0bf8384bc..3f74fd28b 100644
--- a/packages/contracts/test/utils/revert_trace.ts
+++ b/packages/contracts/test/utils/revert_trace.ts
@@ -1,5 +1,5 @@
-import { devConstants } from '@0xproject/dev-utils';
-import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0xproject/sol-cov';
+import { devConstants } from '@0x/dev-utils';
+import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov';
import * as _ from 'lodash';
let revertTraceSubprovider: RevertTraceSubprovider;
diff --git a/packages/contracts/test/utils/signing_utils.ts b/packages/contracts/test/utils/signing_utils.ts
index 9c711c72c..21f864bfa 100644
--- a/packages/contracts/test/utils/signing_utils.ts
+++ b/packages/contracts/test/utils/signing_utils.ts
@@ -1,4 +1,4 @@
-import { SignatureType } from '@0xproject/types';
+import { SignatureType } from '@0x/types';
import * as ethUtil from 'ethereumjs-util';
export const signingUtils = {
diff --git a/packages/contracts/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts b/packages/contracts/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts
index 598ee6d29..64b7dedbe 100644
--- a/packages/contracts/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts
+++ b/packages/contracts/test/utils/simple_asset_balance_and_proxy_allowance_fetcher.ts
@@ -1,5 +1,5 @@
-import { AbstractBalanceAndProxyAllowanceFetcher } from '@0xproject/order-utils';
-import { BigNumber } from '@0xproject/utils';
+import { AbstractBalanceAndProxyAllowanceFetcher } from '@0x/order-utils';
+import { BigNumber } from '@0x/utils';
import { AssetWrapper } from './asset_wrapper';
diff --git a/packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts b/packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts
index ed69ecc63..af959e00e 100644
--- a/packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts
+++ b/packages/contracts/test/utils/simple_order_filled_cancelled_fetcher.ts
@@ -1,5 +1,6 @@
-import { AbstractOrderFilledCancelledFetcher } from '@0xproject/order-utils';
-import { BigNumber } from '@0xproject/utils';
+import { AbstractOrderFilledCancelledFetcher, orderHashUtils } from '@0x/order-utils';
+import { SignedOrder } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import { ExchangeWrapper } from './exchange_wrapper';
@@ -14,9 +15,15 @@ export class SimpleOrderFilledCancelledFetcher implements AbstractOrderFilledCan
const filledTakerAmount = new BigNumber(await this._exchangeWrapper.getTakerAssetFilledAmountAsync(orderHash));
return filledTakerAmount;
}
- public async isOrderCancelledAsync(orderHash: string): Promise<boolean> {
+ public async isOrderCancelledAsync(signedOrder: SignedOrder): Promise<boolean> {
+ const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const isCancelled = await this._exchangeWrapper.isCancelledAsync(orderHash);
- return isCancelled;
+ const orderEpoch = await this._exchangeWrapper.getOrderEpochAsync(
+ signedOrder.makerAddress,
+ signedOrder.senderAddress,
+ );
+ const isCancelledByOrderEpoch = orderEpoch > signedOrder.salt;
+ return isCancelled || isCancelledByOrderEpoch;
}
public getZRXAssetData(): string {
return this._zrxAssetData;
diff --git a/packages/contracts/test/utils/token_registry_wrapper.ts b/packages/contracts/test/utils/token_registry_wrapper.ts
deleted file mode 100644
index f1c40e8ff..000000000
--- a/packages/contracts/test/utils/token_registry_wrapper.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import { Provider } from 'ethereum-types';
-
-import { TokenRegistryContract } from '../../generated_contract_wrappers/token_registry';
-
-import { Token } from './types';
-
-import { constants } from './constants';
-
-export class TokenRegWrapper {
- private readonly _tokenReg: TokenRegistryContract;
- private readonly _web3Wrapper: Web3Wrapper;
- constructor(tokenRegContract: TokenRegistryContract, provider: Provider) {
- this._tokenReg = tokenRegContract;
- this._web3Wrapper = new Web3Wrapper(provider);
- }
- public async addTokenAsync(token: Token, from: string): Promise<string> {
- const txHash = await this._tokenReg.addToken.sendTransactionAsync(
- token.address as string,
- token.name,
- token.symbol,
- token.decimals,
- token.ipfsHash,
- token.swarmHash,
- { from },
- );
- await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
- return txHash;
- }
- public async getTokenMetaDataAsync(tokenAddress: string): Promise<Token> {
- const data = await this._tokenReg.getTokenMetaData.callAsync(tokenAddress);
- const token: Token = {
- address: data[0],
- name: data[1],
- symbol: data[2],
- decimals: data[3],
- ipfsHash: data[4],
- swarmHash: data[5],
- };
- return token;
- }
- public async getTokenByNameAsync(tokenName: string): Promise<Token> {
- const data = await this._tokenReg.getTokenByName.callAsync(tokenName);
- const token: Token = {
- address: data[0],
- name: data[1],
- symbol: data[2],
- decimals: data[3],
- ipfsHash: data[4],
- swarmHash: data[5],
- };
- return token;
- }
- public async getTokenBySymbolAsync(tokenSymbol: string): Promise<Token> {
- const data = await this._tokenReg.getTokenBySymbol.callAsync(tokenSymbol);
- const token: Token = {
- address: data[0],
- name: data[1],
- symbol: data[2],
- decimals: data[3],
- ipfsHash: data[4],
- swarmHash: data[5],
- };
- return token;
- }
-}
diff --git a/packages/contracts/test/utils/transaction_factory.ts b/packages/contracts/test/utils/transaction_factory.ts
index 9ed4c5a31..dbab3ade4 100644
--- a/packages/contracts/test/utils/transaction_factory.ts
+++ b/packages/contracts/test/utils/transaction_factory.ts
@@ -1,6 +1,6 @@
-import { eip712Utils, generatePseudoRandomSalt } from '@0xproject/order-utils';
-import { SignatureType } from '@0xproject/types';
-import { signTypedDataUtils } from '@0xproject/utils';
+import { eip712Utils, generatePseudoRandomSalt } from '@0x/order-utils';
+import { SignatureType } from '@0x/types';
+import { signTypedDataUtils } from '@0x/utils';
import * as ethUtil from 'ethereumjs-util';
import { signingUtils } from './signing_utils';
diff --git a/packages/contracts/test/utils/type_encoding_utils.ts b/packages/contracts/test/utils/type_encoding_utils.ts
index 75307b9bd..bfd9c9ef5 100644
--- a/packages/contracts/test/utils/type_encoding_utils.ts
+++ b/packages/contracts/test/utils/type_encoding_utils.ts
@@ -1,4 +1,4 @@
-import { BigNumber } from '@0xproject/utils';
+import { BigNumber } from '@0x/utils';
import BN = require('bn.js');
import ethUtil = require('ethereumjs-util');
diff --git a/packages/contracts/test/utils/types.ts b/packages/contracts/test/utils/types.ts
index 598fb5393..9fc9e1570 100644
--- a/packages/contracts/test/utils/types.ts
+++ b/packages/contracts/test/utils/types.ts
@@ -1,5 +1,5 @@
-import { OrderWithoutExchangeAddress } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
+import { OrderWithoutExchangeAddress } from '@0x/types';
+import { BigNumber } from '@0x/utils';
import { AbiDefinition } from 'ethereum-types';
export interface ERC20BalancesByOwner {
diff --git a/packages/contracts/test/utils/web3_wrapper.ts b/packages/contracts/test/utils/web3_wrapper.ts
index d1cd3d387..f7b1a732a 100644
--- a/packages/contracts/test/utils/web3_wrapper.ts
+++ b/packages/contracts/test/utils/web3_wrapper.ts
@@ -1,7 +1,7 @@
-import { devConstants, env, EnvVars, web3Factory } from '@0xproject/dev-utils';
-import { prependSubprovider, Web3ProviderEngine } from '@0xproject/subproviders';
-import { logUtils } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { devConstants, env, EnvVars, web3Factory } from '@0x/dev-utils';
+import { prependSubprovider, Web3ProviderEngine } from '@0x/subproviders';
+import { logUtils } from '@0x/utils';
+import { Web3Wrapper } from '@0x/web3-wrapper';
import * as _ from 'lodash';
import { coverage } from './coverage';
diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json
index 5fd4c5331..8b29365cc 100644
--- a/packages/contracts/tsconfig.json
+++ b/packages/contracts/tsconfig.json
@@ -2,15 +2,47 @@
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib",
- "rootDir": "."
+ "rootDir": ".",
+ "resolveJsonModule": true
},
- "include": [
- "./globals.d.ts",
- "./generated_contract_wrappers",
- "./src/**/*",
- "./utils/**/*",
- "./test/**/*",
- "./migrations/**/*"
+ "include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
+ "files": [
+ "./generated-artifacts/AssetProxyOwner.json",
+ "./generated-artifacts/DummyERC20Token.json",
+ "./generated-artifacts/DummyERC721Receiver.json",
+ "./generated-artifacts/DummyERC721Token.json",
+ "./generated-artifacts/DummyMultipleReturnERC20Token.json",
+ "./generated-artifacts/DummyNoReturnERC20Token.json",
+ "./generated-artifacts/ERC20Proxy.json",
+ "./generated-artifacts/ERC20Token.json",
+ "./generated-artifacts/ERC721Proxy.json",
+ "./generated-artifacts/ERC721Token.json",
+ "./generated-artifacts/Exchange.json",
+ "./generated-artifacts/ExchangeWrapper.json",
+ "./generated-artifacts/Forwarder.json",
+ "./generated-artifacts/IAssetData.json",
+ "./generated-artifacts/IAssetProxy.json",
+ "./generated-artifacts/IValidator.json",
+ "./generated-artifacts/IWallet.json",
+ "./generated-artifacts/InvalidERC721Receiver.json",
+ "./generated-artifacts/MixinAuthorizable.json",
+ "./generated-artifacts/MultiSigWallet.json",
+ "./generated-artifacts/MultiSigWalletWithTimeLock.json",
+ "./generated-artifacts/OrderValidator.json",
+ "./generated-artifacts/ReentrantERC20Token.json",
+ "./generated-artifacts/TestAssetProxyDispatcher.json",
+ "./generated-artifacts/TestAssetProxyOwner.json",
+ "./generated-artifacts/TestConstants.json",
+ "./generated-artifacts/TestExchangeInternals.json",
+ "./generated-artifacts/TestLibBytes.json",
+ "./generated-artifacts/TestLibs.json",
+ "./generated-artifacts/TestSignatureValidator.json",
+ "./generated-artifacts/TestStaticCallReceiver.json",
+ "./generated-artifacts/Validator.json",
+ "./generated-artifacts/WETH9.json",
+ "./generated-artifacts/Wallet.json",
+ "./generated-artifacts/Whitelist.json",
+ "./generated-artifacts/ZRXToken.json"
],
"exclude": ["./deploy/solc/solc_bin"]
}
diff --git a/packages/contracts/tslint.json b/packages/contracts/tslint.json
index 1ab924e47..1bb3ac2a2 100644
--- a/packages/contracts/tslint.json
+++ b/packages/contracts/tslint.json
@@ -1,5 +1,5 @@
{
- "extends": ["@0xproject/tslint-config"],
+ "extends": ["@0x/tslint-config"],
"rules": {
"custom-no-magic-numbers": false
}