Mumbai Testnet

Contract

0xf22b6eE71d9f7227B74064597D824066c87f8e39

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Value
0x60a06040274767742022-08-04 23:50:47602 days ago1659657047IN
 Create: MumbaiBridgeAdapter
0 MATIC0.29823242104.53735668

Parent Txn Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MumbaiBridgeAdapter

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
default evmVersion, Apache-2.0 license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 26 : MumbaiBridgeAdapter.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Copyright 2022 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;
pragma experimental ABIEncoderV2;

import "./AbstractBridgeAdapter.sol";
import "./BridgeProtocols.sol";
import "./mixins/MixinAaveV2.sol";
import "./mixins/MixinBalancerV2.sol";
import "./mixins/MixinBalancerV2Batch.sol";
import "./mixins/MixinCurve.sol";
import "./mixins/MixinCurveV2.sol";
import "./mixins/MixinDodo.sol";
import "./mixins/MixinDodoV2.sol";
import "./mixins/MixinKyberDmm.sol";
import "./mixins/MixinMStable.sol";
import "./mixins/MixinNerve.sol";
import "./mixins/MixinUniswapV2.sol";
import "./mixins/MixinUniswapV3.sol";
import "./mixins/MixinZeroExBridge.sol";

contract MumbaiBridgeAdapter is
    AbstractBridgeAdapter(80001, "Polygon-Mumbai"),
    MixinAaveV2,
    MixinBalancerV2,
    MixinBalancerV2Batch,
    MixinCurve,
    MixinCurveV2,
    MixinDodo,
    MixinDodoV2,
    MixinKyberDmm,
    MixinMStable,
    MixinNerve,
    MixinUniswapV2,
    MixinUniswapV3,
    MixinZeroExBridge
{
    constructor(IEtherTokenV06 weth)
        public
        MixinCurve(weth)
    {}

    function _trade(
        BridgeOrder memory order,
        IERC20TokenV06 sellToken,
        IERC20TokenV06 buyToken,
        uint256 sellAmount,
        bool dryRun
    )
        internal
        override
        returns (uint256 boughtAmount, bool supportedSource)
    {
        uint128 protocolId = uint128(uint256(order.source) >> 128);
        if (protocolId == BridgeProtocols.CURVE) {
            if (dryRun) { return (0, true); }
            boughtAmount = _tradeCurve(
                sellToken,
                buyToken,
                sellAmount,
                order.bridgeData
            );
        } else if (protocolId == BridgeProtocols.CURVEV2) {
            if (dryRun) { return (0, true); }
            boughtAmount = _tradeCurveV2(
                sellToken,
                buyToken,
                sellAmount,
                order.bridgeData
            );
        } else if (protocolId == BridgeProtocols.UNISWAPV3) {
            if (dryRun) { return (0, true); }
            boughtAmount = _tradeUniswapV3(
                sellToken,
                sellAmount,
                order.bridgeData
            );
        } else if (protocolId == BridgeProtocols.UNISWAPV2) {
            if (dryRun) { return (0, true); }
            boughtAmount = _tradeUniswapV2(
                buyToken,
                sellAmount,
                order.bridgeData
            );
        } else if (protocolId == BridgeProtocols.BALANCERV2) {
            if (dryRun) { return (0, true); }
            boughtAmount = _tradeBalancerV2(
                sellToken,
                buyToken,
                sellAmount,
                order.bridgeData
            );
        } else if (protocolId == BridgeProtocols.BALANCERV2BATCH) {
            if (dryRun) { return (0, true); }
            boughtAmount = _tradeBalancerV2Batch(
                sellAmount,
                order.bridgeData
            );
        } else if (protocolId == BridgeProtocols.MSTABLE) {
            if (dryRun) { return (0, true); }
            boughtAmount = _tradeMStable(
                sellToken,
                buyToken,
                sellAmount,
                order.bridgeData
            );
        } else if (protocolId == BridgeProtocols.DODO) {
            if (dryRun) { return (0, true); }
            boughtAmount = _tradeDodo(
                sellToken,
                sellAmount,
                order.bridgeData
            );
        } else if (protocolId == BridgeProtocols.DODOV2) {
            if (dryRun) { return (0, true); }
            boughtAmount = _tradeDodoV2(
                sellToken,
                sellAmount,
                order.bridgeData
            );
        } else if (protocolId == BridgeProtocols.NERVE) {
            if (dryRun) { return (0, true); }
            boughtAmount = _tradeNerve(
                sellToken,
                sellAmount,
                order.bridgeData
            );
        } else if (protocolId == BridgeProtocols.KYBERDMM) {
            if (dryRun) { return (0, true); }
            boughtAmount = _tradeKyberDmm(
                buyToken,
                sellAmount,
                order.bridgeData
            );
        } else if (protocolId == BridgeProtocols.AAVEV2) {
            if (dryRun) { return (0, true); }
            boughtAmount = _tradeAaveV2(
                sellToken,
                buyToken,
                sellAmount,
                order.bridgeData
            );
        } else if (protocolId == BridgeProtocols.UNKNOWN) {
            if (dryRun) { return (0, true); }            
            boughtAmount = _tradeZeroExBridge(
                sellToken,
                buyToken,
                sellAmount,
                order.bridgeData
            );
        }

        emit BridgeFill(
            order.source,
            sellToken,
            buyToken,
            sellAmount,
            boughtAmount
        );
    }
}

File 2 of 26 : AbstractBridgeAdapter.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Copyright 2022 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;
pragma experimental ABIEncoderV2;

import "./IBridgeAdapter.sol";

abstract contract AbstractBridgeAdapter is IBridgeAdapter {

    constructor(
        uint256 expectedChainId, 
        string memory expectedChainName
    )
        public
    {
        uint256 chainId;
        assembly { chainId := chainid() }
        // Allow testing on Ganache
        if (chainId != expectedChainId && chainId != 1337) {
            revert(string(abi.encodePacked(expectedChainName, "BridgeAdapter.constructor: wrong chain ID")));
        }
    }

    function isSupportedSource(bytes32 source)
        external
        override
        returns (bool isSupported)
    {
        BridgeOrder memory placeholderOrder;
        placeholderOrder.source = source;
        IERC20TokenV06 placeholderToken = IERC20TokenV06(address(0));
        
        (, isSupported) = _trade(
            placeholderOrder,
            placeholderToken,
            placeholderToken,
            0,
            true
        );
    }

    function trade(
        BridgeOrder memory order,
        IERC20TokenV06 sellToken,
        IERC20TokenV06 buyToken,
        uint256 sellAmount
    )
        public
        override
        returns (uint256 boughtAmount)
    {
        (boughtAmount, ) = _trade(
            order,
            sellToken,
            buyToken,
            sellAmount,
            false
        );
    }

    function _trade(
        BridgeOrder memory order,
        IERC20TokenV06 sellToken,
        IERC20TokenV06 buyToken,
        uint256 sellAmount,
        bool dryRun
    )
        internal
        virtual
        returns (uint256 boughtAmount, bool supportedSource);
}

File 3 of 26 : IBridgeAdapter.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Copyright 2021 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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";


interface IBridgeAdapter {

    struct BridgeOrder {
        // Upper 16 bytes: uint128 protocol ID (right-aligned)
        // Lower 16 bytes: ASCII source name (left-aligned)
        bytes32 source;
        uint256 takerTokenAmount;
        uint256 makerTokenAmount;
        bytes bridgeData;
    }

    /// @dev Emitted when tokens are swapped with an external source.
    /// @param source A unique ID for the source, where the upper 16 bytes
    ///        encodes the (right-aligned) uint128 protocol ID and the
    ///        lower 16 bytes encodes an ASCII source name.
    /// @param inputToken The token the bridge is converting from.
    /// @param outputToken The token the bridge is converting to.
    /// @param inputTokenAmount Amount of input token sold.
    /// @param outputTokenAmount Amount of output token bought.
    event BridgeFill(
        bytes32 source,
        IERC20TokenV06 inputToken,
        IERC20TokenV06 outputToken,
        uint256 inputTokenAmount,
        uint256 outputTokenAmount
    );

    function isSupportedSource(bytes32 source)
        external
        returns (bool isSupported);

    function trade(
        BridgeOrder calldata order,
        IERC20TokenV06 sellToken,
        IERC20TokenV06 buyToken,
        uint256 sellAmount
    )
        external
        returns (uint256 boughtAmount);
}

File 4 of 26 : IERC20TokenV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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 IERC20TokenV06 {

    // 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);

    /// @dev Get the balance of `owner`.
    /// @param owner The address from which the balance will be retrieved
    /// @return Balance of owner
    function balanceOf(address owner)
        external
        view
        returns (uint256);

    /// @dev Get the allowance for `spender` to spend from `owner`.
    /// @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);

    /// @dev Get the number of decimals this token has.
    function decimals()
        external
        view
        returns (uint8);
}

File 5 of 26 : BridgeProtocols.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Copyright 2021 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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";


library BridgeProtocols {
    // A incrementally increasing, append-only list of protocol IDs.
    // We don't use an enum so solidity doesn't throw when we pass in a
    // new protocol ID that hasn't been rolled up yet.
    uint128 internal constant UNKNOWN         = 0;
    uint128 internal constant CURVE           = 1;
    uint128 internal constant UNISWAPV2       = 2;
    uint128 internal constant UNISWAP         = 3;
    uint128 internal constant BALANCER        = 4;
    uint128 internal constant KYBER           = 5;  // Not used: deprecated.
    uint128 internal constant MOONISWAP       = 6;
    uint128 internal constant MSTABLE         = 7;
    uint128 internal constant OASIS           = 8;  // Not used: deprecated.
    uint128 internal constant SHELL           = 9;
    uint128 internal constant DODO            = 10;
    uint128 internal constant DODOV2          = 11;
    uint128 internal constant CRYPTOCOM       = 12;
    uint128 internal constant BANCOR          = 13;
    uint128 internal constant COFIX           = 14; // Not used: deprecated.
    uint128 internal constant NERVE           = 15;
    uint128 internal constant MAKERPSM        = 16;
    uint128 internal constant BALANCERV2      = 17;
    uint128 internal constant UNISWAPV3       = 18;
    uint128 internal constant KYBERDMM        = 19;
    uint128 internal constant CURVEV2         = 20;
    uint128 internal constant LIDO            = 21;
    uint128 internal constant CLIPPER         = 22; // Not used: Clipper is now using PLP interface
    uint128 internal constant AAVEV2          = 23;
    uint128 internal constant COMPOUND        = 24;
    uint128 internal constant BALANCERV2BATCH = 25;
    uint128 internal constant GMX             = 26;
    uint128 internal constant PLATYPUS        = 27;
    uint128 internal constant BANCORV3        = 28;
    uint128 internal constant VELODROME       = 29;
    uint128 internal constant SYNTHETIX       = 30;
}

File 6 of 26 : MixinAaveV2.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Copyright 2021 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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";

