Deploy new FQT (#28)
* `@0x/contracts-zero-ex`: Change `ProtocolFeeUnfunded` event in FQT `@0x/contracts-zero-ex`: Use new PLP interface in FQT. * `@0x/contract-addresses`: Deploy new FQT * fix failing FQT test Co-authored-by: Lawrence Forman <me@merklejerk.com>
This commit is contained in:
		@@ -1,4 +1,17 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "version": "0.7.0",
 | 
			
		||||
        "changes": [
 | 
			
		||||
            {
 | 
			
		||||
                "note": "Change `ProtocolFeeUnfunded` event in FQT",
 | 
			
		||||
                "pr": 28
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                "note": "Use new PLP interface in FQT.",
 | 
			
		||||
                "pr": 28
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "version": "0.6.0",
 | 
			
		||||
        "changes": [
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
 | 
			
		||||
import "@0x/contracts-utils/contracts/src/v06/LibMathV06.sol";
 | 
			
		||||
import "../errors/LibTransformERC20RichErrors.sol";
 | 
			
		||||
import "../vendor/v3/IExchange.sol";
 | 
			
		||||
import "../vendor/v3/LibOrderHash.sol";
 | 
			
		||||
import "./bridges/IBridgeAdapter.sol";
 | 
			
		||||
import "./Transformer.sol";
 | 
			
		||||
import "./LibERC20Transformer.sol";
 | 
			
		||||
@@ -104,13 +105,8 @@ contract FillQuoteTransformer is
 | 
			
		||||
 | 
			
		||||
    /// @dev Emitted when a trade is skipped due to a lack of funds
 | 
			
		||||
    ///      to pay the 0x Protocol fee.
 | 
			
		||||
    /// @param ethBalance The current eth balance.
 | 
			
		||||
    /// @param ethNeeded The current eth balance required to pay
 | 
			
		||||
    ///        the protocol fee.
 | 
			
		||||
    event ProtocolFeeUnfunded(
 | 
			
		||||
        uint256 ethBalance,
 | 
			
		||||
        uint256 ethNeeded
 | 
			
		||||
    );
 | 
			
		||||
    /// @param orderHash The hash of the order that was skipped.
 | 
			
		||||
    event ProtocolFeeUnfunded(bytes32 orderHash);
 | 
			
		||||
 | 
			
		||||
    /// @dev The Exchange ERC20Proxy ID.
 | 
			
		||||
    bytes4 private constant ERC20_ASSET_PROXY_ID = 0xf47261b0;
 | 
			
		||||
@@ -450,7 +446,11 @@ contract FillQuoteTransformer is
 | 
			
		||||
            }
 | 
			
		||||
            // Emit an event if we do not have sufficient ETH to cover the protocol fee.
 | 
			
		||||
            if (state.ethRemaining < state.protocolFee) {
 | 
			
		||||
                emit ProtocolFeeUnfunded(state.ethRemaining, state.protocolFee);
 | 
			
		||||
                bytes32 orderHash = LibOrderHash.getTypedDataHash(
 | 
			
		||||
                    order,
 | 
			
		||||
                    exchange.EIP712_EXCHANGE_DOMAIN_HASH()
 | 
			
		||||
                );
 | 
			
		||||
                emit ProtocolFeeUnfunded(orderHash);
 | 
			
		||||
                return results;
 | 
			
		||||
            }
 | 
			
		||||
            try
 | 
			
		||||
 
 | 
			
		||||
@@ -64,22 +64,6 @@ contract BridgeAdapter is
 | 
			
		||||
    address private immutable UNISWAP_BRIDGE_ADDRESS;
 | 
			
		||||
    address private immutable UNISWAP_V2_BRIDGE_ADDRESS;
 | 
			
		||||
 | 
			
		||||
    /// @dev Emitted when a trade occurs.
 | 
			
		||||
    /// @param inputToken The token the bridge is converting from.
 | 
			
		||||
    /// @param outputToken The token the bridge is converting to.
 | 
			
		||||
    /// @param inputTokenAmount Amount of input token.
 | 
			
		||||
    /// @param outputTokenAmount Amount of output token.
 | 
			
		||||
    /// @param from The bridge address, indicating the underlying source of the fill.
 | 
			
		||||
    /// @param to The `to` address, currrently `address(this)`
 | 
			
		||||
    event ERC20BridgeTransfer(
 | 
			
		||||
        IERC20TokenV06 inputToken,
 | 
			
		||||
        IERC20TokenV06 outputToken,
 | 
			
		||||
        uint256 inputTokenAmount,
 | 
			
		||||
        uint256 outputTokenAmount,
 | 
			
		||||
        address from,
 | 
			
		||||
        address to
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    constructor(AdapterAddresses memory addresses)
 | 
			
		||||
        public
 | 
			
		||||
        MixinBalancer()
 | 
			
		||||
@@ -209,7 +193,8 @@ contract BridgeAdapter is
 | 
			
		||||
                sellAmount,
 | 
			
		||||
                bridgeData
 | 
			
		||||
            );
 | 
			
		||||
            // Do not emit an event. The bridge contract should emit one itself.
 | 
			
		||||
            // Old bridge contracts should emit an `ERC20BridgeTransfer` themselves,
 | 
			
		||||
            // otherwise an event will be emitted from `_tradeZeroExBridge`.
 | 
			
		||||
            return boughtAmount;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -37,8 +37,6 @@ interface IShell {
 | 
			
		||||
        returns (uint256 toAmount);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
contract MixinShell is
 | 
			
		||||
    MixinAdapterAddresses
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -21,32 +21,31 @@ pragma solidity ^0.6.5;
 | 
			
		||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
 | 
			
		||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
 | 
			
		||||
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
 | 
			
		||||
import "../../../vendor/ILiquidityProvider.sol";
 | 
			
		||||
import "../../../vendor/v3/IERC20Bridge.sol";
 | 
			
		||||
 | 
			
		||||
interface IERC20Bridge {
 | 
			
		||||
 | 
			
		||||
    /// @dev Transfers `amount` of the ERC20 `buyToken` from `from` to `to`.
 | 
			
		||||
    /// @param buyToken The address of the ERC20 token to transfer.
 | 
			
		||||
    /// @param from Address to transfer asset from.
 | 
			
		||||
    /// @param to Address to transfer asset to.
 | 
			
		||||
    /// @param amount Amount of asset to transfer.
 | 
			
		||||
    /// @param bridgeData Arbitrary asset data needed by the bridge contract.
 | 
			
		||||
    /// @return success The magic bytes `0xdc1600f3` if successful.
 | 
			
		||||
    function bridgeTransferFrom(
 | 
			
		||||
        IERC20TokenV06 buyToken,
 | 
			
		||||
        address from,
 | 
			
		||||
        address to,
 | 
			
		||||
        uint256 amount,
 | 
			
		||||
        bytes calldata bridgeData
 | 
			
		||||
    )
 | 
			
		||||
        external
 | 
			
		||||
        returns (bytes4 success);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
contract MixinZeroExBridge {
 | 
			
		||||
 | 
			
		||||
    using LibERC20TokenV06 for IERC20TokenV06;
 | 
			
		||||
    using LibSafeMathV06 for uint256;
 | 
			
		||||
 | 
			
		||||
    /// @dev Emitted when a trade occurs.
 | 
			
		||||
    /// @param inputToken The token the bridge is converting from.
 | 
			
		||||
    /// @param outputToken The token the bridge is converting to.
 | 
			
		||||
    /// @param inputTokenAmount Amount of input token.
 | 
			
		||||
    /// @param outputTokenAmount Amount of output token.
 | 
			
		||||
    /// @param from The bridge address, indicating the underlying source of the fill.
 | 
			
		||||
    /// @param to The `to` address, currrently `address(this)`
 | 
			
		||||
    event ERC20BridgeTransfer(
 | 
			
		||||
        IERC20TokenV06 inputToken,
 | 
			
		||||
        IERC20TokenV06 outputToken,
 | 
			
		||||
        uint256 inputTokenAmount,
 | 
			
		||||
        uint256 outputTokenAmount,
 | 
			
		||||
        address from,
 | 
			
		||||
        address to
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    function _tradeZeroExBridge(
 | 
			
		||||
        address bridgeAddress,
 | 
			
		||||
        IERC20TokenV06 sellToken,
 | 
			
		||||
@@ -63,13 +62,31 @@ contract MixinZeroExBridge {
 | 
			
		||||
            bridgeAddress,
 | 
			
		||||
            sellAmount
 | 
			
		||||
        );
 | 
			
		||||
        IERC20Bridge(bridgeAddress).bridgeTransferFrom(
 | 
			
		||||
            buyToken,
 | 
			
		||||
            address(bridgeAddress),
 | 
			
		||||
            address(this),
 | 
			
		||||
            1, // amount to transfer back from the bridge
 | 
			
		||||
            bridgeData
 | 
			
		||||
        );
 | 
			
		||||
        boughtAmount = buyToken.balanceOf(address(this)).safeSub(balanceBefore);
 | 
			
		||||
        try ILiquidityProvider(bridgeAddress).sellTokenForToken(
 | 
			
		||||
                address(sellToken),
 | 
			
		||||
                address(buyToken),
 | 
			
		||||
                address(this), // recipient
 | 
			
		||||
                1, // minBuyAmount
 | 
			
		||||
                bridgeData
 | 
			
		||||
        ) {
 | 
			
		||||
            boughtAmount = buyToken.balanceOf(address(this)).safeSub(balanceBefore);
 | 
			
		||||
            emit ERC20BridgeTransfer(
 | 
			
		||||
                sellToken,
 | 
			
		||||
                buyToken,
 | 
			
		||||
                sellAmount,
 | 
			
		||||
                boughtAmount,
 | 
			
		||||
                bridgeAddress,
 | 
			
		||||
                address(this)
 | 
			
		||||
            );
 | 
			
		||||
        } catch {
 | 
			
		||||
            IERC20Bridge(bridgeAddress).bridgeTransferFrom(
 | 
			
		||||
                address(buyToken),
 | 
			
		||||
                bridgeAddress,
 | 
			
		||||
                address(this), // recipient
 | 
			
		||||
                1, // minBuyAmount
 | 
			
		||||
                bridgeData
 | 
			
		||||
            );
 | 
			
		||||
            boughtAmount = buyToken.balanceOf(address(this)).safeSub(balanceBefore);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										92
									
								
								contracts/zero-ex/contracts/src/vendor/ILiquidityProvider.sol
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								contracts/zero-ex/contracts/src/vendor/ILiquidityProvider.sol
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,92 @@
 | 
			
		||||
/*
 | 
			
		||||
 | 
			
		||||
  Copyright 2020 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.6.5;
 | 
			
		||||
 | 
			
		||||
interface ILiquidityProvider {
 | 
			
		||||
 | 
			
		||||
    /// @dev Trades `inputToken` for `outputToken`. The amount of `inputToken`
 | 
			
		||||
    ///      to sell must be transferred to the contract prior to calling this
 | 
			
		||||
    ///      function to trigger the trade.
 | 
			
		||||
    /// @param inputToken The token being sold.
 | 
			
		||||
    /// @param outputToken The token being bought.
 | 
			
		||||
    /// @param recipient The recipient of the bought tokens.
 | 
			
		||||
    /// @param minBuyAmount The minimum acceptable amount of `outputToken` to buy.
 | 
			
		||||
    /// @param auxiliaryData Arbitrary auxiliary data supplied to the contract.
 | 
			
		||||
    /// @return boughtAmount The amount of `outputToken` bought.
 | 
			
		||||
    function sellTokenForToken(
 | 
			
		||||
        address inputToken,
 | 
			
		||||
        address outputToken,
 | 
			
		||||
        address recipient,
 | 
			
		||||
        uint256 minBuyAmount,
 | 
			
		||||
        bytes calldata auxiliaryData
 | 
			
		||||
    )
 | 
			
		||||
        external
 | 
			
		||||
        returns (uint256 boughtAmount);
 | 
			
		||||
 | 
			
		||||
    /// @dev Trades ETH for token. ETH must either be attached to this function
 | 
			
		||||
    ///      call or sent to the contract prior to calling this function to
 | 
			
		||||
    ///      trigger the trade.
 | 
			
		||||
    /// @param outputToken The token being bought.
 | 
			
		||||
    /// @param recipient The recipient of the bought tokens.
 | 
			
		||||
    /// @param minBuyAmount The minimum acceptable amount of `outputToken` to buy.
 | 
			
		||||
    /// @param auxiliaryData Arbitrary auxiliary data supplied to the contract.
 | 
			
		||||
    /// @return boughtAmount The amount of `outputToken` bought.
 | 
			
		||||
    function sellEthForToken(
 | 
			
		||||
        address outputToken,
 | 
			
		||||
        address recipient,
 | 
			
		||||
        uint256 minBuyAmount,
 | 
			
		||||
        bytes calldata auxiliaryData
 | 
			
		||||
    )
 | 
			
		||||
        external
 | 
			
		||||
        payable
 | 
			
		||||
        returns (uint256 boughtAmount);
 | 
			
		||||
 | 
			
		||||
    /// @dev Trades token for ETH. The token must be sent to the contract prior
 | 
			
		||||
    ///      to calling this function to trigger the trade.
 | 
			
		||||
    /// @param inputToken The token being sold.
 | 
			
		||||
    /// @param recipient The recipient of the bought tokens.
 | 
			
		||||
    /// @param minBuyAmount The minimum acceptable amount of ETH to buy.
 | 
			
		||||
    /// @param auxiliaryData Arbitrary auxiliary data supplied to the contract.
 | 
			
		||||
    /// @return boughtAmount The amount of ETH bought.
 | 
			
		||||
    function sellTokenForEth(
 | 
			
		||||
        address inputToken,
 | 
			
		||||
        address payable recipient,
 | 
			
		||||
        uint256 minBuyAmount,
 | 
			
		||||
        bytes calldata auxiliaryData
 | 
			
		||||
    )
 | 
			
		||||
        external
 | 
			
		||||
        returns (uint256 boughtAmount);
 | 
			
		||||
 | 
			
		||||
    /// @dev Quotes the amount of `outputToken` that would be obtained by
 | 
			
		||||
    ///      selling `sellAmount` of `inputToken`.
 | 
			
		||||
    /// @param inputToken Address of the taker token (what to sell). Use
 | 
			
		||||
    ///        the wETH address if selling ETH.
 | 
			
		||||
    /// @param outputToken Address of the maker token (what to buy). Use
 | 
			
		||||
    ///        the wETH address if buying ETH.
 | 
			
		||||
    /// @param sellAmount Amount of `inputToken` to sell.
 | 
			
		||||
    /// @return outputTokenAmount Amount of `outputToken` that would be obtained.
 | 
			
		||||
    function getSellQuote(
 | 
			
		||||
        address inputToken,
 | 
			
		||||
        address outputToken,
 | 
			
		||||
        uint256 sellAmount
 | 
			
		||||
    )
 | 
			
		||||
        external
 | 
			
		||||
        view
 | 
			
		||||
        returns (uint256 outputTokenAmount);
 | 
			
		||||
}
 | 
			
		||||
@@ -104,4 +104,9 @@ interface IExchange {
 | 
			
		||||
        external
 | 
			
		||||
        view
 | 
			
		||||
        returns (address proxyAddress);
 | 
			
		||||
 | 
			
		||||
    function EIP712_EXCHANGE_DOMAIN_HASH()
 | 
			
		||||
        external
 | 
			
		||||
        view
 | 
			
		||||
        returns (bytes32 domainHash);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										167
									
								
								contracts/zero-ex/contracts/src/vendor/v3/LibOrderHash.sol
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										167
									
								
								contracts/zero-ex/contracts/src/vendor/v3/LibOrderHash.sol
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,167 @@
 | 
			
		||||
/*
 | 
			
		||||
 | 
			
		||||
  Copyright 2020 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.6.5;
 | 
			
		||||
 | 
			
		||||
import "./IExchange.sol";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
library LibOrderHash {
 | 
			
		||||
 | 
			
		||||
    using LibOrderHash for IExchange.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;
 | 
			
		||||
 | 
			
		||||
    /// @dev Calculates the EIP712 typed data hash of an order with a given domain separator.
 | 
			
		||||
    /// @param order The order structure.
 | 
			
		||||
    /// @param eip712ExchangeDomainHash Domain hash for the Exchange.
 | 
			
		||||
    /// @return orderHash EIP712 typed data hash of the order.
 | 
			
		||||
    function getTypedDataHash(IExchange.Order memory order, bytes32 eip712ExchangeDomainHash)
 | 
			
		||||
        internal
 | 
			
		||||
        pure
 | 
			
		||||
        returns (bytes32 orderHash)
 | 
			
		||||
    {
 | 
			
		||||
        orderHash = _hashEIP712Message(
 | 
			
		||||
            eip712ExchangeDomainHash,
 | 
			
		||||
            order.getStructHash()
 | 
			
		||||
        );
 | 
			
		||||
        return orderHash;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @dev Calculates EIP712 hash of the order struct.
 | 
			
		||||
    /// @param order The order structure.
 | 
			
		||||
    /// @return result EIP712 hash of the order struct.
 | 
			
		||||
    function getStructHash(IExchange.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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// @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 result 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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -35,6 +35,8 @@ contract TestFillQuoteTransformerExchange {
 | 
			
		||||
        uint256 makerAssetMintRatio;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bytes32 public constant EIP712_EXCHANGE_DOMAIN_HASH = 0xaa81d881b1adbbf115e15b849cb9cdc643cad3c6a90f30eb505954af943247e6;
 | 
			
		||||
 | 
			
		||||
    uint256 private constant PROTOCOL_FEE_MULTIPLIER = 1337;
 | 
			
		||||
 | 
			
		||||
    using LibSafeMathV06 for uint256;
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,7 @@
 | 
			
		||||
    "config": {
 | 
			
		||||
        "publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IAllowanceTarget,IERC20Transformer,IOwnableFeature,ISimpleFunctionRegistryFeature,ITokenSpenderFeature,ITransformERC20Feature,FillQuoteTransformer,PayTakerTransformer,WethTransformer,OwnableFeature,SimpleFunctionRegistryFeature,TransformERC20Feature,TokenSpenderFeature,AffiliateFeeTransformer,SignatureValidatorFeature,MetaTransactionsFeature,LogMetadataTransformer,BridgeAdapter,LiquidityProviderFeature",
 | 
			
		||||
        "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
 | 
			
		||||
        "abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|AllowanceTarget|BootstrapFeature|BridgeAdapter|FeeCollector|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinProtocolFees|FixinReentrancyGuard|FlashWallet|FullMigration|IAllowanceTarget|IBootstrapFeature|IBridgeAdapter|IERC20Bridge|IERC20Transformer|IExchange|IFeature|IFlashWallet|IGasToken|ILiquidityProviderFeature|IMetaTransactionsFeature|IOwnableFeature|ISignatureValidatorFeature|ISimpleFunctionRegistryFeature|IStaking|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibLiquidityProviderRichErrors|LibLiquidityProviderStorage|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSignedCallData|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibSpenderRichErrors|LibStorage|LibTokenSpender|LibTokenSpenderStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LogMetadataTransformer|MetaTransactionsFeature|MixinAdapterAddresses|MixinBalancer|MixinCurve|MixinDodo|MixinKyber|MixinMStable|MixinMooniswap|MixinOasis|MixinShell|MixinSushiswap|MixinUniswap|MixinUniswapV2|MixinZeroExBridge|OwnableFeature|PayTakerTransformer|SignatureValidatorFeature|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestDelegateCaller|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFullMigration|TestInitialMigration|TestLibSignature|TestLibTokenSpender|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestProtocolFees|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpender|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestWeth|TestWethTransformerHost|TestZeroExFeature|TokenSpenderFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|WethTransformer|ZeroEx).json"
 | 
			
		||||
        "abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|AllowanceTarget|BootstrapFeature|BridgeAdapter|FeeCollector|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinProtocolFees|FixinReentrancyGuard|FlashWallet|FullMigration|IAllowanceTarget|IBootstrapFeature|IBridgeAdapter|IERC20Bridge|IERC20Transformer|IExchange|IFeature|IFlashWallet|IGasToken|ILiquidityProvider|ILiquidityProviderFeature|IMetaTransactionsFeature|IOwnableFeature|ISignatureValidatorFeature|ISimpleFunctionRegistryFeature|IStaking|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibLiquidityProviderRichErrors|LibLiquidityProviderStorage|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibOrderHash|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSignedCallData|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibSpenderRichErrors|LibStorage|LibTokenSpender|LibTokenSpenderStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LogMetadataTransformer|MetaTransactionsFeature|MixinAdapterAddresses|MixinBalancer|MixinCurve|MixinDodo|MixinKyber|MixinMStable|MixinMooniswap|MixinOasis|MixinShell|MixinSushiswap|MixinUniswap|MixinUniswapV2|MixinZeroExBridge|OwnableFeature|PayTakerTransformer|SignatureValidatorFeature|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestDelegateCaller|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFullMigration|TestInitialMigration|TestLibSignature|TestLibTokenSpender|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestProtocolFees|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpender|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestWeth|TestWethTransformerHost|TestZeroExFeature|TokenSpenderFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|WethTransformer|ZeroEx).json"
 | 
			
		||||
    },
 | 
			
		||||
    "repository": {
 | 
			
		||||
        "type": "git",
 | 
			
		||||
@@ -59,7 +59,6 @@
 | 
			
		||||
        "@0x/contracts-gen": "2.0.18",
 | 
			
		||||
        "@0x/contracts-test-utils": "^5.3.8",
 | 
			
		||||
        "@0x/dev-utils": "^4.0.1",
 | 
			
		||||
        "@0x/order-utils": "^10.4.2",
 | 
			
		||||
        "@0x/sol-compiler": "^4.2.7",
 | 
			
		||||
        "@0x/ts-doc-gen": "^0.0.28",
 | 
			
		||||
        "@0x/tslint-config": "^4.1.3",
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ import * as IExchange from '../test/generated-artifacts/IExchange.json';
 | 
			
		||||
import * as IFeature from '../test/generated-artifacts/IFeature.json';
 | 
			
		||||
import * as IFlashWallet from '../test/generated-artifacts/IFlashWallet.json';
 | 
			
		||||
import * as IGasToken from '../test/generated-artifacts/IGasToken.json';
 | 
			
		||||
import * as ILiquidityProvider from '../test/generated-artifacts/ILiquidityProvider.json';
 | 
			
		||||
import * as ILiquidityProviderFeature from '../test/generated-artifacts/ILiquidityProviderFeature.json';
 | 
			
		||||
import * as IMetaTransactionsFeature from '../test/generated-artifacts/IMetaTransactionsFeature.json';
 | 
			
		||||
import * as InitialMigration from '../test/generated-artifacts/InitialMigration.json';
 | 
			
		||||
@@ -46,6 +47,7 @@ import * as LibLiquidityProviderStorage from '../test/generated-artifacts/LibLiq
 | 
			
		||||
import * as LibMetaTransactionsRichErrors from '../test/generated-artifacts/LibMetaTransactionsRichErrors.json';
 | 
			
		||||
import * as LibMetaTransactionsStorage from '../test/generated-artifacts/LibMetaTransactionsStorage.json';
 | 
			
		||||
import * as LibMigrate from '../test/generated-artifacts/LibMigrate.json';
 | 
			
		||||
import * as LibOrderHash from '../test/generated-artifacts/LibOrderHash.json';
 | 
			
		||||
import * as LibOwnableRichErrors from '../test/generated-artifacts/LibOwnableRichErrors.json';
 | 
			
		||||
import * as LibOwnableStorage from '../test/generated-artifacts/LibOwnableStorage.json';
 | 
			
		||||
import * as LibProxyRichErrors from '../test/generated-artifacts/LibProxyRichErrors.json';
 | 
			
		||||
@@ -198,10 +200,12 @@ export const artifacts = {
 | 
			
		||||
    MixinUniswap: MixinUniswap as ContractArtifact,
 | 
			
		||||
    MixinUniswapV2: MixinUniswapV2 as ContractArtifact,
 | 
			
		||||
    MixinZeroExBridge: MixinZeroExBridge as ContractArtifact,
 | 
			
		||||
    ILiquidityProvider: ILiquidityProvider as ContractArtifact,
 | 
			
		||||
    IERC20Bridge: IERC20Bridge as ContractArtifact,
 | 
			
		||||
    IExchange: IExchange as ContractArtifact,
 | 
			
		||||
    IGasToken: IGasToken as ContractArtifact,
 | 
			
		||||
    IStaking: IStaking as ContractArtifact,
 | 
			
		||||
    LibOrderHash: LibOrderHash as ContractArtifact,
 | 
			
		||||
    ITestSimpleFunctionRegistryFeature: ITestSimpleFunctionRegistryFeature as ContractArtifact,
 | 
			
		||||
    TestBridge: TestBridge as ContractArtifact,
 | 
			
		||||
    TestCallTarget: TestCallTarget as ContractArtifact,
 | 
			
		||||
 
 | 
			
		||||
@@ -24,6 +24,7 @@ export * from '../test/generated-wrappers/i_exchange';
 | 
			
		||||
export * from '../test/generated-wrappers/i_feature';
 | 
			
		||||
export * from '../test/generated-wrappers/i_flash_wallet';
 | 
			
		||||
export * from '../test/generated-wrappers/i_gas_token';
 | 
			
		||||
export * from '../test/generated-wrappers/i_liquidity_provider';
 | 
			
		||||
export * from '../test/generated-wrappers/i_liquidity_provider_feature';
 | 
			
		||||
export * from '../test/generated-wrappers/i_meta_transactions_feature';
 | 
			
		||||
export * from '../test/generated-wrappers/i_ownable_feature';
 | 
			
		||||
@@ -44,6 +45,7 @@ export * from '../test/generated-wrappers/lib_liquidity_provider_storage';
 | 
			
		||||
export * from '../test/generated-wrappers/lib_meta_transactions_rich_errors';
 | 
			
		||||
export * from '../test/generated-wrappers/lib_meta_transactions_storage';
 | 
			
		||||
export * from '../test/generated-wrappers/lib_migrate';
 | 
			
		||||
export * from '../test/generated-wrappers/lib_order_hash';
 | 
			
		||||
export * from '../test/generated-wrappers/lib_ownable_rich_errors';
 | 
			
		||||
export * from '../test/generated-wrappers/lib_ownable_storage';
 | 
			
		||||
export * from '../test/generated-wrappers/lib_proxy_rich_errors';
 | 
			
		||||
 
 | 
			
		||||
@@ -48,6 +48,7 @@
 | 
			
		||||
        "test/generated-artifacts/IFeature.json",
 | 
			
		||||
        "test/generated-artifacts/IFlashWallet.json",
 | 
			
		||||
        "test/generated-artifacts/IGasToken.json",
 | 
			
		||||
        "test/generated-artifacts/ILiquidityProvider.json",
 | 
			
		||||
        "test/generated-artifacts/ILiquidityProviderFeature.json",
 | 
			
		||||
        "test/generated-artifacts/IMetaTransactionsFeature.json",
 | 
			
		||||
        "test/generated-artifacts/IOwnableFeature.json",
 | 
			
		||||
@@ -68,6 +69,7 @@
 | 
			
		||||
        "test/generated-artifacts/LibMetaTransactionsRichErrors.json",
 | 
			
		||||
        "test/generated-artifacts/LibMetaTransactionsStorage.json",
 | 
			
		||||
        "test/generated-artifacts/LibMigrate.json",
 | 
			
		||||
        "test/generated-artifacts/LibOrderHash.json",
 | 
			
		||||
        "test/generated-artifacts/LibOwnableRichErrors.json",
 | 
			
		||||
        "test/generated-artifacts/LibOwnableStorage.json",
 | 
			
		||||
        "test/generated-artifacts/LibProxyRichErrors.json",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,13 @@
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "version": "5.1.0",
 | 
			
		||||
        "changes": [
 | 
			
		||||
            {
 | 
			
		||||
                "note": "Deploy new FQT",
 | 
			
		||||
                "pr": 28
 | 
			
		||||
            }
 | 
			
		||||
        ]
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "timestamp": 1603851023,
 | 
			
		||||
        "version": "5.0.1",
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@
 | 
			
		||||
            "wethTransformer": "0x68c0bb685099dc7cb5c5ce2b26185945b357383e",
 | 
			
		||||
            "payTakerTransformer": "0x49b9df2c58491764cf40cb052dd4243df63622c7",
 | 
			
		||||
            "affiliateFeeTransformer": "0x4581b59a05ba373b9f67676f66bdb5fcd67e7567",
 | 
			
		||||
            "fillQuoteTransformer": "0xaaeb683b35a36876bd44aea6b704f58614889228"
 | 
			
		||||
            "fillQuoteTransformer": "0x10c394406d2b15fb8e67b9a7a0dd03fa4d3e8099"
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "3": {
 | 
			
		||||
@@ -76,7 +76,7 @@
 | 
			
		||||
            "wethTransformer": "0x8d822fe2b42f60531203e288f5f357fa79474437",
 | 
			
		||||
            "payTakerTransformer": "0x150652244723102faeaefa4c79597d097ffa26c6",
 | 
			
		||||
            "affiliateFeeTransformer": "0xa39b40642e8e00435857a0fe7d0655e08cc2217e",
 | 
			
		||||
            "fillQuoteTransformer": "0xaf77ff7b00ff528abdcac3f1dcf072de702b758e"
 | 
			
		||||
            "fillQuoteTransformer": "0x83e5e80b685a7bc0cf7364fc0f9f95a14b3051ac"
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "4": {
 | 
			
		||||
@@ -116,7 +116,7 @@
 | 
			
		||||
            "wethTransformer": "0x8d822fe2b42f60531203e288f5f357fa79474437",
 | 
			
		||||
            "payTakerTransformer": "0x150652244723102faeaefa4c79597d097ffa26c6",
 | 
			
		||||
            "affiliateFeeTransformer": "0xa39b40642e8e00435857a0fe7d0655e08cc2217e",
 | 
			
		||||
            "fillQuoteTransformer": "0xaf77ff7b00ff528abdcac3f1dcf072de702b758e"
 | 
			
		||||
            "fillQuoteTransformer": "0xb69af86b536e4869947b53b0b969750ee5fb1257"
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "42": {
 | 
			
		||||
@@ -156,7 +156,7 @@
 | 
			
		||||
            "wethTransformer": "0x9ce35b5ee9e710535e3988e3f8731d9ca9dba17d",
 | 
			
		||||
            "payTakerTransformer": "0x5a53e7b02a83aa9f60ccf4e424f0442c255bc977",
 | 
			
		||||
            "affiliateFeeTransformer": "0x870893920a96a28d4b63c0a7d06a521e3bd074b3",
 | 
			
		||||
            "fillQuoteTransformer": "0x71f5b09fe71d496c9e4f24d4de6aba21bf04b000"
 | 
			
		||||
            "fillQuoteTransformer": "0x2013735f6df965494a0fbc292f84dd44debaba3e"
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "1337": {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user