Contract 0x85d284abc931e4ade71eee52341a0c83845f811c

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x3fa790f94fb5d351cc803f3be002aa16e5bc2a8879428039fbab7a86df72f8e3Issue Exact Set ...220494532021-12-02 12:56:014 mins ago0x9ad568acd49b810e7563f8752058d3acd0424ae4 IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.0330968396
0x7a6163a9378ac6e7d1c78b99899906cda25c0da29b3ceaa77f32a6523592e36fRedeem Exact Set...220494412021-12-02 12:55:375 mins ago0xa0156d1cbb3574a0bad2d98b37624c7b302ece1c IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.014019926
0x176dedaddae36e40cd2569c5f21643200bf54dcd289533f8216a7a1e29fd8ff0Issue Exact Set ...220494162021-12-02 12:54:465 mins ago0xa0156d1cbb3574a0bad2d98b37624c7b302ece1c IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.013723524
0x1fb850506f51bfb52eb52581a06faebfe801f61ded62dc24994cf688f4083fc3Issue Exact Set ...220493322021-12-02 12:51:389 mins ago0xe2f614b89ded052a5d1794712d74110eaaed4322 IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.026782074
0xcc3fb2f2403f46aaee34eac7bae66b059df12c1db5e5bce586015e9ae9a672aeIssue Exact Set ...220492712021-12-02 12:49:3211 mins ago0x4575ab97afa4a7b67395aaf3cb306784b0bebe04 IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.02705718
0x6752afb2cac963bc1ebcd7b2c9f146e3d4d4ff80178a174733c9a1af33c08886Issue Exact Set ...220492162021-12-02 12:47:4213 mins ago0x180854e89dd75ec8df5d77a7bad762d37cdcef12 IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.0366289
0x90251c866125cae24587e1f45e78559f9d61ab18376402c1b805376b01005c42Redeem Exact Set...220492112021-12-02 12:47:2813 mins ago0x5ab36bdf066a5494c39d7d3287fd1a889c3c3d0c IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.051413472
0x42072040021de6b940f196bdf37c898e229e7eda6b9154edae42f9a01f4b345fIssue Exact Set ...220491752021-12-02 12:46:1614 mins ago0x5ab36bdf066a5494c39d7d3287fd1a889c3c3d0c IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.044338525
0x4b9b2dd73851b9400fdee2a87fea0a6963309611ed28ce182a41e0700db0f341Issue Exact Set ...220491642021-12-02 12:45:5414 mins ago0x33b624631f2fcf25e8289dabeee9e308696d146a IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.03868161
0xce49484cd165b6598812c8d3d85c030d0bcfc6d32a2c7fada2b672709088e16bIssue Exact Set ...220490852021-12-02 12:43:0717 mins ago0x0f593310de3815b46ede4d0585f400477094da73 IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.0338198
0x88082b2a242aa15d3f2b4a5854ad7e3abdff8262aa5728e756a04d605d9bef4eRedeem Exact Set...220490742021-12-02 12:42:4517 mins ago0x1bf73d22ca218daa2f2892626b17b103ec86b53e IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.00933042
0x1b1322b31e651bece67fb617c36b841bba5e4870fbdb168eecfd3523e6055602Redeem Exact Set...220490392021-12-02 12:41:3519 mins ago0x5ab36bdf066a5494c39d7d3287fd1a889c3c3d0c IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.02568132
0x8b823860303d41fc7f89a9dbf609fb88cf5acc27a4d43357201b464193cd9da6Issue Exact Set ...220489642021-12-02 12:39:0121 mins ago0x5ab36bdf066a5494c39d7d3287fd1a889c3c3d0c IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.0228189
0x62e1574d1b50e3c0ae711b35625a3aab6d7cb943971288a480bbc951cc70b6a2Issue Exact Set ...220489602021-12-02 12:38:5321 mins ago0x1bf73d22ca218daa2f2892626b17b103ec86b53e IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.01320666
0x557727c93d9715f063ef8a51ed58226d40f3571e4ebab07103afae9c79546da2Issue Exact Set ...220489592021-12-02 12:38:4721 mins ago0x5356f72b4f9f68b8dfc2a18d9aa647ec01ec358a IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.04024212
0xb54105dce79b1b0f43cb0e3ef9a1a413031990b3ec27eacf784d65e87eb201beIssue Exact Set ...220488362021-12-02 12:34:3726 mins ago0x3e499bcc0beb4e2e19e64287827df177d8747732 IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.00905364
0x4921bdbb6a178f3fd0b573b2b4ccddf80a031f5c5d965ecf5869fdc9e9338cb0Issue Exact Set ...220488172021-12-02 12:33:5526 mins ago0x8c69f8d2f360d0bd12cb73b92e90a380e32987bb IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.047354
0xcb39adc86b4194822c91a87b092623dacd4a75cf547f8dba0ab77217caa2df58Redeem Exact Set...220485972021-12-02 12:26:2334 mins ago0x966aceda1a0653856dd91322d108f66ee90c4875 IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.01332156
0xa6a663a7154ba1938227d1decc19f2d50edf54747b9ecb3d0961716bf5446c10Redeem Exact Set...220485562021-12-02 12:24:5735 mins ago0x78ce076b1cbd4b46689d538b41f6686c955fe74d IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.05452944
0xf22bb0114688d68ac510a90e4f961befe1f7a3d56e9f1f6d6b5358f2341d162cIssue Exact Set ...220485272021-12-02 12:23:5936 mins ago0x78ce076b1cbd4b46689d538b41f6686c955fe74d IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.136240195
0x70afda79d8fc0aa38a56e77d3b2bf27cdd820d7b8cba169af5c6329773c3db77Redeem Exact Set...220484932021-12-02 12:22:4737 mins ago0xdfe9823e47e0acd17921d19a7e219625ac1f2a54 IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.00933042
0xe9f416d2146435151f22902751f7dae84504cff75eb3a2ed8d612c36acc2644eIssue Exact Set ...220484782021-12-02 12:22:1738 mins ago0x966aceda1a0653856dd91322d108f66ee90c4875 IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.01715754
0xfa6d54c9f38d3375bc8d82ee99b859a021a07b4a6cc6e4a7bf356822dcda1214Redeem Exact Set...220484052021-12-02 12:19:4740 mins ago0x78ce076b1cbd4b46689d538b41f6686c955fe74d IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.062480105
0xe21283cce8db3ce92e5842cae4316f2948f7ada16685ac42374878c15f9a7ba1Issue Exact Set ...220483842021-12-02 12:19:0541 mins ago0x78ce076b1cbd4b46689d538b41f6686c955fe74d IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.054894096
0x22c518a67857adec119e8fe064241af93d01cda5ddbbef83b675e463b0bf790cRedeem Exact Set...220483822021-12-02 12:18:5741 mins ago0x2d0b06ab52399a1c19856922e08b40d36aa73af3 IN  0x85d284abc931e4ade71eee52341a0c83845f811c0 MATIC0.04139968
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ExchangeIssuanceV2

Compiler Version
v0.6.10+commit.00c0fcaf

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 18 : ExchangeIssuanceV2.sol
/*
    Copyright 2021 Index Cooperative
    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.
    SPDX-License-Identifier: Apache License, Version 2.0
*/
pragma solidity 0.6.10;
pragma experimental ABIEncoderV2;

import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IUniswapV2Factory } from "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import { IUniswapV2Router02 } from "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import { Math } from "@openzeppelin/contracts/math/Math.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

import { IBasicIssuanceModule } from "../interfaces/IBasicIssuanceModule.sol";
import { IController } from "../interfaces/IController.sol";
import { ISetToken } from "../interfaces/ISetToken.sol";
import { IWETH } from "../interfaces/IWETH.sol";
import { PreciseUnitMath } from "../lib/PreciseUnitMath.sol";
import { UniSushiV2Library } from "../../external/contracts/UniSushiV2Library.sol";

/**
 * @title ExchangeIssuance
 * @author Index Coop
 *
 * Contract for issuing and redeeming any SetToken using ETH or an ERC20 as the paying/receiving currency.
 * All swaps are done using the best price found on Uniswap or Sushiswap.
 *
 */
