More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 3,944 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Market Buy Order... | 14224468 | 988 days ago | IN | 0.23828429 ETH | 0.03304042 | ||||
Market Buy Order... | 13574765 | 1089 days ago | IN | 0.0187572 ETH | 0.03031937 | ||||
Market Buy Order... | 13411639 | 1115 days ago | IN | 0.33080683 ETH | 0.05132391 | ||||
Market Buy Order... | 12842781 | 1203 days ago | IN | 0.00391341 ETH | 0.00570765 | ||||
Market Buy Order... | 12621688 | 1238 days ago | IN | 0.12706401 ETH | 0.00287144 | ||||
Market Buy Order... | 12593846 | 1242 days ago | IN | 0.11082988 ETH | 0.02594117 | ||||
Market Buy Order... | 12358667 | 1279 days ago | IN | 0.14152748 ETH | 0.01043064 | ||||
Market Buy Order... | 12086007 | 1321 days ago | IN | 0.31717748 ETH | 0.04028682 | ||||
Market Buy Order... | 11857459 | 1356 days ago | IN | 0.5640905 ETH | 0.01871061 | ||||
Market Buy Order... | 11819974 | 1362 days ago | IN | 2.01302156 ETH | 0.03830298 | ||||
Market Buy Order... | 11818247 | 1362 days ago | IN | 0.200326 ETH | 0.0231916 | ||||
Market Buy Order... | 11794130 | 1366 days ago | IN | 0.05202049 ETH | 0.02780101 | ||||
Market Buy Order... | 11759114 | 1371 days ago | IN | 0.22349513 ETH | 0.02868413 | ||||
Market Buy Order... | 11759007 | 1371 days ago | IN | 0.0538491 ETH | 0.04491922 | ||||
Market Buy Order... | 11752931 | 1372 days ago | IN | 0.29447478 ETH | 0.03187507 | ||||
Market Buy Order... | 11735077 | 1375 days ago | IN | 0.0781905 ETH | 0.01394153 | ||||
Market Buy Order... | 11734988 | 1375 days ago | IN | 0.0447805 ETH | 0.01442189 | ||||
Market Buy Order... | 11725622 | 1376 days ago | IN | 1.24083315 ETH | 0.03661392 | ||||
Market Buy Order... | 11725554 | 1376 days ago | IN | 2.04093752 ETH | 0.03717347 | ||||
Market Buy Order... | 11712870 | 1378 days ago | IN | 0.02467531 ETH | 0.01996457 | ||||
Market Buy Order... | 11712870 | 1378 days ago | IN | 0.02467531 ETH | 0.0195489 | ||||
Market Buy Order... | 11676721 | 1384 days ago | IN | 0.03134862 ETH | 0.01327085 | ||||
Market Buy Order... | 11676688 | 1384 days ago | IN | 0.05827207 ETH | 0.01510085 | ||||
Market Buy Order... | 11567093 | 1400 days ago | IN | 0.01212114 ETH | 0.01091655 | ||||
Market Buy Order... | 11567081 | 1400 days ago | IN | 0.01212114 ETH | 0.01091655 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
14224468 | 988 days ago | 0.02085239 ETH | ||||
14224468 | 988 days ago | 0.02085239 ETH | ||||
14224468 | 988 days ago | 0.23828429 ETH | ||||
13574765 | 1089 days ago | 0.01845 ETH | ||||
13574765 | 1089 days ago | 0.01845 ETH | ||||
13574765 | 1089 days ago | 0.01871042 ETH | ||||
13574765 | 1089 days ago | 0.00004677 ETH | ||||
13411639 | 1115 days ago | 0.04155855 ETH | ||||
13411639 | 1115 days ago | 0.04155855 ETH | ||||
13411639 | 1115 days ago | 0.32998188 ETH | ||||
13411639 | 1115 days ago | 0.00082495 ETH | ||||
12842781 | 1203 days ago | 0.00152 ETH | ||||
12842781 | 1203 days ago | 0.00152 ETH | ||||
12842781 | 1203 days ago | 0.00391341 ETH | ||||
12621688 | 1238 days ago | 0.00081812 ETH | ||||
12621688 | 1238 days ago | 0.00081812 ETH | ||||
12621688 | 1238 days ago | 0.12674715 ETH | ||||
12621688 | 1238 days ago | 0.00031686 ETH | ||||
12593846 | 1242 days ago | 0.11082988 ETH | ||||
12358667 | 1279 days ago | 0.14152748 ETH | ||||
12086007 | 1321 days ago | 0.01618408 ETH | ||||
12086007 | 1321 days ago | 0.01618408 ETH | ||||
12086007 | 1321 days ago | 0.31717748 ETH | ||||
11857459 | 1356 days ago | 0.5640905 ETH | ||||
11819974 | 1362 days ago | 2.01302156 ETH |
Loading...
Loading
Contract Name:
Forwarder
Compiler Version
v0.5.16+commit.9c3226ce
Contract Source Code (Solidity Standard Json-Input format)
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetData.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol"; import "@0x/contracts-extensions/contracts/src/LibAssetDataTransfer.sol"; import "@0x/contracts-extensions/contracts/src/MixinWethUtils.sol"; import "@0x/contracts-utils/contracts/src/LibBytes.sol"; import "@0x/contracts-utils/contracts/src/LibRichErrors.sol"; import "@0x/contracts-utils/contracts/src/LibSafeMath.sol"; import "@0x/contracts-utils/contracts/src/Ownable.sol"; import "./libs/LibForwarderRichErrors.sol"; import "./MixinExchangeWrapper.sol"; import "./MixinReceiver.sol"; import "./interfaces/IForwarder.sol"; contract Forwarder is IForwarder, Ownable, MixinWethUtils, MixinExchangeWrapper, MixinReceiver { using LibBytes for bytes; using LibAssetDataTransfer for bytes; using LibSafeMath for uint256; constructor ( address _exchange, address _exchangeV2, address _weth ) public Ownable() MixinWethUtils( _exchange, _weth ) MixinExchangeWrapper( _exchange, _exchangeV2 ) {} // solhint-disable-line no-empty-blocks /// @dev Withdraws assets from this contract. It may be used by the owner to withdraw assets /// that were accidentally sent to this contract. /// @param assetData Byte array encoded for the respective asset proxy. /// @param amount Amount of the asset to withdraw. function withdrawAsset( bytes calldata assetData, uint256 amount ) external onlyOwner { assetData.transferOut(amount); } /// @dev Approves the respective proxy for a given asset to transfer tokens on the Forwarder contract's behalf. /// This is necessary because an order fee denominated in the maker asset (i.e. a percentage fee) is sent by the /// Forwarder contract to the fee recipient. /// This method needs to be called before forwarding orders of a maker asset that hasn't /// previously been approved. /// @param assetData Byte array encoded for the respective asset proxy. function approveMakerAssetProxy(bytes calldata assetData) external { bytes4 proxyId = assetData.readBytes4(0); bytes4 erc20ProxyId = IAssetData(address(0)).ERC20Token.selector; // For now we only care about ERC20, since percentage fees on ERC721 tokens are invalid. if (proxyId == erc20ProxyId) { address proxyAddress = EXCHANGE.getAssetProxy(erc20ProxyId); if (proxyAddress == address(0)) { LibRichErrors.rrevert(LibForwarderRichErrors.UnregisteredAssetProxyError()); } address token = assetData.readAddress(16); LibERC20Token.approve(token, proxyAddress, MAX_UINT256); } } /// @dev Purchases as much of orders' makerAssets as possible by selling as much of the ETH value sent /// as possible, accounting for order and forwarder fees. /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. /// @param signatures Proofs that orders have been created by makers. /// @param ethFeeAmounts Amounts of ETH, denominated in Wei, that are paid to corresponding feeRecipients. /// @param feeRecipients Addresses that will receive ETH when orders are filled. /// @return wethSpentAmount Amount of WETH spent on the given set of orders. /// @return makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders. function marketSellOrdersWithEth( LibOrder.Order[] memory orders, bytes[] memory signatures, uint256[] memory ethFeeAmounts, address payable[] memory feeRecipients ) public payable returns ( uint256 wethSpentAmount, uint256 makerAssetAcquiredAmount ) { // Pay ETH affiliate fees to all feeRecipient addresses uint256 wethRemaining = _transferEthFeesAndWrapRemaining( ethFeeAmounts, feeRecipients ); // Spends up to wethRemaining to fill orders, transfers purchased assets to msg.sender, // and pays WETH order fees. ( wethSpentAmount, makerAssetAcquiredAmount ) = _marketSellNoThrow( orders, wethRemaining, signatures ); // Ensure that no extra WETH owned by this contract has been spent. if (wethSpentAmount > wethRemaining) { LibRichErrors.rrevert(LibForwarderRichErrors.OverspentWethError( wethSpentAmount, msg.value )); } // Calculate amount of WETH that hasn't been spent. wethRemaining = wethRemaining.safeSub(wethSpentAmount); // Refund remaining ETH to msg.sender. _unwrapAndTransferEth(wethRemaining); } /// @dev Attempt to buy makerAssetBuyAmount of makerAsset by selling ETH provided with transaction. /// The Forwarder may *fill* more than makerAssetBuyAmount of the makerAsset so that it can /// pay takerFees where takerFeeAssetData == makerAssetData (i.e. percentage fees). /// Any ETH not spent will be refunded to sender. /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. /// @param makerAssetBuyAmount Desired amount of makerAsset to purchase. /// @param signatures Proofs that orders have been created by makers. /// @param ethFeeAmounts Amounts of ETH, denominated in Wei, that are paid to corresponding feeRecipients. /// @param feeRecipients Addresses that will receive ETH when orders are filled. /// @return wethSpentAmount Amount of WETH spent on the given set of orders. /// @return makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders. function marketBuyOrdersWithEth( LibOrder.Order[] memory orders, uint256 makerAssetBuyAmount, bytes[] memory signatures, uint256[] memory ethFeeAmounts, address payable[] memory feeRecipients ) public payable returns ( uint256 wethSpentAmount, uint256 makerAssetAcquiredAmount ) { // Pay ETH affiliate fees to all feeRecipient addresses uint256 wethRemaining = _transferEthFeesAndWrapRemaining( ethFeeAmounts, feeRecipients ); // Attempts to fill the desired amount of makerAsset and trasnfer purchased assets to msg.sender. ( wethSpentAmount, makerAssetAcquiredAmount ) = _marketBuyFillOrKill( orders, makerAssetBuyAmount, signatures ); // Ensure that no extra WETH owned by this contract has been spent. if (wethSpentAmount > wethRemaining) { LibRichErrors.rrevert(LibForwarderRichErrors.OverspentWethError( wethSpentAmount, msg.value )); } // Calculate amount of WETH that hasn't been spent. wethRemaining = wethRemaining.safeSub(wethSpentAmount); // Refund remaining ETH to msg.sender. _unwrapAndTransferEth(wethRemaining); } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // solhint-disable pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; // @dev Interface of the asset proxy's assetData. // The asset proxies take an ABI encoded `bytes assetData` as argument. // This argument is ABI encoded as one of the methods of this interface. interface IAssetData { /// @dev Function signature for encoding ERC20 assetData. /// @param tokenAddress Address of ERC20Token contract. function ERC20Token(address tokenAddress) external; /// @dev Function signature for encoding ERC721 assetData. /// @param tokenAddress Address of ERC721 token contract. /// @param tokenId Id of ERC721 token to be transferred. function ERC721Token( address tokenAddress, uint256 tokenId ) external; /// @dev Function signature for encoding ERC1155 assetData. /// @param tokenAddress Address of ERC1155 token contract. /// @param tokenIds Array of ids of tokens to be transferred. /// @param values Array of values that correspond to each token id to be transferred. /// Note that each value will be multiplied by the amount being filled in the order before transferring. /// @param callbackData Extra data to be passed to receiver's `onERC1155Received` callback function. function ERC1155Assets( address tokenAddress, uint256[] calldata tokenIds, uint256[] calldata values, bytes calldata callbackData ) external; /// @dev Function signature for encoding MultiAsset assetData. /// @param values Array of amounts that correspond to each asset to be transferred. /// Note that each value will be multiplied by the amount being filled in the order before transferring. /// @param nestedAssetData Array of assetData fields that will be be dispatched to their correspnding AssetProxy contract. function MultiAsset( uint256[] calldata values, bytes[] calldata nestedAssetData ) external; /// @dev Function signature for encoding StaticCall assetData. /// @param staticCallTargetAddress Address that will execute the staticcall. /// @param staticCallData Data that will be executed via staticcall on the staticCallTargetAddress. /// @param expectedReturnDataHash Keccak-256 hash of the expected staticcall return data. function StaticCall( address staticCallTargetAddress, bytes calldata staticCallData, bytes32 expectedReturnDataHash ) external; /// @dev Function signature for encoding ERC20Bridge assetData. /// @param tokenAddress Address of token to transfer. /// @param bridgeAddress Address of the bridge contract. /// @param bridgeData Arbitrary data to be passed to the bridge contract. function ERC20Bridge( address tokenAddress, address bridgeAddress, bytes calldata bridgeData ) external; }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; import "@0x/contracts-utils/contracts/src/LibEIP712.sol"; library LibOrder { using LibOrder for Order; // Hash for the EIP712 Order Schema: // keccak256(abi.encodePacked( // "Order(", // "address makerAddress,", // "address takerAddress,", // "address feeRecipientAddress,", // "address senderAddress,", // "uint256 makerAssetAmount,", // "uint256 takerAssetAmount,", // "uint256 makerFee,", // "uint256 takerFee,", // "uint256 expirationTimeSeconds,", // "uint256 salt,", // "bytes makerAssetData,", // "bytes takerAssetData,", // "bytes makerFeeAssetData,", // "bytes takerFeeAssetData", // ")" // )) bytes32 constant internal _EIP712_ORDER_SCHEMA_HASH = 0xf80322eb8376aafb64eadf8f0d7623f22130fd9491a221e902b713cb984a7534; // A valid order remains fillable until it is expired, fully filled, or cancelled. // An order's status is unaffected by external factors, like account balances. enum OrderStatus { INVALID, // Default value INVALID_MAKER_ASSET_AMOUNT, // Order does not have a valid maker asset amount INVALID_TAKER_ASSET_AMOUNT, // Order does not have a valid taker asset amount FILLABLE, // Order is fillable EXPIRED, // Order has already expired FULLY_FILLED, // Order is fully filled CANCELLED // Order has been cancelled } // solhint-disable max-line-length /// @dev Canonical order structure. struct Order { address makerAddress; // Address that created the order. address takerAddress; // Address that is allowed to fill the order. If set to 0, any address is allowed to fill the order. address feeRecipientAddress; // Address that will recieve fees when order is filled. 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. uint256 makerAssetAmount; // Amount of makerAsset being offered by maker. Must be greater than 0. uint256 takerAssetAmount; // Amount of takerAsset being bid on by maker. Must be greater than 0. uint256 makerFee; // Fee paid to feeRecipient by maker when order is filled. uint256 takerFee; // Fee paid to feeRecipient by taker when order is filled. uint256 expirationTimeSeconds; // Timestamp in seconds at which order expires. uint256 salt; // Arbitrary number to facilitate uniqueness of the order's hash. bytes makerAssetData; // Encoded data that can be decoded by a specified proxy contract when transferring makerAsset. The leading bytes4 references the id of the asset proxy. bytes takerAssetData; // Encoded data that can be decoded by a specified proxy contract when transferring takerAsset. The leading bytes4 references the id of the asset proxy. bytes makerFeeAssetData; // Encoded data that can be decoded by a specified proxy contract when transferring makerFeeAsset. The leading bytes4 references the id of the asset proxy. bytes takerFeeAssetData; // Encoded data that can be decoded by a specified proxy contract when transferring takerFeeAsset. The leading bytes4 references the id of the asset proxy. } // solhint-enable max-line-length /// @dev Order information returned by `getOrderInfo()`. struct OrderInfo { OrderStatus orderStatus; // Status that describes order's validity and fillability. bytes32 orderHash; // EIP712 typed data hash of the order (see LibOrder.getTypedDataHash). uint256 orderTakerAssetFilledAmount; // Amount of order that has already been filled. } /// @dev Calculates the EIP712 typed data hash of an order with a given domain separator. /// @param order The order structure. /// @return EIP712 typed data hash of the order. function getTypedDataHash(Order memory order, bytes32 eip712ExchangeDomainHash) internal pure returns (bytes32 orderHash) { orderHash = LibEIP712.hashEIP712Message( eip712ExchangeDomainHash, order.getStructHash() ); return orderHash; } /// @dev Calculates EIP712 hash of the order struct. /// @param order The order structure. /// @return EIP712 hash of the order struct. function getStructHash(Order memory order) internal pure returns (bytes32 result) { bytes32 schemaHash = _EIP712_ORDER_SCHEMA_HASH; bytes memory makerAssetData = order.makerAssetData; bytes memory takerAssetData = order.takerAssetData; bytes memory makerFeeAssetData = order.makerFeeAssetData; bytes memory takerFeeAssetData = order.takerFeeAssetData; // Assembly for more efficiently computing: // keccak256(abi.encodePacked( // EIP712_ORDER_SCHEMA_HASH, // uint256(order.makerAddress), // uint256(order.takerAddress), // uint256(order.feeRecipientAddress), // uint256(order.senderAddress), // order.makerAssetAmount, // order.takerAssetAmount, // order.makerFee, // order.takerFee, // order.expirationTimeSeconds, // order.salt, // keccak256(order.makerAssetData), // keccak256(order.takerAssetData), // keccak256(order.makerFeeAssetData), // keccak256(order.takerFeeAssetData) // )); assembly { // Assert order offset (this is an internal error that should never be triggered) if lt(order, 32) { invalid() } // Calculate memory addresses that will be swapped out before hashing let pos1 := sub(order, 32) let pos2 := add(order, 320) let pos3 := add(order, 352) let pos4 := add(order, 384) let pos5 := add(order, 416) // Backup let temp1 := mload(pos1) let temp2 := mload(pos2) let temp3 := mload(pos3) let temp4 := mload(pos4) let temp5 := mload(pos5) // Hash in place mstore(pos1, schemaHash) mstore(pos2, keccak256(add(makerAssetData, 32), mload(makerAssetData))) // store hash of makerAssetData mstore(pos3, keccak256(add(takerAssetData, 32), mload(takerAssetData))) // store hash of takerAssetData mstore(pos4, keccak256(add(makerFeeAssetData, 32), mload(makerFeeAssetData))) // store hash of makerFeeAssetData mstore(pos5, keccak256(add(takerFeeAssetData, 32), mload(takerFeeAssetData))) // store hash of takerFeeAssetData result := keccak256(pos1, 480) // Restore mstore(pos1, temp1) mstore(pos2, temp2) mstore(pos3, temp3) mstore(pos4, temp4) mstore(pos5, temp5) } return result; } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; library LibEIP712 { // Hash of the EIP712 Domain Separator Schema // keccak256(abi.encodePacked( // "EIP712Domain(", // "string name,", // "string version,", // "uint256 chainId,", // "address verifyingContract", // ")" // )) bytes32 constant internal _EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f; /// @dev Calculates a EIP712 domain separator. /// @param name The EIP712 domain name. /// @param version The EIP712 domain version. /// @param verifyingContract The EIP712 verifying contract. /// @return EIP712 domain separator. function hashEIP712Domain( string memory name, string memory version, uint256 chainId, address verifyingContract ) internal pure returns (bytes32 result) { bytes32 schemaHash = _EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH; // Assembly for more efficient computing: // keccak256(abi.encodePacked( // _EIP712_DOMAIN_SEPARATOR_SCHEMA_HASH, // keccak256(bytes(name)), // keccak256(bytes(version)), // chainId, // uint256(verifyingContract) // )) assembly { // Calculate hashes of dynamic data let nameHash := keccak256(add(name, 32), mload(name)) let versionHash := keccak256(add(version, 32), mload(version)) // Load free memory pointer let memPtr := mload(64) // Store params in memory mstore(memPtr, schemaHash) mstore(add(memPtr, 32), nameHash) mstore(add(memPtr, 64), versionHash) mstore(add(memPtr, 96), chainId) mstore(add(memPtr, 128), verifyingContract) // Compute hash result := keccak256(memPtr, 160) } return result; } /// @dev Calculates EIP712 encoding for a hash struct with a given domain hash. /// @param eip712DomainHash Hash of the domain domain separator data, computed /// with getDomainHash(). /// @param hashStruct The EIP712 hash struct. /// @return EIP712 hash applied to the given EIP712 Domain. function hashEIP712Message(bytes32 eip712DomainHash, bytes32 hashStruct) internal pure returns (bytes32 result) { // Assembly for more efficient computing: // keccak256(abi.encodePacked( // EIP191_HEADER, // EIP712_DOMAIN_HASH, // hashStruct // )); assembly { // Load free memory pointer let memPtr := mload(64) mstore(memPtr, 0x1901000000000000000000000000000000000000000000000000000000000000) // EIP191 header mstore(add(memPtr, 2), eip712DomainHash) // EIP712 domain hash mstore(add(memPtr, 34), hashStruct) // Hash of struct // Compute hash result := keccak256(memPtr, 66) } return result; } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; import "@0x/contracts-utils/contracts/src/LibSafeMath.sol"; import "@0x/contracts-utils/contracts/src/LibRichErrors.sol"; import "./LibMathRichErrors.sol"; library LibMath { using LibSafeMath for uint256; /// @dev Calculates partial value given a numerator and denominator rounded down. /// Reverts if rounding error is >= 0.1% /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to calculate partial of. /// @return Partial value of target rounded down. function safeGetPartialAmountFloor( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (uint256 partialAmount) { if (isRoundingErrorFloor( numerator, denominator, target )) { LibRichErrors.rrevert(LibMathRichErrors.RoundingError( numerator, denominator, target )); } partialAmount = numerator.safeMul(target).safeDiv(denominator); return partialAmount; } /// @dev Calculates partial value given a numerator and denominator rounded down. /// Reverts if rounding error is >= 0.1% /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to calculate partial of. /// @return Partial value of target rounded up. function safeGetPartialAmountCeil( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (uint256 partialAmount) { if (isRoundingErrorCeil( numerator, denominator, target )) { LibRichErrors.rrevert(LibMathRichErrors.RoundingError( numerator, denominator, target )); } // safeDiv computes `floor(a / b)`. We use the identity (a, b integer): // ceil(a / b) = floor((a + b - 1) / b) // To implement `ceil(a / b)` using safeDiv. partialAmount = numerator.safeMul(target) .safeAdd(denominator.safeSub(1)) .safeDiv(denominator); return partialAmount; } /// @dev Calculates partial value given a numerator and denominator rounded down. /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to calculate partial of. /// @return Partial value of target rounded down. function getPartialAmountFloor( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (uint256 partialAmount) { partialAmount = numerator.safeMul(target).safeDiv(denominator); return partialAmount; } /// @dev Calculates partial value given a numerator and denominator rounded down. /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to calculate partial of. /// @return Partial value of target rounded up. function getPartialAmountCeil( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (uint256 partialAmount) { // safeDiv computes `floor(a / b)`. We use the identity (a, b integer): // ceil(a / b) = floor((a + b - 1) / b) // To implement `ceil(a / b)` using safeDiv. partialAmount = numerator.safeMul(target) .safeAdd(denominator.safeSub(1)) .safeDiv(denominator); return partialAmount; } /// @dev Checks if rounding error >= 0.1% when rounding down. /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to multiply with numerator/denominator. /// @return Rounding error is present. function isRoundingErrorFloor( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (bool isError) { if (denominator == 0) { LibRichErrors.rrevert(LibMathRichErrors.DivisionByZeroError()); } // The absolute rounding error is the difference between the rounded // value and the ideal value. The relative rounding error is the // absolute rounding error divided by the absolute value of the // ideal value. This is undefined when the ideal value is zero. // // The ideal value is `numerator * target / denominator`. // Let's call `numerator * target % denominator` the remainder. // The absolute error is `remainder / denominator`. // // When the ideal value is zero, we require the absolute error to // be zero. Fortunately, this is always the case. The ideal value is // zero iff `numerator == 0` and/or `target == 0`. In this case the // remainder and absolute error are also zero. if (target == 0 || numerator == 0) { return false; } // Otherwise, we want the relative rounding error to be strictly // less than 0.1%. // The relative error is `remainder / (numerator * target)`. // We want the relative error less than 1 / 1000: // remainder / (numerator * denominator) < 1 / 1000 // or equivalently: // 1000 * remainder < numerator * target // so we have a rounding error iff: // 1000 * remainder >= numerator * target uint256 remainder = mulmod( target, numerator, denominator ); isError = remainder.safeMul(1000) >= numerator.safeMul(target); return isError; } /// @dev Checks if rounding error >= 0.1% when rounding up. /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to multiply with numerator/denominator. /// @return Rounding error is present. function isRoundingErrorCeil( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (bool isError) { if (denominator == 0) { LibRichErrors.rrevert(LibMathRichErrors.DivisionByZeroError()); } // See the comments in `isRoundingError`. if (target == 0 || numerator == 0) { // When either is zero, the ideal value and rounded value are zero // and there is no rounding error. (Although the relative error // is undefined.) return false; } // Compute remainder as before uint256 remainder = mulmod( target, numerator, denominator ); remainder = denominator.safeSub(remainder) % denominator; isError = remainder.safeMul(1000) >= numerator.safeMul(target); return isError; } }
pragma solidity ^0.5.9; import "./LibRichErrors.sol"; import "./LibSafeMathRichErrors.sol"; library LibSafeMath { function safeMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; if (c / a != b) { LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError( LibSafeMathRichErrors.BinOpErrorCodes.MULTIPLICATION_OVERFLOW, a, b )); } return c; } function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError( LibSafeMathRichErrors.BinOpErrorCodes.DIVISION_BY_ZERO, a, b )); } uint256 c = a / b; return c; } function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { if (b > a) { LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError( LibSafeMathRichErrors.BinOpErrorCodes.SUBTRACTION_UNDERFLOW, a, b )); } return a - b; } function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; if (c < a) { LibRichErrors.rrevert(LibSafeMathRichErrors.Uint256BinOpError( LibSafeMathRichErrors.BinOpErrorCodes.ADDITION_OVERFLOW, a, b )); } return c; } function max256(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; library LibRichErrors { // bytes4(keccak256("Error(string)")) bytes4 internal constant STANDARD_ERROR_SELECTOR = 0x08c379a0; // solhint-disable func-name-mixedcase /// @dev ABI encode a standard, string revert error payload. /// This is the same payload that would be included by a `revert(string)` /// solidity statement. It has the function signature `Error(string)`. /// @param message The error string. /// @return The ABI encoded error. function StandardError( string memory message ) internal pure returns (bytes memory) { return abi.encodeWithSelector( STANDARD_ERROR_SELECTOR, bytes(message) ); } // solhint-enable func-name-mixedcase /// @dev Reverts an encoded rich revert reason `errorData`. /// @param errorData ABI encoded error data. function rrevert(bytes memory errorData) internal pure { assembly { revert(add(errorData, 0x20), mload(errorData)) } } }
pragma solidity ^0.5.9; library LibSafeMathRichErrors { // bytes4(keccak256("Uint256BinOpError(uint8,uint256,uint256)")) bytes4 internal constant UINT256_BINOP_ERROR_SELECTOR = 0xe946c1bb; // bytes4(keccak256("Uint256DowncastError(uint8,uint256)")) bytes4 internal constant UINT256_DOWNCAST_ERROR_SELECTOR = 0xc996af7b; enum BinOpErrorCodes { ADDITION_OVERFLOW, MULTIPLICATION_OVERFLOW, SUBTRACTION_UNDERFLOW, DIVISION_BY_ZERO } enum DowncastErrorCodes { VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT32, VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT64, VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT96 } // solhint-disable func-name-mixedcase function Uint256BinOpError( BinOpErrorCodes errorCode, uint256 a, uint256 b ) internal pure returns (bytes memory) { return abi.encodeWithSelector( UINT256_BINOP_ERROR_SELECTOR, errorCode, a, b ); } function Uint256DowncastError( DowncastErrorCodes errorCode, uint256 a ) internal pure returns (bytes memory) { return abi.encodeWithSelector( UINT256_DOWNCAST_ERROR_SELECTOR, errorCode, a ); } }
pragma solidity ^0.5.9; library LibMathRichErrors { // bytes4(keccak256("DivisionByZeroError()")) bytes internal constant DIVISION_BY_ZERO_ERROR = hex"a791837c"; // bytes4(keccak256("RoundingError(uint256,uint256,uint256)")) bytes4 internal constant ROUNDING_ERROR_SELECTOR = 0x339f3de2; // solhint-disable func-name-mixedcase function DivisionByZeroError() internal pure returns (bytes memory) { return DIVISION_BY_ZERO_ERROR; } function RoundingError( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (bytes memory) { return abi.encodeWithSelector( ROUNDING_ERROR_SELECTOR, numerator, denominator, target ); } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/LibBytes.sol"; import "@0x/contracts-utils/contracts/src/LibRichErrors.sol"; import "@0x/contracts-utils/contracts/src/LibSafeMath.sol"; import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol"; import "@0x/contracts-erc721/contracts/src/interfaces/IERC721Token.sol"; import "@0x/contracts-erc1155/contracts/src/interfaces/IERC1155.sol"; import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetData.sol"; import "./rich-errors/LibAssetDataTransferRichErrors.sol"; library LibAssetDataTransfer { using LibBytes for bytes; using LibSafeMath for uint256; using LibAssetDataTransfer for bytes; /// @dev Transfers given amount of asset to sender. /// @param assetData Byte array encoded for the respective asset proxy. /// @param from Address to transfer asset from. /// @param to Address to transfer asset to. /// @param amount Amount of asset to transfer to sender. function transferFrom( bytes memory assetData, address from, address to, uint256 amount ) internal { if (amount == 0) { return; } bytes4 proxyId = assetData.readBytes4(0); if ( proxyId == IAssetData(address(0)).ERC20Token.selector || proxyId == IAssetData(address(0)).ERC20Bridge.selector ) { assetData.transferERC20Token( from, to, amount ); } else if (proxyId == IAssetData(address(0)).ERC721Token.selector) { assetData.transferERC721Token( from, to, amount ); } else if (proxyId == IAssetData(address(0)).ERC1155Assets.selector) { assetData.transferERC1155Assets( from, to, amount ); } else if (proxyId == IAssetData(address(0)).MultiAsset.selector) { assetData.transferMultiAsset( from, to, amount ); } else if (proxyId != IAssetData(address(0)).StaticCall.selector) { LibRichErrors.rrevert(LibAssetDataTransferRichErrors.UnsupportedAssetProxyError( proxyId )); } } ///@dev Transfer asset from sender to this contract. /// @param assetData Byte array encoded for the respective asset proxy. /// @param amount Amount of asset to transfer to sender. function transferIn( bytes memory assetData, uint256 amount ) internal { assetData.transferFrom( msg.sender, address(this), amount ); } ///@dev Transfer asset from this contract to sender. /// @param assetData Byte array encoded for the respective asset proxy. /// @param amount Amount of asset to transfer to sender. function transferOut( bytes memory assetData, uint256 amount ) internal { assetData.transferFrom( address(this), msg.sender, amount ); } /// @dev Decodes ERC20 or ERC20Bridge assetData and transfers given amount to sender. /// @param assetData Byte array encoded for the respective asset proxy. /// @param from Address to transfer asset from. /// @param to Address to transfer asset to. /// @param amount Amount of asset to transfer to sender. function transferERC20Token( bytes memory assetData, address from, address to, uint256 amount ) internal { address token = assetData.readAddress(16); // Transfer tokens. if (from == address(this)) { LibERC20Token.transfer( token, to, amount ); } else { LibERC20Token.transferFrom( token, from, to, amount ); } } /// @dev Decodes ERC721 assetData and transfers given amount to sender. /// @param assetData Byte array encoded for the respective asset proxy. /// @param from Address to transfer asset from. /// @param to Address to transfer asset to. /// @param amount Amount of asset to transfer to sender. function transferERC721Token( bytes memory assetData, address from, address to, uint256 amount ) internal { if (amount != 1) { LibRichErrors.rrevert(LibAssetDataTransferRichErrors.Erc721AmountMustEqualOneError( amount )); } // Decode asset data. address token = assetData.readAddress(16); uint256 tokenId = assetData.readUint256(36); // Perform transfer. IERC721Token(token).transferFrom( from, to, tokenId ); } /// @dev Decodes ERC1155 assetData and transfers given amounts to sender. /// @param assetData Byte array encoded for the respective asset proxy. /// @param from Address to transfer asset from. /// @param to Address to transfer asset to. /// @param amount Amount of asset to transfer to sender. function transferERC1155Assets( bytes memory assetData, address from, address to, uint256 amount ) internal { // Decode assetData // solhint-disable ( address token, uint256[] memory ids, uint256[] memory values, bytes memory data ) = abi.decode( assetData.slice(4, assetData.length), (address, uint256[], uint256[], bytes) ); // solhint-enable // Scale up values by `amount` uint256 length = values.length; uint256[] memory scaledValues = new uint256[](length); for (uint256 i = 0; i != length; i++) { scaledValues[i] = values[i].safeMul(amount); } // Execute `safeBatchTransferFrom` call // Either succeeds or throws IERC1155(token).safeBatchTransferFrom( from, to, ids, scaledValues, data ); } /// @dev Decodes MultiAsset assetData and recursively transfers assets to sender. /// @param assetData Byte array encoded for the respective asset proxy. /// @param from Address to transfer asset from. /// @param to Address to transfer asset to. /// @param amount Amount of asset to transfer to sender. function transferMultiAsset( bytes memory assetData, address from, address to, uint256 amount ) internal { // solhint-disable indent (uint256[] memory nestedAmounts, bytes[] memory nestedAssetData) = abi.decode( assetData.slice(4, assetData.length), (uint256[], bytes[]) ); // solhint-enable indent uint256 numNestedAssets = nestedAssetData.length; for (uint256 i = 0; i != numNestedAssets; i++) { transferFrom( nestedAssetData[i], from, to, amount.safeMul(nestedAmounts[i]) ); } } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; import "./LibBytesRichErrors.sol"; import "./LibRichErrors.sol"; library LibBytes { using LibBytes for bytes; /// @dev Gets the memory address for a byte array. /// @param input Byte array to lookup. /// @return memoryAddress Memory address of byte array. This /// points to the header of the byte array which contains /// the length. function rawAddress(bytes memory input) internal pure returns (uint256 memoryAddress) { assembly { memoryAddress := input } return memoryAddress; } /// @dev Gets the memory address for the contents of a byte array. /// @param input Byte array to lookup. /// @return memoryAddress Memory address of the contents of the byte array. function contentAddress(bytes memory input) internal pure returns (uint256 memoryAddress) { assembly { memoryAddress := add(input, 32) } return memoryAddress; } /// @dev Copies `length` bytes from memory location `source` to `dest`. /// @param dest memory address to copy bytes to. /// @param source memory address to copy bytes from. /// @param length number of bytes to copy. function memCopy( uint256 dest, uint256 source, uint256 length ) internal pure { if (length < 32) { // Handle a partial word by reading destination and masking // off the bits we are interested in. // This correctly handles overlap, zero lengths and source == dest assembly { let mask := sub(exp(256, sub(32, length)), 1) let s := and(mload(source), not(mask)) let d := and(mload(dest), mask) mstore(dest, or(s, d)) } } else { // Skip the O(length) loop when source == dest. if (source == dest) { return; } // For large copies we copy whole words at a time. The final // word is aligned to the end of the range (instead of after the // previous) to handle partial words. So a copy will look like this: // // #### // #### // #### // #### // // We handle overlap in the source and destination range by // changing the copying direction. This prevents us from // overwriting parts of source that we still need to copy. // // This correctly handles source == dest // if (source > dest) { assembly { // We subtract 32 from `sEnd` and `dEnd` because it // is easier to compare with in the loop, and these // are also the addresses we need for copying the // last bytes. length := sub(length, 32) let sEnd := add(source, length) let dEnd := add(dest, length) // Remember the last 32 bytes of source // This needs to be done here and not after the loop // because we may have overwritten the last bytes in // source already due to overlap. let last := mload(sEnd) // Copy whole words front to back // Note: the first check is always true, // this could have been a do-while loop. // solhint-disable-next-line no-empty-blocks for {} lt(source, sEnd) {} { mstore(dest, mload(source)) source := add(source, 32) dest := add(dest, 32) } // Write the last 32 bytes mstore(dEnd, last) } } else { assembly { // We subtract 32 from `sEnd` and `dEnd` because those // are the starting points when copying a word at the end. length := sub(length, 32) let sEnd := add(source, length) let dEnd := add(dest, length) // Remember the first 32 bytes of source // This needs to be done here and not after the loop // because we may have overwritten the first bytes in // source already due to overlap. let first := mload(source) // Copy whole words back to front // We use a signed comparisson here to allow dEnd to become // negative (happens when source and dest < 32). Valid // addresses in local memory will never be larger than // 2**255, so they can be safely re-interpreted as signed. // Note: the first check is always true, // this could have been a do-while loop. // solhint-disable-next-line no-empty-blocks for {} slt(dest, dEnd) {} { mstore(dEnd, mload(sEnd)) sEnd := sub(sEnd, 32) dEnd := sub(dEnd, 32) } // Write the first 32 bytes mstore(dest, first) } } } } /// @dev Returns a slices from a byte array. /// @param b The byte array to take a slice from. /// @param from The starting index for the slice (inclusive). /// @param to The final index for the slice (exclusive). /// @return result The slice containing bytes at indices [from, to) function slice( bytes memory b, uint256 from, uint256 to ) internal pure returns (bytes memory result) { // Ensure that the from and to positions are valid positions for a slice within // the byte array that is being used. if (from > to) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.FromLessThanOrEqualsToRequired, from, to )); } if (to > b.length) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.ToLessThanOrEqualsLengthRequired, to, b.length )); } // Create a new bytes structure and copy contents result = new bytes(to - from); memCopy( result.contentAddress(), b.contentAddress() + from, result.length ); return result; } /// @dev Returns a slice from a byte array without preserving the input. /// @param b The byte array to take a slice from. Will be destroyed in the process. /// @param from The starting index for the slice (inclusive). /// @param to The final index for the slice (exclusive). /// @return result The slice containing bytes at indices [from, to) /// @dev When `from == 0`, the original array will match the slice. In other cases its state will be corrupted. function sliceDestructive( bytes memory b, uint256 from, uint256 to ) internal pure returns (bytes memory result) { // Ensure that the from and to positions are valid positions for a slice within // the byte array that is being used. if (from > to) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.FromLessThanOrEqualsToRequired, from, to )); } if (to > b.length) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.ToLessThanOrEqualsLengthRequired, to, b.length )); } // Create a new bytes structure around [from, to) in-place. assembly { result := add(b, from) mstore(result, sub(to, from)) } return result; } /// @dev Pops the last byte off of a byte array by modifying its length. /// @param b Byte array that will be modified. /// @return The byte that was popped off. function popLastByte(bytes memory b) internal pure returns (bytes1 result) { if (b.length == 0) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.LengthGreaterThanZeroRequired, b.length, 0 )); } // Store last byte. result = b[b.length - 1]; assembly { // Decrement length of byte array. let newLen := sub(mload(b), 1) mstore(b, newLen) } return result; } /// @dev Tests equality of two byte arrays. /// @param lhs First byte array to compare. /// @param rhs Second byte array to compare. /// @return True if arrays are the same. False otherwise. function equals( bytes memory lhs, bytes memory rhs ) internal pure returns (bool equal) { // Keccak gas cost is 30 + numWords * 6. This is a cheap way to compare. // We early exit on unequal lengths, but keccak would also correctly // handle this. return lhs.length == rhs.length && keccak256(lhs) == keccak256(rhs); } /// @dev Reads an address from a position in a byte array. /// @param b Byte array containing an address. /// @param index Index in byte array of address. /// @return address from byte array. function readAddress( bytes memory b, uint256 index ) internal pure returns (address result) { if (b.length < index + 20) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsTwentyRequired, b.length, index + 20 // 20 is length of address )); } // Add offset to index: // 1. Arrays are prefixed by 32-byte length parameter (add 32 to index) // 2. Account for size difference between address length and 32-byte storage word (subtract 12 from index) index += 20; // Read address from array memory assembly { // 1. Add index to address of bytes array // 2. Load 32-byte word from memory // 3. Apply 20-byte mask to obtain address result := and(mload(add(b, index)), 0xffffffffffffffffffffffffffffffffffffffff) } return result; } /// @dev Writes an address into a specific position in a byte array. /// @param b Byte array to insert address into. /// @param index Index in byte array of address. /// @param input Address to put into byte array. function writeAddress( bytes memory b, uint256 index, address input ) internal pure { if (b.length < index + 20) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsTwentyRequired, b.length, index + 20 // 20 is length of address )); } // Add offset to index: // 1. Arrays are prefixed by 32-byte length parameter (add 32 to index) // 2. Account for size difference between address length and 32-byte storage word (subtract 12 from index) index += 20; // Store address into array memory assembly { // The address occupies 20 bytes and mstore stores 32 bytes. // First fetch the 32-byte word where we'll be storing the address, then // apply a mask so we have only the bytes in the word that the address will not occupy. // Then combine these bytes with the address and store the 32 bytes back to memory with mstore. // 1. Add index to address of bytes array // 2. Load 32-byte word from memory // 3. Apply 12-byte mask to obtain extra bytes occupying word of memory where we'll store the address let neighbors := and( mload(add(b, index)), 0xffffffffffffffffffffffff0000000000000000000000000000000000000000 ) // Make sure input address is clean. // (Solidity does not guarantee this) input := and(input, 0xffffffffffffffffffffffffffffffffffffffff) // Store the neighbors and address into memory mstore(add(b, index), xor(input, neighbors)) } } /// @dev Reads a bytes32 value from a position in a byte array. /// @param b Byte array containing a bytes32 value. /// @param index Index in byte array of bytes32 value. /// @return bytes32 value from byte array. function readBytes32( bytes memory b, uint256 index ) internal pure returns (bytes32 result) { if (b.length < index + 32) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsThirtyTwoRequired, b.length, index + 32 )); } // Arrays are prefixed by a 256 bit length parameter index += 32; // Read the bytes32 from array memory assembly { result := mload(add(b, index)) } return result; } /// @dev Writes a bytes32 into a specific position in a byte array. /// @param b Byte array to insert <input> into. /// @param index Index in byte array of <input>. /// @param input bytes32 to put into byte array. function writeBytes32( bytes memory b, uint256 index, bytes32 input ) internal pure { if (b.length < index + 32) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsThirtyTwoRequired, b.length, index + 32 )); } // Arrays are prefixed by a 256 bit length parameter index += 32; // Read the bytes32 from array memory assembly { mstore(add(b, index), input) } } /// @dev Reads a uint256 value from a position in a byte array. /// @param b Byte array containing a uint256 value. /// @param index Index in byte array of uint256 value. /// @return uint256 value from byte array. function readUint256( bytes memory b, uint256 index ) internal pure returns (uint256 result) { result = uint256(readBytes32(b, index)); return result; } /// @dev Writes a uint256 into a specific position in a byte array. /// @param b Byte array to insert <input> into. /// @param index Index in byte array of <input>. /// @param input uint256 to put into byte array. function writeUint256( bytes memory b, uint256 index, uint256 input ) internal pure { writeBytes32(b, index, bytes32(input)); } /// @dev Reads an unpadded bytes4 value from a position in a byte array. /// @param b Byte array containing a bytes4 value. /// @param index Index in byte array of bytes4 value. /// @return bytes4 value from byte array. function readBytes4( bytes memory b, uint256 index ) internal pure returns (bytes4 result) { if (b.length < index + 4) { LibRichErrors.rrevert(LibBytesRichErrors.InvalidByteOperationError( LibBytesRichErrors.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsFourRequired, b.length, index + 4 )); } // Arrays are prefixed by a 32 byte length field index += 32; // Read the bytes4 from array memory assembly { result := mload(add(b, index)) // Solidity does not require us to clean the trailing bytes. // We do it anyway result := and(result, 0xFFFFFFFF00000000000000000000000000000000000000000000000000000000) } return result; } /// @dev Writes a new length to a byte array. /// Decreasing length will lead to removing the corresponding lower order bytes from the byte array. /// Increasing length may lead to appending adjacent in-memory bytes to the end of the byte array. /// @param b Bytes array to write new length to. /// @param length New length of byte array. function writeLength(bytes memory b, uint256 length) internal pure { assembly { mstore(b, length) } } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; library LibBytesRichErrors { enum InvalidByteOperationErrorCodes { FromLessThanOrEqualsToRequired, ToLessThanOrEqualsLengthRequired, LengthGreaterThanZeroRequired, LengthGreaterThanOrEqualsFourRequired, LengthGreaterThanOrEqualsTwentyRequired, LengthGreaterThanOrEqualsThirtyTwoRequired, LengthGreaterThanOrEqualsNestedBytesLengthRequired, DestinationLengthGreaterThanOrEqualSourceLengthRequired } // bytes4(keccak256("InvalidByteOperationError(uint8,uint256,uint256)")) bytes4 internal constant INVALID_BYTE_OPERATION_ERROR_SELECTOR = 0x28006595; // solhint-disable func-name-mixedcase function InvalidByteOperationError( InvalidByteOperationErrorCodes errorCode, uint256 offset, uint256 required ) internal pure returns (bytes memory) { return abi.encodeWithSelector( INVALID_BYTE_OPERATION_ERROR_SELECTOR, errorCode, offset, required ); } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; import "@0x/contracts-utils/contracts/src/LibRichErrors.sol"; import "@0x/contracts-utils/contracts/src/LibBytes.sol"; import "../src/interfaces/IERC20Token.sol"; library LibERC20Token { bytes constant private DECIMALS_CALL_DATA = hex"313ce567"; /// @dev Calls `IERC20Token(token).approve()`. /// Reverts if `false` is returned or if the return /// data length is nonzero and not 32 bytes. /// @param token The address of the token contract. /// @param spender The address that receives an allowance. /// @param allowance The allowance to set. function approve( address token, address spender, uint256 allowance ) internal { bytes memory callData = abi.encodeWithSelector( IERC20Token(0).approve.selector, spender, allowance ); _callWithOptionalBooleanResult(token, callData); } /// @dev Calls `IERC20Token(token).transfer()`. /// Reverts if `false` is returned or if the return /// data length is nonzero and not 32 bytes. /// @param token The address of the token contract. /// @param to The address that receives the tokens /// @param amount Number of tokens to transfer. function transfer( address token, address to, uint256 amount ) internal { bytes memory callData = abi.encodeWithSelector( IERC20Token(0).transfer.selector, to, amount ); _callWithOptionalBooleanResult(token, callData); } /// @dev Calls `IERC20Token(token).transferFrom()`. /// Reverts if `false` is returned or if the return /// data length is nonzero and not 32 bytes. /// @param token The address of the token contract. /// @param from The owner of the tokens. /// @param to The address that receives the tokens /// @param amount Number of tokens to transfer. function transferFrom( address token, address from, address to, uint256 amount ) internal { bytes memory callData = abi.encodeWithSelector( IERC20Token(0).transferFrom.selector, from, to, amount ); _callWithOptionalBooleanResult(token, callData); } /// @dev Retrieves the number of decimals for a token. /// Returns `18` if the call reverts. /// @return The number of decimals places for the token. function decimals(address token) internal view returns (uint8 tokenDecimals) { tokenDecimals = 18; (bool didSucceed, bytes memory resultData) = token.staticcall(DECIMALS_CALL_DATA); if (didSucceed && resultData.length == 32) { tokenDecimals = uint8(LibBytes.readUint256(resultData, 0)); } } /// @dev Executes a call on address `target` with calldata `callData` /// and asserts that either nothing was returned or a single boolean /// was returned equal to `true`. /// @param target The call target. /// @param callData The abi-encoded call data. function _callWithOptionalBooleanResult( address target, bytes memory callData ) private { (bool didSucceed, bytes memory resultData) = target.call(callData); if (didSucceed) { if (resultData.length == 0) { return; } if (resultData.length == 32) { uint256 result = LibBytes.readUint256(resultData, 0); if (result == 1) { return; } } } LibRichErrors.rrevert(resultData); } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; contract IERC20Token { // solhint-disable no-simple-event-func-name event Transfer( address indexed _from, address indexed _to, uint256 _value ); event Approval( address indexed _owner, address indexed _spender, uint256 _value ); /// @dev send `value` token to `to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return True if transfer was successful function transfer(address _to, uint256 _value) external returns (bool); /// @dev send `value` token to `to` from `from` on the condition it is approved by `from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return True if transfer was successful function transferFrom( address _from, address _to, uint256 _value ) external returns (bool); /// @dev `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of wei to be approved for transfer /// @return Always true if the call has enough gas to complete execution function approve(address _spender, uint256 _value) external returns (bool); /// @dev Query total supply of token /// @return Total supply of token function totalSupply() external view returns (uint256); /// @param _owner The address from which the balance will be retrieved /// @return Balance of owner function balanceOf(address _owner) external view returns (uint256); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) external view returns (uint256); }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; contract IERC721Token { /// @dev This emits when ownership of any NFT changes by any mechanism. /// This event emits when NFTs are created (`from` == 0) and destroyed /// (`to` == 0). Exception: during contract creation, any number of NFTs /// may be created and assigned without emitting Transfer. At the time of /// any transfer, the approved address for that NFT (if any) is reset to none. event Transfer( address indexed _from, address indexed _to, uint256 indexed _tokenId ); /// @dev This emits when the approved address for an NFT is changed or /// reaffirmed. The zero address indicates there is no approved address. /// When a Transfer event emits, this also indicates that the approved /// address for that NFT (if any) is reset to none. event Approval( address indexed _owner, address indexed _approved, uint256 indexed _tokenId ); /// @dev This emits when an operator is enabled or disabled for an owner. /// The operator can manage all NFTs of the owner. event ApprovalForAll( address indexed _owner, address indexed _operator, bool _approved ); /// @notice Transfers the ownership of an NFT from one address to another address /// @dev Throws unless `msg.sender` is the current owner, an authorized /// perator, or the approved address for this NFT. Throws if `_from` is /// not the current owner. Throws if `_to` is the zero address. Throws if /// `_tokenId` is not a valid NFT. When transfer is complete, this function /// checks if `_to` is a smart contract (code size > 0). If so, it calls /// `onERC721Received` on `_to` and throws if the return value is not /// `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`. /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer /// @param _data Additional data with no specified format, sent in call to `_to` function safeTransferFrom( address _from, address _to, uint256 _tokenId, bytes calldata _data ) external; /// @notice Transfers the ownership of an NFT from one address to another address /// @dev This works identically to the other function with an extra data parameter, /// except this function just sets data to "". /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer function safeTransferFrom( address _from, address _to, uint256 _tokenId ) external; /// @notice Change or reaffirm the approved address for an NFT /// @dev The zero address indicates there is no approved address. /// Throws unless `msg.sender` is the current NFT owner, or an authorized /// operator of the current owner. /// @param _approved The new approved NFT controller /// @param _tokenId The NFT to approve function approve(address _approved, uint256 _tokenId) external; /// @notice Enable or disable approval for a third party ("operator") to manage /// all of `msg.sender`'s assets /// @dev Emits the ApprovalForAll event. The contract MUST allow /// multiple operators per owner. /// @param _operator Address to add to the set of authorized operators /// @param _approved True if the operator is approved, false to revoke approval function setApprovalForAll(address _operator, bool _approved) external; /// @notice Count all NFTs assigned to an owner /// @dev NFTs assigned to the zero address are considered invalid, and this /// function throws for queries about the zero address. /// @param _owner An address for whom to query the balance /// @return The number of NFTs owned by `_owner`, possibly zero function balanceOf(address _owner) external view returns (uint256); /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE /// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE /// THEY MAY BE PERMANENTLY LOST /// @dev Throws unless `msg.sender` is the current owner, an authorized /// operator, or the approved address for this NFT. Throws if `_from` is /// not the current owner. Throws if `_to` is the zero address. Throws if /// `_tokenId` is not a valid NFT. /// @param _from The current owner of the NFT /// @param _to The new owner /// @param _tokenId The NFT to transfer function transferFrom( address _from, address _to, uint256 _tokenId ) public; /// @notice Find the owner of an NFT /// @dev NFTs assigned to zero address are considered invalid, and queries /// about them do throw. /// @param _tokenId The identifier for an NFT /// @return The address of the owner of the NFT function ownerOf(uint256 _tokenId) public view returns (address); /// @notice Get the approved address for a single NFT /// @dev Throws if `_tokenId` is not a valid NFT. /// @param _tokenId The NFT to find the approved address for /// @return The approved address for this NFT, or the zero address if there is none function getApproved(uint256 _tokenId) public view returns (address); /// @notice Query if an address is an authorized operator for another address /// @param _owner The address that owns the NFTs /// @param _operator The address that acts on behalf of the owner /// @return True if `_operator` is an approved operator for `_owner`, false otherwise function isApprovedForAll(address _owner, address _operator) public view returns (bool); }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; /// @title ERC-1155 Multi Token Standard /// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md /// Note: The ERC-165 identifier for this interface is 0xd9b67a26. interface IERC1155 { /// @dev Either TransferSingle or TransferBatch MUST emit when tokens are transferred, /// including zero value transfers as well as minting or burning. /// Operator will always be msg.sender. /// Either event from address `0x0` signifies a minting operation. /// An event to address `0x0` signifies a burning or melting operation. /// The total value transferred from address 0x0 minus the total value transferred to 0x0 may /// be used by clients and exchanges to be added to the "circulating supply" for a given token ID. /// To define a token ID with no initial balance, the contract SHOULD emit the TransferSingle event /// from `0x0` to `0x0`, with the token creator as `_operator`. event TransferSingle( address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value ); /// @dev Either TransferSingle or TransferBatch MUST emit when tokens are transferred, /// including zero value transfers as well as minting or burning. ///Operator will always be msg.sender. /// Either event from address `0x0` signifies a minting operation. /// An event to address `0x0` signifies a burning or melting operation. /// The total value transferred from address 0x0 minus the total value transferred to 0x0 may /// be used by clients and exchanges to be added to the "circulating supply" for a given token ID. /// To define multiple token IDs with no initial balance, this SHOULD emit the TransferBatch event /// from `0x0` to `0x0`, with the token creator as `_operator`. event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /// @dev MUST emit when an approval is updated. event ApprovalForAll( address indexed owner, address indexed operator, bool approved ); /// @dev MUST emit when the URI is updated for a token ID. /// URIs are defined in RFC 3986. /// The URI MUST point a JSON file that conforms to the "ERC-1155 Metadata JSON Schema". event URI( string value, uint256 indexed id ); /// @notice Transfers value amount of an _id from the _from address to the _to address specified. /// @dev MUST emit TransferSingle event on success. /// Caller must be approved to manage the _from account's tokens (see isApprovedForAll). /// MUST throw if `_to` is the zero address. /// MUST throw if balance of sender for token `_id` is lower than the `_value` sent. /// MUST throw on any other error. /// When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). /// If so, it MUST call `onERC1155Received` on `_to` and revert if the return value /// is not `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`. /// @param from Source address /// @param to Target address /// @param id ID of the token type /// @param value Transfer amount /// @param data Additional data with no specified format, sent in call to `_to` function safeTransferFrom( address from, address to, uint256 id, uint256 value, bytes calldata data ) external; /// @notice Send multiple types of Tokens from a 3rd party in one transfer (with safety call). /// @dev MUST emit TransferBatch event on success. /// Caller must be approved to manage the _from account's tokens (see isApprovedForAll). /// MUST throw if `_to` is the zero address. /// MUST throw if length of `_ids` is not the same as length of `_values`. /// MUST throw if any of the balance of sender for token `_ids` is lower than the respective `_values` sent. /// MUST throw on any other error. /// When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). /// If so, it MUST call `onERC1155BatchReceived` on `_to` and revert if the return value /// is not `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`. /// @param from Source addresses /// @param to Target addresses /// @param ids IDs of each token type /// @param values Transfer amounts per token type /// @param data Additional data with no specified format, sent in call to `_to` function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external; /// @notice Enable or disable approval for a third party ("operator") to manage all of the caller's tokens. /// @dev MUST emit the ApprovalForAll event on success. /// @param operator Address to add to the set of authorized operators /// @param approved True if the operator is approved, false to revoke approval function setApprovalForAll(address operator, bool approved) external; /// @notice Queries the approval status of an operator for a given owner. /// @param owner The owner of the Tokens /// @param operator Address of authorized operator /// @return True if the operator is approved, false if not function isApprovedForAll(address owner, address operator) external view returns (bool); /// @notice Get the balance of an account's Tokens. /// @param owner The address of the token holder /// @param id ID of the Token /// @return The _owner's balance of the Token type requested function balanceOf(address owner, uint256 id) external view returns (uint256); /// @notice Get the balance of multiple account/token pairs /// @param owners The addresses of the token holders /// @param ids ID of the Tokens /// @return The _owner's balance of the Token types requested function balanceOfBatch( address[] calldata owners, uint256[] calldata ids ) external view returns (uint256[] memory balances_); }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; library LibAssetDataTransferRichErrors { // bytes4(keccak256("UnsupportedAssetProxyError(bytes4)")) bytes4 internal constant UNSUPPORTED_ASSET_PROXY_ERROR_SELECTOR = 0x7996a271; // bytes4(keccak256("Erc721AmountMustEqualOneError(uint256)")) bytes4 internal constant ERC721_AMOUNT_MUST_EQUAL_ONE_ERROR_SELECTOR = 0xbaffa474; // solhint-disable func-name-mixedcase function UnsupportedAssetProxyError( bytes4 proxyId ) internal pure returns (bytes memory) { return abi.encodeWithSelector( UNSUPPORTED_ASSET_PROXY_ERROR_SELECTOR, proxyId ); } function Erc721AmountMustEqualOneError( uint256 amount ) internal pure returns (bytes memory) { return abi.encodeWithSelector( ERC721_AMOUNT_MUST_EQUAL_ONE_ERROR_SELECTOR, amount ); } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations \under the License. */ pragma solidity ^0.5.9; import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetData.sol"; import "@0x/contracts-erc20/contracts/src/interfaces/IEtherToken.sol"; import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol"; import "@0x/contracts-utils/contracts/src/LibRichErrors.sol"; import "@0x/contracts-utils/contracts/src/LibSafeMath.sol"; import "./rich-errors/LibWethUtilsRichErrors.sol"; contract MixinWethUtils { uint256 constant internal MAX_UINT256 = uint256(-1); // solhint-disable var-name-mixedcase IEtherToken internal WETH; bytes internal WETH_ASSET_DATA; // solhint-enable var-name-mixedcase using LibSafeMath for uint256; constructor ( address exchange, address weth ) public { WETH = IEtherToken(weth); WETH_ASSET_DATA = abi.encodeWithSelector( IAssetData(address(0)).ERC20Token.selector, weth ); address proxyAddress = IExchange(exchange).getAssetProxy(IAssetData(address(0)).ERC20Token.selector); if (proxyAddress == address(0)) { LibRichErrors.rrevert(LibWethUtilsRichErrors.UnregisteredAssetProxyError()); } WETH.approve(proxyAddress, MAX_UINT256); address protocolFeeCollector = IExchange(exchange).protocolFeeCollector(); if (protocolFeeCollector != address(0)) { WETH.approve(protocolFeeCollector, MAX_UINT256); } } /// @dev Default payable function, this allows us to withdraw WETH function () external payable { if (msg.sender != address(WETH)) { LibRichErrors.rrevert(LibWethUtilsRichErrors.DefaultFunctionWethContractOnlyError( msg.sender )); } } /// @dev Transfers ETH denominated fees to all feeRecipient addresses /// @param ethFeeAmounts Amounts of ETH, denominated in Wei, that are paid to corresponding feeRecipients. /// @param feeRecipients Addresses that will receive ETH when orders are filled. /// @return ethRemaining msg.value minus the amount of ETH spent on affiliate fees. function _transferEthFeesAndWrapRemaining( uint256[] memory ethFeeAmounts, address payable[] memory feeRecipients ) internal returns (uint256 ethRemaining) { uint256 feesLen = ethFeeAmounts.length; // ethFeeAmounts len must equal feeRecipients len if (feesLen != feeRecipients.length) { LibRichErrors.rrevert(LibWethUtilsRichErrors.EthFeeLengthMismatchError( feesLen, feeRecipients.length )); } // This function is always called before any other function, so we assume that // the ETH remaining is the entire msg.value. ethRemaining = msg.value; for (uint256 i = 0; i != feesLen; i++) { uint256 ethFeeAmount = ethFeeAmounts[i]; // Ensure there is enough ETH to pay the fee if (ethRemaining < ethFeeAmount) { LibRichErrors.rrevert(LibWethUtilsRichErrors.InsufficientEthForFeeError( ethFeeAmount, ethRemaining )); } // Decrease ethRemaining and transfer fee to corresponding feeRecipient ethRemaining = ethRemaining.safeSub(ethFeeAmount); feeRecipients[i].transfer(ethFeeAmount); } // Convert remaining ETH to WETH. WETH.deposit.value(ethRemaining)(); return ethRemaining; } /// @dev Unwraps WETH and transfers ETH to msg.sender. /// @param transferAmount Amount of WETH balance to unwrap and transfer. function _unwrapAndTransferEth( uint256 transferAmount ) internal { // Do nothing if amount is zero if (transferAmount > 0) { // Convert WETH to ETH WETH.withdraw(transferAmount); // Transfer ETH to sender msg.sender.transfer(transferAmount); } } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; import "./IERC20Token.sol"; contract IEtherToken is IERC20Token { function deposit() public payable; function withdraw(uint256 amount) public; }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; import "./IExchangeCore.sol"; import "./IProtocolFees.sol"; import "./IMatchOrders.sol"; import "./ISignatureValidator.sol"; import "./ITransactions.sol"; import "./IAssetProxyDispatcher.sol"; import "./IWrapperFunctions.sol"; import "./ITransferSimulator.sol"; // solhint-disable no-empty-blocks contract IExchange is IProtocolFees, IExchangeCore, IMatchOrders, ISignatureValidator, ITransactions, IAssetProxyDispatcher, ITransferSimulator, IWrapperFunctions {}
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol"; contract IExchangeCore { // Fill event is emitted whenever an order is filled. event Fill( address indexed makerAddress, // Address that created the order. address indexed feeRecipientAddress, // Address that received fees. bytes makerAssetData, // Encoded data specific to makerAsset. bytes takerAssetData, // Encoded data specific to takerAsset. bytes makerFeeAssetData, // Encoded data specific to makerFeeAsset. bytes takerFeeAssetData, // Encoded data specific to takerFeeAsset. bytes32 indexed orderHash, // EIP712 hash of order (see LibOrder.getTypedDataHash). address takerAddress, // Address that filled the order. address senderAddress, // Address that called the Exchange contract (msg.sender). uint256 makerAssetFilledAmount, // Amount of makerAsset sold by maker and bought by taker. uint256 takerAssetFilledAmount, // Amount of takerAsset sold by taker and bought by maker. uint256 makerFeePaid, // Amount of makerFeeAssetData paid to feeRecipient by maker. uint256 takerFeePaid, // Amount of takerFeeAssetData paid to feeRecipient by taker. uint256 protocolFeePaid // Amount of eth or weth paid to the staking contract. ); // Cancel event is emitted whenever an individual order is cancelled. event Cancel( address indexed makerAddress, // Address that created the order. address indexed feeRecipientAddress, // Address that would have recieved fees if order was filled. bytes makerAssetData, // Encoded data specific to makerAsset. bytes takerAssetData, // Encoded data specific to takerAsset. address senderAddress, // Address that called the Exchange contract (msg.sender). bytes32 indexed orderHash // EIP712 hash of order (see LibOrder.getTypedDataHash). ); // CancelUpTo event is emitted whenever `cancelOrdersUpTo` is executed succesfully. event CancelUpTo( address indexed makerAddress, // Orders cancelled must have been created by this address. address indexed orderSenderAddress, // Orders cancelled must have a `senderAddress` equal to this address. uint256 orderEpoch // Orders with specified makerAddress and senderAddress with a salt less than this value are considered cancelled. ); /// @dev Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch /// and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress). /// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled. function cancelOrdersUpTo(uint256 targetOrderEpoch) external payable; /// @dev Fills the input order. /// @param order Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. /// @return Amounts filled and fees paid by maker and taker. function fillOrder( LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) public payable returns (LibFillResults.FillResults memory fillResults); /// @dev After calling, the order can not be filled anymore. /// @param order Order struct containing order specifications. function cancelOrder(LibOrder.Order memory order) public payable; /// @dev Gets information about an order: status, hash, and amount filled. /// @param order Order to gather information on. /// @return OrderInfo Information about the order and its state. /// See LibOrder.OrderInfo for a complete description. function getOrderInfo(LibOrder.Order memory order) public view returns (LibOrder.OrderInfo memory orderInfo); }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; import "@0x/contracts-utils/contracts/src/LibSafeMath.sol"; import "./LibMath.sol"; import "./LibOrder.sol"; library LibFillResults { using LibSafeMath for uint256; struct BatchMatchedFillResults { FillResults[] left; // Fill results for left orders FillResults[] right; // Fill results for right orders uint256 profitInLeftMakerAsset; // Profit taken from left makers uint256 profitInRightMakerAsset; // Profit taken from right makers } struct FillResults { uint256 makerAssetFilledAmount; // Total amount of makerAsset(s) filled. uint256 takerAssetFilledAmount; // Total amount of takerAsset(s) filled. uint256 makerFeePaid; // Total amount of fees paid by maker(s) to feeRecipient(s). uint256 takerFeePaid; // Total amount of fees paid by taker to feeRecipients(s). uint256 protocolFeePaid; // Total amount of fees paid by taker to the staking contract. } struct MatchedFillResults { FillResults left; // Amounts filled and fees paid of left order. FillResults right; // Amounts filled and fees paid of right order. uint256 profitInLeftMakerAsset; // Profit taken from the left maker uint256 profitInRightMakerAsset; // Profit taken from the right maker } /// @dev Calculates amounts filled and fees paid by maker and taker. /// @param order to be filled. /// @param takerAssetFilledAmount Amount of takerAsset that will be filled. /// @param protocolFeeMultiplier The current protocol fee of the exchange contract. /// @param gasPrice The gasprice of the transaction. This is provided so that the function call can continue /// to be pure rather than view. /// @return fillResults Amounts filled and fees paid by maker and taker. function calculateFillResults( LibOrder.Order memory order, uint256 takerAssetFilledAmount, uint256 protocolFeeMultiplier, uint256 gasPrice ) internal pure returns (FillResults memory fillResults) { // Compute proportional transfer amounts fillResults.takerAssetFilledAmount = takerAssetFilledAmount; fillResults.makerAssetFilledAmount = LibMath.safeGetPartialAmountFloor( takerAssetFilledAmount, order.takerAssetAmount, order.makerAssetAmount ); fillResults.makerFeePaid = LibMath.safeGetPartialAmountFloor( takerAssetFilledAmount, order.takerAssetAmount, order.makerFee ); fillResults.takerFeePaid = LibMath.safeGetPartialAmountFloor( takerAssetFilledAmount, order.takerAssetAmount, order.takerFee ); // Compute the protocol fee that should be paid for a single fill. fillResults.protocolFeePaid = gasPrice.safeMul(protocolFeeMultiplier); return fillResults; } /// @dev Calculates fill amounts for the matched orders. /// Each order is filled at their respective price point. However, the calculations are /// carried out as though the orders are both being filled at the right order's price point. /// The profit made by the leftOrder order goes to the taker (who matched the two orders). /// @param leftOrder First order to match. /// @param rightOrder Second order to match. /// @param leftOrderTakerAssetFilledAmount Amount of left order already filled. /// @param rightOrderTakerAssetFilledAmount Amount of right order already filled. /// @param protocolFeeMultiplier The current protocol fee of the exchange contract. /// @param gasPrice The gasprice of the transaction. This is provided so that the function call can continue /// to be pure rather than view. /// @param shouldMaximallyFillOrders A value that indicates whether or not this calculation should use /// the maximal fill order matching strategy. /// @param matchedFillResults Amounts to fill and fees to pay by maker and taker of matched orders. function calculateMatchedFillResults( LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder, uint256 leftOrderTakerAssetFilledAmount, uint256 rightOrderTakerAssetFilledAmount, uint256 protocolFeeMultiplier, uint256 gasPrice, bool shouldMaximallyFillOrders ) internal pure returns (MatchedFillResults memory matchedFillResults) { // Derive maker asset amounts for left & right orders, given store taker assert amounts uint256 leftTakerAssetAmountRemaining = leftOrder.takerAssetAmount.safeSub(leftOrderTakerAssetFilledAmount); uint256 leftMakerAssetAmountRemaining = LibMath.safeGetPartialAmountFloor( leftOrder.makerAssetAmount, leftOrder.takerAssetAmount, leftTakerAssetAmountRemaining ); uint256 rightTakerAssetAmountRemaining = rightOrder.takerAssetAmount.safeSub(rightOrderTakerAssetFilledAmount); uint256 rightMakerAssetAmountRemaining = LibMath.safeGetPartialAmountFloor( rightOrder.makerAssetAmount, rightOrder.takerAssetAmount, rightTakerAssetAmountRemaining ); // Maximally fill the orders and pay out profits to the matcher in one or both of the maker assets. if (shouldMaximallyFillOrders) { matchedFillResults = _calculateMatchedFillResultsWithMaximalFill( leftOrder, rightOrder, leftMakerAssetAmountRemaining, leftTakerAssetAmountRemaining, rightMakerAssetAmountRemaining, rightTakerAssetAmountRemaining ); } else { matchedFillResults = _calculateMatchedFillResults( leftOrder, rightOrder, leftMakerAssetAmountRemaining, leftTakerAssetAmountRemaining, rightMakerAssetAmountRemaining, rightTakerAssetAmountRemaining ); } // Compute fees for left order matchedFillResults.left.makerFeePaid = LibMath.safeGetPartialAmountFloor( matchedFillResults.left.makerAssetFilledAmount, leftOrder.makerAssetAmount, leftOrder.makerFee ); matchedFillResults.left.takerFeePaid = LibMath.safeGetPartialAmountFloor( matchedFillResults.left.takerAssetFilledAmount, leftOrder.takerAssetAmount, leftOrder.takerFee ); // Compute fees for right order matchedFillResults.right.makerFeePaid = LibMath.safeGetPartialAmountFloor( matchedFillResults.right.makerAssetFilledAmount, rightOrder.makerAssetAmount, rightOrder.makerFee ); matchedFillResults.right.takerFeePaid = LibMath.safeGetPartialAmountFloor( matchedFillResults.right.takerAssetFilledAmount, rightOrder.takerAssetAmount, rightOrder.takerFee ); // Compute the protocol fee that should be paid for a single fill. In this // case this should be made the protocol fee for both the left and right orders. uint256 protocolFee = gasPrice.safeMul(protocolFeeMultiplier); matchedFillResults.left.protocolFeePaid = protocolFee; matchedFillResults.right.protocolFeePaid = protocolFee; // Return fill results return matchedFillResults; } /// @dev Adds properties of both FillResults instances. /// @param fillResults1 The first FillResults. /// @param fillResults2 The second FillResults. /// @return The sum of both fill results. function addFillResults( FillResults memory fillResults1, FillResults memory fillResults2 ) internal pure returns (FillResults memory totalFillResults) { totalFillResults.makerAssetFilledAmount = fillResults1.makerAssetFilledAmount.safeAdd(fillResults2.makerAssetFilledAmount); totalFillResults.takerAssetFilledAmount = fillResults1.takerAssetFilledAmount.safeAdd(fillResults2.takerAssetFilledAmount); totalFillResults.makerFeePaid = fillResults1.makerFeePaid.safeAdd(fillResults2.makerFeePaid); totalFillResults.takerFeePaid = fillResults1.takerFeePaid.safeAdd(fillResults2.takerFeePaid); totalFillResults.protocolFeePaid = fillResults1.protocolFeePaid.safeAdd(fillResults2.protocolFeePaid); return totalFillResults; } /// @dev Calculates part of the matched fill results for a given situation using the fill strategy that only /// awards profit denominated in the left maker asset. /// @param leftOrder The left order in the order matching situation. /// @param rightOrder The right order in the order matching situation. /// @param leftMakerAssetAmountRemaining The amount of the left order maker asset that can still be filled. /// @param leftTakerAssetAmountRemaining The amount of the left order taker asset that can still be filled. /// @param rightMakerAssetAmountRemaining The amount of the right order maker asset that can still be filled. /// @param rightTakerAssetAmountRemaining The amount of the right order taker asset that can still be filled. /// @return MatchFillResults struct that does not include fees paid. function _calculateMatchedFillResults( LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder, uint256 leftMakerAssetAmountRemaining, uint256 leftTakerAssetAmountRemaining, uint256 rightMakerAssetAmountRemaining, uint256 rightTakerAssetAmountRemaining ) private pure returns (MatchedFillResults memory matchedFillResults) { // Calculate fill results for maker and taker assets: at least one order will be fully filled. // The maximum amount the left maker can buy is `leftTakerAssetAmountRemaining` // The maximum amount the right maker can sell is `rightMakerAssetAmountRemaining` // We have two distinct cases for calculating the fill results: // Case 1. // If the left maker can buy more than the right maker can sell, then only the right order is fully filled. // If the left maker can buy exactly what the right maker can sell, then both orders are fully filled. // Case 2. // If the left maker cannot buy more than the right maker can sell, then only the left order is fully filled. // Case 3. // If the left maker can buy exactly as much as the right maker can sell, then both orders are fully filled. if (leftTakerAssetAmountRemaining > rightMakerAssetAmountRemaining) { // Case 1: Right order is fully filled matchedFillResults = _calculateCompleteRightFill( leftOrder, rightMakerAssetAmountRemaining, rightTakerAssetAmountRemaining ); } else if (leftTakerAssetAmountRemaining < rightMakerAssetAmountRemaining) { // Case 2: Left order is fully filled matchedFillResults.left.makerAssetFilledAmount = leftMakerAssetAmountRemaining; matchedFillResults.left.takerAssetFilledAmount = leftTakerAssetAmountRemaining; matchedFillResults.right.makerAssetFilledAmount = leftTakerAssetAmountRemaining; // Round up to ensure the maker's exchange rate does not exceed the price specified by the order. // We favor the maker when the exchange rate must be rounded. matchedFillResults.right.takerAssetFilledAmount = LibMath.safeGetPartialAmountCeil( rightOrder.takerAssetAmount, rightOrder.makerAssetAmount, leftTakerAssetAmountRemaining // matchedFillResults.right.makerAssetFilledAmount ); } else { // leftTakerAssetAmountRemaining == rightMakerAssetAmountRemaining // Case 3: Both orders are fully filled. Technically, this could be captured by the above cases, but // this calculation will be more precise since it does not include rounding. matchedFillResults = _calculateCompleteFillBoth( leftMakerAssetAmountRemaining, leftTakerAssetAmountRemaining, rightMakerAssetAmountRemaining, rightTakerAssetAmountRemaining ); } // Calculate amount given to taker matchedFillResults.profitInLeftMakerAsset = matchedFillResults.left.makerAssetFilledAmount.safeSub( matchedFillResults.right.takerAssetFilledAmount ); return matchedFillResults; } /// @dev Calculates part of the matched fill results for a given situation using the maximal fill order matching /// strategy. /// @param leftOrder The left order in the order matching situation. /// @param rightOrder The right order in the order matching situation. /// @param leftMakerAssetAmountRemaining The amount of the left order maker asset that can still be filled. /// @param leftTakerAssetAmountRemaining The amount of the left order taker asset that can still be filled. /// @param rightMakerAssetAmountRemaining The amount of the right order maker asset that can still be filled. /// @param rightTakerAssetAmountRemaining The amount of the right order taker asset that can still be filled. /// @return MatchFillResults struct that does not include fees paid. function _calculateMatchedFillResultsWithMaximalFill( LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder, uint256 leftMakerAssetAmountRemaining, uint256 leftTakerAssetAmountRemaining, uint256 rightMakerAssetAmountRemaining, uint256 rightTakerAssetAmountRemaining ) private pure returns (MatchedFillResults memory matchedFillResults) { // If a maker asset is greater than the opposite taker asset, than there will be a spread denominated in that maker asset. bool doesLeftMakerAssetProfitExist = leftMakerAssetAmountRemaining > rightTakerAssetAmountRemaining; bool doesRightMakerAssetProfitExist = rightMakerAssetAmountRemaining > leftTakerAssetAmountRemaining; // Calculate the maximum fill results for the maker and taker assets. At least one of the orders will be fully filled. // // The maximum that the left maker can possibly buy is the amount that the right order can sell. // The maximum that the right maker can possibly buy is the amount that the left order can sell. // // If the left order is fully filled, profit will be paid out in the left maker asset. If the right order is fully filled, // the profit will be out in the right maker asset. // // There are three cases to consider: // Case 1. // If the left maker can buy more than the right maker can sell, then only the right order is fully filled. // Case 2. // If the right maker can buy more than the left maker can sell, then only the right order is fully filled. // Case 3. // If the right maker can sell the max of what the left maker can buy and the left maker can sell the max of // what the right maker can buy, then both orders are fully filled. if (leftTakerAssetAmountRemaining > rightMakerAssetAmountRemaining) { // Case 1: Right order is fully filled with the profit paid in the left makerAsset matchedFillResults = _calculateCompleteRightFill( leftOrder, rightMakerAssetAmountRemaining, rightTakerAssetAmountRemaining ); } else if (rightTakerAssetAmountRemaining > leftMakerAssetAmountRemaining) { // Case 2: Left order is fully filled with the profit paid in the right makerAsset. matchedFillResults.left.makerAssetFilledAmount = leftMakerAssetAmountRemaining; matchedFillResults.left.takerAssetFilledAmount = leftTakerAssetAmountRemaining; // Round down to ensure the right maker's exchange rate does not exceed the price specified by the order. // We favor the right maker when the exchange rate must be rounded and the profit is being paid in the // right maker asset. matchedFillResults.right.makerAssetFilledAmount = LibMath.safeGetPartialAmountFloor( rightOrder.makerAssetAmount, rightOrder.takerAssetAmount, leftMakerAssetAmountRemaining ); matchedFillResults.right.takerAssetFilledAmount = leftMakerAssetAmountRemaining; } else { // Case 3: The right and left orders are fully filled matchedFillResults = _calculateCompleteFillBoth( leftMakerAssetAmountRemaining, leftTakerAssetAmountRemaining, rightMakerAssetAmountRemaining, rightTakerAssetAmountRemaining ); } // Calculate amount given to taker in the left order's maker asset if the left spread will be part of the profit. if (doesLeftMakerAssetProfitExist) { matchedFillResults.profitInLeftMakerAsset = matchedFillResults.left.makerAssetFilledAmount.safeSub( matchedFillResults.right.takerAssetFilledAmount ); } // Calculate amount given to taker in the right order's maker asset if the right spread will be part of the profit. if (doesRightMakerAssetProfitExist) { matchedFillResults.profitInRightMakerAsset = matchedFillResults.right.makerAssetFilledAmount.safeSub( matchedFillResults.left.takerAssetFilledAmount ); } return matchedFillResults; } /// @dev Calculates the fill results for the maker and taker in the order matching and writes the results /// to the fillResults that are being collected on the order. Both orders will be fully filled in this /// case. /// @param leftMakerAssetAmountRemaining The amount of the left maker asset that is remaining to be filled. /// @param leftTakerAssetAmountRemaining The amount of the left taker asset that is remaining to be filled. /// @param rightMakerAssetAmountRemaining The amount of the right maker asset that is remaining to be filled. /// @param rightTakerAssetAmountRemaining The amount of the right taker asset that is remaining to be filled. /// @return MatchFillResults struct that does not include fees paid or spreads taken. function _calculateCompleteFillBoth( uint256 leftMakerAssetAmountRemaining, uint256 leftTakerAssetAmountRemaining, uint256 rightMakerAssetAmountRemaining, uint256 rightTakerAssetAmountRemaining ) private pure returns (MatchedFillResults memory matchedFillResults) { // Calculate the fully filled results for both orders. matchedFillResults.left.makerAssetFilledAmount = leftMakerAssetAmountRemaining; matchedFillResults.left.takerAssetFilledAmount = leftTakerAssetAmountRemaining; matchedFillResults.right.makerAssetFilledAmount = rightMakerAssetAmountRemaining; matchedFillResults.right.takerAssetFilledAmount = rightTakerAssetAmountRemaining; return matchedFillResults; } /// @dev Calculates the fill results for the maker and taker in the order matching and writes the results /// to the fillResults that are being collected on the order. /// @param leftOrder The left order that is being maximally filled. All of the information about fill amounts /// can be derived from this order and the right asset remaining fields. /// @param rightMakerAssetAmountRemaining The amount of the right maker asset that is remaining to be filled. /// @param rightTakerAssetAmountRemaining The amount of the right taker asset that is remaining to be filled. /// @return MatchFillResults struct that does not include fees paid or spreads taken. function _calculateCompleteRightFill( LibOrder.Order memory leftOrder, uint256 rightMakerAssetAmountRemaining, uint256 rightTakerAssetAmountRemaining ) private pure returns (MatchedFillResults memory matchedFillResults) { matchedFillResults.right.makerAssetFilledAmount = rightMakerAssetAmountRemaining; matchedFillResults.right.takerAssetFilledAmount = rightTakerAssetAmountRemaining; matchedFillResults.left.takerAssetFilledAmount = rightMakerAssetAmountRemaining; // Round down to ensure the left maker's exchange rate does not exceed the price specified by the order. // We favor the left maker when the exchange rate must be rounded and the profit is being paid in the // left maker asset. matchedFillResults.left.makerAssetFilledAmount = LibMath.safeGetPartialAmountFloor( leftOrder.makerAssetAmount, leftOrder.takerAssetAmount, rightMakerAssetAmountRemaining ); return matchedFillResults; } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; contract IProtocolFees { // Logs updates to the protocol fee multiplier. event ProtocolFeeMultiplier(uint256 oldProtocolFeeMultiplier, uint256 updatedProtocolFeeMultiplier); // Logs updates to the protocolFeeCollector address. event ProtocolFeeCollectorAddress(address oldProtocolFeeCollector, address updatedProtocolFeeCollector); /// @dev Allows the owner to update the protocol fee multiplier. /// @param updatedProtocolFeeMultiplier The updated protocol fee multiplier. function setProtocolFeeMultiplier(uint256 updatedProtocolFeeMultiplier) external; /// @dev Allows the owner to update the protocolFeeCollector address. /// @param updatedProtocolFeeCollector The updated protocolFeeCollector contract address. function setProtocolFeeCollectorAddress(address updatedProtocolFeeCollector) external; /// @dev Returns the protocolFeeMultiplier function protocolFeeMultiplier() external view returns (uint256); /// @dev Returns the protocolFeeCollector address function protocolFeeCollector() external view returns (address); }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol"; contract IMatchOrders { /// @dev Match complementary orders that have a profitable spread. /// Each order is filled at their respective price point, and /// the matcher receives a profit denominated in the left maker asset. /// @param leftOrders Set of orders with the same maker / taker asset. /// @param rightOrders Set of orders to match against `leftOrders` /// @param leftSignatures Proof that left orders were created by the left makers. /// @param rightSignatures Proof that right orders were created by the right makers. /// @return batchMatchedFillResults Amounts filled and profit generated. function batchMatchOrders( LibOrder.Order[] memory leftOrders, LibOrder.Order[] memory rightOrders, bytes[] memory leftSignatures, bytes[] memory rightSignatures ) public payable returns (LibFillResults.BatchMatchedFillResults memory batchMatchedFillResults); /// @dev Match complementary orders that have a profitable spread. /// Each order is maximally filled at their respective price point, and /// the matcher receives a profit denominated in either the left maker asset, /// right maker asset, or a combination of both. /// @param leftOrders Set of orders with the same maker / taker asset. /// @param rightOrders Set of orders to match against `leftOrders` /// @param leftSignatures Proof that left orders were created by the left makers. /// @param rightSignatures Proof that right orders were created by the right makers. /// @return batchMatchedFillResults Amounts filled and profit generated. function batchMatchOrdersWithMaximalFill( LibOrder.Order[] memory leftOrders, LibOrder.Order[] memory rightOrders, bytes[] memory leftSignatures, bytes[] memory rightSignatures ) public payable returns (LibFillResults.BatchMatchedFillResults memory batchMatchedFillResults); /// @dev Match two complementary orders that have a profitable spread. /// Each order is filled at their respective price point. However, the calculations are /// carried out as though the orders are both being filled at the right order's price point. /// The profit made by the left order goes to the taker (who matched the two orders). /// @param leftOrder First order to match. /// @param rightOrder Second order to match. /// @param leftSignature Proof that order was created by the left maker. /// @param rightSignature Proof that order was created by the right maker. /// @return matchedFillResults Amounts filled and fees paid by maker and taker of matched orders. function matchOrders( LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder, bytes memory leftSignature, bytes memory rightSignature ) public payable returns (LibFillResults.MatchedFillResults memory matchedFillResults); /// @dev Match two complementary orders that have a profitable spread. /// Each order is maximally filled at their respective price point, and /// the matcher receives a profit denominated in either the left maker asset, /// right maker asset, or a combination of both. /// @param leftOrder First order to match. /// @param rightOrder Second order to match. /// @param leftSignature Proof that order was created by the left maker. /// @param rightSignature Proof that order was created by the right maker. /// @return matchedFillResults Amounts filled by maker and taker of matched orders. function matchOrdersWithMaximalFill( LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder, bytes memory leftSignature, bytes memory rightSignature ) public payable returns (LibFillResults.MatchedFillResults memory matchedFillResults); }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol"; contract ISignatureValidator { // Allowed signature types. enum SignatureType { Illegal, // 0x00, default value Invalid, // 0x01 EIP712, // 0x02 EthSign, // 0x03 Wallet, // 0x04 Validator, // 0x05 PreSigned, // 0x06 EIP1271Wallet, // 0x07 NSignatureTypes // 0x08, number of signature types. Always leave at end. } event SignatureValidatorApproval( address indexed signerAddress, // Address that approves or disapproves a contract to verify signatures. address indexed validatorAddress, // Address of signature validator contract. bool isApproved // Approval or disapproval of validator contract. ); /// @dev Approves a hash on-chain. /// After presigning a hash, the preSign signature type will become valid for that hash and signer. /// @param hash Any 32-byte hash. function preSign(bytes32 hash) external payable; /// @dev Approves/unnapproves a Validator contract to verify signatures on signer's behalf. /// @param validatorAddress Address of Validator contract. /// @param approval Approval or disapproval of Validator contract. function setSignatureValidatorApproval( address validatorAddress, bool approval ) external payable; /// @dev Verifies that a hash has been signed by the given signer. /// @param hash Any 32-byte hash. /// @param signature Proof that the hash has been signed by signer. /// @return isValid `true` if the signature is valid for the given hash and signer. function isValidHashSignature( bytes32 hash, address signerAddress, bytes memory signature ) public view returns (bool isValid); /// @dev Verifies that a signature for an order is valid. /// @param order The order. /// @param signature Proof that the order has been signed by signer. /// @return isValid true if the signature is valid for the given order and signer. function isValidOrderSignature( LibOrder.Order memory order, bytes memory signature ) public view returns (bool isValid); /// @dev Verifies that a signature for a transaction is valid. /// @param transaction The transaction. /// @param signature Proof that the order has been signed by signer. /// @return isValid true if the signature is valid for the given transaction and signer. function isValidTransactionSignature( LibZeroExTransaction.ZeroExTransaction memory transaction, bytes memory signature ) public view returns (bool isValid); /// @dev Verifies that an order, with provided order hash, has been signed /// by the given signer. /// @param order The order. /// @param orderHash The hash of the order. /// @param signature Proof that the hash has been signed by signer. /// @return isValid True if the signature is valid for the given order and signer. function _isValidOrderWithHashSignature( LibOrder.Order memory order, bytes32 orderHash, bytes memory signature ) internal view returns (bool isValid); /// @dev Verifies that a transaction, with provided order hash, has been signed /// by the given signer. /// @param transaction The transaction. /// @param transactionHash The hash of the transaction. /// @param signature Proof that the hash has been signed by signer. /// @return isValid True if the signature is valid for the given transaction and signer. function _isValidTransactionWithHashSignature( LibZeroExTransaction.ZeroExTransaction memory transaction, bytes32 transactionHash, bytes memory signature ) internal view returns (bool isValid); }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; import "@0x/contracts-utils/contracts/src/LibEIP712.sol"; library LibZeroExTransaction { using LibZeroExTransaction for ZeroExTransaction; // Hash for the EIP712 0x transaction schema // keccak256(abi.encodePacked( // "ZeroExTransaction(", // "uint256 salt,", // "uint256 expirationTimeSeconds,", // "uint256 gasPrice,", // "address signerAddress,", // "bytes data", // ")" // )); bytes32 constant internal _EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH = 0xec69816980a3a3ca4554410e60253953e9ff375ba4536a98adfa15cc71541508; struct ZeroExTransaction { uint256 salt; // Arbitrary number to ensure uniqueness of transaction hash. uint256 expirationTimeSeconds; // Timestamp in seconds at which transaction expires. uint256 gasPrice; // gasPrice that transaction is required to be executed with. address signerAddress; // Address of transaction signer. bytes data; // AbiV2 encoded calldata. } /// @dev Calculates the EIP712 typed data hash of a transaction with a given domain separator. /// @param transaction 0x transaction structure. /// @return EIP712 typed data hash of the transaction. function getTypedDataHash(ZeroExTransaction memory transaction, bytes32 eip712ExchangeDomainHash) internal pure returns (bytes32 transactionHash) { // Hash the transaction with the domain separator of the Exchange contract. transactionHash = LibEIP712.hashEIP712Message( eip712ExchangeDomainHash, transaction.getStructHash() ); return transactionHash; } /// @dev Calculates EIP712 hash of the 0x transaction struct. /// @param transaction 0x transaction structure. /// @return EIP712 hash of the transaction struct. function getStructHash(ZeroExTransaction memory transaction) internal pure returns (bytes32 result) { bytes32 schemaHash = _EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH; bytes memory data = transaction.data; uint256 salt = transaction.salt; uint256 expirationTimeSeconds = transaction.expirationTimeSeconds; uint256 gasPrice = transaction.gasPrice; address signerAddress = transaction.signerAddress; // Assembly for more efficiently computing: // result = keccak256(abi.encodePacked( // schemaHash, // salt, // expirationTimeSeconds, // gasPrice, // uint256(signerAddress), // keccak256(data) // )); assembly { // Compute hash of data let dataHash := keccak256(add(data, 32), mload(data)) // Load free memory pointer let memPtr := mload(64) mstore(memPtr, schemaHash) // hash of schema mstore(add(memPtr, 32), salt) // salt mstore(add(memPtr, 64), expirationTimeSeconds) // expirationTimeSeconds mstore(add(memPtr, 96), gasPrice) // gasPrice mstore(add(memPtr, 128), and(signerAddress, 0xffffffffffffffffffffffffffffffffffffffff)) // signerAddress mstore(add(memPtr, 160), dataHash) // hash of data // Compute hash result := keccak256(memPtr, 192) } return result; } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol"; contract ITransactions { // TransactionExecution event is emitted when a ZeroExTransaction is executed. event TransactionExecution(bytes32 indexed transactionHash); /// @dev Executes an Exchange method call in the context of signer. /// @param transaction 0x transaction containing salt, signerAddress, and data. /// @param signature Proof that transaction has been signed by signer. /// @return ABI encoded return data of the underlying Exchange function call. function executeTransaction( LibZeroExTransaction.ZeroExTransaction memory transaction, bytes memory signature ) public payable returns (bytes memory); /// @dev Executes a batch of Exchange method calls in the context of signer(s). /// @param transactions Array of 0x transactions containing salt, signerAddress, and data. /// @param signatures Array of proofs that transactions have been signed by signer(s). /// @return Array containing ABI encoded return data for each of the underlying Exchange function calls. function batchExecuteTransactions( LibZeroExTransaction.ZeroExTransaction[] memory transactions, bytes[] memory signatures ) public payable returns (bytes[] memory); /// @dev The current function will be called in the context of this address (either 0x transaction signer or `msg.sender`). /// If calling a fill function, this address will represent the taker. /// If calling a cancel function, this address will represent the maker. /// @return Signer of 0x transaction if entry point is `executeTransaction`. /// `msg.sender` if entry point is any other function. function _getCurrentContextAddress() internal view returns (address); }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; contract IAssetProxyDispatcher { // Logs registration of new asset proxy event AssetProxyRegistered( bytes4 id, // Id of new registered AssetProxy. address assetProxy // Address of new registered AssetProxy. ); /// @dev Registers an asset proxy to its asset proxy id. /// Once an asset proxy is registered, it cannot be unregistered. /// @param assetProxy Address of new asset proxy to register. function registerAssetProxy(address assetProxy) external; /// @dev Gets an asset proxy. /// @param assetProxyId Id of the asset proxy. /// @return The asset proxy registered to assetProxyId. Returns 0x0 if no proxy is registered. function getAssetProxy(bytes4 assetProxyId) external view returns (address); }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol"; contract IWrapperFunctions { /// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled. /// @param order Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. function fillOrKillOrder( LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) public payable returns (LibFillResults.FillResults memory fillResults); /// @dev Executes multiple calls of fillOrder. /// @param orders Array of order specifications. /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders. /// @param signatures Proofs that orders have been created by makers. /// @return Array of amounts filled and fees paid by makers and taker. function batchFillOrders( LibOrder.Order[] memory orders, uint256[] memory takerAssetFillAmounts, bytes[] memory signatures ) public payable returns (LibFillResults.FillResults[] memory fillResults); /// @dev Executes multiple calls of fillOrKillOrder. /// @param orders Array of order specifications. /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders. /// @param signatures Proofs that orders have been created by makers. /// @return Array of amounts filled and fees paid by makers and taker. function batchFillOrKillOrders( LibOrder.Order[] memory orders, uint256[] memory takerAssetFillAmounts, bytes[] memory signatures ) public payable returns (LibFillResults.FillResults[] memory fillResults); /// @dev Executes multiple calls of fillOrder. If any fill reverts, the error is caught and ignored. /// @param orders Array of order specifications. /// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders. /// @param signatures Proofs that orders have been created by makers. /// @return Array of amounts filled and fees paid by makers and taker. function batchFillOrdersNoThrow( LibOrder.Order[] memory orders, uint256[] memory takerAssetFillAmounts, bytes[] memory signatures ) public payable returns (LibFillResults.FillResults[] memory fillResults); /// @dev Executes multiple calls of fillOrder until total amount of takerAsset is sold by taker. /// If any fill reverts, the error is caught and ignored. /// NOTE: This function does not enforce that the takerAsset is the same for each order. /// @param orders Array of order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signatures Proofs that orders have been signed by makers. /// @return Amounts filled and fees paid by makers and taker. function marketSellOrdersNoThrow( LibOrder.Order[] memory orders, uint256 takerAssetFillAmount, bytes[] memory signatures ) public payable returns (LibFillResults.FillResults memory fillResults); /// @dev Executes multiple calls of fillOrder until total amount of makerAsset is bought by taker. /// If any fill reverts, the error is caught and ignored. /// NOTE: This function does not enforce that the makerAsset is the same for each order. /// @param orders Array of order specifications. /// @param makerAssetFillAmount Desired amount of makerAsset to buy. /// @param signatures Proofs that orders have been signed by makers. /// @return Amounts filled and fees paid by makers and taker. function marketBuyOrdersNoThrow( LibOrder.Order[] memory orders, uint256 makerAssetFillAmount, bytes[] memory signatures ) public payable returns (LibFillResults.FillResults memory fillResults); /// @dev Calls marketSellOrdersNoThrow then reverts if < takerAssetFillAmount has been sold. /// NOTE: This function does not enforce that the takerAsset is the same for each order. /// @param orders Array of order specifications. /// @param takerAssetFillAmount Minimum amount of takerAsset to sell. /// @param signatures Proofs that orders have been signed by makers. /// @return Amounts filled and fees paid by makers and taker. function marketSellOrdersFillOrKill( LibOrder.Order[] memory orders, uint256 takerAssetFillAmount, bytes[] memory signatures ) public payable returns (LibFillResults.FillResults memory fillResults); /// @dev Calls marketBuyOrdersNoThrow then reverts if < makerAssetFillAmount has been bought. /// NOTE: This function does not enforce that the makerAsset is the same for each order. /// @param orders Array of order specifications. /// @param makerAssetFillAmount Minimum amount of makerAsset to buy. /// @param signatures Proofs that orders have been signed by makers. /// @return Amounts filled and fees paid by makers and taker. function marketBuyOrdersFillOrKill( LibOrder.Order[] memory orders, uint256 makerAssetFillAmount, bytes[] memory signatures ) public payable returns (LibFillResults.FillResults memory fillResults); /// @dev Executes multiple calls of cancelOrder. /// @param orders Array of order specifications. function batchCancelOrders(LibOrder.Order[] memory orders) public payable; }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; contract ITransferSimulator { /// @dev This function may be used to simulate any amount of transfers /// As they would occur through the Exchange contract. Note that this function /// will always revert, even if all transfers are successful. However, it may /// be used with eth_call or with a try/catch pattern in order to simulate /// the results of the transfers. /// @param assetData Array of asset details, each encoded per the AssetProxy contract specification. /// @param fromAddresses Array containing the `from` addresses that correspond with each transfer. /// @param toAddresses Array containing the `to` addresses that correspond with each transfer. /// @param amounts Array containing the amounts that correspond to each transfer. /// @return This function does not return a value. However, it will always revert with /// `Error("TRANSFERS_SUCCESSFUL")` if all of the transfers were successful. function simulateDispatchTransferFromCalls( bytes[] memory assetData, address[] memory fromAddresses, address[] memory toAddresses, uint256[] memory amounts ) public; }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; library LibWethUtilsRichErrors { // bytes4(keccak256("UnregisteredAssetProxyError()")) bytes4 internal constant UNREGISTERED_ASSET_PROXY_ERROR_SELECTOR = 0xf3b96b8d; // bytes4(keccak256("InsufficientEthForFeeError(uint256,uint256)")) bytes4 internal constant INSUFFICIENT_ETH_FOR_FEE_ERROR_SELECTOR = 0xecf40fd9; // bytes4(keccak256("DefaultFunctionWethContractOnlyError(address)")) bytes4 internal constant DEFAULT_FUNCTION_WETH_CONTRACT_ONLY_ERROR_SELECTOR = 0x08b18698; // bytes4(keccak256("EthFeeLengthMismatchError(uint256,uint256)")) bytes4 internal constant ETH_FEE_LENGTH_MISMATCH_ERROR_SELECTOR = 0x3ecb6ceb; // solhint-disable func-name-mixedcase function UnregisteredAssetProxyError() internal pure returns (bytes memory) { return abi.encodeWithSelector(UNREGISTERED_ASSET_PROXY_ERROR_SELECTOR); } function InsufficientEthForFeeError( uint256 ethFeeRequired, uint256 ethAvailable ) internal pure returns (bytes memory) { return abi.encodeWithSelector( INSUFFICIENT_ETH_FOR_FEE_ERROR_SELECTOR, ethFeeRequired, ethAvailable ); } function DefaultFunctionWethContractOnlyError( address senderAddress ) internal pure returns (bytes memory) { return abi.encodeWithSelector( DEFAULT_FUNCTION_WETH_CONTRACT_ONLY_ERROR_SELECTOR, senderAddress ); } function EthFeeLengthMismatchError( uint256 ethFeesLength, uint256 feeRecipientsLength ) internal pure returns (bytes memory) { return abi.encodeWithSelector( ETH_FEE_LENGTH_MISMATCH_ERROR_SELECTOR, ethFeesLength, feeRecipientsLength ); } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; import "./interfaces/IOwnable.sol"; import "./LibOwnableRichErrors.sol"; import "./LibRichErrors.sol"; contract Ownable is IOwnable { /// @dev The owner of this contract. /// @return 0 The owner address. address public owner; constructor () public { owner = msg.sender; } modifier onlyOwner() { _assertSenderIsOwner(); _; } /// @dev Change the owner of this contract. /// @param newOwner New owner address. function transferOwnership(address newOwner) public onlyOwner { if (newOwner == address(0)) { LibRichErrors.rrevert(LibOwnableRichErrors.TransferOwnerToZeroError()); } else { owner = newOwner; emit OwnershipTransferred(msg.sender, newOwner); } } function _assertSenderIsOwner() internal view { if (msg.sender != owner) { LibRichErrors.rrevert(LibOwnableRichErrors.OnlyOwnerError( msg.sender, owner )); } } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; contract IOwnable { /// @dev Emitted by Ownable when ownership is transferred. /// @param previousOwner The previous owner of the contract. /// @param newOwner The new owner of the contract. event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /// @dev Transfers ownership of the contract to a new address. /// @param newOwner The address that will become the owner. function transferOwnership(address newOwner) public; }
pragma solidity ^0.5.9; library LibOwnableRichErrors { // bytes4(keccak256("OnlyOwnerError(address,address)")) bytes4 internal constant ONLY_OWNER_ERROR_SELECTOR = 0x1de45ad1; // bytes4(keccak256("TransferOwnerToZeroError()")) bytes internal constant TRANSFER_OWNER_TO_ZERO_ERROR_BYTES = hex"e69edc3e"; // solhint-disable func-name-mixedcase function OnlyOwnerError( address sender, address owner ) internal pure returns (bytes memory) { return abi.encodeWithSelector( ONLY_OWNER_ERROR_SELECTOR, sender, owner ); } function TransferOwnerToZeroError() internal pure returns (bytes memory) { return TRANSFER_OWNER_TO_ZERO_ERROR_BYTES; } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; library LibForwarderRichErrors { // bytes4(keccak256("UnregisteredAssetProxyError()")) bytes4 internal constant UNREGISTERED_ASSET_PROXY_ERROR_SELECTOR = 0xf3b96b8d; // bytes4(keccak256("CompleteBuyFailedError(uint256,uint256)")) bytes4 internal constant COMPLETE_BUY_FAILED_ERROR_SELECTOR = 0x91353a0c; // bytes4(keccak256("UnsupportedFeeError(bytes)")) bytes4 internal constant UNSUPPORTED_FEE_ERROR_SELECTOR = 0x31360af1; // bytes4(keccak256("OverspentWethError(uint256,uint256)")) bytes4 internal constant OVERSPENT_WETH_ERROR_SELECTOR = 0xcdcbed5d; // solhint-disable func-name-mixedcase function UnregisteredAssetProxyError() internal pure returns (bytes memory) { return abi.encodeWithSelector(UNREGISTERED_ASSET_PROXY_ERROR_SELECTOR); } function CompleteBuyFailedError( uint256 expectedAssetBuyAmount, uint256 actualAssetBuyAmount ) internal pure returns (bytes memory) { return abi.encodeWithSelector( COMPLETE_BUY_FAILED_ERROR_SELECTOR, expectedAssetBuyAmount, actualAssetBuyAmount ); } function UnsupportedFeeError( bytes memory takerFeeAssetData ) internal pure returns (bytes memory) { return abi.encodeWithSelector( UNSUPPORTED_FEE_ERROR_SELECTOR, takerFeeAssetData ); } function OverspentWethError( uint256 wethSpent, uint256 msgValue ) internal pure returns (bytes memory) { return abi.encodeWithSelector( OVERSPENT_WETH_ERROR_SELECTOR, wethSpent, msgValue ); } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; import "@0x/contracts-asset-proxy/contracts/src/interfaces/IAssetData.sol"; import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol"; import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol"; import "@0x/contracts-extensions/contracts/src/LibAssetDataTransfer.sol"; import "@0x/contracts-utils/contracts/src/LibBytes.sol"; import "@0x/contracts-utils/contracts/src/LibRichErrors.sol"; import "@0x/contracts-utils/contracts/src/LibSafeMath.sol"; import "./libs/LibForwarderRichErrors.sol"; import "./interfaces/IExchangeV2.sol"; contract MixinExchangeWrapper { // The v2 order id is the first 4 bytes of the ExchangeV2 order schema hash. // bytes4(keccak256(abi.encodePacked( // "Order(", // "address makerAddress,", // "address takerAddress,", // "address feeRecipientAddress,", // "address senderAddress,", // "uint256 makerAssetAmount,", // "uint256 takerAssetAmount,", // "uint256 makerFee,", // "uint256 takerFee,", // "uint256 expirationTimeSeconds,", // "uint256 salt,", // "bytes makerAssetData,", // "bytes takerAssetData", // ")" // ))); bytes4 constant public EXCHANGE_V2_ORDER_ID = 0x770501f8; // solhint-disable var-name-mixedcase IExchange internal EXCHANGE; IExchangeV2 internal EXCHANGE_V2; // solhint-enable var-name-mixedcase using LibBytes for bytes; using LibAssetDataTransfer for bytes; using LibSafeMath for uint256; constructor ( address _exchange, address _exchangeV2 ) public { EXCHANGE = IExchange(_exchange); EXCHANGE_V2 = IExchangeV2(_exchangeV2); } /// @dev Fills the input order. /// Returns false if the transaction would otherwise revert. /// @param order Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. /// @return Amounts filled and fees paid by maker and taker. function _fillOrderNoThrow( LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) internal returns (LibFillResults.FillResults memory fillResults) { if (_isV2Order(order)) { return _fillV2OrderNoThrow( order, takerAssetFillAmount, signature ); } return _fillV3OrderNoThrow( order, takerAssetFillAmount, signature ); } /// @dev Executes a single call of fillOrder according to the wethSellAmount and /// the amount already sold. /// @param order A single order specification. /// @param signature Signature for the given order. /// @param remainingTakerAssetFillAmount Remaining amount of WETH to sell. /// @return wethSpentAmount Amount of WETH spent on the given order. /// @return makerAssetAcquiredAmount Amount of maker asset acquired from the given order. function _marketSellSingleOrder( LibOrder.Order memory order, bytes memory signature, uint256 remainingTakerAssetFillAmount ) internal returns ( uint256 wethSpentAmount, uint256 makerAssetAcquiredAmount ) { // No taker fee or percentage fee if ( order.takerFee == 0 || _areUnderlyingAssetsEqual(order.takerFeeAssetData, order.makerAssetData) ) { // Attempt to sell the remaining amount of WETH LibFillResults.FillResults memory singleFillResults = _fillOrderNoThrow( order, remainingTakerAssetFillAmount, signature ); wethSpentAmount = singleFillResults.takerAssetFilledAmount .safeAdd(singleFillResults.protocolFeePaid); // Subtract fee from makerAssetFilledAmount for the net amount acquired. makerAssetAcquiredAmount = singleFillResults.makerAssetFilledAmount .safeSub(singleFillResults.takerFeePaid); // WETH fee } else if (_areUnderlyingAssetsEqual(order.takerFeeAssetData, order.takerAssetData)) { // We will first sell WETH as the takerAsset, then use it to pay the takerFee. // This ensures that we reserve enough to pay the taker and protocol fees. uint256 takerAssetFillAmount = LibMath.getPartialAmountCeil( order.takerAssetAmount, order.takerAssetAmount.safeAdd(order.takerFee), remainingTakerAssetFillAmount ); LibFillResults.FillResults memory singleFillResults = _fillOrderNoThrow( order, takerAssetFillAmount, signature ); // WETH is also spent on the taker fee, so we add it here. wethSpentAmount = singleFillResults.takerAssetFilledAmount .safeAdd(singleFillResults.takerFeePaid) .safeAdd(singleFillResults.protocolFeePaid); makerAssetAcquiredAmount = singleFillResults.makerAssetFilledAmount; // Unsupported fee } else { LibRichErrors.rrevert(LibForwarderRichErrors.UnsupportedFeeError(order.takerFeeAssetData)); } return (wethSpentAmount, makerAssetAcquiredAmount); } /// @dev Synchronously executes multiple calls of fillOrder until total amount of WETH has been sold by taker. /// @param orders Array of order specifications. /// @param wethSellAmount Desired amount of WETH to sell. /// @param signatures Proofs that orders have been signed by makers. /// @return totalWethSpentAmount Total amount of WETH spent on the given orders. /// @return totalMakerAssetAcquiredAmount Total amount of maker asset acquired from the given orders. function _marketSellNoThrow( LibOrder.Order[] memory orders, uint256 wethSellAmount, bytes[] memory signatures ) internal returns ( uint256 totalWethSpentAmount, uint256 totalMakerAssetAcquiredAmount ) { uint256 protocolFee = tx.gasprice.safeMul(EXCHANGE.protocolFeeMultiplier()); bytes4 erc20BridgeProxyId = IAssetData(address(0)).ERC20Bridge.selector; for (uint256 i = 0; i != orders.length; i++) { // Preemptively skip to avoid division by zero in _marketSellSingleOrder if (orders[i].makerAssetAmount == 0 || orders[i].takerAssetAmount == 0) { continue; } // The remaining amount of WETH to sell uint256 remainingTakerAssetFillAmount = wethSellAmount .safeSub(totalWethSpentAmount) .safeSub(_isV2Order(orders[i]) ? 0 : protocolFee); // If the maker asset is ERC20Bridge, take a snapshot of the Forwarder contract's balance. bytes4 makerAssetProxyId = orders[i].makerAssetData.readBytes4(0); address tokenAddress; uint256 balanceBefore; if (makerAssetProxyId == erc20BridgeProxyId) { tokenAddress = orders[i].makerAssetData.readAddress(16); balanceBefore = IERC20Token(tokenAddress).balanceOf(address(this)); } ( uint256 wethSpentAmount, uint256 makerAssetAcquiredAmount ) = _marketSellSingleOrder( orders[i], signatures[i], remainingTakerAssetFillAmount ); // Account for the ERC20Bridge transfering more of the maker asset than expected. if (makerAssetProxyId == erc20BridgeProxyId) { uint256 balanceAfter = IERC20Token(tokenAddress).balanceOf(address(this)); makerAssetAcquiredAmount = LibSafeMath.max256( balanceAfter.safeSub(balanceBefore), makerAssetAcquiredAmount ); } orders[i].makerAssetData.transferOut(makerAssetAcquiredAmount); totalWethSpentAmount = totalWethSpentAmount .safeAdd(wethSpentAmount); totalMakerAssetAcquiredAmount = totalMakerAssetAcquiredAmount .safeAdd(makerAssetAcquiredAmount); // Stop execution if the entire amount of WETH has been sold if (totalWethSpentAmount >= wethSellAmount) { break; } } } /// @dev Executes a single call of fillOrder according to the makerAssetBuyAmount and /// the amount already bought. /// @param order A single order specification. /// @param signature Signature for the given order. /// @param remainingMakerAssetFillAmount Remaining amount of maker asset to buy. /// @return wethSpentAmount Amount of WETH spent on the given order. /// @return makerAssetAcquiredAmount Amount of maker asset acquired from the given order. function _marketBuySingleOrder( LibOrder.Order memory order, bytes memory signature, uint256 remainingMakerAssetFillAmount ) internal returns ( uint256 wethSpentAmount, uint256 makerAssetAcquiredAmount ) { // No taker fee or WETH fee if ( order.takerFee == 0 || _areUnderlyingAssetsEqual(order.takerFeeAssetData, order.takerAssetData) ) { // Calculate the remaining amount of takerAsset to sell uint256 remainingTakerAssetFillAmount = LibMath.getPartialAmountCeil( order.takerAssetAmount, order.makerAssetAmount, remainingMakerAssetFillAmount ); // Attempt to sell the remaining amount of takerAsset LibFillResults.FillResults memory singleFillResults = _fillOrderNoThrow( order, remainingTakerAssetFillAmount, signature ); // WETH is also spent on the protocol and taker fees, so we add it here. wethSpentAmount = singleFillResults.takerAssetFilledAmount .safeAdd(singleFillResults.takerFeePaid) .safeAdd(singleFillResults.protocolFeePaid); makerAssetAcquiredAmount = singleFillResults.makerAssetFilledAmount; // Percentage fee } else if (_areUnderlyingAssetsEqual(order.takerFeeAssetData, order.makerAssetData)) { // Calculate the remaining amount of takerAsset to sell uint256 remainingTakerAssetFillAmount = LibMath.getPartialAmountCeil( order.takerAssetAmount, order.makerAssetAmount.safeSub(order.takerFee), remainingMakerAssetFillAmount ); // Attempt to sell the remaining amount of takerAsset LibFillResults.FillResults memory singleFillResults = _fillOrderNoThrow( order, remainingTakerAssetFillAmount, signature ); wethSpentAmount = singleFillResults.takerAssetFilledAmount .safeAdd(singleFillResults.protocolFeePaid); // Subtract fee from makerAssetFilledAmount for the net amount acquired. makerAssetAcquiredAmount = singleFillResults.makerAssetFilledAmount .safeSub(singleFillResults.takerFeePaid); // Unsupported fee } else { LibRichErrors.rrevert(LibForwarderRichErrors.UnsupportedFeeError(order.takerFeeAssetData)); } return (wethSpentAmount, makerAssetAcquiredAmount); } /// @dev Synchronously executes multiple fill orders in a single transaction until total amount is acquired. /// Note that the Forwarder may fill more than the makerAssetBuyAmount so that, after percentage fees /// are paid, the net amount acquired after fees is equal to makerAssetBuyAmount (modulo rounding). /// The asset being sold by taker must always be WETH. /// @param orders Array of order specifications. /// @param makerAssetBuyAmount Desired amount of makerAsset to fill. /// @param signatures Proofs that orders have been signed by makers. /// @return totalWethSpentAmount Total amount of WETH spent on the given orders. /// @return totalMakerAssetAcquiredAmount Total amount of maker asset acquired from the given orders. function _marketBuyFillOrKill( LibOrder.Order[] memory orders, uint256 makerAssetBuyAmount, bytes[] memory signatures ) internal returns ( uint256 totalWethSpentAmount, uint256 totalMakerAssetAcquiredAmount ) { bytes4 erc20BridgeProxyId = IAssetData(address(0)).ERC20Bridge.selector; uint256 ordersLength = orders.length; for (uint256 i = 0; i != ordersLength; i++) { // Preemptively skip to avoid division by zero in _marketBuySingleOrder if (orders[i].makerAssetAmount == 0 || orders[i].takerAssetAmount == 0) { continue; } uint256 remainingMakerAssetFillAmount = makerAssetBuyAmount .safeSub(totalMakerAssetAcquiredAmount); // If the maker asset is ERC20Bridge, take a snapshot of the Forwarder contract's balance. bytes4 makerAssetProxyId = orders[i].makerAssetData.readBytes4(0); address tokenAddress; uint256 balanceBefore; if (makerAssetProxyId == erc20BridgeProxyId) { tokenAddress = orders[i].makerAssetData.readAddress(16); balanceBefore = IERC20Token(tokenAddress).balanceOf(address(this)); } ( uint256 wethSpentAmount, uint256 makerAssetAcquiredAmount ) = _marketBuySingleOrder( orders[i], signatures[i], remainingMakerAssetFillAmount ); // Account for the ERC20Bridge transfering more of the maker asset than expected. if (makerAssetProxyId == erc20BridgeProxyId) { uint256 balanceAfter = IERC20Token(tokenAddress).balanceOf(address(this)); makerAssetAcquiredAmount = LibSafeMath.max256( balanceAfter.safeSub(balanceBefore), makerAssetAcquiredAmount ); } orders[i].makerAssetData.transferOut(makerAssetAcquiredAmount); totalWethSpentAmount = totalWethSpentAmount .safeAdd(wethSpentAmount); totalMakerAssetAcquiredAmount = totalMakerAssetAcquiredAmount .safeAdd(makerAssetAcquiredAmount); // Stop execution if the entire amount of makerAsset has been bought if (totalMakerAssetAcquiredAmount >= makerAssetBuyAmount) { break; } } if (totalMakerAssetAcquiredAmount < makerAssetBuyAmount) { LibRichErrors.rrevert(LibForwarderRichErrors.CompleteBuyFailedError( makerAssetBuyAmount, totalMakerAssetAcquiredAmount )); } } /// @dev Fills the input ExchangeV2 order. The `makerFeeAssetData` must be // equal to EXCHANGE_V2_ORDER_ID (0x770501f8). /// Returns false if the transaction would otherwise revert. /// @param order Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. /// @return Amounts filled and fees paid by maker and taker. function _fillV2OrderNoThrow( LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) internal returns (LibFillResults.FillResults memory fillResults) { // Strip v3 specific fields from order IExchangeV2.Order memory v2Order = IExchangeV2.Order({ makerAddress: order.makerAddress, takerAddress: order.takerAddress, feeRecipientAddress: order.feeRecipientAddress, senderAddress: order.senderAddress, makerAssetAmount: order.makerAssetAmount, takerAssetAmount: order.takerAssetAmount, // NOTE: We assume fees are 0 for all v2 orders. Orders with non-zero fees will fail to be filled. makerFee: 0, takerFee: 0, expirationTimeSeconds: order.expirationTimeSeconds, salt: order.salt, makerAssetData: order.makerAssetData, takerAssetData: order.takerAssetData }); // ABI encode calldata for `fillOrder` bytes memory fillOrderCalldata = abi.encodeWithSelector( IExchangeV2(address(0)).fillOrder.selector, v2Order, takerAssetFillAmount, signature ); address exchange = address(EXCHANGE_V2); (bool didSucceed, bytes memory returnData) = exchange.call(fillOrderCalldata); if (didSucceed) { assert(returnData.length == 128); // NOTE: makerFeePaid, takerFeePaid, and protocolFeePaid will always be 0 for v2 orders (fillResults.makerAssetFilledAmount, fillResults.takerAssetFilledAmount) = abi.decode(returnData, (uint256, uint256)); } // fillResults values will be 0 by default if call was unsuccessful return fillResults; } /// @dev Fills the input ExchangeV3 order. /// Returns false if the transaction would otherwise revert. /// @param order Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. /// @return Amounts filled and fees paid by maker and taker. function _fillV3OrderNoThrow( LibOrder.Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) internal returns (LibFillResults.FillResults memory fillResults) { // ABI encode calldata for `fillOrder` bytes memory fillOrderCalldata = abi.encodeWithSelector( IExchange(address(0)).fillOrder.selector, order, takerAssetFillAmount, signature ); address exchange = address(EXCHANGE); (bool didSucceed, bytes memory returnData) = exchange.call(fillOrderCalldata); if (didSucceed) { assert(returnData.length == 160); fillResults = abi.decode(returnData, (LibFillResults.FillResults)); } // fillResults values will be 0 by default if call was unsuccessful return fillResults; } /// @dev Checks whether one asset is effectively equal to another asset. /// This is the case if they have the same ERC20Proxy/ERC20BridgeProxy asset data, or if /// one is the ERC20Bridge equivalent of the other. /// @param assetData1 Byte array encoded for the takerFee asset proxy. /// @param assetData2 Byte array encoded for the maker asset proxy. /// @return areEqual Whether or not the underlying assets are equal. function _areUnderlyingAssetsEqual( bytes memory assetData1, bytes memory assetData2 ) internal pure returns (bool) { bytes4 assetProxyId1 = assetData1.readBytes4(0); bytes4 assetProxyId2 = assetData2.readBytes4(0); bytes4 erc20ProxyId = IAssetData(address(0)).ERC20Token.selector; bytes4 erc20BridgeProxyId = IAssetData(address(0)).ERC20Bridge.selector; if ( (assetProxyId1 == erc20ProxyId || assetProxyId1 == erc20BridgeProxyId) && (assetProxyId2 == erc20ProxyId || assetProxyId2 == erc20BridgeProxyId) ) { // Compare the underlying token addresses. address token1 = assetData1.readAddress(16); address token2 = assetData2.readAddress(16); return (token1 == token2); } else { return assetData1.equals(assetData2); } } /// @dev Checks whether an order is a v2 order. /// @param order Order struct containing order specifications. /// @return True if the order's `makerFeeAssetData` is set to the v2 order id. function _isV2Order(LibOrder.Order memory order) internal pure returns (bool) { return order.makerFeeAssetData.length > 3 && order.makerFeeAssetData.readBytes4(0) == EXCHANGE_V2_ORDER_ID; } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; contract IExchangeV2 { // solhint-disable max-line-length struct Order { address makerAddress; // Address that created the order. address takerAddress; // Address that is allowed to fill the order. If set to 0, any address is allowed to fill the order. address feeRecipientAddress; // Address that will recieve fees when order is filled. 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. uint256 makerAssetAmount; // Amount of makerAsset being offered by maker. Must be greater than 0. uint256 takerAssetAmount; // Amount of takerAsset being bid on by maker. Must be greater than 0. 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. 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. uint256 expirationTimeSeconds; // Timestamp in seconds at which order expires. uint256 salt; // Arbitrary number to facilitate uniqueness of the order's hash. 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. 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. } // solhint-enable max-line-length struct FillResults { uint256 makerAssetFilledAmount; // Total amount of makerAsset(s) filled. uint256 takerAssetFilledAmount; // Total amount of takerAsset(s) filled. uint256 makerFeePaid; // Total amount of ZRX paid by maker(s) to feeRecipient(s). uint256 takerFeePaid; // Total amount of ZRX paid by taker to feeRecipients(s). } struct OrderInfo { uint8 orderStatus; // Status that describes order's validity and fillability. bytes32 orderHash; // EIP712 typed data hash of the order (see LibOrder.getTypedDataHash). uint256 orderTakerAssetFilledAmount; // Amount of order that has already been filled. } /// @dev Fills the input order. /// @param order Order struct containing order specifications. /// @param takerAssetFillAmount Desired amount of takerAsset to sell. /// @param signature Proof that order has been created by maker. /// @return Amounts filled and fees paid by maker and taker. function fillOrder( Order memory order, uint256 takerAssetFillAmount, bytes memory signature ) public returns (FillResults memory fillResults); /// @dev Gets information about an order: status, hash, and amount filled. /// @param order Order to gather information on. /// @return OrderInfo Information about the order and its state. /// See LibOrder.OrderInfo for a complete description. function getOrderInfo(Order memory order) public returns (OrderInfo memory orderInfo); }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; contract MixinReceiver { bytes4 constant public ERC1155_RECEIVED = 0xf23a6e61; bytes4 constant public ERC1155_BATCH_RECEIVED = 0xbc197c81; /// @notice Handle the receipt of a single ERC1155 token type /// @dev The smart contract calls this function on the recipient /// after a `safeTransferFrom`. This function MAY throw to revert and reject the /// transfer. Return of other than the magic value MUST result in the ///transaction being reverted /// Note: the contract address is always the message sender /// @param operator The address which called `safeTransferFrom` function /// @param from The address which previously owned the token /// @param id An array containing the ids of the token being transferred /// @param value An array containing the amount of tokens being transferred /// @param data Additional data with no specified format /// @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4) { return ERC1155_RECEIVED; } /// @notice Handle the receipt of multiple ERC1155 token types /// @dev The smart contract calls this function on the recipient /// after a `safeTransferFrom`. This function MAY throw to revert and reject the /// transfer. Return of other than the magic value MUST result in the /// transaction being reverted /// Note: the contract address is always the message sender /// @param operator The address which called `safeTransferFrom` function /// @param from The address which previously owned the token /// @param ids An array containing ids of each token being transferred /// @param values An array containing amounts of each token being transferred /// @param data Additional data with no specified format /// @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4) { return ERC1155_BATCH_RECEIVED; } }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol"; contract IForwarder { /// @dev Withdraws assets from this contract. The contract requires a ZRX balance in order to /// function optimally, and this function allows the ZRX to be withdrawn by owner. It may also be /// used to withdraw assets that were accidentally sent to this contract. /// @param assetData Byte array encoded for the respective asset proxy. /// @param amount Amount of ERC20 token to withdraw. function withdrawAsset( bytes calldata assetData, uint256 amount ) external; /// @dev Approves the respective proxy for a given asset to transfer tokens on the Forwarder contract's behalf. /// This is necessary because an order fee denominated in the maker asset (i.e. a percentage fee) is sent by the /// Forwarder contract to the fee recipient. /// This method needs to be called before forwarding orders of a maker asset that hasn't /// previously been approved. /// @param assetData Byte array encoded for the respective asset proxy. function approveMakerAssetProxy( bytes calldata assetData ) external; /// @dev Purchases as much of orders' makerAssets as possible by selling as much of the ETH value sent /// as possible, accounting for order and forwarder fees. /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. /// @param signatures Proofs that orders have been created by makers. /// @param ethFeeAmounts Amounts of ETH, denominated in Wei, that are paid to corresponding feeRecipients. /// @param feeRecipients Addresses that will receive ETH when orders are filled. /// @return wethSpentAmount Amount of WETH spent on the given set of orders. /// @return makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders. function marketSellOrdersWithEth( LibOrder.Order[] memory orders, bytes[] memory signatures, uint256[] memory ethFeeAmounts, address payable[] memory feeRecipients ) public payable returns ( uint256 wethSpentAmount, uint256 makerAssetAcquiredAmount ); /// @dev Attempt to buy makerAssetBuyAmount of makerAsset by selling ETH provided with transaction. /// The Forwarder may *fill* more than makerAssetBuyAmount of the makerAsset so that it can /// pay takerFees where takerFeeAssetData == makerAssetData (i.e. percentage fees). /// Any ETH not spent will be refunded to sender. /// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset. /// @param makerAssetBuyAmount Desired amount of makerAsset to purchase. /// @param signatures Proofs that orders have been created by makers. /// @param ethFeeAmounts Amounts of ETH, denominated in Wei, that are paid to corresponding feeRecipients. /// @param feeRecipients Addresses that will receive ETH when orders are filled. /// @return wethSpentAmount Amount of WETH spent on the given set of orders. /// @return makerAssetAcquiredAmount Amount of maker asset acquired from the given set of orders. function marketBuyOrdersWithEth( LibOrder.Order[] memory orders, uint256 makerAssetBuyAmount, bytes[] memory signatures, uint256[] memory ethFeeAmounts, address payable[] memory feeRecipients ) public payable returns ( uint256 wethSpentAmount, uint256 makerAssetAcquiredAmount ); }
/* Copyright 2019 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ pragma solidity ^0.5.9; pragma experimental ABIEncoderV2; import "@0x/contracts-extensions/contracts/src/LibAssetDataTransfer.sol"; import "../src/MixinExchangeWrapper.sol"; import "../src/MixinReceiver.sol"; contract TestForwarder is MixinExchangeWrapper, MixinReceiver { using LibAssetDataTransfer for bytes; // solhint-disable no-empty-blocks constructor () public MixinExchangeWrapper( address(0), address(0) ) {} function areUnderlyingAssetsEqual( bytes memory assetData1, bytes memory assetData2 ) public returns (bool) { return _areUnderlyingAssetsEqual( assetData1, assetData2 ); } function transferOut( bytes memory assetData, uint256 amount ) public { assetData.transferOut(amount); } }
{ "optimizer": { "enabled": true, "runs": 1000000, "details": { "yul": true, "deduplicate": true, "cse": true, "constantOptimizer": true } }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "evmVersion": "istanbul", "remappings": [ "@0x/contracts-asset-proxy=/Users/michaelzhu/monorepo/contracts/exchange-forwarder/node_modules/@0x/contracts-asset-proxy", "@0x/contracts-exchange-libs=/Users/michaelzhu/monorepo/contracts/exchange-forwarder/node_modules/@0x/contracts-exchange-libs", "@0x/contracts-utils=/Users/michaelzhu/monorepo/contracts/exchange-forwarder/node_modules/@0x/contracts-utils", "@0x/contracts-extensions=/Users/michaelzhu/monorepo/node_modules/@0x/contracts-extensions", "@0x/contracts-erc20=/Users/michaelzhu/monorepo/contracts/exchange-forwarder/node_modules/@0x/contracts-erc20", "@0x/contracts-erc721=/Users/michaelzhu/monorepo/contracts/exchange-forwarder/node_modules/@0x/contracts-erc721", "@0x/contracts-erc1155=/Users/michaelzhu/monorepo/contracts/exchange-forwarder/node_modules/@0x/contracts-erc1155", "@0x/contracts-exchange=/Users/michaelzhu/monorepo/contracts/exchange-forwarder/node_modules/@0x/contracts-exchange" ] }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_exchange","type":"address"},{"internalType":"address","name":"_exchangeV2","type":"address"},{"internalType":"address","name":"_weth","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":true,"inputs":[],"name":"ERC1155_BATCH_RECEIVED","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ERC1155_RECEIVED","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"EXCHANGE_V2_ORDER_ID","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"assetData","type":"bytes"}],"name":"approveMakerAssetProxy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"components":[{"internalType":"address","name":"makerAddress","type":"address"},{"internalType":"address","name":"takerAddress","type":"address"},{"internalType":"address","name":"feeRecipientAddress","type":"address"},{"internalType":"address","name":"senderAddress","type":"address"},{"internalType":"uint256","name":"makerAssetAmount","type":"uint256"},{"internalType":"uint256","name":"takerAssetAmount","type":"uint256"},{"internalType":"uint256","name":"makerFee","type":"uint256"},{"internalType":"uint256","name":"takerFee","type":"uint256"},{"internalType":"uint256","name":"expirationTimeSeconds","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"makerAssetData","type":"bytes"},{"internalType":"bytes","name":"takerAssetData","type":"bytes"},{"internalType":"bytes","name":"makerFeeAssetData","type":"bytes"},{"internalType":"bytes","name":"takerFeeAssetData","type":"bytes"}],"internalType":"struct LibOrder.Order[]","name":"orders","type":"tuple[]"},{"internalType":"uint256","name":"makerAssetBuyAmount","type":"uint256"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"},{"internalType":"uint256[]","name":"ethFeeAmounts","type":"uint256[]"},{"internalType":"address payable[]","name":"feeRecipients","type":"address[]"}],"name":"marketBuyOrdersWithEth","outputs":[{"internalType":"uint256","name":"wethSpentAmount","type":"uint256"},{"internalType":"uint256","name":"makerAssetAcquiredAmount","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"components":[{"internalType":"address","name":"makerAddress","type":"address"},{"internalType":"address","name":"takerAddress","type":"address"},{"internalType":"address","name":"feeRecipientAddress","type":"address"},{"internalType":"address","name":"senderAddress","type":"address"},{"internalType":"uint256","name":"makerAssetAmount","type":"uint256"},{"internalType":"uint256","name":"takerAssetAmount","type":"uint256"},{"internalType":"uint256","name":"makerFee","type":"uint256"},{"internalType":"uint256","name":"takerFee","type":"uint256"},{"internalType":"uint256","name":"expirationTimeSeconds","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"makerAssetData","type":"bytes"},{"internalType":"bytes","name":"takerAssetData","type":"bytes"},{"internalType":"bytes","name":"makerFeeAssetData","type":"bytes"},{"internalType":"bytes","name":"takerFeeAssetData","type":"bytes"}],"internalType":"struct LibOrder.Order[]","name":"orders","type":"tuple[]"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"},{"internalType":"uint256[]","name":"ethFeeAmounts","type":"uint256[]"},{"internalType":"address payable[]","name":"feeRecipients","type":"address[]"}],"name":"marketSellOrdersWithEth","outputs":[{"internalType":"uint256","name":"wethSpentAmount","type":"uint256"},{"internalType":"uint256","name":"makerAssetAcquiredAmount","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"assetData","type":"bytes"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawAsset","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b5060405162003c9d38038062003c9d833981016040819052620000349162000472565b60008054336001600160a01b031991821617909155600180549091166001600160a01b0383161790556040518390839082908490630f47261b60e41b9062000081908390602401620004e7565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217825251620000c191600291620003a0565b50604051630c0e082160e31b81526000906001600160a01b03841690636070410890620000fa90630f47261b60e41b9060040162000514565b60206040518083038186803b1580156200011357600080fd5b505afa15801562000128573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506200014e919081019062000442565b90506001600160a01b038116620001895762000189620001786200036b60201b620007b11760201c565b6200039860201b620002d81760201c565b60015460405163095ea7b360e01b81526001600160a01b039091169063095ea7b390620001bf90849060001990600401620004fb565b602060405180830381600087803b158015620001da57600080fd5b505af1158015620001ef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250620002159190810190620004c5565b506000836001600160a01b031663850a15016040518163ffffffff1660e01b815260040160206040518083038186803b1580156200025257600080fd5b505afa15801562000267573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506200028d919081019062000442565b90506001600160a01b038116156200032d5760015460405163095ea7b360e01b81526001600160a01b039091169063095ea7b390620002d590849060001990600401620004fb565b602060405180830381600087803b158015620002f057600080fd5b505af115801562000305573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506200032b9190810190620004c5565b505b5050600380546001600160a01b039586166001600160a01b031991821617909155600480549490951693169290921790925550620005429350505050565b6040805160048152602481019091526020810180516001600160e01b031663f3b96b8d60e01b1790525b90565b805160208201fd5b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620003e357805160ff191683800117855562000413565b8280016001018555821562000413579182015b8281111562000413578251825591602001919060010190620003f6565b506200042192915062000425565b5090565b6200039591905b808211156200042157600081556001016200042c565b60006020828403121562000454578081fd5b81516001600160a01b03811681146200046b578182fd5b9392505050565b60008060006060848603121562000487578182fd5b8351620004948162000529565b6020850151909350620004a78162000529565b6040850151909250620004ba8162000529565b809150509250925092565b600060208284031215620004d7578081fd5b815180151581146200046b578182fd5b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160e01b031991909116815260200190565b6001600160a01b03811681146200053f57600080fd5b50565b61374b80620005526000396000f3fe6080604052600436106100bc5760003560e01c8063bc197c8111610074578063f23a6e611161004e578063f23a6e61146101e4578063f2fde38b14610204578063fc67bf1c14610224576100bc565b8063bc197c811461018d578063e0a5c949146101ba578063e196001b146101cf576100bc565b80638da5cb5b116100a55780638da5cb5b1461012e578063907e5cc3146101595780639e8323151461017a576100bc565b8063442026ed146100ee578063630f1e6c1461010e575b60015473ffffffffffffffffffffffffffffffffffffffff1633146100ec576100ec6100e733610239565b6102d8565b005b3480156100fa57600080fd5b506100ec610109366004613075565b6102e0565b34801561011a57600080fd5b506100ec6101293660046130b5565b6104ca565b34801561013a57600080fd5b50610143610520565b6040516101509190613246565b60405180910390f35b61016c610167366004612e77565b61053c565b604051610150929190613623565b61016c610188366004612f13565b610597565b34801561019957600080fd5b506101ad6101a8366004612d42565b6105f3565b604051610150919061334f565b3480156101c657600080fd5b506101ad610620565b3480156101db57600080fd5b506101ad610644565b3480156101f057600080fd5b506101ad6101ff366004612dfd565b610668565b34801561021057600080fd5b506100ec61021f366004612c72565b610693565b34801561023057600080fd5b506101ad610737565b60606308b1869860e01b826040516024016102549190613246565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091529050919050565b805160208201fd5b600061032c600084848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929392505063ffffffff61075b169050565b90507ff47261b0000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000082168114156104c4576003546040517f6070410800000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff16906360704108906103d090859060040161334f565b60206040518083038186803b1580156103e857600080fd5b505afa1580156103fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506104209190810190612c8e565b905073ffffffffffffffffffffffffffffffffffffffff8116610448576104486100e76107b1565b6000610494601087878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929392505063ffffffff61080b169050565b90506104c181837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61084b565b50505b50505050565b6104d261090c565b61051b8184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929392505063ffffffff610955169050565b505050565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b600080600061054b858561096b565b9050610558878288610ac1565b909350915080831115610572576105726100e78434610f28565b610582818463ffffffff610fca16565b905061058d81610fe9565b5094509492505050565b60008060006105a6858561096b565b90506105b38888886110a4565b9093509150808311156105cd576105cd6100e78434610f28565b6105dd818463ffffffff610fca16565b90506105e881610fe9565b509550959350505050565b7fbc197c810000000000000000000000000000000000000000000000000000000098975050505050505050565b7ff23a6e610000000000000000000000000000000000000000000000000000000081565b7f770501f80000000000000000000000000000000000000000000000000000000081565b7ff23a6e61000000000000000000000000000000000000000000000000000000009695505050505050565b61069b61090c565b73ffffffffffffffffffffffffffffffffffffffff81166106c6576106c16100e76113e0565b610734565b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081178255604051909133917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35b50565b7fbc197c810000000000000000000000000000000000000000000000000000000081565b6000816004018351101561077c5761077c6100e76003855185600401611417565b5060208183018101519101907fffffffff00000000000000000000000000000000000000000000000000000000165b92915050565b6040805160048152602481019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167ff3b96b8d0000000000000000000000000000000000000000000000000000000017905290565b6000816014018351101561082c5761082c6100e76004855185601401611417565b50016014015173ffffffffffffffffffffffffffffffffffffffff1690565b6040516060907f095ea7b300000000000000000000000000000000000000000000000000000000906108839085908590602401613329565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290506104c484826114bd565b60005473ffffffffffffffffffffffffffffffffffffffff16331461095357600054610953906100e790339073ffffffffffffffffffffffffffffffffffffffff16611575565b565b6109678230338463ffffffff61159216565b5050565b81518151600091908114610987576109876100e78285516117cd565b34915060005b818114610a365760008582815181106109a257fe5b60200260200101519050808410156109c1576109c16100e782866117ea565b6109d1848263ffffffff610fca16565b93508482815181106109df57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610a2c573d6000803e3d6000fd5b505060010161098d565b50600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b158015610aa157600080fd5b505af1158015610ab5573d6000803e3d6000fd5b50505050505092915050565b6000806000610b76600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631ce4c78b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b3157600080fd5b505afa158015610b45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b699190810190613150565b3a9063ffffffff61180716565b90507fdc1600f30000000000000000000000000000000000000000000000000000000060005b87518114610f1d57878181518110610bb057fe5b60200260200101516080015160001480610be15750878181518110610bd157fe5b602002602001015160a001516000145b15610beb57610f15565b6000610c35610c0c8a8481518110610bff57fe5b6020026020010151611838565b610c165784610c19565b60005b610c298a8963ffffffff610fca16565b9063ffffffff610fca16565b90506000610c6560008b8581518110610c4a57fe5b6020026020010151610140015161075b90919063ffffffff16565b90506000807fffffffff000000000000000000000000000000000000000000000000000000008084169087161415610d6b57610cc360108d8781518110610ca857fe5b6020026020010151610140015161080b90919063ffffffff16565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815290925073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190610d18903090600401613246565b60206040518083038186803b158015610d3057600080fd5b505afa158015610d44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d689190810190613150565b90505b600080610d9f8e8881518110610d7d57fe5b60200260200101518d8981518110610d9157fe5b6020026020010151886118ad565b91509150877bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610ead576040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190610e3e903090600401613246565b60206040518083038186803b158015610e5657600080fd5b505afa158015610e6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610e8e9190810190613150565b9050610ea9610ea3828663ffffffff610fca16565b836119d7565b9150505b610ed8818f8981518110610ebd57fe5b6020026020010151610140015161095590919063ffffffff16565b610ee88b8363ffffffff6119ee16565b9a50610efa8a8263ffffffff6119ee16565b99508c8b10610f0e57505050505050610f1d565b5050505050505b600101610b9c565b505050935093915050565b606063cdcbed5d60e01b8383604051602401610f45929190613623565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152905092915050565b600082821115610fe357610fe36100e760028585611a06565b50900390565b8015610734576001546040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690632e1a7d4d9061104590849060040161361a565b600060405180830381600087803b15801561105f57600080fd5b505af1158015611073573d6000803e3d6000fd5b505060405133925083156108fc02915083906000818181858888f19350505050158015610967573d6000803e3d6000fd5b825160009081907fdc1600f30000000000000000000000000000000000000000000000000000000090825b8181146113c0578781815181106110e257fe5b60200260200101516080015160001480611113575087818151811061110357fe5b602002602001015160a001516000145b1561111d576113b8565b600061112f888663ffffffff610fca16565b9050600061114460008b8581518110610c4a57fe5b90506000807fffffffff00000000000000000000000000000000000000000000000000000000808416908816141561122f5761118760108d8781518110610ca857fe5b6040517f70a0823100000000000000000000000000000000000000000000000000000000815290925073ffffffffffffffffffffffffffffffffffffffff8316906370a08231906111dc903090600401613246565b60206040518083038186803b1580156111f457600080fd5b505afa158015611208573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061122c9190810190613150565b90505b6000806112638e888151811061124157fe5b60200260200101518d898151811061125557fe5b602002602001015188611a25565b91509150887bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561136b576040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190611302903090600401613246565b60206040518083038186803b15801561131a57600080fd5b505afa15801561132e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506113529190810190613150565b9050611367610ea3828663ffffffff610fca16565b9150505b61137b818f8981518110610ebd57fe5b61138b8b8363ffffffff6119ee16565b9a5061139d8a8263ffffffff6119ee16565b99508c8a106113b1575050505050506113c0565b5050505050505b6001016110cf565b50858310156113d6576113d66100e78785611af7565b5050935093915050565b60408051808201909152600481527fe69edc3e00000000000000000000000000000000000000000000000000000000602082015290565b6060632800659560e01b848484604051602401611436939291906133b1565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290505b9392505050565b600060608373ffffffffffffffffffffffffffffffffffffffff16836040516114e6919061322a565b6000604051808303816000865af19150503d8060008114611523576040519150601f19603f3d011682016040523d82523d6000602084013e611528565b606091505b5091509150811561156c578051611540575050610967565b80516020141561156c576000611557826000611b14565b9050806001141561156a57505050610967565b505b6104c4816102d8565b6060631de45ad160e01b8383604051602401610f45929190613267565b8061159c576104c4565b60006115ae858263ffffffff61075b16565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167ff47261b000000000000000000000000000000000000000000000000000000000148061164157507fffffffff0000000000000000000000000000000000000000000000000000000081167fdc1600f300000000000000000000000000000000000000000000000000000000145b1561165d576116588585858563ffffffff611b2016565b6117c6565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f025717920000000000000000000000000000000000000000000000000000000014156116b9576116588585858563ffffffff611b6a16565b7fffffffff0000000000000000000000000000000000000000000000000000000081167fa7cb5fb7000000000000000000000000000000000000000000000000000000001415611715576116588585858563ffffffff611c3916565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f94cfcdd7000000000000000000000000000000000000000000000000000000001415611771576116588585858563ffffffff611d8f16565b7fffffffff0000000000000000000000000000000000000000000000000000000081167fc339d10a00000000000000000000000000000000000000000000000000000000146117c6576117c66100e782611e23565b5050505050565b6060633ecb6ceb60e01b8383604051602401610f45929190613623565b606063ecf40fd960e01b8383604051602401610f45929190613623565b600082611816575060006107ab565b8282028284828161182357fe5b04146114b6576114b66100e760018686611a06565b60006003826101800151511180156107ab57506101808201517f770501f8000000000000000000000000000000000000000000000000000000009061188490600063ffffffff61075b16565b7fffffffff00000000000000000000000000000000000000000000000000000000161492915050565b6000808460e00151600014806118d257506118d2856101a00151866101400151611e3e565b15611929576118df612710565b6118ea868587611feb565b9050611907816080015182602001516119ee90919063ffffffff16565b60608201518251919450611921919063ffffffff610fca16565b9150506119cf565b61193d856101a00151866101600151611e3e565b156119be5760a085015160e086015160009161196a9161196490829063ffffffff6119ee16565b86612026565b9050611974612710565b61197f878388611feb565b90506119b081608001516119a4836060015184602001516119ee90919063ffffffff16565b9063ffffffff6119ee16565b905190935091506119cf9050565b6119cf6100e7866101a0015161205c565b935093915050565b6000818310156119e757816114b6565b5090919050565b6000828201838110156114b6576114b66100e7600086865b606063e946c1bb60e01b8484846040516024016114369392919061338f565b6000808460e0015160001480611a4a5750611a4a856101a00151866101600151611e3e565b15611a6457600061196a8660a00151876080015186612026565b611a78856101a00151866101400151611e3e565b156119be576000611aa28660a001516119648860e001518960800151610fca90919063ffffffff16565b9050611aac612710565b611ab7878388611feb565b9050611ad4816080015182602001516119ee90919063ffffffff16565b60608201518251919550611aee919063ffffffff610fca16565b925050506119cf565b60606391353a0c60e01b8383604051602401610f45929190613623565b60006114b68383612077565b6000611b3385601063ffffffff61080b16565b905073ffffffffffffffffffffffffffffffffffffffff8416301415611b5e576116588184846120a1565b6117c6818585856120d9565b80600114611b7e57611b7e6100e78261219c565b6000611b9185601063ffffffff61080b16565b90506000611ba686602463ffffffff611b1416565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff8316906323b872dd90611bff908890889086906004016132f8565b600060405180830381600087803b158015611c1957600080fd5b505af1158015611c2d573d6000803e3d6000fd5b50505050505050505050565b60006060806060611c57600489518a6121b79092919063ffffffff16565b806020019051611c6a9190810190612caa565b9350935093509350600082519050606081604051908082528060200260200182016040528015611ca4578160200160208202803883390190505b50905060005b828114611cf657611cd788868381518110611cc157fe5b602002602001015161180790919063ffffffff16565b828281518110611ce357fe5b6020908102919091010152600101611caa565b506040517f2eb2c2d600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff871690632eb2c2d690611d51908c908c908a9087908a9060040161328e565b600060405180830381600087803b158015611d6b57600080fd5b505af1158015611d7f573d6000803e3d6000fd5b5050505050505050505050505050565b606080611da960048751886121b79092919063ffffffff16565b806020019051611dbc9190810190612fc5565b8051919350915060005b818114611e1957611e11838281518110611ddc57fe5b60200260200101518888611e0c888681518110611df557fe5b60200260200101518a61180790919063ffffffff16565b611592565b600101611dc6565b5050505050505050565b6060637996a27160e01b82604051602401610254919061334f565b600080611e51848263ffffffff61075b16565b90506000611e65848263ffffffff61075b16565b90507ff47261b0000000000000000000000000000000000000000000000000000000007fdc1600f3000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008416821480611efd57507fffffffff00000000000000000000000000000000000000000000000000000000848116908216145b8015611f5b57507fffffffff000000000000000000000000000000000000000000000000000000008381169083161480611f5b57507fffffffff00000000000000000000000000000000000000000000000000000000838116908216145b15611fc6576000611f7388601063ffffffff61080b16565b90506000611f8888601063ffffffff61080b16565b90508073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161496505050505050506107ab565b611fd6878763ffffffff61223716565b9450505050506107ab565b5050505092915050565b611ff3612710565b611ffc84611838565b156120135761200c84848461225c565b90506114b6565b61201e8484846124b0565b949350505050565b600061201e8361205061204082600163ffffffff610fca16565b6119a4888763ffffffff61180716565b9063ffffffff61261d16565b60606331360af160e01b82604051602401610254919061337c565b60008160200183511015612098576120986100e76005855185602001611417565b50016020015190565b6040516060907fa9059cbb00000000000000000000000000000000000000000000000000000000906108839085908590602401613329565b6040516060907f23b872dd0000000000000000000000000000000000000000000000000000000090612113908690869086906024016132f8565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290506117c685826114bd565b606063baffa47460e01b82604051602401610254919061361a565b6060818311156121d0576121d06100e760008585611417565b83518211156121e9576121e96100e76001848751611417565b8282036040519080825280601f01601f191660200182016040528015612216576020820181803883390190505b5090506114b661222582612647565b8461222f87612647565b01835161264d565b6000815183511480156114b65750508051602091820120825192909101919091201490565b612264612710565b61226c61273f565b604051806101800160405280866000015173ffffffffffffffffffffffffffffffffffffffff168152602001866020015173ffffffffffffffffffffffffffffffffffffffff168152602001866040015173ffffffffffffffffffffffffffffffffffffffff168152602001866060015173ffffffffffffffffffffffffffffffffffffffff168152602001866080015181526020018660a001518152602001600081526020016000815260200186610100015181526020018661012001518152602001866101400151815260200186610160015181525090506060600073ffffffffffffffffffffffffffffffffffffffff1663b4be83d5905060e01b82868660405160240161237f939291906133bf565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090941693909317909252600454915190925073ffffffffffffffffffffffffffffffffffffffff90911690600090606090839061243090869061322a565b6000604051808303816000865af19150503d806000811461246d576040519150601f19603f3d011682016040523d82523d6000602084013e612472565b606091505b509150915081156124a457805160801461248857fe5b8080602001905161249c9190810190613168565b602088015286525b50505050509392505050565b6124b8612710565b6040516060907f9b44d55600000000000000000000000000000000000000000000000000000000906124f2908790879087906024016134df565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090941693909317909252600354915190925073ffffffffffffffffffffffffffffffffffffffff9091169060009060609083906125a390869061322a565b6000604051808303816000865af19150503d80600081146125e0576040519150601f19603f3d011682016040523d82523d6000602084013e6125e5565b606091505b5091509150811561261257805160a0146125fb57fe5b8080602001905161260f91908101906130ff565b94505b505050509392505050565b600081612633576126336100e760038585611a06565b600082848161263e57fe5b04949350505050565b60200190565b6020811015612677576001816020036101000a03801983511681855116808217865250505061051b565b828214156126845761051b565b828211156126be5760208103905080820181840181515b828510156126b657845186526020958601959094019361269b565b90525061051b565b60208103905080820181840183515b8186121561270757825182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe092830192909101906126cd565b85525050505050565b6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b604051806101800160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160608152602001606081525090565b80356107ab816136e6565b600082601f830112612813578081fd5b813561282661282182613658565b613631565b81815291506020808301908481018184028601820187101561284757600080fd5b60005b8481101561286f57813561285d816136e6565b8452928201929082019060010161284a565b505050505092915050565b600082601f83011261288a578081fd5b813561289861282182613658565b8181529150602080830190840160005b83811015611fe1576128c08760208435890101612bd7565b835260209283019291909101906001016128a8565b600082601f8301126128e5578081fd5b81356128f361282182613658565b818152915060208083019084810160005b8481101561286f57813587016101c0807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0838c0301121561294457600080fd5b61294d81613631565b6129598b8785016127f8565b81526129688b604085016127f8565b868201526129798b606085016127f8565b604082015261298b8b608085016127f8565b606082015260a0830135608082015260c083013560a082015260e083013560c08201526101008084013560e0830152610120808501358284015261014091508185013581840152506101608085013567ffffffffffffffff808211156129f057600080fd5b6129fe8f8b848a0101612bd7565b84860152610180935083870135915080821115612a1a57600080fd5b612a288f8b848a0101612bd7565b838601526101a0925082870135915080821115612a4457600080fd5b612a528f8b848a0101612bd7565b8486015285870135935080841115612a6957600080fd5b5050612a798d8984880101612bd7565b9083015250865250509282019290820190600101612904565b60008083601f840112612aa3578182fd5b50813567ffffffffffffffff811115612aba578182fd5b6020830191508360208083028501011115612ad457600080fd5b9250929050565b600082601f830112612aeb578081fd5b8151612af961282182613658565b818152915060208083019084810181840286018201871015612b1a57600080fd5b60005b8481101561286f57815184529282019290820190600101612b1d565b600082601f830112612b49578081fd5b8135612b5761282182613658565b818152915060208083019084810181840286018201871015612b7857600080fd5b60005b8481101561286f57813584529282019290820190600101612b7b565b60008083601f840112612ba8578182fd5b50813567ffffffffffffffff811115612bbf578182fd5b602083019150836020828501011115612ad457600080fd5b600082601f830112612be7578081fd5b8135612bf561282182613678565b9150808252836020828501011115612c0c57600080fd5b8060208401602084013760009082016020015292915050565b600082601f830112612c35578081fd5b8151612c4361282182613678565b9150808252836020828501011115612c5a57600080fd5b612c6b8160208401602086016136ba565b5092915050565b600060208284031215612c83578081fd5b81356114b6816136e6565b600060208284031215612c9f578081fd5b81516114b6816136e6565b60008060008060808587031215612cbf578283fd5b8451612cca816136e6565b602086015190945067ffffffffffffffff80821115612ce7578485fd5b612cf388838901612adb565b94506040870151915080821115612d08578384fd5b612d1488838901612adb565b93506060870151915080821115612d29578283fd5b50612d3687828801612c25565b91505092959194509250565b60008060008060008060008060a0898b031215612d5d578586fd5b8835612d68816136e6565b97506020890135612d78816136e6565b9650604089013567ffffffffffffffff80821115612d94578788fd5b612da08c838d01612a92565b909850965060608b0135915080821115612db8578586fd5b612dc48c838d01612a92565b909650945060808b0135915080821115612ddc578384fd5b50612de98b828c01612b97565b999c989b5096995094979396929594505050565b60008060008060008060a08789031215612e15578384fd5b8635612e20816136e6565b95506020870135612e30816136e6565b94506040870135935060608701359250608087013567ffffffffffffffff811115612e59578283fd5b612e6589828a01612b97565b979a9699509497509295939492505050565b60008060008060808587031215612e8c578182fd5b843567ffffffffffffffff80821115612ea3578384fd5b612eaf888389016128d5565b95506020870135915080821115612ec4578384fd5b612ed08883890161287a565b94506040870135915080821115612ee5578384fd5b612ef188838901612b39565b93506060870135915080821115612f06578283fd5b50612d3687828801612803565b600080600080600060a08688031215612f2a578283fd5b853567ffffffffffffffff80821115612f41578485fd5b612f4d89838a016128d5565b9650602088013595506040880135915080821115612f69578485fd5b612f7589838a0161287a565b94506060880135915080821115612f8a578283fd5b612f9689838a01612b39565b93506080880135915080821115612fab578283fd5b50612fb888828901612803565b9150509295509295909350565b60008060408385031215612fd7578182fd5b825167ffffffffffffffff80821115612fee578384fd5b612ffa86838701612adb565b9350602091508185015181811115613010578384fd5b85019050601f81018613613022578283fd5b805161303061282182613658565b81815283810190838501865b84811015613065576130538b888451890101612c25565b8452928601929086019060010161303c565b5096999098509650505050505050565b60008060208385031215613087578182fd5b823567ffffffffffffffff81111561309d578283fd5b6130a985828601612b97565b90969095509350505050565b6000806000604084860312156130c9578081fd5b833567ffffffffffffffff8111156130df578182fd5b6130eb86828701612b97565b909790965060209590950135949350505050565b600060a08284031215613110578081fd5b61311a60a0613631565b82518152602083015160208201526040830151604082015260608301516060820152608083015160808201528091505092915050565b600060208284031215613161578081fd5b5051919050565b6000806040838503121561317a578182fd5b505080516020909101519092909150565b73ffffffffffffffffffffffffffffffffffffffff169052565b6000815180845260208401935060208301825b828110156131d65781518652602095860195909101906001016131b8565b5093949350505050565b600081518084526131f88160208601602086016136ba565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6000825161323c8184602087016136ba565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525060a060408301526132c760a08301866131a5565b82810360608401526132d981866131a5565b83810360808501526132eb81866131e0565b9998505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff9384168152919092166020820152604081019190915260600190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b6000602082526114b660208301846131e0565b606081016004851061339d57fe5b938152602081019290925260409091015290565b606081016008851061339d57fe5b6000606082526133d360608301865161318b565b60208501516133e5608084018261318b565b5060408501516133f860a084018261318b565b50606085015161340b60c084018261318b565b50608085015160e083015260a0850151610100818185015260c08701519150610120828186015260e088015192506101408381870152828901519350610160925083838701528189015193506101809150838287015280890151935050806101a08601525061347e6101e08501836131e0565b8188015192507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0858203016101c08601526134b981846131e0565b91505085602085015283810360408501526134d481866131e0565b979650505050505050565b6000606082526134f360608301865161318b565b6020850151613505608084018261318b565b50604085015161351860a084018261318b565b50606085015161352b60c084018261318b565b50608085015160e083015260a0850151610100818185015260c08701519150610120828186015260e0880151925061014083818701528289015193506101609250838387015281890151935061018091508382870152808901519350506101c06101a081818801526135a16102208801866131e0565b848b015195507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa094508488820301838901526135dd81876131e0565b925050828a0151945083878303016101e08801526135fb82866131e0565b9250808a01519450505081858203016102008601526134b981846131e0565b90815260200190565b918252602082015260400190565b60405181810167ffffffffffffffff8111828210171561365057600080fd5b604052919050565b600067ffffffffffffffff82111561366e578081fd5b5060209081020190565b600067ffffffffffffffff82111561368e578081fd5b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60005b838110156136d55781810151838201526020016136bd565b838111156104c45750506000910152565b73ffffffffffffffffffffffffffffffffffffffff8116811461073457600080fdfea365627a7a72315820ebedf6ba0823da75dd29d928186748ec6baa07f40f145a90097baa22da29b56a6c6578706572696d656e74616cf564736f6c6343000510004000000000000000000000000061935cbdd02287b511119ddb11aeb42f1593b7ef000000000000000000000000080bf510fcbf18b91105470639e9561022937712000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Deployed Bytecode
0x6080604052600436106100bc5760003560e01c8063bc197c8111610074578063f23a6e611161004e578063f23a6e61146101e4578063f2fde38b14610204578063fc67bf1c14610224576100bc565b8063bc197c811461018d578063e0a5c949146101ba578063e196001b146101cf576100bc565b80638da5cb5b116100a55780638da5cb5b1461012e578063907e5cc3146101595780639e8323151461017a576100bc565b8063442026ed146100ee578063630f1e6c1461010e575b60015473ffffffffffffffffffffffffffffffffffffffff1633146100ec576100ec6100e733610239565b6102d8565b005b3480156100fa57600080fd5b506100ec610109366004613075565b6102e0565b34801561011a57600080fd5b506100ec6101293660046130b5565b6104ca565b34801561013a57600080fd5b50610143610520565b6040516101509190613246565b60405180910390f35b61016c610167366004612e77565b61053c565b604051610150929190613623565b61016c610188366004612f13565b610597565b34801561019957600080fd5b506101ad6101a8366004612d42565b6105f3565b604051610150919061334f565b3480156101c657600080fd5b506101ad610620565b3480156101db57600080fd5b506101ad610644565b3480156101f057600080fd5b506101ad6101ff366004612dfd565b610668565b34801561021057600080fd5b506100ec61021f366004612c72565b610693565b34801561023057600080fd5b506101ad610737565b60606308b1869860e01b826040516024016102549190613246565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091529050919050565b805160208201fd5b600061032c600084848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929392505063ffffffff61075b169050565b90507ff47261b0000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000082168114156104c4576003546040517f6070410800000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff16906360704108906103d090859060040161334f565b60206040518083038186803b1580156103e857600080fd5b505afa1580156103fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506104209190810190612c8e565b905073ffffffffffffffffffffffffffffffffffffffff8116610448576104486100e76107b1565b6000610494601087878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929392505063ffffffff61080b169050565b90506104c181837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61084b565b50505b50505050565b6104d261090c565b61051b8184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929392505063ffffffff610955169050565b505050565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b600080600061054b858561096b565b9050610558878288610ac1565b909350915080831115610572576105726100e78434610f28565b610582818463ffffffff610fca16565b905061058d81610fe9565b5094509492505050565b60008060006105a6858561096b565b90506105b38888886110a4565b9093509150808311156105cd576105cd6100e78434610f28565b6105dd818463ffffffff610fca16565b90506105e881610fe9565b509550959350505050565b7fbc197c810000000000000000000000000000000000000000000000000000000098975050505050505050565b7ff23a6e610000000000000000000000000000000000000000000000000000000081565b7f770501f80000000000000000000000000000000000000000000000000000000081565b7ff23a6e61000000000000000000000000000000000000000000000000000000009695505050505050565b61069b61090c565b73ffffffffffffffffffffffffffffffffffffffff81166106c6576106c16100e76113e0565b610734565b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081178255604051909133917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35b50565b7fbc197c810000000000000000000000000000000000000000000000000000000081565b6000816004018351101561077c5761077c6100e76003855185600401611417565b5060208183018101519101907fffffffff00000000000000000000000000000000000000000000000000000000165b92915050565b6040805160048152602481019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167ff3b96b8d0000000000000000000000000000000000000000000000000000000017905290565b6000816014018351101561082c5761082c6100e76004855185601401611417565b50016014015173ffffffffffffffffffffffffffffffffffffffff1690565b6040516060907f095ea7b300000000000000000000000000000000000000000000000000000000906108839085908590602401613329565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290506104c484826114bd565b60005473ffffffffffffffffffffffffffffffffffffffff16331461095357600054610953906100e790339073ffffffffffffffffffffffffffffffffffffffff16611575565b565b6109678230338463ffffffff61159216565b5050565b81518151600091908114610987576109876100e78285516117cd565b34915060005b818114610a365760008582815181106109a257fe5b60200260200101519050808410156109c1576109c16100e782866117ea565b6109d1848263ffffffff610fca16565b93508482815181106109df57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610a2c573d6000803e3d6000fd5b505060010161098d565b50600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b158015610aa157600080fd5b505af1158015610ab5573d6000803e3d6000fd5b50505050505092915050565b6000806000610b76600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631ce4c78b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b3157600080fd5b505afa158015610b45573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610b699190810190613150565b3a9063ffffffff61180716565b90507fdc1600f30000000000000000000000000000000000000000000000000000000060005b87518114610f1d57878181518110610bb057fe5b60200260200101516080015160001480610be15750878181518110610bd157fe5b602002602001015160a001516000145b15610beb57610f15565b6000610c35610c0c8a8481518110610bff57fe5b6020026020010151611838565b610c165784610c19565b60005b610c298a8963ffffffff610fca16565b9063ffffffff610fca16565b90506000610c6560008b8581518110610c4a57fe5b6020026020010151610140015161075b90919063ffffffff16565b90506000807fffffffff000000000000000000000000000000000000000000000000000000008084169087161415610d6b57610cc360108d8781518110610ca857fe5b6020026020010151610140015161080b90919063ffffffff16565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815290925073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190610d18903090600401613246565b60206040518083038186803b158015610d3057600080fd5b505afa158015610d44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610d689190810190613150565b90505b600080610d9f8e8881518110610d7d57fe5b60200260200101518d8981518110610d9157fe5b6020026020010151886118ad565b91509150877bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610ead576040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190610e3e903090600401613246565b60206040518083038186803b158015610e5657600080fd5b505afa158015610e6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610e8e9190810190613150565b9050610ea9610ea3828663ffffffff610fca16565b836119d7565b9150505b610ed8818f8981518110610ebd57fe5b6020026020010151610140015161095590919063ffffffff16565b610ee88b8363ffffffff6119ee16565b9a50610efa8a8263ffffffff6119ee16565b99508c8b10610f0e57505050505050610f1d565b5050505050505b600101610b9c565b505050935093915050565b606063cdcbed5d60e01b8383604051602401610f45929190613623565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152905092915050565b600082821115610fe357610fe36100e760028585611a06565b50900390565b8015610734576001546040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911690632e1a7d4d9061104590849060040161361a565b600060405180830381600087803b15801561105f57600080fd5b505af1158015611073573d6000803e3d6000fd5b505060405133925083156108fc02915083906000818181858888f19350505050158015610967573d6000803e3d6000fd5b825160009081907fdc1600f30000000000000000000000000000000000000000000000000000000090825b8181146113c0578781815181106110e257fe5b60200260200101516080015160001480611113575087818151811061110357fe5b602002602001015160a001516000145b1561111d576113b8565b600061112f888663ffffffff610fca16565b9050600061114460008b8581518110610c4a57fe5b90506000807fffffffff00000000000000000000000000000000000000000000000000000000808416908816141561122f5761118760108d8781518110610ca857fe5b6040517f70a0823100000000000000000000000000000000000000000000000000000000815290925073ffffffffffffffffffffffffffffffffffffffff8316906370a08231906111dc903090600401613246565b60206040518083038186803b1580156111f457600080fd5b505afa158015611208573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061122c9190810190613150565b90505b6000806112638e888151811061124157fe5b60200260200101518d898151811061125557fe5b602002602001015188611a25565b91509150887bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916857bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561136b576040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8616906370a0823190611302903090600401613246565b60206040518083038186803b15801561131a57600080fd5b505afa15801561132e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506113529190810190613150565b9050611367610ea3828663ffffffff610fca16565b9150505b61137b818f8981518110610ebd57fe5b61138b8b8363ffffffff6119ee16565b9a5061139d8a8263ffffffff6119ee16565b99508c8a106113b1575050505050506113c0565b5050505050505b6001016110cf565b50858310156113d6576113d66100e78785611af7565b5050935093915050565b60408051808201909152600481527fe69edc3e00000000000000000000000000000000000000000000000000000000602082015290565b6060632800659560e01b848484604051602401611436939291906133b1565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290505b9392505050565b600060608373ffffffffffffffffffffffffffffffffffffffff16836040516114e6919061322a565b6000604051808303816000865af19150503d8060008114611523576040519150601f19603f3d011682016040523d82523d6000602084013e611528565b606091505b5091509150811561156c578051611540575050610967565b80516020141561156c576000611557826000611b14565b9050806001141561156a57505050610967565b505b6104c4816102d8565b6060631de45ad160e01b8383604051602401610f45929190613267565b8061159c576104c4565b60006115ae858263ffffffff61075b16565b90507fffffffff0000000000000000000000000000000000000000000000000000000081167ff47261b000000000000000000000000000000000000000000000000000000000148061164157507fffffffff0000000000000000000000000000000000000000000000000000000081167fdc1600f300000000000000000000000000000000000000000000000000000000145b1561165d576116588585858563ffffffff611b2016565b6117c6565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f025717920000000000000000000000000000000000000000000000000000000014156116b9576116588585858563ffffffff611b6a16565b7fffffffff0000000000000000000000000000000000000000000000000000000081167fa7cb5fb7000000000000000000000000000000000000000000000000000000001415611715576116588585858563ffffffff611c3916565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f94cfcdd7000000000000000000000000000000000000000000000000000000001415611771576116588585858563ffffffff611d8f16565b7fffffffff0000000000000000000000000000000000000000000000000000000081167fc339d10a00000000000000000000000000000000000000000000000000000000146117c6576117c66100e782611e23565b5050505050565b6060633ecb6ceb60e01b8383604051602401610f45929190613623565b606063ecf40fd960e01b8383604051602401610f45929190613623565b600082611816575060006107ab565b8282028284828161182357fe5b04146114b6576114b66100e760018686611a06565b60006003826101800151511180156107ab57506101808201517f770501f8000000000000000000000000000000000000000000000000000000009061188490600063ffffffff61075b16565b7fffffffff00000000000000000000000000000000000000000000000000000000161492915050565b6000808460e00151600014806118d257506118d2856101a00151866101400151611e3e565b15611929576118df612710565b6118ea868587611feb565b9050611907816080015182602001516119ee90919063ffffffff16565b60608201518251919450611921919063ffffffff610fca16565b9150506119cf565b61193d856101a00151866101600151611e3e565b156119be5760a085015160e086015160009161196a9161196490829063ffffffff6119ee16565b86612026565b9050611974612710565b61197f878388611feb565b90506119b081608001516119a4836060015184602001516119ee90919063ffffffff16565b9063ffffffff6119ee16565b905190935091506119cf9050565b6119cf6100e7866101a0015161205c565b935093915050565b6000818310156119e757816114b6565b5090919050565b6000828201838110156114b6576114b66100e7600086865b606063e946c1bb60e01b8484846040516024016114369392919061338f565b6000808460e0015160001480611a4a5750611a4a856101a00151866101600151611e3e565b15611a6457600061196a8660a00151876080015186612026565b611a78856101a00151866101400151611e3e565b156119be576000611aa28660a001516119648860e001518960800151610fca90919063ffffffff16565b9050611aac612710565b611ab7878388611feb565b9050611ad4816080015182602001516119ee90919063ffffffff16565b60608201518251919550611aee919063ffffffff610fca16565b925050506119cf565b60606391353a0c60e01b8383604051602401610f45929190613623565b60006114b68383612077565b6000611b3385601063ffffffff61080b16565b905073ffffffffffffffffffffffffffffffffffffffff8416301415611b5e576116588184846120a1565b6117c6818585856120d9565b80600114611b7e57611b7e6100e78261219c565b6000611b9185601063ffffffff61080b16565b90506000611ba686602463ffffffff611b1416565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff8316906323b872dd90611bff908890889086906004016132f8565b600060405180830381600087803b158015611c1957600080fd5b505af1158015611c2d573d6000803e3d6000fd5b50505050505050505050565b60006060806060611c57600489518a6121b79092919063ffffffff16565b806020019051611c6a9190810190612caa565b9350935093509350600082519050606081604051908082528060200260200182016040528015611ca4578160200160208202803883390190505b50905060005b828114611cf657611cd788868381518110611cc157fe5b602002602001015161180790919063ffffffff16565b828281518110611ce357fe5b6020908102919091010152600101611caa565b506040517f2eb2c2d600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff871690632eb2c2d690611d51908c908c908a9087908a9060040161328e565b600060405180830381600087803b158015611d6b57600080fd5b505af1158015611d7f573d6000803e3d6000fd5b5050505050505050505050505050565b606080611da960048751886121b79092919063ffffffff16565b806020019051611dbc9190810190612fc5565b8051919350915060005b818114611e1957611e11838281518110611ddc57fe5b60200260200101518888611e0c888681518110611df557fe5b60200260200101518a61180790919063ffffffff16565b611592565b600101611dc6565b5050505050505050565b6060637996a27160e01b82604051602401610254919061334f565b600080611e51848263ffffffff61075b16565b90506000611e65848263ffffffff61075b16565b90507ff47261b0000000000000000000000000000000000000000000000000000000007fdc1600f3000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008416821480611efd57507fffffffff00000000000000000000000000000000000000000000000000000000848116908216145b8015611f5b57507fffffffff000000000000000000000000000000000000000000000000000000008381169083161480611f5b57507fffffffff00000000000000000000000000000000000000000000000000000000838116908216145b15611fc6576000611f7388601063ffffffff61080b16565b90506000611f8888601063ffffffff61080b16565b90508073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161496505050505050506107ab565b611fd6878763ffffffff61223716565b9450505050506107ab565b5050505092915050565b611ff3612710565b611ffc84611838565b156120135761200c84848461225c565b90506114b6565b61201e8484846124b0565b949350505050565b600061201e8361205061204082600163ffffffff610fca16565b6119a4888763ffffffff61180716565b9063ffffffff61261d16565b60606331360af160e01b82604051602401610254919061337c565b60008160200183511015612098576120986100e76005855185602001611417565b50016020015190565b6040516060907fa9059cbb00000000000000000000000000000000000000000000000000000000906108839085908590602401613329565b6040516060907f23b872dd0000000000000000000000000000000000000000000000000000000090612113908690869086906024016132f8565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290506117c685826114bd565b606063baffa47460e01b82604051602401610254919061361a565b6060818311156121d0576121d06100e760008585611417565b83518211156121e9576121e96100e76001848751611417565b8282036040519080825280601f01601f191660200182016040528015612216576020820181803883390190505b5090506114b661222582612647565b8461222f87612647565b01835161264d565b6000815183511480156114b65750508051602091820120825192909101919091201490565b612264612710565b61226c61273f565b604051806101800160405280866000015173ffffffffffffffffffffffffffffffffffffffff168152602001866020015173ffffffffffffffffffffffffffffffffffffffff168152602001866040015173ffffffffffffffffffffffffffffffffffffffff168152602001866060015173ffffffffffffffffffffffffffffffffffffffff168152602001866080015181526020018660a001518152602001600081526020016000815260200186610100015181526020018661012001518152602001866101400151815260200186610160015181525090506060600073ffffffffffffffffffffffffffffffffffffffff1663b4be83d5905060e01b82868660405160240161237f939291906133bf565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090941693909317909252600454915190925073ffffffffffffffffffffffffffffffffffffffff90911690600090606090839061243090869061322a565b6000604051808303816000865af19150503d806000811461246d576040519150601f19603f3d011682016040523d82523d6000602084013e612472565b606091505b509150915081156124a457805160801461248857fe5b8080602001905161249c9190810190613168565b602088015286525b50505050509392505050565b6124b8612710565b6040516060907f9b44d55600000000000000000000000000000000000000000000000000000000906124f2908790879087906024016134df565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090941693909317909252600354915190925073ffffffffffffffffffffffffffffffffffffffff9091169060009060609083906125a390869061322a565b6000604051808303816000865af19150503d80600081146125e0576040519150601f19603f3d011682016040523d82523d6000602084013e6125e5565b606091505b5091509150811561261257805160a0146125fb57fe5b8080602001905161260f91908101906130ff565b94505b505050509392505050565b600081612633576126336100e760038585611a06565b600082848161263e57fe5b04949350505050565b60200190565b6020811015612677576001816020036101000a03801983511681855116808217865250505061051b565b828214156126845761051b565b828211156126be5760208103905080820181840181515b828510156126b657845186526020958601959094019361269b565b90525061051b565b60208103905080820181840183515b8186121561270757825182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe092830192909101906126cd565b85525050505050565b6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b604051806101800160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160608152602001606081525090565b80356107ab816136e6565b600082601f830112612813578081fd5b813561282661282182613658565b613631565b81815291506020808301908481018184028601820187101561284757600080fd5b60005b8481101561286f57813561285d816136e6565b8452928201929082019060010161284a565b505050505092915050565b600082601f83011261288a578081fd5b813561289861282182613658565b8181529150602080830190840160005b83811015611fe1576128c08760208435890101612bd7565b835260209283019291909101906001016128a8565b600082601f8301126128e5578081fd5b81356128f361282182613658565b818152915060208083019084810160005b8481101561286f57813587016101c0807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0838c0301121561294457600080fd5b61294d81613631565b6129598b8785016127f8565b81526129688b604085016127f8565b868201526129798b606085016127f8565b604082015261298b8b608085016127f8565b606082015260a0830135608082015260c083013560a082015260e083013560c08201526101008084013560e0830152610120808501358284015261014091508185013581840152506101608085013567ffffffffffffffff808211156129f057600080fd5b6129fe8f8b848a0101612bd7565b84860152610180935083870135915080821115612a1a57600080fd5b612a288f8b848a0101612bd7565b838601526101a0925082870135915080821115612a4457600080fd5b612a528f8b848a0101612bd7565b8486015285870135935080841115612a6957600080fd5b5050612a798d8984880101612bd7565b9083015250865250509282019290820190600101612904565b60008083601f840112612aa3578182fd5b50813567ffffffffffffffff811115612aba578182fd5b6020830191508360208083028501011115612ad457600080fd5b9250929050565b600082601f830112612aeb578081fd5b8151612af961282182613658565b818152915060208083019084810181840286018201871015612b1a57600080fd5b60005b8481101561286f57815184529282019290820190600101612b1d565b600082601f830112612b49578081fd5b8135612b5761282182613658565b818152915060208083019084810181840286018201871015612b7857600080fd5b60005b8481101561286f57813584529282019290820190600101612b7b565b60008083601f840112612ba8578182fd5b50813567ffffffffffffffff811115612bbf578182fd5b602083019150836020828501011115612ad457600080fd5b600082601f830112612be7578081fd5b8135612bf561282182613678565b9150808252836020828501011115612c0c57600080fd5b8060208401602084013760009082016020015292915050565b600082601f830112612c35578081fd5b8151612c4361282182613678565b9150808252836020828501011115612c5a57600080fd5b612c6b8160208401602086016136ba565b5092915050565b600060208284031215612c83578081fd5b81356114b6816136e6565b600060208284031215612c9f578081fd5b81516114b6816136e6565b60008060008060808587031215612cbf578283fd5b8451612cca816136e6565b602086015190945067ffffffffffffffff80821115612ce7578485fd5b612cf388838901612adb565b94506040870151915080821115612d08578384fd5b612d1488838901612adb565b93506060870151915080821115612d29578283fd5b50612d3687828801612c25565b91505092959194509250565b60008060008060008060008060a0898b031215612d5d578586fd5b8835612d68816136e6565b97506020890135612d78816136e6565b9650604089013567ffffffffffffffff80821115612d94578788fd5b612da08c838d01612a92565b909850965060608b0135915080821115612db8578586fd5b612dc48c838d01612a92565b909650945060808b0135915080821115612ddc578384fd5b50612de98b828c01612b97565b999c989b5096995094979396929594505050565b60008060008060008060a08789031215612e15578384fd5b8635612e20816136e6565b95506020870135612e30816136e6565b94506040870135935060608701359250608087013567ffffffffffffffff811115612e59578283fd5b612e6589828a01612b97565b979a9699509497509295939492505050565b60008060008060808587031215612e8c578182fd5b843567ffffffffffffffff80821115612ea3578384fd5b612eaf888389016128d5565b95506020870135915080821115612ec4578384fd5b612ed08883890161287a565b94506040870135915080821115612ee5578384fd5b612ef188838901612b39565b93506060870135915080821115612f06578283fd5b50612d3687828801612803565b600080600080600060a08688031215612f2a578283fd5b853567ffffffffffffffff80821115612f41578485fd5b612f4d89838a016128d5565b9650602088013595506040880135915080821115612f69578485fd5b612f7589838a0161287a565b94506060880135915080821115612f8a578283fd5b612f9689838a01612b39565b93506080880135915080821115612fab578283fd5b50612fb888828901612803565b9150509295509295909350565b60008060408385031215612fd7578182fd5b825167ffffffffffffffff80821115612fee578384fd5b612ffa86838701612adb565b9350602091508185015181811115613010578384fd5b85019050601f81018613613022578283fd5b805161303061282182613658565b81815283810190838501865b84811015613065576130538b888451890101612c25565b8452928601929086019060010161303c565b5096999098509650505050505050565b60008060208385031215613087578182fd5b823567ffffffffffffffff81111561309d578283fd5b6130a985828601612b97565b90969095509350505050565b6000806000604084860312156130c9578081fd5b833567ffffffffffffffff8111156130df578182fd5b6130eb86828701612b97565b909790965060209590950135949350505050565b600060a08284031215613110578081fd5b61311a60a0613631565b82518152602083015160208201526040830151604082015260608301516060820152608083015160808201528091505092915050565b600060208284031215613161578081fd5b5051919050565b6000806040838503121561317a578182fd5b505080516020909101519092909150565b73ffffffffffffffffffffffffffffffffffffffff169052565b6000815180845260208401935060208301825b828110156131d65781518652602095860195909101906001016131b8565b5093949350505050565b600081518084526131f88160208601602086016136ba565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6000825161323c8184602087016136ba565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525060a060408301526132c760a08301866131a5565b82810360608401526132d981866131a5565b83810360808501526132eb81866131e0565b9998505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff9384168152919092166020820152604081019190915260600190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b7fffffffff0000000000000000000000000000000000000000000000000000000091909116815260200190565b6000602082526114b660208301846131e0565b606081016004851061339d57fe5b938152602081019290925260409091015290565b606081016008851061339d57fe5b6000606082526133d360608301865161318b565b60208501516133e5608084018261318b565b5060408501516133f860a084018261318b565b50606085015161340b60c084018261318b565b50608085015160e083015260a0850151610100818185015260c08701519150610120828186015260e088015192506101408381870152828901519350610160925083838701528189015193506101809150838287015280890151935050806101a08601525061347e6101e08501836131e0565b8188015192507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0858203016101c08601526134b981846131e0565b91505085602085015283810360408501526134d481866131e0565b979650505050505050565b6000606082526134f360608301865161318b565b6020850151613505608084018261318b565b50604085015161351860a084018261318b565b50606085015161352b60c084018261318b565b50608085015160e083015260a0850151610100818185015260c08701519150610120828186015260e0880151925061014083818701528289015193506101609250838387015281890151935061018091508382870152808901519350506101c06101a081818801526135a16102208801866131e0565b848b015195507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa094508488820301838901526135dd81876131e0565b925050828a0151945083878303016101e08801526135fb82866131e0565b9250808a01519450505081858203016102008601526134b981846131e0565b90815260200190565b918252602082015260400190565b60405181810167ffffffffffffffff8111828210171561365057600080fd5b604052919050565b600067ffffffffffffffff82111561366e578081fd5b5060209081020190565b600067ffffffffffffffff82111561368e578081fd5b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60005b838110156136d55781810151838201526020016136bd565b838111156104c45750506000910152565b73ffffffffffffffffffffffffffffffffffffffff8116811461073457600080fdfea365627a7a72315820ebedf6ba0823da75dd29d928186748ec6baa07f40f145a90097baa22da29b56a6c6578706572696d656e74616cf564736f6c63430005100040
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000061935cbdd02287b511119ddb11aeb42f1593b7ef000000000000000000000000080bf510fcbf18b91105470639e9561022937712000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
-----Decoded View---------------
Arg [0] : _exchange (address): 0x61935CbDd02287B511119DDb11Aeb42F1593b7Ef
Arg [1] : _exchangeV2 (address): 0x080bf510FCbF18b91105470639e9561022937712
Arg [2] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 00000000000000000000000061935cbdd02287b511119ddb11aeb42f1593b7ef
Arg [1] : 000000000000000000000000080bf510fcbf18b91105470639e9561022937712
Arg [2] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Deployed Bytecode Sourcemap
1372:6769:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2206:4:37;;;;2184:10;:27;2180:182;;2227:124;2249:101;2326:10;2249:59;:101::i;:::-;2227:21;:124::i;:::-;1372:6769:0;2916:707;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;2916:707:0;;;;;;;;:::i;2233:172::-;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;2233:172:0;;;;;;;;:::i;827:20:34:-;;8:9:-1;5:2;;;30:1;27;20:12;5:2;827:20:34;;;:::i;:::-;;;;;;;;;;;;;;;;4367:1375:0;;;;;;;;;:::i;:::-;;;;;;;;;6746:1393;;;;;;;;;:::i;2778:274:2:-;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;2778:274:2;;;;;;;;:::i;:::-;;;;;;;;636:58;;8:9:-1;5:2;;;30:1;27;20:12;5:2;636:58:2;;;:::i;2044:56:1:-;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2044:56:1;;;:::i;1644:239:2:-;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;1644:239:2;;;;;;;;:::i;1097:329:34:-;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;1097:329:34;;;;;;;;:::i;700:58:2:-;;8:9:-1;5:2;;;30:1;27;20:12;5:2;700:58:2;;;:::i;1875:295:39:-;2005:12;1118:10;2076:50;;2140:13;2040:123;;;;;;;;;;;;;22:32:-1;26:21;;;22:32;6:49;;2040:123:39;;;49:4:-1;25:18;;61:17;;2040:123:39;182:15:-1;2040:123:39;;;;179:29:-1;;;;160:49;;;2040:123:39;-1:-1:-1;1875:295:39;;;:::o;1511:170:31:-;1654:9;1648:16;1641:4;1630:9;1626:20;1619:46;2916:707:0;3005:14;3022:23;3043:1;3022:9;;:20;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;3022:20:0;;:23;-1:-1:-1;;3022:23:0;:20;:23;;-1:-1:-1;3022:23:0:i;:::-;3005:40;-1:-1:-1;3077:42:0;3231:23;;;;;3227:390;;;3293:8;;:36;;;;;3270:20;;3293:8;;;:22;;:36;;3316:12;;3293:36;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;3293:36:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;3293:36:0;;;;;;;101:4:-1;97:9;90:4;84;80:15;76:31;69:5;65:43;126:6;120:4;113:20;0:138;3293:36:0;;;;;;;;;3270:59;-1:-1:-1;3347:26:0;;;3343:140;;3393:75;3415:52;:50;:52::i;3393:75::-;3496:13;3512:25;3534:2;3512:9;;:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;3512:21:0;;:25;-1:-1:-1;;3512:25:0;:21;:25;;-1:-1:-1;3512:25:0:i;:::-;3496:41;;3551:55;3573:5;3580:12;1079:2:37;3551:21:0;:55::i;:::-;3227:390;;;2916:707;;;;:::o;2233:172::-;960:22:34;:20;:22::i;:::-;2369:29:0;2391:6;2369:9;;:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;2369:21:0;;:29;-1:-1:-1;;2369:29:0;:21;:29;;-1:-1:-1;2369:29:0:i;:::-;2233:172;;;:::o;827:20:34:-;;;;;;:::o;4367:1375:0:-;4630:23;4667:32;4788:21;4812:96;4858:13;4885;4812:32;:96::i;:::-;4788:120;;5131:99;5163:6;5183:13;5210:10;5131:18;:99::i;:::-;5051:179;;-1:-1:-1;5051:179:0;-1:-1:-1;5321:31:0;;;5317:200;;;5368:138;5390:115;5449:15;5482:9;5390:41;:115::i;5368:138::-;5603:38;:13;5625:15;5603:38;:21;:38;:::i;:::-;5587:54;;5699:36;5721:13;5699:21;:36::i;:::-;4367:1375;;;;;;;;:::o;6746:1393::-;7045:23;7082:32;7203:21;7227:96;7273:13;7300;7227:32;:96::i;:::-;7203:120;;7520:107;7554:6;7574:19;7607:10;7520:20;:107::i;:::-;7440:187;;-1:-1:-1;7440:187:0;-1:-1:-1;7718:31:0;;;7714:200;;;7765:138;7787:115;7846:15;7879:9;7787:41;:115::i;7765:138::-;8000:38;:13;8022:15;8000:38;:21;:38;:::i;:::-;7984:54;;8096:36;8118:13;8096:21;:36::i;:::-;6746:1393;;;;;;;;;:::o;2778:274:2:-;3023:22;2778:274;;;;;;;;;;:::o;636:58::-;;;:::o;2044:56:1:-;;;:::o;1644:239:2:-;1860:16;1644:239;;;;;;;;:::o;1097:329:34:-;960:22;:20;:22::i;:::-;1193;;;1189:231;;1231:70;1253:47;:45;:47::i;1231:70::-;1189:231;;;1332:5;:16;;;;;;;;;;;;1367:42;;1332:16;;1388:10;;1367:42;;1332:5;1367:42;1189:231;1097:329;:::o;700:58:2:-;;;:::o;16814:871:27:-;16934:13;16978:5;16986:1;16978:9;16967:1;:8;:20;16963:290;;;17003:239;17025:216;17087:87;17192:1;:8;17218:5;17226:1;17218:9;17025:44;:216::i;17003:239::-;-1:-1:-1;17329:2:27;17426:13;;;;;17420:20;17320:11;;;17579:66;17567:79;16814:871;;;;;:::o;1276:191:5:-;1397:63;;;22:32:-1;6:49;;1397:63:5;;;;;;49:4:-1;25:18;;61:17;;1397:63:5;182:15:-1;1420:39:5;179:29:-1;160:49;;1276:191:5;:::o;10753:1071:27:-;10874:14;10919:5;10927:2;10919:10;10908:1;:8;:21;10904:321;;;10945:269;10967:246;11029:89;11136:1;:8;11162:5;11170:2;11162:10;10967:44;:246::i;10945:269::-;-1:-1:-1;11726:13:27;11471:2;11726:13;11720:20;11742:42;11716:69;;10753:1071::o;1194:338:9:-;1347:121;;1323:21;;1383:31;;1347:121;;1428:7;;1449:9;;1347:121;;;;;;;;22:32:-1;26:21;;;22:32;6:49;;1347:121:9;;;49:4:-1;25:18;;61:17;;1347:121:9;182:15:-1;1347:121:9;;;;179:29:-1;;;;160:49;;;1347:121:9;-1:-1:-1;1478:47:9;1509:5;1347:121;1478:30;:47::i;1432:255:34:-;1526:5;;;;1512:10;:19;1508:173;;1650:5;;1547:123;;1569:100;;1622:10;;1650:5;;1569:35;:100::i;1547:123::-;1432:255::o;3587:224:36:-;3701:103;:9;3745:4;3764:10;3788:6;3701:103;:22;:103;:::i;:::-;3587:224;;:::o;2732:1428:37:-;2956:20;;3059;;2902;;2956;3048:31;;3044:210;;3095:148;3117:125;3183:7;3208:13;:20;3117:48;:125::i;3095:148::-;3420:9;;-1:-1:-1;3445:9:37;3440:597;3465:7;3460:1;:12;3440:597;;3493:20;3516:13;3530:1;3516:16;;;;;;;;;;;;;;3493:39;;3622:12;3607;:27;3603:224;;;3654:158;3676:135;3747:12;3781;3676:49;:135::i;3654:158::-;3939:34;:12;3960;3939:34;:20;:34;:::i;:::-;3924:49;;3987:13;4001:1;3987:16;;;;;;;;;;;;;;:25;;:39;4013:12;3987:39;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;-1:-1;;3474:3:37;;3440:597;;;;4089:4;;;;;;;;;;;:12;;;4108;4089:34;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;4089:34:37;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;-1:-1;;;;;;2732:1428:37;;;;:::o;6846:2627:1:-;7034:28;7076:37;7138:19;7160:53;7180:8;;;;;;;;;;;:30;;;:32;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;7180:32:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;7180:32:1;;;;;;;101:4:-1;97:9;90:4;84;80:15;76:31;69:5;65:43;126:6;120:4;113:20;0:138;7180:32:1;;;;;;;;;7160:11;;:53;:19;:53;:::i;:::-;7138:75;-1:-1:-1;7251:43:1;7223:25;7305:2162;7330:6;:13;7325:1;:18;7305:2162;;7453:6;7460:1;7453:9;;;;;;;;;;;;;;:26;;;7483:1;7453:31;:66;;;;7488:6;7495:1;7488:9;;;;;;;;;;;;;;:26;;;7518:1;7488:31;7453:66;7449:113;;;7539:8;;7449:113;7628:37;7668:127;7755:21;7766:6;7773:1;7766:9;;;;;;;;;;;;;;7755:10;:21::i;:::-;:39;;7783:11;7755:39;;;7779:1;7755:39;7668:61;:14;7708:20;7668:61;:39;:61;:::i;:::-;:86;:127;:86;:127;:::i;:::-;7628:167;;7913:24;7940:38;7976:1;7940:6;7947:1;7940:9;;;;;;;;;;;;;;:24;;;:35;;:38;;;;:::i;:::-;7913:65;-1:-1:-1;7992:20:1;;8065:39;;;;;;;;8061:217;;;8139:40;8176:2;8139:6;8146:1;8139:9;;;;;;;;;;;;;;:24;;;:36;;:40;;;;:::i;:::-;8213:50;;;;;8124:55;;-1:-1:-1;8213:35:1;;;;;;:50;;8257:4;;8213:50;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;8213:50:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;8213:50:1;;;;;;;101:4:-1;97:9;90:4;84;80:15;76:31;69:5;65:43;126:6;120:4;113:20;0:138;8213:50:1;;;;;;;;;8197:66;;8061:217;8310:23;8351:32;8400:141;8440:6;8447:1;8440:9;;;;;;;;;;;;;;8467:10;8478:1;8467:13;;;;;;;;;;;;;;8498:29;8400:22;:141::i;:::-;8292:249;;;;8675:18;8654:39;;;:17;:39;;;;8650:335;;;8736:50;;;;;8713:20;;8736:35;;;;;;:50;;8780:4;;8736:50;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;8736:50:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;8736:50:1;;;;;;;101:4:-1;97:9;90:4;84;80:15;76:31;69:5;65:43;126:6;120:4;113:20;0:138;8736:50:1;;;;;;;;;8713:73;-1:-1:-1;8831:139:1;8871:35;8713:73;8892:13;8871:35;:20;:35;:::i;:::-;8928:24;8831:18;:139::i;:::-;8804:166;;8650:335;;8999:62;9036:24;8999:6;9006:1;8999:9;;;;;;;;;;;;;;:24;;;:36;;:62;;;;:::i;:::-;9099;:20;9145:15;9099:62;:45;:62;:::i;:::-;9076:85;-1:-1:-1;9207:80:1;:29;9262:24;9207:80;:54;:80;:::i;:::-;9175:112;;9403:14;9379:20;:38;9375:82;;9437:5;;;;;;;;9375:82;7305:2162;;;;;;;7345:3;;7305:2162;;;;6846:2627;;;;;;;;:::o;2111:296:5:-;2245:12;1216:10;2316:29;;2359:9;2382:8;2280:120;;;;;;;;;;;;;;22:32:-1;26:21;;;22:32;6:49;;2280:120:5;;;49:4:-1;25:18;;61:17;;2280:120:5;182:15:-1;2280:120:5;;;;179:29:-1;;;;160:49;;;2280:120:5;-1:-1:-1;2111:296:5;;;;:::o;965:364:32:-;1051:7;1082:1;1078;:5;1074:227;;;1099:191;1121:168;1178:59;1255:1;1274;1121:39;:168::i;1099:191::-;-1:-1:-1;1317:5:32;;;965:364::o;4302:346:37:-;4446:18;;4442:200;;4515:4;;:29;;;;;:4;;;;;:13;;:29;;4529:14;;4515:29;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;4515:29:37;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;-1:-1;;4596:35:37;;:10;;-1:-1:-1;4596:35:37;;;;;-1:-1:-1;4616:14:37;;4596:35;;;;4616:14;4596:10;:35;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;13421:2768:1;13825:13;;13616:28;;;;13748:43;;13616:28;13848:2077;13873:12;13868:1;:17;13848:2077;;13994:6;14001:1;13994:9;;;;;;;;;;;;;;:26;;;14024:1;13994:31;:66;;;;14029:6;14036:1;14029:9;;;;;;;;;;;;;;:26;;;14059:1;14029:31;13994:66;13990:113;;;14080:8;;13990:113;14117:37;14157:75;:19;14202:29;14157:75;:44;:75;:::i;:::-;14117:115;;14350:24;14377:38;14413:1;14377:6;14384:1;14377:9;;;;;;;:38;14350:65;-1:-1:-1;14429:20:1;;14502:39;;;;;;;;14498:217;;;14576:40;14613:2;14576:6;14583:1;14576:9;;;;;;;:40;14650:50;;;;;14561:55;;-1:-1:-1;14650:35:1;;;;;;:50;;14694:4;;14650:50;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;14650:50:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;14650:50:1;;;;;;;101:4:-1;97:9;90:4;84;80:15;76:31;69:5;65:43;126:6;120:4;113:20;0:138;14650:50:1;;;;;;;;;14634:66;;14498:217;14747:23;14788:32;14837:140;14876:6;14883:1;14876:9;;;;;;;;;;;;;;14903:10;14914:1;14903:13;;;;;;;;;;;;;;14934:29;14837:21;:140::i;:::-;14729:248;;;;15111:18;15090:39;;;:17;:39;;;;15086:335;;;15172:50;;;;;15149:20;;15172:35;;;;;;:50;;15216:4;;15172:50;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;15172:50:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;15172:50:1;;;;;;;101:4:-1;97:9;90:4;84;80:15;76:31;69:5;65:43;126:6;120:4;113:20;0:138;15172:50:1;;;;;;;;;15149:73;-1:-1:-1;15267:139:1;15307:35;15149:73;15328:13;15307:35;:20;:35;:::i;15267:139::-;15240:166;;15086:335;;15435:62;15472:24;15435:6;15442:1;15435:9;;;;;;;:62;15535;:20;15581:15;15535:62;:45;:62;:::i;:::-;15512:85;-1:-1:-1;15643:80:1;:29;15698:24;15643:80;:54;:80;:::i;:::-;15611:112;;15856:19;15823:29;:52;15819:96;;15895:5;;;;;;;;15819:96;13848:2077;;;;;;;13887:3;;13848:2077;;;;15971:19;15939:29;:51;15935:248;;;16006:166;16028:143;16091:19;16128:29;16028:45;:143::i;16006:166::-;13421:2768;;;;;;;;:::o;669:159:30:-;787:34;;;;;;;;;;;;;;;;;669:159;:::o;1292:378:28:-;1480:12;1232:10;1551:37;;1602:9;1625:6;1645:8;1515:148;;;;;;;;;;;;;;;22:32:-1;26:21;;;22:32;6:49;;1515:148:28;;;49:4:-1;25:18;;61:17;;1515:148:28;182:15:-1;1515:148:28;;;;179:29:-1;;;;160:49;;;1515:148:28;-1:-1:-1;1292:378:28;;;;;;:::o;3779:571:9:-;3911:15;3928:23;3955:6;:11;;3967:8;3955:21;;;;;;;;;;;;;;;;;;;;;;;14:1:-1;21;16:31;;;;75:4;69:11;64:16;;144:4;140:9;133:4;115:16;111:27;107:43;104:1;100:51;94:4;87:65;169:16;166:1;159:27;225:16;222:1;215:4;212:1;208:12;193:49;7:242;;16:31;36:4;31:9;;7:242;;3910:66:9;;;;3990:10;3986:315;;;4020:17;;4016:67;;4062:7;;;;4016:67;4100:10;:17;4121:2;4100:23;4096:195;;;4143:14;4160:35;4181:10;4193:1;4160:20;:35::i;:::-;4143:52;;4217:6;4227:1;4217:11;4213:64;;;4252:7;;;;;4213:64;4096:195;;4310:33;4332:10;4310:21;:33::i;387:276:30:-;511:12;183:10;582:25;;621:6;641:5;546:110;;;;;;;;;;1597:1367:36;1758:11;1754:48;;1785:7;;1754:48;1812:14;1829:23;:9;1812:14;1829:23;:20;:23;:::i;:::-;1812:40;-1:-1:-1;1880:53:36;;;1891:42;1880:53;;:123;;-1:-1:-1;1949:54:36;;;1960:43;1949:54;1880:123;1863:1095;;;2028:108;:9;2074:4;2096:2;2116:6;2028:108;:28;:108;:::i;:::-;1863:1095;;;2157:54;;;2168:43;2157:54;2153:805;;;2227:109;:9;2274:4;2296:2;2316:6;2227:109;:29;:109;:::i;2153:805::-;2357:56;;;2368:45;2357:56;2353:605;;;2429:111;:9;2478:4;2500:2;2520:6;2429:111;:31;:111;:::i;2353:605::-;2561:53;;;2572:42;2561:53;2557:401;;;2630:108;:9;2676:4;2698:2;2718:6;2630:108;:28;:108;:::i;2557:401::-;2759:53;;;2770:42;2759:53;2755:203;;2828:119;2850:96;2925:7;2850:57;:96::i;2828:119::-;1597:1367;;;;;:::o;2176:342:39:-;2332:12;1280:10;2403:38;;2455:13;2482:19;2367:144;;;;;;;;;;1537:332;1688:12;941:10;1759:39;;1812:14;1840:12;1723:139;;;;;;;;;;122:448:32;208:7;235:6;231:45;;-1:-1:-1;264:1:32;257:8;;231:45;297:5;;;301:1;297;:5;:1;316:5;;;;;:10;312:234;;342:193;364:170;421:61;500:1;519;364:39;:170::i;21381:229:1:-;21477:4;21537:1;21504:5;:23;;;:30;:34;:99;;;;-1:-1:-1;21542:23:1;;;;21583:20;;21542:37;;21577:1;21542:37;:34;:37;:::i;:::-;:61;;;21497:106;21381:229;-1:-1:-1;;21381:229:1:o;3970:2376::-;4171:23;4208:32;4324:5;:14;;;4342:1;4324:19;:107;;;;4359:72;4385:5;:23;;;4410:5;:20;;;4359:25;:72::i;:::-;4307:1972;;;4516:51;;:::i;:::-;4570:128;4605:5;4628:29;4675:9;4570:17;:128::i;:::-;4516:182;;4731:100;4797:17;:33;;;4731:17;:40;;;:65;;:100;;;;:::i;:::-;5024:30;;;;4958:40;;4713:118;;-1:-1:-1;4958:97:1;;:40;:97;:65;:97;:::i;:::-;4931:124;;4307:1972;;;;5097:72;5123:5;:23;;;5148:5;:20;;;5097:25;:72::i;:::-;5093:1186;;;5441:22;;;;5512:14;;;;5364:28;;5395:193;;5481:46;;5441:22;;5481:46;:30;:46;:::i;:::-;5545:29;5395:28;:193::i;:::-;5364:224;;5603:51;;:::i;:::-;5657:119;5692:5;5715:20;5753:9;5657:17;:119::i;:::-;5603:173;;5880:157;6003:17;:33;;;5880:97;5946:17;:30;;;5880:17;:40;;;:65;;:97;;;;:::i;:::-;:122;:157;:122;:157;:::i;:::-;6079:40;;5862:175;;-1:-1:-1;6079:40:1;-1:-1:-1;5093:1186:1;;-1:-1:-1;5093:1186:1;;6178:90;6200:67;6243:5;:23;;;6200:42;:67::i;6178:90::-;3970:2376;;;;;;:::o;1724:136:32:-;1809:7;1844:1;1839;:6;;:14;;1852:1;1839:14;;;-1:-1:-1;1848:1:32;;1832:21;-1:-1:-1;1724:136:32:o;1335:383::-;1421:7;1456:5;;;1475;;;1471:223;;;1496:187;1518:164;1575:55;1648:1;1667;731:322:33;884:12;196:10;955:28;;997:9;1020:1;1035;919:127;;;;;;;;;;;9968:2660:1;10168:23;10205:32;10315:5;:14;;;10333:1;10315:19;:107;;;;10350:72;10376:5;:23;;;10401:5;:20;;;10350:25;:72::i;:::-;10298:2263;;;10515:37;10555:169;10601:5;:22;;;10641:5;:22;;;10681:29;10555:28;:169::i;10298:2263::-;11392:72;11418:5;:23;;;11443:5;:20;;;11392:25;:72::i;:::-;11388:1173;;;11548:37;11588:193;11634:5;:22;;;11674:46;11705:5;:14;;;11674:5;:22;;;:30;;:46;;;;:::i;11588:193::-;11548:233;;11862:51;;:::i;:::-;11916:128;11951:5;11974:29;12021:9;11916:17;:128::i;:::-;11862:182;;12077:100;12143:17;:33;;;12077:17;:40;;;:65;;:100;;;;:::i;:::-;12370:30;;;;12304:40;;12059:118;;-1:-1:-1;12304:97:1;;:40;:97;:65;:97;:::i;:::-;12277:124;;11388:1173;;;;1473:355:5;1636:12;932:10;1707:34;;1755:22;1791:20;1671:150;;;;;;;;;;15929:220:27;16050:14;16097:21;16109:1;16112:5;16097:11;:21::i;4144:563:36:-;4307:13;4323:25;:9;4345:2;4323:25;:21;:25;:::i;:::-;4307:41;-1:-1:-1;4390:21:36;;;4406:4;4390:21;4386:315;;;4427:103;4467:5;4490:2;4510:6;4427:22;:103::i;4386:315::-;4561:129;4605:5;4628:4;4650:2;4670:6;4561:26;:129::i;5026:604::-;5194:6;5204:1;5194:11;5190:163;;5221:121;5243:98;5321:6;5243:60;:98::i;5221:121::-;5392:13;5408:25;:9;5430:2;5408:25;:21;:25;:::i;:::-;5392:41;-1:-1:-1;5443:15:36;5461:25;:9;5483:2;5461:25;:21;:25;:::i;:::-;5526:97;;;;;5443:43;;-1:-1:-1;5526:32:36;;;;;;:97;;5572:4;;5590:2;;5443:43;;5526:97;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;5526:97:36;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;5526:97:36;;;;5026:604;;;;;;:::o;5951:1014::-;6186:13;6213:20;6247:23;6284:17;6338:36;6354:1;6357:9;:16;6338:9;:15;;:36;;;;;:::i;:::-;6314:122;;;;;;;;;;;;;;6172:264;;;;;;;;6512:14;6529:6;:13;6512:30;;6552:29;6598:6;6584:21;;;;;;;;;;;;;;;;;;;;;;29:2:-1;21:6;17:15;117:4;105:10;97:6;88:34;136:17;;-1:-1;6584:21:36;-1:-1:-1;6552:53:36;-1:-1:-1;6620:9:36;6615:106;6640:6;6635:1;:11;6615:106;;6685:25;6703:6;6685;6692:1;6685:9;;;;;;;;;;;;;;:17;;:25;;;;:::i;:::-;6667:12;6680:1;6667:15;;;;;;;;;;;;;;;;;:43;6648:3;;6615:106;;;-1:-1:-1;6816:142:36;;;;;:37;;;;;;:142;;6867:4;;6885:2;;6901:3;;6918:12;;6944:4;;6816:142;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;6816:142:36;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;6816:142:36;;;;5951:1014;;;;;;;;;;:::o;7294:702::-;7492:30;7524;7582:36;7598:1;7601:9;:16;7582:9;:15;;:36;;;;;:::i;:::-;7558:104;;;;;;;;;;;;;;7732:22;;7491:171;;-1:-1:-1;7491:171:36;-1:-1:-1;7706:23:36;7764:226;7789:15;7784:1;:20;7764:226;;7825:154;7855:15;7871:1;7855:18;;;;;;;;;;;;;;7891:4;7913:2;7933:32;7948:13;7962:1;7948:16;;;;;;;;;;;;;;7933:6;:14;;:32;;;;:::i;:::-;7825:12;:154::i;:::-;7806:3;;7764:226;;;;7294:702;;;;;;;:::o;1020:260:38:-;1133:12;789:10;1204:38;;1256:7;1168:105;;;;;;;;;20253:920:1;20407:4;;20450:24;:10;20407:4;20450:24;:21;:24;:::i;:::-;20427:47;-1:-1:-1;20484:20:1;20507:24;:10;20484:20;20507:24;:21;:24;:::i;:::-;20484:47;-1:-1:-1;20563:42:1;20643:43;20715:29;;;;;;:68;;-1:-1:-1;20748:35:1;;;;;;;;20715:68;20714:156;;;;-1:-1:-1;20801:29:1;;;;;;;;;:68;;-1:-1:-1;20834:35:1;;;;;;;;20801:68;20697:470;;;20950:14;20967:26;:10;20990:2;20967:26;:22;:26;:::i;:::-;20950:43;-1:-1:-1;21007:14:1;21024:26;:10;21047:2;21024:26;:22;:26;:::i;:::-;21007:43;;21082:6;21072:16;;:6;:16;;;21064:25;;;;;;;;;;20697:470;21127:29;:10;21145;21127:29;:17;:29;:::i;:::-;21120:36;;;;;;;;20697:470;20253:920;;;;;;;;:::o;2948:540::-;3122:45;;:::i;:::-;3187:17;3198:5;3187:10;:17::i;:::-;3183:176;;;3227:121;3264:5;3287:20;3325:9;3227:19;:121::i;:::-;3220:128;;;;3183:176;3376:105;3409:5;3428:20;3462:9;3376:19;:105::i;:::-;3369:112;2948:540;-1:-1:-1;;;;2948:540:1:o;3762:545:14:-;3925:21;4165:104;4257:11;4165:70;4212:22;4257:11;4232:1;4212:22;:19;:22;:::i;:::-;4165:25;:9;4183:6;4165:25;:17;:25;:::i;:70::-;:91;:104;:91;:104;:::i;1834:271:5:-;1956:12;1070:10;2027:30;;2071:17;1991:107;;;;;;;;;14133:679:27;14254:14;14299:5;14307:2;14299:10;14288:1;:8;:21;14284:297;;;14325:245;14347:222;14409:92;14519:1;:8;14545:5;14553:2;14545:10;14347:44;:222::i;14325:245::-;-1:-1:-1;14759:13:27;14661:2;14759:13;14753:20;;14133:679::o;1868:324:9:-;2014:114;;1990:21;;2050:32;;2014:114;;2096:2;;2112:6;;2014:114;;;;2577:372;2749:136;;2725:21;;2785:36;;2749:136;;2835:4;;2853:2;;2869:6;;2749:136;;;;;;;;22:32:-1;26:21;;;22:32;6:49;;2749:136:9;;;49:4:-1;25:18;;61:17;;2749:136:9;182:15:-1;2749:136:9;;;;179:29:-1;;;;160:49;;;2749:136:9;-1:-1:-1;2895:47:9;2926:5;2749:136;2895:30;:47::i;1286:267:38:-;1402:12;952:10;1473:43;;1530:6;1437:109;;;;;;;;;6475:1101:27;6609:19;6789:2;6782:4;:9;6778:261;;;6807:221;6829:198;6891:80;6989:4;7011:2;6829:44;:198::i;6807:221::-;7057:1;:8;7052:2;:13;7048:271;;;7081:227;7103:204;7165:82;7265:2;7285:1;:8;7103:44;:204::i;7081:227::-;7411:4;7406:2;:9;7396:20;;;;;;;;;;;;;;;;;;;;;;;;;21:6:-1;;104:10;7396:20:27;87:34:-1;135:17;;-1:-1;7396:20:27;;7387:29;;7426:120;7447:23;:6;:21;:23::i;:::-;7505:4;7484:18;:1;:16;:18::i;:::-;:25;7523:6;:13;7426:7;:120::i;10136:403::-;10257:10;10486:3;:10;10472:3;:10;:24;:60;;;;-1:-1:-1;;10518:14:27;;;;;;;10500;;;;;;;;;;:32;;10136:403::o;16676:1830:1:-;16852:45;;:::i;:::-;16960:32;;:::i;:::-;16995:692;;;;;;;;17041:5;:18;;;16995:692;;;;;;17087:5;:18;;;16995:692;;;;;;17140:5;:25;;;16995:692;;;;;;17194:5;:19;;;16995:692;;;;;;17245:5;:22;;;16995:692;;;;17299:5;:22;;;16995:692;;;;17456:1;16995:692;;;;17481:1;16995:692;;;;17519:5;:27;;;16995:692;;;;17566:5;:10;;;16995:692;;;;17606:5;:20;;;16995:692;;;;17656:5;:20;;;16995:692;;;16960:727;;17745:30;17834:1;17814:33;;;:42;;;;17870:7;17891:20;17925:9;17778:166;;;;;;;;;;;;;;;22:32:-1;26:21;;;22:32;6:49;;17778:166:1;;;49:4:-1;25:18;;61:17;;17778:166:1;182:15:-1;17778:166:1;;;;179:29:-1;;;;160:49;;;17982:11:1;;18049:32;;17778:166;;-1:-1:-1;17982:11:1;;;;;-1:-1:-1;;18022:23:1;;17982:11;;18049:32;;17778:166;;18049:32;;;;;;;;;;;;;;;;;;14:1:-1;21;16:31;;;;75:4;69:11;64:16;;144:4;140:9;133:4;115:16;111:27;107:43;104:1;100:51;94:4;87:65;169:16;166:1;159:27;225:16;222:1;215:4;212:1;208:12;193:49;7:242;;16:31;36:4;31:9;;7:242;;18004:77:1;;;;18095:10;18091:304;;;18128:10;:17;18149:3;18128:24;18121:32;;;;18353:10;18342:42;;;;;;;;;;;;;;18304:34;;;18267:117;;;18091:304;-1:-1:-1;;;;;16676:1830:1;;;;;:::o;18904:887::-;19080:45;;:::i;:::-;19221:162;;19188:30;;19257:40;;19221:162;;19311:5;;19330:20;;19364:9;;19221:162;;;;;;;;22:32:-1;26:21;;;22:32;6:49;;19221:162:1;;;49:4:-1;25:18;;61:17;;19221:162:1;182:15:-1;19221:162:1;;;;179:29:-1;;;;160:49;;;19421:8:1;;19485:32;;19221:162;;-1:-1:-1;19421:8:1;;;;;-1:-1:-1;;19458:23:1;;19421:8;;19485:32;;19221:162;;19485:32;;;;;;;;;;;;;;;;;;14:1:-1;21;16:31;;;;75:4;69:11;64:16;;144:4;140:9;133:4;115:16;111:27;107:43;104:1;100:51;94:4;87:65;169:16;166:1;159:27;225:16;222:1;215:4;212:1;208:12;193:49;7:242;;16:31;36:4;31:9;;7:242;;19440:77:1;;;;19531:10;19527:153;;;19564:10;:17;19585:3;19564:24;19557:32;;;;19628:10;19617:52;;;;;;;;;;;;;;19603:66;;19527:153;-1:-1:-1;;;;18904:887:1;;;;;:::o;576:383:32:-;662:7;689:6;685:223;;711:186;733:163;790:54;862:1;881;733:39;:163::i;711:186::-;917:9;933:1;929;:5;;;;;;;576:383;-1:-1:-1;;;;576:383:32:o;1403:228:27:-;1582:2;1571:14;;1403:228::o;1870:4297::-;2020:2;2011:6;:11;2007:4154;;;2309:1;2299:6;2295:2;2291:15;2286:3;2282:25;2278:33;2360:4;2356:9;2347:6;2341:13;2337:29;2409:4;2402;2396:11;2392:22;2450:1;2447;2444:8;2438:4;2431:22;;;;2248:219;;;2571:4;2561:6;:14;2557:59;;;2595:7;;2557:59;3305:4;3296:6;:13;3292:2859;;;3631:2;3623:6;3619:15;3609:25;;3679:6;3671;3667:19;3729:6;3723:4;3719:17;4036:4;4030:11;4304:198;4322:4;4314:6;4311:16;4304:198;;;4370:13;;4357:27;;4431:2;4467:13;;;;4419:15;;;;4304:198;;;4571:18;;-1:-1:-1;3338:1269:27;;;4852:2;4844:6;4840:15;4830:25;;4900:6;4892;4888:19;4950:6;4944:4;4940:17;5260:6;5254:13;5839:191;5856:4;5850;5846:15;5839:191;;;5904:11;;5891:25;;5949:13;;;;;5995;;;;5839:191;;;6100:19;;-1:-1:-1;;1870:4297:27;;;:::o;1372:6769:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;5:130:-1:-;72:20;;97:33;72:20;97:33;;619:731;;744:3;737:4;729:6;725:17;721:27;711:2;;-1:-1;;752:12;711:2;799:6;786:20;821:88;836:72;901:6;836:72;;;821:88;;;937:21;;;812:97;-1:-1;981:4;994:14;;;;969:17;;;1083;;;1074:27;;;;1071:36;-1:-1;1068:2;;;1120:1;;1110:12;1068:2;1145:1;1130:214;1155:6;1152:1;1149:13;1130:214;;;371:6;358:20;383:41;418:5;383:41;;;1223:58;;1295:14;;;;1323;;;;1177:1;1170:9;1130:214;;;1134:14;;;;;704:646;;;;;2091:693;;2213:3;2206:4;2198:6;2194:17;2190:27;2180:2;;-1:-1;;2221:12;2180:2;2268:6;2255:20;2290:85;2305:69;2367:6;2305:69;;2290:85;2403:21;;;2281:94;-1:-1;2447:4;2460:14;;;;2435:17;;2555:1;2540:238;2565:6;2562:1;2559:13;2540:238;;;2672:42;2710:3;2447:4;2648:3;2635:17;2439:6;2623:30;;2672:42;;;2660:55;;2447:4;2729:14;;;;2757;;;;;2587:1;2580:9;2540:238;;2824:735;;2960:3;2953:4;2945:6;2941:17;2937:27;2927:2;;-1:-1;;2968:12;2927:2;3015:6;3002:20;3037:99;3052:83;3128:6;3052:83;;3037:99;3164:21;;;3028:108;-1:-1;3208:4;3221:14;;;;3196:17;;;3316:1;3301:252;3326:6;3323:1;3320:13;3301:252;;;3409:3;3396:17;3200:6;3384:30;7872:6;;7851:19;3384:30;7855:3;7851:19;;7847:32;7844:2;;;3316:1;;7882:12;7844:2;7910:22;7872:6;7910:22;;;8022:49;8067:3;3208:4;3384:30;;8022:49;;;8004:16;7997:75;8174:49;8219:3;8195:22;3384:30;8195:22;8174:49;;;3208:4;8160:5;8156:16;8149:75;8333:49;8378:3;8354:22;3384:30;8354:22;8333:49;;;8195:22;8319:5;8315:16;8308:75;8486:49;8531:3;8507:22;3384:30;8507:22;8486:49;;;8354:22;8472:5;8468:16;8461:75;8664:22;3384:30;8664:22;10552:20;8507:22;8629:5;8625:16;8618:75;8821:22;3384:30;8821:22;10552:20;8664:22;8786:5;8782:16;8775:75;8970:22;3384:30;8970:22;10552:20;8821:22;8935:5;8931:16;8924:75;9119:22;;3384:30;9119:22;10552:20;8970:22;9084:5;9080:16;9073:75;9283:22;;3384:30;9283:22;10552:20;9119:22;9246:5;9242:18;9235:77;9430:22;;;;3384:30;9430:22;10552:20;9283:22;9393:5;9389:18;9382:77;;9543:19;;3384:30;9543:19;9530:33;9583:18;;9575:6;9572:30;9569:2;;;3316:1;;9605:12;9569:2;9652:54;9702:3;3208:4;9693:6;3384:30;9678:22;;9652:54;;;9430:22;9636:5;9632:18;9625:82;9791:19;;;;3384:30;9791:19;9778:33;9764:47;;9583:18;9823:6;9820:30;9817:2;;;3316:1;;9853:12;9817:2;9900:54;9950:3;3208:4;9941:6;3384:30;9926:22;;9900:54;;;9543:19;9884:5;9880:18;9873:82;10042:19;;;;3384:30;10042:19;10029:33;10015:47;;9583:18;10074:6;10071:30;10068:2;;;3316:1;;10104:12;10068:2;10151:54;10201:3;3208:4;10192:6;3384:30;10177:22;;10151:54;;;9791:19;10135:5;10131:18;10124:82;7872:6;3384:30;10293:19;10280:33;10266:47;;9583:18;10325:6;10322:30;10319:2;;;3316:1;;10355:12;10319:2;;;10402:54;10452:3;3208:4;10443:6;3384:30;10428:22;;10402:54;;;10382:18;;;10375:82;-1:-1;3421:69;;-1:-1;;3504:14;;;;3532;;;;3348:1;3341:9;3301:252;;3585:352;;;3715:3;3708:4;3700:6;3696:17;3692:27;3682:2;;-1:-1;;3723:12;3682:2;-1:-1;3753:20;;3793:18;3782:30;;3779:2;;;-1:-1;;3815:12;3779:2;3859:4;3851:6;3847:17;3835:29;;3910:3;3859:4;;3894:6;3890:17;3851:6;3876:32;;3873:41;3870:2;;;3927:1;;3917:12;3870:2;3675:262;;;;;;3963:714;;4087:3;4080:4;4072:6;4068:17;4064:27;4054:2;;-1:-1;;4095:12;4054:2;4135:6;4129:13;4157:76;4172:60;4225:6;4172:60;;4157:76;4261:21;;;4148:85;-1:-1;4305:4;4318:14;;;;4293:17;;;4407;;;4398:27;;;;4395:36;-1:-1;4392:2;;;4444:1;;4434:12;4392:2;4469:1;4454:217;4479:6;4476:1;4473:13;4454:217;;;10700:13;;4547:61;;4622:14;;;;4650;;;;4501:1;4494:9;4454:217;;4703:707;;4820:3;4813:4;4805:6;4801:17;4797:27;4787:2;;-1:-1;;4828:12;4787:2;4875:6;4862:20;4897:80;4912:64;4969:6;4912:64;;4897:80;5005:21;;;4888:89;-1:-1;5049:4;5062:14;;;;5037:17;;;5151;;;5142:27;;;;5139:36;-1:-1;5136:2;;;5188:1;;5178:12;5136:2;5213:1;5198:206;5223:6;5220:1;5217:13;5198:206;;;10552:20;;5291:50;;5355:14;;;;5383;;;;5245:1;5238:9;5198:206;;5432:336;;;5546:3;5539:4;5531:6;5527:17;5523:27;5513:2;;-1:-1;;5554:12;5513:2;-1:-1;5584:20;;5624:18;5613:30;;5610:2;;;-1:-1;;5646:12;5610:2;5690:4;5682:6;5678:17;5666:29;;5741:3;5690:4;5721:17;5682:6;5707:32;;5704:41;5701:2;;;5758:1;;5748:12;5777:432;;5874:3;5867:4;5859:6;5855:17;5851:27;5841:2;;-1:-1;;5882:12;5841:2;5929:6;5916:20;5951:60;5966:44;6003:6;5966:44;;5951:60;5942:69;;6031:6;6024:5;6017:21;6135:3;6067:4;6126:6;6059;6117:16;;6114:25;6111:2;;;6152:1;;6142:12;6111:2;38743:6;6067:4;6059:6;6055:17;6067:4;6093:5;6089:16;38720:30;38799:1;38781:16;;;6067:4;38781:16;38774:27;6093:5;5834:375;-1:-1;;5834:375;6218:434;;6326:3;6319:4;6311:6;6307:17;6303:27;6293:2;;-1:-1;;6334:12;6293:2;6374:6;6368:13;6396:60;6411:44;6448:6;6411:44;;6396:60;6387:69;;6476:6;6469:5;6462:21;6580:3;6512:4;6571:6;6504;6562:16;;6559:25;6556:2;;;6597:1;;6587:12;6556:2;6607:39;6639:6;6512:4;6538:5;6534:16;6512:4;6504:6;6500:17;6607:39;;;;6286:366;;;;;10763:241;;10867:2;10855:9;10846:7;10842:23;10838:32;10835:2;;;-1:-1;;10873:12;10835:2;85:6;72:20;97:33;124:5;97:33;;11011:263;;11126:2;11114:9;11105:7;11101:23;11097:32;11094:2;;;-1:-1;;11132:12;11094:2;226:6;220:13;238:33;265:5;238:33;;11281:1019;;;;;11502:3;11490:9;11481:7;11477:23;11473:33;11470:2;;;-1:-1;;11509:12;11470:2;528:6;522:13;540:41;575:5;540:41;;;11701:2;11686:18;;11680:25;11561:82;;-1:-1;11725:18;11714:30;;;11711:2;;;-1:-1;;11747:12;11711:2;11777:85;11854:7;11845:6;11834:9;11830:22;11777:85;;;11767:95;;11920:2;11909:9;11905:18;11899:25;11885:39;;11725:18;11936:6;11933:30;11930:2;;;-1:-1;;11966:12;11930:2;11996:85;12073:7;12064:6;12053:9;12049:22;11996:85;;;11986:95;;12139:2;12128:9;12124:18;12118:25;12104:39;;11725:18;12155:6;12152:30;12149:2;;;-1:-1;;12185:12;12149:2;;12215:69;12276:7;12267:6;12256:9;12252:22;12215:69;;;12205:79;;;11464:836;;;;;;;;12307:1179;;;;;;;;;12568:3;12556:9;12547:7;12543:23;12539:33;12536:2;;;-1:-1;;12575:12;12536:2;85:6;72:20;97:33;124:5;97:33;;;12627:63;-1:-1;12727:2;12766:22;;72:20;97:33;72:20;97:33;;;12735:63;-1:-1;12863:2;12848:18;;12835:32;12887:18;12876:30;;;12873:2;;;-1:-1;;12909:12;12873:2;12947:80;13019:7;13010:6;12999:9;12995:22;12947:80;;;12937:90;;-1:-1;12937:90;-1:-1;13092:2;13077:18;;13064:32;;-1:-1;13105:30;;;13102:2;;;-1:-1;;13138:12;13102:2;13176:80;13248:7;13239:6;13228:9;13224:22;13176:80;;;13166:90;;-1:-1;13166:90;-1:-1;13321:3;13306:19;;13293:33;;-1:-1;13335:30;;;13332:2;;;-1:-1;;13368:12;13332:2;;13406:64;13462:7;13453:6;13442:9;13438:22;13406:64;;;12530:956;;;;-1:-1;12530:956;;-1:-1;12530:956;;;;;;13396:74;-1:-1;;;12530:956;13493:867;;;;;;;13684:3;13672:9;13663:7;13659:23;13655:33;13652:2;;;-1:-1;;13691:12;13652:2;85:6;72:20;97:33;124:5;97:33;;;13743:63;-1:-1;13843:2;13882:22;;72:20;97:33;72:20;97:33;;;13851:63;-1:-1;13951:2;13990:22;;10552:20;;-1:-1;14059:2;14098:22;;10552:20;;-1:-1;14195:3;14180:19;;14167:33;14220:18;14209:30;;14206:2;;;-1:-1;;14242:12;14206:2;14280:64;14336:7;14327:6;14316:9;14312:22;14280:64;;;13646:714;;;;-1:-1;13646:714;;-1:-1;13646:714;;14270:74;;13646:714;-1:-1;;;13646:714;14367:1225;;;;;14654:3;14642:9;14633:7;14629:23;14625:33;14622:2;;;-1:-1;;14661:12;14622:2;14719:17;14706:31;14757:18;;14749:6;14746:30;14743:2;;;-1:-1;;14779:12;14743:2;14809:97;14898:7;14889:6;14878:9;14874:22;14809:97;;;14799:107;;14971:2;14960:9;14956:18;14943:32;14929:46;;14757:18;14987:6;14984:30;14981:2;;;-1:-1;;15017:12;14981:2;15047:83;15122:7;15113:6;15102:9;15098:22;15047:83;;;15037:93;;15195:2;15184:9;15180:18;15167:32;15153:46;;14757:18;15211:6;15208:30;15205:2;;;-1:-1;;15241:12;15205:2;15271:78;15341:7;15332:6;15321:9;15317:22;15271:78;;;15261:88;;15414:2;15403:9;15399:18;15386:32;15372:46;;14757:18;15430:6;15427:30;15424:2;;;-1:-1;;15460:12;15424:2;;15490:86;15568:7;15559:6;15548:9;15544:22;15490:86;;15599:1351;;;;;;15903:3;15891:9;15882:7;15878:23;15874:33;15871:2;;;-1:-1;;15910:12;15871:2;15968:17;15955:31;16006:18;;15998:6;15995:30;15992:2;;;-1:-1;;16028:12;15992:2;16058:97;16147:7;16138:6;16127:9;16123:22;16058:97;;;16048:107;;16192:2;16235:9;16231:22;10552:20;16200:63;;16328:2;16317:9;16313:18;16300:32;16286:46;;16006:18;16344:6;16341:30;16338:2;;;-1:-1;;16374:12;16338:2;16404:83;16479:7;16470:6;16459:9;16455:22;16404:83;;;16394:93;;16552:2;16541:9;16537:18;16524:32;16510:46;;16006:18;16568:6;16565:30;16562:2;;;-1:-1;;16598:12;16562:2;16628:78;16698:7;16689:6;16678:9;16674:22;16628:78;;;16618:88;;16771:3;16760:9;16756:19;16743:33;16729:47;;16006:18;16788:6;16785:30;16782:2;;;-1:-1;;16818:12;16782:2;;16848:86;16926:7;16917:6;16906:9;16902:22;16848:86;;;16838:96;;;15865:1085;;;;;;;;;16957:651;;;17136:2;17124:9;17115:7;17111:23;17107:32;17104:2;;;-1:-1;;17142:12;17104:2;17193:17;17187:24;17231:18;;17223:6;17220:30;17217:2;;;-1:-1;;17253:12;17217:2;17283:85;17360:7;17351:6;17340:9;17336:22;17283:85;;;17273:95;;17426:2;;;;17415:9;17411:18;17405:25;17231:18;17442:6;17439:30;17436:2;;;-1:-1;;17472:12;17436:2;17560:22;;;-1:-1;1496:4;1484:17;;1480:27;-1:-1;1470:2;;-1:-1;;1511:12;1470:2;1551:6;1545:13;1573:81;1588:65;1646:6;1588:65;;1573:81;1682:21;;;1739:14;;;;1714:17;;;-1:-1;1819:242;1844:6;1841:1;1838:13;1819:242;;;1944:53;1993:3;17426:2;1920:3;1914:10;1718:6;1902:23;;1944:53;;;1932:66;;2012:14;;;;2040;;;;1866:1;1859:9;1819:242;;;-1:-1;17098:510;;17492:100;;-1:-1;17098:510;-1:-1;;;;;;;17098:510;17615:365;;;17738:2;17726:9;17717:7;17713:23;17709:32;17706:2;;;-1:-1;;17744:12;17706:2;17802:17;17789:31;17840:18;17832:6;17829:30;17826:2;;;-1:-1;;17862:12;17826:2;17900:64;17956:7;17947:6;17936:9;17932:22;17900:64;;;17890:74;;;;-1:-1;17700:280;-1:-1;;;;17700:280;17987:490;;;;18127:2;18115:9;18106:7;18102:23;18098:32;18095:2;;;-1:-1;;18133:12;18095:2;18191:17;18178:31;18229:18;18221:6;18218:30;18215:2;;;-1:-1;;18251:12;18215:2;18289:64;18345:7;18336:6;18325:9;18321:22;18289:64;;;18279:74;;;;-1:-1;18390:2;18429:22;;;;10552:20;;18089:388;-1:-1;;;;18089:388;18484:314;;18624:3;18612:9;18603:7;18599:23;18595:33;18592:2;;;-1:-1;;18631:12;18592:2;6861:20;18624:3;6861:20;;;7013:22;10700:13;6963:16;6956:86;7121:2;7190:9;7186:22;10700:13;7121:2;7140:5;7136:16;7129:86;7284:2;7353:9;7349:22;10700:13;7284:2;7303:5;7299:16;7292:86;7447:2;7516:9;7512:22;10700:13;7447:2;7466:5;7462:16;7455:86;7613:3;7683:9;7679:22;10700:13;7613:3;7633:5;7629:16;7622:86;18683:99;;;;18586:212;;;;;18805:263;;18920:2;18908:9;18899:7;18895:23;18891:32;18888:2;;;-1:-1;;18926:12;18888:2;-1:-1;10700:13;;18882:186;-1:-1;18882:186;19075:399;;;19207:2;19195:9;19186:7;19182:23;19178:32;19175:2;;;-1:-1;;19213:12;19175:2;-1:-1;;10700:13;;19376:2;19426:22;;;10700:13;;;;;-1:-1;19169:305;19663:103;38191:42;38180:54;19724:37;;19718:48;19924:690;;20117:5;36347:12;36886:6;36881:3;36874:19;36923:4;36918:3;36914:14;20129:93;;36923:4;20293:5;36201:14;-1:-1;20332:260;20357:6;20354:1;20351:13;20332:260;;;20418:13;;27407:37;;36923:4;19635:14;;;;36729;;;;20379:1;20372:9;20332:260;;;-1:-1;20598:10;;20048:566;-1:-1;;;;20048:566;20739:343;;20881:5;36347:12;36886:6;36881:3;36874:19;20974:52;21019:6;36923:4;36918:3;36914:14;36923:4;21000:5;20996:16;20974:52;;;39180:2;39160:14;39176:7;39156:28;21038:39;;;;36923:4;21038:39;;20829:253;-1:-1;;20829:253;27576:262;;21249:5;36347:12;21360:52;21405:6;21400:3;21393:4;21386:5;21382:16;21360:52;;;21424:16;;;;;27701:137;-1:-1;;27701:137;27845:213;38191:42;38180:54;;;;19724:37;;27963:2;27948:18;;27934:124;28065:324;38191:42;38180:54;;;19724:37;;38180:54;;28375:2;28360:18;;19724:37;28211:2;28196:18;;28182:207;28396:1039;;38191:42;;19754:5;38180:54;19731:3;19724:37;38191:42;19754:5;38180:54;28909:2;28898:9;28894:18;19724:37;;28744:3;28946:2;28935:9;28931:18;28924:48;28986:108;28744:3;28733:9;28729:19;29080:6;28986:108;;;29142:9;29136:4;29132:20;29127:2;29116:9;29112:18;29105:48;29167:108;29270:4;29261:6;29167:108;;;29324:9;29318:4;29314:20;29308:3;29297:9;29293:19;29286:49;29349:76;29420:4;29411:6;29349:76;;;29341:84;28715:720;-1:-1;;;;;;;;;28715:720;29442:435;38191:42;38180:54;;;19724:37;;38180:54;;;;29780:2;29765:18;;19724:37;29863:2;29848:18;;27407:37;;;;29616:2;29601:18;;29587:290;29884:324;38191:42;38180:54;;;;19724:37;;30194:2;30179:18;;27407:37;30030:2;30015:18;;30001:207;30215:209;37703:66;37692:78;;;;20691:36;;30331:2;30316:18;;30302:122;30431:297;;30567:2;30588:17;30581:47;30642:76;30567:2;30556:9;30552:18;30704:6;30642:76;;30735:471;30927:2;30912:18;;39286:1;39276:12;;39266:2;;39292:9;39266:2;21863:68;;;31109:2;31094:18;;27407:37;;;;31192:2;31177:18;;;27407:37;30898:308;;31213:501;31420:2;31405:18;;39419:1;39409:12;;39399:2;;39425:9;31721:659;;31959:2;31980:17;31973:47;22453:63;31959:2;31948:9;31944:18;22430:16;22424:23;22453:63;;;22603:4;22596:5;22592:16;22586:23;22615:63;22663:14;31948:9;22663:14;22649:12;22615:63;;;;22772:4;22765:5;22761:16;22755:23;22784:63;22832:14;31948:9;22832:14;22818:12;22784:63;;;;31959:2;22928:5;22924:16;22918:23;22947:63;22995:14;31948:9;22995:14;22981:12;22947:63;;;;22663:14;23094:5;23090:16;23084:23;23161:14;31948:9;23161:14;27407:37;22832:14;23260:5;23256:16;23250:23;23327:14;23250:23;23327:14;31948:9;23327:14;27407:37;22995:14;23418:5;23414:16;23408:23;;;23485:14;23408:23;23485:14;31948:9;23485:14;27407:37;23161:14;23576:5;23572:16;23566:23;;;23643:14;23566:23;23643:14;31948:9;23643:14;27407:37;23327:14;23747:5;23743:18;23737:25;;;23816:16;;;23737:25;23816:16;31948:9;23816:16;27407:37;23485:14;23905:5;23901:18;23895:25;;;22348:6;;;23895:25;22348:6;31948:9;23974:16;27407:37;23643:14;24073:5;24069:18;24063:25;24043:45;;;22348:6;24108:16;31948:9;24108:16;24101:40;;24156:67;22339:16;31948:9;22339:16;24204:12;24156:67;;;23816:16;24311:5;24307:18;24301:25;24281:45;;24364:14;31948:9;24368:4;24364:14;;24346:16;31948:9;24346:16;24339:40;24394:67;24456:4;24442:12;24394:67;;;24483:11;;;27437:5;22603:4;32206:9;32202:18;27407:37;32269:9;32263:4;32259:20;22772:4;32243:9;32239:18;32232:48;32294:76;32365:4;32356:6;32294:76;;;32286:84;31930:450;-1:-1;;;;;;;31930:450;32387:659;;32625:2;32646:17;32639:47;24811:63;32625:2;32614:9;32610:18;24788:16;24782:23;24811:63;;;24961:4;24954:5;24950:16;24944:23;24973:63;25021:14;32614:9;25021:14;25007:12;24973:63;;;;25130:4;25123:5;25119:16;25113:23;25142:63;25190:14;32614:9;25190:14;25176:12;25142:63;;;;32625:2;25286:5;25282:16;25276:23;25305:63;25353:14;32614:9;25353:14;25339:12;25305:63;;;;25021:14;25452:5;25448:16;25442:23;25519:14;32614:9;25519:14;27407:37;25190:14;25618:5;25614:16;25608:23;25685:14;25608:23;25685:14;32614:9;25685:14;27407:37;25353:14;25776:5;25772:16;25766:23;;;25843:14;25766:23;25843:14;32614:9;25843:14;27407:37;25519:14;25934:5;25930:16;25924:23;;;26001:14;25924:23;26001:14;32614:9;26001:14;27407:37;25685:14;26105:5;26101:18;26095:25;;;26174:16;;;26095:25;26174:16;32614:9;26174:16;27407:37;25843:14;26263:5;26259:18;26253:25;;;26332:16;;;26253:25;26332:16;32614:9;26332:16;27407:37;26001:14;26431:5;26427:18;26421:25;26401:45;;;24706:6;26466:16;24706:6;26466:16;32614:9;26466:16;26459:40;26514:67;24697:16;32614:9;24697:16;26562:12;26514:67;;;26174:16;26669:5;26665:18;26659:25;26639:45;;26722:14;;;;32614:9;26726:4;26722:14;;24706:6;32614:9;26704:16;26697:40;26752:67;26814:4;26800:12;26752:67;;;26744:75;;;26332:16;26910:5;26906:18;26900:25;26880:45;;26722:14;32614:9;26967:4;26963:14;;26945:16;32614:9;26945:16;26938:40;26993:67;27055:4;27041:12;26993:67;;;26985:75;;26466:16;27151:5;27147:18;27141:25;27121:45;;;;26722:14;32614:9;27208:4;27204:14;;27186:16;32614:9;27186:16;27179:40;27234:67;27296:4;27282:12;27234:67;;33053:213;27407:37;;;33171:2;33156:18;;33142:124;33273:324;27407:37;;;33583:2;33568:18;;27407:37;33419:2;33404:18;;33390:207;33604:256;33666:2;33660:9;33692:17;;;33767:18;33752:34;;33788:22;;;33749:62;33746:2;;;33824:1;;33814:12;33746:2;33666;33833:22;33644:216;;-1:-1;33644:216;33867:312;;34034:18;34026:6;34023:30;34020:2;;;-1:-1;;34056:12;34020:2;-1:-1;34101:4;34089:17;;;34154:15;;33957:222;35762:317;;35901:18;35893:6;35890:30;35887:2;;;-1:-1;;35923:12;35887:2;-1:-1;36000:4;35977:17;35996:9;35973:33;36064:4;36054:15;;35824:255;38816:268;38881:1;38888:101;38902:6;38899:1;38896:13;38888:101;;;38969:11;;;38963:18;38950:11;;;38943:39;38924:2;38917:10;38888:101;;;39004:6;39001:1;38998:13;38995:2;;;-1:-1;;38881:1;39051:16;;39044:27;38865:219;39448:117;38191:42;39535:5;38180:54;39510:5;39507:35;39497:2;;39556:1;;39546:12
Swarm Source
bzzr://ebedf6ba0823da75dd29d928186748ec6baa07f40f145a90097baa22da29b56a
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.