// Minimal Aave V2 LendingPool interface
interface ILendingPool {
    /**
   * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
   * - E.g. User deposits 100 USDC and gets in return 100 aUSDC
   * @param asset The address of the underlying asset to deposit
   * @param amount The amount to be deposited
   * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
   *   wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
   *   is a different wallet
   * @param referralCode Code used to register the integrator originating the operation, for potential rewards.
   *   0 if the action is executed directly by the user, without any middle-man
   **/
  function deposit(
    address asset,
    uint256 amount,
    address onBehalfOf,
    uint16 referralCode
  ) external;

  /**
   * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
   * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC
   * @param asset The address of the underlying asset to withdraw
   * @param amount The underlying amount to be withdrawn
   *   - Send the value type(uint256).max in order to withdraw the whole aToken balance
   * @param to Address that will receive the underlying, same as msg.sender if the user
   *   wants to receive it on his own wallet, or a different address if the beneficiary is a
   *   different wallet
   * @return The final amount withdrawn
   **/
  function withdraw(
    address asset,
    uint256 amount,
    address to
  ) external returns (uint256);
}

contract MixinAaveV2 {
    using LibERC20TokenV06 for IERC20TokenV06;

    function _tradeAaveV2(
        IERC20TokenV06 sellToken,
        IERC20TokenV06 buyToken,
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256)
    {
        (ILendingPool lendingPool, address aToken) = abi.decode(bridgeData, (ILendingPool, address));

          sellToken.approveIfBelow(
              address(lendingPool),
              sellAmount
          );

        if (address(buyToken) == aToken) {
            lendingPool.deposit(address(sellToken), sellAmount, address(this), 0);
            // 1:1 mapping token -> aToken and have the same number of decimals as the underlying token
            return sellAmount;
        } else if (address(sellToken) == aToken) {
            return lendingPool.withdraw(address(buyToken), sellAmount, address(this));
        }

        revert("MixinAaveV2/UNSUPPORTED_TOKEN_PAIR");
    }
}

File 7 of 26 : LibERC20TokenV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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 "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
import "@0x/contracts-utils/contracts/src/v06/LibBytesV06.sol";
import "./IERC20TokenV06.sol";


library LibERC20TokenV06 {
    bytes constant private DECIMALS_CALL_DATA = hex"313ce567";

    /// @dev Calls `IERC20TokenV06(token).approve()`.
    ///      Reverts if the return data is invalid or the call reverts.
    /// @param token The address of the token contract.
    /// @param spender The address that receives an allowance.
    /// @param allowance The allowance to set.
    function compatApprove(
        IERC20TokenV06 token,
        address spender,
        uint256 allowance
    )
        internal
    {
        bytes memory callData = abi.encodeWithSelector(
            token.approve.selector,
            spender,
            allowance
        );
        _callWithOptionalBooleanResult(address(token), callData);
    }

    /// @dev Calls `IERC20TokenV06(token).approve()` and sets the allowance to the
    ///      maximum if the current approval is not already >= an amount.
    ///      Reverts if the return data is invalid or the call reverts.
    /// @param token The address of the token contract.
    /// @param spender The address that receives an allowance.
    /// @param amount The minimum allowance needed.
    function approveIfBelow(
        IERC20TokenV06 token,
        address spender,
        uint256 amount
    )
        internal
    {
        if (token.allowance(address(this), spender) < amount) {
            compatApprove(token, spender, uint256(-1));
        }
    }

    /// @dev Calls `IERC20TokenV06(token).transfer()`.
    ///      Reverts if the return data is invalid or the call reverts.
    /// @param token The address of the token contract.
    /// @param to The address that receives the tokens
    /// @param amount Number of tokens to transfer.
    function compatTransfer(
        IERC20TokenV06 token,
        address to,
        uint256 amount
    )
        internal
    {
        bytes memory callData = abi.encodeWithSelector(
            token.transfer.selector,
            to,
            amount
        );
        _callWithOptionalBooleanResult(address(token), callData);
    }

    /// @dev Calls `IERC20TokenV06(token).transferFrom()`.
    ///      Reverts if the return data is invalid or the call reverts.
    /// @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 compatTransferFrom(
        IERC20TokenV06 token,
        address from,
        address to,
        uint256 amount
    )
        internal
    {
        bytes memory callData = abi.encodeWithSelector(
            token.transferFrom.selector,
            from,
            to,
            amount
        );
        _callWithOptionalBooleanResult(address(token), callData);
    }

    /// @dev Retrieves the number of decimals for a token.
    ///      Returns `18` if the call reverts.
    /// @param token The address of the token contract.
    /// @return tokenDecimals The number of decimals places for the token.
    function compatDecimals(IERC20TokenV06 token)
        internal
        view
        returns (uint8 tokenDecimals)
    {
        tokenDecimals = 18;
        (bool didSucceed, bytes memory resultData) = address(token).staticcall(DECIMALS_CALL_DATA);
        if (didSucceed && resultData.length >= 32) {
            tokenDecimals = uint8(LibBytesV06.readUint256(resultData, 0));
        }
    }

    /// @dev Retrieves the allowance for a token, owner, and spender.
    ///      Returns `0` if the call reverts.
    /// @param token The address of the token contract.
    /// @param owner The owner of the tokens.
    /// @param spender The address the spender.
    /// @return allowance_ The allowance for a token, owner, and spender.
    function compatAllowance(IERC20TokenV06 token, address owner, address spender)
        internal
        view
        returns (uint256 allowance_)
    {
        (bool didSucceed, bytes memory resultData) = address(token).staticcall(
            abi.encodeWithSelector(
                token.allowance.selector,
                owner,
                spender
            )
        );
        if (didSucceed && resultData.length >= 32) {
            allowance_ = LibBytesV06.readUint256(resultData, 0);
        }
    }

    /// @dev Retrieves the balance for a token owner.
    ///      Returns `0` if the call reverts.
    /// @param token The address of the token contract.
    /// @param owner The owner of the tokens.
    /// @return balance The token balance of an owner.
    function compatBalanceOf(IERC20TokenV06 token, address owner)
        internal
        view
        returns (uint256 balance)
    {
        (bool didSucceed, bytes memory resultData) = address(token).staticcall(
            abi.encodeWithSelector(
                token.balanceOf.selector,
                owner
            )
        );
        if (didSucceed && resultData.length >= 32) {
            balance = LibBytesV06.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);
        // Revert if the call reverted.
        if (!didSucceed) {
            LibRichErrorsV06.rrevert(resultData);
        }
        // If we get back 0 returndata, this may be a non-standard ERC-20 that
        // does not return a boolean. Check that it at least contains code.
        if (resultData.length == 0) {
            uint256 size;
            assembly { size := extcodesize(target) }
            require(size > 0, "invalid token address, contains no code");
            return;
        }
        // If we get back at least 32 bytes, we know the target address
        // contains code, and we assume it is a token that returned a boolean
        // success value, which must be true.
        if (resultData.length >= 32) {
            uint256 result = LibBytesV06.readUint256(resultData, 0);
            if (result == 1) {
                return;
            } else {
                LibRichErrorsV06.rrevert(resultData);
            }
        }
        // If 0 < returndatasize < 32, the target is a contract, but not a
        // valid token.
        LibRichErrorsV06.rrevert(resultData);
    }
}

File 8 of 26 : LibRichErrorsV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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;


library LibRichErrorsV06 {

    // 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))
        }
    }
}

File 9 of 26 : LibBytesV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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 "./errors/LibBytesRichErrorsV06.sol";
import "./errors/LibRichErrorsV06.sol";


library LibBytesV06 {

    using LibBytesV06 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) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.FromLessThanOrEqualsToRequired,
                from,
                to
            ));
        }
        if (to > b.length) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.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.
    ///      When `from == 0`, the original array will match the slice.
    ///      In other cases its state will be corrupted.
    /// @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)
    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) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.FromLessThanOrEqualsToRequired,
                from,
                to
            ));
        }
        if (to > b.length) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.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 result The byte that was popped off.
    function popLastByte(bytes memory b)
        internal
        pure
        returns (bytes1 result)
    {
        if (b.length == 0) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.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 equal 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 result address from byte array.
    function readAddress(
        bytes memory b,
        uint256 index
    )
        internal
        pure
        returns (address result)
    {
        if (b.length < index + 20) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.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) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.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 result bytes32 value from byte array.
    function readBytes32(
        bytes memory b,
        uint256 index
    )
        internal
        pure
        returns (bytes32 result)
    {
        if (b.length < index + 32) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.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) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.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 result 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 result bytes4 value from byte array.
    function readBytes4(
        bytes memory b,
        uint256 index
    )
        internal
        pure
        returns (bytes4 result)
    {
        if (b.length < index + 4) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.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)
        }
    }
}

File 10 of 26 : LibBytesRichErrorsV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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;


library LibBytesRichErrorsV06 {

    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
        );
    }
}

File 11 of 26 : MixinBalancerV2.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";


interface IBalancerV2Vault {

    enum SwapKind { GIVEN_IN, GIVEN_OUT }
    /**
     * @dev Performs a swap with a single Pool.
     *
     * If the swap is given in (the number of tokens to send to the Pool is known), returns the amount of tokens
     * taken from the Pool, which must be greater than or equal to `limit`.
     *
     * If the swap is given out (the number of tokens to take from the Pool is known), returns the amount of
     * tokens sent to the Pool, which must be less than or equal to `limit`.
     *
     * Internal Balance usage and the recipient are determined by the `funds` struct.
     *
     * Emits a `Swap` event.
     * For full documentation see https://github.com/balancer-labs/balancer-core-v2/blob/master/contracts/vault/interfaces/IVault.sol
     */
    function swap(
        SingleSwap calldata request,
        FundManagement calldata funds,
        uint256 limit,
        uint256 deadline
    ) external payable returns (uint256);

    struct SingleSwap {
        bytes32 poolId;
        SwapKind kind;
        IERC20TokenV06 assetIn;
        IERC20TokenV06 assetOut;
        uint256 amount;
        bytes userData;
    }

    struct FundManagement {
        address sender;
        bool fromInternalBalance;
        address payable recipient;
        bool toInternalBalance;
    }
}

contract MixinBalancerV2 {

    using LibERC20TokenV06 for IERC20TokenV06;

    struct BalancerV2BridgeData {
        IBalancerV2Vault vault;
        bytes32 poolId;
    }

    function _tradeBalancerV2(
        IERC20TokenV06 sellToken,
        IERC20TokenV06 buyToken,
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256 boughtAmount)
    {
        // Decode the bridge data.
        BalancerV2BridgeData memory data = abi.decode(bridgeData, (BalancerV2BridgeData));

        // Grant an allowance to the exchange to spend `fromTokenAddress` token.
        sellToken.approveIfBelow(address(data.vault), sellAmount);

        // Sell the entire sellAmount
        IBalancerV2Vault.SingleSwap memory request = IBalancerV2Vault.SingleSwap({
            poolId: data.poolId,
            kind: IBalancerV2Vault.SwapKind.GIVEN_IN,
            assetIn: sellToken,
            assetOut: buyToken,
            amount: sellAmount, // amount in
            userData: ""
        });

        IBalancerV2Vault.FundManagement memory funds = IBalancerV2Vault.FundManagement({
            sender: address(this),
            fromInternalBalance: false,
            recipient: payable(address(this)),
            toInternalBalance: false
        });

        boughtAmount = data.vault.swap(
            request,
            funds,
            1, // min amount out
            block.timestamp // expires after this block
        );
        return boughtAmount;
    }
}