contract ExchangeIssuanceV2 is ReentrancyGuard {

    using Address for address payable;
    using SafeMath for uint256;
    using PreciseUnitMath for uint256;
    using SafeERC20 for IERC20;
    using SafeERC20 for ISetToken;

    /* ============ Enums ============ */

    enum Exchange { Uniswap, Sushiswap, None }

    /* ============ Constants ============= */

    uint256 constant private MAX_UINT96 = 2**96 - 1;
    address constant public ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

    /* ============ State Variables ============ */

    address public WETH;
    IUniswapV2Router02 public uniRouter;
    IUniswapV2Router02 public sushiRouter;

    address public immutable uniFactory;
    address public immutable sushiFactory;

    IController public immutable setController;
    IBasicIssuanceModule public immutable basicIssuanceModule;

    /* ============ Events ============ */

    event ExchangeIssue(
        address indexed _recipient,     // The recipient address of the issued SetTokens
        ISetToken indexed _setToken,    // The issued SetToken
        IERC20 indexed _inputToken,     // The address of the input asset(ERC20/ETH) used to issue the SetTokens
        uint256 _amountInputToken,      // The amount of input tokens used for issuance
        uint256 _amountSetIssued        // The amount of SetTokens received by the recipient
    );

    event ExchangeRedeem(
        address indexed _recipient,     // The recipient address which redeemed the SetTokens
        ISetToken indexed _setToken,    // The redeemed SetToken
        IERC20 indexed _outputToken,    // The address of output asset(ERC20/ETH) received by the recipient
        uint256 _amountSetRedeemed,     // The amount of SetTokens redeemed for output tokens
        uint256 _amountOutputToken      // The amount of output tokens received by the recipient
    );

    event Refund(
        address indexed _recipient,     // The recipient address which redeemed the SetTokens
        uint256 _refundAmount           // The amount of ETH redunded to the recipient
    );

    /* ============ Modifiers ============ */

    modifier isSetToken(ISetToken _setToken) {
         require(setController.isSet(address(_setToken)), "ExchangeIssuance: INVALID SET");
         _;
    }

    /* ============ Constructor ============ */

    constructor(
        address _weth,
        address _uniFactory,
        IUniswapV2Router02 _uniRouter,
        address _sushiFactory,
        IUniswapV2Router02 _sushiRouter,
        IController _setController,
        IBasicIssuanceModule _basicIssuanceModule
    )
        public
    {
        uniFactory = _uniFactory;
        uniRouter = _uniRouter;

        sushiFactory = _sushiFactory;
        sushiRouter = _sushiRouter;

        setController = _setController;
        basicIssuanceModule = _basicIssuanceModule;

        WETH = _weth;
        IERC20(WETH).safeApprove(address(uniRouter), PreciseUnitMath.maxUint256());
        IERC20(WETH).safeApprove(address(sushiRouter), PreciseUnitMath.maxUint256());
    }

    /* ============ Public Functions ============ */

    /**
     * Runs all the necessary approval functions required for a given ERC20 token.
     * This function can be called when a new token is added to a SetToken during a
     * rebalance.
     *
     * @param _token    Address of the token which needs approval
     */
    function approveToken(IERC20 _token) public {
        _safeApprove(_token, address(uniRouter), MAX_UINT96);
        _safeApprove(_token, address(sushiRouter), MAX_UINT96);
        _safeApprove(_token, address(basicIssuanceModule), MAX_UINT96);
    }

    /* ============ External Functions ============ */

    /**
     * Runs all the necessary approval functions required for a list of ERC20 tokens.
     *
     * @param _tokens    Addresses of the tokens which need approval
     */
    function approveTokens(IERC20[] calldata _tokens) external {
        for (uint256 i = 0; i < _tokens.length; i++) {
            approveToken(_tokens[i]);
        }
    }

    /**
     * Runs all the necessary approval functions required before issuing
     * or redeeming a SetToken. This function need to be called only once before the first time
     * this smart contract is used on any particular SetToken.
     *
     * @param _setToken    Address of the SetToken being initialized
     */
    function approveSetToken(ISetToken _setToken) isSetToken(_setToken) external {
        address[] memory components = _setToken.getComponents();
        for (uint256 i = 0; i < components.length; i++) {
            // Check that the component does not have external positions
            require(
                _setToken.getExternalPositionModules(components[i]).length == 0,
                "ExchangeIssuance: EXTERNAL_POSITIONS_NOT_ALLOWED"
            );
            approveToken(IERC20(components[i]));
        }
    }

    /**
     * Issues SetTokens for an exact amount of input ERC20 tokens.
     * The ERC20 token must be approved by the sender to this contract.
     *
     * @param _setToken         Address of the SetToken being issued
     * @param _inputToken       Address of input token
     * @param _amountInput      Amount of the input token / ether to spend
     * @param _minSetReceive    Minimum amount of SetTokens to receive. Prevents unnecessary slippage.
     *
     * @return setTokenAmount   Amount of SetTokens issued to the caller
     */
    function issueSetForExactToken(
        ISetToken _setToken,
        IERC20 _inputToken,
        uint256 _amountInput,
        uint256 _minSetReceive
    )
        isSetToken(_setToken)
        external
        nonReentrant
        returns (uint256)
    {
        require(_amountInput > 0, "ExchangeIssuance: INVALID INPUTS");

        _inputToken.safeTransferFrom(msg.sender, address(this), _amountInput);

        uint256 amountEth = address(_inputToken) == WETH
            ? _amountInput
            : _swapTokenForWETH(_inputToken, _amountInput);

        uint256 setTokenAmount = _issueSetForExactWETH(_setToken, _minSetReceive, amountEth);

        emit ExchangeIssue(msg.sender, _setToken, _inputToken, _amountInput, setTokenAmount);
        return setTokenAmount;
    }

    /**
    * Issues an exact amount of SetTokens for given amount of input ERC20 tokens.
    * The excess amount of tokens is returned in an equivalent amount of ether.
    *
    * @param _setToken              Address of the SetToken to be issued
    * @param _inputToken            Address of the input token
    * @param _amountSetToken        Amount of SetTokens to issue
    * @param _maxAmountInputToken   Maximum amount of input tokens to be used to issue SetTokens. The unused
    *                               input tokens are returned as ether.
    *
    * @return amountEthReturn       Amount of ether returned to the caller
    */
    function issueExactSetFromToken(
        ISetToken _setToken,
        IERC20 _inputToken,
        uint256 _amountSetToken,
        uint256 _maxAmountInputToken
    )
        isSetToken(_setToken)
        external
        nonReentrant
        returns (uint256)
    {
        require(_amountSetToken > 0 && _maxAmountInputToken > 0, "ExchangeIssuance: INVALID INPUTS");

        _inputToken.safeTransferFrom(msg.sender, address(this), _maxAmountInputToken);

        uint256 initETHAmount = address(_inputToken) == WETH
            ? _maxAmountInputToken
            : _swapTokenForWETH(_inputToken, _maxAmountInputToken);

        uint256 amountEthSpent = _issueExactSetFromWETH(_setToken, _amountSetToken, initETHAmount);

        uint256 amountEthReturn = initETHAmount.sub(amountEthSpent);
        if (amountEthReturn > 0) {
            IERC20(WETH).safeTransfer(msg.sender,  amountEthReturn);
        }

        emit Refund(msg.sender, amountEthReturn);
        emit ExchangeIssue(msg.sender, _setToken, _inputToken, _maxAmountInputToken, _amountSetToken);
        return amountEthReturn;
    }

    /**
     * Redeems an exact amount of SetTokens for an ERC20 token.
     * The SetToken must be approved by the sender to this contract.
     *
     * @param _setToken             Address of the SetToken being redeemed
     * @param _outputToken          Address of output token
     * @param _amountSetToken       Amount SetTokens to redeem
     * @param _minOutputReceive     Minimum amount of output token to receive
     *
     * @return outputAmount         Amount of output tokens sent to the caller
     */
    function redeemExactSetForToken(
        ISetToken _setToken,
        IERC20 _outputToken,
        uint256 _amountSetToken,
        uint256 _minOutputReceive
    )
        isSetToken(_setToken)
        external
        nonReentrant
        returns (uint256)
    {
        require(_amountSetToken > 0, "ExchangeIssuance: INVALID INPUTS");

        address[] memory components = _setToken.getComponents();
        (
            uint256 totalEth,
            uint256[] memory amountComponents,
            Exchange[] memory exchanges
        ) =  _getAmountETHForRedemption(_setToken, components, _amountSetToken);

        uint256 outputAmount;
        if (address(_outputToken) == WETH) {
            require(totalEth > _minOutputReceive, "ExchangeIssuance: INSUFFICIENT_OUTPUT_AMOUNT");
            _redeemExactSet(_setToken, _amountSetToken);
            outputAmount = _liquidateComponentsForWETH(components, amountComponents, exchanges);
        } else {
            (uint256 totalOutput, Exchange outTokenExchange, ) = _getMaxTokenForExactToken(totalEth, address(WETH), address(_outputToken));
            require(totalOutput > _minOutputReceive, "ExchangeIssuance: INSUFFICIENT_OUTPUT_AMOUNT");
            _redeemExactSet(_setToken, _amountSetToken);
            uint256 outputEth = _liquidateComponentsForWETH(components, amountComponents, exchanges);
            outputAmount = _swapExactTokensForTokens(outTokenExchange, WETH, address(_outputToken), outputEth);
        }

        _outputToken.safeTransfer(msg.sender, outputAmount);
        emit ExchangeRedeem(msg.sender, _setToken, _outputToken, _amountSetToken, outputAmount);
        return outputAmount;
    }


    /**
     * Returns an estimated amount of SetToken that can be issued given an amount of input ERC20 token.
     *
     * @param _setToken         Address of the SetToken being issued
     * @param _amountInput      Amount of the input token to spend
     * @param _inputToken       Address of input token.
     *
     * @return                  Estimated amount of SetTokens that will be received
     */
    function getEstimatedIssueSetAmount(
        ISetToken _setToken,
        IERC20 _inputToken,
        uint256 _amountInput
    )
        isSetToken(_setToken)
        external
        view
        returns (uint256)
    {
        require(_amountInput > 0, "ExchangeIssuance: INVALID INPUTS");

        uint256 amountEth;
        if (address(_inputToken) != WETH) {
            // get max amount of WETH for the `_amountInput` amount of input tokens
            (amountEth, , ) = _getMaxTokenForExactToken(_amountInput, address(_inputToken), WETH);
        } else {
            amountEth = _amountInput;
        }

        address[] memory components = _setToken.getComponents();
        (uint256 setIssueAmount, , ) = _getSetIssueAmountForETH(_setToken, components, amountEth);
        return setIssueAmount;
    }

    /**
    * Returns the amount of input ERC20 tokens required to issue an exact amount of SetTokens.
    *
    * @param _setToken          Address of the SetToken being issued
    * @param _amountSetToken    Amount of SetTokens to issue
    *
    * @return                   Amount of tokens needed to issue specified amount of SetTokens
    */
    function getAmountInToIssueExactSet(
        ISetToken _setToken,
        IERC20 _inputToken,
        uint256 _amountSetToken
    )
        isSetToken(_setToken)
        external
        view
        returns(uint256)
    {
        require(_amountSetToken > 0, "ExchangeIssuance: INVALID INPUTS");

        address[] memory components = _setToken.getComponents();
        (uint256 totalEth, , , , ) = _getAmountETHForIssuance(_setToken, components, _amountSetToken);

        if (address(_inputToken) == WETH) {
            return totalEth;
        }

        (uint256 tokenAmount, , ) = _getMinTokenForExactToken(totalEth, address(_inputToken), address(WETH));
        return tokenAmount;
    }

    /**
     * Returns amount of output ERC20 tokens received upon redeeming a given amount of SetToken.
     *
     * @param _setToken             Address of SetToken to be redeemed
     * @param _amountSetToken       Amount of SetToken to be redeemed
     * @param _outputToken          Address of output token
     *
     * @return                      Estimated amount of ether/erc20 that will be received
     */
    function getAmountOutOnRedeemSet(
        ISetToken _setToken,
        address _outputToken,
        uint256 _amountSetToken
    )
        isSetToken(_setToken)
        external
        view
        returns (uint256)
    {
        require(_amountSetToken > 0, "ExchangeIssuance: INVALID INPUTS");

        address[] memory components = _setToken.getComponents();
        (uint256 totalEth, , ) = _getAmountETHForRedemption(_setToken, components, _amountSetToken);

        if (_outputToken == WETH) {
            return totalEth;
        }

        // get maximum amount of tokens for totalEth amount of ETH
        (uint256 tokenAmount, , ) = _getMaxTokenForExactToken(totalEth, WETH, _outputToken);
        return tokenAmount;
    }


    /* ============ Internal Functions ============ */

    /**
     * Sets a max approval limit for an ERC20 token, provided the current allowance
     * is less than the required allownce.
     *
     * @param _token    Token to approve
     * @param _spender  Spender address to approve
     */
    function _safeApprove(IERC20 _token, address _spender, uint256 _requiredAllowance) internal {
        uint256 allowance = _token.allowance(address(this), _spender);
        if (allowance < _requiredAllowance) {
            _token.safeIncreaseAllowance(_spender, MAX_UINT96 - allowance);
        }
    }

    /**
     * Issues SetTokens for an exact amount of input WETH.
     *
     * @param _setToken         Address of the SetToken being issued
     * @param _minSetReceive    Minimum amount of index to receive
     * @param _totalEthAmount   Total amount of WETH to be used to purchase the SetToken components
     *
     * @return setTokenAmount   Amount of SetTokens issued
     */
    function _issueSetForExactWETH(ISetToken _setToken, uint256 _minSetReceive, uint256 _totalEthAmount) internal returns (uint256) {

        address[] memory components = _setToken.getComponents();
        (
            uint256 setIssueAmount,
            uint256[] memory amountEthIn,
            Exchange[] memory exchanges
        ) = _getSetIssueAmountForETH(_setToken, components, _totalEthAmount);

        require(setIssueAmount > _minSetReceive, "ExchangeIssuance: INSUFFICIENT_OUTPUT_AMOUNT");

        for (uint256 i = 0; i < components.length; i++) {
            _swapExactTokensForTokens(exchanges[i], WETH, components[i], amountEthIn[i]);
        }

        basicIssuanceModule.issue(_setToken, setIssueAmount, msg.sender);
        return setIssueAmount;
    }

    /**
     * Issues an exact amount of SetTokens using WETH.
     * Acquires SetToken components at the best price accross uniswap and sushiswap.
     * Uses the acquired components to issue the SetTokens.
     *
     * @param _setToken          Address of the SetToken being issued
     * @param _amountSetToken    Amount of SetTokens to be issued
     * @param _maxEther          Max amount of ether that can be used to acquire the SetToken components
     *
     * @return totalEth          Total amount of ether used to acquire the SetToken components
     */
    function _issueExactSetFromWETH(ISetToken _setToken, uint256 _amountSetToken, uint256 _maxEther) internal returns (uint256) {

        address[] memory components = _setToken.getComponents();
        (
            uint256 sumEth,
            ,
            Exchange[] memory exchanges,
            uint256[] memory amountComponents,
        ) = _getAmountETHForIssuance(_setToken, components, _amountSetToken);

        require(sumEth <= _maxEther, "ExchangeIssuance: INSUFFICIENT_INPUT_AMOUNT");

        uint256 totalEth = 0;
        for (uint256 i = 0; i < components.length; i++) {
            uint256 amountEth = _swapTokensForExactTokens(exchanges[i], WETH, components[i], amountComponents[i]);
            totalEth = totalEth.add(amountEth);
        }
        basicIssuanceModule.issue(_setToken, _amountSetToken, msg.sender);
        return totalEth;
    }

    /**
     * Redeems a given amount of SetToken.
     *
     * @param _setToken     Address of the SetToken to be redeemed
     * @param _amount       Amount of SetToken to be redeemed
     */
    function _redeemExactSet(ISetToken _setToken, uint256 _amount) internal returns (uint256) {
        _setToken.safeTransferFrom(msg.sender, address(this), _amount);
        basicIssuanceModule.redeem(_setToken, _amount, address(this));
    }

    /**
     * Liquidates a given list of SetToken components for WETH.
     *
     * @param _components           An array containing the address of SetToken components
     * @param _amountComponents     An array containing the amount of each SetToken component
     * @param _exchanges            An array containing the exchange on which to liquidate the SetToken component
     *
     * @return                      Total amount of WETH received after liquidating all SetToken components
     */
    function _liquidateComponentsForWETH(address[] memory _components, uint256[] memory _amountComponents, Exchange[] memory _exchanges)
        internal
        returns (uint256)
    {
        uint256 sumEth = 0;
        for (uint256 i = 0; i < _components.length; i++) {
            sumEth = _exchanges[i] == Exchange.None
                ? sumEth.add(_amountComponents[i])
                : sumEth.add(_swapExactTokensForTokens(_exchanges[i], _components[i], WETH, _amountComponents[i]));
        }
        return sumEth;
    }

    /**
     * Gets the total amount of ether required for purchasing each component in a SetToken,
     * to enable the issuance of a given amount of SetTokens.
     *
     * @param _setToken             Address of the SetToken to be issued
     * @param _components           An array containing the addresses of the SetToken components
     * @param _amountSetToken       Amount of SetToken to be issued
     *
     * @return sumEth               The total amount of Ether reuired to issue the set
     * @return amountEthIn          An array containing the amount of ether to purchase each component of the SetToken
     * @return exchanges            An array containing the exchange on which to perform the purchase
     * @return amountComponents     An array containing the amount of each SetToken component required for issuing the given
     *                              amount of SetToken
     * @return pairAddresses        An array containing the pair addresses of ETH/component exchange pool
     */
    function _getAmountETHForIssuance(ISetToken _setToken, address[] memory _components, uint256 _amountSetToken)
        internal
        view
        returns (
            uint256 sumEth,
            uint256[] memory amountEthIn,
            Exchange[] memory exchanges,
            uint256[] memory amountComponents,
            address[] memory pairAddresses
        )
    {
        sumEth = 0;
        amountEthIn = new uint256[](_components.length);
        amountComponents = new uint256[](_components.length);
        exchanges = new Exchange[](_components.length);
        pairAddresses = new address[](_components.length);

        for (uint256 i = 0; i < _components.length; i++) {

            // Check that the component does not have external positions
            require(
                _setToken.getExternalPositionModules(_components[i]).length == 0,
                "ExchangeIssuance: EXTERNAL_POSITIONS_NOT_ALLOWED"
            );

            // Get minimum amount of ETH to be spent to acquire the required amount of SetToken component
            uint256 unit = uint256(_setToken.getDefaultPositionRealUnit(_components[i]));
            amountComponents[i] = uint256(unit).preciseMulCeil(_amountSetToken);

            (amountEthIn[i], exchanges[i], pairAddresses[i]) = _getMinTokenForExactToken(amountComponents[i], WETH, _components[i]);
            sumEth = sumEth.add(amountEthIn[i]);
        }
        return (sumEth, amountEthIn, exchanges, amountComponents, pairAddresses);
    }

    /**
     * Gets the total amount of ether returned from liquidating each component in a SetToken.
     *
     * @param _setToken             Address of the SetToken to be redeemed
     * @param _components           An array containing the addresses of the SetToken components
     * @param _amountSetToken       Amount of SetToken to be redeemed
     *
     * @return sumEth               The total amount of Ether that would be obtained from liquidating the SetTokens
     * @return amountComponents     An array containing the amount of SetToken component to be liquidated
     * @return exchanges            An array containing the exchange on which to liquidate the SetToken components
     */
    function _getAmountETHForRedemption(ISetToken _setToken, address[] memory _components, uint256 _amountSetToken)
        internal
        view
        returns (uint256, uint256[] memory, Exchange[] memory)
    {
        uint256 sumEth = 0;
        uint256 amountEth = 0;

        uint256[] memory amountComponents = new uint256[](_components.length);
        Exchange[] memory exchanges = new Exchange[](_components.length);

        for (uint256 i = 0; i < _components.length; i++) {

            // Check that the component does not have external positions
            require(
                _setToken.getExternalPositionModules(_components[i]).length == 0,
                "ExchangeIssuance: EXTERNAL_POSITIONS_NOT_ALLOWED"
            );

            uint256 unit = uint256(_setToken.getDefaultPositionRealUnit(_components[i]));
            amountComponents[i] = unit.preciseMul(_amountSetToken);

            // get maximum amount of ETH received for a given amount of SetToken component
            (amountEth, exchanges[i], ) = _getMaxTokenForExactToken(amountComponents[i], _components[i], WETH);
            sumEth = sumEth.add(amountEth);
        }
        return (sumEth, amountComponents, exchanges);
    }

    /**
     * Returns an estimated amount of SetToken that can be issued given an amount of input ERC20 token.
     *
     * @param _setToken             Address of the SetToken to be issued
     * @param _components           An array containing the addresses of the SetToken components
     * @param _amountEth            Total amount of ether available for the purchase of SetToken components
     *
     * @return setIssueAmount       The max amount of SetTokens that can be issued
     * @return amountEthIn          An array containing the amount ether required to purchase each SetToken component
     * @return exchanges            An array containing the exchange on which to purchase the SetToken components
     */
    function _getSetIssueAmountForETH(ISetToken _setToken, address[] memory _components, uint256 _amountEth)
        internal
        view
        returns (uint256 setIssueAmount, uint256[] memory amountEthIn, Exchange[] memory exchanges)
    {
        uint256 sumEth;
        uint256[] memory unitAmountEthIn;
        uint256[] memory unitAmountComponents;
        address[] memory pairAddresses;
        (
            sumEth,
            unitAmountEthIn,
            exchanges,
            unitAmountComponents,
            pairAddresses
        ) = _getAmountETHForIssuance(_setToken, _components, PreciseUnitMath.preciseUnit());

        setIssueAmount = PreciseUnitMath.maxUint256();
        amountEthIn = new uint256[](_components.length);

        for (uint256 i = 0; i < _components.length; i++) {

            amountEthIn[i] = unitAmountEthIn[i].mul(_amountEth).div(sumEth);

            uint256 amountComponent;
            if (exchanges[i] == Exchange.None) {
                amountComponent = amountEthIn[i];
            } else {
                (uint256 reserveIn, uint256 reserveOut) = UniSushiV2Library.getReserves(pairAddresses[i], WETH, _components[i]);
                amountComponent = UniSushiV2Library.getAmountOut(amountEthIn[i], reserveIn, reserveOut);
            }
            setIssueAmount = Math.min(amountComponent.preciseDiv(unitAmountComponents[i]), setIssueAmount);
        }
        return (setIssueAmount, amountEthIn, exchanges);
    }

    /**
     * Swaps a given amount of an ERC20 token for WETH for the best price on Uniswap/Sushiswap.
     *
     * @param _token    Address of the ERC20 token to be swapped for WETH
     * @param _amount   Amount of ERC20 token to be swapped
     *
     * @return          Amount of WETH received after the swap
     */
    function _swapTokenForWETH(IERC20 _token, uint256 _amount) internal returns (uint256) {
        (, Exchange exchange, ) = _getMaxTokenForExactToken(_amount, address(_token), WETH);
        IUniswapV2Router02 router = _getRouter(exchange);
        _safeApprove(_token, address(router), _amount);
        return _swapExactTokensForTokens(exchange, address(_token), WETH, _amount);
    }

    /**
     * Swap exact tokens for another token on a given DEX.
     *
     * @param _exchange     The exchange on which to peform the swap
     * @param _tokenIn      The address of the input token
     * @param _tokenOut     The address of the output token
     * @param _amountIn     The amount of input token to be spent
     *
     * @return              The amount of output tokens
     */
    function _swapExactTokensForTokens(Exchange _exchange, address _tokenIn, address _tokenOut, uint256 _amountIn) internal returns (uint256) {
        if (_tokenIn == _tokenOut) {
            return _amountIn;
        }
        address[] memory path = new address[](2);
        path[0] = _tokenIn;
        path[1] = _tokenOut;
        return _getRouter(_exchange).swapExactTokensForTokens(_amountIn, 0, path, address(this), block.timestamp)[1];
    }

    /**
     * Swap tokens for exact amount of output tokens on a given DEX.
     *
     * @param _exchange     The exchange on which to peform the swap
     * @param _tokenIn      The address of the input token
     * @param _tokenOut     The address of the output token
     * @param _amountOut    The amount of output token required
     *
     * @return              The amount of input tokens spent
     */
    function _swapTokensForExactTokens(Exchange _exchange, address _tokenIn, address _tokenOut, uint256 _amountOut) internal returns (uint256) {
        if (_tokenIn == _tokenOut) {
            return _amountOut;
        }
        address[] memory path = new address[](2);
        path[0] = _tokenIn;
        path[1] = _tokenOut;
        return _getRouter(_exchange).swapTokensForExactTokens(_amountOut, PreciseUnitMath.maxUint256(), path, address(this), block.timestamp)[0];
    }

    /**
     * Compares the amount of token required for an exact amount of another token across both exchanges,
     * and returns the min amount.
     *
     * @param _amountOut    The amount of output token
     * @param _tokenA       The address of tokenA
     * @param _tokenB       The address of tokenB
     *
     * @return              The min amount of tokenA required across both exchanges
     * @return              The Exchange on which minimum amount of tokenA is required
     * @return              The pair address of the uniswap/sushiswap pool containing _tokenA and _tokenB
     */
    function _getMinTokenForExactToken(uint256 _amountOut, address _tokenA, address _tokenB) internal view returns (uint256, Exchange, address) {
        if (_tokenA == _tokenB) {
            return (_amountOut, Exchange.None, ETH_ADDRESS);
        }

        uint256 maxIn = PreciseUnitMath.maxUint256() ;
        uint256 uniTokenIn = maxIn;
        uint256 sushiTokenIn = maxIn;

        address uniswapPair = _getPair(uniFactory, _tokenA, _tokenB);
        if (uniswapPair != address(0)) {
            (uint256 reserveIn, uint256 reserveOut) = UniSushiV2Library.getReserves(uniswapPair, _tokenA, _tokenB);
            // Prevent subtraction overflow by making sure pool reserves are greater than swap amount
            if (reserveOut > _amountOut) {
                uniTokenIn = UniSushiV2Library.getAmountIn(_amountOut, reserveIn, reserveOut);
            }
        }

        address sushiswapPair = _getPair(sushiFactory, _tokenA, _tokenB);
        if (sushiswapPair != address(0)) {
            (uint256 reserveIn, uint256 reserveOut) = UniSushiV2Library.getReserves(sushiswapPair, _tokenA, _tokenB);
            // Prevent subtraction overflow by making sure pool reserves are greater than swap amount
            if (reserveOut > _amountOut) {
                sushiTokenIn = UniSushiV2Library.getAmountIn(_amountOut, reserveIn, reserveOut);
            }
        }

        // Fails if both the values are maxIn
        require(!(uniTokenIn == maxIn && sushiTokenIn == maxIn), "ExchangeIssuance: ILLIQUID_SET_COMPONENT");
        return (uniTokenIn <= sushiTokenIn) ? (uniTokenIn, Exchange.Uniswap, uniswapPair) : (sushiTokenIn, Exchange.Sushiswap, sushiswapPair);
    }

    /**
     * Compares the amount of token received for an exact amount of another token across both exchanges,
     * and returns the max amount.
     *
     * @param _amountIn     The amount of input token
     * @param _tokenA       The address of tokenA
     * @param _tokenB       The address of tokenB
     *
     * @return              The max amount of tokens that can be received across both exchanges
     * @return              The Exchange on which maximum amount of token can be received
     * @return              The pair address of the uniswap/sushiswap pool containing _tokenA and _tokenB
     */
    function _getMaxTokenForExactToken(uint256 _amountIn, address _tokenA, address _tokenB) internal view returns (uint256, Exchange, address) {
        if (_tokenA == _tokenB) {
            return (_amountIn, Exchange.None, ETH_ADDRESS);
        }

        uint256 uniTokenOut = 0;
        uint256 sushiTokenOut = 0;

        address uniswapPair = _getPair(uniFactory, _tokenA, _tokenB);
        if(uniswapPair != address(0)) {
            (uint256 reserveIn, uint256 reserveOut) = UniSushiV2Library.getReserves(uniswapPair, _tokenA, _tokenB);
            uniTokenOut = UniSushiV2Library.getAmountOut(_amountIn, reserveIn, reserveOut);
        }

        address sushiswapPair = _getPair(sushiFactory, _tokenA, _tokenB);
        if(sushiswapPair != address(0)) {
            (uint256 reserveIn, uint256 reserveOut) = UniSushiV2Library.getReserves(sushiswapPair, _tokenA, _tokenB);
            sushiTokenOut = UniSushiV2Library.getAmountOut(_amountIn, reserveIn, reserveOut);
        }

        // Fails if both the values are 0
        require(!(uniTokenOut == 0 && sushiTokenOut == 0), "ExchangeIssuance: ILLIQUID_SET_COMPONENT");
        return (uniTokenOut >= sushiTokenOut) ? (uniTokenOut, Exchange.Uniswap, uniswapPair) : (sushiTokenOut, Exchange.Sushiswap, sushiswapPair);
    }

    /**
     * Returns the pair address for on a given DEX.
     *
     * @param _factory   The factory to address
     * @param _tokenA    The address of tokenA
     * @param _tokenB    The address of tokenB
     *
     * @return           The pair address (Note: address(0) is returned by default if the pair is not available on that DEX)
     */
    function _getPair(address _factory, address _tokenA, address _tokenB) internal view returns (address) {
        return IUniswapV2Factory(_factory).getPair(_tokenA, _tokenB);
    }

    /**
     * Returns the router address of a given exchange.
     *
     * @param _exchange     The Exchange whose router address is needed
     *
     * @return              IUniswapV2Router02 router of the given exchange
     */
     function _getRouter(Exchange _exchange) internal view returns(IUniswapV2Router02) {
         return (_exchange == Exchange.Uniswap) ? uniRouter : sushiRouter;
     }

}

