aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/generated-artifacts/IWallet.json
blob: e599632cbcb2de221ded605c36c97389eafdfb74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
{
    "schemaVersion": "2.0.0",
    "contractName": "IWallet",
    "compilerOutput": {
        "abi": [
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "hash",
                        "type": "bytes32"
                    },
                    {
                        "name": "signature",
                        "type": "bytes"
                    }
                ],
                "name": "isValidSignature",
                "outputs": [
                    {
                        "name": "isValid",
                        "type": "bool"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            }
        ],
        "evm": {
            "bytecode": {
                "linkReferences": {},
                "object": "0x",
                "opcodes": "",
                "sourceMap": ""
            },
            "deployedBytecode": {
                "linkReferences": {},
                "object": "0x",
                "opcodes": "",
                "sourceMap": ""
            }
        }
    },
    "sources": {
        "examples/ExchangeWrapper/ExchangeWrapper.sol": {
            "id": 0
        },
        "examples/Validator/Validator.sol": {
            "id": 1
        },
        "examples/Wallet/Wallet.sol": {
            "id": 2
        },
        "examples/Whitelist/Whitelist.sol": {
            "id": 3
        },
        "extensions/Forwarder/Forwarder.sol": {
            "id": 4
        },
        "extensions/Forwarder/MixinAssets.sol": {
            "id": 5
        },
        "extensions/Forwarder/MixinExchangeWrapper.sol": {
            "id": 6
        },
        "extensions/Forwarder/MixinForwarderCore.sol": {
            "id": 7
        },
        "extensions/Forwarder/MixinWeth.sol": {
            "id": 8
        },
        "extensions/Forwarder/interfaces/IAssets.sol": {
            "id": 9
        },
        "extensions/Forwarder/interfaces/IForwarderCore.sol": {
            "id": 10
        },
        "extensions/Forwarder/libs/LibConstants.sol": {
            "id": 11
        },
        "extensions/Forwarder/mixins/MAssets.sol": {
            "id": 12
        },
        "extensions/Forwarder/mixins/MExchangeWrapper.sol": {
            "id": 13
        },
        "extensions/Forwarder/mixins/MWeth.sol": {
            "id": 14
        },
        "extensions/OrderValidator/OrderValidator.sol": {
            "id": 15
        },
        "multisig/MultiSigWallet.sol": {
            "id": 16
        },
        "multisig/MultiSigWalletWithTimeLock.sol": {
            "id": 17
        },
        "protocol/AssetProxy/ERC20Proxy.sol": {
            "id": 18
        },
        "protocol/AssetProxy/ERC721Proxy.sol": {
            "id": 19
        },
        "protocol/AssetProxy/MixinAuthorizable.sol": {
            "id": 20
        },
        "protocol/AssetProxy/interfaces/IAssetData.sol": {
            "id": 21
        },
        "protocol/AssetProxy/interfaces/IAssetProxy.sol": {
            "id": 22
        },
        "protocol/AssetProxy/interfaces/IAuthorizable.sol": {
            "id": 23
        },
        "protocol/AssetProxy/mixins/MAuthorizable.sol": {
            "id": 24
        },
        "protocol/AssetProxyOwner/AssetProxyOwner.sol": {
            "id": 25
        },
        "protocol/Exchange/Exchange.sol": {
            "id": 26
        },
        "protocol/Exchange/MixinAssetProxyDispatcher.sol": {
            "id": 27
        },
        "protocol/Exchange/MixinExchangeCore.sol": {
            "id": 28
        },
        "protocol/Exchange/MixinMatchOrders.sol": {
            "id": 29
        },
        "protocol/Exchange/MixinSignatureValidator.sol": {
            "id": 30
        },
        "protocol/Exchange/MixinTransactions.sol": {
            "id": 31
        },
        "protocol/Exchange/MixinWrapperFunctions.sol": {
            "id": 32
        },
        "protocol/Exchange/interfaces/IAssetProxyDispatcher.sol": {
            "id": 33
        },
        "protocol/Exchange/interfaces/IExchange.sol": {
            "id": 34
        },
        "protocol/Exchange/interfaces/IExchangeCore.sol": {
            "id": 35
        },
        "protocol/Exchange/interfaces/IMatchOrders.sol": {
            "id": 36
        },
        "protocol/Exchange/interfaces/ISignatureValidator.sol": {
            "id": 37
        },
        "protocol/Exchange/interfaces/ITransactions.sol": {
            "id": 38
        },
        "protocol/Exchange/interfaces/IValidator.sol": {
            "id": 39
        },
        "protocol/Exchange/interfaces/IWallet.sol": {
            "id": 40
        },
        "protocol/Exchange/interfaces/IWrapperFunctions.sol": {
            "id": 41
        },
        "protocol/Exchange/libs/LibAbiEncoder.sol": {
            "id": 42
        },
        "protocol/Exchange/libs/LibConstants.sol": {
            "id": 43
        },
        "protocol/Exchange/libs/LibEIP712.sol": {
            "id": 44
        },
        "protocol/Exchange/libs/LibExchangeErrors.sol": {
            "id": 45
        },
        "protocol/Exchange/libs/LibFillResults.sol": {
            "id": 46
        },
        "protocol/Exchange/libs/LibMath.sol": {
            "id": 47
        },
        "protocol/Exchange/libs/LibOrder.sol": {
            "id": 48
        },
        "protocol/Exchange/mixins/MAssetProxyDispatcher.sol": {
            "id": 49
        },
        "protocol/Exchange/mixins/MExchangeCore.sol": {
            "id": 50
        },
        "protocol/Exchange/mixins/MMatchOrders.sol": {
            "id": 51
        },
        "protocol/Exchange/mixins/MSignatureValidator.sol": {
            "id": 52
        },
        "protocol/Exchange/mixins/MTransactions.sol": {
            "id": 53
        },
        "protocol/Exchange/mixins/MWrapperFunctions.sol": {
            "id": 54
        },
        "test/DummyERC20Token/DummyERC20Token.sol": {
            "id": 55
        },
        "test/DummyERC20Token/DummyMultipleReturnERC20Token.sol": {
            "id": 56
        },
        "test/DummyERC20Token/DummyNoReturnERC20Token.sol": {
            "id": 57
        },
        "test/DummyERC721Receiver/DummyERC721Receiver.sol": {
            "id": 58
        },
        "test/DummyERC721Receiver/InvalidERC721Receiver.sol": {
            "id": 59
        },
        "test/DummyERC721Token/DummyERC721Token.sol": {
            "id": 60
        },
        "test/ReentrantERC20Token/ReentrantERC20Token.sol": {
            "id": 61
        },
        "test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol": {
            "id": 62
        },
        "test/TestAssetProxyOwner/TestAssetProxyOwner.sol": {
            "id": 63
        },
        "test/TestConstants/TestConstants.sol": {
            "id": 64
        },
        "test/TestExchangeInternals/TestExchangeInternals.sol": {
            "id": 65
        },
        "test/TestLibBytes/TestLibBytes.sol": {
            "id": 66
        },
        "test/TestLibs/TestLibs.sol": {
            "id": 67
        },
        "test/TestSignatureValidator/TestSignatureValidator.sol": {
            "id": 68
        },
        "test/TestStaticCallReceiver/TestStaticCallReceiver.sol": {
            "id": 69
        },
        "tokens/ERC20Token/ERC20Token.sol": {
            "id": 70
        },
        "tokens/ERC20Token/IERC20Token.sol": {
            "id": 71
        },
        "tokens/ERC20Token/MintableERC20Token.sol": {
            "id": 72
        },
        "tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol": {
            "id": 73
        },
        "tokens/ERC721Token/ERC721Token.sol": {
            "id": 74
        },
        "tokens/ERC721Token/IERC721Receiver.sol": {
            "id": 75
        },
        "tokens/ERC721Token/IERC721Token.sol": {
            "id": 76
        },
        "tokens/ERC721Token/MintableERC721Token.sol": {
            "id": 77
        },
        "tokens/EtherToken/IEtherToken.sol": {
            "id": 78
        },
        "tokens/EtherToken/WETH9.sol": {
            "id": 79
        },
        "utils/LibBytes/LibBytes.sol": {
            "id": 80
        },
        "utils/Ownable/IOwnable.sol": {
            "id": 81
        },
        "utils/Ownable/Ownable.sol": {
            "id": 82
        },
        "utils/ReentrancyGuard/ReentrancyGuard.sol": {
            "id": 83
        },
        "utils/SafeMath/SafeMath.sol": {
            "id": 84
        }
    },
    "sourceCodes": {
        "examples/ExchangeWrapper/ExchangeWrapper.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../../protocol/Exchange/interfaces/IExchange.sol\";\nimport \"../../protocol/Exchange/libs/LibOrder.sol\";\n\n\ncontract ExchangeWrapper {\n\n    // Exchange contract.\n    // solhint-disable-next-line var-name-mixedcase\n    IExchange internal EXCHANGE;\n\n    constructor (address _exchange)\n        public\n    {\n        EXCHANGE = IExchange(_exchange);\n    }\n\n    /// @dev Cancels all orders created by sender with a salt less than or equal to the targetOrderEpoch\n    ///      and senderAddress equal to this contract.\n    /// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled.\n    /// @param salt Arbitrary value to gaurantee uniqueness of 0x transaction hash.\n    /// @param makerSignature Proof that maker wishes to call this function with given params.\n    function cancelOrdersUpTo(\n        uint256 targetOrderEpoch,\n        uint256 salt,\n        bytes makerSignature\n    )\n        external\n    {\n        address makerAddress = msg.sender;\n\n        // Encode arguments into byte array.\n        bytes memory data = abi.encodeWithSelector(\n            EXCHANGE.cancelOrdersUpTo.selector,\n            targetOrderEpoch\n        );\n\n        // Call `cancelOrdersUpTo` via `executeTransaction`.\n        EXCHANGE.executeTransaction(\n            salt,\n            makerAddress,\n            data,\n            makerSignature\n        );\n    }\n\n    /// @dev Fills an order using `msg.sender` as the taker.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param salt Arbitrary value to gaurantee uniqueness of 0x transaction hash.\n    /// @param orderSignature Proof that order has been created by maker.\n    /// @param takerSignature Proof that taker wishes to call this function with given params.\n    function fillOrder(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        uint256 salt,\n        bytes memory orderSignature,\n        bytes memory takerSignature\n    )\n        public\n    {\n        address takerAddress = msg.sender;\n\n        // Encode arguments into byte array.\n        bytes memory data = abi.encodeWithSelector(\n            EXCHANGE.fillOrder.selector,\n            order,\n            takerAssetFillAmount,\n            orderSignature\n        );\n\n        // Call `fillOrder` via `executeTransaction`.\n        EXCHANGE.executeTransaction(\n            salt,\n            takerAddress,\n            data,\n            takerSignature\n        );\n    }\n}\n",
        "examples/Validator/Validator.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../protocol/Exchange/interfaces/IValidator.sol\";\n\n\ncontract Validator is \n    IValidator\n{\n\n    // The single valid signer for this wallet.\n    // solhint-disable-next-line var-name-mixedcase\n    address internal VALID_SIGNER;\n\n    /// @dev constructs a new `Validator` with a single valid signer.\n    /// @param validSigner The sole, valid signer.\n    constructor (address validSigner) public {\n        VALID_SIGNER = validSigner;\n    }\n\n    /// @dev Verifies that a signature is valid. `signer` must match `VALID_SIGNER`.\n    /// @param hash Message hash that is signed.\n    /// @param signerAddress Address that should have signed the given hash.\n    /// @param signature Proof of signing.\n    /// @return Validity of signature.\n    // solhint-disable no-unused-vars\n    function isValidSignature(\n        bytes32 hash,\n        address signerAddress,\n        bytes signature\n    )\n        external\n        view\n        returns (bool isValid)\n    {\n        return (signerAddress == VALID_SIGNER);\n    }\n    // solhint-enable no-unused-vars\n}\n",
        "examples/Wallet/Wallet.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../protocol/Exchange/interfaces/IWallet.sol\";\nimport \"../../utils/LibBytes/LibBytes.sol\";\n\n\ncontract Wallet is \n    IWallet\n{\n    using LibBytes for bytes;\n\n    // The owner of this wallet.\n    // solhint-disable-next-line var-name-mixedcase\n    address internal WALLET_OWNER;\n\n    /// @dev constructs a new `Wallet` with a single owner.\n    /// @param walletOwner The owner of this wallet.\n    constructor (address walletOwner) public {\n        WALLET_OWNER = walletOwner;\n    }\n\n    /// @dev Validates an EIP712 signature.\n    ///      The signer must match the owner of this wallet.\n    /// @param hash Message hash that is signed.\n    /// @param eip712Signature Proof of signing.\n    /// @return Validity of signature.\n    function isValidSignature(\n        bytes32 hash,\n        bytes eip712Signature\n    )\n        external\n        view\n        returns (bool isValid)\n    {\n        require(\n            eip712Signature.length == 65,\n            \"LENGTH_65_REQUIRED\"\n        );\n\n        uint8 v = uint8(eip712Signature[0]);\n        bytes32 r = eip712Signature.readBytes32(1);\n        bytes32 s = eip712Signature.readBytes32(33);\n        address recoveredAddress = ecrecover(hash, v, r, s);\n        isValid = WALLET_OWNER == recoveredAddress;\n        return isValid;\n    }\n}\n",
        "examples/Whitelist/Whitelist.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../../protocol/Exchange/interfaces/IExchange.sol\";\nimport \"../../protocol/Exchange/libs/LibOrder.sol\";\nimport \"../../utils/Ownable/Ownable.sol\";\n\n\ncontract Whitelist is\n    Ownable\n{\n\n    // Mapping of address => whitelist status.\n    mapping (address => bool) public isWhitelisted;\n\n    // Exchange contract.\n    // solhint-disable var-name-mixedcase\n    IExchange internal EXCHANGE;\n    bytes internal TX_ORIGIN_SIGNATURE;\n    // solhint-enable var-name-mixedcase\n\n    byte constant internal VALIDATOR_SIGNATURE_BYTE = \"\\x05\";\n\n    constructor (address _exchange)\n        public\n    {\n        EXCHANGE = IExchange(_exchange);\n        TX_ORIGIN_SIGNATURE = abi.encodePacked(address(this), VALIDATOR_SIGNATURE_BYTE);\n    }\n\n    /// @dev Adds or removes an address from the whitelist.\n    /// @param target Address to add or remove from whitelist.\n    /// @param isApproved Whitelist status to assign to address.\n    function updateWhitelistStatus(\n        address target,\n        bool isApproved\n    )\n        external\n        onlyOwner\n    {\n        isWhitelisted[target] = isApproved;\n    }\n\n    /// @dev Verifies signer is same as signer of current Ethereum transaction.\n    ///      NOTE: This function can currently be used to validate signatures coming from outside of this contract.\n    ///      Extra safety checks can be added for a production contract.\n    /// @param signerAddress Address that should have signed the given hash.\n    /// @param signature Proof of signing.\n    /// @return Validity of order signature.\n    // solhint-disable no-unused-vars\n    function isValidSignature(\n        bytes32 hash,\n        address signerAddress,\n        bytes signature\n    )\n        external\n        view\n        returns (bool isValid)\n    {\n        // solhint-disable-next-line avoid-tx-origin\n        return signerAddress == tx.origin;\n    }\n    // solhint-enable no-unused-vars\n\n    /// @dev Fills an order using `msg.sender` as the taker.\n    ///      The transaction will revert if both the maker and taker are not whitelisted.\n    ///      Orders should specify this contract as the `senderAddress` in order to gaurantee\n    ///      that both maker and taker have been whitelisted.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param salt Arbitrary value to gaurantee uniqueness of 0x transaction hash.\n    /// @param orderSignature Proof that order has been created by maker.\n    function fillOrderIfWhitelisted(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        uint256 salt,\n        bytes memory orderSignature\n    )\n        public\n    {\n        address takerAddress = msg.sender;\n\n        // This contract must be the entry point for the transaction.\n        require(\n            // solhint-disable-next-line avoid-tx-origin\n            takerAddress == tx.origin,\n            \"INVALID_SENDER\"\n        );\n\n        // Check if maker is on the whitelist.\n        require(\n            isWhitelisted[order.makerAddress],\n            \"MAKER_NOT_WHITELISTED\"\n        );\n\n        // Check if taker is on the whitelist.\n        require(\n            isWhitelisted[takerAddress],\n            \"TAKER_NOT_WHITELISTED\"\n        );\n\n        // Encode arguments into byte array.\n        bytes memory data = abi.encodeWithSelector(\n            EXCHANGE.fillOrder.selector,\n            order,\n            takerAssetFillAmount,\n            orderSignature\n        );\n\n        // Call `fillOrder` via `executeTransaction`.\n        EXCHANGE.executeTransaction(\n            salt,\n            takerAddress,\n            data,\n            TX_ORIGIN_SIGNATURE\n        );\n    }\n}\n",
        "extensions/Forwarder/Forwarder.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"./MixinWeth.sol\";\nimport \"./MixinForwarderCore.sol\";\nimport \"./libs/LibConstants.sol\";\nimport \"./MixinAssets.sol\";\nimport \"./MixinExchangeWrapper.sol\";\n\n\n// solhint-disable no-empty-blocks\ncontract Forwarder is\n    LibConstants,\n    MixinWeth,\n    MixinAssets,\n    MixinExchangeWrapper,\n    MixinForwarderCore\n{\n    constructor (\n        address _exchange,\n        bytes memory _zrxAssetData,\n        bytes memory _wethAssetData\n    )\n        public\n        LibConstants(\n            _exchange,\n            _zrxAssetData,\n            _wethAssetData\n        )\n        MixinForwarderCore()\n    {}\n}\n",
        "extensions/Forwarder/MixinAssets.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../utils/LibBytes/LibBytes.sol\";\nimport \"../../utils/Ownable/Ownable.sol\";\nimport \"../../tokens/ERC20Token/IERC20Token.sol\";\nimport \"../../tokens/ERC721Token/IERC721Token.sol\";\nimport \"./libs/LibConstants.sol\";\nimport \"./mixins/MAssets.sol\";\n\n\ncontract MixinAssets is\n    Ownable,\n    LibConstants,\n    MAssets\n{\n    using LibBytes for bytes;\n\n    bytes4 constant internal ERC20_TRANSFER_SELECTOR = bytes4(keccak256(\"transfer(address,uint256)\"));\n\n    /// @dev Withdraws assets from this contract. The contract requires a ZRX balance in order to \n    ///      function optimally, and this function allows the ZRX to be withdrawn by owner. It may also be\n    ///      used to withdraw assets that were accidentally sent to this contract.\n    /// @param assetData Byte array encoded for the respective asset proxy.\n    /// @param amount Amount of ERC20 token to withdraw.\n    function withdrawAsset(\n        bytes assetData,\n        uint256 amount\n    )\n        external\n        onlyOwner\n    {\n        transferAssetToSender(assetData, amount);\n    }\n\n    /// @dev Transfers given amount of asset to sender.\n    /// @param assetData Byte array encoded for the respective asset proxy.\n    /// @param amount Amount of asset to transfer to sender.\n    function transferAssetToSender(\n        bytes memory assetData,\n        uint256 amount\n    )\n        internal\n    {\n        bytes4 proxyId = assetData.readBytes4(0);\n\n        if (proxyId == ERC20_DATA_ID) {\n            transferERC20Token(assetData, amount);\n        } else if (proxyId == ERC721_DATA_ID) {\n            transferERC721Token(assetData, amount);\n        } else {\n            revert(\"UNSUPPORTED_ASSET_PROXY\");\n        }\n    }\n\n    /// @dev Decodes ERC20 assetData and transfers given amount to sender.\n    /// @param assetData Byte array encoded for the respective asset proxy.\n    /// @param amount Amount of asset to transfer to sender.\n    function transferERC20Token(\n        bytes memory assetData,\n        uint256 amount\n    )\n        internal\n    {\n        address token = assetData.readAddress(16);\n\n        // Transfer tokens.\n        // We do a raw call so we can check the success separate\n        // from the return data.\n        bool success = token.call(abi.encodeWithSelector(\n            ERC20_TRANSFER_SELECTOR,\n            msg.sender,\n            amount\n        ));\n        require(\n            success,\n            \"TRANSFER_FAILED\"\n        );\n        \n        // Check return data.\n        // If there is no return data, we assume the token incorrectly\n        // does not return a bool. In this case we expect it to revert\n        // on failure, which was handled above.\n        // If the token does return data, we require that it is a single\n        // value that evaluates to true.\n        assembly {\n            if returndatasize {\n                success := 0\n                if eq(returndatasize, 32) {\n                    // First 64 bytes of memory are reserved scratch space\n                    returndatacopy(0, 0, 32)\n                    success := mload(0)\n                }\n            }\n        }\n        require(\n            success,\n            \"TRANSFER_FAILED\"\n        );\n    }\n\n    /// @dev Decodes ERC721 assetData and transfers given amount to sender.\n    /// @param assetData Byte array encoded for the respective asset proxy.\n    /// @param amount Amount of asset to transfer to sender.\n    function transferERC721Token(\n        bytes memory assetData,\n        uint256 amount\n    )\n        internal\n    {\n        require(\n            amount == 1,\n            \"INVALID_AMOUNT\"\n        );\n        // Decode asset data.\n        address token = assetData.readAddress(16);\n        uint256 tokenId = assetData.readUint256(36);\n\n        // Perform transfer.\n        IERC721Token(token).transferFrom(\n            address(this),\n            msg.sender,\n            tokenId\n        );\n    }\n}\n",
        "extensions/Forwarder/MixinExchangeWrapper.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"./libs/LibConstants.sol\";\nimport \"./mixins/MExchangeWrapper.sol\";\nimport \"../../protocol/Exchange/libs/LibAbiEncoder.sol\";\nimport \"../../protocol/Exchange/libs/LibOrder.sol\";\nimport \"../../protocol/Exchange/libs/LibFillResults.sol\";\nimport \"../../protocol/Exchange/libs/LibMath.sol\";\n\n\ncontract MixinExchangeWrapper is\n    LibAbiEncoder,\n    LibFillResults,\n    LibMath,\n    LibConstants,\n    MExchangeWrapper\n{\n    /// @dev Fills the input order.\n    ///      Returns false if the transaction would otherwise revert.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    /// @return Amounts filled and fees paid by maker and taker.\n    function fillOrderNoThrow(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        internal\n        returns (FillResults memory fillResults)\n    {\n        // ABI encode calldata for `fillOrder`\n        bytes memory fillOrderCalldata = abiEncodeFillOrder(\n            order,\n            takerAssetFillAmount,\n            signature\n        );\n\n        address exchange = address(EXCHANGE);\n\n        // Call `fillOrder` and handle any exceptions gracefully\n        assembly {\n            let success := call(\n                gas,                                // forward all gas\n                exchange,                           // call address of Exchange contract\n                0,                                  // transfer 0 wei\n                add(fillOrderCalldata, 32),         // pointer to start of input (skip array length in first 32 bytes)\n                mload(fillOrderCalldata),           // length of input\n                fillOrderCalldata,                  // write output over input\n                128                                 // output size is 128 bytes\n            )\n            if success {\n                mstore(fillResults, mload(fillOrderCalldata))\n                mstore(add(fillResults, 32), mload(add(fillOrderCalldata, 32)))\n                mstore(add(fillResults, 64), mload(add(fillOrderCalldata, 64)))\n                mstore(add(fillResults, 96), mload(add(fillOrderCalldata, 96)))\n            }\n        }\n        // fillResults values will be 0 by default if call was unsuccessful\n        return fillResults;\n    }\n\n    /// @dev Synchronously executes multiple calls of fillOrder until total amount of WETH has been sold by taker.\n    ///      Returns false if the transaction would otherwise revert.\n    /// @param orders Array of order specifications.\n    /// @param wethSellAmount Desired amount of WETH to sell.\n    /// @param signatures Proofs that orders have been signed by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function marketSellWeth(\n        LibOrder.Order[] memory orders,\n        uint256 wethSellAmount,\n        bytes[] memory signatures\n    )\n        internal\n        returns (FillResults memory totalFillResults)\n    {\n        bytes memory makerAssetData = orders[0].makerAssetData;\n        bytes memory wethAssetData = WETH_ASSET_DATA;\n\n        uint256 ordersLength = orders.length;\n        for (uint256 i = 0; i != ordersLength; i++) {\n\n            // We assume that asset being bought by taker is the same for each order.\n            // We assume that asset being sold by taker is WETH for each order.\n            orders[i].makerAssetData = makerAssetData;\n            orders[i].takerAssetData = wethAssetData;\n\n            // Calculate the remaining amount of WETH to sell\n            uint256 remainingTakerAssetFillAmount = safeSub(wethSellAmount, totalFillResults.takerAssetFilledAmount);\n\n            // Attempt to sell the remaining amount of WETH\n            FillResults memory singleFillResults = fillOrderNoThrow(\n                orders[i],\n                remainingTakerAssetFillAmount,\n                signatures[i]\n            );\n\n            // Update amounts filled and fees paid by maker and taker\n            addFillResults(totalFillResults, singleFillResults);\n\n            // Stop execution if the entire amount of takerAsset has been sold\n            if (totalFillResults.takerAssetFilledAmount >= wethSellAmount) {\n                break;\n            }\n        }\n        return totalFillResults;\n    }\n\n    /// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker.\n    ///      Returns false if the transaction would otherwise revert.\n    ///      The asset being sold by taker must always be WETH.\n    /// @param orders Array of order specifications.\n    /// @param makerAssetFillAmount Desired amount of makerAsset to buy.\n    /// @param signatures Proofs that orders have been signed by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function marketBuyExactAmountWithWeth(\n        LibOrder.Order[] memory orders,\n        uint256 makerAssetFillAmount,\n        bytes[] memory signatures\n    )\n        internal\n        returns (FillResults memory totalFillResults)\n    {\n        bytes memory makerAssetData = orders[0].makerAssetData;\n        bytes memory wethAssetData = WETH_ASSET_DATA;\n\n        uint256 ordersLength = orders.length;\n        for (uint256 i = 0; i != ordersLength; i++) {\n\n            // We assume that asset being bought by taker is the same for each order.\n            // We assume that asset being sold by taker is WETH for each order.\n            orders[i].makerAssetData = makerAssetData;\n            orders[i].takerAssetData = wethAssetData;\n\n            // Calculate the remaining amount of makerAsset to buy\n            uint256 remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount);\n\n            // Convert the remaining amount of makerAsset to buy into remaining amount\n            // of takerAsset to sell, assuming entire amount can be sold in the current order\n            uint256 remainingTakerAssetFillAmount = getPartialAmountFloor(\n                orders[i].takerAssetAmount,\n                orders[i].makerAssetAmount,\n                remainingMakerAssetFillAmount\n            );\n\n            // Attempt to sell the remaining amount of takerAsset\n            FillResults memory singleFillResults = fillOrderNoThrow(\n                orders[i],\n                remainingTakerAssetFillAmount,\n                signatures[i]\n            );\n\n            // Update amounts filled and fees paid by maker and taker\n            addFillResults(totalFillResults, singleFillResults);\n\n            // Stop execution if the entire amount of makerAsset has been bought\n            uint256 makerAssetFilledAmount = totalFillResults.makerAssetFilledAmount;\n            if (makerAssetFilledAmount >= makerAssetFillAmount) {\n                break;\n            }\n        }\n\n        require(\n            makerAssetFilledAmount >= makerAssetFillAmount,\n            \"COMPLETE_FILL_FAILED\"\n        );\n        return totalFillResults;\n    }\n\n    /// @dev Buys zrxBuyAmount of ZRX fee tokens, taking into account ZRX fees for each order. This will guarantee\n    ///      that at least zrxBuyAmount of ZRX is purchased (sometimes slightly over due to rounding issues).\n    ///      It is possible that a request to buy 200 ZRX will require purchasing 202 ZRX\n    ///      as 2 ZRX is required to purchase the 200 ZRX fee tokens. This guarantees at least 200 ZRX for future purchases.\n    ///      The asset being sold by taker must always be WETH. \n    /// @param orders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset.\n    /// @param zrxBuyAmount Desired amount of ZRX to buy.\n    /// @param signatures Proofs that orders have been created by makers.\n    /// @return totalFillResults Amounts filled and fees paid by maker and taker.\n    function marketBuyExactZrxWithWeth(\n        LibOrder.Order[] memory orders,\n        uint256 zrxBuyAmount,\n        bytes[] memory signatures\n    )\n        internal\n        returns (FillResults memory totalFillResults)\n    {\n        // Do nothing if zrxBuyAmount == 0\n        if (zrxBuyAmount == 0) {\n            return totalFillResults;\n        }\n\n        bytes memory zrxAssetData = ZRX_ASSET_DATA;\n        bytes memory wethAssetData = WETH_ASSET_DATA;\n        uint256 zrxPurchased = 0;\n\n        uint256 ordersLength = orders.length;\n        for (uint256 i = 0; i != ordersLength; i++) {\n\n            // All of these are ZRX/WETH, so we can drop the respective assetData from calldata.\n            orders[i].makerAssetData = zrxAssetData;\n            orders[i].takerAssetData = wethAssetData;\n\n            // Calculate the remaining amount of ZRX to buy.\n            uint256 remainingZrxBuyAmount = safeSub(zrxBuyAmount, zrxPurchased);\n\n            // Convert the remaining amount of ZRX to buy into remaining amount\n            // of WETH to sell, assuming entire amount can be sold in the current order.\n            uint256 remainingWethSellAmount = getPartialAmountFloor(\n                orders[i].takerAssetAmount,\n                safeSub(orders[i].makerAssetAmount, orders[i].takerFee),  // our exchange rate after fees \n                remainingZrxBuyAmount\n            );\n\n            // Attempt to sell the remaining amount of WETH.\n            FillResults memory singleFillResult = fillOrderNoThrow(\n                orders[i],\n                safeAdd(remainingWethSellAmount, 1),  // we add 1 wei to the fill amount to make up for rounding errors\n                signatures[i]\n            );\n\n            // Update amounts filled and fees paid by maker and taker.\n            addFillResults(totalFillResults, singleFillResult);\n            zrxPurchased = safeSub(totalFillResults.makerAssetFilledAmount, totalFillResults.takerFeePaid);\n\n            // Stop execution if the entire amount of ZRX has been bought.\n            if (zrxPurchased >= zrxBuyAmount) {\n                break;\n            }\n        }\n\n        require(\n            zrxPurchased >= zrxBuyAmount,\n            \"COMPLETE_FILL_FAILED\"\n        );\n        return totalFillResults;\n    }\n}\n",
        "extensions/Forwarder/MixinForwarderCore.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"./libs/LibConstants.sol\";\nimport \"./mixins/MWeth.sol\";\nimport \"./mixins/MAssets.sol\";\nimport \"./mixins/MExchangeWrapper.sol\";\nimport \"./interfaces/IForwarderCore.sol\";\nimport \"../../utils/LibBytes/LibBytes.sol\";\nimport \"../../protocol/Exchange/libs/LibOrder.sol\";\nimport \"../../protocol/Exchange/libs/LibFillResults.sol\";\nimport \"../../protocol/Exchange/libs/LibMath.sol\";\n\n\ncontract MixinForwarderCore is\n    LibFillResults,\n    LibMath,\n    LibConstants,\n    MWeth,\n    MAssets,\n    MExchangeWrapper,\n    IForwarderCore\n{\n    using LibBytes for bytes;\n\n    /// @dev Constructor approves ERC20 proxy to transfer ZRX and WETH on this contract's behalf.\n    constructor ()\n        public\n    {\n        address proxyAddress = EXCHANGE.getAssetProxy(ERC20_DATA_ID);\n        require(\n            proxyAddress != address(0),\n            \"UNREGISTERED_ASSET_PROXY\"\n        );\n        ETHER_TOKEN.approve(proxyAddress, MAX_UINT);\n        ZRX_TOKEN.approve(proxyAddress, MAX_UINT);\n    }\n\n    /// @dev Purchases as much of orders' makerAssets as possible by selling up to 95% of transaction's ETH value.\n    ///      Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.\n    ///      5% of ETH value is reserved for paying fees to order feeRecipients (in ZRX) and forwarding contract feeRecipient (in ETH).\n    ///      Any ETH not spent will be refunded to sender.\n    /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. \n    /// @param signatures Proofs that orders have been created by makers.\n    /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.\n    /// @param feeSignatures Proofs that feeOrders have been created by makers.\n    /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.\n    /// @param feeRecipient Address that will receive ETH when orders are filled.\n    /// @return Amounts filled and fees paid by maker and taker for both sets of orders.\n    function marketSellOrdersWithEth(\n        LibOrder.Order[] memory orders,\n        bytes[] memory signatures,\n        LibOrder.Order[] memory feeOrders,\n        bytes[] memory feeSignatures,\n        uint256  feePercentage,\n        address feeRecipient\n    )\n        public\n        payable\n        returns (\n            FillResults memory orderFillResults,\n            FillResults memory feeOrderFillResults\n        )\n    {\n        // Convert ETH to WETH.\n        convertEthToWeth();\n\n        uint256 wethSellAmount;\n        uint256 zrxBuyAmount;\n        uint256 makerAssetAmountPurchased;\n        if (orders[0].makerAssetData.equals(ZRX_ASSET_DATA)) {\n            // Calculate amount of WETH that won't be spent on ETH fees.\n            wethSellAmount = getPartialAmountFloor(\n                PERCENTAGE_DENOMINATOR,\n                safeAdd(PERCENTAGE_DENOMINATOR, feePercentage),\n                msg.value\n            );\n            // Market sell available WETH.\n            // ZRX fees are paid with this contract's balance.\n            orderFillResults = marketSellWeth(\n                orders,\n                wethSellAmount,\n                signatures\n            );\n            // The fee amount must be deducted from the amount transfered back to sender.\n            makerAssetAmountPurchased = safeSub(orderFillResults.makerAssetFilledAmount, orderFillResults.takerFeePaid);\n        } else {\n            // 5% of WETH is reserved for filling feeOrders and paying feeRecipient.\n            wethSellAmount = getPartialAmountFloor(\n                MAX_WETH_FILL_PERCENTAGE,\n                PERCENTAGE_DENOMINATOR,\n                msg.value\n            );\n            // Market sell 95% of WETH.\n            // ZRX fees are payed with this contract's balance.\n            orderFillResults = marketSellWeth(\n                orders,\n                wethSellAmount,\n                signatures\n            );\n            // Buy back all ZRX spent on fees.\n            zrxBuyAmount = orderFillResults.takerFeePaid;\n            feeOrderFillResults = marketBuyExactZrxWithWeth(\n                feeOrders,\n                zrxBuyAmount,\n                feeSignatures\n            );\n            makerAssetAmountPurchased = orderFillResults.makerAssetFilledAmount;\n        }\n\n        // Transfer feePercentage of total ETH spent on primary orders to feeRecipient.\n        // Refund remaining ETH to msg.sender.\n        transferEthFeeAndRefund(\n            orderFillResults.takerAssetFilledAmount,\n            feeOrderFillResults.takerAssetFilledAmount,\n            feePercentage,\n            feeRecipient\n        );\n\n        // Transfer purchased assets to msg.sender.\n        transferAssetToSender(orders[0].makerAssetData, makerAssetAmountPurchased);\n    }\n\n    /// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction.\n    ///      Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.\n    ///      Any ETH not spent will be refunded to sender.\n    /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. \n    /// @param makerAssetFillAmount Desired amount of makerAsset to purchase.\n    /// @param signatures Proofs that orders have been created by makers.\n    /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.\n    /// @param feeSignatures Proofs that feeOrders have been created by makers.\n    /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.\n    /// @param feeRecipient Address that will receive ETH when orders are filled.\n    /// @return Amounts filled and fees paid by maker and taker for both sets of orders.\n    function marketBuyOrdersWithEth(\n        LibOrder.Order[] memory orders,\n        uint256 makerAssetFillAmount,\n        bytes[] memory signatures,\n        LibOrder.Order[] memory feeOrders,\n        bytes[] memory feeSignatures,\n        uint256  feePercentage,\n        address feeRecipient\n    )\n        public\n        payable\n        returns (\n            FillResults memory orderFillResults,\n            FillResults memory feeOrderFillResults\n        )\n    {\n        // Convert ETH to WETH.\n        convertEthToWeth();\n\n        uint256 zrxBuyAmount;\n        uint256 makerAssetAmountPurchased;\n        if (orders[0].makerAssetData.equals(ZRX_ASSET_DATA)) {\n            // If the makerAsset is ZRX, it is not necessary to pay fees out of this\n            // contracts's ZRX balance because fees are factored into the price of the order.\n            orderFillResults = marketBuyExactZrxWithWeth(\n                orders,\n                makerAssetFillAmount,\n                signatures\n            );\n            // The fee amount must be deducted from the amount transfered back to sender.\n            makerAssetAmountPurchased = safeSub(orderFillResults.makerAssetFilledAmount, orderFillResults.takerFeePaid);\n        } else {\n            // Attemp to purchase desired amount of makerAsset.\n            // ZRX fees are payed with this contract's balance.\n            orderFillResults = marketBuyExactAmountWithWeth(\n                orders,\n                makerAssetFillAmount,\n                signatures\n            );\n            // Buy back all ZRX spent on fees.\n            zrxBuyAmount = orderFillResults.takerFeePaid;\n            feeOrderFillResults = marketBuyExactZrxWithWeth(\n                feeOrders,\n                zrxBuyAmount,\n                feeSignatures\n            );\n            makerAssetAmountPurchased = orderFillResults.makerAssetFilledAmount;\n        }\n\n        // Transfer feePercentage of total ETH spent on primary orders to feeRecipient.\n        // Refund remaining ETH to msg.sender.\n        transferEthFeeAndRefund(\n            orderFillResults.takerAssetFilledAmount,\n            feeOrderFillResults.takerAssetFilledAmount,\n            feePercentage,\n            feeRecipient\n        );\n\n        // Transfer purchased assets to msg.sender.\n        transferAssetToSender(orders[0].makerAssetData, makerAssetAmountPurchased);\n    }\n}\n",
        "extensions/Forwarder/MixinWeth.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../protocol/Exchange/libs/LibMath.sol\";\nimport \"./libs/LibConstants.sol\";\nimport \"./mixins/MWeth.sol\";\n\n\ncontract MixinWeth is\n    LibMath,\n    LibConstants,\n    MWeth\n{\n    /// @dev Default payabale function, this allows us to withdraw WETH\n    function ()\n        public\n        payable\n    {\n        require(\n            msg.sender == address(ETHER_TOKEN),\n            \"DEFAULT_FUNCTION_WETH_CONTRACT_ONLY\"\n        );\n    }\n\n    /// @dev Converts message call's ETH value into WETH.\n    function convertEthToWeth()\n        internal\n    {\n        require(\n            msg.value > 0,\n            \"INVALID_MSG_VALUE\"\n        );\n        ETHER_TOKEN.deposit.value(msg.value)();\n    }\n\n    /// @dev Transfers feePercentage of WETH spent on primary orders to feeRecipient.\n    ///      Refunds any excess ETH to msg.sender.\n    /// @param wethSoldExcludingFeeOrders Amount of WETH sold when filling primary orders.\n    /// @param wethSoldForZrx Amount of WETH sold when purchasing ZRX required for primary order fees.\n    /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.\n    /// @param feeRecipient Address that will receive ETH when orders are filled.\n    function transferEthFeeAndRefund(\n        uint256 wethSoldExcludingFeeOrders,\n        uint256 wethSoldForZrx,\n        uint256 feePercentage,\n        address feeRecipient\n    )\n        internal\n    {\n        // Ensure feePercentage is less than 5%.\n        require(\n            feePercentage <= MAX_FEE_PERCENTAGE,\n            \"FEE_PERCENTAGE_TOO_LARGE\"\n        );\n\n        // Ensure that no extra WETH owned by this contract has been sold.\n        uint256 wethSold = safeAdd(wethSoldExcludingFeeOrders, wethSoldForZrx);\n        require(\n            wethSold <= msg.value,\n            \"OVERSOLD_WETH\"\n        );\n\n        // Calculate amount of WETH that hasn't been sold.\n        uint256 wethRemaining = safeSub(msg.value, wethSold);\n\n        // Calculate ETH fee to pay to feeRecipient.\n        uint256 ethFee = getPartialAmountFloor(\n            feePercentage,\n            PERCENTAGE_DENOMINATOR,\n            wethSoldExcludingFeeOrders\n        );\n\n        // Ensure fee is less than amount of WETH remaining.\n        require(\n            ethFee <= wethRemaining,\n            \"INSUFFICIENT_ETH_REMAINING\"\n        );\n    \n        // Do nothing if no WETH remaining\n        if (wethRemaining > 0) {\n            // Convert remaining WETH to ETH\n            ETHER_TOKEN.withdraw(wethRemaining);\n\n            // Pay ETH to feeRecipient\n            if (ethFee > 0) {\n                feeRecipient.transfer(ethFee);\n            }\n\n            // Refund remaining ETH to msg.sender.\n            uint256 ethRefund = safeSub(wethRemaining, ethFee);\n            if (ethRefund > 0) {\n                msg.sender.transfer(ethRefund);\n            }\n        }\n    }\n}\n",
        "extensions/Forwarder/interfaces/IAssets.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\ncontract IAssets {\n\n    /// @dev Withdraws assets from this contract. The contract requires a ZRX balance in order to \n    ///      function optimally, and this function allows the ZRX to be withdrawn by owner. It may also be\n    ///      used to withdraw assets that were accidentally sent to this contract.\n    /// @param assetData Byte array encoded for the respective asset proxy.\n    /// @param amount Amount of ERC20 token to withdraw.\n    function withdrawAsset(\n        bytes assetData,\n        uint256 amount\n    )\n        external;\n}\n",
        "extensions/Forwarder/interfaces/IForwarderCore.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../../../protocol/Exchange/libs/LibOrder.sol\";\nimport \"../../../protocol/Exchange/libs/LibFillResults.sol\";\n\n\ncontract IForwarderCore {\n\n    /// @dev Purchases as much of orders' makerAssets as possible by selling up to 95% of transaction's ETH value.\n    ///      Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.\n    ///      5% of ETH value is reserved for paying fees to order feeRecipients (in ZRX) and forwarding contract feeRecipient (in ETH).\n    ///      Any ETH not spent will be refunded to sender.\n    /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. \n    /// @param signatures Proofs that orders have been created by makers.\n    /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.\n    /// @param feeSignatures Proofs that feeOrders have been created by makers.\n    /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.\n    /// @param feeRecipient Address that will receive ETH when orders are filled.\n    /// @return Amounts filled and fees paid by maker and taker for both sets of orders.\n    function marketSellOrdersWithEth(\n        LibOrder.Order[] memory orders,\n        bytes[] memory signatures,\n        LibOrder.Order[] memory feeOrders,\n        bytes[] memory feeSignatures,\n        uint256  feePercentage,\n        address feeRecipient\n    )\n        public\n        payable\n        returns (\n            LibFillResults.FillResults memory orderFillResults,\n            LibFillResults.FillResults memory feeOrderFillResults\n        );\n\n    /// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction.\n    ///      Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.\n    ///      Any ETH not spent will be refunded to sender.\n    /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. \n    /// @param makerAssetFillAmount Desired amount of makerAsset to purchase.\n    /// @param signatures Proofs that orders have been created by makers.\n    /// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.\n    /// @param feeSignatures Proofs that feeOrders have been created by makers.\n    /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.\n    /// @param feeRecipient Address that will receive ETH when orders are filled.\n    /// @return Amounts filled and fees paid by maker and taker for both sets of orders.\n    function marketBuyOrdersWithEth(\n        LibOrder.Order[] memory orders,\n        uint256 makerAssetFillAmount,\n        bytes[] memory signatures,\n        LibOrder.Order[] memory feeOrders,\n        bytes[] memory feeSignatures,\n        uint256  feePercentage,\n        address feeRecipient\n    )\n        public\n        payable\n        returns (\n            LibFillResults.FillResults memory orderFillResults,\n            LibFillResults.FillResults memory feeOrderFillResults\n        );\n}\n",
        "extensions/Forwarder/libs/LibConstants.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../../utils/LibBytes/LibBytes.sol\";\nimport \"../../../protocol/Exchange/interfaces/IExchange.sol\";\nimport \"../../../tokens/EtherToken/IEtherToken.sol\";\nimport \"../../../tokens/ERC20Token/IERC20Token.sol\";\n\n\ncontract LibConstants {\n\n    using LibBytes for bytes;\n\n    bytes4 constant internal ERC20_DATA_ID = bytes4(keccak256(\"ERC20Token(address)\"));\n    bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256(\"ERC721Token(address,uint256)\"));\n    uint256 constant internal MAX_UINT = 2**256 - 1;\n    uint256 constant internal PERCENTAGE_DENOMINATOR = 10**18; \n    uint256 constant internal MAX_FEE_PERCENTAGE = 5 * PERCENTAGE_DENOMINATOR / 100;         // 5%\n    uint256 constant internal MAX_WETH_FILL_PERCENTAGE = 95 * PERCENTAGE_DENOMINATOR / 100;  // 95%\n \n     // solhint-disable var-name-mixedcase\n    IExchange internal EXCHANGE;\n    IEtherToken internal ETHER_TOKEN;\n    IERC20Token internal ZRX_TOKEN;\n    bytes internal ZRX_ASSET_DATA;\n    bytes internal WETH_ASSET_DATA;\n    // solhint-enable var-name-mixedcase\n\n    constructor (\n        address _exchange,\n        bytes memory _zrxAssetData,\n        bytes memory _wethAssetData\n    )\n        public\n    {\n        EXCHANGE = IExchange(_exchange);\n        ZRX_ASSET_DATA = _zrxAssetData;\n        WETH_ASSET_DATA = _wethAssetData;\n\n        address etherToken = _wethAssetData.readAddress(16);\n        address zrxToken = _zrxAssetData.readAddress(16);\n        ETHER_TOKEN = IEtherToken(etherToken);\n        ZRX_TOKEN = IERC20Token(zrxToken);\n    }\n}\n",
        "extensions/Forwarder/mixins/MAssets.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../interfaces/IAssets.sol\";\n\n\ncontract MAssets is\n    IAssets\n{\n    /// @dev Transfers given amount of asset to sender.\n    /// @param assetData Byte array encoded for the respective asset proxy.\n    /// @param amount Amount of asset to transfer to sender.\n    function transferAssetToSender(\n        bytes memory assetData,\n        uint256 amount\n    )\n        internal;\n\n    /// @dev Decodes ERC20 assetData and transfers given amount to sender.\n    /// @param assetData Byte array encoded for the respective asset proxy.\n    /// @param amount Amount of asset to transfer to sender.\n    function transferERC20Token(\n        bytes memory assetData,\n        uint256 amount\n    )\n        internal;\n\n    /// @dev Decodes ERC721 assetData and transfers given amount to sender.\n    /// @param assetData Byte array encoded for the respective asset proxy.\n    /// @param amount Amount of asset to transfer to sender.\n    function transferERC721Token(\n        bytes memory assetData,\n        uint256 amount\n    )\n        internal;\n}\n",
        "extensions/Forwarder/mixins/MExchangeWrapper.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../../../protocol/Exchange/libs/LibOrder.sol\";\nimport \"../../../protocol/Exchange/libs/LibFillResults.sol\";\n\n\ncontract MExchangeWrapper {\n\n    /// @dev Fills the input order.\n    ///      Returns false if the transaction would otherwise revert.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    /// @return Amounts filled and fees paid by maker and taker.\n    function fillOrderNoThrow(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        internal\n        returns (LibFillResults.FillResults memory fillResults);\n\n    /// @dev Synchronously executes multiple calls of fillOrder until total amount of WETH has been sold by taker.\n    ///      Returns false if the transaction would otherwise revert.\n    /// @param orders Array of order specifications.\n    /// @param wethSellAmount Desired amount of WETH to sell.\n    /// @param signatures Proofs that orders have been signed by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function marketSellWeth(\n        LibOrder.Order[] memory orders,\n        uint256 wethSellAmount,\n        bytes[] memory signatures\n    )\n        internal\n        returns (LibFillResults.FillResults memory totalFillResults);\n\n    /// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker.\n    ///      Returns false if the transaction would otherwise revert.\n    ///      The asset being sold by taker must always be WETH.\n    /// @param orders Array of order specifications.\n    /// @param makerAssetFillAmount Desired amount of makerAsset to buy.\n    /// @param signatures Proofs that orders have been signed by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function marketBuyExactAmountWithWeth(\n        LibOrder.Order[] memory orders,\n        uint256 makerAssetFillAmount,\n        bytes[] memory signatures\n    )\n        internal\n        returns (LibFillResults.FillResults memory totalFillResults);\n\n    /// @dev Buys zrxBuyAmount of ZRX fee tokens, taking into account ZRX fees for each order. This will guarantee\n    ///      that at least zrxBuyAmount of ZRX is purchased (sometimes slightly over due to rounding issues).\n    ///      It is possible that a request to buy 200 ZRX will require purchasing 202 ZRX\n    ///      as 2 ZRX is required to purchase the 200 ZRX fee tokens. This guarantees at least 200 ZRX for future purchases.\n    ///      The asset being sold by taker must always be WETH. \n    /// @param orders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset.\n    /// @param zrxBuyAmount Desired amount of ZRX to buy.\n    /// @param signatures Proofs that orders have been created by makers.\n    /// @return totalFillResults Amounts filled and fees paid by maker and taker.\n    function marketBuyExactZrxWithWeth(\n        LibOrder.Order[] memory orders,\n        uint256 zrxBuyAmount,\n        bytes[] memory signatures\n    )\n        internal\n        returns (LibFillResults.FillResults memory totalFillResults);\n}\n",
        "extensions/Forwarder/mixins/MWeth.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\ncontract MWeth {\n\n    /// @dev Converts message call's ETH value into WETH.\n    function convertEthToWeth()\n        internal;\n\n    /// @dev Transfers feePercentage of WETH spent on primary orders to feeRecipient.\n    ///      Refunds any excess ETH to msg.sender.\n    /// @param wethSoldExcludingFeeOrders Amount of WETH sold when filling primary orders.\n    /// @param wethSoldForZrx Amount of WETH sold when purchasing ZRX required for primary order fees.\n    /// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.\n    /// @param feeRecipient Address that will receive ETH when orders are filled.\n    function transferEthFeeAndRefund(\n        uint256 wethSoldExcludingFeeOrders,\n        uint256 wethSoldForZrx,\n        uint256 feePercentage,\n        address feeRecipient\n    )\n        internal;\n}\n",
        "extensions/OrderValidator/OrderValidator.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../../protocol/Exchange/interfaces/IExchange.sol\";\nimport \"../../protocol/Exchange/libs/LibOrder.sol\";\nimport \"../../tokens/ERC20Token/IERC20Token.sol\";\nimport \"../../tokens/ERC721Token/IERC721Token.sol\";\nimport \"../../utils/LibBytes/LibBytes.sol\";\n\n\ncontract OrderValidator {\n\n    using LibBytes for bytes;\n\n    bytes4 constant internal ERC20_DATA_ID = bytes4(keccak256(\"ERC20Token(address)\"));\n    bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256(\"ERC721Token(address,uint256)\"));\n\n    struct TraderInfo {\n        uint256 makerBalance;       // Maker's balance of makerAsset\n        uint256 makerAllowance;     // Maker's allowance to corresponding AssetProxy\n        uint256 takerBalance;       // Taker's balance of takerAsset\n        uint256 takerAllowance;     // Taker's allowance to corresponding AssetProxy\n        uint256 makerZrxBalance;    // Maker's balance of ZRX\n        uint256 makerZrxAllowance;  // Maker's allowance of ZRX to ERC20Proxy\n        uint256 takerZrxBalance;    // Taker's balance of ZRX\n        uint256 takerZrxAllowance;  // Taker's allowance of ZRX to ERC20Proxy\n    }\n\n    // solhint-disable var-name-mixedcase\n    IExchange internal EXCHANGE;\n    bytes internal ZRX_ASSET_DATA;\n    // solhint-enable var-name-mixedcase\n\n    constructor (address _exchange, bytes memory _zrxAssetData)\n        public\n    {\n        EXCHANGE = IExchange(_exchange);\n        ZRX_ASSET_DATA = _zrxAssetData;\n    }\n\n    /// @dev Fetches information for order and maker/taker of order.\n    /// @param order The order structure.\n    /// @param takerAddress Address that will be filling the order.\n    /// @return OrderInfo and TraderInfo instances for given order.\n    function getOrderAndTraderInfo(LibOrder.Order memory order, address takerAddress)\n        public\n        view\n        returns (LibOrder.OrderInfo memory orderInfo, TraderInfo memory traderInfo)\n    {\n        orderInfo = EXCHANGE.getOrderInfo(order);\n        traderInfo = getTraderInfo(order, takerAddress);\n        return (orderInfo, traderInfo);\n    }\n\n    /// @dev Fetches information for all passed in orders and the makers/takers of each order.\n    /// @param orders Array of order specifications.\n    /// @param takerAddresses Array of taker addresses corresponding to each order.\n    /// @return Arrays of OrderInfo and TraderInfo instances that correspond to each order.\n    function getOrdersAndTradersInfo(LibOrder.Order[] memory orders, address[] memory takerAddresses)\n        public\n        view\n        returns (LibOrder.OrderInfo[] memory ordersInfo, TraderInfo[] memory tradersInfo)\n    {\n        ordersInfo = EXCHANGE.getOrdersInfo(orders);\n        tradersInfo = getTradersInfo(orders, takerAddresses);\n        return (ordersInfo, tradersInfo);\n    }\n\n    /// @dev Fetches balance and allowances for maker and taker of order.\n    /// @param order The order structure.\n    /// @param takerAddress Address that will be filling the order.\n    /// @return Balances and allowances of maker and taker of order.\n    function getTraderInfo(LibOrder.Order memory order, address takerAddress)\n        public\n        view\n        returns (TraderInfo memory traderInfo)\n    {\n        (traderInfo.makerBalance, traderInfo.makerAllowance) = getBalanceAndAllowance(order.makerAddress, order.makerAssetData);\n        (traderInfo.takerBalance, traderInfo.takerAllowance) = getBalanceAndAllowance(takerAddress, order.takerAssetData);\n        bytes memory zrxAssetData = ZRX_ASSET_DATA;\n        (traderInfo.makerZrxBalance, traderInfo.makerZrxAllowance) = getBalanceAndAllowance(order.makerAddress, zrxAssetData);\n        (traderInfo.takerZrxBalance, traderInfo.takerZrxAllowance) = getBalanceAndAllowance(takerAddress, zrxAssetData);\n        return traderInfo;\n    }\n\n    /// @dev Fetches balances and allowances of maker and taker for each provided order.\n    /// @param orders Array of order specifications.\n    /// @param takerAddresses Array of taker addresses corresponding to each order.\n    /// @return Array of balances and allowances for maker and taker of each order.\n    function getTradersInfo(LibOrder.Order[] memory orders, address[] memory takerAddresses)\n        public\n        view\n        returns (TraderInfo[] memory)\n    {\n        uint256 ordersLength = orders.length;\n        TraderInfo[] memory tradersInfo = new TraderInfo[](ordersLength);\n        for (uint256 i = 0; i != ordersLength; i++) {\n            tradersInfo[i] = getTraderInfo(orders[i], takerAddresses[i]);\n        }\n        return tradersInfo;\n    }\n\n    /// @dev Fetches token balances and allowances of an address to given assetProxy. Supports ERC20 and ERC721.\n    /// @param target Address to fetch balances and allowances of.\n    /// @param assetData Encoded data that can be decoded by a specified proxy contract when transferring asset.\n    /// @return Balance of asset and allowance set to given proxy of asset.\n    ///         For ERC721 tokens, these values will always be 1 or 0.\n    function getBalanceAndAllowance(address target, bytes memory assetData)\n        public\n        view\n        returns (uint256 balance, uint256 allowance)\n    {\n        bytes4 assetProxyId = assetData.readBytes4(0);\n        address token = assetData.readAddress(16);\n        address assetProxy = EXCHANGE.getAssetProxy(assetProxyId);\n\n        if (assetProxyId == ERC20_DATA_ID) {\n            // Query balance\n            balance = IERC20Token(token).balanceOf(target);\n\n            // Query allowance\n            allowance = IERC20Token(token).allowance(target, assetProxy);\n        } else if (assetProxyId == ERC721_DATA_ID) {\n            uint256 tokenId = assetData.readUint256(36);\n\n            // Query owner of tokenId\n            address owner = getERC721TokenOwner(token, tokenId);\n\n            // Set balance to 1 if tokenId is owned by target\n            balance = target == owner ? 1 : 0;\n\n            // Check if ERC721Proxy is approved to spend tokenId\n            bool isApproved = IERC721Token(token).isApprovedForAll(target, assetProxy) || IERC721Token(token).getApproved(tokenId) == assetProxy;\n            \n            // Set alowance to 1 if ERC721Proxy is approved to spend tokenId\n            allowance = isApproved ? 1 : 0;\n        } else {\n            revert(\"UNSUPPORTED_ASSET_PROXY\");\n        }\n        return (balance, allowance);\n    }\n\n    /// @dev Fetches token balances and allowances of an address for each given assetProxy. Supports ERC20 and ERC721.\n    /// @param target Address to fetch balances and allowances of.\n    /// @param assetData Array of encoded byte arrays that can be decoded by a specified proxy contract when transferring asset.\n    /// @return Balances and allowances of assets.\n    ///         For ERC721 tokens, these values will always be 1 or 0.\n    function getBalancesAndAllowances(address target, bytes[] memory assetData)\n        public\n        view\n        returns (uint256[] memory, uint256[] memory)\n    {\n        uint256 length = assetData.length;\n        uint256[] memory balances = new uint256[](length);\n        uint256[] memory allowances = new uint256[](length);\n        for (uint256 i = 0; i != length; i++) {\n            (balances[i], allowances[i]) = getBalanceAndAllowance(target, assetData[i]);\n        }\n        return (balances, allowances);\n    }\n\n    /// @dev Calls `token.ownerOf(tokenId)`, but returns a null owner instead of reverting on an unowned token.\n    /// @param token Address of ERC721 token.\n    /// @param tokenId The identifier for the specific NFT.\n    /// @return Owner of tokenId or null address if unowned.\n    function getERC721TokenOwner(address token, uint256 tokenId)\n        public\n        view\n        returns (address owner)\n    {\n        assembly {\n            // load free memory pointer\n            let cdStart := mload(64)\n\n            // bytes4(keccak256(ownerOf(uint256))) = 0x6352211e\n            mstore(cdStart, 0x6352211e00000000000000000000000000000000000000000000000000000000)\n            mstore(add(cdStart, 4), tokenId)\n\n            // staticcall `ownerOf(tokenId)`\n            // `ownerOf` will revert if tokenId is not owned\n            let success := staticcall(\n                gas,      // forward all gas\n                token,    // call token contract\n                cdStart,  // start of calldata\n                36,       // length of input is 36 bytes\n                cdStart,  // write output over input\n                32        // size of output is 32 bytes\n            )\n\n            // Success implies that tokenId is owned\n            // Copy owner from return data if successful\n            if success {\n                owner := mload(cdStart)\n            }    \n        }\n\n        // Owner initialized to address(0), no need to modify if call is unsuccessful\n        return owner;\n    }\n}\n",
        "multisig/MultiSigWallet.sol": "// solhint-disable\npragma solidity ^0.4.15;\n\n\n/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.\n/// @author Stefan George - <stefan.george@consensys.net>\ncontract MultiSigWallet {\n\n    /*\n     *  Events\n     */\n    event Confirmation(address indexed sender, uint indexed transactionId);\n    event Revocation(address indexed sender, uint indexed transactionId);\n    event Submission(uint indexed transactionId);\n    event Execution(uint indexed transactionId);\n    event ExecutionFailure(uint indexed transactionId);\n    event Deposit(address indexed sender, uint value);\n    event OwnerAddition(address indexed owner);\n    event OwnerRemoval(address indexed owner);\n    event RequirementChange(uint required);\n\n    /*\n     *  Constants\n     */\n    uint constant public MAX_OWNER_COUNT = 50;\n\n    /*\n     *  Storage\n     */\n    mapping (uint => Transaction) public transactions;\n    mapping (uint => mapping (address => bool)) public confirmations;\n    mapping (address => bool) public isOwner;\n    address[] public owners;\n    uint public required;\n    uint public transactionCount;\n\n    struct Transaction {\n        address destination;\n        uint value;\n        bytes data;\n        bool executed;\n    }\n\n    /*\n     *  Modifiers\n     */\n    modifier onlyWallet() {\n        require(msg.sender == address(this));\n        _;\n    }\n\n    modifier ownerDoesNotExist(address owner) {\n        require(!isOwner[owner]);\n        _;\n    }\n\n    modifier ownerExists(address owner) {\n        require(isOwner[owner]);\n        _;\n    }\n\n    modifier transactionExists(uint transactionId) {\n        require(transactions[transactionId].destination != 0);\n        _;\n    }\n\n    modifier confirmed(uint transactionId, address owner) {\n        require(confirmations[transactionId][owner]);\n        _;\n    }\n\n    modifier notConfirmed(uint transactionId, address owner) {\n        require(!confirmations[transactionId][owner]);\n        _;\n    }\n\n    modifier notExecuted(uint transactionId) {\n        require(!transactions[transactionId].executed);\n        _;\n    }\n\n    modifier notNull(address _address) {\n        require(_address != 0);\n        _;\n    }\n\n    modifier validRequirement(uint ownerCount, uint _required) {\n        require(ownerCount <= MAX_OWNER_COUNT\n            && _required <= ownerCount\n            && _required != 0\n            && ownerCount != 0);\n        _;\n    }\n\n    /// @dev Fallback function allows to deposit ether.\n    function()\n        payable\n    {\n        if (msg.value > 0)\n            Deposit(msg.sender, msg.value);\n    }\n\n    /*\n     * Public functions\n     */\n    /// @dev Contract constructor sets initial owners and required number of confirmations.\n    /// @param _owners List of initial owners.\n    /// @param _required Number of required confirmations.\n    function MultiSigWallet(address[] _owners, uint _required)\n        public\n        validRequirement(_owners.length, _required)\n    {\n        for (uint i=0; i<_owners.length; i++) {\n            require(!isOwner[_owners[i]] && _owners[i] != 0);\n            isOwner[_owners[i]] = true;\n        }\n        owners = _owners;\n        required = _required;\n    }\n\n    /// @dev Allows to add a new owner. Transaction has to be sent by wallet.\n    /// @param owner Address of new owner.\n    function addOwner(address owner)\n        public\n        onlyWallet\n        ownerDoesNotExist(owner)\n        notNull(owner)\n        validRequirement(owners.length + 1, required)\n    {\n        isOwner[owner] = true;\n        owners.push(owner);\n        OwnerAddition(owner);\n    }\n\n    /// @dev Allows to remove an owner. Transaction has to be sent by wallet.\n    /// @param owner Address of owner.\n    function removeOwner(address owner)\n        public\n        onlyWallet\n        ownerExists(owner)\n    {\n        isOwner[owner] = false;\n        for (uint i=0; i<owners.length - 1; i++)\n            if (owners[i] == owner) {\n                owners[i] = owners[owners.length - 1];\n                break;\n            }\n        owners.length -= 1;\n        if (required > owners.length)\n            changeRequirement(owners.length);\n        OwnerRemoval(owner);\n    }\n\n    /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.\n    /// @param owner Address of owner to be replaced.\n    /// @param newOwner Address of new owner.\n    function replaceOwner(address owner, address newOwner)\n        public\n        onlyWallet\n        ownerExists(owner)\n        ownerDoesNotExist(newOwner)\n    {\n        for (uint i=0; i<owners.length; i++)\n            if (owners[i] == owner) {\n                owners[i] = newOwner;\n                break;\n            }\n        isOwner[owner] = false;\n        isOwner[newOwner] = true;\n        OwnerRemoval(owner);\n        OwnerAddition(newOwner);\n    }\n\n    /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.\n    /// @param _required Number of required confirmations.\n    function changeRequirement(uint _required)\n        public\n        onlyWallet\n        validRequirement(owners.length, _required)\n    {\n        required = _required;\n        RequirementChange(_required);\n    }\n\n    /// @dev Allows an owner to submit and confirm a transaction.\n    /// @param destination Transaction target address.\n    /// @param value Transaction ether value.\n    /// @param data Transaction data payload.\n    /// @return Returns transaction ID.\n    function submitTransaction(address destination, uint value, bytes data)\n        public\n        returns (uint transactionId)\n    {\n        transactionId = addTransaction(destination, value, data);\n        confirmTransaction(transactionId);\n    }\n\n    /// @dev Allows an owner to confirm a transaction.\n    /// @param transactionId Transaction ID.\n    function confirmTransaction(uint transactionId)\n        public\n        ownerExists(msg.sender)\n        transactionExists(transactionId)\n        notConfirmed(transactionId, msg.sender)\n    {\n        confirmations[transactionId][msg.sender] = true;\n        Confirmation(msg.sender, transactionId);\n        executeTransaction(transactionId);\n    }\n\n    /// @dev Allows an owner to revoke a confirmation for a transaction.\n    /// @param transactionId Transaction ID.\n    function revokeConfirmation(uint transactionId)\n        public\n        ownerExists(msg.sender)\n        confirmed(transactionId, msg.sender)\n        notExecuted(transactionId)\n    {\n        confirmations[transactionId][msg.sender] = false;\n        Revocation(msg.sender, transactionId);\n    }\n\n    /// @dev Allows anyone to execute a confirmed transaction.\n    /// @param transactionId Transaction ID.\n    function executeTransaction(uint transactionId)\n        public\n        ownerExists(msg.sender)\n        confirmed(transactionId, msg.sender)\n        notExecuted(transactionId)\n    {\n        if (isConfirmed(transactionId)) {\n            Transaction storage txn = transactions[transactionId];\n            txn.executed = true;\n            if (external_call(txn.destination, txn.value, txn.data.length, txn.data))\n                Execution(transactionId);\n            else {\n                ExecutionFailure(transactionId);\n                txn.executed = false;\n            }\n        }\n    }\n\n    // call has been separated into its own function in order to take advantage\n    // of the Solidity's code generator to produce a loop that copies tx.data into memory.\n    function external_call(address destination, uint value, uint dataLength, bytes data) internal returns (bool) {\n        bool result;\n        assembly {\n            let x := mload(0x40)   // \"Allocate\" memory for output (0x40 is where \"free memory\" pointer is stored by convention)\n            let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that\n            result := call(\n                sub(gas, 34710),   // 34710 is the value that solidity is currently emitting\n                                   // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) +\n                                   // callNewAccountGas (25000, in case the destination address does not exist and needs creating)\n                destination,\n                value,\n                d,\n                dataLength,        // Size of the input (in bytes) - this is what fixes the padding problem\n                x,\n                0                  // Output is ignored, therefore the output size is zero\n            )\n        }\n        return result;\n    }\n\n    /// @dev Returns the confirmation status of a transaction.\n    /// @param transactionId Transaction ID.\n    /// @return Confirmation status.\n    function isConfirmed(uint transactionId)\n        public\n        constant\n        returns (bool)\n    {\n        uint count = 0;\n        for (uint i=0; i<owners.length; i++) {\n            if (confirmations[transactionId][owners[i]])\n                count += 1;\n            if (count == required)\n                return true;\n        }\n    }\n\n    /*\n     * Internal functions\n     */\n    /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.\n    /// @param destination Transaction target address.\n    /// @param value Transaction ether value.\n    /// @param data Transaction data payload.\n    /// @return Returns transaction ID.\n    function addTransaction(address destination, uint value, bytes data)\n        internal\n        notNull(destination)\n        returns (uint transactionId)\n    {\n        transactionId = transactionCount;\n        transactions[transactionId] = Transaction({\n            destination: destination,\n            value: value,\n            data: data,\n            executed: false\n        });\n        transactionCount += 1;\n        Submission(transactionId);\n    }\n\n    /*\n     * Web3 call functions\n     */\n    /// @dev Returns number of confirmations of a transaction.\n    /// @param transactionId Transaction ID.\n    /// @return Number of confirmations.\n    function getConfirmationCount(uint transactionId)\n        public\n        constant\n        returns (uint count)\n    {\n        for (uint i=0; i<owners.length; i++)\n            if (confirmations[transactionId][owners[i]])\n                count += 1;\n    }\n\n    /// @dev Returns total number of transactions after filers are applied.\n    /// @param pending Include pending transactions.\n    /// @param executed Include executed transactions.\n    /// @return Total number of transactions after filters are applied.\n    function getTransactionCount(bool pending, bool executed)\n        public\n        constant\n        returns (uint count)\n    {\n        for (uint i=0; i<transactionCount; i++)\n            if (   pending && !transactions[i].executed\n                || executed && transactions[i].executed)\n                count += 1;\n    }\n\n    /// @dev Returns list of owners.\n    /// @return List of owner addresses.\n    function getOwners()\n        public\n        constant\n        returns (address[])\n    {\n        return owners;\n    }\n\n    /// @dev Returns array with owner addresses, which confirmed transaction.\n    /// @param transactionId Transaction ID.\n    /// @return Returns array of owner addresses.\n    function getConfirmations(uint transactionId)\n        public\n        constant\n        returns (address[] _confirmations)\n    {\n        address[] memory confirmationsTemp = new address[](owners.length);\n        uint count = 0;\n        uint i;\n        for (i=0; i<owners.length; i++)\n            if (confirmations[transactionId][owners[i]]) {\n                confirmationsTemp[count] = owners[i];\n                count += 1;\n            }\n        _confirmations = new address[](count);\n        for (i=0; i<count; i++)\n            _confirmations[i] = confirmationsTemp[i];\n    }\n\n    /// @dev Returns list of transaction IDs in defined range.\n    /// @param from Index start position of transaction array.\n    /// @param to Index end position of transaction array.\n    /// @param pending Include pending transactions.\n    /// @param executed Include executed transactions.\n    /// @return Returns array of transaction IDs.\n    function getTransactionIds(uint from, uint to, bool pending, bool executed)\n        public\n        constant\n        returns (uint[] _transactionIds)\n    {\n        uint[] memory transactionIdsTemp = new uint[](transactionCount);\n        uint count = 0;\n        uint i;\n        for (i=0; i<transactionCount; i++)\n            if (   pending && !transactions[i].executed\n                || executed && transactions[i].executed)\n            {\n                transactionIdsTemp[count] = i;\n                count += 1;\n            }\n        _transactionIds = new uint[](to - from);\n        for (i=from; i<to; i++)\n            _transactionIds[i - from] = transactionIdsTemp[i];\n    }\n}",
        "multisig/MultiSigWalletWithTimeLock.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"./MultiSigWallet.sol\";\n\n\n/// @title Multisignature wallet with time lock- Allows multiple parties to execute a transaction after a time lock has passed.\n/// @author Amir Bandeali - <amir@0xProject.com>\n// solhint-disable not-rely-on-time\ncontract MultiSigWalletWithTimeLock is\n    MultiSigWallet\n{\n    event ConfirmationTimeSet(uint256 indexed transactionId, uint256 confirmationTime);\n    event TimeLockChange(uint256 secondsTimeLocked);\n\n    uint256 public secondsTimeLocked;\n\n    mapping (uint256 => uint256) public confirmationTimes;\n\n    modifier notFullyConfirmed(uint256 transactionId) {\n        require(\n            !isConfirmed(transactionId),\n            \"TX_FULLY_CONFIRMED\"\n        );\n        _;\n    }\n\n    modifier fullyConfirmed(uint256 transactionId) {\n        require(\n            isConfirmed(transactionId),\n            \"TX_NOT_FULLY_CONFIRMED\"\n        );\n        _;\n    }\n\n    modifier pastTimeLock(uint256 transactionId) {\n        require(\n            block.timestamp >= confirmationTimes[transactionId] + secondsTimeLocked,\n            \"TIME_LOCK_INCOMPLETE\"\n        );\n        _;\n    }\n\n    /// @dev Contract constructor sets initial owners, required number of confirmations, and time lock.\n    /// @param _owners List of initial owners.\n    /// @param _required Number of required confirmations.\n    /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds.\n    constructor (\n        address[] _owners,\n        uint256 _required,\n        uint256 _secondsTimeLocked\n    )\n        public\n        MultiSigWallet(_owners, _required)\n    {\n        secondsTimeLocked = _secondsTimeLocked;\n    }\n\n    /// @dev Changes the duration of the time lock for transactions.\n    /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds.\n    function changeTimeLock(uint256 _secondsTimeLocked)\n        public\n        onlyWallet\n    {\n        secondsTimeLocked = _secondsTimeLocked;\n        emit TimeLockChange(_secondsTimeLocked);\n    }\n\n    /// @dev Allows an owner to confirm a transaction.\n    /// @param transactionId Transaction ID.\n    function confirmTransaction(uint256 transactionId)\n        public\n        ownerExists(msg.sender)\n        transactionExists(transactionId)\n        notConfirmed(transactionId, msg.sender)\n        notFullyConfirmed(transactionId)\n    {\n        confirmations[transactionId][msg.sender] = true;\n        emit Confirmation(msg.sender, transactionId);\n        if (isConfirmed(transactionId)) {\n            setConfirmationTime(transactionId, block.timestamp);\n        }\n    }\n\n    /// @dev Allows anyone to execute a confirmed transaction.\n    /// @param transactionId Transaction ID.\n    function executeTransaction(uint256 transactionId)\n        public\n        notExecuted(transactionId)\n        fullyConfirmed(transactionId)\n        pastTimeLock(transactionId)\n    {\n        Transaction storage txn = transactions[transactionId];\n        txn.executed = true;\n        if (external_call(txn.destination, txn.value, txn.data.length, txn.data)) {\n            emit Execution(transactionId);\n        } else {\n            emit ExecutionFailure(transactionId);\n            txn.executed = false;\n        }\n    }\n\n    /// @dev Sets the time of when a submission first passed.\n    function setConfirmationTime(uint256 transactionId, uint256 confirmationTime)\n        internal\n    {\n        confirmationTimes[transactionId] = confirmationTime;\n        emit ConfirmationTimeSet(transactionId, confirmationTime);\n    }\n}\n",
        "protocol/AssetProxy/ERC20Proxy.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"./MixinAuthorizable.sol\";\n\n\ncontract ERC20Proxy is\n    MixinAuthorizable\n{\n    // Id of this proxy.\n    bytes4 constant internal PROXY_ID = bytes4(keccak256(\"ERC20Token(address)\"));\n    \n    // solhint-disable-next-line payable-fallback\n    function () \n        external\n    {\n        assembly {\n            // The first 4 bytes of calldata holds the function selector\n            let selector := and(calldataload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000)\n\n            // `transferFrom` will be called with the following parameters:\n            // assetData Encoded byte array.\n            // from Address to transfer asset from.\n            // to Address to transfer asset to.\n            // amount Amount of asset to transfer.\n            // bytes4(keccak256(\"transferFrom(bytes,address,address,uint256)\")) = 0xa85e59e4\n            if eq(selector, 0xa85e59e400000000000000000000000000000000000000000000000000000000) {\n\n                // To lookup a value in a mapping, we load from the storage location keccak256(k, p),\n                // where k is the key left padded to 32 bytes and p is the storage slot\n                let start := mload(64)\n                mstore(start, and(caller, 0xffffffffffffffffffffffffffffffffffffffff))\n                mstore(add(start, 32), authorized_slot)\n\n                // Revert if authorized[msg.sender] == false\n                if iszero(sload(keccak256(start, 64))) {\n                    // Revert with `Error(\"SENDER_NOT_AUTHORIZED\")`\n                    mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)\n                    mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)\n                    mstore(64, 0x0000001553454e4445525f4e4f545f415554484f52495a454400000000000000)\n                    mstore(96, 0)\n                    revert(0, 100)\n                }\n\n                // `transferFrom`.\n                // The function is marked `external`, so no abi decodeding is done for\n                // us. Instead, we expect the `calldata` memory to contain the\n                // following:\n                //\n                // | Area     | Offset | Length  | Contents                            |\n                // |----------|--------|---------|-------------------------------------|\n                // | Header   | 0      | 4       | function selector                   |\n                // | Params   |        | 4 * 32  | function parameters:                |\n                // |          | 4      |         |   1. offset to assetData (*)        |\n                // |          | 36     |         |   2. from                           |\n                // |          | 68     |         |   3. to                             |\n                // |          | 100    |         |   4. amount                         |\n                // | Data     |        |         | assetData:                          |\n                // |          | 132    | 32      | assetData Length                    |\n                // |          | 164    | **      | assetData Contents                  |\n                //\n                // (*): offset is computed from start of function parameters, so offset\n                //      by an additional 4 bytes in the calldata.\n                //\n                // (**): see table below to compute length of assetData Contents\n                //\n                // WARNING: The ABIv2 specification allows additional padding between\n                //          the Params and Data section. This will result in a larger\n                //          offset to assetData.\n\n                // Asset data itself is encoded as follows:\n                //\n                // | Area     | Offset | Length  | Contents                            |\n                // |----------|--------|---------|-------------------------------------|\n                // | Header   | 0      | 4       | function selector                   |\n                // | Params   |        | 1 * 32  | function parameters:                |\n                // |          | 4      | 12 + 20 |   1. token address                  |\n\n                // We construct calldata for the `token.transferFrom` ABI.\n                // The layout of this calldata is in the table below.\n                //\n                // | Area     | Offset | Length  | Contents                            |\n                // |----------|--------|---------|-------------------------------------|\n                // | Header   | 0      | 4       | function selector                   |\n                // | Params   |        | 3 * 32  | function parameters:                |\n                // |          | 4      |         |   1. from                           |\n                // |          | 36     |         |   2. to                             |\n                // |          | 68     |         |   3. amount                         |\n\n                /////// Read token address from calldata ///////\n                // * The token address is stored in `assetData`.\n                //\n                // * The \"offset to assetData\" is stored at offset 4 in the calldata (table 1).\n                //   [assetDataOffsetFromParams = calldataload(4)]\n                //\n                // * Notes that the \"offset to assetData\" is relative to the \"Params\" area of calldata;\n                //   add 4 bytes to account for the length of the \"Header\" area (table 1).\n                //   [assetDataOffsetFromHeader = assetDataOffsetFromParams + 4]\n                //\n                // * The \"token address\" is offset 32+4=36 bytes into \"assetData\" (tables 1 & 2).\n                //   [tokenOffset = assetDataOffsetFromHeader + 36 = calldataload(4) + 4 + 36]\n                let token := calldataload(add(calldataload(4), 40))\n                \n                /////// Setup Header Area ///////\n                // This area holds the 4-byte `transferFrom` selector.\n                // Any trailing data in transferFromSelector will be\n                // overwritten in the next `mstore` call.\n                mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n                \n                /////// Setup Params Area ///////\n                // We copy the fields `from`, `to` and `amount` in bulk\n                // from our own calldata to the new calldata.\n                calldatacopy(4, 36, 96)\n\n                /////// Call `token.transferFrom` using the calldata ///////\n                let success := call(\n                    gas,            // forward all gas\n                    token,          // call address of token contract\n                    0,              // don't send any ETH\n                    0,              // pointer to start of input\n                    100,            // length of input\n                    0,              // write output over input\n                    32              // output size should be 32 bytes\n                )\n\n                /////// Check return data. ///////\n                // If there is no return data, we assume the token incorrectly\n                // does not return a bool. In this case we expect it to revert\n                // on failure, which was handled above.\n                // If the token does return data, we require that it is a single\n                // nonzero 32 bytes value.\n                // So the transfer succeeded if the call succeeded and either\n                // returned nothing, or returned a non-zero 32 byte value. \n                success := and(success, or(\n                    iszero(returndatasize),\n                    and(\n                        eq(returndatasize, 32),\n                        gt(mload(0), 0)\n                    )\n                ))\n                if success {\n                    return(0, 0)\n                }\n                \n                // Revert with `Error(\"TRANSFER_FAILED\")`\n                mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)\n                mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)\n                mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)\n                mstore(96, 0)\n                revert(0, 100)\n            }\n\n            // Revert if undefined function is called\n            revert(0, 0)\n        }\n    }\n\n    /// @dev Gets the proxy id associated with the proxy address.\n    /// @return Proxy id.\n    function getProxyId()\n        external\n        pure\n        returns (bytes4)\n    {\n        return PROXY_ID;\n    }\n}\n",
        "protocol/AssetProxy/ERC721Proxy.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"./MixinAuthorizable.sol\";\n\n\ncontract ERC721Proxy is\n    MixinAuthorizable\n{\n    // Id of this proxy.\n    bytes4 constant internal PROXY_ID = bytes4(keccak256(\"ERC721Token(address,uint256)\"));\n\n    // solhint-disable-next-line payable-fallback\n    function () \n        external\n    {\n        assembly {\n            // The first 4 bytes of calldata holds the function selector\n            let selector := and(calldataload(0), 0xffffffff00000000000000000000000000000000000000000000000000000000)\n\n            // `transferFrom` will be called with the following parameters:\n            // assetData Encoded byte array.\n            // from Address to transfer asset from.\n            // to Address to transfer asset to.\n            // amount Amount of asset to transfer.\n            // bytes4(keccak256(\"transferFrom(bytes,address,address,uint256)\")) = 0xa85e59e4\n            if eq(selector, 0xa85e59e400000000000000000000000000000000000000000000000000000000) {\n\n                // To lookup a value in a mapping, we load from the storage location keccak256(k, p),\n                // where k is the key left padded to 32 bytes and p is the storage slot\n                let start := mload(64)\n                mstore(start, and(caller, 0xffffffffffffffffffffffffffffffffffffffff))\n                mstore(add(start, 32), authorized_slot)\n\n                // Revert if authorized[msg.sender] == false\n                if iszero(sload(keccak256(start, 64))) {\n                    // Revert with `Error(\"SENDER_NOT_AUTHORIZED\")`\n                    mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)\n                    mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)\n                    mstore(64, 0x0000001553454e4445525f4e4f545f415554484f52495a454400000000000000)\n                    mstore(96, 0)\n                    revert(0, 100)\n                }\n\n                // `transferFrom`.\n                // The function is marked `external`, so no abi decodeding is done for\n                // us. Instead, we expect the `calldata` memory to contain the\n                // following:\n                //\n                // | Area     | Offset | Length  | Contents                            |\n                // |----------|--------|---------|-------------------------------------|\n                // | Header   | 0      | 4       | function selector                   |\n                // | Params   |        | 4 * 32  | function parameters:                |\n                // |          | 4      |         |   1. offset to assetData (*)        |\n                // |          | 36     |         |   2. from                           |\n                // |          | 68     |         |   3. to                             |\n                // |          | 100    |         |   4. amount                         |\n                // | Data     |        |         | assetData:                          |\n                // |          | 132    | 32      | assetData Length                    |\n                // |          | 164    | **      | assetData Contents                  |\n                //\n                // (*): offset is computed from start of function parameters, so offset\n                //      by an additional 4 bytes in the calldata.\n                //\n                // (**): see table below to compute length of assetData Contents\n                //\n                // WARNING: The ABIv2 specification allows additional padding between\n                //          the Params and Data section. This will result in a larger\n                //          offset to assetData.\n\n                // Asset data itself is encoded as follows:\n                //\n                // | Area     | Offset | Length  | Contents                            |\n                // |----------|--------|---------|-------------------------------------|\n                // | Header   | 0      | 4       | function selector                   |\n                // | Params   |        | 2 * 32  | function parameters:                |\n                // |          | 4      | 12 + 20 |   1. token address                  |\n                // |          | 36     |         |   2. tokenId                        |\n                \n                // We construct calldata for the `token.transferFrom` ABI.\n                // The layout of this calldata is in the table below.\n                // \n                // | Area     | Offset | Length  | Contents                            |\n                // |----------|--------|---------|-------------------------------------|\n                // | Header   | 0      | 4       | function selector                   |\n                // | Params   |        | 3 * 32  | function parameters:                |\n                // |          | 4      |         |   1. from                           |\n                // |          | 36     |         |   2. to                             |\n                // |          | 68     |         |   3. tokenId                        |\n\n                // There exists only 1 of each token.\n                // require(amount == 1, \"INVALID_AMOUNT\")\n                if sub(calldataload(100), 1) {\n                    // Revert with `Error(\"INVALID_AMOUNT\")`\n                    mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)\n                    mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)\n                    mstore(64, 0x0000000e494e56414c49445f414d4f554e540000000000000000000000000000)\n                    mstore(96, 0)\n                    revert(0, 100)\n                }\n\n                /////// Setup Header Area ///////\n                // This area holds the 4-byte `transferFrom` selector.\n                // Any trailing data in transferFromSelector will be\n                // overwritten in the next `mstore` call.\n                mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n                \n                /////// Setup Params Area ///////\n                // We copy the fields `from` and `to` in bulk\n                // from our own calldata to the new calldata.\n                calldatacopy(4, 36, 64)\n\n                // Copy `tokenId` field from our own calldata to the new calldata.\n                let assetDataOffset := calldataload(4)\n                calldatacopy(68, add(assetDataOffset, 72), 32)\n\n                /////// Call `token.transferFrom` using the calldata ///////\n                let token := calldataload(add(assetDataOffset, 40))\n                let success := call(\n                    gas,            // forward all gas\n                    token,          // call address of token contract\n                    0,              // don't send any ETH\n                    0,              // pointer to start of input\n                    100,            // length of input\n                    0,              // write output to null\n                    0               // output size is 0 bytes\n                )\n                if success {\n                    return(0, 0)\n                }\n                \n                // Revert with `Error(\"TRANSFER_FAILED\")`\n                mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)\n                mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)\n                mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000)\n                mstore(96, 0)\n                revert(0, 100)\n            }\n\n            // Revert if undefined function is called\n            revert(0, 0)\n        }\n    }\n\n    /// @dev Gets the proxy id associated with the proxy address.\n    /// @return Proxy id.\n    function getProxyId()\n        external\n        pure\n        returns (bytes4)\n    {\n        return PROXY_ID;\n    }\n}\n",
        "protocol/AssetProxy/MixinAuthorizable.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../utils/Ownable/Ownable.sol\";\nimport \"./mixins/MAuthorizable.sol\";\n\n\ncontract MixinAuthorizable is\n    Ownable,\n    MAuthorizable\n{\n    /// @dev Only authorized addresses can invoke functions with this modifier.\n    modifier onlyAuthorized {\n        require(\n            authorized[msg.sender],\n            \"SENDER_NOT_AUTHORIZED\"\n        );\n        _;\n    }\n\n    mapping (address => bool) public authorized;\n    address[] public authorities;\n\n    /// @dev Authorizes an address.\n    /// @param target Address to authorize.\n    function addAuthorizedAddress(address target)\n        external\n        onlyOwner\n    {\n        require(\n            !authorized[target],\n            \"TARGET_ALREADY_AUTHORIZED\"\n        );\n\n        authorized[target] = true;\n        authorities.push(target);\n        emit AuthorizedAddressAdded(target, msg.sender);\n    }\n\n    /// @dev Removes authorizion of an address.\n    /// @param target Address to remove authorization from.\n    function removeAuthorizedAddress(address target)\n        external\n        onlyOwner\n    {\n        require(\n            authorized[target],\n            \"TARGET_NOT_AUTHORIZED\"\n        );\n\n        delete authorized[target];\n        for (uint256 i = 0; i < authorities.length; i++) {\n            if (authorities[i] == target) {\n                authorities[i] = authorities[authorities.length - 1];\n                authorities.length -= 1;\n                break;\n            }\n        }\n        emit AuthorizedAddressRemoved(target, msg.sender);\n    }\n\n    /// @dev Removes authorizion of an address.\n    /// @param target Address to remove authorization from.\n    /// @param index Index of target in authorities array.\n    function removeAuthorizedAddressAtIndex(\n        address target,\n        uint256 index\n    )\n        external\n        onlyOwner\n    {\n        require(\n            authorized[target],\n            \"TARGET_NOT_AUTHORIZED\"\n        );\n        require(\n            index < authorities.length,\n            \"INDEX_OUT_OF_BOUNDS\"\n        );\n        require(\n            authorities[index] == target,\n            \"AUTHORIZED_ADDRESS_MISMATCH\"\n        );\n\n        delete authorized[target];\n        authorities[index] = authorities[authorities.length - 1];\n        authorities.length -= 1;\n        emit AuthorizedAddressRemoved(target, msg.sender);\n    }\n\n    /// @dev Gets all authorized addresses.\n    /// @return Array of authorized addresses.\n    function getAuthorizedAddresses()\n        external\n        view\n        returns (address[] memory)\n    {\n        return authorities;\n    }\n}\n",
        "protocol/AssetProxy/interfaces/IAssetData.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\n// solhint-disable\npragma solidity 0.4.24;\n\n\n// @dev Interface of the asset proxy's assetData.\n// The asset proxies take an ABI encoded `bytes assetData` as argument.\n// This argument is ABI encoded as one of the methods of this interface.\ninterface IAssetData {\n\n    function ERC20Token(address tokenContract)\n        external\n        pure;\n    \n    function ERC721Token(\n        address tokenContract,\n        uint256 tokenId,\n        bytes receiverData\n    )\n        external\n        pure;\n    \n}\n",
        "protocol/AssetProxy/interfaces/IAssetProxy.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"./IAuthorizable.sol\";\n\n\ncontract IAssetProxy is\n    IAuthorizable\n{\n    /// @dev Transfers assets. Either succeeds or throws.\n    /// @param assetData Byte array encoded for the respective asset proxy.\n    /// @param from Address to transfer asset from.\n    /// @param to Address to transfer asset to.\n    /// @param amount Amount of asset to transfer.\n    function transferFrom(\n        bytes assetData,\n        address from,\n        address to,\n        uint256 amount\n    )\n        external;\n    \n    /// @dev Gets the proxy id associated with the proxy address.\n    /// @return Proxy id.\n    function getProxyId()\n        external\n        pure\n        returns (bytes4);\n}\n",
        "protocol/AssetProxy/interfaces/IAuthorizable.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../../utils/Ownable/IOwnable.sol\";\n\n\ncontract IAuthorizable is\n    IOwnable\n{\n    /// @dev Authorizes an address.\n    /// @param target Address to authorize.\n    function addAuthorizedAddress(address target)\n        external;\n\n    /// @dev Removes authorizion of an address.\n    /// @param target Address to remove authorization from.\n    function removeAuthorizedAddress(address target)\n        external;\n\n    /// @dev Removes authorizion of an address.\n    /// @param target Address to remove authorization from.\n    /// @param index Index of target in authorities array.\n    function removeAuthorizedAddressAtIndex(\n        address target,\n        uint256 index\n    )\n        external;\n    \n    /// @dev Gets all authorized addresses.\n    /// @return Array of authorized addresses.\n    function getAuthorizedAddresses()\n        external\n        view\n        returns (address[] memory);\n}\n",
        "protocol/AssetProxy/mixins/MAuthorizable.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../interfaces/IAuthorizable.sol\";\n\n\ncontract MAuthorizable is\n    IAuthorizable\n{\n    // Event logged when a new address is authorized.\n    event AuthorizedAddressAdded(\n        address indexed target,\n        address indexed caller\n    );\n\n    // Event logged when a currently authorized address is unauthorized.\n    event AuthorizedAddressRemoved(\n        address indexed target,\n        address indexed caller\n    );\n\n    /// @dev Only authorized addresses can invoke functions with this modifier.\n    modifier onlyAuthorized { revert(); _; }\n}\n",
        "protocol/AssetProxyOwner/AssetProxyOwner.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../multisig/MultiSigWalletWithTimeLock.sol\";\nimport \"../../utils/LibBytes/LibBytes.sol\";\n\n\ncontract AssetProxyOwner is\n    MultiSigWalletWithTimeLock\n{\n    using LibBytes for bytes;\n\n    event AssetProxyRegistration(address assetProxyContract, bool isRegistered);\n\n    // Mapping of AssetProxy contract address =>\n    // if this contract is allowed to call the AssetProxy's `removeAuthorizedAddressAtIndex` method without a time lock.\n    mapping (address => bool) public isAssetProxyRegistered;\n\n    bytes4 constant internal REMOVE_AUTHORIZED_ADDRESS_AT_INDEX_SELECTOR = bytes4(keccak256(\"removeAuthorizedAddressAtIndex(address,uint256)\"));\n\n    /// @dev Function will revert if the transaction does not call `removeAuthorizedAddressAtIndex`\n    ///      on an approved AssetProxy contract.\n    modifier validRemoveAuthorizedAddressAtIndexTx(uint256 transactionId) {\n        Transaction storage txn = transactions[transactionId];\n        require(\n            isAssetProxyRegistered[txn.destination],\n            \"UNREGISTERED_ASSET_PROXY\"\n        );\n        require(\n            txn.data.readBytes4(0) == REMOVE_AUTHORIZED_ADDRESS_AT_INDEX_SELECTOR,\n            \"INVALID_FUNCTION_SELECTOR\"\n        );\n        _;\n    }\n\n    /// @dev Contract constructor sets initial owners, required number of confirmations,\n    ///      time lock, and list of AssetProxy addresses.\n    /// @param _owners List of initial owners.\n    /// @param _assetProxyContracts Array of AssetProxy contract addresses.\n    /// @param _required Number of required confirmations.\n    /// @param _secondsTimeLocked Duration needed after a transaction is confirmed and before it becomes executable, in seconds.\n    constructor (\n        address[] memory _owners,\n        address[] memory _assetProxyContracts,\n        uint256 _required,\n        uint256 _secondsTimeLocked\n    )\n        public\n        MultiSigWalletWithTimeLock(_owners, _required, _secondsTimeLocked)\n    {\n        for (uint256 i = 0; i < _assetProxyContracts.length; i++) {\n            address assetProxy = _assetProxyContracts[i];\n            require(\n                assetProxy != address(0),\n                \"INVALID_ASSET_PROXY\"\n            );\n            isAssetProxyRegistered[assetProxy] = true;\n        }\n    }\n\n    /// @dev Registers or deregisters an AssetProxy to be able to execute\n    ///      `removeAuthorizedAddressAtIndex` without a timelock.\n    /// @param assetProxyContract Address of AssetProxy contract.\n    /// @param isRegistered Status of approval for AssetProxy contract.\n    function registerAssetProxy(address assetProxyContract, bool isRegistered)\n        public\n        onlyWallet\n        notNull(assetProxyContract)\n    {\n        isAssetProxyRegistered[assetProxyContract] = isRegistered;\n        emit AssetProxyRegistration(assetProxyContract, isRegistered);\n    }\n\n    /// @dev Allows execution of `removeAuthorizedAddressAtIndex` without time lock.\n    /// @param transactionId Transaction ID.\n    function executeRemoveAuthorizedAddressAtIndex(uint256 transactionId)\n        public\n        notExecuted(transactionId)\n        fullyConfirmed(transactionId)\n        validRemoveAuthorizedAddressAtIndexTx(transactionId)\n    {\n        Transaction storage txn = transactions[transactionId];\n        txn.executed = true;\n        if (external_call(txn.destination, txn.value, txn.data.length, txn.data)) {\n            emit Execution(transactionId);\n        } else {\n            emit ExecutionFailure(transactionId);\n            txn.executed = false;\n        }\n    }\n}\n",
        "protocol/Exchange/Exchange.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"./libs/LibConstants.sol\";\nimport \"./MixinExchangeCore.sol\";\nimport \"./MixinSignatureValidator.sol\";\nimport \"./MixinWrapperFunctions.sol\";\nimport \"./MixinAssetProxyDispatcher.sol\";\nimport \"./MixinTransactions.sol\";\nimport \"./MixinMatchOrders.sol\";\n\n\n// solhint-disable no-empty-blocks\ncontract Exchange is\n    MixinExchangeCore,\n    MixinMatchOrders,\n    MixinSignatureValidator,\n    MixinTransactions,\n    MixinAssetProxyDispatcher,\n    MixinWrapperFunctions\n{\n    string constant public VERSION = \"2.0.1-alpha\";\n\n    // Mixins are instantiated in the order they are inherited\n    constructor (bytes memory _zrxAssetData)\n        public\n        LibConstants(_zrxAssetData) // @TODO: Remove when we deploy.\n        MixinExchangeCore()\n        MixinMatchOrders()\n        MixinSignatureValidator()\n        MixinTransactions()\n        MixinAssetProxyDispatcher()\n        MixinWrapperFunctions()\n    {}\n}\n",
        "protocol/Exchange/MixinAssetProxyDispatcher.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../utils/Ownable/Ownable.sol\";\nimport \"./mixins/MAssetProxyDispatcher.sol\";\nimport \"../AssetProxy/interfaces/IAssetProxy.sol\";\n\n\ncontract MixinAssetProxyDispatcher is\n    Ownable,\n    MAssetProxyDispatcher\n{\n    // Mapping from Asset Proxy Id's to their respective Asset Proxy\n    mapping (bytes4 => IAssetProxy) public assetProxies;\n\n    /// @dev Registers an asset proxy to its asset proxy id.\n    ///      Once an asset proxy is registered, it cannot be unregistered.\n    /// @param assetProxy Address of new asset proxy to register.\n    function registerAssetProxy(address assetProxy)\n        external\n        onlyOwner\n    {\n        IAssetProxy assetProxyContract = IAssetProxy(assetProxy);\n\n        // Ensure that no asset proxy exists with current id.\n        bytes4 assetProxyId = assetProxyContract.getProxyId();\n        address currentAssetProxy = assetProxies[assetProxyId];\n        require(\n            currentAssetProxy == address(0),\n            \"ASSET_PROXY_ALREADY_EXISTS\"\n        );\n\n        // Add asset proxy and log registration.\n        assetProxies[assetProxyId] = assetProxyContract;\n        emit AssetProxyRegistered(\n            assetProxyId,\n            assetProxy\n        );\n    }\n\n    /// @dev Gets an asset proxy.\n    /// @param assetProxyId Id of the asset proxy.\n    /// @return The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered.\n    function getAssetProxy(bytes4 assetProxyId)\n        external\n        view\n        returns (address)\n    {\n        return assetProxies[assetProxyId];\n    }\n\n    /// @dev Forwards arguments to assetProxy and calls `transferFrom`. Either succeeds or throws.\n    /// @param assetData Byte array encoded for the asset.\n    /// @param from Address to transfer token from.\n    /// @param to Address to transfer token to.\n    /// @param amount Amount of token to transfer.\n    function dispatchTransferFrom(\n        bytes memory assetData,\n        address from,\n        address to,\n        uint256 amount\n    )\n        internal\n    {\n        // Do nothing if no amount should be transferred.\n        if (amount > 0 && from != to) {\n            // Ensure assetData length is valid\n            require(\n                assetData.length > 3,\n                \"LENGTH_GREATER_THAN_3_REQUIRED\"\n            );\n            \n            // Lookup assetProxy. We do not use `LibBytes.readBytes4` for gas efficiency reasons.\n            bytes4 assetProxyId;\n            assembly {\n                assetProxyId := and(mload(\n                    add(assetData, 32)),\n                    0xFFFFFFFF00000000000000000000000000000000000000000000000000000000\n                )\n            }\n            address assetProxy = assetProxies[assetProxyId];\n\n            // Ensure that assetProxy exists\n            require(\n                assetProxy != address(0),\n                \"ASSET_PROXY_DOES_NOT_EXIST\"\n            );\n            \n            // We construct calldata for the `assetProxy.transferFrom` ABI.\n            // The layout of this calldata is in the table below.\n            // \n            // | Area     | Offset | Length  | Contents                                    |\n            // | -------- |--------|---------|-------------------------------------------- |\n            // | Header   | 0      | 4       | function selector                           |\n            // | Params   |        | 4 * 32  | function parameters:                        |\n            // |          | 4      |         |   1. offset to assetData (*)                |\n            // |          | 36     |         |   2. from                                   |\n            // |          | 68     |         |   3. to                                     |\n            // |          | 100    |         |   4. amount                                 |\n            // | Data     |        |         | assetData:                                  |\n            // |          | 132    | 32      | assetData Length                            |\n            // |          | 164    | **      | assetData Contents                          |\n\n            assembly {\n                /////// Setup State ///////\n                // `cdStart` is the start of the calldata for `assetProxy.transferFrom` (equal to free memory ptr).\n                let cdStart := mload(64)\n                // `dataAreaLength` is the total number of words needed to store `assetData`\n                //  As-per the ABI spec, this value is padded up to the nearest multiple of 32,\n                //  and includes 32-bytes for length.\n                let dataAreaLength := and(add(mload(assetData), 63), 0xFFFFFFFFFFFE0)\n                // `cdEnd` is the end of the calldata for `assetProxy.transferFrom`.\n                let cdEnd := add(cdStart, add(132, dataAreaLength))\n\n                \n                /////// Setup Header Area ///////\n                // This area holds the 4-byte `transferFromSelector`.\n                // bytes4(keccak256(\"transferFrom(bytes,address,address,uint256)\")) = 0xa85e59e4\n                mstore(cdStart, 0xa85e59e400000000000000000000000000000000000000000000000000000000)\n                \n                /////// Setup Params Area ///////\n                // Each parameter is padded to 32-bytes. The entire Params Area is 128 bytes.\n                // Notes:\n                //   1. The offset to `assetData` is the length of the Params Area (128 bytes).\n                //   2. A 20-byte mask is applied to addresses to zero-out the unused bytes.\n                mstore(add(cdStart, 4), 128)\n                mstore(add(cdStart, 36), and(from, 0xffffffffffffffffffffffffffffffffffffffff))\n                mstore(add(cdStart, 68), and(to, 0xffffffffffffffffffffffffffffffffffffffff))\n                mstore(add(cdStart, 100), amount)\n                \n                /////// Setup Data Area ///////\n                // This area holds `assetData`.\n                let dataArea := add(cdStart, 132)\n                // solhint-disable-next-line no-empty-blocks\n                for {} lt(dataArea, cdEnd) {} {\n                    mstore(dataArea, mload(assetData))\n                    dataArea := add(dataArea, 32)\n                    assetData := add(assetData, 32)\n                }\n\n                /////// Call `assetProxy.transferFrom` using the constructed calldata ///////\n                let success := call(\n                    gas,                    // forward all gas\n                    assetProxy,             // call address of asset proxy\n                    0,                      // don't send any ETH\n                    cdStart,                // pointer to start of input\n                    sub(cdEnd, cdStart),    // length of input  \n                    cdStart,                // write output over input\n                    512                     // reserve 512 bytes for output\n                )\n                if iszero(success) {\n                    revert(cdStart, returndatasize())\n                }\n            }\n        }\n    }\n}\n",
        "protocol/Exchange/MixinExchangeCore.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../../utils/ReentrancyGuard/ReentrancyGuard.sol\";\nimport \"./libs/LibConstants.sol\";\nimport \"./libs/LibFillResults.sol\";\nimport \"./libs/LibOrder.sol\";\nimport \"./libs/LibMath.sol\";\nimport \"./mixins/MExchangeCore.sol\";\nimport \"./mixins/MSignatureValidator.sol\";\nimport \"./mixins/MTransactions.sol\";\nimport \"./mixins/MAssetProxyDispatcher.sol\";\n\n\ncontract MixinExchangeCore is\n    ReentrancyGuard,\n    LibConstants,\n    LibMath,\n    LibOrder,\n    LibFillResults,\n    MAssetProxyDispatcher,\n    MExchangeCore,\n    MSignatureValidator,\n    MTransactions\n{\n    // Mapping of orderHash => amount of takerAsset already bought by maker\n    mapping (bytes32 => uint256) public filled;\n\n    // Mapping of orderHash => cancelled\n    mapping (bytes32 => bool) public cancelled;\n\n    // Mapping of makerAddress => senderAddress => lowest salt an order can have in order to be fillable\n    // Orders with specified senderAddress and with a salt less than their epoch are considered cancelled\n    mapping (address => mapping (address => uint256)) public orderEpoch;\n\n    /// @dev Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch\n    ///      and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress).\n    /// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled.\n    function cancelOrdersUpTo(uint256 targetOrderEpoch)\n        external\n        nonReentrant\n    {\n        address makerAddress = getCurrentContextAddress();\n        // If this function is called via `executeTransaction`, we only update the orderEpoch for the makerAddress/msg.sender combination.\n        // This allows external filter contracts to add rules to how orders are cancelled via this function.\n        address senderAddress = makerAddress == msg.sender ? address(0) : msg.sender;\n\n        // orderEpoch is initialized to 0, so to cancelUpTo we need salt + 1\n        uint256 newOrderEpoch = targetOrderEpoch + 1;  \n        uint256 oldOrderEpoch = orderEpoch[makerAddress][senderAddress];\n\n        // Ensure orderEpoch is monotonically increasing\n        require(\n            newOrderEpoch > oldOrderEpoch, \n            \"INVALID_NEW_ORDER_EPOCH\"\n        );\n\n        // Update orderEpoch\n        orderEpoch[makerAddress][senderAddress] = newOrderEpoch;\n        emit CancelUpTo(\n            makerAddress,\n            senderAddress,\n            newOrderEpoch\n        );\n    }\n\n    /// @dev Fills the input order.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    /// @return Amounts filled and fees paid by maker and taker.\n    function fillOrder(\n        Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        public\n        nonReentrant\n        returns (FillResults memory fillResults)\n    {\n        fillResults = fillOrderInternal(\n            order,\n            takerAssetFillAmount,\n            signature\n        );\n        return fillResults;\n    }\n\n    /// @dev After calling, the order can not be filled anymore.\n    ///      Throws if order is invalid or sender does not have permission to cancel.\n    /// @param order Order to cancel. Order must be OrderStatus.FILLABLE.\n    function cancelOrder(Order memory order)\n        public\n        nonReentrant\n    {\n        cancelOrderInternal(order);\n    }\n\n    /// @dev Gets information about an order: status, hash, and amount filled.\n    /// @param order Order to gather information on.\n    /// @return OrderInfo Information about the order and its state.\n    ///         See LibOrder.OrderInfo for a complete description.\n    function getOrderInfo(Order memory order)\n        public\n        view\n        returns (OrderInfo memory orderInfo)\n    {\n        // Compute the order hash\n        orderInfo.orderHash = getOrderHash(order);\n\n        // Fetch filled amount\n        orderInfo.orderTakerAssetFilledAmount = filled[orderInfo.orderHash];\n\n        // If order.makerAssetAmount is zero, we also reject the order.\n        // While the Exchange contract handles them correctly, they create\n        // edge cases in the supporting infrastructure because they have\n        // an 'infinite' price when computed by a simple division.\n        if (order.makerAssetAmount == 0) {\n            orderInfo.orderStatus = uint8(OrderStatus.INVALID_MAKER_ASSET_AMOUNT);\n            return orderInfo;\n        }\n\n        // If order.takerAssetAmount is zero, then the order will always\n        // be considered filled because 0 == takerAssetAmount == orderTakerAssetFilledAmount\n        // Instead of distinguishing between unfilled and filled zero taker\n        // amount orders, we choose not to support them.\n        if (order.takerAssetAmount == 0) {\n            orderInfo.orderStatus = uint8(OrderStatus.INVALID_TAKER_ASSET_AMOUNT);\n            return orderInfo;\n        }\n\n        // Validate order availability\n        if (orderInfo.orderTakerAssetFilledAmount >= order.takerAssetAmount) {\n            orderInfo.orderStatus = uint8(OrderStatus.FULLY_FILLED);\n            return orderInfo;\n        }\n\n        // Validate order expiration\n        // solhint-disable-next-line not-rely-on-time\n        if (block.timestamp >= order.expirationTimeSeconds) {\n            orderInfo.orderStatus = uint8(OrderStatus.EXPIRED);\n            return orderInfo;\n        }\n\n        // Check if order has been cancelled\n        if (cancelled[orderInfo.orderHash]) {\n            orderInfo.orderStatus = uint8(OrderStatus.CANCELLED);\n            return orderInfo;\n        }\n        if (orderEpoch[order.makerAddress][order.senderAddress] > order.salt) {\n            orderInfo.orderStatus = uint8(OrderStatus.CANCELLED);\n            return orderInfo;\n        }\n\n        // All other statuses are ruled out: order is Fillable\n        orderInfo.orderStatus = uint8(OrderStatus.FILLABLE);\n        return orderInfo;\n    }\n\n    /// @dev Fills the input order.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    /// @return Amounts filled and fees paid by maker and taker.\n    function fillOrderInternal(\n        Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        internal\n        returns (FillResults memory fillResults)\n    {\n        // Fetch order info\n        OrderInfo memory orderInfo = getOrderInfo(order);\n\n        // Fetch taker address\n        address takerAddress = getCurrentContextAddress();\n        \n        // Assert that the order is fillable by taker\n        assertFillableOrder(\n            order,\n            orderInfo,\n            takerAddress,\n            signature\n        );\n        \n        // Get amount of takerAsset to fill\n        uint256 remainingTakerAssetAmount = safeSub(order.takerAssetAmount, orderInfo.orderTakerAssetFilledAmount);\n        uint256 takerAssetFilledAmount = min256(takerAssetFillAmount, remainingTakerAssetAmount);\n\n        // Validate context\n        assertValidFill(\n            order,\n            orderInfo,\n            takerAssetFillAmount,\n            takerAssetFilledAmount,\n            fillResults.makerAssetFilledAmount\n        );\n\n        // Compute proportional fill amounts\n        fillResults = calculateFillResults(order, takerAssetFilledAmount);\n\n        // Update exchange internal state\n        updateFilledState(\n            order,\n            takerAddress,\n            orderInfo.orderHash,\n            orderInfo.orderTakerAssetFilledAmount,\n            fillResults\n        );\n    \n        // Settle order\n        settleOrder(\n            order,\n            takerAddress,\n            fillResults\n        );\n\n        return fillResults;\n    }\n\n    /// @dev After calling, the order can not be filled anymore.\n    ///      Throws if order is invalid or sender does not have permission to cancel.\n    /// @param order Order to cancel. Order must be OrderStatus.FILLABLE.\n    function cancelOrderInternal(Order memory order)\n        internal\n    {\n        // Fetch current order status\n        OrderInfo memory orderInfo = getOrderInfo(order);\n\n        // Validate context\n        assertValidCancel(order, orderInfo);\n\n        // Perform cancel\n        updateCancelledState(order, orderInfo.orderHash);\n    }\n\n    /// @dev Updates state with results of a fill order.\n    /// @param order that was filled.\n    /// @param takerAddress Address of taker who filled the order.\n    /// @param orderTakerAssetFilledAmount Amount of order already filled.\n    function updateFilledState(\n        Order memory order,\n        address takerAddress,\n        bytes32 orderHash,\n        uint256 orderTakerAssetFilledAmount,\n        FillResults memory fillResults\n    )\n        internal\n    {\n        // Update state\n        filled[orderHash] = safeAdd(orderTakerAssetFilledAmount, fillResults.takerAssetFilledAmount);\n\n        // Log order\n        emit Fill(\n            order.makerAddress,\n            order.feeRecipientAddress,\n            takerAddress,\n            msg.sender,\n            fillResults.makerAssetFilledAmount,\n            fillResults.takerAssetFilledAmount,\n            fillResults.makerFeePaid,\n            fillResults.takerFeePaid,\n            orderHash,\n            order.makerAssetData,\n            order.takerAssetData\n        );\n    }\n\n    /// @dev Updates state with results of cancelling an order.\n    ///      State is only updated if the order is currently fillable.\n    ///      Otherwise, updating state would have no effect.\n    /// @param order that was cancelled.\n    /// @param orderHash Hash of order that was cancelled.\n    function updateCancelledState(\n        Order memory order,\n        bytes32 orderHash\n    )\n        internal\n    {\n        // Perform cancel\n        cancelled[orderHash] = true;\n\n        // Log cancel\n        emit Cancel(\n            order.makerAddress,\n            order.feeRecipientAddress,\n            msg.sender,\n            orderHash,\n            order.makerAssetData,\n            order.takerAssetData\n        );\n    }\n    \n    /// @dev Validates context for fillOrder. Succeeds or throws.\n    /// @param order to be filled.\n    /// @param orderInfo OrderStatus, orderHash, and amount already filled of order.\n    /// @param takerAddress Address of order taker.\n    /// @param signature Proof that the orders was created by its maker.\n    function assertFillableOrder(\n        Order memory order,\n        OrderInfo memory orderInfo,\n        address takerAddress,\n        bytes memory signature\n    )\n        internal\n        view\n    {\n        // An order can only be filled if its status is FILLABLE.\n        require(\n            orderInfo.orderStatus == uint8(OrderStatus.FILLABLE),\n            \"ORDER_UNFILLABLE\"\n        );\n        \n        // Validate sender is allowed to fill this order\n        if (order.senderAddress != address(0)) {\n            require(\n                order.senderAddress == msg.sender,\n                \"INVALID_SENDER\"\n            );\n        }\n        \n        // Validate taker is allowed to fill this order\n        if (order.takerAddress != address(0)) {\n            require(\n                order.takerAddress == takerAddress,\n                \"INVALID_TAKER\"\n            );\n        }\n        \n        // Validate Maker signature (check only if first time seen)\n        if (orderInfo.orderTakerAssetFilledAmount == 0) {\n            require(\n                isValidSignature(\n                    orderInfo.orderHash,\n                    order.makerAddress,\n                    signature\n                ),\n                \"INVALID_ORDER_SIGNATURE\"\n            );\n        }\n    }\n    \n    /// @dev Validates context for fillOrder. Succeeds or throws.\n    /// @param order to be filled.\n    /// @param orderInfo OrderStatus, orderHash, and amount already filled of order.\n    /// @param takerAssetFillAmount Desired amount of order to fill by taker.\n    /// @param takerAssetFilledAmount Amount of takerAsset that will be filled.\n    /// @param makerAssetFilledAmount Amount of makerAsset that will be transfered.\n    function assertValidFill(\n        Order memory order,\n        OrderInfo memory orderInfo,\n        uint256 takerAssetFillAmount,  // TODO: use FillResults\n        uint256 takerAssetFilledAmount,\n        uint256 makerAssetFilledAmount\n    )\n        internal\n        view\n    {\n        // Revert if fill amount is invalid\n        // TODO: reconsider necessity for v2.1\n        require(\n            takerAssetFillAmount != 0,\n            \"INVALID_TAKER_AMOUNT\"\n        );\n        \n        // Make sure taker does not pay more than desired amount\n        // NOTE: This assertion should never fail, it is here\n        //       as an extra defence against potential bugs.\n        require(\n            takerAssetFilledAmount <= takerAssetFillAmount,\n            \"TAKER_OVERPAY\"\n        );\n        \n        // Make sure order is not overfilled\n        // NOTE: This assertion should never fail, it is here\n        //       as an extra defence against potential bugs.\n        require(\n            safeAdd(orderInfo.orderTakerAssetFilledAmount, takerAssetFilledAmount) <= order.takerAssetAmount,\n            \"ORDER_OVERFILL\"\n        );\n        \n        // Make sure order is filled at acceptable price.\n        // The order has an implied price from the makers perspective:\n        //    order price = order.makerAssetAmount / order.takerAssetAmount\n        // i.e. the number of makerAsset maker is paying per takerAsset. The\n        // maker is guaranteed to get this price or a better (lower) one. The\n        // actual price maker is getting in this fill is:\n        //    fill price = makerAssetFilledAmount / takerAssetFilledAmount\n        // We need `fill price <= order price` for the fill to be fair to maker.\n        // This amounts to:\n        //     makerAssetFilledAmount        order.makerAssetAmount\n        //    ------------------------  <=  -----------------------\n        //     takerAssetFilledAmount        order.takerAssetAmount\n        // or, equivalently:\n        //     makerAssetFilledAmount * order.takerAssetAmount <=\n        //     order.makerAssetAmount * takerAssetFilledAmount\n        // NOTE: This assertion should never fail, it is here\n        //       as an extra defence against potential bugs.\n        require(\n            safeMul(makerAssetFilledAmount, order.takerAssetAmount)\n            <= \n            safeMul(order.makerAssetAmount, takerAssetFilledAmount),\n            \"INVALID_FILL_PRICE\"\n        );\n    }\n\n    /// @dev Validates context for cancelOrder. Succeeds or throws.\n    /// @param order to be cancelled.\n    /// @param orderInfo OrderStatus, orderHash, and amount already filled of order.\n    function assertValidCancel(\n        Order memory order,\n        OrderInfo memory orderInfo\n    )\n        internal\n        view\n    {\n        // Ensure order is valid\n        // An order can only be cancelled if its status is FILLABLE.\n        require(\n            orderInfo.orderStatus == uint8(OrderStatus.FILLABLE),\n            \"ORDER_UNFILLABLE\"\n        );\n\n        // Validate sender is allowed to cancel this order\n        if (order.senderAddress != address(0)) {\n            require(\n                order.senderAddress == msg.sender,\n                \"INVALID_SENDER\"\n            );\n        }\n\n        // Validate transaction signed by maker\n        address makerAddress = getCurrentContextAddress();\n        require(\n            order.makerAddress == makerAddress,\n            \"INVALID_MAKER\"\n        );\n    }\n\n    /// @dev Calculates amounts filled and fees paid by maker and taker.\n    /// @param order to be filled.\n    /// @param takerAssetFilledAmount Amount of takerAsset that will be filled.\n    /// @return fillResults Amounts filled and fees paid by maker and taker.\n    function calculateFillResults(\n        Order memory order,\n        uint256 takerAssetFilledAmount\n    )\n        internal\n        pure\n        returns (FillResults memory fillResults)\n    {\n        // Compute proportional transfer amounts\n        fillResults.takerAssetFilledAmount = takerAssetFilledAmount;\n        fillResults.makerAssetFilledAmount = safeGetPartialAmountFloor(\n            takerAssetFilledAmount,\n            order.takerAssetAmount,\n            order.makerAssetAmount\n        );\n        fillResults.makerFeePaid = safeGetPartialAmountFloor(\n            fillResults.makerAssetFilledAmount,\n            order.makerAssetAmount,\n            order.makerFee\n        );\n        fillResults.takerFeePaid = safeGetPartialAmountFloor(\n            takerAssetFilledAmount,\n            order.takerAssetAmount,\n            order.takerFee\n        );\n\n        return fillResults;\n    }\n\n    /// @dev Settles an order by transferring assets between counterparties.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAddress Address selling takerAsset and buying makerAsset.\n    /// @param fillResults Amounts to be filled and fees paid by maker and taker.\n    function settleOrder(\n        LibOrder.Order memory order,\n        address takerAddress,\n        LibFillResults.FillResults memory fillResults\n    )\n        private\n    {\n        bytes memory zrxAssetData = ZRX_ASSET_DATA;\n        dispatchTransferFrom(\n            order.makerAssetData,\n            order.makerAddress,\n            takerAddress,\n            fillResults.makerAssetFilledAmount\n        );\n        dispatchTransferFrom(\n            order.takerAssetData,\n            takerAddress,\n            order.makerAddress,\n            fillResults.takerAssetFilledAmount\n        );\n        dispatchTransferFrom(\n            zrxAssetData,\n            order.makerAddress,\n            order.feeRecipientAddress,\n            fillResults.makerFeePaid\n        );\n        dispatchTransferFrom(\n            zrxAssetData,\n            takerAddress,\n            order.feeRecipientAddress,\n            fillResults.takerFeePaid\n        );\n    }\n}\n",
        "protocol/Exchange/MixinMatchOrders.sol": "/*\n  Copyright 2018 ZeroEx Intl.\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n    http://www.apache.org/licenses/LICENSE-2.0\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../../utils/ReentrancyGuard/ReentrancyGuard.sol\";\nimport \"./libs/LibConstants.sol\";\nimport \"./libs/LibMath.sol\";\nimport \"./libs/LibOrder.sol\";\nimport \"./libs/LibFillResults.sol\";\nimport \"./mixins/MExchangeCore.sol\";\nimport \"./mixins/MMatchOrders.sol\";\nimport \"./mixins/MTransactions.sol\";\nimport \"./mixins/MAssetProxyDispatcher.sol\";\n\n\ncontract MixinMatchOrders is\n    ReentrancyGuard,\n    LibConstants,\n    LibMath,\n    MAssetProxyDispatcher,\n    MExchangeCore,\n    MMatchOrders,\n    MTransactions\n{\n    /// @dev Match two complementary orders that have a profitable spread.\n    ///      Each order is filled at their respective price point. However, the calculations are\n    ///      carried out as though the orders are both being filled at the right order's price point.\n    ///      The profit made by the left order goes to the taker (who matched the two orders).\n    /// @param leftOrder First order to match.\n    /// @param rightOrder Second order to match.\n    /// @param leftSignature Proof that order was created by the left maker.\n    /// @param rightSignature Proof that order was created by the right maker.\n    /// @return matchedFillResults Amounts filled and fees paid by maker and taker of matched orders.\n    function matchOrders(\n        LibOrder.Order memory leftOrder,\n        LibOrder.Order memory rightOrder,\n        bytes memory leftSignature,\n        bytes memory rightSignature\n    )\n        public\n        nonReentrant\n        returns (LibFillResults.MatchedFillResults memory matchedFillResults)\n    {\n        // We assume that rightOrder.takerAssetData == leftOrder.makerAssetData and rightOrder.makerAssetData == leftOrder.takerAssetData.\n        // If this assumption isn't true, the match will fail at signature validation.\n        rightOrder.makerAssetData = leftOrder.takerAssetData;\n        rightOrder.takerAssetData = leftOrder.makerAssetData;\n\n        // Get left & right order info\n        LibOrder.OrderInfo memory leftOrderInfo = getOrderInfo(leftOrder);\n        LibOrder.OrderInfo memory rightOrderInfo = getOrderInfo(rightOrder);\n\n        // Fetch taker address\n        address takerAddress = getCurrentContextAddress();\n        \n        // Either our context is valid or we revert\n        assertFillableOrder(\n            leftOrder,\n            leftOrderInfo,\n            takerAddress,\n            leftSignature\n        );\n        assertFillableOrder(\n            rightOrder,\n            rightOrderInfo,\n            takerAddress,\n            rightSignature\n        );\n        assertValidMatch(leftOrder, rightOrder);\n\n        // Compute proportional fill amounts\n        matchedFillResults = calculateMatchedFillResults(\n            leftOrder,\n            rightOrder,\n            leftOrderInfo.orderTakerAssetFilledAmount,\n            rightOrderInfo.orderTakerAssetFilledAmount\n        );\n\n        // Validate fill contexts\n        assertValidFill(\n            leftOrder,\n            leftOrderInfo,\n            matchedFillResults.left.takerAssetFilledAmount,\n            matchedFillResults.left.takerAssetFilledAmount,\n            matchedFillResults.left.makerAssetFilledAmount\n        );\n        assertValidFill(\n            rightOrder,\n            rightOrderInfo,\n            matchedFillResults.right.takerAssetFilledAmount,\n            matchedFillResults.right.takerAssetFilledAmount,\n            matchedFillResults.right.makerAssetFilledAmount\n        );\n        \n        // Update exchange state\n        updateFilledState(\n            leftOrder,\n            takerAddress,\n            leftOrderInfo.orderHash,\n            leftOrderInfo.orderTakerAssetFilledAmount,\n            matchedFillResults.left\n        );\n        updateFilledState(\n            rightOrder,\n            takerAddress,\n            rightOrderInfo.orderHash,\n            rightOrderInfo.orderTakerAssetFilledAmount,\n            matchedFillResults.right\n        );\n\n        // Settle matched orders. Succeeds or throws.\n        settleMatchedOrders(\n            leftOrder,\n            rightOrder,\n            takerAddress,\n            matchedFillResults\n        );\n\n        return matchedFillResults;\n    }\n\n    /// @dev Validates context for matchOrders. Succeeds or throws.\n    /// @param leftOrder First order to match.\n    /// @param rightOrder Second order to match.\n    function assertValidMatch(\n        LibOrder.Order memory leftOrder,\n        LibOrder.Order memory rightOrder\n    )\n        internal\n        pure\n    {\n        // Make sure there is a profitable spread.\n        // There is a profitable spread iff the cost per unit bought (OrderA.MakerAmount/OrderA.TakerAmount) for each order is greater\n        // than the profit per unit sold of the matched order (OrderB.TakerAmount/OrderB.MakerAmount).\n        // This is satisfied by the equations below:\n        // <leftOrder.makerAssetAmount> / <leftOrder.takerAssetAmount> >= <rightOrder.takerAssetAmount> / <rightOrder.makerAssetAmount>\n        // AND\n        // <rightOrder.makerAssetAmount> / <rightOrder.takerAssetAmount> >= <leftOrder.takerAssetAmount> / <leftOrder.makerAssetAmount>\n        // These equations can be combined to get the following:\n        require(\n            safeMul(leftOrder.makerAssetAmount, rightOrder.makerAssetAmount) >=\n            safeMul(leftOrder.takerAssetAmount, rightOrder.takerAssetAmount),\n            \"NEGATIVE_SPREAD_REQUIRED\"\n        );\n    }\n\n    /// @dev Calculates fill amounts for the matched orders.\n    ///      Each order is filled at their respective price point. However, the calculations are\n    ///      carried out as though the orders are both being filled at the right order's price point.\n    ///      The profit made by the leftOrder order goes to the taker (who matched the two orders).\n    /// @param leftOrder First order to match.\n    /// @param rightOrder Second order to match.\n    /// @param leftOrderTakerAssetFilledAmount Amount of left order already filled.\n    /// @param rightOrderTakerAssetFilledAmount Amount of right order already filled.\n    /// @param matchedFillResults Amounts to fill and fees to pay by maker and taker of matched orders.\n    function calculateMatchedFillResults(\n        LibOrder.Order memory leftOrder,\n        LibOrder.Order memory rightOrder,\n        uint256 leftOrderTakerAssetFilledAmount,\n        uint256 rightOrderTakerAssetFilledAmount\n    )\n        internal\n        pure\n        returns (LibFillResults.MatchedFillResults memory matchedFillResults)\n    {\n        // Derive maker asset amounts for left & right orders, given store taker assert amounts\n        uint256 leftTakerAssetAmountRemaining = safeSub(leftOrder.takerAssetAmount, leftOrderTakerAssetFilledAmount);\n        uint256 leftMakerAssetAmountRemaining = safeGetPartialAmountFloor(\n            leftOrder.makerAssetAmount,\n            leftOrder.takerAssetAmount,\n            leftTakerAssetAmountRemaining\n        );\n        uint256 rightTakerAssetAmountRemaining = safeSub(rightOrder.takerAssetAmount, rightOrderTakerAssetFilledAmount);\n        uint256 rightMakerAssetAmountRemaining = safeGetPartialAmountFloor(\n            rightOrder.makerAssetAmount,\n            rightOrder.takerAssetAmount,\n            rightTakerAssetAmountRemaining\n        );\n\n        // Calculate fill results for maker and taker assets: at least one order will be fully filled.\n        // The maximum amount the left maker can buy is `leftTakerAssetAmountRemaining`\n        // The maximum amount the right maker can sell is `rightMakerAssetAmountRemaining`\n        // We have two distinct cases for calculating the fill results:\n        // Case 1.\n        //   If the left maker can buy more than the right maker can sell, then only the right order is fully filled.\n        //   If the left maker can buy exactly what the right maker can sell, then both orders are fully filled.\n        // Case 2.\n        //   If the left maker cannot buy more than the right maker can sell, then only the left order is fully filled.\n        if (leftTakerAssetAmountRemaining >= rightMakerAssetAmountRemaining) {\n            // Case 1: Right order is fully filled\n            matchedFillResults.right.makerAssetFilledAmount = rightMakerAssetAmountRemaining;\n            matchedFillResults.right.takerAssetFilledAmount = rightTakerAssetAmountRemaining;\n            matchedFillResults.left.takerAssetFilledAmount = matchedFillResults.right.makerAssetFilledAmount;\n            // Round down to ensure the maker's exchange rate does not exceed the price specified by the order. \n            // We favor the maker when the exchange rate must be rounded.\n            matchedFillResults.left.makerAssetFilledAmount = safeGetPartialAmountFloor(\n                leftOrder.makerAssetAmount,\n                leftOrder.takerAssetAmount,\n                matchedFillResults.left.takerAssetFilledAmount\n            );\n        } else {\n            // Case 2: Left order is fully filled\n            matchedFillResults.left.makerAssetFilledAmount = leftMakerAssetAmountRemaining;\n            matchedFillResults.left.takerAssetFilledAmount = leftTakerAssetAmountRemaining;\n            matchedFillResults.right.makerAssetFilledAmount = matchedFillResults.left.takerAssetFilledAmount;\n            // Round up to ensure the maker's exchange rate does not exceed the price specified by the order.\n            // We favor the maker when the exchange rate must be rounded.\n            matchedFillResults.right.takerAssetFilledAmount = safeGetPartialAmountCeil(\n                rightOrder.takerAssetAmount,\n                rightOrder.makerAssetAmount,\n                matchedFillResults.right.makerAssetFilledAmount\n            );\n        }\n\n        // Calculate amount given to taker\n        matchedFillResults.leftMakerAssetSpreadAmount = safeSub(\n            matchedFillResults.left.makerAssetFilledAmount,\n            matchedFillResults.right.takerAssetFilledAmount\n        );\n\n        // Compute fees for left order\n        matchedFillResults.left.makerFeePaid = safeGetPartialAmountFloor(\n            matchedFillResults.left.makerAssetFilledAmount,\n            leftOrder.makerAssetAmount,\n            leftOrder.makerFee\n        );\n        matchedFillResults.left.takerFeePaid = safeGetPartialAmountFloor(\n            matchedFillResults.left.takerAssetFilledAmount,\n            leftOrder.takerAssetAmount,\n            leftOrder.takerFee\n        );\n\n        // Compute fees for right order\n        matchedFillResults.right.makerFeePaid = safeGetPartialAmountFloor(\n            matchedFillResults.right.makerAssetFilledAmount,\n            rightOrder.makerAssetAmount,\n            rightOrder.makerFee\n        );\n        matchedFillResults.right.takerFeePaid = safeGetPartialAmountFloor(\n            matchedFillResults.right.takerAssetFilledAmount,\n            rightOrder.takerAssetAmount,\n            rightOrder.takerFee\n        );\n\n        // Return fill results\n        return matchedFillResults;\n    }\n\n    /// @dev Settles matched order by transferring appropriate funds between order makers, taker, and fee recipient.\n    /// @param leftOrder First matched order.\n    /// @param rightOrder Second matched order.\n    /// @param takerAddress Address that matched the orders. The taker receives the spread between orders as profit.\n    /// @param matchedFillResults Struct holding amounts to transfer between makers, taker, and fee recipients.\n    function settleMatchedOrders(\n        LibOrder.Order memory leftOrder,\n        LibOrder.Order memory rightOrder,\n        address takerAddress,\n        LibFillResults.MatchedFillResults memory matchedFillResults\n    )\n        private\n    {\n        bytes memory zrxAssetData = ZRX_ASSET_DATA;\n        // Order makers and taker\n        dispatchTransferFrom(\n            leftOrder.makerAssetData,\n            leftOrder.makerAddress,\n            rightOrder.makerAddress,\n            matchedFillResults.right.takerAssetFilledAmount\n        );\n        dispatchTransferFrom(\n            rightOrder.makerAssetData,\n            rightOrder.makerAddress,\n            leftOrder.makerAddress,\n            matchedFillResults.left.takerAssetFilledAmount\n        );\n        dispatchTransferFrom(\n            leftOrder.makerAssetData,\n            leftOrder.makerAddress,\n            takerAddress,\n            matchedFillResults.leftMakerAssetSpreadAmount\n        );\n\n        // Maker fees\n        dispatchTransferFrom(\n            zrxAssetData,\n            leftOrder.makerAddress,\n            leftOrder.feeRecipientAddress,\n            matchedFillResults.left.makerFeePaid\n        );\n        dispatchTransferFrom(\n            zrxAssetData,\n            rightOrder.makerAddress,\n            rightOrder.feeRecipientAddress,\n            matchedFillResults.right.makerFeePaid\n        );\n\n        // Taker fees\n        if (leftOrder.feeRecipientAddress == rightOrder.feeRecipientAddress) {\n            dispatchTransferFrom(\n                zrxAssetData,\n                takerAddress,\n                leftOrder.feeRecipientAddress,\n                safeAdd(\n                    matchedFillResults.left.takerFeePaid,\n                    matchedFillResults.right.takerFeePaid\n                )\n            );\n        } else {\n            dispatchTransferFrom(\n                zrxAssetData,\n                takerAddress,\n                leftOrder.feeRecipientAddress,\n                matchedFillResults.left.takerFeePaid\n            );\n            dispatchTransferFrom(\n                zrxAssetData,\n                takerAddress,\n                rightOrder.feeRecipientAddress,\n                matchedFillResults.right.takerFeePaid\n            );\n        }\n    }\n}\n",
        "protocol/Exchange/MixinSignatureValidator.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../utils/LibBytes/LibBytes.sol\";\nimport \"../../utils/ReentrancyGuard/ReentrancyGuard.sol\";\nimport \"./mixins/MSignatureValidator.sol\";\nimport \"./mixins/MTransactions.sol\";\nimport \"./interfaces/IWallet.sol\";\nimport \"./interfaces/IValidator.sol\";\n\n\ncontract MixinSignatureValidator is\n    ReentrancyGuard,\n    MSignatureValidator,\n    MTransactions\n{\n    using LibBytes for bytes;\n    \n    // Mapping of hash => signer => signed\n    mapping (bytes32 => mapping (address => bool)) public preSigned;\n\n    // Mapping of signer => validator => approved\n    mapping (address => mapping (address => bool)) public allowedValidators;\n\n    /// @dev Approves a hash on-chain using any valid signature type.\n    ///      After presigning a hash, the preSign signature type will become valid for that hash and signer.\n    /// @param signerAddress Address that should have signed the given hash.\n    /// @param signature Proof that the hash has been signed by signer.\n    function preSign(\n        bytes32 hash,\n        address signerAddress,\n        bytes signature\n    )\n        external\n    {\n        if (signerAddress != msg.sender) {\n            require(\n                isValidSignature(\n                    hash,\n                    signerAddress,\n                    signature\n                ),\n                \"INVALID_SIGNATURE\"\n            );\n        }\n        preSigned[hash][signerAddress] = true;\n    }\n\n    /// @dev Approves/unnapproves a Validator contract to verify signatures on signer's behalf.\n    /// @param validatorAddress Address of Validator contract.\n    /// @param approval Approval or disapproval of  Validator contract.\n    function setSignatureValidatorApproval(\n        address validatorAddress,\n        bool approval\n    )\n        external\n        nonReentrant\n    {\n        address signerAddress = getCurrentContextAddress();\n        allowedValidators[signerAddress][validatorAddress] = approval;\n        emit SignatureValidatorApproval(\n            signerAddress,\n            validatorAddress,\n            approval\n        );\n    }\n\n    /// @dev Verifies that a hash has been signed by the given signer.\n    /// @param hash Any 32 byte hash.\n    /// @param signerAddress Address that should have signed the given hash.\n    /// @param signature Proof that the hash has been signed by signer.\n    /// @return True if the address recovered from the provided signature matches the input signer address.\n    function isValidSignature(\n        bytes32 hash,\n        address signerAddress,\n        bytes memory signature\n    )\n        public\n        view\n        returns (bool isValid)\n    {\n        require(\n            signature.length > 0,\n            \"LENGTH_GREATER_THAN_0_REQUIRED\"\n        );\n\n        // Pop last byte off of signature byte array.\n        uint8 signatureTypeRaw = uint8(signature.popLastByte());\n\n        // Ensure signature is supported\n        require(\n            signatureTypeRaw < uint8(SignatureType.NSignatureTypes),\n            \"SIGNATURE_UNSUPPORTED\"\n        );\n\n        SignatureType signatureType = SignatureType(signatureTypeRaw);\n\n        // Variables are not scoped in Solidity.\n        uint8 v;\n        bytes32 r;\n        bytes32 s;\n        address recovered;\n\n        // Always illegal signature.\n        // This is always an implicit option since a signer can create a\n        // signature array with invalid type or length. We may as well make\n        // it an explicit option. This aids testing and analysis. It is\n        // also the initialization value for the enum type.\n        if (signatureType == SignatureType.Illegal) {\n            revert(\"SIGNATURE_ILLEGAL\");\n\n        // Always invalid signature.\n        // Like Illegal, this is always implicitly available and therefore\n        // offered explicitly. It can be implicitly created by providing\n        // a correctly formatted but incorrect signature.\n        } else if (signatureType == SignatureType.Invalid) {\n            require(\n                signature.length == 0,\n                \"LENGTH_0_REQUIRED\"\n            );\n            isValid = false;\n            return isValid;\n\n        // Signature using EIP712\n        } else if (signatureType == SignatureType.EIP712) {\n            require(\n                signature.length == 65,\n                \"LENGTH_65_REQUIRED\"\n            );\n            v = uint8(signature[0]);\n            r = signature.readBytes32(1);\n            s = signature.readBytes32(33);\n            recovered = ecrecover(\n                hash,\n                v,\n                r,\n                s\n            );\n            isValid = signerAddress == recovered;\n            return isValid;\n\n        // Signed using web3.eth_sign\n        } else if (signatureType == SignatureType.EthSign) {\n            require(\n                signature.length == 65,\n                \"LENGTH_65_REQUIRED\"\n            );\n            v = uint8(signature[0]);\n            r = signature.readBytes32(1);\n            s = signature.readBytes32(33);\n            recovered = ecrecover(\n                keccak256(abi.encodePacked(\n                    \"\\x19Ethereum Signed Message:\\n32\",\n                    hash\n                )),\n                v,\n                r,\n                s\n            );\n            isValid = signerAddress == recovered;\n            return isValid;\n\n        // Signature verified by wallet contract.\n        // If used with an order, the maker of the order is the wallet contract.\n        } else if (signatureType == SignatureType.Wallet) {\n            isValid = isValidWalletSignature(\n                hash,\n                signerAddress,\n                signature\n            );\n            return isValid;\n\n        // Signature verified by validator contract.\n        // If used with an order, the maker of the order can still be an EOA.\n        // A signature using this type should be encoded as:\n        // | Offset   | Length | Contents                        |\n        // | 0x00     | x      | Signature to validate           |\n        // | 0x00 + x | 20     | Address of validator contract   |\n        // | 0x14 + x | 1      | Signature type is always \"\\x06\" |\n        } else if (signatureType == SignatureType.Validator) {\n            // Pop last 20 bytes off of signature byte array.\n            address validatorAddress = signature.popLast20Bytes();\n            \n            // Ensure signer has approved validator.\n            if (!allowedValidators[signerAddress][validatorAddress]) {\n                return false;\n            }\n            isValid = isValidValidatorSignature(\n                validatorAddress,\n                hash,\n                signerAddress,\n                signature\n            );\n            return isValid;\n\n        // Signer signed hash previously using the preSign function.\n        } else if (signatureType == SignatureType.PreSigned) {\n            isValid = preSigned[hash][signerAddress];\n            return isValid;\n        }\n\n        // Anything else is illegal (We do not return false because\n        // the signature may actually be valid, just not in a format\n        // that we currently support. In this case returning false\n        // may lead the caller to incorrectly believe that the\n        // signature was invalid.)\n        revert(\"SIGNATURE_UNSUPPORTED\");\n    }\n\n    /// @dev Verifies signature using logic defined by Wallet contract.\n    /// @param hash Any 32 byte hash.\n    /// @param walletAddress Address that should have signed the given hash\n    ///                      and defines its own signature verification method.\n    /// @param signature Proof that the hash has been signed by signer.\n    /// @return True if signature is valid for given wallet..\n    function isValidWalletSignature(\n        bytes32 hash,\n        address walletAddress,\n        bytes signature\n    )\n        internal\n        view\n        returns (bool isValid)\n    {\n        bytes memory calldata = abi.encodeWithSelector(\n            IWallet(walletAddress).isValidSignature.selector,\n            hash,\n            signature\n        );\n        assembly {\n            let cdStart := add(calldata, 32)\n            let success := staticcall(\n                gas,              // forward all gas\n                walletAddress,    // address of Wallet contract\n                cdStart,          // pointer to start of input\n                mload(calldata),  // length of input\n                cdStart,          // write output over input\n                32                // output size is 32 bytes\n            )\n\n            switch success\n            case 0 {\n                // Revert with `Error(\"WALLET_ERROR\")`\n                mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)\n                mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)\n                mstore(64, 0x0000000c57414c4c45545f4552524f5200000000000000000000000000000000)\n                mstore(96, 0)\n                revert(0, 100)\n            }\n            case 1 {\n                // Signature is valid if call did not revert and returned true\n                isValid := mload(cdStart)\n            }\n        }\n        return isValid;\n    }\n\n    /// @dev Verifies signature using logic defined by Validator contract.\n    /// @param validatorAddress Address of validator contract.\n    /// @param hash Any 32 byte hash.\n    /// @param signerAddress Address that should have signed the given hash.\n    /// @param signature Proof that the hash has been signed by signer.\n    /// @return True if the address recovered from the provided signature matches the input signer address.\n    function isValidValidatorSignature(\n        address validatorAddress,\n        bytes32 hash,\n        address signerAddress,\n        bytes signature\n    )\n        internal\n        view\n        returns (bool isValid)\n    {\n        bytes memory calldata = abi.encodeWithSelector(\n            IValidator(signerAddress).isValidSignature.selector,\n            hash,\n            signerAddress,\n            signature\n        );\n        assembly {\n            let cdStart := add(calldata, 32)\n            let success := staticcall(\n                gas,               // forward all gas\n                validatorAddress,  // address of Validator contract\n                cdStart,           // pointer to start of input\n                mload(calldata),   // length of input\n                cdStart,           // write output over input\n                32                 // output size is 32 bytes\n            )\n\n            switch success\n            case 0 {\n                // Revert with `Error(\"VALIDATOR_ERROR\")`\n                mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)\n                mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)\n                mstore(64, 0x0000000f56414c494441544f525f4552524f5200000000000000000000000000)\n                mstore(96, 0)\n                revert(0, 100)\n            }\n            case 1 {\n                // Signature is valid if call did not revert and returned true\n                isValid := mload(cdStart)\n            }\n        }\n        return isValid;\n    }\n}\n",
        "protocol/Exchange/MixinTransactions.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\npragma solidity 0.4.24;\n\nimport \"./libs/LibExchangeErrors.sol\";\nimport \"./mixins/MSignatureValidator.sol\";\nimport \"./mixins/MTransactions.sol\";\nimport \"./libs/LibEIP712.sol\";\n\n\ncontract MixinTransactions is\n    LibEIP712,\n    MSignatureValidator,\n    MTransactions\n{\n    // Mapping of transaction hash => executed\n    // This prevents transactions from being executed more than once.\n    mapping (bytes32 => bool) public transactions;\n\n    // Address of current transaction signer\n    address public currentContextAddress;\n\n    /// @dev Executes an exchange method call in the context of signer.\n    /// @param salt Arbitrary number to ensure uniqueness of transaction hash.\n    /// @param signerAddress Address of transaction signer.\n    /// @param data AbiV2 encoded calldata.\n    /// @param signature Proof of signer transaction by signer.\n    function executeTransaction(\n        uint256 salt,\n        address signerAddress,\n        bytes data,\n        bytes signature\n    )\n        external\n    {\n        // Prevent reentrancy\n        require(\n            currentContextAddress == address(0),\n            \"REENTRANCY_ILLEGAL\"\n        );\n\n        bytes32 transactionHash = hashEIP712Message(hashZeroExTransaction(\n            salt,\n            signerAddress,\n            data\n        ));\n\n        // Validate transaction has not been executed\n        require(\n            !transactions[transactionHash],\n            \"INVALID_TX_HASH\"\n        );\n\n        // Transaction always valid if signer is sender of transaction\n        if (signerAddress != msg.sender) {\n            // Validate signature\n            require(\n                isValidSignature(\n                    transactionHash,\n                    signerAddress,\n                    signature\n                ),\n                \"INVALID_TX_SIGNATURE\"\n            );\n\n            // Set the current transaction signer\n            currentContextAddress = signerAddress;\n        }\n\n        // Execute transaction\n        transactions[transactionHash] = true;\n        require(\n            address(this).delegatecall(data),\n            \"FAILED_EXECUTION\"\n        );\n\n        // Reset current transaction signer if it was previously updated\n        if (signerAddress != msg.sender) {\n            currentContextAddress = address(0);\n        }\n    }\n\n    /// @dev Calculates EIP712 hash of the Transaction.\n    /// @param salt Arbitrary number to ensure uniqueness of transaction hash.\n    /// @param signerAddress Address of transaction signer.\n    /// @param data AbiV2 encoded calldata.\n    /// @return EIP712 hash of the Transaction.\n    function hashZeroExTransaction(\n        uint256 salt,\n        address signerAddress,\n        bytes memory data\n    )\n        internal\n        pure\n        returns (bytes32 result)\n    {\n        bytes32 schemaHash = EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH;\n        bytes32 dataHash = keccak256(data);\n\n        // Assembly for more efficiently computing:\n        // keccak256(abi.encodePacked(\n        //     EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH,\n        //     salt,\n        //     bytes32(signerAddress),\n        //     keccak256(data)\n        // ));\n\n        assembly {\n            // Load free memory pointer\n            let memPtr := mload(64)\n\n            mstore(memPtr, schemaHash)                                                               // hash of schema\n            mstore(add(memPtr, 32), salt)                                                            // salt\n            mstore(add(memPtr, 64), and(signerAddress, 0xffffffffffffffffffffffffffffffffffffffff))  // signerAddress\n            mstore(add(memPtr, 96), dataHash)                                                        // hash of data\n\n            // Compute hash\n            result := keccak256(memPtr, 128)\n        }\n        return result;\n    }\n\n    /// @dev The current function will be called in the context of this address (either 0x transaction signer or `msg.sender`).\n    ///      If calling a fill function, this address will represent the taker.\n    ///      If calling a cancel function, this address will represent the maker.\n    /// @return Signer of 0x transaction if entry point is `executeTransaction`.\n    ///         `msg.sender` if entry point is any other function.\n    function getCurrentContextAddress()\n        internal\n        view\n        returns (address)\n    {\n        address currentContextAddress_ = currentContextAddress;\n        address contextAddress = currentContextAddress_ == address(0) ? msg.sender : currentContextAddress_;\n        return contextAddress;\n    }\n}\n",
        "protocol/Exchange/MixinWrapperFunctions.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../../utils/ReentrancyGuard/ReentrancyGuard.sol\";\nimport \"./libs/LibMath.sol\";\nimport \"./libs/LibOrder.sol\";\nimport \"./libs/LibFillResults.sol\";\nimport \"./libs/LibAbiEncoder.sol\";\nimport \"./mixins/MExchangeCore.sol\";\nimport \"./mixins/MWrapperFunctions.sol\";\n\n\ncontract MixinWrapperFunctions is\n    ReentrancyGuard,\n    LibMath,\n    LibFillResults,\n    LibAbiEncoder,\n    MExchangeCore,\n    MWrapperFunctions\n{\n    /// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    function fillOrKillOrder(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        public\n        nonReentrant\n        returns (FillResults memory fillResults)\n    {\n        fillResults = fillOrKillOrderInternal(\n            order,\n            takerAssetFillAmount,\n            signature\n        );\n        return fillResults;\n    }\n\n    /// @dev Fills the input order.\n    ///      Returns false if the transaction would otherwise revert.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    /// @return Amounts filled and fees paid by maker and taker.\n    function fillOrderNoThrow(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        public\n        returns (FillResults memory fillResults)\n    {\n        // ABI encode calldata for `fillOrder`\n        bytes memory fillOrderCalldata = abiEncodeFillOrder(\n            order,\n            takerAssetFillAmount,\n            signature\n        );\n\n        // Delegate to `fillOrder` and handle any exceptions gracefully\n        assembly {\n            let success := delegatecall(\n                gas,                                // forward all gas\n                address,                            // call address of this contract\n                add(fillOrderCalldata, 32),         // pointer to start of input (skip array length in first 32 bytes)\n                mload(fillOrderCalldata),           // length of input\n                fillOrderCalldata,                  // write output over input\n                128                                 // output size is 128 bytes\n            )\n            if success {\n                mstore(fillResults, mload(fillOrderCalldata))\n                mstore(add(fillResults, 32), mload(add(fillOrderCalldata, 32)))\n                mstore(add(fillResults, 64), mload(add(fillOrderCalldata, 64)))\n                mstore(add(fillResults, 96), mload(add(fillOrderCalldata, 96)))\n            }\n        }\n        // fillResults values will be 0 by default if call was unsuccessful\n        return fillResults;\n    }\n\n    /// @dev Synchronously executes multiple calls of fillOrder.\n    /// @param orders Array of order specifications.\n    /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.\n    /// @param signatures Proofs that orders have been created by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    ///         NOTE: makerAssetFilledAmount and takerAssetFilledAmount may include amounts filled of different assets.\n    function batchFillOrders(\n        LibOrder.Order[] memory orders,\n        uint256[] memory takerAssetFillAmounts,\n        bytes[] memory signatures\n    )\n        public\n        nonReentrant\n        returns (FillResults memory totalFillResults)\n    {\n        uint256 ordersLength = orders.length;\n        for (uint256 i = 0; i != ordersLength; i++) {\n            FillResults memory singleFillResults = fillOrderInternal(\n                orders[i],\n                takerAssetFillAmounts[i],\n                signatures[i]\n            );\n            addFillResults(totalFillResults, singleFillResults);\n        }\n        return totalFillResults;\n    }\n\n    /// @dev Synchronously executes multiple calls of fillOrKill.\n    /// @param orders Array of order specifications.\n    /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.\n    /// @param signatures Proofs that orders have been created by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    ///         NOTE: makerAssetFilledAmount and takerAssetFilledAmount may include amounts filled of different assets.\n    function batchFillOrKillOrders(\n        LibOrder.Order[] memory orders,\n        uint256[] memory takerAssetFillAmounts,\n        bytes[] memory signatures\n    )\n        public\n        nonReentrant\n        returns (FillResults memory totalFillResults)\n    {\n        uint256 ordersLength = orders.length;\n        for (uint256 i = 0; i != ordersLength; i++) {\n            FillResults memory singleFillResults = fillOrKillOrderInternal(\n                orders[i],\n                takerAssetFillAmounts[i],\n                signatures[i]\n            );\n            addFillResults(totalFillResults, singleFillResults);\n        }\n        return totalFillResults;\n    }\n\n    /// @dev Fills an order with specified parameters and ECDSA signature.\n    ///      Returns false if the transaction would otherwise revert.\n    /// @param orders Array of order specifications.\n    /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.\n    /// @param signatures Proofs that orders have been created by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    ///         NOTE: makerAssetFilledAmount and takerAssetFilledAmount may include amounts filled of different assets.\n    function batchFillOrdersNoThrow(\n        LibOrder.Order[] memory orders,\n        uint256[] memory takerAssetFillAmounts,\n        bytes[] memory signatures\n    )\n        public\n        returns (FillResults memory totalFillResults)\n    {\n        uint256 ordersLength = orders.length;\n        for (uint256 i = 0; i != ordersLength; i++) {\n            FillResults memory singleFillResults = fillOrderNoThrow(\n                orders[i],\n                takerAssetFillAmounts[i],\n                signatures[i]\n            );\n            addFillResults(totalFillResults, singleFillResults);\n        }\n        return totalFillResults;\n    }\n\n    /// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker.\n    /// @param orders Array of order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signatures Proofs that orders have been created by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function marketSellOrders(\n        LibOrder.Order[] memory orders,\n        uint256 takerAssetFillAmount,\n        bytes[] memory signatures\n    )\n        public\n        nonReentrant\n        returns (FillResults memory totalFillResults)\n    {\n        bytes memory takerAssetData = orders[0].takerAssetData;\n    \n        uint256 ordersLength = orders.length;\n        for (uint256 i = 0; i != ordersLength; i++) {\n\n            // We assume that asset being sold by taker is the same for each order.\n            // Rather than passing this in as calldata, we use the takerAssetData from the first order in all later orders.\n            orders[i].takerAssetData = takerAssetData;\n\n            // Calculate the remaining amount of takerAsset to sell\n            uint256 remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, totalFillResults.takerAssetFilledAmount);\n\n            // Attempt to sell the remaining amount of takerAsset\n            FillResults memory singleFillResults = fillOrderInternal(\n                orders[i],\n                remainingTakerAssetFillAmount,\n                signatures[i]\n            );\n\n            // Update amounts filled and fees paid by maker and taker\n            addFillResults(totalFillResults, singleFillResults);\n\n            // Stop execution if the entire amount of takerAsset has been sold\n            if (totalFillResults.takerAssetFilledAmount >= takerAssetFillAmount) {\n                break;\n            }\n        }\n        return totalFillResults;\n    }\n\n    /// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker.\n    ///      Returns false if the transaction would otherwise revert.\n    /// @param orders Array of order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signatures Proofs that orders have been signed by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function marketSellOrdersNoThrow(\n        LibOrder.Order[] memory orders,\n        uint256 takerAssetFillAmount,\n        bytes[] memory signatures\n    )\n        public\n        returns (FillResults memory totalFillResults)\n    {\n        bytes memory takerAssetData = orders[0].takerAssetData;\n\n        uint256 ordersLength = orders.length;\n        for (uint256 i = 0; i != ordersLength; i++) {\n\n            // We assume that asset being sold by taker is the same for each order.\n            // Rather than passing this in as calldata, we use the takerAssetData from the first order in all later orders.\n            orders[i].takerAssetData = takerAssetData;\n\n            // Calculate the remaining amount of takerAsset to sell\n            uint256 remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, totalFillResults.takerAssetFilledAmount);\n\n            // Attempt to sell the remaining amount of takerAsset\n            FillResults memory singleFillResults = fillOrderNoThrow(\n                orders[i],\n                remainingTakerAssetFillAmount,\n                signatures[i]\n            );\n\n            // Update amounts filled and fees paid by maker and taker\n            addFillResults(totalFillResults, singleFillResults);\n\n            // Stop execution if the entire amount of takerAsset has been sold\n            if (totalFillResults.takerAssetFilledAmount >= takerAssetFillAmount) {\n                break;\n            }\n        }\n        return totalFillResults;\n    }\n\n    /// @dev Synchronously executes multiple calls of fillOrder until total amount of makerAsset is bought by taker.\n    /// @param orders Array of order specifications.\n    /// @param makerAssetFillAmount Desired amount of makerAsset to buy.\n    /// @param signatures Proofs that orders have been signed by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function marketBuyOrders(\n        LibOrder.Order[] memory orders,\n        uint256 makerAssetFillAmount,\n        bytes[] memory signatures\n    )\n        public\n        nonReentrant\n        returns (FillResults memory totalFillResults)\n    {\n        bytes memory makerAssetData = orders[0].makerAssetData;\n\n        uint256 ordersLength = orders.length;\n        for (uint256 i = 0; i != ordersLength; i++) {\n\n            // We assume that asset being bought by taker is the same for each order.\n            // Rather than passing this in as calldata, we copy the makerAssetData from the first order onto all later orders.\n            orders[i].makerAssetData = makerAssetData;\n\n            // Calculate the remaining amount of makerAsset to buy\n            uint256 remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount);\n\n            // Convert the remaining amount of makerAsset to buy into remaining amount\n            // of takerAsset to sell, assuming entire amount can be sold in the current order\n            uint256 remainingTakerAssetFillAmount = getPartialAmountFloor(\n                orders[i].takerAssetAmount,\n                orders[i].makerAssetAmount,\n                remainingMakerAssetFillAmount\n            );\n\n            // Attempt to sell the remaining amount of takerAsset\n            FillResults memory singleFillResults = fillOrderInternal(\n                orders[i],\n                remainingTakerAssetFillAmount,\n                signatures[i]\n            );\n\n            // Update amounts filled and fees paid by maker and taker\n            addFillResults(totalFillResults, singleFillResults);\n\n            // Stop execution if the entire amount of makerAsset has been bought\n            if (totalFillResults.makerAssetFilledAmount >= makerAssetFillAmount) {\n                break;\n            }\n        }\n        return totalFillResults;\n    }\n\n    /// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker.\n    ///      Returns false if the transaction would otherwise revert.\n    /// @param orders Array of order specifications.\n    /// @param makerAssetFillAmount Desired amount of makerAsset to buy.\n    /// @param signatures Proofs that orders have been signed by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function marketBuyOrdersNoThrow(\n        LibOrder.Order[] memory orders,\n        uint256 makerAssetFillAmount,\n        bytes[] memory signatures\n    )\n        public\n        returns (FillResults memory totalFillResults)\n    {\n        bytes memory makerAssetData = orders[0].makerAssetData;\n\n        uint256 ordersLength = orders.length;\n        for (uint256 i = 0; i != ordersLength; i++) {\n\n            // We assume that asset being bought by taker is the same for each order.\n            // Rather than passing this in as calldata, we copy the makerAssetData from the first order onto all later orders.\n            orders[i].makerAssetData = makerAssetData;\n\n            // Calculate the remaining amount of makerAsset to buy\n            uint256 remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount);\n\n            // Convert the remaining amount of makerAsset to buy into remaining amount\n            // of takerAsset to sell, assuming entire amount can be sold in the current order\n            uint256 remainingTakerAssetFillAmount = getPartialAmountFloor(\n                orders[i].takerAssetAmount,\n                orders[i].makerAssetAmount,\n                remainingMakerAssetFillAmount\n            );\n\n            // Attempt to sell the remaining amount of takerAsset\n            FillResults memory singleFillResults = fillOrderNoThrow(\n                orders[i],\n                remainingTakerAssetFillAmount,\n                signatures[i]\n            );\n\n            // Update amounts filled and fees paid by maker and taker\n            addFillResults(totalFillResults, singleFillResults);\n\n            // Stop execution if the entire amount of makerAsset has been bought\n            if (totalFillResults.makerAssetFilledAmount >= makerAssetFillAmount) {\n                break;\n            }\n        }\n        return totalFillResults;\n    }\n\n    /// @dev Synchronously cancels multiple orders in a single transaction.\n    /// @param orders Array of order specifications.\n    function batchCancelOrders(LibOrder.Order[] memory orders)\n        public\n        nonReentrant\n    {\n        uint256 ordersLength = orders.length;\n        for (uint256 i = 0; i != ordersLength; i++) {\n            cancelOrderInternal(orders[i]);\n        }\n    }\n\n    /// @dev Fetches information for all passed in orders.\n    /// @param orders Array of order specifications.\n    /// @return Array of OrderInfo instances that correspond to each order.\n    function getOrdersInfo(LibOrder.Order[] memory orders)\n        public\n        view\n        returns (LibOrder.OrderInfo[] memory)\n    {\n        uint256 ordersLength = orders.length;\n        LibOrder.OrderInfo[] memory ordersInfo = new LibOrder.OrderInfo[](ordersLength);\n        for (uint256 i = 0; i != ordersLength; i++) {\n            ordersInfo[i] = getOrderInfo(orders[i]);\n        }\n        return ordersInfo;\n    }\n\n    /// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    function fillOrKillOrderInternal(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        internal\n        returns (FillResults memory fillResults)\n    {\n        fillResults = fillOrderInternal(\n            order,\n            takerAssetFillAmount,\n            signature\n        );\n        require(\n            fillResults.takerAssetFilledAmount == takerAssetFillAmount,\n            \"COMPLETE_FILL_FAILED\"\n        );\n        return fillResults;\n    }\n}\n",
        "protocol/Exchange/interfaces/IAssetProxyDispatcher.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\ncontract IAssetProxyDispatcher {\n\n    /// @dev Registers an asset proxy to its asset proxy id.\n    ///      Once an asset proxy is registered, it cannot be unregistered.\n    /// @param assetProxy Address of new asset proxy to register.\n    function registerAssetProxy(address assetProxy)\n        external;\n\n    /// @dev Gets an asset proxy.\n    /// @param assetProxyId Id of the asset proxy.\n    /// @return The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered.\n    function getAssetProxy(bytes4 assetProxyId)\n        external\n        view\n        returns (address);\n}\n",
        "protocol/Exchange/interfaces/IExchange.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"./IExchangeCore.sol\";\nimport \"./IMatchOrders.sol\";\nimport \"./ISignatureValidator.sol\";\nimport \"./ITransactions.sol\";\nimport \"./IAssetProxyDispatcher.sol\";\nimport \"./IWrapperFunctions.sol\";\n\n\n// solhint-disable no-empty-blocks\ncontract IExchange is\n    IExchangeCore,\n    IMatchOrders,\n    ISignatureValidator,\n    ITransactions,\n    IAssetProxyDispatcher,\n    IWrapperFunctions\n{}\n",
        "protocol/Exchange/interfaces/IExchangeCore.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../libs/LibOrder.sol\";\nimport \"../libs/LibFillResults.sol\";\n\n\ncontract IExchangeCore {\n\n    /// @dev Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch\n    ///      and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress).\n    /// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled.\n    function cancelOrdersUpTo(uint256 targetOrderEpoch)\n        external;\n\n    /// @dev Fills the input order.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    /// @return Amounts filled and fees paid by maker and taker.\n    function fillOrder(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        public\n        returns (LibFillResults.FillResults memory fillResults);\n\n    /// @dev After calling, the order can not be filled anymore.\n    /// @param order Order struct containing order specifications.\n    function cancelOrder(LibOrder.Order memory order)\n        public;\n\n    /// @dev Gets information about an order: status, hash, and amount filled.\n    /// @param order Order to gather information on.\n    /// @return OrderInfo Information about the order and its state.\n    ///                   See LibOrder.OrderInfo for a complete description.\n    function getOrderInfo(LibOrder.Order memory order)\n        public\n        view\n        returns (LibOrder.OrderInfo memory orderInfo);\n}\n",
        "protocol/Exchange/interfaces/IMatchOrders.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../libs/LibOrder.sol\";\nimport \"../libs/LibFillResults.sol\";\n\n\ncontract IMatchOrders {\n\n    /// @dev Match two complementary orders that have a profitable spread.\n    ///      Each order is filled at their respective price point. However, the calculations are\n    ///      carried out as though the orders are both being filled at the right order's price point.\n    ///      The profit made by the left order goes to the taker (who matched the two orders).\n    /// @param leftOrder First order to match.\n    /// @param rightOrder Second order to match.\n    /// @param leftSignature Proof that order was created by the left maker.\n    /// @param rightSignature Proof that order was created by the right maker.\n    /// @return matchedFillResults Amounts filled and fees paid by maker and taker of matched orders.\n    function matchOrders(\n        LibOrder.Order memory leftOrder,\n        LibOrder.Order memory rightOrder,\n        bytes memory leftSignature,\n        bytes memory rightSignature\n    )\n        public\n        returns (LibFillResults.MatchedFillResults memory matchedFillResults);\n}\n",
        "protocol/Exchange/interfaces/ISignatureValidator.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\ncontract ISignatureValidator {\n\n    /// @dev Approves a hash on-chain using any valid signature type.\n    ///      After presigning a hash, the preSign signature type will become valid for that hash and signer.\n    /// @param signerAddress Address that should have signed the given hash.\n    /// @param signature Proof that the hash has been signed by signer.\n    function preSign(\n        bytes32 hash,\n        address signerAddress,\n        bytes signature\n    )\n        external;\n    \n    /// @dev Approves/unnapproves a Validator contract to verify signatures on signer's behalf.\n    /// @param validatorAddress Address of Validator contract.\n    /// @param approval Approval or disapproval of  Validator contract.\n    function setSignatureValidatorApproval(\n        address validatorAddress,\n        bool approval\n    )\n        external;\n\n    /// @dev Verifies that a signature is valid.\n    /// @param hash Message hash that is signed.\n    /// @param signerAddress Address of signer.\n    /// @param signature Proof of signing.\n    /// @return Validity of order signature.\n    function isValidSignature(\n        bytes32 hash,\n        address signerAddress,\n        bytes memory signature\n    )\n        public\n        view\n        returns (bool isValid);\n}\n",
        "protocol/Exchange/interfaces/ITransactions.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\npragma solidity 0.4.24;\n\n\ncontract ITransactions {\n\n    /// @dev Executes an exchange method call in the context of signer.\n    /// @param salt Arbitrary number to ensure uniqueness of transaction hash.\n    /// @param signerAddress Address of transaction signer.\n    /// @param data AbiV2 encoded calldata.\n    /// @param signature Proof of signer transaction by signer.\n    function executeTransaction(\n        uint256 salt,\n        address signerAddress,\n        bytes data,\n        bytes signature\n    )\n        external;\n}\n",
        "protocol/Exchange/interfaces/IValidator.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\ncontract IValidator {\n\n    /// @dev Verifies that a signature is valid.\n    /// @param hash Message hash that is signed.\n    /// @param signerAddress Address that should have signed the given hash.\n    /// @param signature Proof of signing.\n    /// @return Validity of order signature.\n    function isValidSignature(\n        bytes32 hash,\n        address signerAddress,\n        bytes signature\n    )\n        external\n        view\n        returns (bool isValid);\n}\n",
        "protocol/Exchange/interfaces/IWallet.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\ncontract IWallet {\n\n    /// @dev Verifies that a signature is valid.\n    /// @param hash Message hash that is signed.\n    /// @param signature Proof of signing.\n    /// @return Validity of order signature.\n    function isValidSignature(\n        bytes32 hash,\n        bytes signature\n    )\n        external\n        view\n        returns (bool isValid);\n}\n",
        "protocol/Exchange/interfaces/IWrapperFunctions.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../libs/LibOrder.sol\";\nimport \"../libs/LibFillResults.sol\";\n\n\ncontract IWrapperFunctions {\n\n    /// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled.\n    /// @param order LibOrder.Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    function fillOrKillOrder(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        public\n        returns (LibFillResults.FillResults memory fillResults);\n\n    /// @dev Fills an order with specified parameters and ECDSA signature.\n    ///      Returns false if the transaction would otherwise revert.\n    /// @param order LibOrder.Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    /// @return Amounts filled and fees paid by maker and taker.\n    function fillOrderNoThrow(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        public\n        returns (LibFillResults.FillResults memory fillResults);\n\n    /// @dev Synchronously executes multiple calls of fillOrder.\n    /// @param orders Array of order specifications.\n    /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.\n    /// @param signatures Proofs that orders have been created by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function batchFillOrders(\n        LibOrder.Order[] memory orders,\n        uint256[] memory takerAssetFillAmounts,\n        bytes[] memory signatures\n    )\n        public\n        returns (LibFillResults.FillResults memory totalFillResults);\n\n    /// @dev Synchronously executes multiple calls of fillOrKill.\n    /// @param orders Array of order specifications.\n    /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.\n    /// @param signatures Proofs that orders have been created by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function batchFillOrKillOrders(\n        LibOrder.Order[] memory orders,\n        uint256[] memory takerAssetFillAmounts,\n        bytes[] memory signatures\n    )\n        public\n        returns (LibFillResults.FillResults memory totalFillResults);\n\n    /// @dev Fills an order with specified parameters and ECDSA signature.\n    ///      Returns false if the transaction would otherwise revert.\n    /// @param orders Array of order specifications.\n    /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.\n    /// @param signatures Proofs that orders have been created by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function batchFillOrdersNoThrow(\n        LibOrder.Order[] memory orders,\n        uint256[] memory takerAssetFillAmounts,\n        bytes[] memory signatures\n    )\n        public\n        returns (LibFillResults.FillResults memory totalFillResults);\n\n    /// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker.\n    /// @param orders Array of order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signatures Proofs that orders have been created by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function marketSellOrders(\n        LibOrder.Order[] memory orders,\n        uint256 takerAssetFillAmount,\n        bytes[] memory signatures\n    )\n        public\n        returns (LibFillResults.FillResults memory totalFillResults);\n\n    /// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker.\n    ///      Returns false if the transaction would otherwise revert.\n    /// @param orders Array of order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signatures Proofs that orders have been signed by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function marketSellOrdersNoThrow(\n        LibOrder.Order[] memory orders,\n        uint256 takerAssetFillAmount,\n        bytes[] memory signatures\n    )\n        public\n        returns (LibFillResults.FillResults memory totalFillResults);\n\n    /// @dev Synchronously executes multiple calls of fillOrder until total amount of makerAsset is bought by taker.\n    /// @param orders Array of order specifications.\n    /// @param makerAssetFillAmount Desired amount of makerAsset to buy.\n    /// @param signatures Proofs that orders have been signed by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function marketBuyOrders(\n        LibOrder.Order[] memory orders,\n        uint256 makerAssetFillAmount,\n        bytes[] memory signatures\n    )\n        public\n        returns (LibFillResults.FillResults memory totalFillResults);\n\n    /// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker.\n    ///      Returns false if the transaction would otherwise revert.\n    /// @param orders Array of order specifications.\n    /// @param makerAssetFillAmount Desired amount of makerAsset to buy.\n    /// @param signatures Proofs that orders have been signed by makers.\n    /// @return Amounts filled and fees paid by makers and taker.\n    function marketBuyOrdersNoThrow(\n        LibOrder.Order[] memory orders,\n        uint256 makerAssetFillAmount,\n        bytes[] memory signatures\n    )\n        public\n        returns (LibFillResults.FillResults memory totalFillResults);\n\n    /// @dev Synchronously cancels multiple orders in a single transaction.\n    /// @param orders Array of order specifications.\n    function batchCancelOrders(LibOrder.Order[] memory orders)\n        public;\n\n    /// @dev Fetches information for all passed in orders\n    /// @param orders Array of order specifications.\n    /// @return Array of OrderInfo instances that correspond to each order.\n    function getOrdersInfo(LibOrder.Order[] memory orders)\n        public\n        view\n        returns (LibOrder.OrderInfo[] memory);\n}\n",
        "protocol/Exchange/libs/LibAbiEncoder.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"./LibOrder.sol\";\n\n\ncontract LibAbiEncoder {\n\n    /// @dev ABI encodes calldata for `fillOrder`.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    /// @return ABI encoded calldata for `fillOrder`.\n    function abiEncodeFillOrder(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        internal\n        pure\n        returns (bytes memory fillOrderCalldata)\n    {\n        // We need to call MExchangeCore.fillOrder using a delegatecall in\n        // assembly so that we can intercept a call that throws. For this, we\n        // need the input encoded in memory in the Ethereum ABIv2 format [1].\n\n        // | Area     | Offset | Length  | Contents                                    |\n        // | -------- |--------|---------|-------------------------------------------- |\n        // | Header   | 0x00   | 4       | function selector                           |\n        // | Params   |        | 3 * 32  | function parameters:                        |\n        // |          | 0x00   |         |   1. offset to order (*)                    |\n        // |          | 0x20   |         |   2. takerAssetFillAmount                   |\n        // |          | 0x40   |         |   3. offset to signature (*)                |\n        // | Data     |        | 12 * 32 | order:                                      |\n        // |          | 0x000  |         |   1.  senderAddress                         |\n        // |          | 0x020  |         |   2.  makerAddress                          |\n        // |          | 0x040  |         |   3.  takerAddress                          |\n        // |          | 0x060  |         |   4.  feeRecipientAddress                   |\n        // |          | 0x080  |         |   5.  makerAssetAmount                      |\n        // |          | 0x0A0  |         |   6.  takerAssetAmount                      |\n        // |          | 0x0C0  |         |   7.  makerFeeAmount                        |\n        // |          | 0x0E0  |         |   8.  takerFeeAmount                        |\n        // |          | 0x100  |         |   9.  expirationTimeSeconds                 |\n        // |          | 0x120  |         |   10. salt                                  |\n        // |          | 0x140  |         |   11. Offset to makerAssetData (*)          |\n        // |          | 0x160  |         |   12. Offset to takerAssetData (*)          |\n        // |          | 0x180  | 32      | makerAssetData Length                       |\n        // |          | 0x1A0  | **      | makerAssetData Contents                     |\n        // |          | 0x1C0  | 32      | takerAssetData Length                       |\n        // |          | 0x1E0  | **      | takerAssetData Contents                     |\n        // |          | 0x200  | 32      | signature Length                            |\n        // |          | 0x220  | **      | signature Contents                          |\n\n        // * Offsets are calculated from the beginning of the current area: Header, Params, Data:\n        //     An offset stored in the Params area is calculated from the beginning of the Params section.\n        //     An offset stored in the Data area is calculated from the beginning of the Data section.\n\n        // ** The length of dynamic array contents are stored in the field immediately preceeding the contents.\n\n        // [1]: https://solidity.readthedocs.io/en/develop/abi-spec.html\n\n        assembly {\n\n            // Areas below may use the following variables:\n            //   1. <area>Start   -- Start of this area in memory\n            //   2. <area>End     -- End of this area in memory. This value may\n            //                       be precomputed (before writing contents),\n            //                       or it may be computed as contents are written.\n            //   3. <area>Offset  -- Current offset into area. If an area's End\n            //                       is precomputed, this variable tracks the\n            //                       offsets of contents as they are written.\n\n            /////// Setup Header Area ///////\n            // Load free memory pointer\n            fillOrderCalldata := mload(0x40)\n            // bytes4(keccak256(\"fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)\"))\n            // = 0xb4be83d5\n            // Leave 0x20 bytes to store the length\n            mstore(add(fillOrderCalldata, 0x20), 0xb4be83d500000000000000000000000000000000000000000000000000000000)\n            let headerAreaEnd := add(fillOrderCalldata, 0x24)\n\n            /////// Setup Params Area ///////\n            // This area is preallocated and written to later.\n            // This is because we need to fill in offsets that have not yet been calculated.\n            let paramsAreaStart := headerAreaEnd\n            let paramsAreaEnd := add(paramsAreaStart, 0x60)\n            let paramsAreaOffset := paramsAreaStart\n\n            /////// Setup Data Area ///////\n            let dataAreaStart := paramsAreaEnd\n            let dataAreaEnd := dataAreaStart\n\n            // Offset from the source data we're reading from\n            let sourceOffset := order\n            // arrayLenBytes and arrayLenWords track the length of a dynamically-allocated bytes array.\n            let arrayLenBytes := 0\n            let arrayLenWords := 0\n\n            /////// Write order Struct ///////\n            // Write memory location of Order, relative to the start of the\n            // parameter list, then increment the paramsAreaOffset respectively.\n            mstore(paramsAreaOffset, sub(dataAreaEnd, paramsAreaStart))\n            paramsAreaOffset := add(paramsAreaOffset, 0x20)\n\n            // Write values for each field in the order\n            // It would be nice to use a loop, but we save on gas by writing\n            // the stores sequentially.\n            mstore(dataAreaEnd, mload(sourceOffset))                            // makerAddress\n            mstore(add(dataAreaEnd, 0x20), mload(add(sourceOffset, 0x20)))      // takerAddress\n            mstore(add(dataAreaEnd, 0x40), mload(add(sourceOffset, 0x40)))      // feeRecipientAddress\n            mstore(add(dataAreaEnd, 0x60), mload(add(sourceOffset, 0x60)))      // senderAddress\n            mstore(add(dataAreaEnd, 0x80), mload(add(sourceOffset, 0x80)))      // makerAssetAmount\n            mstore(add(dataAreaEnd, 0xA0), mload(add(sourceOffset, 0xA0)))      // takerAssetAmount\n            mstore(add(dataAreaEnd, 0xC0), mload(add(sourceOffset, 0xC0)))      // makerFeeAmount\n            mstore(add(dataAreaEnd, 0xE0), mload(add(sourceOffset, 0xE0)))      // takerFeeAmount\n            mstore(add(dataAreaEnd, 0x100), mload(add(sourceOffset, 0x100)))    // expirationTimeSeconds\n            mstore(add(dataAreaEnd, 0x120), mload(add(sourceOffset, 0x120)))    // salt\n            mstore(add(dataAreaEnd, 0x140), mload(add(sourceOffset, 0x140)))    // Offset to makerAssetData\n            mstore(add(dataAreaEnd, 0x160), mload(add(sourceOffset, 0x160)))    // Offset to takerAssetData\n            dataAreaEnd := add(dataAreaEnd, 0x180)\n            sourceOffset := add(sourceOffset, 0x180)\n\n            // Write offset to <order.makerAssetData>\n            mstore(add(dataAreaStart, mul(10, 0x20)), sub(dataAreaEnd, dataAreaStart))\n\n            // Calculate length of <order.makerAssetData>\n            sourceOffset := mload(add(order, 0x140)) // makerAssetData\n            arrayLenBytes := mload(sourceOffset)\n            sourceOffset := add(sourceOffset, 0x20)\n            arrayLenWords := div(add(arrayLenBytes, 0x1F), 0x20)\n\n            // Write length of <order.makerAssetData>\n            mstore(dataAreaEnd, arrayLenBytes)\n            dataAreaEnd := add(dataAreaEnd, 0x20)\n\n            // Write contents of <order.makerAssetData>\n            for {let i := 0} lt(i, arrayLenWords) {i := add(i, 1)} {\n                mstore(dataAreaEnd, mload(sourceOffset))\n                dataAreaEnd := add(dataAreaEnd, 0x20)\n                sourceOffset := add(sourceOffset, 0x20)\n            }\n\n            // Write offset to <order.takerAssetData>\n            mstore(add(dataAreaStart, mul(11, 0x20)), sub(dataAreaEnd, dataAreaStart))\n\n            // Calculate length of <order.takerAssetData>\n            sourceOffset := mload(add(order, 0x160)) // takerAssetData\n            arrayLenBytes := mload(sourceOffset)\n            sourceOffset := add(sourceOffset, 0x20)\n            arrayLenWords := div(add(arrayLenBytes, 0x1F), 0x20)\n\n            // Write length of <order.takerAssetData>\n            mstore(dataAreaEnd, arrayLenBytes)\n            dataAreaEnd := add(dataAreaEnd, 0x20)\n\n            // Write contents of  <order.takerAssetData>\n            for {let i := 0} lt(i, arrayLenWords) {i := add(i, 1)} {\n                mstore(dataAreaEnd, mload(sourceOffset))\n                dataAreaEnd := add(dataAreaEnd, 0x20)\n                sourceOffset := add(sourceOffset, 0x20)\n            }\n\n            /////// Write takerAssetFillAmount ///////\n            mstore(paramsAreaOffset, takerAssetFillAmount)\n            paramsAreaOffset := add(paramsAreaOffset, 0x20)\n\n            /////// Write signature ///////\n            // Write offset to paramsArea\n            mstore(paramsAreaOffset, sub(dataAreaEnd, paramsAreaStart))\n\n            // Calculate length of signature\n            sourceOffset := signature\n            arrayLenBytes := mload(sourceOffset)\n            sourceOffset := add(sourceOffset, 0x20)\n            arrayLenWords := div(add(arrayLenBytes, 0x1F), 0x20)\n\n            // Write length of signature\n            mstore(dataAreaEnd, arrayLenBytes)\n            dataAreaEnd := add(dataAreaEnd, 0x20)\n\n            // Write contents of signature\n            for {let i := 0} lt(i, arrayLenWords) {i := add(i, 1)} {\n                mstore(dataAreaEnd, mload(sourceOffset))\n                dataAreaEnd := add(dataAreaEnd, 0x20)\n                sourceOffset := add(sourceOffset, 0x20)\n            }\n\n            // Set length of calldata\n            mstore(fillOrderCalldata, sub(dataAreaEnd, add(fillOrderCalldata, 0x20)))\n\n            // Increment free memory pointer\n            mstore(0x40, dataAreaEnd)\n        }\n\n        return fillOrderCalldata;\n    }\n}\n",
        "protocol/Exchange/libs/LibConstants.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\n// solhint-disable max-line-length\ncontract LibConstants {\n   \n    // Asset data for ZRX token. Used for fee transfers.\n    // @TODO: Hardcode constant when we deploy. Currently \n    //        not constant to make testing easier.\n\n    // The proxyId for ZRX_ASSET_DATA is bytes4(keccak256(\"ERC20Token(address)\")) = 0xf47261b0\n    \n    // Kovan ZRX address is 0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570.\n    // The ABI encoded proxyId and address is 0xf47261b00000000000000000000000006ff6c0ff1d68b964901f986d4c9fa3ac68346570\n    // bytes constant public ZRX_ASSET_DATA = \"\\xf4\\x72\\x61\\xb0\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x6f\\xf6\\xc0\\xff\\x1d\\x68\\xb9\\x64\\x90\\x1f\\x98\\x6d\\x4c\\x9f\\xa3\\xac\\x68\\x34\\x65\\x70\";\n    \n    // Mainnet ZRX address is 0xe41d2489571d322189246dafa5ebde1f4699f498.\n    // The ABI encoded proxyId and address is 0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498\n    // bytes constant public ZRX_ASSET_DATA = \"\\xf4\\x72\\x61\\xb0\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xe4\\x1d\\x24\\x89\\x57\\x1d\\x32\\x21\\x89\\x24\\x6d\\xaf\\xa5\\xeb\\xde\\x1f\\x46\\x99\\xf4\\x98\";\n    \n    // solhint-disable-next-line var-name-mixedcase\n    bytes public ZRX_ASSET_DATA;\n\n    // @TODO: Remove when we deploy.\n    constructor (bytes memory zrxAssetData)\n        public\n    {\n        ZRX_ASSET_DATA = zrxAssetData;\n    }\n}\n// solhint-enable max-line-length\n",
        "protocol/Exchange/libs/LibEIP712.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\ncontract LibEIP712 {\n\n    // EIP191 header for EIP712 prefix\n    string constant internal EIP191_HEADER = \"\\x19\\x01\";\n\n    // EIP712 Domain Name value\n    string constant internal EIP712_DOMAIN_NAME = \"0x Protocol\";\n\n    // EIP712 Domain Version value\n    string constant internal EIP712_DOMAIN_VERSION = \"2\";\n\n    // Hash of the EIP712 Domain Separator Schema\n    bytes32 constant internal EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH = keccak256(abi.encodePacked(\n        \"EIP712Domain(\",\n        \"string name,\",\n        \"string version,\",\n        \"address verifyingContract\",\n        \")\"\n    ));\n\n    // Hash of the EIP712 Domain Separator data\n    // solhint-disable-next-line var-name-mixedcase\n    bytes32 public EIP712_DOMAIN_HASH;\n\n    constructor ()\n        public\n    {\n        EIP712_DOMAIN_HASH = keccak256(abi.encodePacked(\n            EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH,\n            keccak256(bytes(EIP712_DOMAIN_NAME)),\n            keccak256(bytes(EIP712_DOMAIN_VERSION)),\n            bytes32(address(this))\n        ));\n    }\n\n    /// @dev Calculates EIP712 encoding for a hash struct in this EIP712 Domain.\n    /// @param hashStruct The EIP712 hash struct.\n    /// @return EIP712 hash applied to this EIP712 Domain.\n    function hashEIP712Message(bytes32 hashStruct)\n        internal\n        view\n        returns (bytes32 result)\n    {\n        bytes32 eip712DomainHash = EIP712_DOMAIN_HASH;\n\n        // Assembly for more efficient computing:\n        // keccak256(abi.encodePacked(\n        //     EIP191_HEADER,\n        //     EIP712_DOMAIN_HASH,\n        //     hashStruct    \n        // ));\n\n        assembly {\n            // Load free memory pointer\n            let memPtr := mload(64)\n\n            mstore(memPtr, 0x1901000000000000000000000000000000000000000000000000000000000000)  // EIP191 header\n            mstore(add(memPtr, 2), eip712DomainHash)                                            // EIP712 domain hash\n            mstore(add(memPtr, 34), hashStruct)                                                 // Hash of struct\n\n            // Compute hash\n            result := keccak256(memPtr, 66)\n        }\n        return result;\n    }\n}\n",
        "protocol/Exchange/libs/LibExchangeErrors.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\n// solhint-disable\npragma solidity 0.4.24;\n\n\n/// @dev This contract documents the revert reasons used in the Exchange contract.\n/// This contract is intended to serve as a reference, but is not actually used for efficiency reasons.\ncontract LibExchangeErrors {\n\n    /// Order validation errors ///\n    string constant ORDER_UNFILLABLE = \"ORDER_UNFILLABLE\";                              // Order cannot be filled.\n    string constant INVALID_MAKER = \"INVALID_MAKER\";                                    // Invalid makerAddress.\n    string constant INVALID_TAKER = \"INVALID_TAKER\";                                    // Invalid takerAddress.\n    string constant INVALID_SENDER = \"INVALID_SENDER\";                                  // Invalid `msg.sender`.\n    string constant INVALID_ORDER_SIGNATURE = \"INVALID_ORDER_SIGNATURE\";                // Signature validation failed. \n    \n    /// fillOrder validation errors ///\n    string constant INVALID_TAKER_AMOUNT = \"INVALID_TAKER_AMOUNT\";                      // takerAssetFillAmount cannot equal 0.\n    string constant ROUNDING_ERROR = \"ROUNDING_ERROR\";                                  // Rounding error greater than 0.1% of takerAssetFillAmount. \n    \n    /// Signature validation errors ///\n    string constant INVALID_SIGNATURE = \"INVALID_SIGNATURE\";                            // Signature validation failed. \n    string constant SIGNATURE_ILLEGAL = \"SIGNATURE_ILLEGAL\";                            // Signature type is illegal.\n    string constant SIGNATURE_UNSUPPORTED = \"SIGNATURE_UNSUPPORTED\";                    // Signature type unsupported.\n    \n    /// cancelOrdersUptTo errors ///\n    string constant INVALID_NEW_ORDER_EPOCH = \"INVALID_NEW_ORDER_EPOCH\";                // Specified salt must be greater than or equal to existing orderEpoch.\n\n    /// fillOrKillOrder errors ///\n    string constant COMPLETE_FILL_FAILED = \"COMPLETE_FILL_FAILED\";                      // Desired takerAssetFillAmount could not be completely filled. \n\n    /// matchOrders errors ///\n    string constant NEGATIVE_SPREAD_REQUIRED = \"NEGATIVE_SPREAD_REQUIRED\";              // Matched orders must have a negative spread.\n\n    /// Transaction errors ///\n    string constant REENTRANCY_ILLEGAL = \"REENTRANCY_ILLEGAL\";                          // Recursive reentrancy is not allowed. \n    string constant INVALID_TX_HASH = \"INVALID_TX_HASH\";                                // Transaction has already been executed. \n    string constant INVALID_TX_SIGNATURE = \"INVALID_TX_SIGNATURE\";                      // Signature validation failed. \n    string constant FAILED_EXECUTION = \"FAILED_EXECUTION\";                              // Transaction execution failed. \n    \n    /// registerAssetProxy errors ///\n    string constant ASSET_PROXY_ALREADY_EXISTS = \"ASSET_PROXY_ALREADY_EXISTS\";          // AssetProxy with same id already exists.\n\n    /// dispatchTransferFrom errors ///\n    string constant ASSET_PROXY_DOES_NOT_EXIST = \"ASSET_PROXY_DOES_NOT_EXIST\";          // No assetProxy registered at given id.\n    string constant TRANSFER_FAILED = \"TRANSFER_FAILED\";                                // Asset transfer unsuccesful.\n\n    /// Length validation errors ///\n    string constant LENGTH_GREATER_THAN_0_REQUIRED = \"LENGTH_GREATER_THAN_0_REQUIRED\";  // Byte array must have a length greater than 0.\n    string constant LENGTH_GREATER_THAN_3_REQUIRED = \"LENGTH_GREATER_THAN_3_REQUIRED\";  // Byte array must have a length greater than 3.\n    string constant LENGTH_0_REQUIRED = \"LENGTH_0_REQUIRED\";                            // Byte array must have a length of 0.\n    string constant LENGTH_65_REQUIRED = \"LENGTH_65_REQUIRED\";                          // Byte array must have a length of 65.\n}\n",
        "protocol/Exchange/libs/LibFillResults.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../../utils/SafeMath/SafeMath.sol\";\n\n\ncontract LibFillResults is\n    SafeMath\n{\n    struct FillResults {\n        uint256 makerAssetFilledAmount;  // Total amount of makerAsset(s) filled.\n        uint256 takerAssetFilledAmount;  // Total amount of takerAsset(s) filled.\n        uint256 makerFeePaid;            // Total amount of ZRX paid by maker(s) to feeRecipient(s).\n        uint256 takerFeePaid;            // Total amount of ZRX paid by taker to feeRecipients(s).\n    }\n\n    struct MatchedFillResults {\n        FillResults left;                    // Amounts filled and fees paid of left order.\n        FillResults right;                   // Amounts filled and fees paid of right order.\n        uint256 leftMakerAssetSpreadAmount;  // Spread between price of left and right order, denominated in the left order's makerAsset, paid to taker.\n    }\n\n    /// @dev Adds properties of both FillResults instances.\n    ///      Modifies the first FillResults instance specified.\n    /// @param totalFillResults Fill results instance that will be added onto.\n    /// @param singleFillResults Fill results instance that will be added to totalFillResults.\n    function addFillResults(FillResults memory totalFillResults, FillResults memory singleFillResults)\n        internal\n        pure\n    {\n        totalFillResults.makerAssetFilledAmount = safeAdd(totalFillResults.makerAssetFilledAmount, singleFillResults.makerAssetFilledAmount);\n        totalFillResults.takerAssetFilledAmount = safeAdd(totalFillResults.takerAssetFilledAmount, singleFillResults.takerAssetFilledAmount);\n        totalFillResults.makerFeePaid = safeAdd(totalFillResults.makerFeePaid, singleFillResults.makerFeePaid);\n        totalFillResults.takerFeePaid = safeAdd(totalFillResults.takerFeePaid, singleFillResults.takerFeePaid);\n    }\n}\n",
        "protocol/Exchange/libs/LibMath.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../../utils/SafeMath/SafeMath.sol\";\n\n\ncontract LibMath is\n    SafeMath\n{\n    /// @dev Calculates partial value given a numerator and denominator rounded down.\n    ///      Reverts if rounding error is >= 0.1%\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to calculate partial of.\n    /// @return Partial value of target rounded down.\n    function safeGetPartialAmountFloor(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        internal\n        pure\n        returns (uint256 partialAmount)\n    {\n        require(\n            denominator > 0,\n            \"DIVISION_BY_ZERO\"\n        );\n\n        require(\n            !isRoundingErrorFloor(\n                numerator,\n                denominator,\n                target\n            ),\n            \"ROUNDING_ERROR\"\n        );\n        \n        partialAmount = safeDiv(\n            safeMul(numerator, target),\n            denominator\n        );\n        return partialAmount;\n    }\n\n    /// @dev Calculates partial value given a numerator and denominator rounded down.\n    ///      Reverts if rounding error is >= 0.1%\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to calculate partial of.\n    /// @return Partial value of target rounded up.\n    function safeGetPartialAmountCeil(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        internal\n        pure\n        returns (uint256 partialAmount)\n    {\n        require(\n            denominator > 0,\n            \"DIVISION_BY_ZERO\"\n        );\n\n        require(\n            !isRoundingErrorCeil(\n                numerator,\n                denominator,\n                target\n            ),\n            \"ROUNDING_ERROR\"\n        );\n        \n        // safeDiv computes `floor(a / b)`. We use the identity (a, b integer):\n        //       ceil(a / b) = floor((a + b - 1) / b)\n        // To implement `ceil(a / b)` using safeDiv.\n        partialAmount = safeDiv(\n            safeAdd(\n                safeMul(numerator, target),\n                safeSub(denominator, 1)\n            ),\n            denominator\n        );\n        return partialAmount;\n    }\n\n    /// @dev Calculates partial value given a numerator and denominator rounded down.\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to calculate partial of.\n    /// @return Partial value of target rounded down.\n    function getPartialAmountFloor(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        internal\n        pure\n        returns (uint256 partialAmount)\n    {\n        require(\n            denominator > 0,\n            \"DIVISION_BY_ZERO\"\n        );\n\n        partialAmount = safeDiv(\n            safeMul(numerator, target),\n            denominator\n        );\n        return partialAmount;\n    }\n    \n    /// @dev Calculates partial value given a numerator and denominator rounded down.\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to calculate partial of.\n    /// @return Partial value of target rounded up.\n    function getPartialAmountCeil(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        internal\n        pure\n        returns (uint256 partialAmount)\n    {\n        require(\n            denominator > 0,\n            \"DIVISION_BY_ZERO\"\n        );\n\n        // safeDiv computes `floor(a / b)`. We use the identity (a, b integer):\n        //       ceil(a / b) = floor((a + b - 1) / b)\n        // To implement `ceil(a / b)` using safeDiv.\n        partialAmount = safeDiv(\n            safeAdd(\n                safeMul(numerator, target),\n                safeSub(denominator, 1)\n            ),\n            denominator\n        );\n        return partialAmount;\n    }\n    \n    /// @dev Checks if rounding error >= 0.1% when rounding down.\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to multiply with numerator/denominator.\n    /// @return Rounding error is present.\n    function isRoundingErrorFloor(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        internal\n        pure\n        returns (bool isError)\n    {\n        require(\n            denominator > 0,\n            \"DIVISION_BY_ZERO\"\n        );\n        \n        // The absolute rounding error is the difference between the rounded\n        // value and the ideal value. The relative rounding error is the\n        // absolute rounding error divided by the absolute value of the\n        // ideal value. This is undefined when the ideal value is zero.\n        //\n        // The ideal value is `numerator * target / denominator`.\n        // Let's call `numerator * target % denominator` the remainder.\n        // The absolute error is `remainder / denominator`.\n        //\n        // When the ideal value is zero, we require the absolute error to\n        // be zero. Fortunately, this is always the case. The ideal value is\n        // zero iff `numerator == 0` and/or `target == 0`. In this case the\n        // remainder and absolute error are also zero. \n        if (target == 0 || numerator == 0) {\n            return false;\n        }\n        \n        // Otherwise, we want the relative rounding error to be strictly\n        // less than 0.1%.\n        // The relative error is `remainder / (numerator * target)`.\n        // We want the relative error less than 1 / 1000:\n        //        remainder / (numerator * denominator)  <  1 / 1000\n        // or equivalently:\n        //        1000 * remainder  <  numerator * target\n        // so we have a rounding error iff:\n        //        1000 * remainder  >=  numerator * target\n        uint256 remainder = mulmod(\n            target,\n            numerator,\n            denominator\n        );\n        isError = safeMul(1000, remainder) >= safeMul(numerator, target);\n        return isError;\n    }\n    \n    /// @dev Checks if rounding error >= 0.1% when rounding up.\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to multiply with numerator/denominator.\n    /// @return Rounding error is present.\n    function isRoundingErrorCeil(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        internal\n        pure\n        returns (bool isError)\n    {\n        require(\n            denominator > 0,\n            \"DIVISION_BY_ZERO\"\n        );\n        \n        // See the comments in `isRoundingError`.\n        if (target == 0 || numerator == 0) {\n            // When either is zero, the ideal value and rounded value are zero\n            // and there is no rounding error. (Although the relative error\n            // is undefined.)\n            return false;\n        }\n        // Compute remainder as before\n        uint256 remainder = mulmod(\n            target,\n            numerator,\n            denominator\n        );\n        remainder = safeSub(denominator, remainder) % denominator;\n        isError = safeMul(1000, remainder) >= safeMul(numerator, target);\n        return isError;\n    }\n}\n",
        "protocol/Exchange/libs/LibOrder.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"./LibEIP712.sol\";\n\n\ncontract LibOrder is\n    LibEIP712\n{\n    // Hash for the EIP712 Order Schema\n    bytes32 constant internal EIP712_ORDER_SCHEMA_HASH = keccak256(abi.encodePacked(\n        \"Order(\",\n        \"address makerAddress,\",\n        \"address takerAddress,\",\n        \"address feeRecipientAddress,\",\n        \"address senderAddress,\",\n        \"uint256 makerAssetAmount,\",\n        \"uint256 takerAssetAmount,\",\n        \"uint256 makerFee,\",\n        \"uint256 takerFee,\",\n        \"uint256 expirationTimeSeconds,\",\n        \"uint256 salt,\",\n        \"bytes makerAssetData,\",\n        \"bytes takerAssetData\",\n        \")\"\n    ));\n\n    // A valid order remains fillable until it is expired, fully filled, or cancelled.\n    // An order's state is unaffected by external factors, like account balances.\n    enum OrderStatus {\n        INVALID,                     // Default value\n        INVALID_MAKER_ASSET_AMOUNT,  // Order does not have a valid maker asset amount\n        INVALID_TAKER_ASSET_AMOUNT,  // Order does not have a valid taker asset amount\n        FILLABLE,                    // Order is fillable\n        EXPIRED,                     // Order has already expired\n        FULLY_FILLED,                // Order is fully filled\n        CANCELLED                    // Order has been cancelled\n    }\n\n    // solhint-disable max-line-length\n    struct Order {\n        address makerAddress;           // Address that created the order.      \n        address takerAddress;           // Address that is allowed to fill the order. If set to 0, any address is allowed to fill the order.          \n        address feeRecipientAddress;    // Address that will recieve fees when order is filled.      \n        address senderAddress;          // Address that is allowed to call Exchange contract methods that affect this order. If set to 0, any address is allowed to call these methods.\n        uint256 makerAssetAmount;       // Amount of makerAsset being offered by maker. Must be greater than 0.        \n        uint256 takerAssetAmount;       // Amount of takerAsset being bid on by maker. Must be greater than 0.        \n        uint256 makerFee;               // Amount of ZRX paid to feeRecipient by maker when order is filled. If set to 0, no transfer of ZRX from maker to feeRecipient will be attempted.\n        uint256 takerFee;               // Amount of ZRX paid to feeRecipient by taker when order is filled. If set to 0, no transfer of ZRX from taker to feeRecipient will be attempted.\n        uint256 expirationTimeSeconds;  // Timestamp in seconds at which order expires.          \n        uint256 salt;                   // Arbitrary number to facilitate uniqueness of the order's hash.     \n        bytes makerAssetData;           // Encoded data that can be decoded by a specified proxy contract when transferring makerAsset. The last byte references the id of this proxy.\n        bytes takerAssetData;           // Encoded data that can be decoded by a specified proxy contract when transferring takerAsset. The last byte references the id of this proxy.\n    }\n    // solhint-enable max-line-length\n\n    struct OrderInfo {\n        uint8 orderStatus;                    // Status that describes order's validity and fillability.\n        bytes32 orderHash;                    // EIP712 hash of the order (see LibOrder.getOrderHash).\n        uint256 orderTakerAssetFilledAmount;  // Amount of order that has already been filled.\n    }\n\n    /// @dev Calculates Keccak-256 hash of the order.\n    /// @param order The order structure.\n    /// @return Keccak-256 EIP712 hash of the order.\n    function getOrderHash(Order memory order)\n        internal\n        view\n        returns (bytes32 orderHash)\n    {\n        orderHash = hashEIP712Message(hashOrder(order));\n        return orderHash;\n    }\n\n    /// @dev Calculates EIP712 hash of the order.\n    /// @param order The order structure.\n    /// @return EIP712 hash of the order.\n    function hashOrder(Order memory order)\n        internal\n        pure\n        returns (bytes32 result)\n    {\n        bytes32 schemaHash = EIP712_ORDER_SCHEMA_HASH;\n        bytes32 makerAssetDataHash = keccak256(order.makerAssetData);\n        bytes32 takerAssetDataHash = keccak256(order.takerAssetData);\n\n        // Assembly for more efficiently computing:\n        // keccak256(abi.encodePacked(\n        //     EIP712_ORDER_SCHEMA_HASH,\n        //     bytes32(order.makerAddress),\n        //     bytes32(order.takerAddress),\n        //     bytes32(order.feeRecipientAddress),\n        //     bytes32(order.senderAddress),\n        //     order.makerAssetAmount,\n        //     order.takerAssetAmount,\n        //     order.makerFee,\n        //     order.takerFee,\n        //     order.expirationTimeSeconds,\n        //     order.salt,\n        //     keccak256(order.makerAssetData),\n        //     keccak256(order.takerAssetData)\n        // ));\n\n        assembly {\n            // Calculate memory addresses that will be swapped out before hashing\n            let pos1 := sub(order, 32)\n            let pos2 := add(order, 320)\n            let pos3 := add(order, 352)\n\n            // Backup\n            let temp1 := mload(pos1)\n            let temp2 := mload(pos2)\n            let temp3 := mload(pos3)\n            \n            // Hash in place\n            mstore(pos1, schemaHash)\n            mstore(pos2, makerAssetDataHash)\n            mstore(pos3, takerAssetDataHash)\n            result := keccak256(pos1, 416)\n            \n            // Restore\n            mstore(pos1, temp1)\n            mstore(pos2, temp2)\n            mstore(pos3, temp3)\n        }\n        return result;\n    }\n}\n",
        "protocol/Exchange/mixins/MAssetProxyDispatcher.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../interfaces/IAssetProxyDispatcher.sol\";\n\n\ncontract MAssetProxyDispatcher is\n    IAssetProxyDispatcher\n{\n    // Logs registration of new asset proxy\n    event AssetProxyRegistered(\n        bytes4 id,              // Id of new registered AssetProxy.\n        address assetProxy      // Address of new registered AssetProxy.\n    );\n\n    /// @dev Forwards arguments to assetProxy and calls `transferFrom`. Either succeeds or throws.\n    /// @param assetData Byte array encoded for the asset.\n    /// @param from Address to transfer token from.\n    /// @param to Address to transfer token to.\n    /// @param amount Amount of token to transfer.\n    function dispatchTransferFrom(\n        bytes memory assetData,\n        address from,\n        address to,\n        uint256 amount\n    )\n        internal;\n}\n",
        "protocol/Exchange/mixins/MExchangeCore.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../libs/LibOrder.sol\";\nimport \"../libs/LibFillResults.sol\";\nimport \"../interfaces/IExchangeCore.sol\";\n\n\ncontract MExchangeCore is\n    IExchangeCore\n{\n    // Fill event is emitted whenever an order is filled.\n    event Fill(\n        address indexed makerAddress,         // Address that created the order.      \n        address indexed feeRecipientAddress,  // Address that received fees.\n        address takerAddress,                 // Address that filled the order.\n        address senderAddress,                // Address that called the Exchange contract (msg.sender).\n        uint256 makerAssetFilledAmount,       // Amount of makerAsset sold by maker and bought by taker. \n        uint256 takerAssetFilledAmount,       // Amount of takerAsset sold by taker and bought by maker.\n        uint256 makerFeePaid,                 // Amount of ZRX paid to feeRecipient by maker.\n        uint256 takerFeePaid,                 // Amount of ZRX paid to feeRecipient by taker.\n        bytes32 indexed orderHash,            // EIP712 hash of order (see LibOrder.getOrderHash).\n        bytes makerAssetData,                 // Encoded data specific to makerAsset. \n        bytes takerAssetData                  // Encoded data specific to takerAsset.\n    );\n\n    // Cancel event is emitted whenever an individual order is cancelled.\n    event Cancel(\n        address indexed makerAddress,         // Address that created the order.      \n        address indexed feeRecipientAddress,  // Address that would have recieved fees if order was filled.   \n        address senderAddress,                // Address that called the Exchange contract (msg.sender).\n        bytes32 indexed orderHash,            // EIP712 hash of order (see LibOrder.getOrderHash).\n        bytes makerAssetData,                 // Encoded data specific to makerAsset. \n        bytes takerAssetData                  // Encoded data specific to takerAsset.\n    );\n\n    // CancelUpTo event is emitted whenever `cancelOrdersUpTo` is executed succesfully.\n    event CancelUpTo(\n        address indexed makerAddress,         // Orders cancelled must have been created by this address.\n        address indexed senderAddress,        // Orders cancelled must have a `senderAddress` equal to this address.\n        uint256 orderEpoch                    // Orders with specified makerAddress and senderAddress with a salt less than this value are considered cancelled.\n    );\n\n    /// @dev Fills the input order.\n    /// @param order Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    /// @return Amounts filled and fees paid by maker and taker.\n    function fillOrderInternal(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        internal\n        returns (LibFillResults.FillResults memory fillResults);\n\n    /// @dev After calling, the order can not be filled anymore.\n    /// @param order Order struct containing order specifications.\n    function cancelOrderInternal(LibOrder.Order memory order)\n        internal;\n\n    /// @dev Updates state with results of a fill order.\n    /// @param order that was filled.\n    /// @param takerAddress Address of taker who filled the order.\n    /// @param orderTakerAssetFilledAmount Amount of order already filled.\n    /// @return fillResults Amounts filled and fees paid by maker and taker.\n    function updateFilledState(\n        LibOrder.Order memory order,\n        address takerAddress,\n        bytes32 orderHash,\n        uint256 orderTakerAssetFilledAmount,\n        LibFillResults.FillResults memory fillResults\n    )\n        internal;\n\n    /// @dev Updates state with results of cancelling an order.\n    ///      State is only updated if the order is currently fillable.\n    ///      Otherwise, updating state would have no effect.\n    /// @param order that was cancelled.\n    /// @param orderHash Hash of order that was cancelled.\n    function updateCancelledState(\n        LibOrder.Order memory order,\n        bytes32 orderHash\n    )\n        internal;\n    \n    /// @dev Validates context for fillOrder. Succeeds or throws.\n    /// @param order to be filled.\n    /// @param orderInfo OrderStatus, orderHash, and amount already filled of order.\n    /// @param takerAddress Address of order taker.\n    /// @param signature Proof that the orders was created by its maker.\n    function assertFillableOrder(\n        LibOrder.Order memory order,\n        LibOrder.OrderInfo memory orderInfo,\n        address takerAddress,\n        bytes memory signature\n    )\n        internal\n        view;\n    \n    /// @dev Validates context for fillOrder. Succeeds or throws.\n    /// @param order to be filled.\n    /// @param orderInfo Status, orderHash, and amount already filled of order.\n    /// @param takerAssetFillAmount Desired amount of order to fill by taker.\n    /// @param takerAssetFilledAmount Amount of takerAsset that will be filled.\n    /// @param makerAssetFilledAmount Amount of makerAsset that will be transfered.\n    function assertValidFill(\n        LibOrder.Order memory order,\n        LibOrder.OrderInfo memory orderInfo,\n        uint256 takerAssetFillAmount,\n        uint256 takerAssetFilledAmount,\n        uint256 makerAssetFilledAmount\n    )\n        internal\n        view;\n\n    /// @dev Validates context for cancelOrder. Succeeds or throws.\n    /// @param order to be cancelled.\n    /// @param orderInfo OrderStatus, orderHash, and amount already filled of order.\n    function assertValidCancel(\n        LibOrder.Order memory order,\n        LibOrder.OrderInfo memory orderInfo\n    )\n        internal\n        view;\n\n    /// @dev Calculates amounts filled and fees paid by maker and taker.\n    /// @param order to be filled.\n    /// @param takerAssetFilledAmount Amount of takerAsset that will be filled.\n    /// @return fillResults Amounts filled and fees paid by maker and taker.\n    function calculateFillResults(\n        LibOrder.Order memory order,\n        uint256 takerAssetFilledAmount\n    )\n        internal\n        pure\n        returns (LibFillResults.FillResults memory fillResults);\n\n}\n",
        "protocol/Exchange/mixins/MMatchOrders.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../libs/LibOrder.sol\";\nimport \"../libs/LibFillResults.sol\";\nimport \"../interfaces/IMatchOrders.sol\";\n\n\ncontract MMatchOrders is\n    IMatchOrders\n{\n    /// @dev Validates context for matchOrders. Succeeds or throws.\n    /// @param leftOrder First order to match.\n    /// @param rightOrder Second order to match.\n    function assertValidMatch(\n        LibOrder.Order memory leftOrder,\n        LibOrder.Order memory rightOrder\n    )\n        internal\n        pure;\n\n    /// @dev Calculates fill amounts for the matched orders.\n    ///      Each order is filled at their respective price point. However, the calculations are\n    ///      carried out as though the orders are both being filled at the right order's price point.\n    ///      The profit made by the leftOrder order goes to the taker (who matched the two orders).\n    /// @param leftOrder First order to match.\n    /// @param rightOrder Second order to match.\n    /// @param leftOrderTakerAssetFilledAmount Amount of left order already filled.\n    /// @param rightOrderTakerAssetFilledAmount Amount of right order already filled.\n    /// @param matchedFillResults Amounts to fill and fees to pay by maker and taker of matched orders.\n    function calculateMatchedFillResults(\n        LibOrder.Order memory leftOrder,\n        LibOrder.Order memory rightOrder,\n        uint256 leftOrderTakerAssetFilledAmount,\n        uint256 rightOrderTakerAssetFilledAmount\n    )\n        internal\n        pure\n        returns (LibFillResults.MatchedFillResults memory matchedFillResults);\n\n}\n",
        "protocol/Exchange/mixins/MSignatureValidator.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../interfaces/ISignatureValidator.sol\";\n\n\ncontract MSignatureValidator is\n    ISignatureValidator\n{\n    event SignatureValidatorApproval(\n        address indexed signerAddress,     // Address that approves or disapproves a contract to verify signatures.\n        address indexed validatorAddress,  // Address of signature validator contract.\n        bool approved                      // Approval or disapproval of validator contract.\n    );\n\n    // Allowed signature types.\n    enum SignatureType {\n        Illegal,         // 0x00, default value\n        Invalid,         // 0x01\n        EIP712,          // 0x02\n        EthSign,         // 0x03\n        Wallet,          // 0x04\n        Validator,       // 0x05\n        PreSigned,       // 0x06\n        NSignatureTypes  // 0x07, number of signature types. Always leave at end.\n    }\n\n    /// @dev Verifies signature using logic defined by Wallet contract.\n    /// @param hash Any 32 byte hash.\n    /// @param walletAddress Address that should have signed the given hash\n    ///                      and defines its own signature verification method.\n    /// @param signature Proof that the hash has been signed by signer.\n    /// @return True if the address recovered from the provided signature matches the input signer address.\n    function isValidWalletSignature(\n        bytes32 hash,\n        address walletAddress,\n        bytes signature\n    )\n        internal\n        view\n        returns (bool isValid);\n\n    /// @dev Verifies signature using logic defined by Validator contract.\n    /// @param validatorAddress Address of validator contract.\n    /// @param hash Any 32 byte hash.\n    /// @param signerAddress Address that should have signed the given hash.\n    /// @param signature Proof that the hash has been signed by signer.\n    /// @return True if the address recovered from the provided signature matches the input signer address.\n    function isValidValidatorSignature(\n        address validatorAddress,\n        bytes32 hash,\n        address signerAddress,\n        bytes signature\n    )\n        internal\n        view\n        returns (bool isValid);\n}\n",
        "protocol/Exchange/mixins/MTransactions.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\npragma solidity 0.4.24;\n\nimport \"../interfaces/ITransactions.sol\";\n\n\ncontract MTransactions is\n    ITransactions\n{\n    // Hash for the EIP712 ZeroEx Transaction Schema\n    bytes32 constant internal EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH = keccak256(abi.encodePacked(\n        \"ZeroExTransaction(\",\n        \"uint256 salt,\",\n        \"address signerAddress,\",\n        \"bytes data\",\n        \")\"\n    ));\n\n    /// @dev Calculates EIP712 hash of the Transaction.\n    /// @param salt Arbitrary number to ensure uniqueness of transaction hash.\n    /// @param signerAddress Address of transaction signer.\n    /// @param data AbiV2 encoded calldata.\n    /// @return EIP712 hash of the Transaction.\n    function hashZeroExTransaction(\n        uint256 salt,\n        address signerAddress,\n        bytes memory data\n    )\n        internal\n        pure\n        returns (bytes32 result);\n\n    /// @dev The current function will be called in the context of this address (either 0x transaction signer or `msg.sender`).\n    ///      If calling a fill function, this address will represent the taker.\n    ///      If calling a cancel function, this address will represent the maker.\n    /// @return Signer of 0x transaction if entry point is `executeTransaction`.\n    ///         `msg.sender` if entry point is any other function.\n    function getCurrentContextAddress()\n        internal\n        view\n        returns (address);\n}\n",
        "protocol/Exchange/mixins/MWrapperFunctions.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../libs/LibOrder.sol\";\nimport \"../libs/LibFillResults.sol\";\nimport \"../interfaces/IWrapperFunctions.sol\";\n\n\ncontract MWrapperFunctions is \n    IWrapperFunctions\n{\n    /// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled.\n    /// @param order LibOrder.Order struct containing order specifications.\n    /// @param takerAssetFillAmount Desired amount of takerAsset to sell.\n    /// @param signature Proof that order has been created by maker.\n    function fillOrKillOrderInternal(\n        LibOrder.Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        internal\n        returns (LibFillResults.FillResults memory fillResults);\n}\n",
        "test/DummyERC20Token/DummyERC20Token.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../utils/Ownable/Ownable.sol\";\nimport \"../../tokens/ERC20Token/MintableERC20Token.sol\";\n\n\ncontract DummyERC20Token is \n    Ownable,\n    MintableERC20Token\n{\n    string public name;\n    string public symbol;\n    uint256 public decimals;\n    uint256 public constant MAX_MINT_AMOUNT = 10000000000000000000000;\n\n    constructor (\n        string _name,\n        string _symbol,\n        uint256 _decimals,\n        uint256 _totalSupply\n    )\n        public\n    {\n        name = _name;\n        symbol = _symbol;\n        decimals = _decimals;\n        _totalSupply = _totalSupply;\n        balances[msg.sender] = _totalSupply;\n    }\n\n    /// @dev Sets the balance of target address\n    /// @param _target Address or which balance will be updated\n    /// @param _value New balance of target address\n    function setBalance(address _target, uint256 _value)\n        external\n        onlyOwner\n    {\n        uint256 currBalance = balances[_target];\n        if (_value < currBalance) {\n            _totalSupply = safeSub(_totalSupply, safeSub(currBalance, _value));\n        } else {\n            _totalSupply = safeAdd(_totalSupply, safeSub(_value, currBalance));\n        }\n        balances[_target] = _value;\n    }\n\n    /// @dev Mints new tokens for sender\n    /// @param _value Amount of tokens to mint\n    function mint(uint256 _value)\n        external\n    {\n        require(\n            _value <= MAX_MINT_AMOUNT,\n            \"VALUE_TOO_LARGE\"\n        );\n\n        _mint(msg.sender, _value);\n    }\n}\n",
        "test/DummyERC20Token/DummyMultipleReturnERC20Token.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"./DummyERC20Token.sol\";\n\n\n// solhint-disable no-empty-blocks\ncontract DummyMultipleReturnERC20Token is\n    DummyERC20Token\n{\n    constructor (\n        string _name,\n        string _symbol,\n        uint256 _decimals,\n        uint256 _totalSupply\n    )\n        public\n        DummyERC20Token(\n            _name,\n            _symbol,\n            _decimals,\n            _totalSupply\n        )\n    {}\n\n    /// @dev send `value` token to `to` from `from` on the condition it is approved by `from`\n    /// @param _from The address of the sender\n    /// @param _to The address of the recipient\n    /// @param _value The amount of token to be transferred\n    function transferFrom(\n        address _from,\n        address _to,\n        uint256 _value\n    )\n        external\n        returns (bool)\n    {\n        emit Transfer(\n            _from,\n            _to,\n            _value\n        );\n\n        // HACK: This contract will not compile if we remove `returns (bool)`, so we manually return 64 bytes (equiavalent to true, true)\n        assembly {\n            mstore(0, 1)\n            mstore(32, 1)\n            return(0, 64)\n        }\n    }\n}\n\n",
        "test/DummyERC20Token/DummyNoReturnERC20Token.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"./DummyERC20Token.sol\";\n\n\n// solhint-disable no-empty-blocks\ncontract DummyNoReturnERC20Token is\n    DummyERC20Token\n{\n    constructor (\n        string _name,\n        string _symbol,\n        uint256 _decimals,\n        uint256 _totalSupply\n    )\n        public\n        DummyERC20Token(\n            _name,\n            _symbol,\n            _decimals,\n            _totalSupply\n        )\n    {}\n\n    /// @dev send `value` token to `to` from `msg.sender`\n    /// @param _to The address of the recipient\n    /// @param _value The amount of token to be transferred\n    function transfer(address _to, uint256 _value)\n        external\n        returns (bool)\n    {\n        require(\n            balances[msg.sender] >= _value,\n            \"ERC20_INSUFFICIENT_BALANCE\"\n        );\n        require(\n            balances[_to] + _value >= balances[_to],\n            \"UINT256_OVERFLOW\"\n        );\n\n        balances[msg.sender] -= _value;\n        balances[_to] += _value;\n\n        emit Transfer(\n            msg.sender,\n            _to,\n            _value\n        );\n\n        // HACK: This contract will not compile if we remove `returns (bool)`, so we manually return no data\n        assembly {\n            return(0, 0)\n        }\n    }\n\n    /// @dev send `value` token to `to` from `from` on the condition it is approved by `from`\n    /// @param _from The address of the sender\n    /// @param _to The address of the recipient\n    /// @param _value The amount of token to be transferred\n    function transferFrom(\n        address _from,\n        address _to,\n        uint256 _value\n    )\n        external\n        returns (bool)\n    {\n        require(\n            balances[_from] >= _value,\n            \"ERC20_INSUFFICIENT_BALANCE\"\n        );\n        require(\n            allowed[_from][msg.sender] >= _value,\n            \"ERC20_INSUFFICIENT_ALLOWANCE\"\n        );\n        require(\n            balances[_to] + _value >= balances[_to],\n            \"UINT256_OVERFLOW\"\n        );\n\n        balances[_to] += _value;\n        balances[_from] -= _value;\n        allowed[_from][msg.sender] -= _value;\n    \n        emit Transfer(\n            _from,\n            _to,\n            _value\n        );\n\n        // HACK: This contract will not compile if we remove `returns (bool)`, so we manually return no data\n        assembly {\n            return(0, 0)\n        }\n    }\n}\n\n",
        "test/DummyERC721Receiver/DummyERC721Receiver.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../tokens/ERC721Token/IERC721Receiver.sol\";\n\n\ncontract DummyERC721Receiver is\n    IERC721Receiver\n{\n    // Function selector for ERC721Receiver.onERC721Received\n    // 0x150b7a02\n    bytes4 constant internal ERC721_RECEIVED = bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"));\n\n    event TokenReceived(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes data\n    );\n\n    /// @notice Handle the receipt of an NFT\n    /// @dev The ERC721 smart contract calls this function on the recipient\n    ///      after a `transfer`. This function MAY throw to revert and reject the\n    ///      transfer. Return of other than the magic value MUST result in the\n    ///      transaction being reverted.\n    ///      Note: the contract address is always the message sender.\n    /// @param _operator The address which called `safeTransferFrom` function\n    /// @param _from The address which previously owned the token\n    /// @param _tokenId The NFT identifier which is being transferred\n    /// @param _data Additional data with no specified format\n    /// @return `bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"))`\n    ///         unless throwing\n    function onERC721Received(\n        address _operator,\n        address _from,\n        uint256 _tokenId,\n        bytes _data\n    )\n        external\n        returns (bytes4)\n    {\n        emit TokenReceived(\n            _operator,\n            _from,\n            _tokenId,\n            _data\n        );\n        return ERC721_RECEIVED;\n    }\n}\n",
        "test/DummyERC721Receiver/InvalidERC721Receiver.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../tokens/ERC721Token/IERC721Receiver.sol\";\n\n\ncontract InvalidERC721Receiver is\n    IERC721Receiver\n{\n    // Actual function signature is `onERC721Received(address,address,uint256,bytes)`\n    bytes4 constant internal INVALID_ERC721_RECEIVED = bytes4(keccak256(\"onERC721Received(address,uint256,bytes)\"));\n\n    event TokenReceived(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes data\n    );\n\n    /// @notice Handle the receipt of an NFT\n    /// @dev The ERC721 smart contract calls this function on the recipient\n    ///      after a `transfer`. This function MAY throw to revert and reject the\n    ///      transfer. Return of other than the magic value MUST result in the\n    ///      transaction being reverted.\n    ///      Note: the contract address is always the message sender.\n    /// @param _operator The address which called `safeTransferFrom` function\n    /// @param _from The address which previously owned the token\n    /// @param _tokenId The NFT identifier which is being transferred\n    /// @param _data Additional data with no specified format\n    /// @return `bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"))`\n    ///         unless throwing\n    function onERC721Received(\n        address _operator,\n        address _from,\n        uint256 _tokenId,\n        bytes _data\n    )\n        external\n        returns (bytes4)\n    {\n        emit TokenReceived(\n            _operator,\n            _from,\n            _tokenId,\n            _data\n        );\n        return INVALID_ERC721_RECEIVED;\n    }\n}\n",
        "test/DummyERC721Token/DummyERC721Token.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../tokens/ERC721Token/MintableERC721Token.sol\";\nimport \"../../utils/Ownable/Ownable.sol\";\n\n\n// solhint-disable no-empty-blocks\ncontract DummyERC721Token is\n    Ownable,\n    MintableERC721Token\n{\n    string public name;\n    string public symbol;\n\n    constructor (\n        string _name,\n        string _symbol\n    )\n        public\n    {\n        name = _name;\n        symbol = _symbol;\n    }\n\n    /// @dev Function to mint a new token\n    ///      Reverts if the given token ID already exists\n    /// @param _to Address of the beneficiary that will own the minted token\n    /// @param _tokenId ID of the token to be minted by the msg.sender    \n    function mint(address _to, uint256 _tokenId)\n        external\n    {\n        _mint(_to, _tokenId);\n    }\n\n    /// @dev Function to burn a token\n    ///      Reverts if the given token ID doesn't exist or not called by contract owner\n    /// @param _owner Owner of token with given token ID\n    /// @param _tokenId ID of the token to be burned by the msg.sender\n    function burn(address _owner, uint256 _tokenId)\n        external\n        onlyOwner\n    {\n        _burn(_owner, _tokenId);\n    }\n}\n",
        "test/ReentrantERC20Token/ReentrantERC20Token.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../../utils/LibBytes/LibBytes.sol\";\nimport \"../../tokens/ERC20Token/ERC20Token.sol\";\nimport \"../../protocol/Exchange/interfaces/IExchange.sol\";\nimport \"../../protocol/Exchange/libs/LibOrder.sol\";\n\n\n// solhint-disable no-unused-vars\ncontract ReentrantERC20Token is\n    ERC20Token\n{\n    using LibBytes for bytes;\n\n    // solhint-disable-next-line var-name-mixedcase\n    IExchange internal EXCHANGE;\n\n    bytes internal constant REENTRANCY_ILLEGAL_REVERT_REASON = abi.encodeWithSelector(\n        bytes4(keccak256(\"Error(string)\")),\n        \"REENTRANCY_ILLEGAL\"\n    );\n\n    // All of these functions are potentially vulnerable to reentrancy\n    // We do not test any \"noThrow\" functions because `fillOrderNoThrow` makes a delegatecall to `fillOrder`\n    enum ExchangeFunction {\n        FILL_ORDER,\n        FILL_OR_KILL_ORDER,\n        BATCH_FILL_ORDERS,\n        BATCH_FILL_OR_KILL_ORDERS,\n        MARKET_BUY_ORDERS,\n        MARKET_SELL_ORDERS,\n        MATCH_ORDERS,\n        CANCEL_ORDER,\n        BATCH_CANCEL_ORDERS,\n        CANCEL_ORDERS_UP_TO,\n        SET_SIGNATURE_VALIDATOR_APPROVAL\n    }\n\n    uint8 internal currentFunctionId = 0;\n\n    constructor (address _exchange)\n        public\n    {\n        EXCHANGE = IExchange(_exchange);\n    }\n\n    /// @dev Set the current function that will be called when `transferFrom` is called.\n    /// @param _currentFunctionId Id that corresponds to function name.\n    function setCurrentFunction(uint8 _currentFunctionId)\n        external\n    {\n        currentFunctionId = _currentFunctionId;\n    }\n\n    /// @dev A version of `transferFrom` that attempts to reenter the Exchange contract.\n    /// @param _from The address of the sender\n    /// @param _to The address of the recipient\n    /// @param _value The amount of token to be transferred\n    function transferFrom(\n        address _from,\n        address _to,\n        uint256 _value\n    )\n        external\n        returns (bool)\n    {\n        // This order would normally be invalid, but it will be used strictly for testing reentrnacy.\n        // Any reentrancy checks will happen before any other checks that invalidate the order.\n        LibOrder.Order memory order;\n\n        // Initialize remaining null parameters\n        bytes memory signature;\n        LibOrder.Order[] memory orders;\n        uint256[] memory takerAssetFillAmounts;\n        bytes[] memory signatures;\n        bytes memory calldata;\n\n        // Create calldata for function that corresponds to currentFunctionId\n        if (currentFunctionId == uint8(ExchangeFunction.FILL_ORDER)) {\n            calldata = abi.encodeWithSelector(\n                EXCHANGE.fillOrder.selector,\n                order,\n                0,\n                signature\n            );\n        } else if (currentFunctionId == uint8(ExchangeFunction.FILL_OR_KILL_ORDER)) {\n            calldata = abi.encodeWithSelector(\n                EXCHANGE.fillOrKillOrder.selector,\n                order,\n                0,\n                signature\n            );\n        } else if (currentFunctionId == uint8(ExchangeFunction.BATCH_FILL_ORDERS)) {\n            calldata = abi.encodeWithSelector(\n                EXCHANGE.batchFillOrders.selector,\n                orders,\n                takerAssetFillAmounts,\n                signatures\n            );\n        } else if (currentFunctionId == uint8(ExchangeFunction.BATCH_FILL_OR_KILL_ORDERS)) {\n            calldata = abi.encodeWithSelector(\n                EXCHANGE.batchFillOrKillOrders.selector,\n                orders,\n                takerAssetFillAmounts,\n                signatures\n            );\n        } else if (currentFunctionId == uint8(ExchangeFunction.MARKET_BUY_ORDERS)) {\n            calldata = abi.encodeWithSelector(\n                EXCHANGE.marketBuyOrders.selector,\n                orders,\n                0,\n                signatures\n            );\n        } else if (currentFunctionId == uint8(ExchangeFunction.MARKET_SELL_ORDERS)) {\n            calldata = abi.encodeWithSelector(\n                EXCHANGE.marketSellOrders.selector,\n                orders,\n                0,\n                signatures\n            );\n        } else if (currentFunctionId == uint8(ExchangeFunction.MATCH_ORDERS)) {\n            calldata = abi.encodeWithSelector(\n                EXCHANGE.matchOrders.selector,\n                order,\n                order,\n                signature,\n                signature\n            );\n        } else if (currentFunctionId == uint8(ExchangeFunction.CANCEL_ORDER)) {\n            calldata = abi.encodeWithSelector(\n                EXCHANGE.cancelOrder.selector,\n                order\n            );\n        } else if (currentFunctionId == uint8(ExchangeFunction.BATCH_CANCEL_ORDERS)) {\n            calldata = abi.encodeWithSelector(\n                EXCHANGE.batchCancelOrders.selector,\n                orders\n            );\n        } else if (currentFunctionId == uint8(ExchangeFunction.CANCEL_ORDERS_UP_TO)) {\n            calldata = abi.encodeWithSelector(\n                EXCHANGE.cancelOrdersUpTo.selector,\n                0\n            );\n        } else if (currentFunctionId == uint8(ExchangeFunction.SET_SIGNATURE_VALIDATOR_APPROVAL)) {\n            calldata = abi.encodeWithSelector(\n                EXCHANGE.setSignatureValidatorApproval.selector,\n                address(0),\n                false\n            );\n        }\n\n        // Call Exchange function, swallow error\n        address(EXCHANGE).call(calldata);\n\n        // Revert reason is 100 bytes\n        bytes memory returnData = new bytes(100);\n\n        // Copy return data\n        assembly {\n            returndatacopy(add(returnData, 32), 0, 100)\n        }\n\n        // Revert if function reverted with REENTRANCY_ILLEGAL error\n        require(!REENTRANCY_ILLEGAL_REVERT_REASON.equals(returnData));\n\n        // Transfer will return true if function failed for any other reason\n        return true;\n    }\n}",
        "test/TestAssetProxyDispatcher/TestAssetProxyDispatcher.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../protocol/Exchange/MixinAssetProxyDispatcher.sol\";\n\n\ncontract TestAssetProxyDispatcher is \n    MixinAssetProxyDispatcher\n{\n    function publicDispatchTransferFrom(\n        bytes memory assetData,\n        address from,\n        address to,\n        uint256 amount\n    )\n        public\n    {\n        dispatchTransferFrom(assetData, from, to, amount);\n    }\n}\n",
        "test/TestAssetProxyOwner/TestAssetProxyOwner.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../protocol/AssetProxyOwner/AssetProxyOwner.sol\";\n\n\n// solhint-disable no-empty-blocks\ncontract TestAssetProxyOwner is\n    AssetProxyOwner\n{\n    constructor (\n        address[] memory _owners,\n        address[] memory _assetProxyContracts,\n        uint256 _required,\n        uint256 _secondsTimeLocked\n    )\n        public\n        AssetProxyOwner(_owners, _assetProxyContracts, _required, _secondsTimeLocked)\n    {}\n    \n    function testValidRemoveAuthorizedAddressAtIndexTx(uint256 id)\n        public\n        view\n        validRemoveAuthorizedAddressAtIndexTx(id)\n        returns (bool)\n    {\n        // Do nothing. We expect reverts through the modifier\n        return true;\n    }\n    \n    /// @dev Compares first 4 bytes of byte array to `removeAuthorizedAddressAtIndex` function selector.\n    /// @param data Transaction data.\n    /// @return Successful if data is a call to `removeAuthorizedAddressAtIndex`.\n    function isFunctionRemoveAuthorizedAddressAtIndex(bytes memory data)\n        public\n        pure\n        returns (bool)\n    {\n        return data.readBytes4(0) == REMOVE_AUTHORIZED_ADDRESS_AT_INDEX_SELECTOR;\n    }\n}\n",
        "test/TestConstants/TestConstants.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../utils/LibBytes/LibBytes.sol\";\n\n\n// solhint-disable max-line-length\ncontract TestConstants {\n   \n    using LibBytes for bytes;\n\n    bytes4 constant internal ERC20_PROXY_ID = bytes4(keccak256(\"ERC20Token(address)\"));\n    \n    address constant internal KOVAN_ZRX_ADDRESS = 0x6Ff6C0Ff1d68b964901F986d4C9FA3ac68346570;\n    bytes constant internal KOVAN_ZRX_ASSET_DATA = \"\\xf4\\x72\\x61\\xb0\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x6f\\xf6\\xc0\\xff\\x1d\\x68\\xb9\\x64\\x90\\x1f\\x98\\x6d\\x4c\\x9f\\xa3\\xac\\x68\\x34\\x65\\x70\";\n    \n    address constant internal MAINNET_ZRX_ADDRESS = 0xE41d2489571d322189246DaFA5ebDe1F4699F498;\n    bytes constant public MAINNET_ZRX_ASSET_DATA = \"\\xf4\\x72\\x61\\xb0\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xe4\\x1d\\x24\\x89\\x57\\x1d\\x32\\x21\\x89\\x24\\x6d\\xaf\\xa5\\xeb\\xde\\x1f\\x46\\x99\\xf4\\x98\";\n    \n    function assertValidZrxAssetData()\n        public\n        pure\n        returns (bool)\n    {\n        bytes memory kovanZrxAssetData = abi.encodeWithSelector(ERC20_PROXY_ID, KOVAN_ZRX_ADDRESS);\n        require(\n            kovanZrxAssetData.equals(KOVAN_ZRX_ASSET_DATA),\n            \"INVALID_KOVAN_ZRX_ASSET_DATA\"\n        );\n\n        bytes memory mainetZrxAssetData = abi.encodeWithSelector(ERC20_PROXY_ID, MAINNET_ZRX_ADDRESS);\n        require(\n            mainetZrxAssetData.equals(MAINNET_ZRX_ASSET_DATA),\n            \"INVALID_MAINNET_ZRX_ASSET_DATA\"\n        );\n\n        return true;\n    }\n}\n// solhint-enable max-line-length",
        "test/TestExchangeInternals/TestExchangeInternals.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../../protocol/Exchange/Exchange.sol\";\n\n\n// solhint-disable no-empty-blocks\ncontract TestExchangeInternals is\n    Exchange\n{\n    constructor ()\n        public\n        Exchange(\"\")\n    {}\n\n    /// @dev Adds properties of both FillResults instances.\n    ///      Modifies the first FillResults instance specified.\n    ///      Note that this function has been modified from the original\n    //       internal version to return the FillResults.\n    /// @param totalFillResults Fill results instance that will be added onto.\n    /// @param singleFillResults Fill results instance that will be added to totalFillResults.\n    /// @return newTotalFillResults The result of adding singleFillResults to totalFilResults.\n    function publicAddFillResults(FillResults memory totalFillResults, FillResults memory singleFillResults)\n        public\n        pure\n        returns (FillResults memory)\n    {\n        addFillResults(totalFillResults, singleFillResults);\n        return totalFillResults;\n    }\n\n    /// @dev Calculates amounts filled and fees paid by maker and taker.\n    /// @param order to be filled.\n    /// @param takerAssetFilledAmount Amount of takerAsset that will be filled.\n    /// @return fillResults Amounts filled and fees paid by maker and taker.\n    function publicCalculateFillResults(\n        Order memory order,\n        uint256 takerAssetFilledAmount\n    )\n        public\n        pure\n        returns (FillResults memory fillResults)\n    {\n        return calculateFillResults(order, takerAssetFilledAmount);\n    }\n\n    /// @dev Calculates partial value given a numerator and denominator.\n    ///      Reverts if rounding error is >= 0.1%\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to calculate partial of.\n    /// @return Partial value of target.\n    function publicSafeGetPartialAmountFloor(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        public\n        pure\n        returns (uint256 partialAmount)\n    {\n        return safeGetPartialAmountFloor(numerator, denominator, target);\n    }\n\n    /// @dev Calculates partial value given a numerator and denominator.\n    ///      Reverts if rounding error is >= 0.1%\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to calculate partial of.\n    /// @return Partial value of target.\n    function publicSafeGetPartialAmountCeil(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        public\n        pure\n        returns (uint256 partialAmount)\n    {\n        return safeGetPartialAmountCeil(numerator, denominator, target);\n    }\n\n    /// @dev Calculates partial value given a numerator and denominator.\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to calculate partial of.\n    /// @return Partial value of target.\n    function publicGetPartialAmountFloor(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        public\n        pure\n        returns (uint256 partialAmount)\n    {\n        return getPartialAmountFloor(numerator, denominator, target);\n    }\n\n    /// @dev Calculates partial value given a numerator and denominator.\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to calculate partial of.\n    /// @return Partial value of target.\n    function publicGetPartialAmountCeil(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        public\n        pure\n        returns (uint256 partialAmount)\n    {\n        return getPartialAmountCeil(numerator, denominator, target);\n    }\n\n    /// @dev Checks if rounding error >= 0.1%.\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to multiply with numerator/denominator.\n    /// @return Rounding error is present.\n    function publicIsRoundingErrorFloor(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        public\n        pure\n        returns (bool isError)\n    {\n        return isRoundingErrorFloor(numerator, denominator, target);\n    }\n\n    /// @dev Checks if rounding error >= 0.1%.\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to multiply with numerator/denominator.\n    /// @return Rounding error is present.\n    function publicIsRoundingErrorCeil(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        public\n        pure\n        returns (bool isError)\n    {\n        return isRoundingErrorCeil(numerator, denominator, target);\n    }\n \n    /// @dev Updates state with results of a fill order.\n    /// @param order that was filled.\n    /// @param takerAddress Address of taker who filled the order.\n    /// @param orderTakerAssetFilledAmount Amount of order already filled.\n    /// @return fillResults Amounts filled and fees paid by maker and taker.\n    function publicUpdateFilledState(\n        Order memory order,\n        address takerAddress,\n        bytes32 orderHash,\n        uint256 orderTakerAssetFilledAmount,\n        FillResults memory fillResults\n    )\n        public\n    {\n        updateFilledState(\n            order,\n            takerAddress,\n            orderHash,\n            orderTakerAssetFilledAmount,\n            fillResults\n        );\n    }\n}\n",
        "test/TestLibBytes/TestLibBytes.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../utils/LibBytes/LibBytes.sol\";\n\n\ncontract TestLibBytes {\n    \n    using LibBytes for bytes;\n\n    /// @dev Pops the last byte off of a byte array by modifying its length.\n    /// @param b Byte array that will be modified.\n    /// @return The byte that was popped off.\n    function publicPopLastByte(bytes memory b)\n        public\n        pure\n        returns (bytes memory, bytes1 result)\n    {\n        result = b.popLastByte();\n        return (b, result);\n    }\n\n    /// @dev Pops the last 20 bytes off of a byte array by modifying its length.\n    /// @param b Byte array that will be modified.\n    /// @return The 20 byte address that was popped off.\n    function publicPopLast20Bytes(bytes memory b)\n        public\n        pure\n        returns (bytes memory, address result)\n    {\n        result = b.popLast20Bytes();\n        return (b, result);\n    }\n\n    /// @dev Tests equality of two byte arrays.\n    /// @param lhs First byte array to compare.\n    /// @param rhs Second byte array to compare.\n    /// @return True if arrays are the same. False otherwise.\n    function publicEquals(bytes memory lhs, bytes memory rhs)\n        public\n        pure\n        returns (bool equal)\n    {\n        equal = lhs.equals(rhs);\n        return equal;\n    }\n    \n    function publicEqualsPop1(bytes memory lhs, bytes memory rhs)\n        public\n        pure\n        returns (bool equal)\n    {\n        lhs.popLastByte();\n        rhs.popLastByte();\n        equal = lhs.equals(rhs);\n        return equal;\n    }\n\n    /// @dev Performs a deep copy of a byte array onto another byte array of greater than or equal length.\n    /// @param dest Byte array that will be overwritten with source bytes.\n    /// @param source Byte array to copy onto dest bytes.\n    function publicDeepCopyBytes(\n        bytes memory dest,\n        bytes memory source\n    )\n        public\n        pure\n        returns (bytes memory)\n    {\n        LibBytes.deepCopyBytes(dest, source);\n        return dest;\n    }\n\n    /// @dev Reads an address from a position in a byte array.\n    /// @param b Byte array containing an address.\n    /// @param index Index in byte array of address.\n    /// @return address from byte array.\n    function publicReadAddress(\n        bytes memory b,\n        uint256 index\n    )\n        public\n        pure\n        returns (address result)\n    {\n        result = b.readAddress(index);\n        return result;\n    }\n\n    /// @dev Writes an address into a specific position in a byte array.\n    /// @param b Byte array to insert address into.\n    /// @param index Index in byte array of address.\n    /// @param input Address to put into byte array.\n    function publicWriteAddress(\n        bytes memory b,\n        uint256 index,\n        address input\n    )\n        public\n        pure\n        returns (bytes memory)\n    {\n        b.writeAddress(index, input);\n        return b;\n    }\n\n    /// @dev Reads a bytes32 value from a position in a byte array.\n    /// @param b Byte array containing a bytes32 value.\n    /// @param index Index in byte array of bytes32 value.\n    /// @return bytes32 value from byte array.\n    function publicReadBytes32(\n        bytes memory b,\n        uint256 index\n    )\n        public\n        pure\n        returns (bytes32 result)\n    {\n        result = b.readBytes32(index);\n        return result;\n    }\n\n    /// @dev Writes a bytes32 into a specific position in a byte array.\n    /// @param b Byte array to insert <input> into.\n    /// @param index Index in byte array of <input>.\n    /// @param input bytes32 to put into byte array.\n    function publicWriteBytes32(\n        bytes memory b,\n        uint256 index,\n        bytes32 input\n    )\n        public\n        pure\n        returns (bytes memory)\n    {\n        b.writeBytes32(index, input);\n        return b;\n    }\n\n    /// @dev Reads a uint256 value from a position in a byte array.\n    /// @param b Byte array containing a uint256 value.\n    /// @param index Index in byte array of uint256 value.\n    /// @return uint256 value from byte array.\n    function publicReadUint256(\n        bytes memory b,\n        uint256 index\n    )\n        public\n        pure\n        returns (uint256 result)\n    {\n        result = b.readUint256(index);\n        return result;\n    }\n\n    /// @dev Writes a uint256 into a specific position in a byte array.\n    /// @param b Byte array to insert <input> into.\n    /// @param index Index in byte array of <input>.\n    /// @param input uint256 to put into byte array.\n    function publicWriteUint256(\n        bytes memory b,\n        uint256 index,\n        uint256 input\n    )\n        public\n        pure\n        returns (bytes memory)\n    {\n        b.writeUint256(index, input);\n        return b;\n    }\n\n    /// @dev Reads an unpadded bytes4 value from a position in a byte array.\n    /// @param b Byte array containing a bytes4 value.\n    /// @param index Index in byte array of bytes4 value.\n    /// @return bytes4 value from byte array.\n    function publicReadBytes4(\n        bytes memory b,\n        uint256 index\n    )\n        public\n        pure\n        returns (bytes4 result)\n    {\n        result = b.readBytes4(index);\n        return result;\n    }\n\n    /// @dev Reads nested bytes from a specific position.\n    /// @param b Byte array containing nested bytes.\n    /// @param index Index of nested bytes.\n    /// @return result Nested bytes.\n    function publicReadBytesWithLength(\n        bytes memory b,\n        uint256 index\n    )\n        public\n        pure\n        returns (bytes memory result)\n    {\n        result = b.readBytesWithLength(index);\n        return result;\n    }\n\n    /// @dev Inserts bytes at a specific position in a byte array.\n    /// @param b Byte array to insert <input> into.\n    /// @param index Index in byte array of <input>.\n    /// @param input bytes to insert.\n    /// @return b Updated input byte array\n    function publicWriteBytesWithLength(\n        bytes memory b,\n        uint256 index,\n        bytes memory input\n    )\n        public\n        pure\n        returns (bytes memory)\n    {\n        b.writeBytesWithLength(index, input);\n        return b;\n    }\n    \n    /// @dev Copies a block of memory from one location to another.\n    /// @param mem Memory contents we want to apply memCopy to\n    /// @param dest Destination offset into <mem>.\n    /// @param source Source offset into <mem>.\n    /// @param length Length of bytes to copy from <source> to <dest>\n    /// @return mem Memory contents after calling memCopy.\n    function testMemcpy(\n        bytes mem,\n        uint256 dest,\n        uint256 source,\n        uint256 length\n    )\n        public // not external, we need input in memory\n        pure\n        returns (bytes)\n    {\n        // Sanity check. Overflows are not checked.\n        require(source + length <= mem.length);\n        require(dest + length <= mem.length);\n\n        // Get pointer to memory contents\n        uint256 offset = mem.contentAddress();\n\n        // Execute memCopy adjusted for memory array location\n        LibBytes.memCopy(offset + dest, offset + source, length);\n\n        // Return modified memory contents\n        return mem;\n    }\n}\n",
        "test/TestLibs/TestLibs.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\npragma experimental ABIEncoderV2;\n\nimport \"../../protocol/Exchange/libs/LibMath.sol\";\nimport \"../../protocol/Exchange/libs/LibOrder.sol\";\nimport \"../../protocol/Exchange/libs/LibFillResults.sol\";\nimport \"../../protocol/Exchange/libs/LibAbiEncoder.sol\";\n\n\ncontract TestLibs is \n    LibMath,\n    LibOrder,\n    LibFillResults,\n    LibAbiEncoder\n{\n    function publicAbiEncodeFillOrder(\n        Order memory order,\n        uint256 takerAssetFillAmount,\n        bytes memory signature\n    )\n        public\n        pure\n        returns (bytes memory fillOrderCalldata)\n    {\n        fillOrderCalldata = abiEncodeFillOrder(\n            order,\n            takerAssetFillAmount,\n            signature\n        );\n        return fillOrderCalldata;\n    }\n\n    function publicGetPartialAmountFloor(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        public\n        pure\n        returns (uint256 partialAmount)\n    {\n        partialAmount = getPartialAmountFloor(\n            numerator,\n            denominator,\n            target\n        );\n        return partialAmount;\n    }\n\n    function publicGetPartialAmountCeil(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        public\n        pure\n        returns (uint256 partialAmount)\n    {\n        partialAmount = getPartialAmountCeil(\n            numerator,\n            denominator,\n            target\n        );\n        return partialAmount;\n    }\n\n    function publicIsRoundingErrorFloor(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        public\n        pure\n        returns (bool isError)\n    {\n        isError = isRoundingErrorFloor(\n            numerator,\n            denominator,\n            target\n        );\n        return isError;\n    }\n\n    function publicIsRoundingErrorCeil(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    )\n        public\n        pure\n        returns (bool isError)\n    {\n        isError = isRoundingErrorCeil(\n            numerator,\n            denominator,\n            target\n        );\n        return isError;\n    }\n\n    function publicGetOrderHash(Order memory order)\n        public\n        view\n        returns (bytes32 orderHash)\n    {\n        orderHash = getOrderHash(order);\n        return orderHash;\n    }\n\n    function getOrderSchemaHash()\n        public\n        pure\n        returns (bytes32)\n    {\n        return EIP712_ORDER_SCHEMA_HASH;\n    }\n\n    function getDomainSeparatorSchemaHash()\n        public\n        pure\n        returns (bytes32)\n    {\n        return EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH;\n    }\n\n    function publicAddFillResults(FillResults memory totalFillResults, FillResults memory singleFillResults)\n        public\n        pure\n        returns (FillResults memory)\n    {\n        addFillResults(totalFillResults, singleFillResults);\n        return totalFillResults;\n    }\n}\n",
        "test/TestSignatureValidator/TestSignatureValidator.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../protocol/Exchange/MixinSignatureValidator.sol\";\nimport \"../../protocol/Exchange/MixinTransactions.sol\";\n\n\ncontract TestSignatureValidator is\n    MixinSignatureValidator,\n    MixinTransactions\n{\n    function publicIsValidSignature(\n        bytes32 hash,\n        address signer,\n        bytes memory signature\n    )\n        public\n        view\n        returns (bool isValid)\n    {\n        isValid = isValidSignature(\n            hash,\n            signer,\n            signature\n        );\n        return isValid;\n    }\n}\n",
        "test/TestStaticCallReceiver/TestStaticCallReceiver.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../tokens/ERC20Token/IERC20Token.sol\";\n\n\n// solhint-disable no-unused-vars\ncontract TestStaticCallReceiver {\n\n    uint256 internal state = 1;\n\n    /// @dev Updates state and returns true. Intended to be used with `Validator` signature type.\n    /// @param hash Message hash that is signed.\n    /// @param signerAddress Address that should have signed the given hash.\n    /// @param signature Proof of signing.\n    /// @return Validity of order signature.\n    function isValidSignature(\n        bytes32 hash,\n        address signerAddress,\n        bytes signature\n    )\n        external\n        returns (bool isValid)\n    {\n        updateState();\n        return true;\n    }\n\n    /// @dev Updates state and returns true. Intended to be used with `Wallet` signature type.\n    /// @param hash Message hash that is signed.\n    /// @param signature Proof of signing.\n    /// @return Validity of order signature.\n    function isValidSignature(\n        bytes32 hash,\n        bytes signature\n    )\n        external\n        returns (bool isValid)\n    {\n        updateState();\n        return true;\n    }\n\n    /// @dev Approves an ERC20 token to spend tokens from this address.\n    /// @param token Address of ERC20 token.\n    /// @param spender Address that will spend tokens.\n    /// @param value Amount of tokens spender is approved to spend.\n    function approveERC20(\n        address token,\n        address spender,\n        uint256 value\n    )\n        external\n    {\n        IERC20Token(token).approve(spender, value);\n    }\n\n    /// @dev Increments state variable.\n    function updateState()\n        internal\n    {\n        state++;\n    }\n}\n",
        "tokens/ERC20Token/ERC20Token.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"./IERC20Token.sol\";\n\n\ncontract ERC20Token is\n    IERC20Token\n{\n    mapping (address => uint256) internal balances;\n    mapping (address => mapping (address => uint256)) internal allowed;\n\n    uint256 internal _totalSupply;\n\n    /// @dev send `value` token to `to` from `msg.sender`\n    /// @param _to The address of the recipient\n    /// @param _value The amount of token to be transferred\n    /// @return True if transfer was successful\n    function transfer(address _to, uint256 _value)\n        external\n        returns (bool)\n    {\n        require(\n            balances[msg.sender] >= _value,\n            \"ERC20_INSUFFICIENT_BALANCE\"\n        );\n        require(\n            balances[_to] + _value >= balances[_to],\n            \"UINT256_OVERFLOW\"\n        );\n\n        balances[msg.sender] -= _value;\n        balances[_to] += _value;\n\n        emit Transfer(\n            msg.sender,\n            _to,\n            _value\n        );\n\n        return true;\n    }\n\n    /// @dev send `value` token to `to` from `from` on the condition it is approved by `from`\n    /// @param _from The address of the sender\n    /// @param _to The address of the recipient\n    /// @param _value The amount of token to be transferred\n    /// @return True if transfer was successful\n    function transferFrom(\n        address _from,\n        address _to,\n        uint256 _value\n    )\n        external\n        returns (bool)\n    {\n        require(\n            balances[_from] >= _value,\n            \"ERC20_INSUFFICIENT_BALANCE\"\n        );\n        require(\n            allowed[_from][msg.sender] >= _value,\n            \"ERC20_INSUFFICIENT_ALLOWANCE\"\n        );\n        require(\n            balances[_to] + _value >= balances[_to],\n            \"UINT256_OVERFLOW\"\n        );\n\n        balances[_to] += _value;\n        balances[_from] -= _value;\n        allowed[_from][msg.sender] -= _value;\n    \n        emit Transfer(\n            _from,\n            _to,\n            _value\n        );\n    \n        return true;\n    }\n\n    /// @dev `msg.sender` approves `_spender` to spend `_value` tokens\n    /// @param _spender The address of the account able to transfer the tokens\n    /// @param _value The amount of wei to be approved for transfer\n    /// @return Always true if the call has enough gas to complete execution\n    function approve(address _spender, uint256 _value)\n        external\n        returns (bool)\n    {\n        allowed[msg.sender][_spender] = _value;\n        emit Approval(\n            msg.sender,\n            _spender,\n            _value\n        );\n        return true;\n    }\n\n    /// @dev Query total supply of token\n    /// @return Total supply of token\n    function totalSupply()\n        external\n        view\n        returns (uint256)\n    {\n        return _totalSupply;\n    }\n\n    /// @dev Query the balance of owner\n    /// @param _owner The address from which the balance will be retrieved\n    /// @return Balance of owner\n    function balanceOf(address _owner)\n        external\n        view\n        returns (uint256)\n    {\n        return balances[_owner];\n    }\n\n    /// @param _owner The address of the account owning tokens\n    /// @param _spender The address of the account able to transfer the tokens\n    /// @return Amount of remaining tokens allowed to spent\n    function allowance(address _owner, address _spender)\n        external\n        view\n        returns (uint256)\n    {\n        return allowed[_owner][_spender];\n    }\n}\n",
        "tokens/ERC20Token/IERC20Token.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\ncontract IERC20Token {\n\n    // solhint-disable no-simple-event-func-name\n    event Transfer(\n        address indexed _from,\n        address indexed _to,\n        uint256 _value\n    );\n\n    event Approval(\n        address indexed _owner,\n        address indexed _spender,\n        uint256 _value\n    );\n\n    /// @dev send `value` token to `to` from `msg.sender`\n    /// @param _to The address of the recipient\n    /// @param _value The amount of token to be transferred\n    /// @return True if transfer was successful\n    function transfer(address _to, uint256 _value)\n        external\n        returns (bool);\n\n    /// @dev send `value` token to `to` from `from` on the condition it is approved by `from`\n    /// @param _from The address of the sender\n    /// @param _to The address of the recipient\n    /// @param _value The amount of token to be transferred\n    /// @return True if transfer was successful\n    function transferFrom(\n        address _from,\n        address _to,\n        uint256 _value\n    )\n        external\n        returns (bool);\n    \n    /// @dev `msg.sender` approves `_spender` to spend `_value` tokens\n    /// @param _spender The address of the account able to transfer the tokens\n    /// @param _value The amount of wei to be approved for transfer\n    /// @return Always true if the call has enough gas to complete execution\n    function approve(address _spender, uint256 _value)\n        external\n        returns (bool);\n\n    /// @dev Query total supply of token\n    /// @return Total supply of token\n    function totalSupply()\n        external\n        view\n        returns (uint256);\n    \n    /// @param _owner The address from which the balance will be retrieved\n    /// @return Balance of owner\n    function balanceOf(address _owner)\n        external\n        view\n        returns (uint256);\n\n    /// @param _owner The address of the account owning tokens\n    /// @param _spender The address of the account able to transfer the tokens\n    /// @return Amount of remaining tokens allowed to spent\n    function allowance(address _owner, address _spender)\n        external\n        view\n        returns (uint256);\n}\n",
        "tokens/ERC20Token/MintableERC20Token.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../../utils/SafeMath/SafeMath.sol\";\nimport \"./UnlimitedAllowanceERC20Token.sol\";\n\n\ncontract MintableERC20Token is \n    SafeMath,\n    UnlimitedAllowanceERC20Token\n{\n    /// @dev Mints new tokens\n    /// @param _to Address of the beneficiary that will own the minted token\n    /// @param _value Amount of tokens to mint\n    function _mint(address _to, uint256 _value)\n        internal\n    {\n        balances[_to] = safeAdd(_value, balances[_to]);\n        _totalSupply = safeAdd(_totalSupply, _value);\n\n        emit Transfer(\n            address(0),\n            _to,\n            _value\n        );\n    }\n\n    /// @dev Mints new tokens\n    /// @param _owner Owner of tokens that will be burned\n    /// @param _value Amount of tokens to burn\n    function _burn(address _owner, uint256 _value)\n        internal\n    {\n        balances[_owner] = safeSub(balances[_owner], _value);\n        _totalSupply = safeSub(_totalSupply, _value);\n\n        emit Transfer(\n            _owner,\n            address(0),\n            _value\n        );\n    }\n}\n",
        "tokens/ERC20Token/UnlimitedAllowanceERC20Token.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../ERC20Token/ERC20Token.sol\";\n\n\ncontract UnlimitedAllowanceERC20Token is\n    ERC20Token\n{\n    uint256 constant internal MAX_UINT = 2**256 - 1;\n\n    /// @dev ERC20 transferFrom, modified such that an allowance of MAX_UINT represents an unlimited allowance. See https://github.com/ethereum/EIPs/issues/717\n    /// @param _from Address to transfer from.\n    /// @param _to Address to transfer to.\n    /// @param _value Amount to transfer.\n    /// @return Success of transfer.\n    function transferFrom(\n        address _from,\n        address _to,\n        uint256 _value\n    )\n        external\n        returns (bool)\n    {\n        uint256 allowance = allowed[_from][msg.sender];\n        require(\n            balances[_from] >= _value,\n            \"ERC20_INSUFFICIENT_BALANCE\"\n        );\n        require(\n            allowance >= _value,\n            \"ERC20_INSUFFICIENT_ALLOWANCE\"\n        );\n        require(\n            balances[_to] + _value >= balances[_to],\n            \"UINT256_OVERFLOW\"\n        );\n\n        balances[_to] += _value;\n        balances[_from] -= _value;\n        if (allowance < MAX_UINT) {\n            allowed[_from][msg.sender] -= _value;\n        }\n\n        emit Transfer(\n            _from,\n            _to,\n            _value\n        );\n\n        return true;\n    }\n}\n",
        "tokens/ERC721Token/ERC721Token.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"./IERC721Token.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"../../utils/SafeMath/SafeMath.sol\";\n\n\ncontract ERC721Token is\n    IERC721Token,\n    SafeMath\n{\n    // Function selector for ERC721Receiver.onERC721Received\n    // 0x150b7a02\n    bytes4 constant internal ERC721_RECEIVED = bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"));\n\n    // Mapping of tokenId => owner\n    mapping (uint256 => address) internal owners;\n\n    // Mapping of tokenId => approved address\n    mapping (uint256 => address) internal approvals;\n\n    // Mapping of owner => number of tokens owned\n    mapping (address => uint256) internal balances;\n\n    // Mapping of owner => operator => approved\n    mapping (address => mapping (address => bool)) internal operatorApprovals;\n\n    /// @notice Transfers the ownership of an NFT from one address to another address\n    /// @dev Throws unless `msg.sender` is the current owner, an authorized\n    ///      operator, or the approved address for this NFT. Throws if `_from` is\n    ///      not the current owner. Throws if `_to` is the zero address. Throws if\n    ///      `_tokenId` is not a valid NFT. When transfer is complete, this function\n    ///      checks if `_to` is a smart contract (code size > 0). If so, it calls\n    ///      `onERC721Received` on `_to` and throws if the return value is not\n    ///      `bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"))`.\n    /// @param _from The current owner of the NFT\n    /// @param _to The new owner\n    /// @param _tokenId The NFT to transfer\n    /// @param _data Additional data with no specified format, sent in call to `_to`\n    function safeTransferFrom(\n        address _from,\n        address _to,\n        uint256 _tokenId,\n        bytes _data\n    )\n        external\n    {\n        transferFrom(\n            _from,\n            _to,\n            _tokenId\n        );\n\n        uint256 receiverCodeSize;\n        assembly {\n            receiverCodeSize := extcodesize(_to)\n        }\n        if (receiverCodeSize > 0) {\n            bytes4 selector = IERC721Receiver(_to).onERC721Received(\n                msg.sender,\n                _from,\n                _tokenId,\n                _data\n            );\n            require(\n                selector == ERC721_RECEIVED,\n                \"ERC721_INVALID_SELECTOR\"\n            );\n        }\n    }\n\n    /// @notice Transfers the ownership of an NFT from one address to another address\n    /// @dev This works identically to the other function with an extra data parameter,\n    ///      except this function just sets data to \"\".\n    /// @param _from The current owner of the NFT\n    /// @param _to The new owner\n    /// @param _tokenId The NFT to transfer\n    function safeTransferFrom(\n        address _from,\n        address _to,\n        uint256 _tokenId\n    )\n        external\n    {\n        transferFrom(\n            _from,\n            _to,\n            _tokenId\n        );\n\n        uint256 receiverCodeSize;\n        assembly {\n            receiverCodeSize := extcodesize(_to)\n        }\n        if (receiverCodeSize > 0) {\n            bytes4 selector = IERC721Receiver(_to).onERC721Received(\n                msg.sender,\n                _from,\n                _tokenId,\n                \"\"\n            );\n            require(\n                selector == ERC721_RECEIVED,\n                \"ERC721_INVALID_SELECTOR\"\n            );\n        }\n    }\n\n    /// @notice Change or reaffirm the approved address for an NFT\n    /// @dev The zero address indicates there is no approved address.\n    ///      Throws unless `msg.sender` is the current NFT owner, or an authorized\n    ///      operator of the current owner.\n    /// @param _approved The new approved NFT controller\n    /// @param _tokenId The NFT to approve\n    function approve(address _approved, uint256 _tokenId)\n        external\n    {\n        address owner = ownerOf(_tokenId);\n        require(\n            msg.sender == owner || isApprovedForAll(owner, msg.sender),\n            \"ERC721_INVALID_SENDER\"\n        );\n\n        approvals[_tokenId] = _approved;\n        emit Approval(\n            owner,\n            _approved,\n            _tokenId\n        );\n    }\n\n    /// @notice Enable or disable approval for a third party (\"operator\") to manage\n    ///         all of `msg.sender`'s assets\n    /// @dev Emits the ApprovalForAll event. The contract MUST allow\n    ///      multiple operators per owner.\n    /// @param _operator Address to add to the set of authorized operators\n    /// @param _approved True if the operator is approved, false to revoke approval\n    function setApprovalForAll(address _operator, bool _approved)\n        external\n    {\n        operatorApprovals[msg.sender][_operator] = _approved;\n        emit ApprovalForAll(\n            msg.sender,\n            _operator,\n            _approved\n        );\n    }\n    \n    /// @notice Count all NFTs assigned to an owner\n    /// @dev NFTs assigned to the zero address are considered invalid, and this\n    ///      function throws for queries about the zero address.\n    /// @param _owner An address for whom to query the balance\n    /// @return The number of NFTs owned by `_owner`, possibly zero\n    function balanceOf(address _owner)\n        external\n        view\n        returns (uint256)\n    {\n        require(\n            _owner != address(0),\n            \"ERC721_ZERO_OWNER\"\n        );\n        return balances[_owner];\n    }\n\n    /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE\n    ///         TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE\n    ///         THEY MAY BE PERMANENTLY LOST\n    /// @dev Throws unless `msg.sender` is the current owner, an authorized\n    ///      operator, or the approved address for this NFT. Throws if `_from` is\n    ///      not the current owner. Throws if `_to` is the zero address. Throws if\n    ///      `_tokenId` is not a valid NFT.\n    /// @param _from The current owner of the NFT\n    /// @param _to The new owner\n    /// @param _tokenId The NFT to transfer\n    function transferFrom(\n        address _from,\n        address _to,\n        uint256 _tokenId\n    )\n        public\n    {\n        require(\n            _to != address(0),\n            \"ERC721_ZERO_TO_ADDRESS\"\n        );\n\n        address owner = ownerOf(_tokenId);\n        require(\n            _from == owner,\n            \"ERC721_OWNER_MISMATCH\"\n        );\n\n        address spender = msg.sender;\n        address approvedAddress = getApproved(_tokenId);\n        require(\n            spender == owner ||\n            isApprovedForAll(owner, spender) ||\n            approvedAddress == spender,\n            \"ERC721_INVALID_SPENDER\"\n        );\n\n        if (approvedAddress != address(0)) {\n            approvals[_tokenId] = address(0);\n        }\n\n        owners[_tokenId] = _to;\n        balances[_from] = safeSub(balances[_from], 1);\n        balances[_to] = safeAdd(balances[_to], 1);\n    \n        emit Transfer(\n            _from,\n            _to,\n            _tokenId\n        );\n    }\n\n    /// @notice Find the owner of an NFT\n    /// @dev NFTs assigned to zero address are considered invalid, and queries\n    ///      about them do throw.\n    /// @param _tokenId The identifier for an NFT\n    /// @return The address of the owner of the NFT\n    function ownerOf(uint256 _tokenId)\n        public\n        view\n        returns (address)\n    {\n        address owner = owners[_tokenId];\n        require(\n            owner != address(0),\n            \"ERC721_ZERO_OWNER\"\n        );\n        return owner;\n    }\n\n    /// @notice Get the approved address for a single NFT\n    /// @dev Throws if `_tokenId` is not a valid NFT.\n    /// @param _tokenId The NFT to find the approved address for\n    /// @return The approved address for this NFT, or the zero address if there is none\n    function getApproved(uint256 _tokenId)\n        public\n        view\n        returns (address)\n    {\n        return approvals[_tokenId];\n    }\n\n    /// @notice Query if an address is an authorized operator for another address\n    /// @param _owner The address that owns the NFTs\n    /// @param _operator The address that acts on behalf of the owner\n    /// @return True if `_operator` is an approved operator for `_owner`, false otherwise\n    function isApprovedForAll(address _owner, address _operator)\n        public\n        view\n        returns (bool)\n    {\n        return operatorApprovals[_owner][_operator];\n    }\n}\n",
        "tokens/ERC721Token/IERC721Receiver.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\ncontract IERC721Receiver {\n\n    /// @notice Handle the receipt of an NFT\n    /// @dev The ERC721 smart contract calls this function on the recipient\n    ///  after a `transfer`. This function MAY throw to revert and reject the\n    ///  transfer. Return of other than the magic value MUST result in the\n    ///  transaction being reverted.\n    ///  Note: the contract address is always the message sender.\n    /// @param _operator The address which called `safeTransferFrom` function\n    /// @param _from The address which previously owned the token\n    /// @param _tokenId The NFT identifier which is being transferred\n    /// @param _data Additional data with no specified format\n    /// @return `bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"))`\n    ///  unless throwing\n    function onERC721Received(\n        address _operator,\n        address _from,\n        uint256 _tokenId,\n        bytes _data\n    )\n        external\n        returns (bytes4);\n}\n",
        "tokens/ERC721Token/IERC721Token.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\ncontract IERC721Token {\n\n    /// @dev This emits when ownership of any NFT changes by any mechanism.\n    ///      This event emits when NFTs are created (`from` == 0) and destroyed\n    ///      (`to` == 0). Exception: during contract creation, any number of NFTs\n    ///      may be created and assigned without emitting Transfer. At the time of\n    ///      any transfer, the approved address for that NFT (if any) is reset to none.\n    event Transfer(\n        address indexed _from,\n        address indexed _to,\n        uint256 indexed _tokenId\n    );\n\n    /// @dev This emits when the approved address for an NFT is changed or\n    ///      reaffirmed. The zero address indicates there is no approved address.\n    ///      When a Transfer event emits, this also indicates that the approved\n    ///      address for that NFT (if any) is reset to none.\n    event Approval(\n        address indexed _owner,\n        address indexed _approved,\n        uint256 indexed _tokenId\n    );\n\n    /// @dev This emits when an operator is enabled or disabled for an owner.\n    ///      The operator can manage all NFTs of the owner.\n    event ApprovalForAll(\n        address indexed _owner,\n        address indexed _operator,\n        bool _approved\n    );\n\n    /// @notice Transfers the ownership of an NFT from one address to another address\n    /// @dev Throws unless `msg.sender` is the current owner, an authorized\n    ///      perator, or the approved address for this NFT. Throws if `_from` is\n    ///      not the current owner. Throws if `_to` is the zero address. Throws if\n    ///      `_tokenId` is not a valid NFT. When transfer is complete, this function\n    ///      checks if `_to` is a smart contract (code size > 0). If so, it calls\n    ///      `onERC721Received` on `_to` and throws if the return value is not\n    ///      `bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"))`.\n    /// @param _from The current owner of the NFT\n    /// @param _to The new owner\n    /// @param _tokenId The NFT to transfer\n    /// @param _data Additional data with no specified format, sent in call to `_to`\n    function safeTransferFrom(\n        address _from,\n        address _to,\n        uint256 _tokenId,\n        bytes _data\n    )\n        external;\n\n    /// @notice Transfers the ownership of an NFT from one address to another address\n    /// @dev This works identically to the other function with an extra data parameter,\n    ///      except this function just sets data to \"\".\n    /// @param _from The current owner of the NFT\n    /// @param _to The new owner\n    /// @param _tokenId The NFT to transfer\n    function safeTransferFrom(\n        address _from,\n        address _to,\n        uint256 _tokenId\n    )\n        external;\n\n    /// @notice Change or reaffirm the approved address for an NFT\n    /// @dev The zero address indicates there is no approved address.\n    ///      Throws unless `msg.sender` is the current NFT owner, or an authorized\n    ///      operator of the current owner.\n    /// @param _approved The new approved NFT controller\n    /// @param _tokenId The NFT to approve\n    function approve(address _approved, uint256 _tokenId)\n        external;\n\n    /// @notice Enable or disable approval for a third party (\"operator\") to manage\n    ///         all of `msg.sender`'s assets\n    /// @dev Emits the ApprovalForAll event. The contract MUST allow\n    ///      multiple operators per owner.\n    /// @param _operator Address to add to the set of authorized operators\n    /// @param _approved True if the operator is approved, false to revoke approval\n    function setApprovalForAll(address _operator, bool _approved)\n        external;\n\n    /// @notice Count all NFTs assigned to an owner\n    /// @dev NFTs assigned to the zero address are considered invalid, and this\n    ///      function throws for queries about the zero address.\n    /// @param _owner An address for whom to query the balance\n    /// @return The number of NFTs owned by `_owner`, possibly zero\n    function balanceOf(address _owner)\n        external\n        view\n        returns (uint256);\n\n    /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE\n    ///         TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE\n    ///         THEY MAY BE PERMANENTLY LOST\n    /// @dev Throws unless `msg.sender` is the current owner, an authorized\n    ///      operator, or the approved address for this NFT. Throws if `_from` is\n    ///      not the current owner. Throws if `_to` is the zero address. Throws if\n    ///      `_tokenId` is not a valid NFT.\n    /// @param _from The current owner of the NFT\n    /// @param _to The new owner\n    /// @param _tokenId The NFT to transfer\n    function transferFrom(\n        address _from,\n        address _to,\n        uint256 _tokenId\n    )\n        public;\n\n    /// @notice Find the owner of an NFT\n    /// @dev NFTs assigned to zero address are considered invalid, and queries\n    ///      about them do throw.\n    /// @param _tokenId The identifier for an NFT\n    /// @return The address of the owner of the NFT\n    function ownerOf(uint256 _tokenId)\n        public\n        view\n        returns (address);\n\n    /// @notice Get the approved address for a single NFT\n    /// @dev Throws if `_tokenId` is not a valid NFT.\n    /// @param _tokenId The NFT to find the approved address for\n    /// @return The approved address for this NFT, or the zero address if there is none\n    function getApproved(uint256 _tokenId) \n        public\n        view\n        returns (address);\n    \n    /// @notice Query if an address is an authorized operator for another address\n    /// @param _owner The address that owns the NFTs\n    /// @param _operator The address that acts on behalf of the owner\n    /// @return True if `_operator` is an approved operator for `_owner`, false otherwise\n    function isApprovedForAll(address _owner, address _operator)\n        public\n        view\n        returns (bool);\n}\n",
        "tokens/ERC721Token/MintableERC721Token.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"./ERC721Token.sol\";\n\n\ncontract MintableERC721Token is\n    ERC721Token\n{\n    /// @dev Function to mint a new token\n    ///      Reverts if the given token ID already exists\n    /// @param _to Address of the beneficiary that will own the minted token\n    /// @param _tokenId ID of the token to be minted by the msg.sender    \n    function _mint(address _to, uint256 _tokenId)\n        internal\n    {\n        require(\n            _to != address(0),\n            \"ERC721_ZERO_TO_ADDRESS\"\n        );\n\n        address owner = owners[_tokenId];\n        require(\n            owner == address(0),\n            \"ERC721_OWNER_ALREADY_EXISTS\"\n        );\n\n        owners[_tokenId] = _to;\n        balances[_to] = safeAdd(balances[_to], 1);\n\n        emit Transfer(\n            address(0),\n            _to,\n            _tokenId\n        );\n    }\n\n    /// @dev Function to burn a token\n    ///      Reverts if the given token ID doesn't exist\n    /// @param _owner Owner of token with given token ID\n    /// @param _tokenId ID of the token to be burned by the msg.sender\n    function _burn(address _owner, uint256 _tokenId)\n        internal\n    {\n        require(\n            _owner != address(0),\n            \"ERC721_ZERO_OWNER_ADDRESS\"\n        );\n\n        address owner = owners[_tokenId];\n        require(\n            owner == _owner,\n            \"ERC721_OWNER_MISMATCH\"\n        );\n\n        owners[_tokenId] = address(0);\n        balances[_owner] = safeSub(balances[_owner], 1);\n\n        emit Transfer(\n            _owner,\n            address(0),\n            _tokenId\n        );\n    }\n}\n",
        "tokens/EtherToken/IEtherToken.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\nimport \"../ERC20Token/IERC20Token.sol\";\n\n\ncontract IEtherToken is\n    IERC20Token\n{\n    function deposit()\n        public\n        payable;\n    \n    function withdraw(uint256 amount)\n        public;\n}\n",
        "tokens/EtherToken/WETH9.sol": "// Copyright (C) 2015, 2016, 2017 Dapphub\n\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\n// solhint-disable\npragma solidity ^0.4.18;\n\n\ncontract WETH9 {\n    string public name     = \"Wrapped Ether\";\n    string public symbol   = \"WETH\";\n    uint8  public decimals = 18;\n\n    event  Approval(address indexed _owner, address indexed _spender, uint _value);\n    event  Transfer(address indexed _from, address indexed _to, uint _value);\n    event  Deposit(address indexed _owner, uint _value);\n    event  Withdrawal(address indexed _owner, uint _value);\n\n    mapping (address => uint)                       public  balanceOf;\n    mapping (address => mapping (address => uint))  public  allowance;\n\n    function() public payable {\n        deposit();\n    }\n    function deposit() public payable {\n        balanceOf[msg.sender] += msg.value;\n        Deposit(msg.sender, msg.value);\n    }\n    function withdraw(uint wad) public {\n        require(balanceOf[msg.sender] >= wad);\n        balanceOf[msg.sender] -= wad;\n        msg.sender.transfer(wad);\n        Withdrawal(msg.sender, wad);\n    }\n\n    function totalSupply() public view returns (uint) {\n        return this.balance;\n    }\n\n    function approve(address guy, uint wad) public returns (bool) {\n        allowance[msg.sender][guy] = wad;\n        Approval(msg.sender, guy, wad);\n        return true;\n    }\n\n    function transfer(address dst, uint wad) public returns (bool) {\n        return transferFrom(msg.sender, dst, wad);\n    }\n\n    function transferFrom(address src, address dst, uint wad)\n        public\n        returns (bool)\n    {\n        require(balanceOf[src] >= wad);\n\n        if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {\n            require(allowance[src][msg.sender] >= wad);\n            allowance[src][msg.sender] -= wad;\n        }\n\n        balanceOf[src] -= wad;\n        balanceOf[dst] += wad;\n\n        Transfer(src, dst, wad);\n\n        return true;\n    }\n}\n\n\n/*\n                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n\n*/\n",
        "utils/LibBytes/LibBytes.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\nlibrary LibBytes {\n\n    using LibBytes for bytes;\n\n    /// @dev Gets the memory address for a byte array.\n    /// @param input Byte array to lookup.\n    /// @return memoryAddress Memory address of byte array. This\n    ///         points to the header of the byte array which contains\n    ///         the length.\n    function rawAddress(bytes memory input)\n        internal\n        pure\n        returns (uint256 memoryAddress)\n    {\n        assembly {\n            memoryAddress := input\n        }\n        return memoryAddress;\n    }\n    \n    /// @dev Gets the memory address for the contents of a byte array.\n    /// @param input Byte array to lookup.\n    /// @return memoryAddress Memory address of the contents of the byte array.\n    function contentAddress(bytes memory input)\n        internal\n        pure\n        returns (uint256 memoryAddress)\n    {\n        assembly {\n            memoryAddress := add(input, 32)\n        }\n        return memoryAddress;\n    }\n\n    /// @dev Copies `length` bytes from memory location `source` to `dest`.\n    /// @param dest memory address to copy bytes to.\n    /// @param source memory address to copy bytes from.\n    /// @param length number of bytes to copy.\n    function memCopy(\n        uint256 dest,\n        uint256 source,\n        uint256 length\n    )\n        internal\n        pure\n    {\n        if (length < 32) {\n            // Handle a partial word by reading destination and masking\n            // off the bits we are interested in.\n            // This correctly handles overlap, zero lengths and source == dest\n            assembly {\n                let mask := sub(exp(256, sub(32, length)), 1)\n                let s := and(mload(source), not(mask))\n                let d := and(mload(dest), mask)\n                mstore(dest, or(s, d))\n            }\n        } else {\n            // Skip the O(length) loop when source == dest.\n            if (source == dest) {\n                return;\n            }\n\n            // For large copies we copy whole words at a time. The final\n            // word is aligned to the end of the range (instead of after the\n            // previous) to handle partial words. So a copy will look like this:\n            //\n            //  ####\n            //      ####\n            //          ####\n            //            ####\n            //\n            // We handle overlap in the source and destination range by\n            // changing the copying direction. This prevents us from\n            // overwriting parts of source that we still need to copy.\n            //\n            // This correctly handles source == dest\n            //\n            if (source > dest) {\n                assembly {\n                    // We subtract 32 from `sEnd` and `dEnd` because it\n                    // is easier to compare with in the loop, and these\n                    // are also the addresses we need for copying the\n                    // last bytes.\n                    length := sub(length, 32)\n                    let sEnd := add(source, length)\n                    let dEnd := add(dest, length)\n\n                    // Remember the last 32 bytes of source\n                    // This needs to be done here and not after the loop\n                    // because we may have overwritten the last bytes in\n                    // source already due to overlap.\n                    let last := mload(sEnd)\n\n                    // Copy whole words front to back\n                    // Note: the first check is always true,\n                    // this could have been a do-while loop.\n                    // solhint-disable-next-line no-empty-blocks\n                    for {} lt(source, sEnd) {} {\n                        mstore(dest, mload(source))\n                        source := add(source, 32)\n                        dest := add(dest, 32)\n                    }\n                    \n                    // Write the last 32 bytes\n                    mstore(dEnd, last)\n                }\n            } else {\n                assembly {\n                    // We subtract 32 from `sEnd` and `dEnd` because those\n                    // are the starting points when copying a word at the end.\n                    length := sub(length, 32)\n                    let sEnd := add(source, length)\n                    let dEnd := add(dest, length)\n\n                    // Remember the first 32 bytes of source\n                    // This needs to be done here and not after the loop\n                    // because we may have overwritten the first bytes in\n                    // source already due to overlap.\n                    let first := mload(source)\n\n                    // Copy whole words back to front\n                    // We use a signed comparisson here to allow dEnd to become\n                    // negative (happens when source and dest < 32). Valid\n                    // addresses in local memory will never be larger than\n                    // 2**255, so they can be safely re-interpreted as signed.\n                    // Note: the first check is always true,\n                    // this could have been a do-while loop.\n                    // solhint-disable-next-line no-empty-blocks\n                    for {} slt(dest, dEnd) {} {\n                        mstore(dEnd, mload(sEnd))\n                        sEnd := sub(sEnd, 32)\n                        dEnd := sub(dEnd, 32)\n                    }\n                    \n                    // Write the first 32 bytes\n                    mstore(dest, first)\n                }\n            }\n        }\n    }\n\n    /// @dev Returns a slices from a byte array.\n    /// @param b The byte array to take a slice from.\n    /// @param from The starting index for the slice (inclusive).\n    /// @param to The final index for the slice (exclusive).\n    /// @return result The slice containing bytes at indices [from, to)\n    function slice(\n        bytes memory b,\n        uint256 from,\n        uint256 to\n    )\n        internal\n        pure\n        returns (bytes memory result)\n    {\n        require(\n            from <= to,\n            \"FROM_LESS_THAN_TO_REQUIRED\"\n        );\n        require(\n            to < b.length,\n            \"TO_LESS_THAN_LENGTH_REQUIRED\"\n        );\n        \n        // Create a new bytes structure and copy contents\n        result = new bytes(to - from);\n        memCopy(\n            result.contentAddress(),\n            b.contentAddress() + from,\n            result.length\n        );\n        return result;\n    }\n    \n    /// @dev Returns a slice from a byte array without preserving the input.\n    /// @param b The byte array to take a slice from. Will be destroyed in the process.\n    /// @param from The starting index for the slice (inclusive).\n    /// @param to The final index for the slice (exclusive).\n    /// @return result The slice containing bytes at indices [from, to)\n    /// @dev When `from == 0`, the original array will match the slice. In other cases its state will be corrupted.\n    function sliceDestructive(\n        bytes memory b,\n        uint256 from,\n        uint256 to\n    )\n        internal\n        pure\n        returns (bytes memory result)\n    {\n        require(\n            from <= to,\n            \"FROM_LESS_THAN_TO_REQUIRED\"\n        );\n        require(\n            to < b.length,\n            \"TO_LESS_THAN_LENGTH_REQUIRED\"\n        );\n        \n        // Create a new bytes structure around [from, to) in-place.\n        assembly {\n            result := add(b, from)\n            mstore(result, sub(to, from))\n        }\n        return result;\n    }\n\n    /// @dev Pops the last byte off of a byte array by modifying its length.\n    /// @param b Byte array that will be modified.\n    /// @return The byte that was popped off.\n    function popLastByte(bytes memory b)\n        internal\n        pure\n        returns (bytes1 result)\n    {\n        require(\n            b.length > 0,\n            \"GREATER_THAN_ZERO_LENGTH_REQUIRED\"\n        );\n\n        // Store last byte.\n        result = b[b.length - 1];\n\n        assembly {\n            // Decrement length of byte array.\n            let newLen := sub(mload(b), 1)\n            mstore(b, newLen)\n        }\n        return result;\n    }\n\n    /// @dev Pops the last 20 bytes off of a byte array by modifying its length.\n    /// @param b Byte array that will be modified.\n    /// @return The 20 byte address that was popped off.\n    function popLast20Bytes(bytes memory b)\n        internal\n        pure\n        returns (address result)\n    {\n        require(\n            b.length >= 20,\n            \"GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED\"\n        );\n\n        // Store last 20 bytes.\n        result = readAddress(b, b.length - 20);\n\n        assembly {\n            // Subtract 20 from byte array length.\n            let newLen := sub(mload(b), 20)\n            mstore(b, newLen)\n        }\n        return result;\n    }\n\n    /// @dev Tests equality of two byte arrays.\n    /// @param lhs First byte array to compare.\n    /// @param rhs Second byte array to compare.\n    /// @return True if arrays are the same. False otherwise.\n    function equals(\n        bytes memory lhs,\n        bytes memory rhs\n    )\n        internal\n        pure\n        returns (bool equal)\n    {\n        // Keccak gas cost is 30 + numWords * 6. This is a cheap way to compare.\n        // We early exit on unequal lengths, but keccak would also correctly\n        // handle this.\n        return lhs.length == rhs.length && keccak256(lhs) == keccak256(rhs);\n    }\n\n    /// @dev Reads an address from a position in a byte array.\n    /// @param b Byte array containing an address.\n    /// @param index Index in byte array of address.\n    /// @return address from byte array.\n    function readAddress(\n        bytes memory b,\n        uint256 index\n    )\n        internal\n        pure\n        returns (address result)\n    {\n        require(\n            b.length >= index + 20,  // 20 is length of address\n            \"GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED\"\n        );\n\n        // Add offset to index:\n        // 1. Arrays are prefixed by 32-byte length parameter (add 32 to index)\n        // 2. Account for size difference between address length and 32-byte storage word (subtract 12 from index)\n        index += 20;\n\n        // Read address from array memory\n        assembly {\n            // 1. Add index to address of bytes array\n            // 2. Load 32-byte word from memory\n            // 3. Apply 20-byte mask to obtain address\n            result := and(mload(add(b, index)), 0xffffffffffffffffffffffffffffffffffffffff)\n        }\n        return result;\n    }\n\n    /// @dev Writes an address into a specific position in a byte array.\n    /// @param b Byte array to insert address into.\n    /// @param index Index in byte array of address.\n    /// @param input Address to put into byte array.\n    function writeAddress(\n        bytes memory b,\n        uint256 index,\n        address input\n    )\n        internal\n        pure\n    {\n        require(\n            b.length >= index + 20,  // 20 is length of address\n            \"GREATER_OR_EQUAL_TO_20_LENGTH_REQUIRED\"\n        );\n\n        // Add offset to index:\n        // 1. Arrays are prefixed by 32-byte length parameter (add 32 to index)\n        // 2. Account for size difference between address length and 32-byte storage word (subtract 12 from index)\n        index += 20;\n\n        // Store address into array memory\n        assembly {\n            // The address occupies 20 bytes and mstore stores 32 bytes.\n            // First fetch the 32-byte word where we'll be storing the address, then\n            // apply a mask so we have only the bytes in the word that the address will not occupy.\n            // Then combine these bytes with the address and store the 32 bytes back to memory with mstore.\n\n            // 1. Add index to address of bytes array\n            // 2. Load 32-byte word from memory\n            // 3. Apply 12-byte mask to obtain extra bytes occupying word of memory where we'll store the address\n            let neighbors := and(\n                mload(add(b, index)),\n                0xffffffffffffffffffffffff0000000000000000000000000000000000000000\n            )\n            \n            // Make sure input address is clean.\n            // (Solidity does not guarantee this)\n            input := and(input, 0xffffffffffffffffffffffffffffffffffffffff)\n\n            // Store the neighbors and address into memory\n            mstore(add(b, index), xor(input, neighbors))\n        }\n    }\n\n    /// @dev Reads a bytes32 value from a position in a byte array.\n    /// @param b Byte array containing a bytes32 value.\n    /// @param index Index in byte array of bytes32 value.\n    /// @return bytes32 value from byte array.\n    function readBytes32(\n        bytes memory b,\n        uint256 index\n    )\n        internal\n        pure\n        returns (bytes32 result)\n    {\n        require(\n            b.length >= index + 32,\n            \"GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED\"\n        );\n\n        // Arrays are prefixed by a 256 bit length parameter\n        index += 32;\n\n        // Read the bytes32 from array memory\n        assembly {\n            result := mload(add(b, index))\n        }\n        return result;\n    }\n\n    /// @dev Writes a bytes32 into a specific position in a byte array.\n    /// @param b Byte array to insert <input> into.\n    /// @param index Index in byte array of <input>.\n    /// @param input bytes32 to put into byte array.\n    function writeBytes32(\n        bytes memory b,\n        uint256 index,\n        bytes32 input\n    )\n        internal\n        pure\n    {\n        require(\n            b.length >= index + 32,\n            \"GREATER_OR_EQUAL_TO_32_LENGTH_REQUIRED\"\n        );\n\n        // Arrays are prefixed by a 256 bit length parameter\n        index += 32;\n\n        // Read the bytes32 from array memory\n        assembly {\n            mstore(add(b, index), input)\n        }\n    }\n\n    /// @dev Reads a uint256 value from a position in a byte array.\n    /// @param b Byte array containing a uint256 value.\n    /// @param index Index in byte array of uint256 value.\n    /// @return uint256 value from byte array.\n    function readUint256(\n        bytes memory b,\n        uint256 index\n    )\n        internal\n        pure\n        returns (uint256 result)\n    {\n        result = uint256(readBytes32(b, index));\n        return result;\n    }\n\n    /// @dev Writes a uint256 into a specific position in a byte array.\n    /// @param b Byte array to insert <input> into.\n    /// @param index Index in byte array of <input>.\n    /// @param input uint256 to put into byte array.\n    function writeUint256(\n        bytes memory b,\n        uint256 index,\n        uint256 input\n    )\n        internal\n        pure\n    {\n        writeBytes32(b, index, bytes32(input));\n    }\n\n    /// @dev Reads an unpadded bytes4 value from a position in a byte array.\n    /// @param b Byte array containing a bytes4 value.\n    /// @param index Index in byte array of bytes4 value.\n    /// @return bytes4 value from byte array.\n    function readBytes4(\n        bytes memory b,\n        uint256 index\n    )\n        internal\n        pure\n        returns (bytes4 result)\n    {\n        require(\n            b.length >= index + 4,\n            \"GREATER_OR_EQUAL_TO_4_LENGTH_REQUIRED\"\n        );\n\n        // Arrays are prefixed by a 32 byte length field\n        index += 32;\n\n        // Read the bytes4 from array memory\n        assembly {\n            result := mload(add(b, index))\n            // Solidity does not require us to clean the trailing bytes.\n            // We do it anyway\n            result := and(result, 0xFFFFFFFF00000000000000000000000000000000000000000000000000000000)\n        }\n        return result;\n    }\n\n    /// @dev Reads nested bytes from a specific position.\n    /// @dev NOTE: the returned value overlaps with the input value.\n    ///            Both should be treated as immutable.\n    /// @param b Byte array containing nested bytes.\n    /// @param index Index of nested bytes.\n    /// @return result Nested bytes.\n    function readBytesWithLength(\n        bytes memory b,\n        uint256 index\n    )\n        internal\n        pure\n        returns (bytes memory result)\n    {\n        // Read length of nested bytes\n        uint256 nestedBytesLength = readUint256(b, index);\n        index += 32;\n\n        // Assert length of <b> is valid, given\n        // length of nested bytes\n        require(\n            b.length >= index + nestedBytesLength,\n            \"GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED\"\n        );\n        \n        // Return a pointer to the byte array as it exists inside `b`\n        assembly {\n            result := add(b, index)\n        }\n        return result;\n    }\n\n    /// @dev Inserts bytes at a specific position in a byte array.\n    /// @param b Byte array to insert <input> into.\n    /// @param index Index in byte array of <input>.\n    /// @param input bytes to insert.\n    function writeBytesWithLength(\n        bytes memory b,\n        uint256 index,\n        bytes memory input\n    )\n        internal\n        pure\n    {\n        // Assert length of <b> is valid, given\n        // length of input\n        require(\n            b.length >= index + 32 + input.length,  // 32 bytes to store length\n            \"GREATER_OR_EQUAL_TO_NESTED_BYTES_LENGTH_REQUIRED\"\n        );\n\n        // Copy <input> into <b>\n        memCopy(\n            b.contentAddress() + index,\n            input.rawAddress(), // includes length of <input>\n            input.length + 32   // +32 bytes to store <input> length\n        );\n    }\n\n    /// @dev Performs a deep copy of a byte array onto another byte array of greater than or equal length.\n    /// @param dest Byte array that will be overwritten with source bytes.\n    /// @param source Byte array to copy onto dest bytes.\n    function deepCopyBytes(\n        bytes memory dest,\n        bytes memory source\n    )\n        internal\n        pure\n    {\n        uint256 sourceLen = source.length;\n        // Dest length must be >= source length, or some bytes would not be copied.\n        require(\n            dest.length >= sourceLen,\n            \"GREATER_OR_EQUAL_TO_SOURCE_BYTES_LENGTH_REQUIRED\"\n        );\n        memCopy(\n            dest.contentAddress(),\n            source.contentAddress(),\n            sourceLen\n        );\n    }\n}\n",
        "utils/Ownable/IOwnable.sol": "pragma solidity 0.4.24;\n\n\ncontract IOwnable {\n\n    function transferOwnership(address newOwner)\n        public;\n}\n",
        "utils/Ownable/Ownable.sol": "pragma solidity 0.4.24;\n\nimport \"./IOwnable.sol\";\n\n\ncontract Ownable is\n    IOwnable\n{\n    address public owner;\n\n    constructor ()\n        public\n    {\n        owner = msg.sender;\n    }\n\n    modifier onlyOwner() {\n        require(\n            msg.sender == owner,\n            \"ONLY_CONTRACT_OWNER\"\n        );\n        _;\n    }\n\n    function transferOwnership(address newOwner)\n        public\n        onlyOwner\n    {\n        if (newOwner != address(0)) {\n            owner = newOwner;\n        }\n    }\n}\n",
        "utils/ReentrancyGuard/ReentrancyGuard.sol": "/*\n\n  Copyright 2018 ZeroEx Intl.\n\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n\n*/\n\npragma solidity 0.4.24;\n\n\ncontract ReentrancyGuard {\n\n    // Locked state of mutex\n    bool private locked = false;\n\n    /// @dev Functions with this modifer cannot be reentered. The mutex will be locked\n    ///      before function execution and unlocked after.\n    modifier nonReentrant() {\n        // Ensure mutex is unlocked\n        require(\n            !locked,\n            \"REENTRANCY_ILLEGAL\"\n        );\n\n        // Lock mutex before function call\n        locked = true;\n\n        // Perform function call\n        _;\n\n        // Unlock mutex after function call\n        locked = false;\n    }\n}\n",
        "utils/SafeMath/SafeMath.sol": "pragma solidity 0.4.24;\n\n\ncontract SafeMath {\n\n    function safeMul(uint256 a, uint256 b)\n        internal\n        pure\n        returns (uint256)\n    {\n        if (a == 0) {\n            return 0;\n        }\n        uint256 c = a * b;\n        require(\n            c / a == b,\n            \"UINT256_OVERFLOW\"\n        );\n        return c;\n    }\n\n    function safeDiv(uint256 a, uint256 b)\n        internal\n        pure\n        returns (uint256)\n    {\n        uint256 c = a / b;\n        return c;\n    }\n\n    function safeSub(uint256 a, uint256 b)\n        internal\n        pure\n        returns (uint256)\n    {\n        require(\n            b <= a,\n            \"UINT256_UNDERFLOW\"\n        );\n        return a - b;\n    }\n\n    function safeAdd(uint256 a, uint256 b)\n        internal\n        pure\n        returns (uint256)\n    {\n        uint256 c = a + b;\n        require(\n            c >= a,\n            \"UINT256_OVERFLOW\"\n        );\n        return c;\n    }\n\n    function max64(uint64 a, uint64 b)\n        internal\n        pure\n        returns (uint256)\n    {\n        return a >= b ? a : b;\n    }\n\n    function min64(uint64 a, uint64 b)\n        internal\n        pure\n        returns (uint256)\n    {\n        return a < b ? a : b;\n    }\n\n    function max256(uint256 a, uint256 b)\n        internal\n        pure\n        returns (uint256)\n    {\n        return a >= b ? a : b;\n    }\n\n    function min256(uint256 a, uint256 b)\n        internal\n        pure\n        returns (uint256)\n    {\n        return a < b ? a : b;\n    }\n}\n"
    },
    "sourceTreeHashHex": "0x70b7d3c15ab87e6b4b1011d194282163232dfd88486038e4120d6bf245d58e44",
    "compiler": {
        "name": "solc",
        "version": "soljson-v0.4.24+commit.e67f0147.js",
        "settings": {
            "optimizer": {
                "enabled": true,
                "runs": 1000000
            },
            "outputSelection": {
                "*": {
                    "*": [
                        "abi",
                        "evm.bytecode.object",
                        "evm.bytecode.sourceMap",
                        "evm.deployedBytecode.object",
                        "evm.deployedBytecode.sourceMap"
                    ]
                }
            }
        }
    },
    "networks": {}
}