File 12 of 26 : MixinBalancerV2Batch.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";


interface IBalancerV2BatchSwapVault {

    enum SwapKind { GIVEN_IN, GIVEN_OUT }

    struct BatchSwapStep {
        bytes32 poolId;
        uint256 assetInIndex;
        uint256 assetOutIndex;
        uint256 amount;
        bytes userData;
    }

    struct FundManagement {
        address sender;
        bool fromInternalBalance;
        address payable recipient;
        bool toInternalBalance;
    }

    function batchSwap(
        SwapKind kind,
        BatchSwapStep[] calldata swaps,
        IERC20TokenV06[] calldata assets,
        FundManagement calldata funds,
        int256[] calldata limits,
        uint256 deadline
    ) external returns (int256[] memory amounts);
}

contract MixinBalancerV2Batch {

    using LibERC20TokenV06 for IERC20TokenV06;

    struct BalancerV2BatchBridgeData {
        IBalancerV2BatchSwapVault vault;
        IBalancerV2BatchSwapVault.BatchSwapStep[] swapSteps;
        IERC20TokenV06[] assets;
    }

    function _tradeBalancerV2Batch(
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256 boughtAmount)
    {
        // Decode the bridge data.
        (
            IBalancerV2BatchSwapVault vault,
            IBalancerV2BatchSwapVault.BatchSwapStep[] memory swapSteps,
            address[] memory assets_
        ) = abi.decode(bridgeData, (IBalancerV2BatchSwapVault, IBalancerV2BatchSwapVault.BatchSwapStep[], address[]));
        IERC20TokenV06[] memory assets;
        assembly { assets := assets_ }

        // Grant an allowance to the exchange to spend `fromTokenAddress` token.
        assets[0].approveIfBelow(address(vault), sellAmount);

        swapSteps[0].amount = sellAmount;
        int256[] memory limits = new int256[](assets.length);
        for (uint256 i = 0; i < limits.length; ++i) {
            limits[i] = type(int256).max;
        }

        int256[] memory amounts = vault.batchSwap(
            IBalancerV2BatchSwapVault.SwapKind.GIVEN_IN,
            swapSteps,
            assets,
            IBalancerV2BatchSwapVault.FundManagement({
                sender: address(this),
                fromInternalBalance: false,
                recipient: payable(address(this)),
                toInternalBalance: false
            }),
            limits,
            block.timestamp + 1
        );
        require(amounts[amounts.length - 1] <= 0, 'Unexpected BalancerV2Batch output');
        return uint256(amounts[amounts.length - 1] * -1);
    }
}

File 13 of 26 : MixinCurve.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
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";

contract MixinCurve {

    using LibERC20TokenV06 for IERC20TokenV06;
    using LibSafeMathV06 for uint256;
    using LibRichErrorsV06 for bytes;

    /// @dev Mainnet address of the WETH contract.
    IEtherTokenV06 private immutable WETH;

    constructor(IEtherTokenV06 weth)
        public
    {
        WETH = weth;
    }


    struct CurveBridgeData {
        address curveAddress;
        bytes4 exchangeFunctionSelector;
        int128 fromCoinIdx;
        int128 toCoinIdx;
    }

    function _tradeCurve(
        IERC20TokenV06 sellToken,
        IERC20TokenV06 buyToken,
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256 boughtAmount)
    {
        // Decode the bridge data to get the Curve metadata.
        CurveBridgeData memory data = abi.decode(bridgeData, (CurveBridgeData));
        uint256 payableAmount;
        if (sellToken == WETH) {
            payableAmount = sellAmount;
            WETH.withdraw(sellAmount);
        } else {
            sellToken.approveIfBelow(data.curveAddress, sellAmount);
        }

        uint256 beforeBalance = buyToken.balanceOf(address(this));
        (bool success, bytes memory resultData) =
            data.curveAddress.call{value: payableAmount}(abi.encodeWithSelector(
                data.exchangeFunctionSelector,
                data.fromCoinIdx,
                data.toCoinIdx,
                // dx
                sellAmount,
                // min dy
                1
            ));
        if (!success) {
            resultData.rrevert();
        }

        if (buyToken == WETH) {
            boughtAmount = address(this).balance;
            WETH.deposit{ value: boughtAmount }();
        }

        return buyToken.balanceOf(address(this)).safeSub(beforeBalance);
    }
}

File 14 of 26 : IEtherTokenV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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 "./IERC20TokenV06.sol";


interface IEtherTokenV06 is
    IERC20TokenV06
{
    /// @dev Wrap ether.
    function deposit() external payable;

    /// @dev Unwrap ether.
    function withdraw(uint256 amount) external;
}

File 15 of 26 : LibSafeMathV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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 "./errors/LibRichErrorsV06.sol";
import "./errors/LibSafeMathRichErrorsV06.sol";


library LibSafeMathV06 {

    function safeMul(uint256 a, uint256 b)
        internal
        pure
        returns (uint256)
    {
        if (a == 0) {
            return 0;
        }
        uint256 c = a * b;
        if (c / a != b) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.MULTIPLICATION_OVERFLOW,
                a,
                b
            ));
        }
        return c;
    }

    function safeDiv(uint256 a, uint256 b)
        internal
        pure
        returns (uint256)
    {
        if (b == 0) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.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) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.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) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.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;
    }

    function safeMul128(uint128 a, uint128 b)
        internal
        pure
        returns (uint128)
    {
        if (a == 0) {
            return 0;
        }
        uint128 c = a * b;
        if (c / a != b) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.MULTIPLICATION_OVERFLOW,
                a,
                b
            ));
        }
        return c;
    }

    function safeDiv128(uint128 a, uint128 b)
        internal
        pure
        returns (uint128)
    {
        if (b == 0) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.DIVISION_BY_ZERO,
                a,
                b
            ));
        }
        uint128 c = a / b;
        return c;
    }

    function safeSub128(uint128 a, uint128 b)
        internal
        pure
        returns (uint128)
    {
        if (b > a) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.SUBTRACTION_UNDERFLOW,
                a,
                b
            ));
        }
        return a - b;
    }

    function safeAdd128(uint128 a, uint128 b)
        internal
        pure
        returns (uint128)
    {
        uint128 c = a + b;
        if (c < a) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256BinOpError(
                LibSafeMathRichErrorsV06.BinOpErrorCodes.ADDITION_OVERFLOW,
                a,
                b
            ));
        }
        return c;
    }

    function max128(uint128 a, uint128 b)
        internal
        pure
        returns (uint128)
    {
        return a >= b ? a : b;
    }

    function min128(uint128 a, uint128 b)
        internal
        pure
        returns (uint128)
    {
        return a < b ? a : b;
    }

    function safeDowncastToUint128(uint256 a)
        internal
        pure
        returns (uint128)
    {
        if (a > type(uint128).max) {
            LibRichErrorsV06.rrevert(LibSafeMathRichErrorsV06.Uint256DowncastError(
                LibSafeMathRichErrorsV06.DowncastErrorCodes.VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT128,
                a
            ));
        }
        return uint128(a);
    }
}

File 16 of 26 : LibSafeMathRichErrorsV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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;


library LibSafeMathRichErrorsV06 {

    // 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,
        VALUE_TOO_LARGE_TO_DOWNCAST_TO_UINT128
    }

    // 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
        );
    }
}

File 17 of 26 : MixinCurveV2.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
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";

contract MixinCurveV2 {

    using LibERC20TokenV06 for IERC20TokenV06;
    using LibSafeMathV06 for uint256;
    using LibRichErrorsV06 for bytes;

    struct CurveBridgeDataV2 {
        address curveAddress;
        bytes4 exchangeFunctionSelector;
        int128 fromCoinIdx;
        int128 toCoinIdx;
    }

    function _tradeCurveV2(
        IERC20TokenV06 sellToken,
        IERC20TokenV06 buyToken,
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256 boughtAmount)
    {
        // Decode the bridge data to get the Curve metadata.
        CurveBridgeDataV2 memory data = abi.decode(bridgeData, (CurveBridgeDataV2));
        sellToken.approveIfBelow(data.curveAddress, sellAmount);

        uint256 beforeBalance = buyToken.balanceOf(address(this));
        (bool success, bytes memory resultData) =
            data.curveAddress.call(abi.encodeWithSelector(
                data.exchangeFunctionSelector,
                data.fromCoinIdx,
                data.toCoinIdx,
                // dx
                sellAmount,
                // min dy
                1
            ));
        if (!success) {
            resultData.rrevert();
        }

        return buyToken.balanceOf(address(this)).safeSub(beforeBalance);
    }
}

File 18 of 26 : MixinDodo.sol
// SPDX-License-Identifier: Apache-2.0

/*

  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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "../IBridgeAdapter.sol";


interface IDODO {
    function sellBaseToken(
        uint256 amount,
        uint256 minReceiveQuote,
        bytes calldata data
    )
        external
        returns (uint256);

    function buyBaseToken(
        uint256 amount,
        uint256 maxPayQuote,
        bytes calldata data
    )
        external
        returns (uint256);
}


interface IDODOHelper {
    function querySellQuoteToken(
        IDODO dodo,
        uint256 amount
    )
        external
        view
        returns (uint256);
}


contract MixinDodo {

    using LibERC20TokenV06 for IERC20TokenV06;

    function _tradeDodo(
        IERC20TokenV06 sellToken,
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256 boughtAmount)
    {
        (IDODOHelper helper, IDODO pool, bool isSellBase) =
            abi.decode(bridgeData, (IDODOHelper, IDODO, bool));

        // Grant the Dodo pool contract an allowance to sell the first token.
        sellToken.approveIfBelow(address(pool), sellAmount);

        if (isSellBase) {
            // Sell the Base token directly against the contract
            boughtAmount = pool.sellBaseToken(
                // amount to sell
                sellAmount,
                // min receive amount
                1,
                new bytes(0)
            );
        } else {
            // Need to re-calculate the sell quote amount into buyBase
            boughtAmount = helper.querySellQuoteToken(
                pool,
                sellAmount
            );
            pool.buyBaseToken(
                // amount to buy
                boughtAmount,
                // max pay amount
                sellAmount,
                new bytes(0)
            );
        }

        return boughtAmount;
    }
}

File 19 of 26 : MixinDodoV2.sol
// SPDX-License-Identifier: Apache-2.0

/*

  Copyright 2021 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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "../IBridgeAdapter.sol";


interface IDODOV2 {
    function sellBase(address recipient)
        external
        returns (uint256);

    function sellQuote(address recipient)
        external
        returns (uint256);
}


contract MixinDodoV2 {

    using LibERC20TokenV06 for IERC20TokenV06;

    function _tradeDodoV2(
        IERC20TokenV06 sellToken,
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256 boughtAmount)
    {
        (IDODOV2 pool, bool isSellBase) =
            abi.decode(bridgeData, (IDODOV2, bool));

        // Transfer the tokens into the pool
        sellToken.compatTransfer(address(pool), sellAmount);

        boughtAmount = isSellBase ?
            pool.sellBase(address(this))
            : pool.sellQuote(address(this));
    }
}

File 20 of 26 : MixinKyberDmm.sol
// SPDX-License-Identifier: Apache-2.0

/*

  Copyright 2021 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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "../IBridgeAdapter.sol";

/*
    KyberDmm Router
*/
interface IKyberDmmRouter {