File 2 of 18 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 3 of 18 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 4 of 18 : IUniswapV2Factory.sol
pragma solidity >=0.5.0;

interface IUniswapV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

File 5 of 18 : IUniswapV2Router02.sol
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

File 6 of 18 : Math.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow, so we distribute
        return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
    }
}

File 7 of 18 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 8 of 18 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 9 of 18 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 10 of 18 : IBasicIssuanceModule.sol
/*
    Copyright 2020 Set Labs Inc.
    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.
    SPDX-License-Identifier: Apache License, Version 2.0
*/
pragma solidity >=0.6.10;

import { ISetToken } from "./ISetToken.sol";

interface IBasicIssuanceModule {
    function getRequiredComponentUnitsForIssue(
        ISetToken _setToken,
        uint256 _quantity
    ) external returns(address[] memory, uint256[] memory);
    function issue(ISetToken _setToken, uint256 _quantity, address _to) external;
    function redeem(ISetToken _token, uint256 _quantity, address _to) external;
}

File 11 of 18 : IController.sol
/*
    Copyright 2020 Set Labs Inc.
    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.
    SPDX-License-Identifier: Apache License, Version 2.0
*/
pragma solidity 0.6.10;

interface IController {
    function addSet(address _setToken) external;
    function feeRecipient() external view returns(address);
    function getModuleFee(address _module, uint256 _feeType) external view returns(uint256);
    function isModule(address _module) external view returns(bool);
    function isSet(address _setToken) external view returns(bool);
    function isSystemContract(address _contractAddress) external view returns (bool);
    function resourceId(uint256 _id) external view returns(address);
}

File 12 of 18 : ISetToken.sol
pragma solidity 0.6.10;
pragma experimental "ABIEncoderV2";

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/**
 * @title ISetToken
 * @author Set Protocol
 *
 * Interface for operating with SetTokens.
 */
interface ISetToken is IERC20 {

    /* ============ Enums ============ */

    enum ModuleState {
        NONE,
        PENDING,
        INITIALIZED
    }

    /* ============ Structs ============ */
    /**
     * The base definition of a SetToken Position
     *
     * @param component           Address of token in the Position
     * @param module              If not in default state, the address of associated module
     * @param unit                Each unit is the # of components per 10^18 of a SetToken
     * @param positionState       Position ENUM. Default is 0; External is 1
     * @param data                Arbitrary data
     */
    struct Position {
        address component;
        address module;
        int256 unit;
        uint8 positionState;
        bytes data;
    }

    /**
     * A struct that stores a component's cash position details and external positions
     * This data structure allows O(1) access to a component's cash position units and 
     * virtual units.
     *
     * @param virtualUnit               Virtual value of a component's DEFAULT position. Stored as virtual for efficiency
     *                                  updating all units at once via the position multiplier. Virtual units are achieved
     *                                  by dividing a "real" value by the "positionMultiplier"
     * @param componentIndex            
     * @param externalPositionModules   List of external modules attached to each external position. Each module
     *                                  maps to an external position
     * @param externalPositions         Mapping of module => ExternalPosition struct for a given component
     */
    struct ComponentPosition {
      int256 virtualUnit;
      address[] externalPositionModules;
      mapping(address => ExternalPosition) externalPositions;
    }

    /**
     * A struct that stores a component's external position details including virtual unit and any
     * auxiliary data.
     *
     * @param virtualUnit       Virtual value of a component's EXTERNAL position.
     * @param data              Arbitrary data
     */
    struct ExternalPosition {
      int256 virtualUnit;
      bytes data;
    }


    /* ============ Functions ============ */
    
    function addComponent(address _component) external;
    function removeComponent(address _component) external;
    function editDefaultPositionUnit(address _component, int256 _realUnit) external;
    function addExternalPositionModule(address _component, address _positionModule) external;
    function removeExternalPositionModule(address _component, address _positionModule) external;
    function editExternalPositionUnit(address _component, address _positionModule, int256 _realUnit) external;
    function editExternalPositionData(address _component, address _positionModule, bytes calldata _data) external;

    function invoke(address _target, uint256 _value, bytes calldata _data) external returns(bytes memory);

    function editPositionMultiplier(int256 _newMultiplier) external;

    function mint(address _account, uint256 _quantity) external;
    function burn(address _account, uint256 _quantity) external;