    /// @dev Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path.
    ///      The first element of path is the input token, the last is the output token, and any intermediate elements represent
    ///      intermediate pairs to trade through (if, for example, a direct pair does not exist).
    /// @param amountIn The amount of input tokens to send.
    /// @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.
    /// @param pools An array of pool addresses. pools.length must be >= 1.
    /// @param path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
    /// @param to Recipient of the output tokens.
    /// @param deadline Unix timestamp after which the transaction will revert.
    /// @return amounts The input token amount and all subsequent output token amounts.
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata pools,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
}

contract MixinKyberDmm {

    using LibERC20TokenV06 for IERC20TokenV06;

    function _tradeKyberDmm(
        IERC20TokenV06 buyToken,
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256 boughtAmount)
    {
        address router;
        address[] memory pools;
        address[] memory path;
        (router, pools, path) = abi.decode(bridgeData, (address, address[], address[]));

        require(pools.length >= 1, "MixinKyberDmm/POOLS_LENGTH_MUST_BE_AT_LEAST_ONE");
        require(path.length == pools.length + 1, "MixinKyberDmm/ARRAY_LENGTH_MISMATCH");
         require(
             path[path.length - 1] == address(buyToken),
             "MixinKyberDmm/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN"
         );
        // Grant the KyberDmm router an allowance to sell the first token.
        IERC20TokenV06(path[0]).approveIfBelow(address(router), sellAmount);

        uint[] memory amounts = IKyberDmmRouter(router).swapExactTokensForTokens(
             // Sell all tokens we hold.
            sellAmount,
             // Minimum buy amount.
            1,
            pools,
            // Convert to `buyToken` along this path.
            path,
            // Recipient is `this`.
            address(this),
            // Expires after this block.
            block.timestamp
        );
        return amounts[amounts.length-1];
    }
}

File 21 of 26 : MixinMStable.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "../IBridgeAdapter.sol";


interface IMStable {

    function swap(
        IERC20TokenV06 sellToken,
        IERC20TokenV06 buyToken,
        uint256 sellAmount,
        uint256 minBoughtAmount,
        address recipient
    )
        external
        returns (uint256 boughtAmount);
}

contract MixinMStable {

    using LibERC20TokenV06 for IERC20TokenV06;

    function _tradeMStable(
        IERC20TokenV06 sellToken,
        IERC20TokenV06 buyToken,
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256 boughtAmount)
    {
        (IMStable mstable) = abi.decode(bridgeData, (IMStable));

        // Grant an allowance to the exchange to spend `sellToken` token.
        sellToken.approveIfBelow(address(mstable), sellAmount);

        boughtAmount = mstable.swap(
            sellToken,
            buyToken,
            sellAmount,
            // Minimum buy amount.
            1,
            address(this)
        );
    }
}

File 22 of 26 : MixinNerve.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
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";

contract MixinNerve {

    using LibERC20TokenV06 for IERC20TokenV06;
    using LibSafeMathV06 for uint256;
    using LibRichErrorsV06 for bytes;


    struct NerveBridgeData {
        address pool;
        bytes4 exchangeFunctionSelector;
        int128 fromCoinIdx;
        int128 toCoinIdx;
    }

    function _tradeNerve(
        IERC20TokenV06 sellToken,
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256 boughtAmount)
    {
        // Basically a Curve fork but the swap option has a deadline

        // Decode the bridge data to get the Curve metadata.
        NerveBridgeData memory data = abi.decode(bridgeData, (NerveBridgeData));
        sellToken.approveIfBelow(data.pool, sellAmount);
        (bool success, bytes memory resultData) =
            data.pool.call(abi.encodeWithSelector(
                data.exchangeFunctionSelector,
                data.fromCoinIdx,
                data.toCoinIdx,
                // dx
                sellAmount,
                // min dy
                1,
                // deadline
                block.timestamp
            ));
        if (!success) {
            resultData.rrevert();
        }
        return abi.decode(resultData, (uint256));
    }
}

File 23 of 26 : MixinUniswapV2.sol
// SPDX-License-Identifier: Apache-2.0

/*

  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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "../IBridgeAdapter.sol";

/*
    UniswapV2
*/
interface IUniswapV2Router02 {

    /// @dev Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path.
    ///      The first element of path is the input token, the last is the output token, and any intermediate elements represent
    ///      intermediate pairs to trade through (if, for example, a direct pair does not exist).
    /// @param amountIn The amount of input tokens to send.
    /// @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.
    /// @param path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
    /// @param to Recipient of the output tokens.
    /// @param deadline Unix timestamp after which the transaction will revert.
    /// @return amounts The input token amount and all subsequent output token amounts.
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        IERC20TokenV06[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
}

contract MixinUniswapV2 {

    using LibERC20TokenV06 for IERC20TokenV06;

    function _tradeUniswapV2(
        IERC20TokenV06 buyToken,
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256 boughtAmount)
    {
        IUniswapV2Router02 router;
        IERC20TokenV06[] memory path;
        {
            address[] memory _path;
            (router, _path) = abi.decode(bridgeData, (IUniswapV2Router02, address[]));
            // To get around `abi.decode()` not supporting interface array types.
            assembly { path := _path }
        }

        require(path.length >= 2, "MixinUniswapV2/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
        require(
            path[path.length - 1] == buyToken,
            "MixinUniswapV2/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN"
        );
        // Grant the Uniswap router an allowance to sell the first token.
        path[0].approveIfBelow(address(router), sellAmount);

        uint[] memory amounts = router.swapExactTokensForTokens(
             // Sell all tokens we hold.
            sellAmount,
             // Minimum buy amount.
            1,
            // Convert to `buyToken` along this path.
            path,
            // Recipient is `this`.
            address(this),
            // Expires after this block.
            block.timestamp
        );
        return amounts[amounts.length-1];
    }
}

File 24 of 26 : MixinUniswapV3.sol
// SPDX-License-Identifier: Apache-2.0

/*

  Copyright 2021 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;
pragma experimental ABIEncoderV2;

import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "../IBridgeAdapter.sol";

interface IUniswapV3Router {

    struct ExactInputParams {
        bytes path;
        address recipient;
        uint256 deadline;
        uint256 amountIn;
        uint256 amountOutMinimum;
    }

    function exactInput(ExactInputParams memory params)
        external
        payable
        returns (uint256 amountOut);
}

contract MixinUniswapV3 {

    using LibERC20TokenV06 for IERC20TokenV06;

    function _tradeUniswapV3(
        IERC20TokenV06 sellToken,
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256 boughtAmount)
    {
        (IUniswapV3Router router, bytes memory path) =
            abi.decode(bridgeData, (IUniswapV3Router, bytes));

        // Grant the Uniswap router an allowance to sell the sell token.
        sellToken.approveIfBelow(address(router), sellAmount);

        boughtAmount = router.exactInput(IUniswapV3Router.ExactInputParams({
            path: path,
            recipient: address(this),
            deadline: block.timestamp,
            amountIn: sellAmount,
            amountOutMinimum: 1
        }));
    }
}

File 25 of 26 : MixinZeroExBridge.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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 "@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";


contract MixinZeroExBridge {

    using LibERC20TokenV06 for IERC20TokenV06;
    using LibSafeMathV06 for uint256;

    function _tradeZeroExBridge(
        IERC20TokenV06 sellToken,
        IERC20TokenV06 buyToken,
        uint256 sellAmount,
        bytes memory bridgeData
    )
        internal
        returns (uint256 boughtAmount)
    {
        (ILiquidityProvider provider, bytes memory lpData) =
            abi.decode(bridgeData, (ILiquidityProvider, bytes));
        // Trade the good old fashioned way
        sellToken.compatTransfer(
            address(provider),
            sellAmount
        );
        boughtAmount = provider.sellTokenForToken(
            sellToken,
            buyToken,
            address(this), // recipient
            1, // minBuyAmount
            lpData
        );
    }
}

File 26 of 26 : ILiquidityProvider.sol
// SPDX-License-Identifier: Apache-2.0
/*

  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 "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";


interface ILiquidityProvider {

    /// @dev An optional event an LP can emit for each fill against a source.
    /// @param inputToken The input token.
    /// @param outputToken The output token.
    /// @param inputTokenAmount How much input token was sold.
    /// @param outputTokenAmount How much output token was bought.
    /// @param sourceId A bytes32 encoded ascii source ID. E.g., `bytes32('Curve')`/
    /// @param sourceAddress An optional address associated with the source (e.g, a curve pool).
    /// @param sourceId A bytes32 encoded ascii source ID. E.g., `bytes32('Curve')`/
    /// @param sourceAddress An optional address associated with the source (e.g, a curve pool).
    /// @param sender The caller of the LP.
    /// @param recipient The recipient of the output tokens.
    event LiquidityProviderFill(
        IERC20TokenV06 inputToken,
        IERC20TokenV06 outputToken,
        uint256 inputTokenAmount,
        uint256 outputTokenAmount,
        bytes32 sourceId,
        address sourceAddress,
        address sender,
        address recipient
    );

    /// @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(
        IERC20TokenV06 inputToken,
        IERC20TokenV06 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(
        IERC20TokenV06 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(
        IERC20TokenV06 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(
        IERC20TokenV06 inputToken,
        IERC20TokenV06 outputToken,
        uint256 sellAmount
    )
        external
        view
        returns (uint256 outputTokenAmount);
}

Settings
{
  "remappings": [
    "@0x/contracts-erc20=/Users/0xnoah/Documents/ArbitrumDeploy/protocol/contracts/zero-ex/node_modules/@0x/contracts-erc20",
    "@0x/contracts-utils=/Users/0xnoah/Documents/ArbitrumDeploy/protocol/node_modules/@0x/contracts-utils"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 1000000,
    "details": {
      "yul": true,
      "deduplicate": true,
      "cse": true,
      "constantOptimizer": true
    }
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "istanbul"
}

Contract ABI

[{"inputs":[{"internalType":"contract IEtherTokenV06","name":"weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"source","type":"bytes32"},{"indexed":false,"internalType":"contract IERC20TokenV06","name":"inputToken","type":"address"},{"indexed":false,"internalType":"contract IERC20TokenV06","name":"outputToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"inputTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"outputTokenAmount","type":"uint256"}],"name":"BridgeFill","type":"event"},{"inputs":[{"internalType":"bytes32","name":"source","type":"bytes32"}],"name":"isSupportedSource","outputs":[{"internalType":"bool","name":"isSupported","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"source","type":"bytes32"},{"internalType":"uint256","name":"takerTokenAmount","type":"uint256"},{"internalType":"uint256","name":"makerTokenAmount","type":"uint256"},{"internalType":"bytes","name":"bridgeData","type":"bytes"}],"internalType":"struct IBridgeAdapter.BridgeOrder","name":"order","type":"tuple"},{"internalType":"contract IERC20TokenV06","name":"sellToken","type":"address"},{"internalType":"contract IERC20TokenV06","name":"buyToken","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"}],"name":"trade","outputs":[{"internalType":"uint256","name":"boughtAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

60a06040523480156200001157600080fd5b50604051620034b1380380620034b18339810160408190526200003491620000d8565b60408051808201909152600e81526d506f6c79676f6e2d4d756d62616960901b602082015281906201388190468083148015906200007457508061053914155b15620000be57816040516020016200008d919062000108565b60408051601f198184030181529082905262461bcd60e51b8252620000b5916004016200015d565b60405180910390fd5b50505060601b6001600160601b03191660805250620001c5565b600060208284031215620000ea578081fd5b81516001600160a01b038116811462000101578182fd5b9392505050565b600082516200011c81846020870162000192565b7f427269646765416461707465722e636f6e7374727563746f723a2077726f6e67920191825250680818da185a5b88125160ba1b6020820152602901919050565b60006020825282518060208401526200017e81604085016020870162000192565b601f01601f19169190910160400192915050565b60005b83811015620001af57818101518382015260200162000195565b83811115620001bf576000848401525b50505050565b60805160601c6132bf620001f26000398061045d52806104ef528061074b52806107a252506132bf6000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806302d2734f1461003b578063f712a14814610064575b600080fd5b61004e610049366004612522565b610084565b60405161005b9190612ac3565b60405180910390f35b61007761007236600461279c565b6100aa565b60405161005b91906130c8565b600061008e612136565b82815260006100a18282808060016100c4565b95945050505050565b60006100ba8585858560006100c4565b5095945050505050565b8451600090819060801c60018114156101025783156100eb5760006001925092505061042f565b6100fb8787878b60600151610439565b92506103ed565b6fffffffffffffffffffffffffffffffff8116601414156101415783156101315760006001925092505061042f565b6100fb8787878b606001516108c5565b6fffffffffffffffffffffffffffffffff81166012141561017f5783156101705760006001925092505061042f565b6100fb87868a60600151610b1d565b6fffffffffffffffffffffffffffffffff8116600214156101bd5783156101ae5760006001925092505061042f565b6100fb86868a60600151610c2e565b6fffffffffffffffffffffffffffffffff8116601114156101fc5783156101ec5760006001925092505061042f565b6100fb8787878b60600151610e47565b6fffffffffffffffffffffffffffffffff81166019141561023957831561022b5760006001925092505061042f565b6100fb858960600151610fe8565b6fffffffffffffffffffffffffffffffff8116600714156102785783156102685760006001925092505061042f565b6100fb8787878b60600151611265565b6fffffffffffffffffffffffffffffffff8116600a14156102b65783156102a75760006001925092505061042f565b6100fb87868a606001516112fa565b6fffffffffffffffffffffffffffffffff8116600b14156102f45783156102e55760006001925092505061042f565b6100fb87868a60600151611567565b6fffffffffffffffffffffffffffffffff8116600f14156103325783156103235760006001925092505061042f565b6100fb87868a606001516116a6565b6fffffffffffffffffffffffffffffffff8116601314156103705783156103615760006001925092505061042f565b6100fb86868a6060015161182e565b6fffffffffffffffffffffffffffffffff8116601714156103af57831561039f5760006001925092505061042f565b6100fb8787878b60600151611a53565b6fffffffffffffffffffffffffffffffff81166103ed5783156103da5760006001925092505061042f565b6103ea8787878b60600151611c72565b92505b87516040517fe59e71a14fe90157eedc866c4f8c767d3943d6b6b2e8cd64dddcc92ab4c55af891610425918a908a908a908990612ace565b60405180910390a1505b9550959350505050565b6000610443612161565b828060200190518101906104579190612852565b905060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff16141561055b57506040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152849073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d906105249084906004016130c8565b600060405180830381600087803b15801561053e57600080fd5b505af1158015610552573d6000803e3d6000fd5b5050505061057f565b815161057f9073ffffffffffffffffffffffffffffffffffffffff89169087611d5e565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8816906370a08231906105d49030906004016129eb565b60206040518083038186803b1580156105ec57600080fd5b505afa158015610600573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610624919061286d565b905060006060846000015173ffffffffffffffffffffffffffffffffffffffff16848660200151876040015188606001518c600160405160240161066b9493929190612c8f565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516106f491906129cf565b60006040518083038185875af1925050503d8060008114610731576040519150601f19603f3d011682016040523d82523d6000602084013e610736565b606091505b5091509150816107495761074981611e3a565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff161415610822574795507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0876040518263ffffffff1660e01b81526004016000604051808303818588803b15801561080857600080fd5b505af115801561081c573d6000803e3d6000fd5b50505050505b6108b5838a73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161085f91906129eb565b60206040518083038186803b15801561087757600080fd5b505afa15801561088b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108af919061286d565b90611e42565b955050505050505b949350505050565b60006108cf612161565b828060200190518101906108e39190612852565b805190915061090a9073ffffffffffffffffffffffffffffffffffffffff88169086611d5e565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8716906370a082319061095f9030906004016129eb565b60206040518083038186803b15801561097757600080fd5b505afa15801561098b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109af919061286d565b905060006060836000015173ffffffffffffffffffffffffffffffffffffffff168460200151856040015186606001518a60016040516024016109f59493929190612c8f565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051610a7e91906129cf565b6000604051808303816000865af19150503d8060008114610abb576040519150601f19603f3d011682016040523d82523d6000602084013e610ac0565b606091505b509150915081610ad357610ad381611e3a565b610b10838973ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161085f91906129eb565b9998505050505050505050565b600080606083806020019051810190610b3691906126b1565b9092509050610b5c73ffffffffffffffffffffffffffffffffffffffff87168387611d5e565b6040805160a0810182528281523060208201524281830152606081018790526001608082015290517fc04b8d5900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84169163c04b8d5991610bd29190600401612fca565b602060405180830381600087803b158015610bec57600080fd5b505af1158015610c00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c24919061286d565b9695505050505050565b60008060608084806020019051810190610c48919061271c565b80519194509250600211159050610c94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612d9c565b60405180910390fd5b8573ffffffffffffffffffffffffffffffffffffffff1681600183510381518110610cbb57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614610d10576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612f6d565b610d4f828683600081518110610d2257fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16611d5e9092919063ffffffff16565b6040517f38ed173900000000000000000000000000000000000000000000000000000000815260609073ffffffffffffffffffffffffffffffffffffffff8416906338ed173990610dad90899060019087903090429060040161312e565b600060405180830381600087803b158015610dc757600080fd5b505af1158015610ddb573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610e219190810190612492565b905080600182510381518110610e3357fe5b602002602001015193505050509392505050565b6000610e51612188565b82806020019051810190610e659190612761565b8051909150610e8c9073ffffffffffffffffffffffffffffffffffffffff88169086611d5e565b610e9461219f565b6040805160c0810190915260208084015182528101600081526020018873ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff168152602001868152602001604051806020016040528060008152508152509050610f0b612161565b506040805160808101825230808252600060208301819052828401919091526060820152835191517f52bbbe29000000000000000000000000000000000000000000000000000000008152909173ffffffffffffffffffffffffffffffffffffffff16906352bbbe2990610f8a90859085906001904290600401613030565b602060405180830381600087803b158015610fa457600080fd5b505af1158015610fb8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fdc919061286d565b98975050505050505050565b60008060608084806020019051810190611002919061253a565b925092509250606081905061101f848883600081518110610d2257fe5b868360008151811061102d57fe5b602002602001015160600181815250506060815167ffffffffffffffff8111801561105757600080fd5b50604051908082528060200260200182016040528015611081578160200160208202803683370190505b50905060005b81518110156110d0577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8282815181106110bd57fe5b6020908102919091010152600101611087565b50604080516080810182523080825260006020830181905282840191909152606082810182905292517f945bcec900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff89169263945bcec9926111549290918a9189919089904260010190600401612bbe565b600060405180830381600087803b15801561116e57600080fd5b505af1158015611182573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526111c89190810190612492565b90506000816001835103815181106111dc57fe5b6020026020010151131561121c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612d3f565b8060018251038151811061122c57fe5b60200260200101517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0296505050505050505b92915050565b6000808280602001905181019061127c9190612700565b905061129f73ffffffffffffffffffffffffffffffffffffffff87168286611d5e565b6040517fd5bcb9b500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82169063d5bcb9b590610bd2908990899089906001903090600401612b51565b6000806000808480602001905181019061131491906125f6565b9194509250905061133c73ffffffffffffffffffffffffffffffffffffffff88168388611d5e565b80156113ff57604080516000815260208101918290527f8dae73330000000000000000000000000000000000000000000000000000000090915273ffffffffffffffffffffffffffffffffffffffff831690638dae7333906113a690899060019060248101613177565b602060405180830381600087803b1580156113c057600080fd5b505af11580156113d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f8919061286d565b935061155d565b6040517fca19ebd900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84169063ca19ebd9906114539085908a90600401612a33565b60206040518083038186803b15801561146b57600080fd5b505afa15801561147f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114a3919061286d565b604080516000815260208101918290527fe67ce7060000000000000000000000000000000000000000000000000000000090915290945073ffffffffffffffffffffffffffffffffffffffff83169063e67ce706906115099087908a9060248101613177565b602060405180830381600087803b15801561152357600080fd5b505af1158015611537573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155b919061286d565b505b5050509392505050565b6000806000838060200190518101906115809190612646565b90925090506115a673ffffffffffffffffffffffffffffffffffffffff87168387611e66565b80611654576040517fdd93f59a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169063dd93f59a906115fd9030906004016129eb565b602060405180830381600087803b15801561161757600080fd5b505af115801561162b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164f919061286d565b610c24565b6040517fbd6015b400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169063bd6015b490610bd29030906004016129eb565b60006116b0612161565b828060200190518101906116c49190612852565b80519091506116eb9073ffffffffffffffffffffffffffffffffffffffff87169086611d5e565b60006060826000015173ffffffffffffffffffffffffffffffffffffffff1683602001518460400151856060015189600142604051602401611731959493929190612cb4565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516117ba91906129cf565b6000604051808303816000865af19150503d80600081146117f7576040519150601f19603f3d011682016040523d82523d6000602084013e6117fc565b606091505b50915091508161180f5761180f81611e3a565b80806020019051810190611823919061286d565b979650505050505050565b60008060608084806020019051810190611848919061241e565b815192955090935091506001111561188c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612eb3565b81516001018151146118ca576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612df9565b8673ffffffffffffffffffffffffffffffffffffffff16816001835103815181106118f157fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614611946576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612ce2565b611958838783600081518110610d2257fe5b6040517fceb757d500000000000000000000000000000000000000000000000000000000815260609073ffffffffffffffffffffffffffffffffffffffff85169063ceb757d5906119b8908a9060019088908890309042906004016130d1565b600060405180830381600087803b1580156119d257600080fd5b505af11580156119e6573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052611a2c9190810190612492565b905080600182510381518110611a3e57fe5b60200260200101519450505050509392505050565b600080600083806020019051810190611a6c9190612683565b9092509050611a9273ffffffffffffffffffffffffffffffffffffffff88168387611d5e565b8073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611b5b576040517fe8eda9df00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169063e8eda9df90611b1f908a9089903090600090600401612a89565b600060405180830381600087803b158015611b3957600080fd5b505af1158015611b4d573d6000803e3d6000fd5b5050505084925050506108bd565b8073ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff161415611c40576040517f69328dec00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8316906369328dec90611be590899089903090600401612a59565b602060405180830381600087803b158015611bff57600080fd5b505af1158015611c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c37919061286d565b925050506108bd565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612f10565b600080606083806020019051810190611c8b91906126b1565b9092509050611cb173ffffffffffffffffffffffffffffffffffffffff88168387611e66565b6040517f65d02b0400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8316906365d02b0490611d0c908a908a9030906001908890600401612b0a565b602060405180830381600087803b158015611d2657600080fd5b505af1158015611d3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611823919061286d565b6040517fdd62ed3e000000000000000000000000000000000000000000000000000000008152819073ffffffffffffffffffffffffffffffffffffffff85169063dd62ed3e90611db49030908790600401612a0c565b60206040518083038186803b158015611dcc57600080fd5b505afa158015611de0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e04919061286d565b1015611e3557611e3583837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff611f12565b505050565b805160208201fd5b600082821115611e6057611e60611e5b60028585611f2f565b611e3a565b50900390565b606063a9059cbb60e01b8383604051602401611e83929190612a33565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091529050611f0c8482611fd4565b50505050565b606063095ea7b360e01b8383604051602401611e83929190612a33565b606063e946c1bb60e01b848484604051602401611f4e93929190612b8e565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290509392505050565b600060608373ffffffffffffffffffffffffffffffffffffffff1683604051611ffd91906129cf565b6000604051808303816000865af19150503d806000811461203a576040519150601f19603f3d011682016040523d82523d6000602084013e61203f565b606091505b5091509150816120525761205281611e3a565b805161209957833b80612091576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612e56565b5050506120d6565b60208151106120cd5760006120af8260006120da565b905080600114156120c2575050506120d6565b6120cb82611e3a565b505b611f0c81611e3a565b5050565b60006120e683836120ed565b9392505050565b6000816020018351101561210e5761210e611e5b6005855185602001612117565b50016020015190565b6060632800659560e01b848484604051602401611f4e93929190612bb0565b6040518060800160405280600080191681526020016000815260200160008152602001606081525090565b60408051608081018252600080825260208201819052918101829052606081019190915290565b604080518082019091526000808252602082015290565b6040805160c08101909152600080825260208201908152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001606081525090565b600082601f830112612212578081fd5b8151612225612220826131bd565b613196565b81815291506020808301908481018184028601820187101561224657600080fd5b60005b8481101561226e57815161225c81613258565b84529282019290820190600101612249565b505050505092915050565b600082601f830112612289578081fd5b8135612297612220826131dd565b91508082528360208285010111156122ae57600080fd5b8060208401602084013760009082016020015292915050565b600082601f8301126122d7578081fd5b81516122e5612220826131dd565b91508082528360208285010111156122fc57600080fd5b61230d81602084016020860161321f565b5092915050565b803561125f81613258565b600060a08284031215612330578081fd5b61233a60a0613196565b905081518152602082015160208201526040820151604082015260608201516060820152608082015167ffffffffffffffff81111561237857600080fd5b612384848285016122c7565b60808301525092915050565b6000608082840312156123a1578081fd5b6123ab6080613196565b905081516123b881613258565b815260208201517fffffffff00000000000000000000000000000000000000000000000000000000811681146123ed57600080fd5b602082015260408201516124008161327a565b604082015260608201516124138161327a565b606082015292915050565b600080600060608486031215612432578283fd5b835161243d81613258565b602085015190935067ffffffffffffffff8082111561245a578384fd5b61246687838801612202565b9350604086015191508082111561247b578283fd5b5061248886828701612202565b9150509250925092565b600060208083850312156124a4578182fd5b825167ffffffffffffffff8111156124ba578283fd5b8301601f810185136124ca578283fd5b80516124d8612220826131bd565b81815283810190838501858402850186018910156124f4578687fd5b8694505b838510156125165780518352600194909401939185019185016124f8565b50979650505050505050565b600060208284031215612533578081fd5b5035919050565b60008060006060848603121561254e578081fd5b835161255981613258565b8093505060208085015167ffffffffffffffff80821115612578578384fd5b818701915087601f83011261258b578384fd5b8151612599612220826131bd565b81815284810190848601875b848110156125ce576125bc8d8984518a010161231f565b845292870192908701906001016125a5565b505060408a015190975094505050808311156125e8578384fd5b505061248886828701612202565b60008060006060848603121561260a578081fd5b835161261581613258565b602085015190935061262681613258565b6040850151909250801515811461263b578182fd5b809150509250925092565b60008060408385031215612658578182fd5b825161266381613258565b60208401519092508015158114612678578182fd5b809150509250929050565b60008060408385031215612695578182fd5b82516126a081613258565b602084015190925061267881613258565b600080604083850312156126c3578182fd5b82516126ce81613258565b602084015190925067ffffffffffffffff8111156126ea578182fd5b6126f6858286016122c7565b9150509250929050565b600060208284031215612711578081fd5b81516120e681613258565b6000806040838503121561272e578182fd5b825161273981613258565b602084015190925067ffffffffffffffff811115612755578182fd5b6126f685828601612202565b600060408284031215612772578081fd5b61277c6040613196565b825161278781613258565b81526020928301519281019290925250919050565b600080600080608085870312156127b1578182fd5b843567ffffffffffffffff808211156127c8578384fd5b90860190608082890312156127db578384fd5b6127e56080613196565b82358152602083013560208201526040830135604082015260608301358281111561280e578586fd5b61281a8a828601612279565b6060830152508096505050506128338660208701612314565b92506128428660408701612314565b9396929550929360600135925050565b600060808284031215612863578081fd5b6120e68383612390565b60006020828403121561287e578081fd5b5051919050565b6000815180845260208085019450808401835b838110156128ca57815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101612898565b509495945050505050565b6000815180845260208085019450808401835b838110156128ca578151875295820195908201906001016128e8565b6000815180845261291c81602086016020860161321f565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600081518352602082015160208401526040820151604084015260608201516060840152608082015160a060808501526108bd60a0850182612904565b73ffffffffffffffffffffffffffffffffffffffff808251168352602082015115156020840152806040830151166040840152506060810151151560608301525050565b600082516129e181846020870161321f565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff93841681526020810192909252909116604082015260600190565b73ffffffffffffffffffffffffffffffffffffffff948516815260208101939093529216604082015261ffff909116606082015260800190565b901515815260200190565b94855273ffffffffffffffffffffffffffffffffffffffff93841660208601529190921660408401526060830191909152608082015260a00190565b600073ffffffffffffffffffffffffffffffffffffffff8088168352808716602084015280861660408401525083606083015260a0608083015261182360a0830184612904565b73ffffffffffffffffffffffffffffffffffffffff9586168152938516602085015260408401929092526060830152909116608082015260a00190565b6060810160048510612b9c57fe5b938152602081019290925260409091015290565b6060810160088510612b9c57fe5b6000610120808301612bcf8a61324b565b898452602080850192909252885190819052610140808501928281028601909101918a8201855b82811015612c42577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec0888603018652612c3085835161294e565b95840195945090830190600101612bf6565b505050508381036040850152612c588189612885565b915050612c68606084018761298b565b82810360e0840152612c7a81866128d5565b91505082610100830152979650505050505050565b600f94850b81529290930b6020830152604082015260ff909116606082015260800190565b600f95860b81529390940b6020840152604083019190915260ff166060820152608081019190915260a00190565b6020808252603a908201527f4d6978696e4b79626572446d6d2f4c4153545f454c454d454e545f4f465f504160408201527f54485f4d5553545f4d415443485f4f55545055545f544f4b454e000000000000606082015260800190565b60208082526021908201527f556e65787065637465642042616c616e63657256324261746368206f7574707560408201527f7400000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f4d6978696e556e697377617056322f504154485f4c454e4754485f4d5553545f60408201527f42455f41545f4c454153545f54574f0000000000000000000000000000000000606082015260800190565b60208082526023908201527f4d6978696e4b79626572446d6d2f41525241595f4c454e4754485f4d49534d4160408201527f5443480000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526027908201527f696e76616c696420746f6b656e20616464726573732c20636f6e7461696e732060408201527f6e6f20636f646500000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f4d6978696e4b79626572446d6d2f504f4f4c535f4c454e4754485f4d5553545f60408201527f42455f41545f4c454153545f4f4e450000000000000000000000000000000000606082015260800190565b60208082526022908201527f4d6978696e4161766556322f554e535550504f525445445f544f4b454e5f504160408201527f4952000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252603b908201527f4d6978696e556e697377617056322f4c4153545f454c454d454e545f4f465f5060408201527f4154485f4d5553545f4d415443485f4f55545055545f544f4b454e0000000000606082015260800190565b600060208252825160a06020840152612fe660c0840182612904565b905073ffffffffffffffffffffffffffffffffffffffff60208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b600060e08252855160e0830152602086015161304b8161324b565b610100830152604086015173ffffffffffffffffffffffffffffffffffffffff908116610120840152606087015116610140830152608086015161016083015260a086015160c06101808401526130a66101a0840182612904565b9150506130b6602083018661298b565b60a082019390935260c0015292915050565b90815260200190565b600087825286602083015260c060408301526130f060c0830187612885565b82810360608401526131028187612885565b73ffffffffffffffffffffffffffffffffffffffff959095166080840152505060a00152949350505050565b600086825285602083015260a0604083015261314d60a0830186612885565b73ffffffffffffffffffffffffffffffffffffffff94909416606083015250608001529392505050565b6000848252836020830152606060408301526100a16060830184612904565b60405181810167ffffffffffffffff811182821017156131b557600080fd5b604052919050565b600067ffffffffffffffff8211156131d3578081fd5b5060209081020190565b600067ffffffffffffffff8211156131f3578081fd5b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60005b8381101561323a578181015183820152602001613222565b83811115611f0c5750506000910152565b6002811061325557fe5b50565b73ffffffffffffffffffffffffffffffffffffffff8116811461325557600080fd5b80600f0b811461325557600080fdfea2646970667358221220e52b7f7baec09f1909a4272f1f673be4a10da31bf94784404ef41f5421626a5464736f6c634300060c00330000000000000000000000009c3c9283d3e44854697cd22d3faa240cfb032889

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100365760003560e01c806302d2734f1461003b578063f712a14814610064575b600080fd5b61004e610049366004612522565b610084565b60405161005b9190612ac3565b60405180910390f35b61007761007236600461279c565b6100aa565b60405161005b91906130c8565b600061008e612136565b82815260006100a18282808060016100c4565b95945050505050565b60006100ba8585858560006100c4565b5095945050505050565b8451600090819060801c60018114156101025783156100eb5760006001925092505061042f565b6100fb8787878b60600151610439565b92506103ed565b6fffffffffffffffffffffffffffffffff8116601414156101415783156101315760006001925092505061042f565b6100fb8787878b606001516108c5565b6fffffffffffffffffffffffffffffffff81166012141561017f5783156101705760006001925092505061042f565b6100fb87868a60600151610b1d565b6fffffffffffffffffffffffffffffffff8116600214156101bd5783156101ae5760006001925092505061042f565b6100fb86868a60600151610c2e565b6fffffffffffffffffffffffffffffffff8116601114156101fc5783156101ec5760006001925092505061042f565b6100fb8787878b60600151610e47565b6fffffffffffffffffffffffffffffffff81166019141561023957831561022b5760006001925092505061042f565b6100fb858960600151610fe8565b6fffffffffffffffffffffffffffffffff8116600714156102785783156102685760006001925092505061042f565b6100fb8787878b60600151611265565b6fffffffffffffffffffffffffffffffff8116600a14156102b65783156102a75760006001925092505061042f565b6100fb87868a606001516112fa565b6fffffffffffffffffffffffffffffffff8116600b14156102f45783156102e55760006001925092505061042f565b6100fb87868a60600151611567565b6fffffffffffffffffffffffffffffffff8116600f14156103325783156103235760006001925092505061042f565b6100fb87868a606001516116a6565b6fffffffffffffffffffffffffffffffff8116601314156103705783156103615760006001925092505061042f565b6100fb86868a6060015161182e565b6fffffffffffffffffffffffffffffffff8116601714156103af57831561039f5760006001925092505061042f565b6100fb8787878b60600151611a53565b6fffffffffffffffffffffffffffffffff81166103ed5783156103da5760006001925092505061042f565b6103ea8787878b60600151611c72565b92505b87516040517fe59e71a14fe90157eedc866c4f8c767d3943d6b6b2e8cd64dddcc92ab4c55af891610425918a908a908a908990612ace565b60405180910390a1505b9550959350505050565b6000610443612161565b828060200190518101906104579190612852565b905060007f0000000000000000000000009c3c9283d3e44854697cd22d3faa240cfb03288973ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff16141561055b57506040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152849073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000009c3c9283d3e44854697cd22d3faa240cfb0328891690632e1a7d4d906105249084906004016130c8565b600060405180830381600087803b15801561053e57600080fd5b505af1158015610552573d6000803e3d6000fd5b5050505061057f565b815161057f9073ffffffffffffffffffffffffffffffffffffffff89169087611d5e565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8816906370a08231906105d49030906004016129eb565b60206040518083038186803b1580156105ec57600080fd5b505afa158015610600573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610624919061286d565b905060006060846000015173ffffffffffffffffffffffffffffffffffffffff16848660200151876040015188606001518c600160405160240161066b9493929190612c8f565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516106f491906129cf565b60006040518083038185875af1925050503d8060008114610731576040519150601f19603f3d011682016040523d82523d6000602084013e610736565b606091505b5091509150816107495761074981611e3a565b7f0000000000000000000000009c3c9283d3e44854697cd22d3faa240cfb03288973ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff161415610822574795507f0000000000000000000000009c3c9283d3e44854697cd22d3faa240cfb03288973ffffffffffffffffffffffffffffffffffffffff1663d0e30db0876040518263ffffffff1660e01b81526004016000604051808303818588803b15801561080857600080fd5b505af115801561081c573d6000803e3d6000fd5b50505050505b6108b5838a73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161085f91906129eb565b60206040518083038186803b15801561087757600080fd5b505afa15801561088b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108af919061286d565b90611e42565b955050505050505b949350505050565b60006108cf612161565b828060200190518101906108e39190612852565b805190915061090a9073ffffffffffffffffffffffffffffffffffffffff88169086611d5e565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff8716906370a082319061095f9030906004016129eb565b60206040518083038186803b15801561097757600080fd5b505afa15801561098b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109af919061286d565b905060006060836000015173ffffffffffffffffffffffffffffffffffffffff168460200151856040015186606001518a60016040516024016109f59493929190612c8f565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051610a7e91906129cf565b6000604051808303816000865af19150503d8060008114610abb576040519150601f19603f3d011682016040523d82523d6000602084013e610ac0565b606091505b509150915081610ad357610ad381611e3a565b610b10838973ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161085f91906129eb565b9998505050505050505050565b600080606083806020019051810190610b3691906126b1565b9092509050610b5c73ffffffffffffffffffffffffffffffffffffffff87168387611d5e565b6040805160a0810182528281523060208201524281830152606081018790526001608082015290517fc04b8d5900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84169163c04b8d5991610bd29190600401612fca565b602060405180830381600087803b158015610bec57600080fd5b505af1158015610c00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c24919061286d565b9695505050505050565b60008060608084806020019051810190610c48919061271c565b80519194509250600211159050610c94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612d9c565b60405180910390fd5b8573ffffffffffffffffffffffffffffffffffffffff1681600183510381518110610cbb57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614610d10576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612f6d565b610d4f828683600081518110610d2257fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16611d5e9092919063ffffffff16565b6040517f38ed173900000000000000000000000000000000000000000000000000000000815260609073ffffffffffffffffffffffffffffffffffffffff8416906338ed173990610dad90899060019087903090429060040161312e565b600060405180830381600087803b158015610dc757600080fd5b505af1158015610ddb573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610e219190810190612492565b905080600182510381518110610e3357fe5b602002602001015193505050509392505050565b6000610e51612188565b82806020019051810190610e659190612761565b8051909150610e8c9073ffffffffffffffffffffffffffffffffffffffff88169086611d5e565b610e9461219f565b6040805160c0810190915260208084015182528101600081526020018873ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff168152602001868152602001604051806020016040528060008152508152509050610f0b612161565b506040805160808101825230808252600060208301819052828401919091526060820152835191517f52bbbe29000000000000000000000000000000000000000000000000000000008152909173ffffffffffffffffffffffffffffffffffffffff16906352bbbe2990610f8a90859085906001904290600401613030565b602060405180830381600087803b158015610fa457600080fd5b505af1158015610fb8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fdc919061286d565b98975050505050505050565b60008060608084806020019051810190611002919061253a565b925092509250606081905061101f848883600081518110610d2257fe5b868360008151811061102d57fe5b602002602001015160600181815250506060815167ffffffffffffffff8111801561105757600080fd5b50604051908082528060200260200182016040528015611081578160200160208202803683370190505b50905060005b81518110156110d0577f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8282815181106110bd57fe5b6020908102919091010152600101611087565b50604080516080810182523080825260006020830181905282840191909152606082810182905292517f945bcec900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff89169263945bcec9926111549290918a9189919089904260010190600401612bbe565b600060405180830381600087803b15801561116e57600080fd5b505af1158015611182573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526111c89190810190612492565b90506000816001835103815181106111dc57fe5b6020026020010151131561121c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612d3f565b8060018251038151811061122c57fe5b60200260200101517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0296505050505050505b92915050565b6000808280602001905181019061127c9190612700565b905061129f73ffffffffffffffffffffffffffffffffffffffff87168286611d5e565b6040517fd5bcb9b500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82169063d5bcb9b590610bd2908990899089906001903090600401612b51565b6000806000808480602001905181019061131491906125f6565b9194509250905061133c73ffffffffffffffffffffffffffffffffffffffff88168388611d5e565b80156113ff57604080516000815260208101918290527f8dae73330000000000000000000000000000000000000000000000000000000090915273ffffffffffffffffffffffffffffffffffffffff831690638dae7333906113a690899060019060248101613177565b602060405180830381600087803b1580156113c057600080fd5b505af11580156113d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f8919061286d565b935061155d565b6040517fca19ebd900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84169063ca19ebd9906114539085908a90600401612a33565b60206040518083038186803b15801561146b57600080fd5b505afa15801561147f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114a3919061286d565b604080516000815260208101918290527fe67ce7060000000000000000000000000000000000000000000000000000000090915290945073ffffffffffffffffffffffffffffffffffffffff83169063e67ce706906115099087908a9060248101613177565b602060405180830381600087803b15801561152357600080fd5b505af1158015611537573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155b919061286d565b505b5050509392505050565b6000806000838060200190518101906115809190612646565b90925090506115a673ffffffffffffffffffffffffffffffffffffffff87168387611e66565b80611654576040517fdd93f59a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169063dd93f59a906115fd9030906004016129eb565b602060405180830381600087803b15801561161757600080fd5b505af115801561162b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164f919061286d565b610c24565b6040517fbd6015b400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169063bd6015b490610bd29030906004016129eb565b60006116b0612161565b828060200190518101906116c49190612852565b80519091506116eb9073ffffffffffffffffffffffffffffffffffffffff87169086611d5e565b60006060826000015173ffffffffffffffffffffffffffffffffffffffff1683602001518460400151856060015189600142604051602401611731959493929190612cb4565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516117ba91906129cf565b6000604051808303816000865af19150503d80600081146117f7576040519150601f19603f3d011682016040523d82523d6000602084013e6117fc565b606091505b50915091508161180f5761180f81611e3a565b80806020019051810190611823919061286d565b979650505050505050565b60008060608084806020019051810190611848919061241e565b815192955090935091506001111561188c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612eb3565b81516001018151146118ca576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612df9565b8673ffffffffffffffffffffffffffffffffffffffff16816001835103815181106118f157fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1614611946576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612ce2565b611958838783600081518110610d2257fe5b6040517fceb757d500000000000000000000000000000000000000000000000000000000815260609073ffffffffffffffffffffffffffffffffffffffff85169063ceb757d5906119b8908a9060019088908890309042906004016130d1565b600060405180830381600087803b1580156119d257600080fd5b505af11580156119e6573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052611a2c9190810190612492565b905080600182510381518110611a3e57fe5b60200260200101519450505050509392505050565b600080600083806020019051810190611a6c9190612683565b9092509050611a9273ffffffffffffffffffffffffffffffffffffffff88168387611d5e565b8073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611b5b576040517fe8eda9df00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169063e8eda9df90611b1f908a9089903090600090600401612a89565b600060405180830381600087803b158015611b3957600080fd5b505af1158015611b4d573d6000803e3d6000fd5b5050505084925050506108bd565b8073ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff161415611c40576040517f69328dec00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8316906369328dec90611be590899089903090600401612a59565b602060405180830381600087803b158015611bff57600080fd5b505af1158015611c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c37919061286d565b925050506108bd565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612f10565b600080606083806020019051810190611c8b91906126b1565b9092509050611cb173ffffffffffffffffffffffffffffffffffffffff88168387611e66565b6040517f65d02b0400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8316906365d02b0490611d0c908a908a9030906001908890600401612b0a565b602060405180830381600087803b158015611d2657600080fd5b505af1158015611d3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611823919061286d565b6040517fdd62ed3e000000000000000000000000000000000000000000000000000000008152819073ffffffffffffffffffffffffffffffffffffffff85169063dd62ed3e90611db49030908790600401612a0c565b60206040518083038186803b158015611dcc57600080fd5b505afa158015611de0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e04919061286d565b1015611e3557611e3583837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff611f12565b505050565b805160208201fd5b600082821115611e6057611e60611e5b60028585611f2f565b611e3a565b50900390565b606063a9059cbb60e01b8383604051602401611e83929190612a33565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091529050611f0c8482611fd4565b50505050565b606063095ea7b360e01b8383604051602401611e83929190612a33565b606063e946c1bb60e01b848484604051602401611f4e93929190612b8e565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915290509392505050565b600060608373ffffffffffffffffffffffffffffffffffffffff1683604051611ffd91906129cf565b6000604051808303816000865af19150503d806000811461203a576040519150601f19603f3d011682016040523d82523d6000602084013e61203f565b606091505b5091509150816120525761205281611e3a565b805161209957833b80612091576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612e56565b5050506120d6565b60208151106120cd5760006120af8260006120da565b905080600114156120c2575050506120d6565b6120cb82611e3a565b505b611f0c81611e3a565b5050565b60006120e683836120ed565b9392505050565b6000816020018351101561210e5761210e611e5b6005855185602001612117565b50016020015190565b6060632800659560e01b848484604051602401611f4e93929190612bb0565b6040518060800160405280600080191681526020016000815260200160008152602001606081525090565b60408051608081018252600080825260208201819052918101829052606081019190915290565b604080518082019091526000808252602082015290565b6040805160c08101909152600080825260208201908152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001606081525090565b600082601f830112612212578081fd5b8151612225612220826131bd565b613196565b81815291506020808301908481018184028601820187101561224657600080fd5b60005b8481101561226e57815161225c81613258565b84529282019290820190600101612249565b505050505092915050565b600082601f830112612289578081fd5b8135612297612220826131dd565b91508082528360208285010111156122ae57600080fd5b8060208401602084013760009082016020015292915050565b600082601f8301126122d7578081fd5b81516122e5612220826131dd565b91508082528360208285010111156122fc57600080fd5b61230d81602084016020860161321f565b5092915050565b803561125f81613258565b600060a08284031215612330578081fd5b61233a60a0613196565b905081518152602082015160208201526040820151604082015260608201516060820152608082015167ffffffffffffffff81111561237857600080fd5b612384848285016122c7565b60808301525092915050565b6000608082840312156123a1578081fd5b6123ab6080613196565b905081516123b881613258565b815260208201517fffffffff00000000000000000000000000000000000000000000000000000000811681146123ed57600080fd5b602082015260408201516124008161327a565b604082015260608201516124138161327a565b606082015292915050565b600080600060608486031215612432578283fd5b835161243d81613258565b602085015190935067ffffffffffffffff8082111561245a578384fd5b61246687838801612202565b9350604086015191508082111561247b578283fd5b5061248886828701612202565b9150509250925092565b600060208083850312156124a4578182fd5b825167ffffffffffffffff8111156124ba578283fd5b8301601f810185136124ca578283fd5b80516124d8612220826131bd565b81815283810190838501858402850186018910156124f4578687fd5b8694505b838510156125165780518352600194909401939185019185016124f8565b50979650505050505050565b600060208284031215612533578081fd5b5035919050565b60008060006060848603121561254e578081fd5b835161255981613258565b8093505060208085015167ffffffffffffffff80821115612578578384fd5b818701915087601f83011261258b578384fd5b8151612599612220826131bd565b81815284810190848601875b848110156125ce576125bc8d8984518a010161231f565b845292870192908701906001016125a5565b505060408a015190975094505050808311156125e8578384fd5b505061248886828701612202565b60008060006060848603121561260a578081fd5b835161261581613258565b602085015190935061262681613258565b6040850151909250801515811461263b578182fd5b809150509250925092565b60008060408385031215612658578182fd5b825161266381613258565b60208401519092508015158114612678578182fd5b809150509250929050565b60008060408385031215612695578182fd5b82516126a081613258565b602084015190925061267881613258565b600080604083850312156126c3578182fd5b82516126ce81613258565b602084015190925067ffffffffffffffff8111156126ea578182fd5b6126f6858286016122c7565b9150509250929050565b600060208284031215612711578081fd5b81516120e681613258565b6000806040838503121561272e578182fd5b825161273981613258565b602084015190925067ffffffffffffffff811115612755578182fd5b6126f685828601612202565b600060408284031215612772578081fd5b61277c6040613196565b825161278781613258565b81526020928301519281019290925250919050565b600080600080608085870312156127b1578182fd5b843567ffffffffffffffff808211156127c8578384fd5b90860190608082890312156127db578384fd5b6127e56080613196565b82358152602083013560208201526040830135604082015260608301358281111561280e578586fd5b61281a8a828601612279565b6060830152508096505050506128338660208701612314565b92506128428660408701612314565b9396929550929360600135925050565b600060808284031215612863578081fd5b6120e68383612390565b60006020828403121561287e578081fd5b5051919050565b6000815180845260208085019450808401835b838110156128ca57815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101612898565b509495945050505050565b6000815180845260208085019450808401835b838110156128ca578151875295820195908201906001016128e8565b6000815180845261291c81602086016020860161321f565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600081518352602082015160208401526040820151604084015260608201516060840152608082015160a060808501526108bd60a0850182612904565b73ffffffffffffffffffffffffffffffffffffffff808251168352602082015115156020840152806040830151166040840152506060810151151560608301525050565b600082516129e181846020870161321f565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff93841681526020810192909252909116604082015260600190565b73ffffffffffffffffffffffffffffffffffffffff948516815260208101939093529216604082015261ffff909116606082015260800190565b901515815260200190565b94855273ffffffffffffffffffffffffffffffffffffffff93841660208601529190921660408401526060830191909152608082015260a00190565b600073ffffffffffffffffffffffffffffffffffffffff8088168352808716602084015280861660408401525083606083015260a0608083015261182360a0830184612904565b73ffffffffffffffffffffffffffffffffffffffff9586168152938516602085015260408401929092526060830152909116608082015260a00190565b6060810160048510612b9c57fe5b938152602081019290925260409091015290565b6060810160088510612b9c57fe5b6000610120808301612bcf8a61324b565b898452602080850192909252885190819052610140808501928281028601909101918a8201855b82811015612c42577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec0888603018652612c3085835161294e565b95840195945090830190600101612bf6565b505050508381036040850152612c588189612885565b915050612c68606084018761298b565b82810360e0840152612c7a81866128d5565b91505082610100830152979650505050505050565b600f94850b81529290930b6020830152604082015260ff909116606082015260800190565b600f95860b81529390940b6020840152604083019190915260ff166060820152608081019190915260a00190565b6020808252603a908201527f4d6978696e4b79626572446d6d2f4c4153545f454c454d454e545f4f465f504160408201527f54485f4d5553545f4d415443485f4f55545055545f544f4b454e000000000000606082015260800190565b60208082526021908201527f556e65787065637465642042616c616e63657256324261746368206f7574707560408201527f7400000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f4d6978696e556e697377617056322f504154485f4c454e4754485f4d5553545f60408201527f42455f41545f4c454153545f54574f0000000000000000000000000000000000606082015260800190565b60208082526023908201527f4d6978696e4b79626572446d6d2f41525241595f4c454e4754485f4d49534d4160408201527f5443480000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526027908201527f696e76616c696420746f6b656e20616464726573732c20636f6e7461696e732060408201527f6e6f20636f646500000000000000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f4d6978696e4b79626572446d6d2f504f4f4c535f4c454e4754485f4d5553545f60408201527f42455f41545f4c454153545f4f4e450000000000000000000000000000000000606082015260800190565b60208082526022908201527f4d6978696e4161766556322f554e535550504f525445445f544f4b454e5f504160408201527f4952000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252603b908201527f4d6978696e556e697377617056322f4c4153545f454c454d454e545f4f465f5060408201527f4154485f4d5553545f4d415443485f4f55545055545f544f4b454e0000000000606082015260800190565b600060208252825160a06020840152612fe660c0840182612904565b905073ffffffffffffffffffffffffffffffffffffffff60208501511660408401526040840151606084015260608401516080840152608084015160a08401528091505092915050565b600060e08252855160e0830152602086015161304b8161324b565b610100830152604086015173ffffffffffffffffffffffffffffffffffffffff908116610120840152606087015116610140830152608086015161016083015260a086015160c06101808401526130a66101a0840182612904565b9150506130b6602083018661298b565b60a082019390935260c0015292915050565b90815260200190565b600087825286602083015260c060408301526130f060c0830187612885565b82810360608401526131028187612885565b73ffffffffffffffffffffffffffffffffffffffff959095166080840152505060a00152949350505050565b600086825285602083015260a0604083015261314d60a0830186612885565b73ffffffffffffffffffffffffffffffffffffffff94909416606083015250608001529392505050565b6000848252836020830152606060408301526100a16060830184612904565b60405181810167ffffffffffffffff811182821017156131b557600080fd5b604052919050565b600067ffffffffffffffff8211156131d3578081fd5b5060209081020190565b600067ffffffffffffffff8211156131f3578081fd5b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60005b8381101561323a578181015183820152602001613222565b83811115611f0c5750506000910152565b6002811061325557fe5b50565b73ffffffffffffffffffffffffffffffffffffffff8116811461325557600080fd5b80600f0b811461325557600080fdfea2646970667358221220e52b7f7baec09f1909a4272f1f673be4a10da31bf94784404ef41f5421626a5464736f6c634300060c0033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000009c3c9283d3e44854697cd22d3faa240cfb032889

-----Decoded View---------------
Arg [0] : weth (address): 0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000009c3c9283d3e44854697cd22d3faa240cfb032889


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ 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.