    function lock() external;
    function unlock() external;

    function addModule(address _module) external;
    function removeModule(address _module) external;
    function initializeModule() external;

    function setManager(address _manager) external;

    function manager() external view returns (address);
    function moduleStates(address _module) external view returns (ModuleState);
    function getModules() external view returns (address[] memory);
    
    function getDefaultPositionRealUnit(address _component) external view returns(int256);
    function getExternalPositionRealUnit(address _component, address _positionModule) external view returns(int256);
    function getComponents() external view returns(address[] memory);
    function getExternalPositionModules(address _component) external view returns(address[] memory);
    function getExternalPositionData(address _component, address _positionModule) external view returns(bytes memory);
    function isExternalPositionModule(address _component, address _module) external view returns(bool);
    function isComponent(address _component) external view returns(bool);
    
    function positionMultiplier() external view returns (int256);
    function getPositions() external view returns (Position[] memory);
    function getTotalComponentRealUnits(address _component) external view returns(int256);

    function isInitializedModule(address _module) external view returns(bool);
    function isPendingModule(address _module) external view returns(bool);
    function isLocked() external view returns (bool);
}

File 13 of 18 : IWETH.sol
pragma solidity >=0.6.10;

interface IWETH {
    function deposit() external payable;
    function transfer(address to, uint value) external returns (bool);
    function withdraw(uint) external;
}

File 14 of 18 : PreciseUnitMath.sol
/*
    Copyright 2020 Set Labs Inc.

    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.

    SPDX-License-Identifier: Apache License, Version 2.0
*/

pragma solidity 0.6.10;
pragma experimental ABIEncoderV2;

import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
import { SignedSafeMath } from "@openzeppelin/contracts/math/SignedSafeMath.sol";


/**
 * @title PreciseUnitMath
 * @author Set Protocol
 *
 * Arithmetic for fixed-point numbers with 18 decimals of precision. Some functions taken from
 * dYdX's BaseMath library.
 *
 * CHANGELOG:
 * - 9/21/20: Added safePower function
 */
library PreciseUnitMath {
    using SafeMath for uint256;
    using SignedSafeMath for int256;

    // The number One in precise units.
    uint256 constant internal PRECISE_UNIT = 10 ** 18;
    int256 constant internal PRECISE_UNIT_INT = 10 ** 18;

    // Max unsigned integer value
    uint256 constant internal MAX_UINT_256 = type(uint256).max;
    // Max and min signed integer value
    int256 constant internal MAX_INT_256 = type(int256).max;
    int256 constant internal MIN_INT_256 = type(int256).min;

    /**
     * @dev Getter function since constants can't be read directly from libraries.
     */
    function preciseUnit() internal pure returns (uint256) {
        return PRECISE_UNIT;
    }

    /**
     * @dev Getter function since constants can't be read directly from libraries.
     */
    function preciseUnitInt() internal pure returns (int256) {
        return PRECISE_UNIT_INT;
    }

    /**
     * @dev Getter function since constants can't be read directly from libraries.
     */
    function maxUint256() internal pure returns (uint256) {
        return MAX_UINT_256;
    }

    /**
     * @dev Getter function since constants can't be read directly from libraries.
     */
    function maxInt256() internal pure returns (int256) {
        return MAX_INT_256;
    }

    /**
     * @dev Getter function since constants can't be read directly from libraries.
     */
    function minInt256() internal pure returns (int256) {
        return MIN_INT_256;
    }

    /**
     * @dev Multiplies value a by value b (result is rounded down). It's assumed that the value b is the significand
     * of a number with 18 decimals precision.
     */
    function preciseMul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a.mul(b).div(PRECISE_UNIT);
    }

    /**
     * @dev Multiplies value a by value b (result is rounded towards zero). It's assumed that the value b is the
     * significand of a number with 18 decimals precision.
     */
    function preciseMul(int256 a, int256 b) internal pure returns (int256) {
        return a.mul(b).div(PRECISE_UNIT_INT);
    }

    /**
     * @dev Multiplies value a by value b (result is rounded up). It's assumed that the value b is the significand
     * of a number with 18 decimals precision.
     */
    function preciseMulCeil(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0 || b == 0) {
            return 0;
        }
        return a.mul(b).sub(1).div(PRECISE_UNIT).add(1);
    }

    /**
     * @dev Divides value a by value b (result is rounded down).
     */
    function preciseDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        return a.mul(PRECISE_UNIT).div(b);
    }


    /**
     * @dev Divides value a by value b (result is rounded towards 0).
     */
    function preciseDiv(int256 a, int256 b) internal pure returns (int256) {
        return a.mul(PRECISE_UNIT_INT).div(b);
    }

    /**
     * @dev Divides value a by value b (result is rounded up or away from 0).
     */
    function preciseDivCeil(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b != 0, "Cant divide by 0");

        return a > 0 ? a.mul(PRECISE_UNIT).sub(1).div(b).add(1) : 0;
    }

    /**
     * @dev Divides value a by value b (result is rounded down - positive numbers toward 0 and negative away from 0).
     */
    function divDown(int256 a, int256 b) internal pure returns (int256) {
        require(b != 0, "Cant divide by 0");
        require(a != MIN_INT_256 || b != -1, "Invalid input");

        int256 result = a.div(b);
        if (a ^ b < 0 && a % b != 0) {
            result -= 1;
        }

        return result;
    }

    /**
     * @dev Multiplies value a by value b where rounding is towards the lesser number. 
     * (positive values are rounded towards zero and negative values are rounded away from 0). 
     */
    function conservativePreciseMul(int256 a, int256 b) internal pure returns (int256) {
        return divDown(a.mul(b), PRECISE_UNIT_INT);
    }

    /**
     * @dev Divides value a by value b where rounding is towards the lesser number. 
     * (positive values are rounded towards zero and negative values are rounded away from 0). 
     */
    function conservativePreciseDiv(int256 a, int256 b) internal pure returns (int256) {
        return divDown(a.mul(PRECISE_UNIT_INT), b);
    }

    /**
    * @dev Performs the power on a specified value, reverts on overflow.
    */
    function safePower(
        uint256 a,
        uint256 pow
    )
        internal
        pure
        returns (uint256)
    {
        require(a > 0, "Value must be positive");

        uint256 result = 1;
        for (uint256 i = 0; i < pow; i++){
            uint256 previousResult = result;

            // Using safemath multiplication prevents overflows
            result = previousResult.mul(a);
        }

        return result;
    }
}

File 15 of 18 : UniSushiV2Library.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.0;

import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol';

import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";

library UniSushiV2Library {
    using SafeMath for uint;

    // returns sorted token addresses, used to handle return values from pairs sorted in this order
    function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
        require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
    }

    // fetches and sorts the reserves for a pair
    function getReserves(address pair, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
        (address token0,) = sortTokens(tokenA, tokenB);
        (uint reserve0, uint reserve1,) = IUniswapV2Pair(pair).getReserves();
        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
    }

    // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
    function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
        require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
        require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        amountB = amountA.mul(reserveB) / reserveA;
    }

    // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
        require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        uint amountInWithFee = amountIn.mul(997);
        uint numerator = amountInWithFee.mul(reserveOut);
        uint denominator = reserveIn.mul(1000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    // given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
        require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
        uint numerator = reserveIn.mul(amountOut).mul(1000);
        uint denominator = reserveOut.sub(amountOut).mul(997);
        amountIn = (numerator / denominator).add(1);
    }

    // performs chained getAmountOut calculations on any number of pairs
    function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[0] = amountIn;
        for (uint i; i < path.length - 1; i++) {
            (uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
            amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
        }
    }

    // performs chained getAmountIn calculations on any number of pairs
    function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[amounts.length - 1] = amountOut;
        for (uint i = path.length - 1; i > 0; i--) {
            (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
            amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
        }
    }
}

File 16 of 18 : IUniswapV2Router01.sol
pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

File 17 of 18 : SignedSafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @title SignedSafeMath
 * @dev Signed math operations with safety checks that revert on error.
 */
library SignedSafeMath {
    int256 constant private _INT256_MIN = -2**255;

    /**
     * @dev Returns the multiplication of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(int256 a, int256 b) internal pure returns (int256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");

        int256 c = a * b;
        require(c / a == b, "SignedSafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two signed integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(int256 a, int256 b) internal pure returns (int256) {
        require(b != 0, "SignedSafeMath: division by zero");
        require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow");

        int256 c = a / b;

        return c;
    }

    /**
     * @dev Returns the subtraction of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a - b;
        require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");

        return c;
    }

    /**
     * @dev Returns the addition of two signed integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(int256 a, int256 b) internal pure returns (int256) {
        int256 c = a + b;
        require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");

        return c;
    }
}

File 18 of 18 : IUniswapV2Pair.sol
pragma solidity >=0.5.0;

interface IUniswapV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

    event Mint(address indexed sender, uint amount0, uint amount1);
    event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
    event Swap(
        address indexed sender,
        uint amount0In,
        uint amount1In,
        uint amount0Out,
        uint amount1Out,
        address indexed to
    );
    event Sync(uint112 reserve0, uint112 reserve1);

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_uniFactory","type":"address"},{"internalType":"contract IUniswapV2Router02","name":"_uniRouter","type":"address"},{"internalType":"address","name":"_sushiFactory","type":"address"},{"internalType":"contract IUniswapV2Router02","name":"_sushiRouter","type":"address"},{"internalType":"contract IController","name":"_setController","type":"address"},{"internalType":"contract IBasicIssuanceModule","name":"_basicIssuanceModule","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"indexed":true,"internalType":"contract IERC20","name":"_inputToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amountInputToken","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amountSetIssued","type":"uint256"}],"name":"ExchangeIssue","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"indexed":true,"internalType":"contract IERC20","name":"_outputToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amountSetRedeemed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amountOutputToken","type":"uint256"}],"name":"ExchangeRedeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"_refundAmount","type":"uint256"}],"name":"Refund","type":"event"},{"inputs":[],"name":"ETH_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"}],"name":"approveSetToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"}],"name":"approveToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20[]","name":"_tokens","type":"address[]"}],"name":"approveTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"basicIssuanceModule","outputs":[{"internalType":"contract IBasicIssuanceModule","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"contract IERC20","name":"_inputToken","type":"address"},{"internalType":"uint256","name":"_amountSetToken","type":"uint256"}],"name":"getAmountInToIssueExactSet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"address","name":"_outputToken","type":"address"},{"internalType":"uint256","name":"_amountSetToken","type":"uint256"}],"name":"getAmountOutOnRedeemSet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"contract IERC20","name":"_inputToken","type":"address"},{"internalType":"uint256","name":"_amountInput","type":"uint256"}],"name":"getEstimatedIssueSetAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"contract IERC20","name":"_inputToken","type":"address"},{"internalType":"uint256","name":"_amountSetToken","type":"uint256"},{"internalType":"uint256","name":"_maxAmountInputToken","type":"uint256"}],"name":"issueExactSetFromToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"contract IERC20","name":"_inputToken","type":"address"},{"internalType":"uint256","name":"_amountInput","type":"uint256"},{"internalType":"uint256","name":"_minSetReceive","type":"uint256"}],"name":"issueSetForExactToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISetToken","name":"_setToken","type":"address"},{"internalType":"contract IERC20","name":"_outputToken","type":"address"},{"internalType":"uint256","name":"_amountSetToken","type":"uint256"},{"internalType":"uint256","name":"_minOutputReceive","type":"uint256"}],"name":"redeemExactSetForToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setController","outputs":[{"internalType":"contract IController","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sushiFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sushiRouter","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uniFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uniRouter","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6101006040523480156200001257600080fd5b5060405162003f6f38038062003f6f833981016040819052620000359162000418565b60016000819055606087811b6001600160601b0319908116608052600280546001600160a01b03199081166001600160a01b038b8116919091179283905589851b841660a0526003805483168a831617905587851b841660c0529386901b90921660e05283549091168a831617909255620000e19116620000c162000115602090811b6200119f17901c565b6001546001600160a01b031691906200011b602090811b620011a517901c565b60035462000108906001600160a01b0316620000c162000115602090811b6200119f17901c565b50505050505050620006f3565b60001990565b801580620001aa5750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e906200015490309086906004016200051b565b60206040518083038186803b1580156200016d57600080fd5b505afa15801562000182573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001a89190620004e4565b155b620001d25760405162461bcd60e51b8152600401620001c9906200064a565b60405180910390fd5b6200022d8363095ea7b360e01b8484604051602401620001f492919062000535565b60408051808303601f190181529190526020810180516001600160e01b0319939093166001600160e01b03938416179052906200023216565b505050565b60606200028e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316620002ce60201b6200129f179092919060201c565b8051909150156200022d5780806020019051810190620002af9190620004c2565b6200022d5760405162461bcd60e51b8152600401620001c99062000600565b6060620002e884846000856001600160e01b03620002f216565b90505b9392505050565b606082471015620003175760405162461bcd60e51b8152600401620001c99062000583565b6200032b856001600160e01b03620003d416565b6200034a5760405162461bcd60e51b8152600401620001c990620005c9565b60006060866001600160a01b03168587604051620003699190620004fd565b60006040518083038185875af1925050503d8060008114620003a8576040519150601f19603f3d011682016040523d82523d6000602084013e620003ad565b606091505b509092509050620003c98282866001600160e01b03620003da16565b979650505050505050565b3b151590565b60608315620003eb575081620002eb565b825115620003fc5782518084602001fd5b8160405162461bcd60e51b8152600401620001c991906200054e565b600080600080600080600060e0888a03121562000433578283fd5b87516200044081620006da565b60208901519097506200045381620006da565b60408901519096506200046681620006da565b60608901519095506200047981620006da565b60808901519094506200048c81620006da565b60a08901519093506200049f81620006da565b60c0890151909250620004b281620006da565b8091505092959891949750929550565b600060208284031215620004d4578081fd5b81518015158114620002eb578182fd5b600060208284031215620004f6578081fd5b5051919050565b6000825162000511818460208701620006a7565b9190910192915050565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b60006020825282518060208401526200056f816040850160208701620006a7565b601f01601f19169190910160400192915050565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000606082015260800190565b60005b83811015620006c4578181015183820152602001620006aa565b83811115620006d4576000848401525b50505050565b6001600160a01b0381168114620006f057600080fd5b50565b60805160601c60a05160601c60c05160601c60e05160601c6137ef6200078060003980610492528061052b52806114895280611f6f52806122cb525080610249528061055c5280610583528061073752806109495280610b055280610cb95280610ebf5250806102225280611a5b5280611bbd5250806104c552806119f25280611b5d52506137ef6000f3fe608060405234801561001057600080fd5b506004361061010b5760003560e01c80638da43bf7116100a2578063ad5c464811610071578063ad5c4648146101cc578063b0a8acc0146101d4578063b0fa416a146101e7578063b7711c63146101fa578063d7fa49841461020d5761010b565b80638da43bf714610196578063a0e47bf6146101a9578063a734f06e146101b1578063ac43070b146101b95761010b565b806376771d4b116100de57806376771d4b1461015e57806380b2edd8146101665780638b2704ec1461017b5780638c54e4ec146101835761010b565b806322984b2414610110578063464bc34b1461012e57806350e2c07f1461014e5780636d13582c14610156575b600080fd5b610118610220565b6040516101259190613146565b60405180910390f35b61014161013c366004613036565b610244565b60405161012591906136c9565b610118610490565b6101186104b4565b6101186104c3565b610179610174366004612fc6565b6104e7565b005b61011861055a565b610141610191366004613022565b61057e565b6101416101a4366004613022565b610732565b6101186108d2565b6101186108e1565b6101796101c7366004612eb3565b6108f9565b610118610935565b6101416101e2366004613036565b610944565b6101416101f5366004612fe2565b610b00565b610179610208366004612fc6565b610ca0565b61014161021b366004613036565b610eba565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000847f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166374ebe3ec826040518263ffffffff1660e01b81526004016102939190613146565b60206040518083038186803b1580156102ab57600080fd5b505afa1580156102bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e39190612fa6565b6103085760405162461bcd60e51b81526004016102ff90613307565b60405180910390fd5b6002600054141561032b5760405162461bcd60e51b81526004016102ff906135f1565b6002600055831580159061033f5750600083115b61035b5760405162461bcd60e51b81526004016102ff90613286565b6103766001600160a01b03861633308663ffffffff6112b816565b6001546000906001600160a01b0387811691161461039d5761039886856112d9565b61039f565b835b905060006103ae888784611338565b905060006103c2838363ffffffff61150116565b905080156103e7576001546103e7906001600160a01b0316338363ffffffff61154316565b336001600160a01b03167fbb28353e4598c3b9199101a66e0989549b659a59a54d2c27fbb183f1932c8e6d8260405161042091906136c9565b60405180910390a2876001600160a01b0316896001600160a01b0316336001600160a01b03167f44b3b16472a909f781f712646232271ffd156fff642d4895b700146a40462601898b60405161047792919061370e565b60405180910390a4600160005598975050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6003546001600160a01b031681565b7f000000000000000000000000000000000000000000000000000000000000000081565b6002546105069082906001600160a01b03166001600160601b03611562565b6003546105259082906001600160a01b03166001600160601b03611562565b610557817f00000000000000000000000000000000000000000000000000000000000000006001600160601b03611562565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000837f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166374ebe3ec826040518263ffffffff1660e01b81526004016105cd9190613146565b60206040518083038186803b1580156105e557600080fd5b505afa1580156105f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061d9190612fa6565b6106395760405162461bcd60e51b81526004016102ff90613307565b600083116106595760405162461bcd60e51b81526004016102ff90613286565b6060856001600160a01b03166399d50d5d6040518163ffffffff1660e01b815260040160006040518083038186803b15801561069457600080fd5b505afa1580156106a8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106d09190810190612e12565b905060006106df878387611611565b505060015492935050506001600160a01b038781169116141561070557925061072a9050565b60015460009061072190839089906001600160a01b031661199c565b50909550505050505b509392505050565b6000837f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166374ebe3ec826040518263ffffffff1660e01b81526004016107819190613146565b60206040518083038186803b15801561079957600080fd5b505afa1580156107ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107d19190612fa6565b6107ed5760405162461bcd60e51b81526004016102ff90613307565b6000831161080d5760405162461bcd60e51b81526004016102ff90613286565b6001546000906001600160a01b038681169116146108495760015461083e90859087906001600160a01b0316611b13565b5090915061084c9050565b50825b6060866001600160a01b03166399d50d5d6040518163ffffffff1660e01b815260040160006040518083038186803b15801561088757600080fd5b505afa15801561089b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108c39190810190612e12565b90506000610721888385611c68565b6002546001600160a01b031681565b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81565b60005b818110156109305761092883838381811061091357fe5b90506020020160208101906101749190612fc6565b6001016108fc565b505050565b6001546001600160a01b031681565b6000847f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166374ebe3ec826040518263ffffffff1660e01b81526004016109939190613146565b60206040518083038186803b1580156109ab57600080fd5b505afa1580156109bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e39190612fa6565b6109ff5760405162461bcd60e51b81526004016102ff90613307565b60026000541415610a225760405162461bcd60e51b81526004016102ff906135f1565b600260005583610a445760405162461bcd60e51b81526004016102ff90613286565b610a5f6001600160a01b03861633308763ffffffff6112b816565b6001546000906001600160a01b03878116911614610a8657610a8186866112d9565b610a88565b845b90506000610a97888684611e38565b9050866001600160a01b0316886001600160a01b0316336001600160a01b03167f44b3b16472a909f781f712646232271ffd156fff642d4895b700146a404626018985604051610ae892919061370e565b60405180910390a46001600055979650505050505050565b6000837f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166374ebe3ec826040518263ffffffff1660e01b8152600401610b4f9190613146565b60206040518083038186803b158015610b6757600080fd5b505afa158015610b7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9f9190612fa6565b610bbb5760405162461bcd60e51b81526004016102ff90613307565b60008311610bdb5760405162461bcd60e51b81526004016102ff90613286565b6060856001600160a01b03166399d50d5d6040518163ffffffff1660e01b815260040160006040518083038186803b158015610c1657600080fd5b505afa158015610c2a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c529190810190612e12565b90506000610c61878387611fe6565b50506001549091506001600160a01b0387811691161415610c8557925061072a9050565b6001546000906107219083906001600160a01b031689611b13565b604051631d3af8fb60e21b815281906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906374ebe3ec90610cee908490600401613146565b60206040518083038186803b158015610d0657600080fd5b505afa158015610d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3e9190612fa6565b610d5a5760405162461bcd60e51b81526004016102ff90613307565b6060826001600160a01b03166399d50d5d6040518163ffffffff1660e01b815260040160006040518083038186803b158015610d9557600080fd5b505afa158015610da9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610dd19190810190612e12565b905060005b8151811015610eb457836001600160a01b031663a7bdad03838381518110610dfa57fe5b60200260200101516040518263ffffffff1660e01b8152600401610e1e9190613146565b60006040518083038186803b158015610e3657600080fd5b505afa158015610e4a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e729190810190612e12565b5115610e905760405162461bcd60e51b81526004016102ff906134a8565b610eac828281518110610e9f57fe5b60200260200101516104e7565b600101610dd6565b50505050565b6000847f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166374ebe3ec826040518263ffffffff1660e01b8152600401610f099190613146565b60206040518083038186803b158015610f2157600080fd5b505afa158015610f35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f599190612fa6565b610f755760405162461bcd60e51b81526004016102ff90613307565b60026000541415610f985760405162461bcd60e51b81526004016102ff906135f1565b600260005583610fba5760405162461bcd60e51b81526004016102ff90613286565b6060866001600160a01b03166399d50d5d6040518163ffffffff1660e01b815260040160006040518083038186803b158015610ff557600080fd5b505afa158015611009573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110319190810190612e12565b905060006060806110438a858a611fe6565b60015492955090935091506000906001600160a01b038b8116911614156110a0578784116110835760405162461bcd60e51b81526004016102ff90613414565b61108d8b8a612297565b5061109985848461233c565b905061111b565b60015460009081906110bd9087906001600160a01b03168e611b13565b50915091508982116110e15760405162461bcd60e51b81526004016102ff90613414565b6110eb8d8c612297565b5060006110f988878761233c565b6001549091506111159083906001600160a01b03168f8461240b565b93505050505b6111356001600160a01b038b16338363ffffffff61154316565b896001600160a01b03168b6001600160a01b0316336001600160a01b03167f9f8f1a845f52c0a7086f16f355a092a5acf0cca219c831409b9e5b1c39af9f9f8c8560405161118492919061370e565b60405180910390a460016000559a9950505050505050505050565b60001990565b80158061122d5750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e906111db903090869060040161315a565b60206040518083038186803b1580156111f357600080fd5b505afa158015611207573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122b919061307b565b155b6112495760405162461bcd60e51b81526004016102ff90613673565b6109308363095ea7b360e01b8484604051602401611268929190613198565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261255d565b60606112ae84846000856125ec565b90505b9392505050565b610eb4846323b872dd60e01b85858560405160240161126893929190613174565b60015460009081906112f790849086906001600160a01b0316611b13565b509150506000611306826126ad565b9050611313858286611562565b60015461132d90839087906001600160a01b03168761240b565b925050505b92915050565b60006060846001600160a01b03166399d50d5d6040518163ffffffff1660e01b815260040160006040518083038186803b15801561137557600080fd5b505afa158015611389573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113b19190810190612e12565b905060006060806113c3888589611611565b5093509350509250858311156113eb5760405162461bcd60e51b81526004016102ff906133c9565b6000805b855181101561147157600061145485838151811061140957fe5b6020026020010151600160009054906101000a90046001600160a01b031689858151811061143357fe5b602002602001015187868151811061144757fe5b60200260200101516126e3565b9050611466838263ffffffff61282716565b9250506001016113ef565b506040516336bc7a3d60e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636d78f47a906114c2908c908c9033906004016131b1565b600060405180830381600087803b1580156114dc57600080fd5b505af11580156114f0573d6000803e3d6000fd5b50929b9a5050505050505050505050565b60006112b183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061284c565b6109308363a9059cbb60e01b8484604051602401611268929190613198565b604051636eb1769f60e11b81526000906001600160a01b0385169063dd62ed3e90611593903090879060040161315a565b60206040518083038186803b1580156115ab57600080fd5b505afa1580156115bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e3919061307b565b905081811015610eb457610eb46001600160a01b038516846001600160601b0384900363ffffffff61287816565b600060608060608060009450865167ffffffffffffffff8111801561163557600080fd5b5060405190808252806020026020018201604052801561165f578160200160208202803683370190505b509350865167ffffffffffffffff8111801561167a57600080fd5b506040519080825280602002602001820160405280156116a4578160200160208202803683370190505b509150865167ffffffffffffffff811180156116bf57600080fd5b506040519080825280602002602001820160405280156116e9578160200160208202803683370190505b509250865167ffffffffffffffff8111801561170457600080fd5b5060405190808252806020026020018201604052801561172e578160200160208202803683370190505b50905060005b875181101561199057886001600160a01b031663a7bdad0389838151811061175857fe5b60200260200101516040518263ffffffff1660e01b815260040161177c9190613146565b60006040518083038186803b15801561179457600080fd5b505afa1580156117a8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526117d09190810190612e12565b51156117ee5760405162461bcd60e51b81526004016102ff906134a8565b6000896001600160a01b03166366cb8d2f8a848151811061180b57fe5b60200260200101516040518263ffffffff1660e01b815260040161182f9190613146565b60206040518083038186803b15801561184757600080fd5b505afa15801561185b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187f919061307b565b9050611891818963ffffffff61292916565b84838151811061189d57fe5b6020026020010181815250506118ef8483815181106118b857fe5b6020026020010151600160009054906101000a90046001600160a01b03168b85815181106118e257fe5b602002602001015161199c565b8885815181106118fb57fe5b6020026020010188868151811061190e57fe5b6020026020010187878151811061192157fe5b60200260200101836001600160a01b03166001600160a01b031681525083600281111561194a57fe5b600281111561195557fe5b8152508381525050505061198586838151811061196e57fe5b60200260200101518861282790919063ffffffff16565b965050600101611734565b50939792965093509350565b6000806000836001600160a01b0316856001600160a01b031614156119dd57508491506002905073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee611b0a565b60006119e761119f565b905080806000611a187f00000000000000000000000000000000000000000000000000000000000000008a8a612974565b90506001600160a01b03811615611a5457600080611a37838c8c6129f5565b915091508b811115611a5157611a4e8c8383612ac4565b94505b50505b6000611a817f00000000000000000000000000000000000000000000000000000000000000008b8b612974565b90506001600160a01b03811615611abd57600080611aa0838d8d6129f5565b915091508c811115611aba57611ab78d8383612ac4565b94505b50505b8484148015611acb57508483145b15611ae85760405162461bcd60e51b81526004016102ff90613207565b82841115611af95782600182611afe565b836000835b97509750975050505050505b93509350939050565b6000806000836001600160a01b0316856001600160a01b03161415611b5457508491506002905073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee611b0a565b60008080611b837f00000000000000000000000000000000000000000000000000000000000000008989612974565b90506001600160a01b03811615611bb657600080611ba2838b8b6129f5565b91509150611bb18b8383612b76565b945050505b6000611be37f00000000000000000000000000000000000000000000000000000000000000008a8a612974565b90506001600160a01b03811615611c1657600080611c02838c8c6129f5565b91509150611c118c8383612b76565b945050505b83158015611c22575082155b15611c3f5760405162461bcd60e51b81526004016102ff90613207565b82841015611c505782600182611c55565b836000835b9650965096505050505093509350939050565b600060608060006060806060611c868a8a611c81612c1c565b611611565b9198509296509094509092509050611c9c61119f565b9650885167ffffffffffffffff81118015611cb657600080fd5b50604051908082528060200260200182016040528015611ce0578160200160208202803683370190505b50955060005b8951811015611e2a57611d2585611d198b878581518110611d0357fe5b6020026020010151612c2890919063ffffffff16565b9063ffffffff612c6216565b878281518110611d3157fe5b602090810291909101015260006002878381518110611d4c57fe5b60200260200101516002811115611d5f57fe5b1415611d8057878281518110611d7157fe5b60200260200101519050611df0565b600080611dc9858581518110611d9257fe5b6020026020010151600160009054906101000a90046001600160a01b03168f8781518110611dbc57fe5b60200260200101516129f5565b91509150611deb8a8581518110611ddc57fe5b60200260200101518383612b76565b925050505b611e1f611e19858481518110611e0257fe5b602002602001015183612ca490919063ffffffff16565b8a612cc2565b985050600101611ce6565b505050505093509350939050565b60006060846001600160a01b03166399d50d5d6040518163ffffffff1660e01b815260040160006040518083038186803b158015611e7557600080fd5b505afa158015611e89573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611eb19190810190612e12565b90506000606080611ec3888588611c68565b925092509250868311611ee85760405162461bcd60e51b81526004016102ff90613414565b60005b8451811015611f5757611f4e828281518110611f0357fe5b6020026020010151600160009054906101000a90046001600160a01b0316878481518110611f2d57fe5b6020026020010151868581518110611f4157fe5b602002602001015161240b565b50600101611eeb565b506040516336bc7a3d60e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636d78f47a90611fa8908b90879033906004016131b1565b600060405180830381600087803b158015611fc257600080fd5b505af1158015611fd6573d6000803e3d6000fd5b50949a9950505050505050505050565b6000606080600080905060008090506060875167ffffffffffffffff8111801561200f57600080fd5b50604051908082528060200260200182016040528015612039578160200160208202803683370190505b5090506060885167ffffffffffffffff8111801561205657600080fd5b50604051908082528060200260200182016040528015612080578160200160208202803683370190505b50905060005b8951811015612285578a6001600160a01b031663a7bdad038b83815181106120aa57fe5b60200260200101516040518263ffffffff1660e01b81526004016120ce9190613146565b60006040518083038186803b1580156120e657600080fd5b505afa1580156120fa573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121229190810190612e12565b51156121405760405162461bcd60e51b81526004016102ff906134a8565b60008b6001600160a01b03166366cb8d2f8c848151811061215d57fe5b60200260200101516040518263ffffffff1660e01b81526004016121819190613146565b60206040518083038186803b15801561219957600080fd5b505afa1580156121ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121d1919061307b565b90506121e3818b63ffffffff612cd816565b8483815181106121ef57fe5b60200260200101818152505061223a84838151811061220a57fe5b60200260200101518c848151811061221e57fe5b60209081029190910101516001546001600160a01b0316611b13565b5084848151811061224757fe5b6020026020010181600281111561225a57fe5b600281111561226557fe5b905250945061227a868663ffffffff61282716565b955050600101612086565b50929990985091965090945050505050565b60006122b46001600160a01b03841633308563ffffffff6112b816565b604051635c833bfd60e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690635c833bfd90612304908690869030906004016131b1565b600060405180830381600087803b15801561231e57600080fd5b505af1158015612332573d6000803e3d6000fd5b5050505092915050565b600080805b855181101561240257600284828151811061235857fe5b6020026020010151600281111561236b57fe5b146123d2576123cd6123c085838151811061238257fe5b602002602001015188848151811061239657fe5b6020026020010151600160009054906101000a90046001600160a01b0316898681518110611f4157fe5b839063ffffffff61282716565b6123f8565b6123f88582815181106123e157fe5b60200260200101518361282790919063ffffffff16565b9150600101612341565b50949350505050565b6000826001600160a01b0316846001600160a01b0316141561242e575080612555565b6040805160028082526060808301845292602083019080368337019050509050848160008151811061245c57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050838160018151811061248a57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506124b3866126ad565b6001600160a01b03166338ed17398460008430426040518663ffffffff1660e01b81526004016124e79594939291906136d2565b600060405180830381600087803b15801561250157600080fd5b505af1158015612515573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261253d9190810190612f1f565b60018151811061254957fe5b60200260200101519150505b949350505050565b60606125b2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661129f9092919063ffffffff16565b80519091501561093057808060200190518101906125d09190612fa6565b6109305760405162461bcd60e51b81526004016102ff906135a7565b60608247101561260e5760405162461bcd60e51b81526004016102ff90613383565b61261785612cf6565b6126335760405162461bcd60e51b81526004016102ff90613539565b60006060866001600160a01b03168587604051612650919061312a565b60006040518083038185875af1925050503d806000811461268d576040519150601f19603f3d011682016040523d82523d6000602084013e612692565b606091505b50915091506126a2828286612cfc565b979650505050505050565b6000808260028111156126bc57fe5b146126d2576003546001600160a01b0316611332565b50506002546001600160a01b031690565b6000826001600160a01b0316846001600160a01b03161415612706575080612555565b6040805160028082526060808301845292602083019080368337019050509050848160008151811061273457fe5b60200260200101906001600160a01b031690816001600160a01b031681525050838160018151811061276257fe5b60200260200101906001600160a01b031690816001600160a01b03168152505061278b866126ad565b6001600160a01b0316638803dbee846127a261119f565b8430426040518663ffffffff1660e01b81526004016127c59594939291906136d2565b600060405180830381600087803b1580156127df57600080fd5b505af11580156127f3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261281b9190810190612f1f565b60008151811061254957fe5b6000828201838110156112b15760405162461bcd60e51b81526004016102ff9061324f565b600081848411156128705760405162461bcd60e51b81526004016102ff91906131d4565b505050900390565b600061290882856001600160a01b031663dd62ed3e30876040518363ffffffff1660e01b81526004016128ac92919061315a565b60206040518083038186803b1580156128c457600080fd5b505afa1580156128d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128fc919061307b565b9063ffffffff61282716565b9050610eb48463095ea7b360e01b8584604051602401611268929190613198565b6000821580612936575081155b1561294357506000611332565b6112b160016128fc670de0b6b3a7640000611d1983612968898963ffffffff612c2816565b9063ffffffff61150116565b60405163e6a4390560e01b81526000906001600160a01b0385169063e6a43905906129a5908690869060040161315a565b60206040518083038186803b1580156129bd57600080fd5b505afa1580156129d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ae9190612df6565b6000806000612a048585612d35565b509050600080876001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015612a4357600080fd5b505afa158015612a57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7b9190613093565b506001600160701b031691506001600160701b03169150826001600160a01b0316876001600160a01b031614612ab2578082612ab5565b81815b90999098509650505050505050565b6000808411612ae55760405162461bcd60e51b81526004016102ff906132bb565b600083118015612af55750600082115b612b115760405162461bcd60e51b81526004016102ff90613460565b6000612b356103e8612b29868863ffffffff612c2816565b9063ffffffff612c2816565b90506000612b4f6103e5612b29868963ffffffff61150116565b9050612b6c6001828481612b5f57fe5b049063ffffffff61282716565b9695505050505050565b6000808411612b975760405162461bcd60e51b81526004016102ff90613628565b600083118015612ba75750600082115b612bc35760405162461bcd60e51b81526004016102ff90613460565b6000612bd7856103e563ffffffff612c2816565b90506000612beb828563ffffffff612c2816565b90506000612c05836128fc886103e863ffffffff612c2816565b9050808281612c1057fe5b04979650505050505050565b670de0b6b3a764000090565b600082612c3757506000611332565b82820282848281612c4457fe5b04146112b15760405162461bcd60e51b81526004016102ff906134f8565b60006112b183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612dbf565b60006112b182611d1985670de0b6b3a764000063ffffffff612c2816565b6000818310612cd157816112b1565b5090919050565b60006112b1670de0b6b3a7640000611d19858563ffffffff612c2816565b3b151590565b60608315612d0b5750816112b1565b825115612d1b5782518084602001fd5b8160405162461bcd60e51b81526004016102ff91906131d4565b600080826001600160a01b0316846001600160a01b03161415612d6a5760405162461bcd60e51b81526004016102ff9061333e565b826001600160a01b0316846001600160a01b031610612d8a578284612d8d565b83835b90925090506001600160a01b038216612db85760405162461bcd60e51b81526004016102ff90613570565b9250929050565b60008183612de05760405162461bcd60e51b81526004016102ff91906131d4565b506000838581612dec57fe5b0495945050505050565b600060208284031215612e07578081fd5b81516112b18161378f565b60006020808385031215612e24578182fd5b825167ffffffffffffffff811115612e3a578283fd5b80840185601f820112612e4b578384fd5b80519150612e60612e5b83613743565b61371c565b8281528381019082850185850284018601891015612e7c578687fd5b8693505b84841015612ea7578051612e938161378f565b835260019390930192918501918501612e80565b50979650505050505050565b60008060208385031215612ec5578081fd5b823567ffffffffffffffff80821115612edc578283fd5b81850186601f820112612eed578384fd5b8035925081831115612efd578384fd5b8660208085028301011115612f10578384fd5b60200196919550909350505050565b60006020808385031215612f31578182fd5b825167ffffffffffffffff811115612f47578283fd5b80840185601f820112612f58578384fd5b80519150612f68612e5b83613743565b8281528381019082850185850284018601891015612f84578687fd5b8693505b84841015612ea7578051835260019390930192918501918501612f88565b600060208284031215612fb7578081fd5b815180151581146112b1578182fd5b600060208284031215612fd7578081fd5b81356112b18161378f565b600080600060608486031215612ff6578081fd5b83356130018161378f565b925060208401356130118161378f565b929592945050506040919091013590565b600080600060608486031215612ff6578283fd5b6000806000806080858703121561304b578081fd5b84356130568161378f565b935060208501356130668161378f565b93969395505050506040820135916060013590565b60006020828403121561308c578081fd5b5051919050565b6000806000606084860312156130a7578283fd5b83516130b2816137a4565b60208501519093506130c3816137a4565b604085015190925063ffffffff811681146130dc578182fd5b809150509250925092565b6000815180845260208085019450808401835b8381101561311f5781516001600160a01b0316875295820195908201906001016130fa565b509495945050505050565b6000825161313c818460208701613763565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b60006020825282518060208401526131f3816040850160208701613763565b601f01601f19169190910160400192915050565b60208082526028908201527f45786368616e676549737375616e63653a20494c4c49515549445f5345545f4360408201526713d35413d391539560c21b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252818101527f45786368616e676549737375616e63653a20494e56414c494420494e50555453604082015260600190565b6020808252602c908201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4f60408201526b155514155517d05353d5539560a21b606082015260800190565b6020808252601d908201527f45786368616e676549737375616e63653a20494e56414c494420534554000000604082015260600190565b60208082526025908201527f556e697377617056324c6962726172793a204944454e544943414c5f41444452604082015264455353455360d81b606082015260800190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252602b908201527f45786368616e676549737375616e63653a20494e53554646494349454e545f4960408201526a1394155517d05353d5539560aa1b606082015260800190565b6020808252602c908201527f45786368616e676549737375616e63653a20494e53554646494349454e545f4f60408201526b155514155517d05353d5539560a21b606082015260800190565b60208082526028908201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4c604082015267495155494449545960c01b606082015260800190565b60208082526030908201527f45786368616e676549737375616e63653a2045585445524e414c5f504f53495460408201526f1253d394d7d393d517d0531313d5d15160821b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252601e908201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252602b908201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4960408201526a1394155517d05353d5539560aa1b606082015260800190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b90815260200190565b600086825285602083015260a060408301526136f160a08301866130e7565b6001600160a01b0394909416606083015250608001529392505050565b918252602082015260400190565b60405181810167ffffffffffffffff8111828210171561373b57600080fd5b604052919050565b600067ffffffffffffffff821115613759578081fd5b5060209081020190565b60005b8381101561377e578181015183820152602001613766565b83811115610eb45750506000910152565b6001600160a01b038116811461055757600080fd5b6001600160701b038116811461055757600080fdfea26469706673582212208356f63bd6a73cfecb762ca4f5adaa2b21ce7b2fc44f3181a6d9b4d363c513f564736f6c634300060a00330000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000005757371414417b8c6caad45baef941abc7d3ab32000000000000000000000000a5e0829caced8ffdd4de3c43696c57f7d7a678ff000000000000000000000000c35dadb65012ec5796536bd9864ed8773abc74c40000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000075fbbdeafe23a48c0736b2731b956b7a03adcfb200000000000000000000000038e5462bbe6a72f79606c1a0007468aa4334a92b

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

0000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000005757371414417b8c6caad45baef941abc7d3ab32000000000000000000000000a5e0829caced8ffdd4de3c43696c57f7d7a678ff000000000000000000000000c35dadb65012ec5796536bd9864ed8773abc74c40000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b4799750600000000000000000000000075fbbdeafe23a48c0736b2731b956b7a03adcfb200000000000000000000000038e5462bbe6a72f79606c1a0007468aa4334a92b

-----Decoded View---------------
Arg [0] : _weth (address): 0x7ceb23fd6bc0add59e62ac25578270cff1b9f619
Arg [1] : _uniFactory (address): 0x5757371414417b8c6caad45baef941abc7d3ab32
Arg [2] : _uniRouter (address): 0xa5e0829caced8ffdd4de3c43696c57f7d7a678ff
Arg [3] : _sushiFactory (address): 0xc35dadb65012ec5796536bd9864ed8773abc74c4
Arg [4] : _sushiRouter (address): 0x1b02da8cb0d097eb8d57a175b88c7d8b47997506
Arg [5] : _setController (address): 0x75fbbdeafe23a48c0736b2731b956b7a03adcfb2
Arg [6] : _basicIssuanceModule (address): 0x38e5462bbe6a72f79606c1a0007468aa4334a92b

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 0000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f619
Arg [1] : 0000000000000000000000005757371414417b8c6caad45baef941abc7d3ab32
Arg [2] : 000000000000000000000000a5e0829caced8ffdd4de3c43696c57f7d7a678ff
Arg [3] : 000000000000000000000000c35dadb65012ec5796536bd9864ed8773abc74c4
Arg [4] : 0000000000000000000000001b02da8cb0d097eb8d57a175b88c7d8b47997506
Arg [5] : 00000000000000000000000075fbbdeafe23a48c0736b2731b956b7a03adcfb2
Arg [6] : 00000000000000000000000038e5462bbe6a72f79606c1a0007468aa4334a92b


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.