ETH Price: $3,117.96 (+1.01%)
Gas: 3 Gwei

Contract

0xBE6FEe3756f7BE3A0cD492059341cb5b77dD81F9
 
Transaction Hash
Method
Block
From
To
Value
0xedf176085e36c6b3c89893a26f8bf67263950a899be90943f27f70eea8935cebSwap Exact Token...(pending)2024-05-16 18:43:3946 hrs ago1715885019IN
0xBE6FEe37...b77dD81F9
0 ETH(Pending)(Pending)
Execute Zero Ex ...198967192024-05-18 12:06:355 hrs ago1716033995IN
0xBE6FEe37...b77dD81F9
0.068 ETH0.001189444
Execute Zero Ex ...198944062024-05-18 4:18:4713 hrs ago1716005927IN
0xBE6FEe37...b77dD81F9
0.02754806 ETH0.001405834
Execute Zero Ex ...198944062024-05-18 4:18:4713 hrs ago1716005927IN
0xBE6FEe37...b77dD81F9
0.02754806 ETH0.001477984
Swap Exact ETH F...198908912024-05-17 16:30:1124 hrs ago1715963411IN
0xBE6FEe37...b77dD81F9
0.14909174 ETH0.001405449
Swap Exact Token...198888652024-05-17 9:42:1131 hrs ago1715938931IN
0xBE6FEe37...b77dD81F9
0 ETH0.001254686
Swap Exact Token...198888622024-05-17 9:41:3531 hrs ago1715938895IN
0xBE6FEe37...b77dD81F9
0 ETH0.001172736
Execute Zero Ex ...198888552024-05-17 9:39:5931 hrs ago1715938799IN
0xBE6FEe37...b77dD81F9
0 ETH0.001881976
Swap Exact Token...198888502024-05-17 9:38:5931 hrs ago1715938739IN
0xBE6FEe37...b77dD81F9
0 ETH0.001240556
Swap Exact Token...198888432024-05-17 9:37:2331 hrs ago1715938643IN
0xBE6FEe37...b77dD81F9
0 ETH0.001388556
Execute Zero Ex ...198886452024-05-17 8:57:3532 hrs ago1715936255IN
0xBE6FEe37...b77dD81F9
0.10456224 ETH0.0033189510
Execute Zero Ex ...198844542024-05-16 18:54:2346 hrs ago1715885663IN
0xBE6FEe37...b77dD81F9
0.10005508 ETH0.001781985
Swap Exact Token...198825652024-05-16 12:33:472 days ago1715862827IN
0xBE6FEe37...b77dD81F9
0 ETH0.001288366
Execute Zero Ex ...198823762024-05-16 11:55:472 days ago1715860547IN
0xBE6FEe37...b77dD81F9
0 ETH0.001840085
Swap Exact Token...198818972024-05-16 10:19:352 days ago1715854775IN
0xBE6FEe37...b77dD81F9
0 ETH0.001803096
Swap Exact Token...198799082024-05-16 3:38:352 days ago1715830715IN
0xBE6FEe37...b77dD81F9
0 ETH0.000922965
Swap Exact Token...198769742024-05-15 17:48:112 days ago1715795291IN
0xBE6FEe37...b77dD81F9
0 ETH0.0021828710
Swap Exact Token...198768052024-05-15 17:14:233 days ago1715793263IN
0xBE6FEe37...b77dD81F9
0 ETH0.0027317513
Swap Exact Token...198767532024-05-15 17:03:593 days ago1715792639IN
0xBE6FEe37...b77dD81F9
0 ETH0.0027422910
Swap Exact Token...198763042024-05-15 15:33:593 days ago1715787239IN
0xBE6FEe37...b77dD81F9
0 ETH0.0030063414
Swap Exact Token...198758482024-05-15 14:01:593 days ago1715781719IN
0xBE6FEe37...b77dD81F9
0 ETH0.0034356316
Swap Exact ETH F...198756242024-05-15 13:16:593 days ago1715779019IN
0xBE6FEe37...b77dD81F9
0.06975105 ETH0.001405449
Swap Exact Token...198756152024-05-15 13:15:113 days ago1715778911IN
0xBE6FEe37...b77dD81F9
0 ETH0.0017106510
Execute Zero Ex ...198745092024-05-15 9:33:233 days ago1715765603IN
0xBE6FEe37...b77dD81F9
0.1034741 ETH0.002421537
Execute Zero Ex ...198731022024-05-15 4:50:353 days ago1715748635IN
0xBE6FEe37...b77dD81F9
0 ETH0.000251084
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To Value
198967192024-05-18 12:06:355 hrs ago1716033995
0xBE6FEe37...b77dD81F9
0.00068 ETH
198967192024-05-18 12:06:355 hrs ago1716033995
0xBE6FEe37...b77dD81F9
0.06732 ETH
198944062024-05-18 4:18:4713 hrs ago1716005927
0xBE6FEe37...b77dD81F9
0.00027548 ETH
198944062024-05-18 4:18:4713 hrs ago1716005927
0xBE6FEe37...b77dD81F9
0.02727257 ETH
198944062024-05-18 4:18:4713 hrs ago1716005927
0xBE6FEe37...b77dD81F9
0.02727257 ETH
198908912024-05-17 16:30:1124 hrs ago1715963411
0xBE6FEe37...b77dD81F9
0.00149091 ETH
198908912024-05-17 16:30:1124 hrs ago1715963411
0xBE6FEe37...b77dD81F9
0.14760082 ETH
198888652024-05-17 9:42:1131 hrs ago1715938931
0xBE6FEe37...b77dD81F9
0.00149962 ETH
198888652024-05-17 9:42:1131 hrs ago1715938931
0xBE6FEe37...b77dD81F9
0.1484627 ETH
198888652024-05-17 9:42:1131 hrs ago1715938931
0xBE6FEe37...b77dD81F9
0.14996233 ETH
198888622024-05-17 9:41:3531 hrs ago1715938895
0xBE6FEe37...b77dD81F9
0.0011472 ETH
198888622024-05-17 9:41:3531 hrs ago1715938895
0xBE6FEe37...b77dD81F9
0.11357341 ETH
198888622024-05-17 9:41:3531 hrs ago1715938895
0xBE6FEe37...b77dD81F9
0.11472062 ETH
198888552024-05-17 9:39:5931 hrs ago1715938799
0xBE6FEe37...b77dD81F9
0.33526812 ETH
198888552024-05-17 9:39:5931 hrs ago1715938799
0xBE6FEe37...b77dD81F9
0.33526812 ETH
198888502024-05-17 9:38:5931 hrs ago1715938739
0xBE6FEe37...b77dD81F9
0.0020244 ETH
198888502024-05-17 9:38:5931 hrs ago1715938739
0xBE6FEe37...b77dD81F9
0.20041606 ETH
198888502024-05-17 9:38:5931 hrs ago1715938739
0xBE6FEe37...b77dD81F9
0.20244046 ETH
198888432024-05-17 9:37:2331 hrs ago1715938643
0xBE6FEe37...b77dD81F9
0.00381691 ETH
198888432024-05-17 9:37:2331 hrs ago1715938643
0xBE6FEe37...b77dD81F9
0.377875 ETH
198888432024-05-17 9:37:2331 hrs ago1715938643
0xBE6FEe37...b77dD81F9
0.38169192 ETH
198886452024-05-17 8:57:3532 hrs ago1715936255
0xBE6FEe37...b77dD81F9
0.00104562 ETH
198886452024-05-17 8:57:3532 hrs ago1715936255
0xBE6FEe37...b77dD81F9
0.10351662 ETH
198844542024-05-16 18:54:2346 hrs ago1715885663
0xBE6FEe37...b77dD81F9
0.00100055 ETH
198844542024-05-16 18:54:2346 hrs ago1715885663
0xBE6FEe37...b77dD81F9
0.09905453 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FloozMultichainRouter

Compiler Version
v0.6.6+commit.6c089d02

Optimization Enabled:
Yes with 100 runs

Other Settings:
default evmVersion, Unlicense license
File 1 of 21 : FloozMultichainRouter.sol
pragma solidity =0.6.6;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "./libraries/TransferHelper.sol";
import "./libraries/PancakeLibrary.sol";
import "./interfaces/IReferralRegistry.sol";
import "./interfaces/IWETH.sol";
import "./interfaces/IZerox.sol";

contract FloozMultichainRouter is Ownable, Pausable, ReentrancyGuard {
    using SafeMath for uint256;

    event SwapFeeUpdated(uint16 swapFee);
    event ReferralRegistryUpdated(address referralRegistry);
    event ReferralRewardRateUpdated(uint16 referralRewardRate);
    event ReferralsActivatedUpdated(bool activated);
    event FeeReceiverUpdated(address payable feeReceiver);
    event CustomReferralRewardRateUpdated(address indexed account, uint16 referralRate);
    event ReferralRewardPaid(address from, address indexed to, address tokenOut, address tokenReward, uint256 amount);
    event ForkCreated(address factory);
    event ForkUpdated(address factory);

    struct SwapData {
        address fork;
        address referee;
        bool fee;
    }

    struct ExternalSwapData {
        bytes data;
        address fromToken;
        address toToken;
        uint256 amountFrom;
        address referee;
        uint256 minOut;
        bool fee;
    }

    // Denominator of fee
    uint256 public constant FEE_DENOMINATOR = 10000;

    // Numerator of fee
    uint16 public swapFee;

    // address of WETH
    address public immutable WETH;

    // address of zeroEx proxy contract to forward swaps
    address payable public immutable zeroEx;

    // address of 1inch contract to forward swaps
    address payable public immutable oneInch;

    // address of referral registry that stores referral anchors
    IReferralRegistry public referralRegistry;

    // address that receives protocol fees
    address payable public feeReceiver;

    // percentage of fees that will be paid as rewards
    uint16 public referralRewardRate;

    // stores if the referral system is turned on or off
    bool public referralsActivated;

    // stores individual referral rates
    mapping(address => uint16) public customReferralRewardRate;

    // stores uniswap forks status, index is the factory address
    mapping(address => bool) public forkActivated;

    // stores uniswap forks initCodes, index is the factory address
    mapping(address => bytes) public forkInitCode;

    /// @dev construct this contract
    /// @param _WETH address of WETH.
    /// @param _swapFee nominator for swapFee. Denominator = 10000
    /// @param _referralRewardRate percentage of swapFee that are paid out as rewards
    /// @param _feeReceiver address that receives protocol fees
    /// @param _referralRegistry address of referral registry that stores referral anchors
    /// @param _zeroEx address of zeroX proxy contract to forward swaps
    constructor(
        address _WETH,
        uint16 _swapFee,
        uint16 _referralRewardRate,
        address payable _feeReceiver,
        IReferralRegistry _referralRegistry,
        address payable _zeroEx,
        address payable _oneInch
    ) public {
        WETH = _WETH;
        swapFee = _swapFee;
        referralRewardRate = _referralRewardRate;
        feeReceiver = _feeReceiver;
        referralRegistry = _referralRegistry;
        zeroEx = _zeroEx;
        oneInch = _oneInch;
        referralsActivated = true;
    }

    /// @dev execute swap directly on Uniswap/Pancake & simular forks
    /// @param swapData stores the swapData information
    /// @param amountOutMin minimum tokens to receive
    /// @param path Sell path.
    /// @return amounts
    function swapExactETHForTokens(
        SwapData calldata swapData,
        uint256 amountOutMin,
        address[] calldata path
    )
        external
        payable
        whenNotPaused
        isValidFork(swapData.fork)
        isValidReferee(swapData.referee)
        returns (uint256[] memory amounts)
    {
        require(path[0] == WETH, "FloozRouter: INVALID_PATH");
        address referee = _getReferee(swapData.referee);
        (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            swapData.fee,
            msg.value,
            referee,
            false
        );
        amounts = _getAmountsOut(swapData.fork, swapAmount, path);
        require(amounts[amounts.length - 1] >= amountOutMin, "FloozRouter: INSUFFICIENT_OUTPUT_AMOUNT");
        IWETH(WETH).deposit{value: amounts[0]}();
        assert(IWETH(WETH).transfer(_pairFor(swapData.fork, path[0], path[1]), amounts[0]));
        _swap(swapData.fork, amounts, path, msg.sender);

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(address(0), path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param swapData stores the swapData information
    /// @param amountIn amount of tokensIn
    /// @param amountOutMin minimum tokens to receive
    /// @param path Sell path.
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        SwapData calldata swapData,
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path
    ) external whenNotPaused isValidFork(swapData.fork) isValidReferee(swapData.referee) {
        require(path[path.length - 1] == WETH, "FloozRouter: INVALID_PATH");
        address referee = _getReferee(swapData.referee);
        TransferHelper.safeTransferFrom(path[0], msg.sender, _pairFor(swapData.fork, path[0], path[1]), amountIn);
        _swapSupportingFeeOnTransferTokens(swapData.fork, path, address(this));
        uint256 amountOut = IERC20(WETH).balanceOf(address(this));
        IWETH(WETH).withdraw(amountOut);
        (uint256 amountWithdraw, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            swapData.fee,
            amountOut,
            referee,
            false
        );
        require(amountWithdraw >= amountOutMin, "FloozRouter: LOW_SLIPPAGE");
        TransferHelper.safeTransferETH(msg.sender, amountWithdraw);

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(address(0), path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param swapData stores the swapData information
    /// @param amountIn amount if tokens In
    /// @param amountOutMin minimum tokens to receive
    /// @param path Sell path.
    /// @return amounts
    function swapExactTokensForTokens(
        SwapData calldata swapData,
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path
    )
        external
        whenNotPaused
        isValidFork(swapData.fork)
        isValidReferee(swapData.referee)
        returns (uint256[] memory amounts)
    {
        address referee = _getReferee(swapData.referee);
        (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            swapData.fee,
            amountIn,
            referee,
            false
        );
        amounts = _getAmountsOut(swapData.fork, swapAmount, path);
        require(amounts[amounts.length - 1] >= amountOutMin, "FloozRouter: INSUFFICIENT_OUTPUT_AMOUNT");
        TransferHelper.safeTransferFrom(path[0], msg.sender, _pairFor(swapData.fork, path[0], path[1]), swapAmount);
        _swap(swapData.fork, amounts, path, msg.sender);

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(path[0], path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param swapData stores the swapData information
    /// @param amountIn amount if tokens In
    /// @param amountOutMin minimum tokens to receive
    /// @param path Sell path.
    /// @return amounts
    function swapExactTokensForETH(
        SwapData calldata swapData,
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path
    )
        external
        whenNotPaused
        isValidFork(swapData.fork)
        isValidReferee(swapData.referee)
        returns (uint256[] memory amounts)
    {
        require(path[path.length - 1] == WETH, "FloozRouter: INVALID_PATH");
        address referee = _getReferee(swapData.referee);
        amounts = _getAmountsOut(swapData.fork, amountIn, path);
        (uint256 amountWithdraw, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            swapData.fee,
            amounts[amounts.length - 1],
            referee,
            false
        );
        require(amountWithdraw >= amountOutMin, "FloozRouter: INSUFFICIENT_OUTPUT_AMOUNT");
        TransferHelper.safeTransferFrom(path[0], msg.sender, _pairFor(swapData.fork, path[0], path[1]), amounts[0]);
        _swap(swapData.fork, amounts, path, address(this));
        IWETH(WETH).withdraw(amounts[amounts.length - 1]);
        TransferHelper.safeTransferETH(msg.sender, amountWithdraw);

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(address(0), path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param swapData stores the swapData information
    /// @param amountOut expected amount of tokens out
    /// @param path Sell path.
    /// @return amounts
    function swapETHForExactTokens(
        SwapData calldata swapData,
        uint256 amountOut,
        address[] calldata path
    )
        external
        payable
        whenNotPaused
        isValidFork(swapData.fork)
        isValidReferee(swapData.referee)
        returns (uint256[] memory amounts)
    {
        require(path[0] == WETH, "FloozRouter: INVALID_PATH");
        address referee = _getReferee(swapData.referee);
        amounts = _getAmountsIn(swapData.fork, amountOut, path);
        (, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            swapData.fee,
            amounts[0],
            referee,
            true
        );
        require(amounts[0].add(feeAmount).add(referralReward) <= msg.value, "FloozRouter: EXCESSIVE_INPUT_AMOUNT");

        IWETH(WETH).deposit{value: amounts[0]}();
        assert(IWETH(WETH).transfer(_pairFor(swapData.fork, path[0], path[1]), amounts[0]));
        _swap(swapData.fork, amounts, path, msg.sender);

        // refund dust eth, if any
        if (msg.value > amounts[0].add(feeAmount).add(referralReward))
            TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0].add(feeAmount).add(referralReward));

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(address(0), path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param swapData stores the swapData information
    /// @param amountIn amount if tokens In
    /// @param amountOutMin minimum tokens to receive
    /// @param path Sell path.
    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        SwapData calldata swapData,
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path
    ) external whenNotPaused isValidFork(swapData.fork) isValidReferee(swapData.referee) {
        address referee = _getReferee(swapData.referee);
        (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            swapData.fee,
            amountIn,
            referee,
            false
        );
        TransferHelper.safeTransferFrom(path[0], msg.sender, _pairFor(swapData.fork, path[0], path[1]), swapAmount);
        uint256 balanceBefore = IERC20(path[path.length - 1]).balanceOf(msg.sender);
        _swapSupportingFeeOnTransferTokens(swapData.fork, path, msg.sender);
        require(
            IERC20(path[path.length - 1]).balanceOf(msg.sender).sub(balanceBefore) >= amountOutMin,
            "FloozRouter: INSUFFICIENT_OUTPUT_AMOUNT"
        );

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(path[0], path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param swapData stores the swapData information
    /// @param amountOut expected tokens to receive
    /// @param amountInMax maximum tokens to send
    /// @param path Sell path.
    /// @return amounts
    function swapTokensForExactTokens(
        SwapData calldata swapData,
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path
    )
        external
        whenNotPaused
        isValidFork(swapData.fork)
        isValidReferee(swapData.referee)
        returns (uint256[] memory amounts)
    {
        address referee = _getReferee(swapData.referee);
        amounts = _getAmountsIn(swapData.fork, amountOut, path);
        (, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            swapData.fee,
            amounts[0],
            referee,
            true
        );

        require(amounts[0].add(feeAmount).add(referralReward) <= amountInMax, "FloozRouter: EXCESSIVE_INPUT_AMOUNT");
        TransferHelper.safeTransferFrom(path[0], msg.sender, _pairFor(swapData.fork, path[0], path[1]), amounts[0]);
        _swap(swapData.fork, amounts, path, msg.sender);

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(path[0], path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param swapData stores the swapData information
    /// @param amountOut expected tokens to receive
    /// @param amountInMax maximum tokens to send
    /// @param path Sell path.
    /// @return amounts
    function swapTokensForExactETH(
        SwapData calldata swapData,
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path
    )
        external
        whenNotPaused
        isValidFork(swapData.fork)
        isValidReferee(swapData.referee)
        returns (uint256[] memory amounts)
    {
        require(path[path.length - 1] == WETH, "FloozRouter: INVALID_PATH");
        address referee = _getReferee(swapData.referee);

        (, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            swapData.fee,
            amountOut,
            referee,
            true
        );

        amounts = _getAmountsIn(swapData.fork, amountOut.add(feeAmount).add(referralReward), path);
        require(amounts[0].add(feeAmount).add(referralReward) <= amountInMax, "FloozRouter: EXCESSIVE_INPUT_AMOUNT");
        TransferHelper.safeTransferFrom(path[0], msg.sender, _pairFor(swapData.fork, path[0], path[1]), amounts[0]);
        _swap(swapData.fork, amounts, path, address(this));
        IWETH(WETH).withdraw(amounts[amounts.length - 1]);

        TransferHelper.safeTransferETH(msg.sender, amountOut);
        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(address(0), path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param swapData stores the swapData information
    /// @param amountOutMin minimum expected tokens to receive
    /// @param path Sell path.
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        SwapData calldata swapData,
        uint256 amountOutMin,
        address[] calldata path
    ) external payable whenNotPaused isValidFork(swapData.fork) isValidReferee(swapData.referee) {
        require(path[0] == WETH, "FloozRouter: INVALID_PATH");
        address referee = _getReferee(swapData.referee);
        (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            swapData.fee,
            msg.value,
            referee,
            false
        );
        IWETH(WETH).deposit{value: swapAmount}();
        assert(IWETH(WETH).transfer(_pairFor(swapData.fork, path[0], path[1]), swapAmount));
        uint256 balanceBefore = IERC20(path[path.length - 1]).balanceOf(msg.sender);
        _swapSupportingFeeOnTransferTokens(swapData.fork, path, msg.sender);
        require(
            IERC20(path[path.length - 1]).balanceOf(msg.sender).sub(balanceBefore) >= amountOutMin,
            "FloozRouter: INSUFFICIENT_OUTPUT_AMOUNT"
        );
        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(address(0), path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev returns the referee for a given address, if new, registers referee
    /// @param referee the address of the referee for msg.sender
    /// @return referee address from referral registry
    function _getReferee(address referee) internal returns (address) {
        address sender = msg.sender;
        if (!referralRegistry.hasUserReferee(sender) && referee != address(0)) {
            referralRegistry.createReferralAnchor(sender, referee);
        }
        return referralRegistry.getUserReferee(sender);
    }

    // **** SWAP ****
    // requires the initial amount to have already been sent to the first pair
    function _swap(
        address fork,
        uint256[] memory amounts,
        address[] memory path,
        address _to
    ) internal {
        for (uint256 i; i < path.length - 1; i++) {
            (address input, address output) = (path[i], path[i + 1]);
            (address token0, ) = PancakeLibrary.sortTokens(input, output);
            uint256 amountOut = amounts[i + 1];
            (uint256 amount0Out, uint256 amount1Out) = input == token0
                ? (uint256(0), amountOut)
                : (amountOut, uint256(0));
            address to = i < path.length - 2 ? _pairFor(fork, output, path[i + 2]) : _to;
            IPancakePair(_pairFor(fork, input, output)).swap(amount0Out, amount1Out, to, new bytes(0));
        }
    }

    // **** SWAP (supporting fee-on-transfer tokens) ****
    // requires the initial amount to have already been sent to the first pair
    function _swapSupportingFeeOnTransferTokens(
        address fork,
        address[] memory path,
        address _to
    ) internal {
        for (uint256 i; i < path.length - 1; i++) {
            (address input, address output) = (path[i], path[i + 1]);
            (address token0, ) = PancakeLibrary.sortTokens(input, output);
            IPancakePair pair = IPancakePair(_pairFor(fork, input, output));
            uint256 amountInput;
            uint256 amountOutput;
            {
                // scope to avoid stack too deep errors
                (uint256 reserve0, uint256 reserve1, ) = pair.getReserves();
                (uint256 reserveInput, uint256 reserveOutput) = input == token0
                    ? (reserve0, reserve1)
                    : (reserve1, reserve0);
                amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
                amountOutput = _getAmountOut(amountInput, reserveInput, reserveOutput);
            }
            (uint256 amount0Out, uint256 amount1Out) = input == token0
                ? (uint256(0), amountOutput)
                : (amountOutput, uint256(0));
            address to = i < path.length - 2 ? _pairFor(fork, output, path[i + 2]) : _to;
            pair.swap(amount0Out, amount1Out, to, new bytes(0));
        }
    }

    /// @dev Executes a swap on 1inch
    /// @param swapData encoded swap data
    function executeOneInchSwap(ExternalSwapData calldata swapData)
        external
        payable
        nonReentrant
        whenNotPaused
        isValidReferee(swapData.referee)
    {
        address referee = _getReferee(swapData.referee);
        uint256 balanceBefore;
        if (swapData.toToken == address(0)) {
            balanceBefore = msg.sender.balance;
        } else {
            balanceBefore = IERC20(swapData.toToken).balanceOf(msg.sender);
        }
        if (!swapData.fee) {
            // execute without fees
            if (swapData.fromToken != address(0)) {
                IERC20(swapData.fromToken).transferFrom(msg.sender, address(this), swapData.amountFrom);
                IERC20(swapData.fromToken).approve(oneInch, swapData.amountFrom);
            }
            // executes trade and sends toToken to defined recipient
            (bool success, ) = address(oneInch).call{value: msg.value}(swapData.data);
            require(success, "FloozRouter: REVERTED");
        } else {
            // Swap from ETH
            if (msg.value > 0 && swapData.fromToken == address(0)) {
                (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
                    swapData.fee,
                    msg.value,
                    referee,
                    false
                );
                (bool success, ) = address(oneInch).call{value: swapAmount}(swapData.data);
                require(success, "FloozRouter: REVERTED");
                _withdrawFeesAndRewards(address(0), swapData.toToken, referee, feeAmount, referralReward);
                // Swap from token
            } else {
                (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
                    swapData.fee,
                    swapData.amountFrom,
                    referee,
                    false
                );
                IERC20(swapData.fromToken).transferFrom(msg.sender, address(this), swapAmount);
                IERC20(swapData.fromToken).approve(oneInch, swapAmount);
                (bool success, ) = address(oneInch).call(swapData.data);
                require(success, "FloozRouter: REVERTED");
                _withdrawFeesAndRewards(swapData.fromToken, swapData.toToken, referee, feeAmount, referralReward);
            }
            uint256 balanceAfter;
            if (swapData.toToken == address(0)) {
                balanceAfter = msg.sender.balance;
            } else {
                balanceAfter = IERC20(swapData.toToken).balanceOf(msg.sender);
            }
            require(balanceAfter.sub(balanceBefore) >= swapData.minOut, "FloozRouter: INSUFFICIENT_OUTPUT");
        }
    }

    /// @dev Executes a swap on 0x
    /// @param swapData encoded swap data
    function executeZeroExSwap(ExternalSwapData calldata swapData)
        external
        payable
        nonReentrant
        whenNotPaused
        isValidReferee(swapData.referee)
    {
        address referee = _getReferee(swapData.referee);
        uint256 balanceBefore;
        if (swapData.toToken == address(0)) {
            balanceBefore = msg.sender.balance;
        } else {
            balanceBefore = IERC20(swapData.toToken).balanceOf(msg.sender);
        }
        if (!swapData.fee) {
            if (msg.value > 0 && swapData.fromToken == address(0)) {
                (bool success, ) = zeroEx.call{value: msg.value}(swapData.data);
                require(success, "FloozRouter: REVERTED");
                TransferHelper.safeTransfer(
                    swapData.toToken,
                    msg.sender,
                    IERC20(swapData.toToken).balanceOf(address(this))
                );
            } else {
                IERC20(swapData.fromToken).transferFrom(msg.sender, address(this), swapData.amountFrom);
                IERC20(swapData.fromToken).approve(zeroEx, swapData.amountFrom);
                (bool success, ) = zeroEx.call(swapData.data);
                require(success, "FloozRouter: REVERTED");
                if (swapData.toToken == address(0)) {
                    TransferHelper.safeTransferETH(msg.sender, address(this).balance);
                } else {
                    TransferHelper.safeTransfer(
                        swapData.toToken,
                        msg.sender,
                        IERC20(swapData.toToken).balanceOf(address(this))
                    );
                }
            }
        } else {
            // Swap from ETH
            if (msg.value > 0 && swapData.fromToken == address(0)) {
                (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
                    swapData.fee,
                    msg.value,
                    referee,
                    false
                );
                (bool success, ) = zeroEx.call{value: swapAmount}(swapData.data);
                require(success, "FloozRouter: REVERTED");
                TransferHelper.safeTransfer(
                    swapData.toToken,
                    msg.sender,
                    IERC20(swapData.toToken).balanceOf(address(this))
                );
                _withdrawFeesAndRewards(address(0), swapData.toToken, referee, feeAmount, referralReward);
                // Swap from Token
            } else {
                (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
                    swapData.fee,
                    swapData.amountFrom,
                    referee,
                    false
                );
                IERC20(swapData.fromToken).transferFrom(msg.sender, address(this), swapAmount);
                IERC20(swapData.fromToken).approve(zeroEx, swapAmount);
                (bool success, ) = zeroEx.call(swapData.data);
                require(success, "FloozRouter: REVERTED");
                if (swapData.toToken == address(0)) {
                    TransferHelper.safeTransferETH(msg.sender, address(this).balance);
                } else {
                    TransferHelper.safeTransfer(
                        swapData.toToken,
                        msg.sender,
                        IERC20(swapData.toToken).balanceOf(address(this))
                    );
                }
                _withdrawFeesAndRewards(swapData.fromToken, swapData.toToken, referee, feeAmount, referralReward);
            }
        }
        uint256 balanceAfter;
        if (swapData.toToken == address(0)) {
            balanceAfter = msg.sender.balance;
        } else {
            balanceAfter = IERC20(swapData.toToken).balanceOf(msg.sender);
        }
        require(balanceAfter.sub(balanceBefore) >= swapData.minOut, "FloozRouter: INSUFFICIENT_OUTPUT");
    }

    /// @dev calculates swap, fee & reward amounts
    /// @param fee boolean if fee will be applied or not
    /// @param amount total amount of tokens
    /// @param referee the address of the referee for msg.sender
    function _calculateFeesAndRewards(
        bool fee,
        uint256 amount,
        address referee,
        bool additiveFee
    )
        internal
        view
        returns (
            uint256 swapAmount,
            uint256 feeAmount,
            uint256 referralReward
        )
    {
        uint16 swapFee = swapFee;
        // no fees for users above threshold
        if (!fee) {
            swapAmount = amount;
        } else {
            if (additiveFee) {
                swapAmount = amount;
                feeAmount = swapAmount.mul(FEE_DENOMINATOR).div(FEE_DENOMINATOR.sub(swapFee)).sub(amount);
            } else {
                feeAmount = amount.mul(swapFee).div(FEE_DENOMINATOR);
                swapAmount = amount.sub(feeAmount);
            }

            // calculate referral rates, if referee is not 0x
            if (referee != address(0) && referralsActivated) {
                uint16 referralRate = customReferralRewardRate[referee] > 0
                    ? customReferralRewardRate[referee]
                    : referralRewardRate;
                referralReward = feeAmount.mul(referralRate).div(FEE_DENOMINATOR);
                feeAmount = feeAmount.sub(referralReward);
            } else {
                referralReward = 0;
            }
        }
    }

    /// @dev lets the admin register an Uniswap style fork
    function registerFork(address _factory, bytes calldata _initCode) external onlyOwner {
        require(!forkActivated[_factory], "FloozRouter: ACTIVE_FORK");
        forkActivated[_factory] = true;
        forkInitCode[_factory] = _initCode;
        emit ForkCreated(_factory);
    }

    /// @dev lets the admin update an Uniswap style fork
    function updateFork(
        address _factory,
        bytes calldata _initCode,
        bool _activated
    ) external onlyOwner {
        forkActivated[_factory] = _activated;
        forkInitCode[_factory] = _initCode;
        emit ForkUpdated(_factory);
    }

    /// @dev lets the admin update the swapFee nominator
    function updateSwapFee(uint16 newSwapFee) external onlyOwner {
        swapFee = newSwapFee;
        emit SwapFeeUpdated(newSwapFee);
    }

    /// @dev lets the admin update the referral reward rate
    function updateReferralRewardRate(uint16 newReferralRewardRate) external onlyOwner {
        require(newReferralRewardRate <= FEE_DENOMINATOR, "FloozRouter: INVALID_RATE");
        referralRewardRate = newReferralRewardRate;
        emit ReferralRewardRateUpdated(newReferralRewardRate);
    }

    /// @dev lets the admin update which address receives the protocol fees
    function updateFeeReceiver(address payable newFeeReceiver) external onlyOwner {
        feeReceiver = newFeeReceiver;
        emit FeeReceiverUpdated(newFeeReceiver);
    }

    /// @dev lets the admin update the status of the referral system
    function updateReferralsActivated(bool newReferralsActivated) external onlyOwner {
        referralsActivated = newReferralsActivated;
        emit ReferralsActivatedUpdated(newReferralsActivated);
    }

    /// @dev lets the admin set a new referral registry
    function updateReferralRegistry(address newReferralRegistry) external onlyOwner {
        referralRegistry = IReferralRegistry(newReferralRegistry);
        emit ReferralRegistryUpdated(newReferralRegistry);
    }

    /// @dev lets the admin set a custom referral rate
    function updateCustomReferralRewardRate(address account, uint16 referralRate) external onlyOwner returns (uint256) {
        require(referralRate <= FEE_DENOMINATOR, "FloozRouter: INVALID_RATE");
        customReferralRewardRate[account] = referralRate;
        emit CustomReferralRewardRateUpdated(account, referralRate);
    }

    /// @dev returns the referee for a given user - 0x address if none
    function getUserReferee(address user) external view returns (address) {
        return referralRegistry.getUserReferee(user);
    }

    /// @dev returns if the given user has been referred or not
    function hasUserReferee(address user) external view returns (bool) {
        return referralRegistry.hasUserReferee(user);
    }

    /// @dev lets the admin withdraw ETH from the contract.
    function withdrawETH(address payable to, uint256 amount) external onlyOwner {
        TransferHelper.safeTransferETH(to, amount);
    }

    /// @dev lets the admin withdraw ERC20s from the contract.
    function withdrawERC20Token(
        address token,
        address to,
        uint256 amount
    ) external onlyOwner {
        TransferHelper.safeTransfer(token, to, amount);
    }

    /// @dev distributes fees & referral rewards to users
    function _withdrawFeesAndRewards(
        address tokenReward,
        address tokenOut,
        address referee,
        uint256 feeAmount,
        uint256 referralReward
    ) internal {
        if (tokenReward == address(0)) {
            TransferHelper.safeTransferETH(feeReceiver, feeAmount);
            if (referralReward > 0) {
                TransferHelper.safeTransferETH(referee, referralReward);
                emit ReferralRewardPaid(msg.sender, referee, tokenOut, tokenReward, referralReward);
            }
        } else {
            TransferHelper.safeTransferFrom(tokenReward, msg.sender, feeReceiver, feeAmount);
            if (referralReward > 0) {
                TransferHelper.safeTransferFrom(tokenReward, msg.sender, referee, referralReward);
                emit ReferralRewardPaid(msg.sender, referee, tokenOut, tokenReward, referralReward);
            }
        }
    }

    /// @dev given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function _getAmountOut(
        uint256 amountIn,
        uint256 reserveIn,
        uint256 reserveOut
    ) internal pure returns (uint256 amountOut) {
        require(amountIn > 0, "FloozRouter: INSUFFICIENT_INPUT_AMOUNT");
        require(reserveIn > 0 && reserveOut > 0, "FloozRouter: INSUFFICIENT_LIQUIDITY");
        uint256 amountInWithFee = amountIn.mul((9970));
        uint256 numerator = amountInWithFee.mul(reserveOut);
        uint256 denominator = reserveIn.mul(10000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    /// @dev given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function _getAmountIn(
        uint256 amountOut,
        uint256 reserveIn,
        uint256 reserveOut
    ) internal pure returns (uint256 amountIn) {
        require(amountOut > 0, "FloozRouter: INSUFFICIENT_OUTPUT_AMOUNT");
        require(reserveIn > 0 && reserveOut > 0, "FloozRouter: INSUFFICIENT_LIQUIDITY");
        uint256 numerator = reserveIn.mul(amountOut).mul(10000);
        uint256 denominator = reserveOut.sub(amountOut).mul(9970);
        amountIn = (numerator / denominator).add(1);
    }

    /// @dev performs chained getAmountOut calculations on any number of pairs
    function _getAmountsOut(
        address fork,
        uint256 amountIn,
        address[] memory path
    ) internal view returns (uint256[] memory amounts) {
        require(path.length >= 2, "FloozRouter: INVALID_PATH");
        amounts = new uint256[](path.length);
        amounts[0] = amountIn;
        for (uint256 i; i < path.length - 1; i++) {
            (uint256 reserveIn, uint256 reserveOut) = _getReserves(fork, path[i], path[i + 1]);
            amounts[i + 1] = _getAmountOut(amounts[i], reserveIn, reserveOut);
        }
    }

    /// @dev performs chained getAmountIn calculations on any number of pairs
    function _getAmountsIn(
        address factory,
        uint256 amountOut,
        address[] memory path
    ) internal view returns (uint256[] memory amounts) {
        require(path.length >= 2, "FloozRouter: INVALID_PATH");
        amounts = new uint256[](path.length);
        amounts[amounts.length - 1] = amountOut;
        for (uint256 i = path.length - 1; i > 0; i--) {
            (uint256 reserveIn, uint256 reserveOut) = _getReserves(factory, path[i - 1], path[i]);
            amounts[i - 1] = _getAmountIn(amounts[i], reserveIn, reserveOut);
        }
    }

    /// @dev fetches and sorts the reserves for a pair
    function _getReserves(
        address factory,
        address tokenA,
        address tokenB
    ) internal view returns (uint256 reserveA, uint256 reserveB) {
        (address token0, ) = PancakeLibrary.sortTokens(tokenA, tokenB);
        (uint256 reserve0, uint256 reserve1, ) = IPancakePair(_pairFor(factory, tokenA, tokenB)).getReserves();
        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
    }

    /// @dev calculates the CREATE2 address for a pair without making any external calls
    function _pairFor(
        address factory,
        address tokenA,
        address tokenB
    ) internal view returns (address pair) {
        (address token0, address token1) = PancakeLibrary.sortTokens(tokenA, tokenB);
        pair = address(
            uint256(
                keccak256(
                    abi.encodePacked(
                        hex"ff",
                        factory,
                        keccak256(abi.encodePacked(token0, token1)),
                        forkInitCode[factory] // init code hash
                    )
                )
            )
        );
    }

    /// @dev lets the admin pause this contract
    function pause() external onlyOwner {
        _pause();
    }

    /// @dev lets the admin unpause this contract
    function unpause() external onlyOwner {
        _unpause();
    }

    /// @dev allows to receive ETH on the contract
    receive() external payable {}

    modifier isValidFork(address factory) {
        require(forkActivated[factory], "FloozRouter: INVALID_FACTORY");
        _;
    }

    modifier isValidReferee(address referee) {
        require(msg.sender != referee, "FloozRouter: SELF_REFERRAL");
        _;
    }
}

File 2 of 21 : FeeReceiver.sol
pragma solidity =0.6.6;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "./libraries/TransferHelper.sol";
import "./interfaces/IPancakeRouter02.sol";
import "./interfaces/IWETH.sol";

contract FeeReceiver is Pausable, Ownable {
    using SafeMath for uint256;

    event BuybackRateUpdated(uint256 newBuybackRate);
    event RevenueReceiverUpdated(address newRevenueReceiver);
    event RouterWhitelistUpdated(address router, bool status);
    event BuybackExecuted(uint256 amountBuyback, uint256 amountRevenue);

    address internal constant ZERO_ADDRESS = address(0);
    uint256 public constant FEE_DENOMINATOR = 10000;
    IPancakeRouter02 public pancakeRouter;
    address payable public revenueReceiver;
    uint256 public buybackRate;
    address public SYA;
    address public WETH;

    mapping(address => bool) public routerWhitelist;

    constructor(
        IPancakeRouter02 _pancakeRouterV2,
        address _SYA,
        address _WETH,
        address payable _revenueReceiver,
        uint256 _buybackRate
    ) public {
        pancakeRouter = _pancakeRouterV2;
        SYA = _SYA;
        WETH = _WETH;
        revenueReceiver = _revenueReceiver;
        buybackRate = _buybackRate;
        routerWhitelist[address(pancakeRouter)] = true;
    }

    /// @dev executes the buyback, buys SYA on pancake & sends revenue to the revenueReceiver by the defined rate.
    function executeBuyback() external whenNotPaused {
        require(address(this).balance > 0, "FeeReceiver: No balance for buyback");
        address[] memory path = new address[](2);
        path[0] = WETH;
        path[1] = SYA;

        uint256 balance = address(this).balance;
        uint256 amountBuyback = balance.mul(buybackRate).div(FEE_DENOMINATOR);
        uint256 amountRevenue = balance.sub(amountBuyback);

        pancakeRouter.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amountBuyback}(
            0,
            path,
            ZERO_ADDRESS,
            block.timestamp
        );
        TransferHelper.safeTransferETH(revenueReceiver, amountRevenue);
        emit BuybackExecuted(amountBuyback, amountRevenue);
    }

    /// @dev converts collected tokens from fees to ETH for executing buybacks
    function convertToETH(
        address _router,
        IERC20 _token,
        bool _fee
    ) public whenNotPaused {
        require(routerWhitelist[_router], "FeeReceiver: Router not whitelisted");
        address[] memory path = new address[](2);
        path[0] = address(_token);
        path[1] = WETH;

        uint256 balance = _token.balanceOf(address(this));
        TransferHelper.safeApprove(address(_token), address(pancakeRouter), balance);
        if (_fee) {
            IPancakeRouter02(_router).swapExactTokensForETHSupportingFeeOnTransferTokens(
                balance,
                0,
                path,
                address(this),
                block.timestamp
            );
        } else {
            IPancakeRouter02(_router).swapExactTokensForETH(balance, 0, path, address(this), block.timestamp);
        }
    }

    /// @dev converts WETH to ETH
    function unwrapWETH() public whenNotPaused {
        uint256 balance = IWETH(WETH).balanceOf(address(this));
        require(balance > 0, "FeeReceiver: Nothing to unwrap");
        IWETH(WETH).withdraw(balance);
    }

    /// @dev lets the owner update update the router whitelist
    function updateRouterWhiteliste(address _router, bool _status) external onlyOwner {
        routerWhitelist[_router] = _status;
        emit RouterWhitelistUpdated(_router, _status);
    }

    /// @dev lets the owner update the buyback rate
    function updateBuybackRate(uint256 _newBuybackRate) external onlyOwner {
        buybackRate = _newBuybackRate;
        emit BuybackRateUpdated(_newBuybackRate);
    }

    /// @dev lets the owner update the revenue receiver address
    function updateRevenueReceiver(address payable _newRevenueReceiver) external onlyOwner {
        revenueReceiver = _newRevenueReceiver;
        emit RevenueReceiverUpdated(_newRevenueReceiver);
    }

    /// @dev lets the owner withdraw ETH from the contract
    function withdrawETH(address payable to, uint256 amount) external onlyOwner {
        to.transfer(amount);
    }

    /// @dev lets the owner withdraw any ERC20 Token from the contract
    function withdrawERC20Token(
        address token,
        address to,
        uint256 amount
    ) external onlyOwner {
        IERC20(token).transfer(to, amount);
    }

    /// @dev allows to receive ETH on this contract
    receive() external payable {}

    /// @dev lets the owner pause the contract
    function pause() external onlyOwner {
        _pause();
    }

    /// @dev lets the owner unpause the contract
    function unpause() external onlyOwner {
        _unpause();
    }
}

File 3 of 21 : 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 21 : 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, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, 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 (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @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) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @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) {
        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, reverting 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) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting 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) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * 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);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * 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);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * 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 5 of 21 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../utils/Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

File 6 of 21 : Pausable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor () internal {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 7 of 21 : TransferHelper.sol
pragma solidity =0.6.6;

// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('approve(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: APPROVE_FAILED");
    }

    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transfer(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: TRANSFER_FAILED");
    }

    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: TRANSFER_FROM_FAILED");
    }

    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, "TransferHelper: ETH_TRANSFER_FAILED");
    }
}

File 8 of 21 : IPancakeRouter02.sol
pragma solidity >=0.6.2;

import "./IPancakeRouter01.sol";

interface IPancakeRouter02 is IPancakeRouter01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountETH);

    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline,
        bool approveMax,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint256 amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external;

    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external payable;

    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external;
}

File 9 of 21 : IWETH.sol
pragma solidity >=0.5.0;

interface IWETH {
    function deposit() external payable;

    function transfer(address to, uint256 value) external returns (bool);

    function withdraw(uint256) external;

    function approve(address _spender, uint256 _amount) external returns (bool);

    function balanceOf(address _account) external view returns (uint256);
}

File 10 of 21 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 11 of 21 : IPancakeRouter01.sol
pragma solidity >=0.6.2;

interface IPancakeRouter01 {
    function factory() external pure returns (address);

    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint256 amountADesired,
        uint256 amountBDesired,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline
    )
        external
        returns (
            uint256 amountA,
            uint256 amountB,
            uint256 liquidity
        );

    function addLiquidityETH(
        address token,
        uint256 amountTokenDesired,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    )
        external
        payable
        returns (
            uint256 amountToken,
            uint256 amountETH,
            uint256 liquidity
        );

    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint256 liquidity,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountA, uint256 amountB);

    function removeLiquidityETH(
        address token,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline
    ) external returns (uint256 amountToken, uint256 amountETH);

    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint256 liquidity,
        uint256 amountAMin,
        uint256 amountBMin,
        address to,
        uint256 deadline,
        bool approveMax,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint256 amountA, uint256 amountB);

    function removeLiquidityETHWithPermit(
        address token,
        uint256 liquidity,
        uint256 amountTokenMin,
        uint256 amountETHMin,
        address to,
        uint256 deadline,
        bool approveMax,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external returns (uint256 amountToken, uint256 amountETH);

    function swapExactTokensForTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapTokensForExactTokens(
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapExactETHForTokens(
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external payable returns (uint256[] memory amounts);

    function swapTokensForExactETH(
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapExactTokensForETH(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);

    function swapETHForExactTokens(
        uint256 amountOut,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external payable returns (uint256[] memory amounts);

    function quote(
        uint256 amountA,
        uint256 reserveA,
        uint256 reserveB
    ) external pure returns (uint256 amountB);

    function getAmountOut(
        uint256 amountIn,
        uint256 reserveIn,
        uint256 reserveOut
    ) external pure returns (uint256 amountOut);

    function getAmountIn(
        uint256 amountOut,
        uint256 reserveIn,
        uint256 reserveOut
    ) external pure returns (uint256 amountIn);

    function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);

    function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);
}

File 12 of 21 : FloozRouter.sol
pragma solidity =0.6.6;

import "@0x/contracts-utils/contracts/src/v06/LibBytesV06.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "./libraries/TransferHelper.sol";
import "./libraries/PancakeLibrary.sol";
import "./interfaces/IReferralRegistry.sol";
import "./interfaces/IWETH.sol";
import "./interfaces/IZerox.sol";

contract FloozRouter is Ownable, Pausable, ReentrancyGuard {
    using SafeMath for uint256;
    using LibBytesV06 for bytes;

    event SwapFeeUpdated(uint16 swapFee);
    event ReferralRegistryUpdated(address referralRegistry);
    event ReferralRewardRateUpdated(uint16 referralRewardRate);
    event ReferralsActivatedUpdated(bool activated);
    event FeeReceiverUpdated(address payable feeReceiver);
    event BalanceThresholdUpdated(uint256 balanceThreshold);
    event CustomReferralRewardRateUpdated(address indexed account, uint16 referralRate);
    event ReferralRewardPaid(address from, address indexed to, address tokenOut, address tokenReward, uint256 amount);
    event ForkUpdated(address factory);

    // Denominator of fee
    uint256 public constant FEE_DENOMINATOR = 10000;

    // Numerator of fee
    uint16 public swapFee;

    // address of WETH
    address public immutable WETH;

    // address of zeroEx proxy contract to forward swaps
    address payable public immutable zeroEx;

    // address of 1inch contract to forward swaps
    address payable public immutable oneInch;

    // address of referral registry that stores referral anchors
    IReferralRegistry public referralRegistry;

    // address of SYA token
    IERC20 public saveYourAssetsToken;

    // balance threshold of SYA tokens which actives feeless swapping
    uint256 public balanceThreshold;

    // address that receives protocol fees
    address payable public feeReceiver;

    // percentage of fees that will be paid as rewards
    uint16 public referralRewardRate;

    // stores if the referral system is turned on or off
    bool public referralsActivated;

    // stores individual referral rates
    mapping(address => uint16) public customReferralRewardRate;

    // stores uniswap forks status, index is the factory address
    mapping(address => bool) public forkActivated;

    // stores uniswap forks initCodes, index is the factory address
    mapping(address => bytes) public forkInitCode;

    /// @dev construct this contract
    /// @param _WETH address of WETH.
    /// @param _swapFee nominator for swapFee. Denominator = 10000
    /// @param _referralRewardRate percentage of swapFee that are paid out as rewards
    /// @param _feeReceiver address that receives protocol fees
    /// @param _balanceThreshold balance threshold of SYA tokens which actives feeless swapping
    /// @param _saveYourAssetsToken address of SYA token
    /// @param _referralRegistry address of referral registry that stores referral anchors
    /// @param _zeroEx address of zeroX proxy contract to forward swaps
    /// @param _oneInch address of 1inch contract to forward swaps
    constructor(
        address _WETH,
        uint16 _swapFee,
        uint16 _referralRewardRate,
        address payable _feeReceiver,
        uint256 _balanceThreshold,
        IERC20 _saveYourAssetsToken,
        IReferralRegistry _referralRegistry,
        address payable _zeroEx,
        address payable _oneInch
    ) public {
        WETH = _WETH;
        swapFee = _swapFee;
        referralRewardRate = _referralRewardRate;
        feeReceiver = _feeReceiver;
        saveYourAssetsToken = _saveYourAssetsToken;
        balanceThreshold = _balanceThreshold;
        referralRegistry = _referralRegistry;
        zeroEx = _zeroEx;
        oneInch = _oneInch;
        referralsActivated = true;
    }

    /// @dev execute swap directly on Uniswap/Pancake & simular forks
    /// @param fork fork used to execute swap
    /// @param amountOutMin minimum tokens to receive
    /// @param path Sell path.
    /// @param referee address of referee for msg.sender, 0x adress if none
    /// @return amounts
    function swapExactETHForTokens(
        address fork,
        uint256 amountOutMin,
        address[] calldata path,
        address referee
    ) external payable whenNotPaused isValidFork(fork) isValidReferee(referee) returns (uint256[] memory amounts) {
        require(path[0] == WETH, "FloozRouter: INVALID_PATH");
        referee = _getReferee(referee);
        (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            msg.value,
            referee,
            false
        );
        amounts = _getAmountsOut(fork, swapAmount, path);
        require(amounts[amounts.length - 1] >= amountOutMin, "FloozRouter: INSUFFICIENT_OUTPUT_AMOUNT");
        IWETH(WETH).deposit{value: amounts[0]}();
        assert(IWETH(WETH).transfer(_pairFor(fork, path[0], path[1]), amounts[0]));
        _swap(fork, amounts, path, msg.sender);

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(address(0), path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param fork fork used to execute swap
    /// @param amountIn amount of tokensIn
    /// @param amountOutMin minimum tokens to receive
    /// @param path Sell path.
    /// @param referee address of referee for msg.sender, 0x adress if none
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        address fork,
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address referee
    ) external whenNotPaused isValidFork(fork) isValidReferee(referee) {
        require(path[path.length - 1] == WETH, "FloozRouter: INVALID_PATH");
        referee = _getReferee(referee);
        TransferHelper.safeTransferFrom(path[0], msg.sender, _pairFor(fork, path[0], path[1]), amountIn);
        _swapSupportingFeeOnTransferTokens(fork, path, address(this));
        uint256 amountOut = IERC20(WETH).balanceOf(address(this));
        IWETH(WETH).withdraw(amountOut);
        (uint256 amountWithdraw, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            amountOut,
            referee,
            false
        );
        require(amountWithdraw >= amountOutMin, "FloozRouter: LOW_SLIPPAGE");
        TransferHelper.safeTransferETH(msg.sender, amountWithdraw);

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(address(0), path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param fork fork used to execute swap
    /// @param amountIn amount if tokens In
    /// @param amountOutMin minimum tokens to receive
    /// @param path Sell path.
    /// @param referee address of referee for msg.sender, 0x adress if none
    /// @return amounts
    function swapExactTokensForTokens(
        address fork,
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address referee
    ) external whenNotPaused isValidFork(fork) isValidReferee(referee) returns (uint256[] memory amounts) {
        referee = _getReferee(referee);
        (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            amountIn,
            referee,
            false
        );
        amounts = _getAmountsOut(fork, swapAmount, path);
        require(amounts[amounts.length - 1] >= amountOutMin, "FloozRouter: INSUFFICIENT_OUTPUT_AMOUNT");
        TransferHelper.safeTransferFrom(path[0], msg.sender, _pairFor(fork, path[0], path[1]), swapAmount);
        _swap(fork, amounts, path, msg.sender);

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(path[0], path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param fork fork used to execute swap
    /// @param amountIn amount if tokens In
    /// @param amountOutMin minimum tokens to receive
    /// @param path Sell path.
    /// @param referee address of referee for msg.sender, 0x adress if none
    /// @return amounts
    function swapExactTokensForETH(
        address fork,
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address referee
    ) external whenNotPaused isValidFork(fork) isValidReferee(referee) returns (uint256[] memory amounts) {
        require(path[path.length - 1] == WETH, "FloozRouter: INVALID_PATH");
        referee = _getReferee(referee);
        amounts = _getAmountsOut(fork, amountIn, path);
        (uint256 amountWithdraw, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            amounts[amounts.length - 1],
            referee,
            false
        );
        require(amountWithdraw >= amountOutMin, "FloozRouter: INSUFFICIENT_OUTPUT_AMOUNT");
        TransferHelper.safeTransferFrom(path[0], msg.sender, _pairFor(fork, path[0], path[1]), amounts[0]);
        _swap(fork, amounts, path, address(this));
        IWETH(WETH).withdraw(amounts[amounts.length - 1]);
        TransferHelper.safeTransferETH(msg.sender, amountWithdraw);

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(address(0), path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param fork fork used to execute swap
    /// @param amountOut expected amount of tokens out
    /// @param path Sell path.
    /// @param referee address of referee for msg.sender, 0x adress if none
    /// @return amounts
    function swapETHForExactTokens(
        address fork,
        uint256 amountOut,
        address[] calldata path,
        address referee
    ) external payable whenNotPaused isValidFork(fork) isValidReferee(referee) returns (uint256[] memory amounts) {
        require(path[0] == WETH, "FloozRouter: INVALID_PATH");
        amounts = _getAmountsIn(fork, amountOut, path);
        (, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(amounts[0], referee, true);
        require(amounts[0].add(feeAmount).add(referralReward) <= msg.value, "FloozRouter: EXCESSIVE_INPUT_AMOUNT");

        IWETH(WETH).deposit{value: amounts[0]}();
        assert(IWETH(WETH).transfer(_pairFor(fork, path[0], path[1]), amounts[0]));
        _swap(fork, amounts, path, msg.sender);

        // refund dust eth, if any
        if (msg.value > amounts[0].add(feeAmount).add(referralReward))
            TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0].add(feeAmount).add(referralReward));

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(address(0), path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param fork fork used to execute swap
    /// @param amountIn amount if tokens In
    /// @param amountOutMin minimum tokens to receive
    /// @param path Sell path.
    /// @param referee address of referee for msg.sender, 0x adress if none
    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        address fork,
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address referee
    ) external whenNotPaused isValidFork(fork) isValidReferee(referee) {
        referee = _getReferee(referee);
        (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            amountIn,
            referee,
            false
        );
        TransferHelper.safeTransferFrom(path[0], msg.sender, _pairFor(fork, path[0], path[1]), swapAmount);
        uint256 balanceBefore = IERC20(path[path.length - 1]).balanceOf(msg.sender);
        _swapSupportingFeeOnTransferTokens(fork, path, msg.sender);
        require(
            IERC20(path[path.length - 1]).balanceOf(msg.sender).sub(balanceBefore) >= amountOutMin,
            "FloozRouter: INSUFFICIENT_OUTPUT_AMOUNT"
        );

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(path[0], path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param fork fork used to execute swap
    /// @param amountOut expected tokens to receive
    /// @param amountInMax maximum tokens to send
    /// @param path Sell path.
    /// @param referee address of referee for msg.sender, 0x adress if none
    /// @return amounts
    function swapTokensForExactTokens(
        address fork,
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path,
        address referee
    ) external whenNotPaused isValidFork(fork) isValidReferee(referee) returns (uint256[] memory amounts) {
        referee = _getReferee(referee);
        amounts = _getAmountsIn(fork, amountOut, path);
        (, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(amounts[0], referee, true);

        require(amounts[0].add(feeAmount).add(referralReward) <= amountInMax, "FloozRouter: EXCESSIVE_INPUT_AMOUNT");
        TransferHelper.safeTransferFrom(path[0], msg.sender, _pairFor(fork, path[0], path[1]), amounts[0]);
        _swap(fork, amounts, path, msg.sender);

        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(path[0], path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param fork fork used to execute swap
    /// @param amountOut expected tokens to receive
    /// @param amountInMax maximum tokens to send
    /// @param path Sell path.
    /// @param referee address of referee for msg.sender, 0x adress if none
    /// @return amounts
    function swapTokensForExactETH(
        address fork,
        uint256 amountOut,
        uint256 amountInMax,
        address[] calldata path,
        address referee
    ) external whenNotPaused isValidFork(fork) isValidReferee(referee) returns (uint256[] memory amounts) {
        require(path[path.length - 1] == WETH, "FloozRouter: INVALID_PATH");
        referee = _getReferee(referee);

        (, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(amountOut, referee, true);

        amounts = _getAmountsIn(fork, amountOut.add(feeAmount).add(referralReward), path);
        require(amounts[0].add(feeAmount).add(referralReward) <= amountInMax, "FloozRouter: EXCESSIVE_INPUT_AMOUNT");
        TransferHelper.safeTransferFrom(path[0], msg.sender, _pairFor(fork, path[0], path[1]), amounts[0]);
        _swap(fork, amounts, path, address(this));
        IWETH(WETH).withdraw(amounts[amounts.length - 1]);

        TransferHelper.safeTransferETH(msg.sender, amountOut);
        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(address(0), path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev execute swap directly on Uniswap/Pancake/...
    /// @param fork fork used to execute swap
    /// @param amountOutMin minimum expected tokens to receive
    /// @param path Sell path.
    /// @param referee address of referee for msg.sender, 0x adress if none
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        address fork,
        uint256 amountOutMin,
        address[] calldata path,
        address referee
    ) external payable whenNotPaused isValidFork(fork) isValidReferee(referee) {
        require(path[0] == WETH, "FloozRouter: INVALID_PATH");
        referee = _getReferee(referee);
        (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
            msg.value,
            referee,
            false
        );
        IWETH(WETH).deposit{value: swapAmount}();
        assert(IWETH(WETH).transfer(_pairFor(fork, path[0], path[1]), swapAmount));
        uint256 balanceBefore = IERC20(path[path.length - 1]).balanceOf(msg.sender);
        _swapSupportingFeeOnTransferTokens(fork, path, msg.sender);
        require(
            IERC20(path[path.length - 1]).balanceOf(msg.sender).sub(balanceBefore) >= amountOutMin,
            "FloozRouter: INSUFFICIENT_OUTPUT_AMOUNT"
        );
        if (feeAmount.add(referralReward) > 0)
            _withdrawFeesAndRewards(address(0), path[path.length - 1], referee, feeAmount, referralReward);
    }

    /// @dev returns the referee for a given address, if new, registers referee
    /// @param referee the address of the referee for msg.sender
    /// @return referee address from referral registry
    function _getReferee(address referee) internal returns (address) {
        address sender = msg.sender;
        if (!referralRegistry.hasUserReferee(sender) && referee != address(0)) {
            referralRegistry.createReferralAnchor(sender, referee);
        }
        return referralRegistry.getUserReferee(sender);
    }

    // **** SWAP ****
    // requires the initial amount to have already been sent to the first pair
    function _swap(
        address fork,
        uint256[] memory amounts,
        address[] memory path,
        address _to
    ) internal {
        for (uint256 i; i < path.length - 1; i++) {
            (address input, address output) = (path[i], path[i + 1]);
            (address token0, ) = PancakeLibrary.sortTokens(input, output);
            uint256 amountOut = amounts[i + 1];
            (uint256 amount0Out, uint256 amount1Out) = input == token0
                ? (uint256(0), amountOut)
                : (amountOut, uint256(0));
            address to = i < path.length - 2 ? _pairFor(fork, output, path[i + 2]) : _to;
            IPancakePair(_pairFor(fork, input, output)).swap(amount0Out, amount1Out, to, new bytes(0));
        }
    }

    // **** SWAP (supporting fee-on-transfer tokens) ****
    // requires the initial amount to have already been sent to the first pair
    function _swapSupportingFeeOnTransferTokens(
        address fork,
        address[] memory path,
        address _to
    ) internal {
        for (uint256 i; i < path.length - 1; i++) {
            (address input, address output) = (path[i], path[i + 1]);
            (address token0, ) = PancakeLibrary.sortTokens(input, output);
            IPancakePair pair = IPancakePair(_pairFor(fork, input, output));
            uint256 amountInput;
            uint256 amountOutput;
            {
                // scope to avoid stack too deep errors
                (uint256 reserve0, uint256 reserve1, ) = pair.getReserves();
                (uint256 reserveInput, uint256 reserveOutput) = input == token0
                    ? (reserve0, reserve1)
                    : (reserve1, reserve0);
                amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
                amountOutput = _getAmountOut(amountInput, reserveInput, reserveOutput);
            }
            (uint256 amount0Out, uint256 amount1Out) = input == token0
                ? (uint256(0), amountOutput)
                : (amountOutput, uint256(0));
            address to = i < path.length - 2 ? _pairFor(fork, output, path[i + 2]) : _to;
            pair.swap(amount0Out, amount1Out, to, new bytes(0));
        }
    }

    /// @dev Executes a swap on 0x API
    /// @param data calldata expected by data field on 0x API (https://0x.org/docs/api#response-1)
    /// @param tokenOut the address of currency to sell – 0x address for ETH
    /// @param tokenIn the address of currency to buy – 0x address for ETH
    /// @param referee address of referee for msg.sender, 0x adress if none
    function executeZeroExSwap(
        bytes calldata data,
        address tokenOut,
        address tokenIn,
        address referee
    ) external payable nonReentrant whenNotPaused isValidReferee(referee) {
        referee = _getReferee(referee);
        bytes4 selector = data.readBytes4(0);
        address impl = IZerox(zeroEx).getFunctionImplementation(selector);
        require(impl != address(0), "FloozRouter: NO_IMPLEMENTATION");

        bool isAboveThreshold = userAboveBalanceThreshold(msg.sender);
        // skip fees & rewards for god mode users
        if (isAboveThreshold) {
            (bool success, ) = impl.delegatecall(data);
            require(success, "FloozRouter: REVERTED");
        } else {
            // if ETH in execute trade as router & distribute funds & fees
            if (msg.value > 0) {
                (uint256 swapAmount, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
                    msg.value,
                    referee,
                    false
                );
                (bool success, ) = impl.call{value: swapAmount}(data);
                require(success, "FloozRouter: REVERTED");
                TransferHelper.safeTransfer(tokenIn, msg.sender, IERC20(tokenIn).balanceOf(address(this)));
                _withdrawFeesAndRewards(address(0), tokenIn, referee, feeAmount, referralReward);
            } else {
                uint256 balanceBefore = IERC20(tokenOut).balanceOf(msg.sender);
                (bool success, ) = impl.delegatecall(data);
                require(success, "FloozRouter: REVERTED");
                uint256 balanceAfter = IERC20(tokenOut).balanceOf(msg.sender);
                require(balanceBefore > balanceAfter, "INVALID_TOKEN");
                (, uint256 feeAmount, uint256 referralReward) = _calculateFeesAndRewards(
                    balanceBefore.sub(balanceAfter),
                    referee,
                    true
                );
                _withdrawFeesAndRewards(tokenOut, tokenIn, referee, feeAmount, referralReward);
            }
        }
    }

    /// @dev calculates swap, fee & reward amounts
    /// @param amount total amount of tokens
    /// @param referee the address of the referee for msg.sender
    function _calculateFeesAndRewards(
        uint256 amount,
        address referee,
        bool additiveFee
    )
        internal
        view
        returns (
            uint256 swapAmount,
            uint256 feeAmount,
            uint256 referralReward
        )
    {
        // no fees for users above threshold
        if (userAboveBalanceThreshold(msg.sender)) {
            swapAmount = amount;
        } else {
            if (additiveFee) {
                swapAmount = amount;
                feeAmount = swapAmount.mul(FEE_DENOMINATOR).div(FEE_DENOMINATOR.sub(swapFee)).sub(amount);
            } else {
                feeAmount = amount.mul(swapFee).div(FEE_DENOMINATOR);
                swapAmount = amount.sub(feeAmount);
            }

            // calculate referral rates, if referee is not 0x
            if (referee != address(0) && referralsActivated) {
                uint16 referralRate = customReferralRewardRate[referee] > 0
                    ? customReferralRewardRate[referee]
                    : referralRewardRate;
                referralReward = feeAmount.mul(referralRate).div(FEE_DENOMINATOR);
                feeAmount = feeAmount.sub(referralReward);
            } else {
                referralReward = 0;
            }
        }
    }

    /// @dev lets the admin update an Uniswap style fork
    function updateFork(
        address _factory,
        bytes calldata _initCode,
        bool _activated
    ) external onlyOwner {
        forkActivated[_factory] = _activated;
        forkInitCode[_factory] = _initCode;
        emit ForkUpdated(_factory);
    }

    /// @dev returns if a users is above the SYA threshold and can swap without fees
    function userAboveBalanceThreshold(address _account) public view returns (bool) {
        return saveYourAssetsToken.balanceOf(_account) >= balanceThreshold;
    }

    /// @dev returns the fee nominator for a given user
    function getUserFee(address user) public view returns (uint256) {
        saveYourAssetsToken.balanceOf(user) >= balanceThreshold ? 0 : swapFee;
    }

    /// @dev lets the admin update the swapFee nominator
    function updateSwapFee(uint16 newSwapFee) external onlyOwner {
        swapFee = newSwapFee;
        emit SwapFeeUpdated(newSwapFee);
    }

    /// @dev lets the admin update the referral reward rate
    function updateReferralRewardRate(uint16 newReferralRewardRate) external onlyOwner {
        require(newReferralRewardRate <= FEE_DENOMINATOR, "FloozRouter: INVALID_RATE");
        referralRewardRate = newReferralRewardRate;
        emit ReferralRewardRateUpdated(newReferralRewardRate);
    }

    /// @dev lets the admin update which address receives the protocol fees
    function updateFeeReceiver(address payable newFeeReceiver) external onlyOwner {
        feeReceiver = newFeeReceiver;
        emit FeeReceiverUpdated(newFeeReceiver);
    }

    /// @dev lets the admin update the SYA balance threshold, which activates feeless trading for users
    function updateBalanceThreshold(uint256 newBalanceThreshold) external onlyOwner {
        balanceThreshold = newBalanceThreshold;
        emit BalanceThresholdUpdated(balanceThreshold);
    }

    /// @dev lets the admin update the status of the referral system
    function updateReferralsActivated(bool newReferralsActivated) external onlyOwner {
        referralsActivated = newReferralsActivated;
        emit ReferralsActivatedUpdated(newReferralsActivated);
    }

    /// @dev lets the admin set a new referral registry
    function updateReferralRegistry(address newReferralRegistry) external onlyOwner {
        referralRegistry = IReferralRegistry(newReferralRegistry);
        emit ReferralRegistryUpdated(newReferralRegistry);
    }

    /// @dev lets the admin set a custom referral rate
    function updateCustomReferralRewardRate(address account, uint16 referralRate) external onlyOwner returns (uint256) {
        require(referralRate <= FEE_DENOMINATOR, "FloozRouter: INVALID_RATE");
        customReferralRewardRate[account] = referralRate;
        emit CustomReferralRewardRateUpdated(account, referralRate);
    }

    /// @dev returns the referee for a given user – 0x address if none
    function getUserReferee(address user) external view returns (address) {
        return referralRegistry.getUserReferee(user);
    }

    /// @dev returns if the given user has been referred or not
    function hasUserReferee(address user) external view returns (bool) {
        return referralRegistry.hasUserReferee(user);
    }

    /// @dev lets the admin withdraw ETH from the contract.
    function withdrawETH(address payable to, uint256 amount) external onlyOwner {
        TransferHelper.safeTransferETH(to, amount);
    }

    /// @dev lets the admin withdraw ERC20s from the contract.
    function withdrawERC20Token(
        address token,
        address to,
        uint256 amount
    ) external onlyOwner {
        TransferHelper.safeTransfer(token, to, amount);
    }

    /// @dev distributes fees & referral rewards to users
    function _withdrawFeesAndRewards(
        address tokenReward,
        address tokenOut,
        address referee,
        uint256 feeAmount,
        uint256 referralReward
    ) internal {
        if (tokenReward == address(0)) {
            TransferHelper.safeTransferETH(feeReceiver, feeAmount);
            if (referralReward > 0) {
                TransferHelper.safeTransferETH(referee, referralReward);
                emit ReferralRewardPaid(msg.sender, referee, tokenOut, tokenReward, referralReward);
            }
        } else {
            TransferHelper.safeTransferFrom(tokenReward, msg.sender, feeReceiver, feeAmount);
            if (referralReward > 0) {
                TransferHelper.safeTransferFrom(tokenReward, msg.sender, referee, referralReward);
                emit ReferralRewardPaid(msg.sender, referee, tokenOut, tokenReward, referralReward);
            }
        }
    }

    /// @dev given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function _getAmountOut(
        uint256 amountIn,
        uint256 reserveIn,
        uint256 reserveOut
    ) internal pure returns (uint256 amountOut) {
        require(amountIn > 0, "FloozRouter: INSUFFICIENT_INPUT_AMOUNT");
        require(reserveIn > 0 && reserveOut > 0, "FloozRouter: INSUFFICIENT_LIQUIDITY");
        uint256 amountInWithFee = amountIn.mul((9980));
        uint256 numerator = amountInWithFee.mul(reserveOut);
        uint256 denominator = reserveIn.mul(10000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    /// @dev given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function _getAmountIn(
        uint256 amountOut,
        uint256 reserveIn,
        uint256 reserveOut
    ) internal pure returns (uint256 amountIn) {
        require(amountOut > 0, "FloozRouter: INSUFFICIENT_OUTPUT_AMOUNT");
        require(reserveIn > 0 && reserveOut > 0, "FloozRouter: INSUFFICIENT_LIQUIDITY");
        uint256 numerator = reserveIn.mul(amountOut).mul(10000);
        uint256 denominator = reserveOut.sub(amountOut).mul(9980);
        amountIn = (numerator / denominator).add(1);
    }

    /// @dev performs chained getAmountOut calculations on any number of pairs
    function _getAmountsOut(
        address fork,
        uint256 amountIn,
        address[] memory path
    ) internal view returns (uint256[] memory amounts) {
        require(path.length >= 2, "FloozRouter: INVALID_PATH");
        amounts = new uint256[](path.length);
        amounts[0] = amountIn;
        for (uint256 i; i < path.length - 1; i++) {
            (uint256 reserveIn, uint256 reserveOut) = _getReserves(fork, path[i], path[i + 1]);
            amounts[i + 1] = _getAmountOut(amounts[i], reserveIn, reserveOut);
        }
    }

    /// @dev performs chained getAmountIn calculations on any number of pairs
    function _getAmountsIn(
        address factory,
        uint256 amountOut,
        address[] memory path
    ) internal view returns (uint256[] memory amounts) {
        require(path.length >= 2, "FloozRouter: INVALID_PATH");
        amounts = new uint256[](path.length);
        amounts[amounts.length - 1] = amountOut;
        for (uint256 i = path.length - 1; i > 0; i--) {
            (uint256 reserveIn, uint256 reserveOut) = _getReserves(factory, path[i - 1], path[i]);
            amounts[i - 1] = _getAmountIn(amounts[i], reserveIn, reserveOut);
        }
    }

    /// @dev fetches and sorts the reserves for a pair
    function _getReserves(
        address factory,
        address tokenA,
        address tokenB
    ) internal view returns (uint256 reserveA, uint256 reserveB) {
        (address token0, ) = PancakeLibrary.sortTokens(tokenA, tokenB);
        (uint256 reserve0, uint256 reserve1, ) = IPancakePair(_pairFor(factory, tokenA, tokenB)).getReserves();
        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
    }

    /// @dev calculates the CREATE2 address for a pair without making any external calls
    function _pairFor(
        address factory,
        address tokenA,
        address tokenB
    ) internal view returns (address pair) {
        (address token0, address token1) = PancakeLibrary.sortTokens(tokenA, tokenB);
        pair = address(
            uint256(
                keccak256(
                    abi.encodePacked(
                        hex"ff",
                        factory,
                        keccak256(abi.encodePacked(token0, token1)),
                        forkInitCode[factory] // init code hash
                    )
                )
            )
        );
    }

    /// @dev lets the admin pause this contract
    function pause() external onlyOwner {
        _pause();
    }

    /// @dev lets the admin unpause this contract
    function unpause() external onlyOwner {
        _unpause();
    }

    /// @dev allows to receive ETH on the contract
    receive() external payable {}

    modifier isValidFork(address factory) {
        require(forkActivated[factory], "FloozRouter: INVALID_FACTORY");
        _;
    }

    modifier isValidReferee(address referee) {
        require(msg.sender != referee, "FloozRouter: SELF_REFERRAL");
        _;
    }
}

File 13 of 21 : LibBytesV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Copyright 2020 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.6.5;

import "./errors/LibBytesRichErrorsV06.sol";
import "./errors/LibRichErrorsV06.sol";


library LibBytesV06 {

    using LibBytesV06 for bytes;

    /// @dev Gets the memory address for a byte array.
    /// @param input Byte array to lookup.
    /// @return memoryAddress Memory address of byte array. This
    ///         points to the header of the byte array which contains
    ///         the length.
    function rawAddress(bytes memory input)
        internal
        pure
        returns (uint256 memoryAddress)
    {
        assembly {
            memoryAddress := input
        }
        return memoryAddress;
    }

    /// @dev Gets the memory address for the contents of a byte array.
    /// @param input Byte array to lookup.
    /// @return memoryAddress Memory address of the contents of the byte array.
    function contentAddress(bytes memory input)
        internal
        pure
        returns (uint256 memoryAddress)
    {
        assembly {
            memoryAddress := add(input, 32)
        }
        return memoryAddress;
    }

    /// @dev Copies `length` bytes from memory location `source` to `dest`.
    /// @param dest memory address to copy bytes to.
    /// @param source memory address to copy bytes from.
    /// @param length number of bytes to copy.
    function memCopy(
        uint256 dest,
        uint256 source,
        uint256 length
    )
        internal
        pure
    {
        if (length < 32) {
            // Handle a partial word by reading destination and masking
            // off the bits we are interested in.
            // This correctly handles overlap, zero lengths and source == dest
            assembly {
                let mask := sub(exp(256, sub(32, length)), 1)
                let s := and(mload(source), not(mask))
                let d := and(mload(dest), mask)
                mstore(dest, or(s, d))
            }
        } else {
            // Skip the O(length) loop when source == dest.
            if (source == dest) {
                return;
            }

            // For large copies we copy whole words at a time. The final
            // word is aligned to the end of the range (instead of after the
            // previous) to handle partial words. So a copy will look like this:
            //
            //  ####
            //      ####
            //          ####
            //            ####
            //
            // We handle overlap in the source and destination range by
            // changing the copying direction. This prevents us from
            // overwriting parts of source that we still need to copy.
            //
            // This correctly handles source == dest
            //
            if (source > dest) {
                assembly {
                    // We subtract 32 from `sEnd` and `dEnd` because it
                    // is easier to compare with in the loop, and these
                    // are also the addresses we need for copying the
                    // last bytes.
                    length := sub(length, 32)
                    let sEnd := add(source, length)
                    let dEnd := add(dest, length)

                    // Remember the last 32 bytes of source
                    // This needs to be done here and not after the loop
                    // because we may have overwritten the last bytes in
                    // source already due to overlap.
                    let last := mload(sEnd)

                    // Copy whole words front to back
                    // Note: the first check is always true,
                    // this could have been a do-while loop.
                    // solhint-disable-next-line no-empty-blocks
                    for {} lt(source, sEnd) {} {
                        mstore(dest, mload(source))
                        source := add(source, 32)
                        dest := add(dest, 32)
                    }

                    // Write the last 32 bytes
                    mstore(dEnd, last)
                }
            } else {
                assembly {
                    // We subtract 32 from `sEnd` and `dEnd` because those
                    // are the starting points when copying a word at the end.
                    length := sub(length, 32)
                    let sEnd := add(source, length)
                    let dEnd := add(dest, length)

                    // Remember the first 32 bytes of source
                    // This needs to be done here and not after the loop
                    // because we may have overwritten the first bytes in
                    // source already due to overlap.
                    let first := mload(source)

                    // Copy whole words back to front
                    // We use a signed comparisson here to allow dEnd to become
                    // negative (happens when source and dest < 32). Valid
                    // addresses in local memory will never be larger than
                    // 2**255, so they can be safely re-interpreted as signed.
                    // Note: the first check is always true,
                    // this could have been a do-while loop.
                    // solhint-disable-next-line no-empty-blocks
                    for {} slt(dest, dEnd) {} {
                        mstore(dEnd, mload(sEnd))
                        sEnd := sub(sEnd, 32)
                        dEnd := sub(dEnd, 32)
                    }

                    // Write the first 32 bytes
                    mstore(dest, first)
                }
            }
        }
    }

    /// @dev Returns a slices from a byte array.
    /// @param b The byte array to take a slice from.
    /// @param from The starting index for the slice (inclusive).
    /// @param to The final index for the slice (exclusive).
    /// @return result The slice containing bytes at indices [from, to)
    function slice(
        bytes memory b,
        uint256 from,
        uint256 to
    )
        internal
        pure
        returns (bytes memory result)
    {
        // Ensure that the from and to positions are valid positions for a slice within
        // the byte array that is being used.
        if (from > to) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.FromLessThanOrEqualsToRequired,
                from,
                to
            ));
        }
        if (to > b.length) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.ToLessThanOrEqualsLengthRequired,
                to,
                b.length
            ));
        }

        // Create a new bytes structure and copy contents
        result = new bytes(to - from);
        memCopy(
            result.contentAddress(),
            b.contentAddress() + from,
            result.length
        );
        return result;
    }

    /// @dev Returns a slice from a byte array without preserving the input.
    ///      When `from == 0`, the original array will match the slice.
    ///      In other cases its state will be corrupted.
    /// @param b The byte array to take a slice from. Will be destroyed in the process.
    /// @param from The starting index for the slice (inclusive).
    /// @param to The final index for the slice (exclusive).
    /// @return result The slice containing bytes at indices [from, to)
    function sliceDestructive(
        bytes memory b,
        uint256 from,
        uint256 to
    )
        internal
        pure
        returns (bytes memory result)
    {
        // Ensure that the from and to positions are valid positions for a slice within
        // the byte array that is being used.
        if (from > to) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.FromLessThanOrEqualsToRequired,
                from,
                to
            ));
        }
        if (to > b.length) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.ToLessThanOrEqualsLengthRequired,
                to,
                b.length
            ));
        }

        // Create a new bytes structure around [from, to) in-place.
        assembly {
            result := add(b, from)
            mstore(result, sub(to, from))
        }
        return result;
    }

    /// @dev Pops the last byte off of a byte array by modifying its length.
    /// @param b Byte array that will be modified.
    /// @return result The byte that was popped off.
    function popLastByte(bytes memory b)
        internal
        pure
        returns (bytes1 result)
    {
        if (b.length == 0) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.LengthGreaterThanZeroRequired,
                b.length,
                0
            ));
        }

        // Store last byte.
        result = b[b.length - 1];

        assembly {
            // Decrement length of byte array.
            let newLen := sub(mload(b), 1)
            mstore(b, newLen)
        }
        return result;
    }

    /// @dev Tests equality of two byte arrays.
    /// @param lhs First byte array to compare.
    /// @param rhs Second byte array to compare.
    /// @return equal True if arrays are the same. False otherwise.
    function equals(
        bytes memory lhs,
        bytes memory rhs
    )
        internal
        pure
        returns (bool equal)
    {
        // Keccak gas cost is 30 + numWords * 6. This is a cheap way to compare.
        // We early exit on unequal lengths, but keccak would also correctly
        // handle this.
        return lhs.length == rhs.length && keccak256(lhs) == keccak256(rhs);
    }

    /// @dev Reads an address from a position in a byte array.
    /// @param b Byte array containing an address.
    /// @param index Index in byte array of address.
    /// @return result address from byte array.
    function readAddress(
        bytes memory b,
        uint256 index
    )
        internal
        pure
        returns (address result)
    {
        if (b.length < index + 20) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsTwentyRequired,
                b.length,
                index + 20 // 20 is length of address
            ));
        }

        // Add offset to index:
        // 1. Arrays are prefixed by 32-byte length parameter (add 32 to index)
        // 2. Account for size difference between address length and 32-byte storage word (subtract 12 from index)
        index += 20;

        // Read address from array memory
        assembly {
            // 1. Add index to address of bytes array
            // 2. Load 32-byte word from memory
            // 3. Apply 20-byte mask to obtain address
            result := and(mload(add(b, index)), 0xffffffffffffffffffffffffffffffffffffffff)
        }
        return result;
    }

    /// @dev Writes an address into a specific position in a byte array.
    /// @param b Byte array to insert address into.
    /// @param index Index in byte array of address.
    /// @param input Address to put into byte array.
    function writeAddress(
        bytes memory b,
        uint256 index,
        address input
    )
        internal
        pure
    {
        if (b.length < index + 20) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsTwentyRequired,
                b.length,
                index + 20 // 20 is length of address
            ));
        }

        // Add offset to index:
        // 1. Arrays are prefixed by 32-byte length parameter (add 32 to index)
        // 2. Account for size difference between address length and 32-byte storage word (subtract 12 from index)
        index += 20;

        // Store address into array memory
        assembly {
            // The address occupies 20 bytes and mstore stores 32 bytes.
            // First fetch the 32-byte word where we'll be storing the address, then
            // apply a mask so we have only the bytes in the word that the address will not occupy.
            // Then combine these bytes with the address and store the 32 bytes back to memory with mstore.

            // 1. Add index to address of bytes array
            // 2. Load 32-byte word from memory
            // 3. Apply 12-byte mask to obtain extra bytes occupying word of memory where we'll store the address
            let neighbors := and(
                mload(add(b, index)),
                0xffffffffffffffffffffffff0000000000000000000000000000000000000000
            )

            // Make sure input address is clean.
            // (Solidity does not guarantee this)
            input := and(input, 0xffffffffffffffffffffffffffffffffffffffff)

            // Store the neighbors and address into memory
            mstore(add(b, index), xor(input, neighbors))
        }
    }

    /// @dev Reads a bytes32 value from a position in a byte array.
    /// @param b Byte array containing a bytes32 value.
    /// @param index Index in byte array of bytes32 value.
    /// @return result bytes32 value from byte array.
    function readBytes32(
        bytes memory b,
        uint256 index
    )
        internal
        pure
        returns (bytes32 result)
    {
        if (b.length < index + 32) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsThirtyTwoRequired,
                b.length,
                index + 32
            ));
        }

        // Arrays are prefixed by a 256 bit length parameter
        index += 32;

        // Read the bytes32 from array memory
        assembly {
            result := mload(add(b, index))
        }
        return result;
    }

    /// @dev Writes a bytes32 into a specific position in a byte array.
    /// @param b Byte array to insert <input> into.
    /// @param index Index in byte array of <input>.
    /// @param input bytes32 to put into byte array.
    function writeBytes32(
        bytes memory b,
        uint256 index,
        bytes32 input
    )
        internal
        pure
    {
        if (b.length < index + 32) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsThirtyTwoRequired,
                b.length,
                index + 32
            ));
        }

        // Arrays are prefixed by a 256 bit length parameter
        index += 32;

        // Read the bytes32 from array memory
        assembly {
            mstore(add(b, index), input)
        }
    }

    /// @dev Reads a uint256 value from a position in a byte array.
    /// @param b Byte array containing a uint256 value.
    /// @param index Index in byte array of uint256 value.
    /// @return result uint256 value from byte array.
    function readUint256(
        bytes memory b,
        uint256 index
    )
        internal
        pure
        returns (uint256 result)
    {
        result = uint256(readBytes32(b, index));
        return result;
    }

    /// @dev Writes a uint256 into a specific position in a byte array.
    /// @param b Byte array to insert <input> into.
    /// @param index Index in byte array of <input>.
    /// @param input uint256 to put into byte array.
    function writeUint256(
        bytes memory b,
        uint256 index,
        uint256 input
    )
        internal
        pure
    {
        writeBytes32(b, index, bytes32(input));
    }

    /// @dev Reads an unpadded bytes4 value from a position in a byte array.
    /// @param b Byte array containing a bytes4 value.
    /// @param index Index in byte array of bytes4 value.
    /// @return result bytes4 value from byte array.
    function readBytes4(
        bytes memory b,
        uint256 index
    )
        internal
        pure
        returns (bytes4 result)
    {
        if (b.length < index + 4) {
            LibRichErrorsV06.rrevert(LibBytesRichErrorsV06.InvalidByteOperationError(
                LibBytesRichErrorsV06.InvalidByteOperationErrorCodes.LengthGreaterThanOrEqualsFourRequired,
                b.length,
                index + 4
            ));
        }

        // Arrays are prefixed by a 32 byte length field
        index += 32;

        // Read the bytes4 from array memory
        assembly {
            result := mload(add(b, index))
            // Solidity does not require us to clean the trailing bytes.
            // We do it anyway
            result := and(result, 0xFFFFFFFF00000000000000000000000000000000000000000000000000000000)
        }
        return result;
    }

    /// @dev Writes a new length to a byte array.
    ///      Decreasing length will lead to removing the corresponding lower order bytes from the byte array.
    ///      Increasing length may lead to appending adjacent in-memory bytes to the end of the byte array.
    /// @param b Bytes array to write new length to.
    /// @param length New length of byte array.
    function writeLength(bytes memory b, uint256 length)
        internal
        pure
    {
        assembly {
            mstore(b, length)
        }
    }
}

File 14 of 21 : 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 15 of 21 : PancakeLibrary.sol
pragma solidity =0.6.6;

import "@openzeppelin/contracts/math/SafeMath.sol";

interface IPancakePair {
    event Approval(address indexed owner, address indexed spender, uint256 value);
    event Transfer(address indexed from, address indexed to, uint256 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 (uint256);

    function balanceOf(address owner) external view returns (uint256);

    function allowance(address owner, address spender) external view returns (uint256);

    function approve(address spender, uint256 value) external returns (bool);

    function transfer(address to, uint256 value) external returns (bool);

    function transferFrom(
        address from,
        address to,
        uint256 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 (uint256);

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

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

    function MINIMUM_LIQUIDITY() external pure returns (uint256);

    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 (uint256);

    function price1CumulativeLast() external view returns (uint256);

    function kLast() external view returns (uint256);

    function mint(address to) external returns (uint256 liquidity);

    function burn(address to) external returns (uint256 amount0, uint256 amount1);

    function swap(
        uint256 amount0Out,
        uint256 amount1Out,
        address to,
        bytes calldata data
    ) external;

    function skim(address to) external;

    function sync() external;

    function initialize(address, address) external;
}

library PancakeLibrary {
    using SafeMath for uint256;

    // 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, "PancakeLibrary: IDENTICAL_ADDRESSES");
        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), "PancakeLibrary: ZERO_ADDRESS");
    }

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

File 16 of 21 : IReferralRegistry.sol
pragma solidity >=0.5.0;

interface IReferralRegistry {
    function getUserReferee(address _user) external view returns (address);

    function hasUserReferee(address _user) external view returns (bool);

    function createReferralAnchor(address _user, address _referee) external;
}

File 17 of 21 : IZerox.sol
pragma solidity ^0.6.5;

interface IZerox {
    function getFunctionImplementation(bytes4 selector) external returns (address payable);
}

File 18 of 21 : LibBytesRichErrorsV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Copyright 2020 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.6.5;


library LibBytesRichErrorsV06 {

    enum InvalidByteOperationErrorCodes {
        FromLessThanOrEqualsToRequired,
        ToLessThanOrEqualsLengthRequired,
        LengthGreaterThanZeroRequired,
        LengthGreaterThanOrEqualsFourRequired,
        LengthGreaterThanOrEqualsTwentyRequired,
        LengthGreaterThanOrEqualsThirtyTwoRequired,
        LengthGreaterThanOrEqualsNestedBytesLengthRequired,
        DestinationLengthGreaterThanOrEqualSourceLengthRequired
    }

    // bytes4(keccak256("InvalidByteOperationError(uint8,uint256,uint256)"))
    bytes4 internal constant INVALID_BYTE_OPERATION_ERROR_SELECTOR =
        0x28006595;

    // solhint-disable func-name-mixedcase
    function InvalidByteOperationError(
        InvalidByteOperationErrorCodes errorCode,
        uint256 offset,
        uint256 required
    )
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            INVALID_BYTE_OPERATION_ERROR_SELECTOR,
            errorCode,
            offset,
            required
        );
    }
}

File 19 of 21 : LibRichErrorsV06.sol
// SPDX-License-Identifier: Apache-2.0
/*

  Copyright 2020 ZeroEx Intl.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

*/

pragma solidity ^0.6.5;


library LibRichErrorsV06 {

    // bytes4(keccak256("Error(string)"))
    bytes4 internal constant STANDARD_ERROR_SELECTOR = 0x08c379a0;

    // solhint-disable func-name-mixedcase
    /// @dev ABI encode a standard, string revert error payload.
    ///      This is the same payload that would be included by a `revert(string)`
    ///      solidity statement. It has the function signature `Error(string)`.
    /// @param message The error string.
    /// @return The ABI encoded error.
    function StandardError(string memory message)
        internal
        pure
        returns (bytes memory)
    {
        return abi.encodeWithSelector(
            STANDARD_ERROR_SELECTOR,
            bytes(message)
        );
    }
    // solhint-enable func-name-mixedcase

    /// @dev Reverts an encoded rich revert reason `errorData`.
    /// @param errorData ABI encoded error data.
    function rrevert(bytes memory errorData)
        internal
        pure
    {
        assembly {
            revert(add(errorData, 0x20), mload(errorData))
        }
    }
}

File 21 of 21 : FeeReceiverMultichain.sol
pragma solidity =0.6.6;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./libraries/TransferHelper.sol";
import "./interfaces/IWETH.sol";

contract FeeReceiverMultichain is Ownable {
    address public WETH;

    constructor(address _WETH) public {
        WETH = _WETH;
    }

    /// @dev converts WETH to ETH
    function unwrapWETH() public {
        uint256 balance = IWETH(WETH).balanceOf(address(this));
        require(balance > 0, "FeeReceiver: Nothing to unwrap");
        IWETH(WETH).withdraw(balance);
    }

    /// @dev lets the owner withdraw ETH from the contract
    function withdrawETH(address payable to, uint256 amount) external onlyOwner {
        to.transfer(amount);
    }

    /// @dev lets the owner withdraw any ERC20 Token from the contract
    function withdrawERC20Token(
        address token,
        address to,
        uint256 amount
    ) external onlyOwner {
        IERC20(token).transfer(to, amount);
    }

    /// @dev allows to receive ETH on this contract
    receive() external payable {}
}

File 22 of 21 : ReferralRegistry.sol
pragma solidity =0.6.6;

import "@openzeppelin/contracts/access/Ownable.sol";

contract ReferralRegistry is Ownable {
    event ReferralAnchorCreated(address indexed user, address indexed referee);
    event ReferralAnchorUpdated(address indexed user, address indexed referee);
    event AnchorManagerUpdated(address account, bool isManager);

    // stores addresses which are allowed to create new anchors
    mapping(address => bool) public isAnchorManager;

    // stores the address that referred a given user
    mapping(address => address) public referralAnchor;

    /// @dev create a new referral anchor on the registry
    /// @param _user address of the user
    /// @param _referee address wich referred the user
    function createReferralAnchor(address _user, address _referee) external onlyAnchorManager {
        require(referralAnchor[_user] == address(0), "ReferralRegistry: ANCHOR_EXISTS");
        referralAnchor[_user] = _referee;
        emit ReferralAnchorCreated(_user, _referee);
    }

    /// @dev allows admin to overwrite anchor
    /// @param _user address of the user
    /// @param _referee address wich referred the user
    function updateReferralAnchor(address _user, address _referee) external onlyOwner {
        referralAnchor[_user] = _referee;
        emit ReferralAnchorUpdated(_user, _referee);
    }

    /// @dev allows admin to grant/remove anchor priviliges
    /// @param _anchorManager address of the anchor manager
    /// @param _isManager add or remove privileges
    function updateAnchorManager(address _anchorManager, bool _isManager) external onlyOwner {
        isAnchorManager[_anchorManager] = _isManager;
        emit AnchorManagerUpdated(_anchorManager, _isManager);
    }

    function getUserReferee(address _user) external view returns (address) {
        return referralAnchor[_user];
    }

    function hasUserReferee(address _user) external view returns (bool) {
        return referralAnchor[_user] != address(0);
    }

    modifier onlyAnchorManager() {
        require(isAnchorManager[msg.sender], "ReferralRegistry: FORBIDDEN");
        _;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_WETH","type":"address"},{"internalType":"uint16","name":"_swapFee","type":"uint16"},{"internalType":"uint16","name":"_referralRewardRate","type":"uint16"},{"internalType":"address payable","name":"_feeReceiver","type":"address"},{"internalType":"contract IReferralRegistry","name":"_referralRegistry","type":"address"},{"internalType":"address payable","name":"_zeroEx","type":"address"},{"internalType":"address payable","name":"_oneInch","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint16","name":"referralRate","type":"uint16"}],"name":"CustomReferralRewardRateUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address payable","name":"feeReceiver","type":"address"}],"name":"FeeReceiverUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"factory","type":"address"}],"name":"ForkCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"factory","type":"address"}],"name":"ForkUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"referralRegistry","type":"address"}],"name":"ReferralRegistryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"address","name":"tokenReward","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ReferralRewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"referralRewardRate","type":"uint16"}],"name":"ReferralRewardRateUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"activated","type":"bool"}],"name":"ReferralsActivatedUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"swapFee","type":"uint16"}],"name":"SwapFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"FEE_DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"customReferralRewardRate","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"amountFrom","type":"uint256"},{"internalType":"address","name":"referee","type":"address"},{"internalType":"uint256","name":"minOut","type":"uint256"},{"internalType":"bool","name":"fee","type":"bool"}],"internalType":"struct FloozMultichainRouter.ExternalSwapData","name":"swapData","type":"tuple"}],"name":"executeOneInchSwap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"amountFrom","type":"uint256"},{"internalType":"address","name":"referee","type":"address"},{"internalType":"uint256","name":"minOut","type":"uint256"},{"internalType":"bool","name":"fee","type":"bool"}],"internalType":"struct FloozMultichainRouter.ExternalSwapData","name":"swapData","type":"tuple"}],"name":"executeZeroExSwap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"feeReceiver","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"forkActivated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"forkInitCode","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserReferee","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"hasUserReferee","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oneInch","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referralRegistry","outputs":[{"internalType":"contract IReferralRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referralRewardRate","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referralsActivated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"bytes","name":"_initCode","type":"bytes"}],"name":"registerFork","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fork","type":"address"},{"internalType":"address","name":"referee","type":"address"},{"internalType":"bool","name":"fee","type":"bool"}],"internalType":"struct FloozMultichainRouter.SwapData","name":"swapData","type":"tuple"},{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"swapETHForExactTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fork","type":"address"},{"internalType":"address","name":"referee","type":"address"},{"internalType":"bool","name":"fee","type":"bool"}],"internalType":"struct FloozMultichainRouter.SwapData","name":"swapData","type":"tuple"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"swapExactETHForTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fork","type":"address"},{"internalType":"address","name":"referee","type":"address"},{"internalType":"bool","name":"fee","type":"bool"}],"internalType":"struct FloozMultichainRouter.SwapData","name":"swapData","type":"tuple"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"swapExactETHForTokensSupportingFeeOnTransferTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fork","type":"address"},{"internalType":"address","name":"referee","type":"address"},{"internalType":"bool","name":"fee","type":"bool"}],"internalType":"struct FloozMultichainRouter.SwapData","name":"swapData","type":"tuple"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"swapExactTokensForETH","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fork","type":"address"},{"internalType":"address","name":"referee","type":"address"},{"internalType":"bool","name":"fee","type":"bool"}],"internalType":"struct FloozMultichainRouter.SwapData","name":"swapData","type":"tuple"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"swapExactTokensForETHSupportingFeeOnTransferTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fork","type":"address"},{"internalType":"address","name":"referee","type":"address"},{"internalType":"bool","name":"fee","type":"bool"}],"internalType":"struct FloozMultichainRouter.SwapData","name":"swapData","type":"tuple"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"swapExactTokensForTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fork","type":"address"},{"internalType":"address","name":"referee","type":"address"},{"internalType":"bool","name":"fee","type":"bool"}],"internalType":"struct FloozMultichainRouter.SwapData","name":"swapData","type":"tuple"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"swapExactTokensForTokensSupportingFeeOnTransferTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapFee","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fork","type":"address"},{"internalType":"address","name":"referee","type":"address"},{"internalType":"bool","name":"fee","type":"bool"}],"internalType":"struct FloozMultichainRouter.SwapData","name":"swapData","type":"tuple"},{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMax","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"swapTokensForExactETH","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"fork","type":"address"},{"internalType":"address","name":"referee","type":"address"},{"internalType":"bool","name":"fee","type":"bool"}],"internalType":"struct FloozMultichainRouter.SwapData","name":"swapData","type":"tuple"},{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMax","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"swapTokensForExactTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint16","name":"referralRate","type":"uint16"}],"name":"updateCustomReferralRewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newFeeReceiver","type":"address"}],"name":"updateFeeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"bytes","name":"_initCode","type":"bytes"},{"internalType":"bool","name":"_activated","type":"bool"}],"name":"updateFork","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newReferralRegistry","type":"address"}],"name":"updateReferralRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newReferralRewardRate","type":"uint16"}],"name":"updateReferralRewardRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"newReferralsActivated","type":"bool"}],"name":"updateReferralsActivated","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newSwapFee","type":"uint16"}],"name":"updateSwapFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawERC20Token","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"zeroEx","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60e06040523480156200001157600080fd5b50604051620060cb380380620060cb83398101604081905262000034916200015d565b6000620000496001600160e01b036200014016565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506000805460ff60a01b1916905560018055606096871b6001600160601b0319908116608052600280546003805461ffff1990921661ffff9a8b161762010000600160b01b031916620100006001600160a01b03988916021790925593891b821660a0529190971b90961660c052600160b01b61ffff60a01b19909116600160a01b9490951693909302939093176001600160a01b03191692169190911760ff60b01b19161790556200021b565b3390565b805161ffff811681146200015757600080fd5b92915050565b600080600080600080600060e0888a03121562000178578283fd5b8751620001858162000202565b9650620001968960208a0162000144565b9550620001a78960408a0162000144565b94506060880151620001b98162000202565b6080890151909450620001cc8162000202565b60a0890151909350620001df8162000202565b60c0890151909250620001f28162000202565b8091505092959891949750929550565b6001600160a01b03811681146200021857600080fd5b50565b60805160601c60a05160601c60c05160601c615df3620002d8600039806106f65280610e3f5280610ee05280610fe25280611181528061121d5250806115795280611775528061181552806119515280611ae15280611b7d52806126975250806107c85280610900528061098d5280611d4b5280611eae5280611f3b528061220052806122a6528061231f52806129845280612b6352806130a6528061385152806139a35280613a425280613cc75280613e895250615df36000f3fe60806040526004361061024a5760003560e01c80638456cb5911610139578063c69bebe4116100b6578063e96b2f501161007a578063e96b2f501461063f578063ea043e271461065f578063f01e063a1461067f578063f2fde38b1461069f578063fe4ad446146106bf578063fe7d4f34146106d457610251565b8063c69bebe4146105aa578063caa9b5cb146105ca578063d113efc4146105ea578063d73792a91461060a578063e5ae0c321461061f57610251565b8063a7a94fde116100fd578063a7a94fde14610520578063ad5c464814610540578063b3f0067414610555578063bdf771081461056a578063c00a31591461058a57610251565b80638456cb591461049657806388b28687146104ab5780638d18300a146104cb5780638da5cb5b146104eb578063927e897a1461050057610251565b80634ba4ecb1116101c757806357d1b31b1161018b57806357d1b31b146103ff5780635c975abb1461041f578063692247c314610434578063715018a6146104615780637cde0c741461047657610251565b80634ba4ecb1146103735780634e627e62146103865780634fb5df081461039b57806352ab413b146103c857806354cf2aeb146103dd57610251565b80633149f47f1161020e5780633149f47f146103055780633b74651c146103185780633f4ba83a1461032b5780633f9f5ecb146103405780634782f7791461035357610251565b8063045c08d514610256578063279c186814610281578063279f3291146102a15780632def48b1146102c35780632f912005146102e557610251565b3661025157005b600080fd5b34801561026257600080fd5b5061026b6106f4565b60405161027891906155f0565b60405180910390f35b61029461028f366004615383565b610718565b6040516102789190615685565b3480156102ad57600080fd5b506102b6610b3f565b60405161027891906156c9565b3480156102cf57600080fd5b506102e36102de366004615173565b610b4f565b005b3480156102f157600080fd5b506102b6610300366004615173565b610beb565b6102e3610313366004615343565b610c00565b6102e3610326366004615343565b6113d7565b34801561033757600080fd5b506102e3611c5b565b61029461034e366004615383565b611ca4565b34801561035f57600080fd5b506102e361036e3660046151ab565b61210e565b6102e3610381366004615383565b61215b565b34801561039257600080fd5b5061026b6125e5565b3480156103a757600080fd5b506103bb6103b6366004615173565b6125fa565b60405161027891906156d4565b3480156103d457600080fd5b5061026b612695565b3480156103e957600080fd5b506103f26126b9565b6040516102789190615cbf565b34801561040b57600080fd5b506102e361041a3660046151d6565b6126c3565b34801561042b57600080fd5b506102b6612712565b34801561044057600080fd5b5061045461044f3660046152cd565b612723565b6040516102789190615cce565b34801561046d57600080fd5b506102e36127ef565b34801561048257600080fd5b506103f2610491366004615173565b612878565b3480156104a257600080fd5b506102e361288e565b3480156104b757600080fd5b506102946104c63660046153db565b6128d5565b3480156104d757600080fd5b506102946104e63660046153db565b612c3b565b3480156104f757600080fd5b5061026b612e44565b34801561050c57600080fd5b506102b661051b366004615173565b612e53565b34801561052c57600080fd5b5061029461053b3660046153db565b612ee0565b34801561054c57600080fd5b5061026b6130a4565b34801561056157600080fd5b5061026b6130c8565b34801561057657600080fd5b506102e3610585366004615216565b6130d7565b34801561059657600080fd5b506102e36105a5366004615268565b6131c4565b3480156105b657600080fd5b506102e36105c5366004615173565b61327a565b3480156105d657600080fd5b506102e36105e5366004615495565b613304565b3480156105f657600080fd5b5061026b610605366004615173565b613384565b34801561061657600080fd5b5061045461340b565b34801561062b57600080fd5b506102e361063a366004615495565b613411565b34801561064b57600080fd5b506102e361065a36600461530b565b6134c0565b34801561066b57600080fd5b506102e361067a3660046153db565b613546565b34801561068b57600080fd5b506102e361069a3660046153db565b6137a4565b3480156106ab57600080fd5b506102e36106ba366004615173565b613b47565b3480156106cb57600080fd5b506103f2613c07565b3480156106e057600080fd5b506102946106ef3660046153db565b613c18565b7f000000000000000000000000000000000000000000000000000000000000000081565b6060610722612712565b156107485760405162461bcd60e51b815260040161073f906159a6565b60405180910390fd5b6107556020860186615173565b6001600160a01b03811660009081526005602052604090205460ff1661078d5760405162461bcd60e51b815260040161073f90615aff565b61079d6040870160208801615173565b336001600160a01b03821614156107c65760405162461bcd60e51b815260040161073f906158be565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316858560008181106107fd57fe5b90506020020160208101906108129190615173565b6001600160a01b0316146108385760405162461bcd60e51b815260040161073f906159d0565b600061085261084d60408a0160208b01615173565b613f53565b90506000808061087461086b60608d0160408e0161530b565b348660006140ed565b919450925090506108c561088b60208d018d615173565b848b8b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061424092505050565b965089876001895103815181106108d857fe5b602002602001015110156108fe5760405162461bcd60e51b815260040161073f90615842565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db08860008151811061093a57fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b15801561096d57600080fd5b505af1158015610981573d6000803e3d6000fd5b50506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016925063a9059cbb9150610a1190506109c860208f018f615173565b8c8c60008181106109d557fe5b90506020020160208101906109ea9190615173565b8d8d60018181106109f757fe5b9050602002016020810190610a0c9190615173565b614356565b89600081518110610a1e57fe5b60200260200101516040518363ffffffff1660e01b8152600401610a43929190615652565b602060405180830381600087803b158015610a5d57600080fd5b505af1158015610a71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a959190615327565b610a9b57fe5b610ae7610aab60208d018d615173565b888b8b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503392506143db915050565b6000610af9838363ffffffff61455c16565b1115610b3157610b3160008a8a6000198101818110610b1457fe5b9050602002016020810190610b299190615173565b868585614581565b505050505050949350505050565b600354600160b01b900460ff1681565b610b5761467c565b6001600160a01b0316610b68612e44565b6001600160a01b031614610b8e5760405162461bcd60e51b815260040161073f90615a87565b6002805462010000600160b01b031916620100006001600160a01b038416021790556040517f9d4414af8d61d821c1ad25f0aadfa28aa386c452716a31fc1f7fdbd9b9d364dc90610be09083906155f0565b60405180910390a150565b60056020526000908152604090205460ff1681565b60026001541415610c235760405162461bcd60e51b815260040161073f90615c56565b6002600155610c30612712565b15610c4d5760405162461bcd60e51b815260040161073f906159a6565b610c5d60a0820160808301615173565b336001600160a01b0382161415610c865760405162461bcd60e51b815260040161073f906158be565b6000610c9b61084d60a0850160808601615173565b9050600080610cb06060860160408701615173565b6001600160a01b03161415610cc757503331610d55565b610cd76060850160408601615173565b6001600160a01b03166370a08231336040518263ffffffff1660e01b8152600401610d0291906155f0565b60206040518083038186803b158015610d1a57600080fd5b505afa158015610d2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5291906154b7565b90505b610d6560e0850160c0860161530b565b610f82576000610d7b6040860160208701615173565b6001600160a01b031614610ed457610d996040850160208601615173565b6001600160a01b03166323b872dd333087606001356040518463ffffffff1660e01b8152600401610dcc93929190615604565b602060405180830381600087803b158015610de657600080fd5b505af1158015610dfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1e9190615327565b50610e2f6040850160208601615173565b6001600160a01b031663095ea7b37f000000000000000000000000000000000000000000000000000000000000000086606001356040518363ffffffff1660e01b8152600401610e80929190615652565b602060405180830381600087803b158015610e9a57600080fd5b505af1158015610eae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed29190615327565b505b60006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001634610f0b8780615d04565b604051610f19929190615522565b60006040518083038185875af1925050503d8060008114610f56576040519150601f19603f3d011682016040523d82523d6000602084013e610f5b565b606091505b5050905080610f7c5760405162461bcd60e51b815260040161073f90615ba0565b506113cd565b600034118015610faa57506000610f9f6040860160208701615173565b6001600160a01b0316145b156110a45760008080610fcf610fc660e0890160c08a0161530b565b348760006140ed565b9194509250905060006001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168461100d8a80615d04565b60405161101b929190615522565b60006040518083038185875af1925050503d8060008114611058576040519150601f19603f3d011682016040523d82523d6000602084013e61105d565b606091505b505090508061107e5760405162461bcd60e51b815260040161073f90615ba0565b61109b600061109360608b0160408c01615173565b888686614581565b505050506112e0565b600080806110c86110bb60e0890160c08a0161530b565b88606001358760006140ed565b919450925090506110df6040880160208901615173565b6001600160a01b03166323b872dd3330866040518463ffffffff1660e01b815260040161110e93929190615604565b602060405180830381600087803b15801561112857600080fd5b505af115801561113c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111609190615327565b506111716040880160208901615173565b6001600160a01b031663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000856040518363ffffffff1660e01b81526004016111be929190615652565b602060405180830381600087803b1580156111d857600080fd5b505af11580156111ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112109190615327565b5060006001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166112478980615d04565b604051611255929190615522565b6000604051808303816000865af19150503d8060008114611292576040519150601f19603f3d011682016040523d82523d6000602084013e611297565b606091505b50509050806112b85760405162461bcd60e51b815260040161073f90615ba0565b6112db6112cb60408a0160208b01615173565b61109360608b0160408c01615173565b505050505b6000806112f36060870160408801615173565b6001600160a01b0316141561130a57503331611398565b61131a6060860160408701615173565b6001600160a01b03166370a08231336040518263ffffffff1660e01b815260040161134591906155f0565b60206040518083038186803b15801561135d57600080fd5b505afa158015611371573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139591906154b7565b90505b60a08501356113ad828463ffffffff61468016565b10156113cb5760405162461bcd60e51b815260040161073f90615889565b505b5050600180555050565b600260015414156113fa5760405162461bcd60e51b815260040161073f90615c56565b6002600155611407612712565b156114245760405162461bcd60e51b815260040161073f906159a6565b61143460a0820160808301615173565b336001600160a01b038216141561145d5760405162461bcd60e51b815260040161073f906158be565b600061147261084d60a0850160808601615173565b90506000806114876060860160408701615173565b6001600160a01b0316141561149e5750333161152c565b6114ae6060850160408601615173565b6001600160a01b03166370a08231336040518263ffffffff1660e01b81526004016114d991906155f0565b60206040518083038186803b1580156114f157600080fd5b505afa158015611505573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061152991906154b7565b90505b61153c60e0850160c0860161530b565b6118fa576000341180156115685750600061155d6040860160208701615173565b6001600160a01b0316145b156116bf5760006001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016346115a48780615d04565b6040516115b2929190615522565b60006040518083038185875af1925050503d80600081146115ef576040519150601f19603f3d011682016040523d82523d6000602084013e6115f4565b606091505b50509050806116155760405162461bcd60e51b815260040161073f90615ba0565b6116b96116286060870160408801615173565b336116396060890160408a01615173565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161166491906155f0565b60206040518083038186803b15801561167c57600080fd5b505afa158015611690573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b491906154b7565b6146a8565b506118f5565b6116cf6040850160208601615173565b6001600160a01b03166323b872dd333087606001356040518463ffffffff1660e01b815260040161170293929190615604565b602060405180830381600087803b15801561171c57600080fd5b505af1158015611730573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117549190615327565b506117656040850160208601615173565b6001600160a01b031663095ea7b37f000000000000000000000000000000000000000000000000000000000000000086606001356040518363ffffffff1660e01b81526004016117b6929190615652565b602060405180830381600087803b1580156117d057600080fd5b505af11580156117e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118089190615327565b5060006001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001661183f8680615d04565b60405161184d929190615522565b6000604051808303816000865af19150503d806000811461188a576040519150601f19603f3d011682016040523d82523d6000602084013e61188f565b606091505b50509050806118b05760405162461bcd60e51b815260040161073f90615ba0565b60006118c26060870160408801615173565b6001600160a01b031614156118e0576118db334761478f565b6118f3565b6118f36116286060870160408801615173565b505b6112e0565b600034118015611922575060006119176040860160208701615173565b6001600160a01b0316145b15611a11576000808061193e610fc660e0890160c08a0161530b565b9194509250905060006001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168461197c8a80615d04565b60405161198a929190615522565b60006040518083038185875af1925050503d80600081146119c7576040519150601f19603f3d011682016040523d82523d6000602084013e6119cc565b606091505b50509050806119ed5760405162461bcd60e51b815260040161073f90615ba0565b61107e611a0060608a0160408b01615173565b3361163960608c0160408d01615173565b60008080611a286110bb60e0890160c08a0161530b565b91945092509050611a3f6040880160208901615173565b6001600160a01b03166323b872dd3330866040518463ffffffff1660e01b8152600401611a6e93929190615604565b602060405180830381600087803b158015611a8857600080fd5b505af1158015611a9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac09190615327565b50611ad16040880160208901615173565b6001600160a01b031663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000856040518363ffffffff1660e01b8152600401611b1e929190615652565b602060405180830381600087803b158015611b3857600080fd5b505af1158015611b4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b709190615327565b5060006001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016611ba78980615d04565b604051611bb5929190615522565b6000604051808303816000865af19150503d8060008114611bf2576040519150601f19603f3d011682016040523d82523d6000602084013e611bf7565b606091505b5050905080611c185760405162461bcd60e51b815260040161073f90615ba0565b6000611c2a60608a0160408b01615173565b6001600160a01b03161415611c4857611c43334761478f565b6112b8565b6112b8611a0060608a0160408b01615173565b611c6361467c565b6001600160a01b0316611c74612e44565b6001600160a01b031614611c9a5760405162461bcd60e51b815260040161073f90615a87565b611ca261481c565b565b6060611cae612712565b15611ccb5760405162461bcd60e51b815260040161073f906159a6565b611cd86020860186615173565b6001600160a01b03811660009081526005602052604090205460ff16611d105760405162461bcd60e51b815260040161073f90615aff565b611d206040870160208801615173565b336001600160a01b0382161415611d495760405162461bcd60e51b815260040161073f906158be565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031685856000818110611d8057fe5b9050602002016020810190611d959190615173565b6001600160a01b031614611dbb5760405162461bcd60e51b815260040161073f906159d0565b6000611dd061084d60408a0160208b01615173565b9050611e1c611de260208a018a615173565b8888888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061488d92505050565b9350600080611e51611e3460608c0160408d0161530b565b87600081518110611e4157fe5b60200260200101518560016140ed565b925092505034611e8e82611e82858a600081518110611e6c57fe5b602002602001015161455c90919063ffffffff16565b9063ffffffff61455c16565b1115611eac5760405162461bcd60e51b815260040161073f9061592c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db087600081518110611ee857fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b158015611f1b57600080fd5b505af1158015611f2f573d6000803e3d6000fd5b50506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016925063a9059cbb9150611fa59050611f7660208e018e615173565b8b8b6000818110611f8357fe5b9050602002016020810190611f989190615173565b8c8c60018181106109f757fe5b88600081518110611fb257fe5b60200260200101516040518363ffffffff1660e01b8152600401611fd7929190615652565b602060405180830381600087803b158015611ff157600080fd5b505af1158015612005573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120299190615327565b61202f57fe5b61207b61203f60208c018c615173565b878a8a808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503392506143db915050565b61209081611e828489600081518110611e6c57fe5b3411156120b7576120b7336120b083611e82868b600081518110611e6c57fe5b340361478f565b60006120c9838363ffffffff61455c16565b1115612101576121016000898960001981018181106120e457fe5b90506020020160208101906120f99190615173565b858585614581565b5050505050949350505050565b61211661467c565b6001600160a01b0316612127612e44565b6001600160a01b03161461214d5760405162461bcd60e51b815260040161073f90615a87565b612157828261478f565b5050565b612163612712565b156121805760405162461bcd60e51b815260040161073f906159a6565b61218d6020850185615173565b6001600160a01b03811660009081526005602052604090205460ff166121c55760405162461bcd60e51b815260040161073f90615aff565b6121d56040860160208701615173565b336001600160a01b03821614156121fe5760405162461bcd60e51b815260040161073f906158be565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168484600081811061223557fe5b905060200201602081019061224a9190615173565b6001600160a01b0316146122705760405162461bcd60e51b815260040161073f906159d0565b600061228561084d6040890160208a01615173565b90506000808061229e61086b60608c0160408d0161530b565b9250925092507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156122ff57600080fd5b505af1158015612313573d6000803e3d6000fd5b50506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016925063a9059cbb915061235a9050611f7660208e018e615173565b856040518363ffffffff1660e01b8152600401612378929190615652565b602060405180830381600087803b15801561239257600080fd5b505af11580156123a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123ca9190615327565b6123d057fe5b6000888860001981018181106123e257fe5b90506020020160208101906123f79190615173565b6001600160a01b03166370a08231336040518263ffffffff1660e01b815260040161242291906155f0565b60206040518083038186803b15801561243a57600080fd5b505afa15801561244e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247291906154b7565b90506124bf61248460208d018d615173565b8a8a8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525033925061498f915050565b89612570828b8b60001981018181106124d457fe5b90506020020160208101906124e99190615173565b6001600160a01b03166370a08231336040518263ffffffff1660e01b815260040161251491906155f0565b60206040518083038186803b15801561252c57600080fd5b505afa158015612540573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256491906154b7565b9063ffffffff61468016565b101561258e5760405162461bcd60e51b815260040161073f90615842565b60006125a0848463ffffffff61455c16565b11156125d8576125d860008a8a60001981018181106125bb57fe5b90506020020160208101906125d09190615173565b878686614581565b5050505050505050505050565b6002546201000090046001600160a01b031681565b60066020908152600091825260409182902080548351601f60026000196101006001861615020190931692909204918201849004840281018401909452808452909183018282801561268d5780601f106126625761010080835404028352916020019161268d565b820191906000526020600020905b81548152906001019060200180831161267057829003601f168201915b505050505081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60025461ffff1681565b6126cb61467c565b6001600160a01b03166126dc612e44565b6001600160a01b0316146127025760405162461bcd60e51b815260040161073f90615a87565b61270d8383836146a8565b505050565b600054600160a01b900460ff165b90565b600061272d61467c565b6001600160a01b031661273e612e44565b6001600160a01b0316146127645760405162461bcd60e51b815260040161073f90615a87565b6127108261ffff16111561278a5760405162461bcd60e51b815260040161073f90615b36565b6001600160a01b03831660008181526004602052604090819020805461ffff191661ffff8616179055517f9b182573c5f49d27d10ab506c71acd90f3b44f15c35eb906f9a40d9c35412e41906127e1908590615cbf565b60405180910390a292915050565b6127f761467c565b6001600160a01b0316612808612e44565b6001600160a01b03161461282e5760405162461bcd60e51b815260040161073f90615a87565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60046020526000908152604090205461ffff1681565b61289661467c565b6001600160a01b03166128a7612e44565b6001600160a01b0316146128cd5760405162461bcd60e51b815260040161073f90615a87565b611ca2614bcb565b60606128df612712565b156128fc5760405162461bcd60e51b815260040161073f906159a6565b6129096020870187615173565b6001600160a01b03811660009081526005602052604090205460ff166129415760405162461bcd60e51b815260040161073f90615aff565b6129516040880160208901615173565b336001600160a01b038216141561297a5760405162461bcd60e51b815260040161073f906158be565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858560001981018181106129b457fe5b90506020020160208101906129c99190615173565b6001600160a01b0316146129ef5760405162461bcd60e51b815260040161073f906159d0565b6000612a0461084d60408b0160208c01615173565b9050600080612a25612a1c60608d0160408e0161530b565b8b8560016140ed565b9093509150612a899050612a3c60208d018d615173565b612a5083611e828e8763ffffffff61455c16565b8a8a8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061488d92505050565b955088612aa182611e82858a600081518110611e6c57fe5b1115612abf5760405162461bcd60e51b815260040161073f9061592c565b612b1588886000818110612acf57fe5b9050602002016020810190612ae49190615173565b33612afb8e60000160208101906109c89190615173565b89600081518110612b0857fe5b6020026020010151614c2c565b612b61612b2560208d018d615173565b878a8a808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503092506143db915050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632e1a7d4d87600189510381518110612ba057fe5b60200260200101516040518263ffffffff1660e01b8152600401612bc49190615cce565b600060405180830381600087803b158015612bde57600080fd5b505af1158015612bf2573d6000803e3d6000fd5b50505050612c00338b61478f565b6000612c12838363ffffffff61455c16565b1115612c2d57612c2d6000898960001981018181106120e457fe5b505050505095945050505050565b6060612c45612712565b15612c625760405162461bcd60e51b815260040161073f906159a6565b612c6f6020870187615173565b6001600160a01b03811660009081526005602052604090205460ff16612ca75760405162461bcd60e51b815260040161073f90615aff565b612cb76040880160208901615173565b336001600160a01b0382161415612ce05760405162461bcd60e51b815260040161073f906158be565b6000612cf561084d60408b0160208c01615173565b905060008080612d17612d0e60608e0160408f0161530b565b8c8660006140ed565b91945092509050612d2e61088b60208e018e615173565b96508987600189510381518110612d4157fe5b60200260200101511015612d675760405162461bcd60e51b815260040161073f90615842565b612dd889896000818110612d7757fe5b9050602002016020810190612d8c9190615173565b33612dd28f6000016020810190612da39190615173565b8d8d6000818110612db057fe5b9050602002016020810190612dc59190615173565b8e8e60018181106109f757fe5b86614c2c565b612de8610aab60208e018e615173565b6000612dfa838363ffffffff61455c16565b1115612e3557612e3589896000818110612e1057fe5b9050602002016020810190612e259190615173565b8a8a6000198101818110610b1457fe5b50505050505095945050505050565b6000546001600160a01b031690565b60025460405163493f44bd60e11b81526000916201000090046001600160a01b03169063927e897a90612e8a9085906004016155f0565b60206040518083038186803b158015612ea257600080fd5b505afa158015612eb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eda9190615327565b92915050565b6060612eea612712565b15612f075760405162461bcd60e51b815260040161073f906159a6565b612f146020870187615173565b6001600160a01b03811660009081526005602052604090205460ff16612f4c5760405162461bcd60e51b815260040161073f90615aff565b612f5c6040880160208901615173565b336001600160a01b0382161415612f855760405162461bcd60e51b815260040161073f906158be565b6000612f9a61084d60408b0160208c01615173565b9050612fe6612fac60208b018b615173565b8988888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061488d92505050565b9350600080612ffe611e3460608d0160408e0161530b565b92509250508861301982611e82858a600081518110611e6c57fe5b11156130375760405162461bcd60e51b815260040161073f9061592c565b61304788886000818110612acf57fe5b61305761203f60208d018d615173565b6000613069838363ffffffff61455c16565b1115612c2d57612c2d8888600081811061307f57fe5b90506020020160208101906130949190615173565b898960001981018181106120e457fe5b7f000000000000000000000000000000000000000000000000000000000000000081565b6003546001600160a01b031681565b6130df61467c565b6001600160a01b03166130f0612e44565b6001600160a01b0316146131165760405162461bcd60e51b815260040161073f90615a87565b6001600160a01b03831660009081526005602052604090205460ff161561314f5760405162461bcd60e51b815260040161073f90615c8d565b6001600160a01b0383166000908152600560209081526040808320805460ff1916600117905560069091529020613187908383615044565b507f18191c6cb9d1bb0cd78a863c5efffb51200f41513b93a678d368156b26d7cc94836040516131b791906155f0565b60405180910390a1505050565b6131cc61467c565b6001600160a01b03166131dd612e44565b6001600160a01b0316146132035760405162461bcd60e51b815260040161073f90615a87565b6001600160a01b0384166000908152600560209081526040808320805460ff19168515151790556006909152902061323c908484615044565b507fd3e17274581b648825e308eb9fca7b795aa9ca651ee0953b1f66dd35cbc099788460405161326c91906155f0565b60405180910390a150505050565b61328261467c565b6001600160a01b0316613293612e44565b6001600160a01b0316146132b95760405162461bcd60e51b815260040161073f90615a87565b600380546001600160a01b0319166001600160a01b0383161790556040517f27aae5db36d94179909d019ae0b1ac7c16d96d953148f63c0f6a0a9c8ead79ee90610be09083906155f0565b61330c61467c565b6001600160a01b031661331d612e44565b6001600160a01b0316146133435760405162461bcd60e51b815260040161073f90615a87565b6002805461ffff191661ffff83161790556040517fc8d25ca8616825eb60e022dde2d5ec038bdac6dd1bd8bba3fb5f74de553d062890610be0908390615cbf565b600254604051633444fbf160e21b81526000916201000090046001600160a01b03169063d113efc4906133bb9085906004016155f0565b60206040518083038186803b1580156133d357600080fd5b505afa1580156133e7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eda919061518f565b61271081565b61341961467c565b6001600160a01b031661342a612e44565b6001600160a01b0316146134505760405162461bcd60e51b815260040161073f90615a87565b6127108161ffff1611156134765760405162461bcd60e51b815260040161073f90615b36565b6003805461ffff60a01b1916600160a01b61ffff8416021790556040517f2e8b87e2b3dff0b7b11ce73a61e3bb94498159c531480d9abf1307014b650af990610be0908390615cbf565b6134c861467c565b6001600160a01b03166134d9612e44565b6001600160a01b0316146134ff5760405162461bcd60e51b815260040161073f90615a87565b6003805460ff60b01b1916600160b01b831515021790556040517f13a5d968457cb650b136b77bb4a3ff25f31b92939f2d8df0010911117b7ba9e090610be09083906156c9565b61354e612712565b1561356b5760405162461bcd60e51b815260040161073f906159a6565b6135786020860186615173565b6001600160a01b03811660009081526005602052604090205460ff166135b05760405162461bcd60e51b815260040161073f90615aff565b6135c06040870160208801615173565b336001600160a01b03821614156135e95760405162461bcd60e51b815260040161073f906158be565b60006135fe61084d60408a0160208b01615173565b90506000808061362061361760608d0160408e0161530b565b8b8660006140ed565b9250925092506136628888600081811061363657fe5b905060200201602081019061364b9190615173565b33612dd28e60000160208101906109c89190615173565b60008888600019810181811061367457fe5b90506020020160208101906136899190615173565b6001600160a01b03166370a08231336040518263ffffffff1660e01b81526004016136b491906155f0565b60206040518083038186803b1580156136cc57600080fd5b505afa1580156136e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061370491906154b7565b905061371661248460208e018e615173565b8961372b828b8b60001981018181106124d457fe5b10156137495760405162461bcd60e51b815260040161073f90615842565b600061375b848463ffffffff61455c16565b1115613796576137968989600081811061377157fe5b90506020020160208101906137869190615173565b8a8a60001981018181106125bb57fe5b505050505050505050505050565b6137ac612712565b156137c95760405162461bcd60e51b815260040161073f906159a6565b6137d66020860186615173565b6001600160a01b03811660009081526005602052604090205460ff1661380e5760405162461bcd60e51b815260040161073f90615aff565b61381e6040870160208801615173565b336001600160a01b03821614156138475760405162461bcd60e51b815260040161073f906158be565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168484600019810181811061388157fe5b90506020020160208101906138969190615173565b6001600160a01b0316146138bc5760405162461bcd60e51b815260040161073f906159d0565b60006138d161084d60408a0160208b01615173565b905061393e858560008181106138e357fe5b90506020020160208101906138f89190615173565b3361393861390960208d018d615173565b8989600081811061391657fe5b905060200201602081019061392b9190615173565b8a8a60018181106109f757fe5b8a614c2c565b61398961394e60208a018a615173565b86868080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525030925061498f915050565b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a08231906139d89030906004016155f0565b60206040518083038186803b1580156139f057600080fd5b505afa158015613a04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a2891906154b7565b604051632e1a7d4d60e01b81529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632e1a7d4d90613a77908490600401615cce565b600060405180830381600087803b158015613a9157600080fd5b505af1158015613aa5573d6000803e3d6000fd5b505050506000806000613acd8c6040016020810190613ac4919061530b565b858760006140ed565b92509250925089831015613af35760405162461bcd60e51b815260040161073f9061580f565b613afd338461478f565b6000613b0f838363ffffffff61455c16565b11156137965761379660008a8a6000198101818110613b2a57fe5b9050602002016020810190613b3f9190615173565b878585614581565b613b4f61467c565b6001600160a01b0316613b60612e44565b6001600160a01b031614613b865760405162461bcd60e51b815260040161073f90615a87565b6001600160a01b038116613bac5760405162461bcd60e51b815260040161073f90615792565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600354600160a01b900461ffff1681565b6060613c22612712565b15613c3f5760405162461bcd60e51b815260040161073f906159a6565b613c4c6020870187615173565b6001600160a01b03811660009081526005602052604090205460ff16613c845760405162461bcd60e51b815260040161073f90615aff565b613c946040880160208901615173565b336001600160a01b0382161415613cbd5760405162461bcd60e51b815260040161073f906158be565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001685856000198101818110613cf757fe5b9050602002016020810190613d0c9190615173565b6001600160a01b031614613d325760405162461bcd60e51b815260040161073f906159d0565b6000613d4761084d60408b0160208c01615173565b9050613d93613d5960208b018b615173565b8988888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061424092505050565b935060008080613dcc613dac60608e0160408f0161530b565b8860018a510381518110613dbc57fe5b60200260200101518660006140ed565b92509250925089831015613df25760405162461bcd60e51b815260040161073f90615842565b613e3b89896000818110613e0257fe5b9050602002016020810190613e179190615173565b33613e2e8f6000016020810190612da39190615173565b8a600081518110612b0857fe5b613e87613e4b60208e018e615173565b888b8b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503092506143db915050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632e1a7d4d8860018a510381518110613ec657fe5b60200260200101516040518263ffffffff1660e01b8152600401613eea9190615cce565b600060405180830381600087803b158015613f0457600080fd5b505af1158015613f18573d6000803e3d6000fd5b50505050613f26338461478f565b6000613f38838363ffffffff61455c16565b1115612e3557612e3560008a8a6000198101818110610b1457fe5b60025460405163493f44bd60e11b81526000913391620100009091046001600160a01b03169063927e897a90613f8d9084906004016155f0565b60206040518083038186803b158015613fa557600080fd5b505afa158015613fb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fdd9190615327565b158015613ff257506001600160a01b03831615155b15614061576002546040516364e0b15960e01b8152620100009091046001600160a01b0316906364e0b1599061402e908490879060040161566b565b600060405180830381600087803b15801561404857600080fd5b505af115801561405c573d6000803e3d6000fd5b505050505b600254604051633444fbf160e21b8152620100009091046001600160a01b03169063d113efc4906140969084906004016155f0565b60206040518083038186803b1580156140ae57600080fd5b505afa1580156140c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140e6919061518f565b9392505050565b6002546000908190819061ffff168761410857869350614235565b84156141535786935061414c8461256461412e61271061ffff861663ffffffff61468016565b6141408861271063ffffffff614d1d16565b9063ffffffff614d5716565b9250614182565b61416d6127106141408961ffff851663ffffffff614d1d16565b925061417f878463ffffffff61468016565b93505b6001600160a01b038616158015906141a35750600354600160b01b900460ff165b15614230576001600160a01b03861660009081526004602052604081205461ffff166141dc57600354600160a01b900461ffff166141fa565b6001600160a01b03871660009081526004602052604090205461ffff165b90506142166127106141408661ffff851663ffffffff614d1d16565b9250614228848463ffffffff61468016565b935050614235565b600091505b509450945094915050565b60606002825110156142645760405162461bcd60e51b815260040161073f906159d0565b81516001600160401b038111801561427b57600080fd5b506040519080825280602002602001820160405280156142a5578160200160208202803683370190505b50905082816000815181106142b657fe5b60200260200101818152505060005b600183510381101561434e57600080614308878685815181106142e457fe5b60200260200101518786600101815181106142fb57fe5b6020026020010151614d89565b9150915061432a84848151811061431b57fe5b60200260200101518383614e62565b84846001018151811061433957fe5b602090810291909101015250506001016142c5565b509392505050565b60008060006143658585614f08565b9150915085828260405160200161437d9291906154fb565b60408051601f1981840301815282825280516020918201206001600160a01b038b16600090815260068352929092206143b9949390910161554e565b60408051601f1981840301815291905280516020909101209695505050505050565b60005b6001835103811015614555576000808483815181106143f957fe5b602002602001015185846001018151811061441057fe5b60200260200101519150915060006144288383614f08565b509050600087856001018151811061443c57fe5b60200260200101519050600080836001600160a01b0316866001600160a01b03161461446a5782600061446e565b6000835b91509150600060028a5103881061448557886144a6565b6144a68c878c8b6002018151811061449957fe5b6020026020010151614356565b90506144b38c8888614356565b6001600160a01b031663022c0d9f84848460006040519080825280601f01601f1916602001820160405280156144f0576020820181803683370190505b506040518563ffffffff1660e01b81526004016145109493929190615cd7565b600060405180830381600087803b15801561452a57600080fd5b505af115801561453e573d6000803e3d6000fd5b5050600190990198506143de975050505050505050565b5050505050565b6000828201838110156140e65760405162461bcd60e51b815260040161073f906157d8565b6001600160a01b038516614602576003546145a5906001600160a01b03168361478f565b80156145fd576145b5838261478f565b826001600160a01b03167f84ff16114f882a54c4748006b5e4b0b7ac76bd911d135145a6d063fd76a38a40338688856040516145f49493929190615628565b60405180910390a25b614555565b60035461461c90869033906001600160a01b031685614c2c565b80156145555761462e85338584614c2c565b826001600160a01b03167f84ff16114f882a54c4748006b5e4b0b7ac76bd911d135145a6d063fd76a38a403386888560405161466d9493929190615628565b60405180910390a25050505050565b3390565b6000828211156146a25760405162461bcd60e51b815260040161073f906158f5565b50900390565b60006060846001600160a01b031663a9059cbb85856040516024016146ce929190615652565b6040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040516147079190615532565b6000604051808303816000865af19150503d8060008114614744576040519150601f19603f3d011682016040523d82523d6000602084013e614749565b606091505b50915091508180156147735750805115806147735750808060200190518101906147739190615327565b6145555760405162461bcd60e51b815260040161073f906156e7565b604080516000808252602082019092526001600160a01b0384169083906040516147b99190615532565b60006040518083038185875af1925050503d80600081146147f6576040519150601f19603f3d011682016040523d82523d6000602084013e6147fb565b606091505b505090508061270d5760405162461bcd60e51b815260040161073f90615bcf565b614824612712565b6148405760405162461bcd60e51b815260040161073f9061571e565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61487661467c565b60405161488391906155f0565b60405180910390a1565b60606002825110156148b15760405162461bcd60e51b815260040161073f906159d0565b81516001600160401b03811180156148c857600080fd5b506040519080825280602002602001820160405280156148f2578160200160208202803683370190505b509050828160018351038151811061490657fe5b60209081029190910101528151600019015b801561434e576000806149488786600186038151811061493457fe5b60200260200101518786815181106142fb57fe5b9150915061496a84848151811061495b57fe5b60200260200101518383614f92565b84600185038151811061497957fe5b6020908102919091010152505060001901614918565b60005b6001835103811015614bc5576000808483815181106149ad57fe5b60200260200101518584600101815181106149c457fe5b60200260200101519150915060006149dc8383614f08565b50905060006149ec888585614356565b9050600080600080846001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015614a2d57600080fd5b505afa158015614a41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a659190615441565b506001600160701b031691506001600160701b03169150600080876001600160a01b03168a6001600160a01b031614614a9f578284614aa2565b83835b91509150614ad6828b6001600160a01b03166370a082318a6040518263ffffffff1660e01b815260040161251491906155f0565b9550614ae3868383614e62565b945050505050600080856001600160a01b0316886001600160a01b031614614b0d57826000614b11565b6000835b91509150600060028c51038a10614b28578a614b3c565b614b3c8d898e8d6002018151811061449957fe5b6040805160008152602081019182905263022c0d9f60e01b9091529091506001600160a01b0387169063022c0d9f90614b7e9086908690869060248101615cd7565b600060405180830381600087803b158015614b9857600080fd5b505af1158015614bac573d6000803e3d6000fd5b50506001909b019a506149929950505050505050505050565b50505050565b614bd3612712565b15614bf05760405162461bcd60e51b815260040161073f906159a6565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861487661467c565b60006060856001600160a01b03166323b872dd868686604051602401614c5493929190615604565b6040516020818303038152906040529060e01b6020820180516001600160e01b038381831617835250505050604051614c8d9190615532565b6000604051808303816000865af19150503d8060008114614cca576040519150601f19603f3d011682016040523d82523d6000602084013e614ccf565b606091505b5091509150818015614cf9575080511580614cf9575080806020019051810190614cf99190615327565b614d155760405162461bcd60e51b815260040161073f90615c12565b505050505050565b600082614d2c57506000612eda565b82820282848281614d3957fe5b04146140e65760405162461bcd60e51b815260040161073f90615a46565b6000808211614d785760405162461bcd60e51b815260040161073f9061596f565b818381614d8157fe5b049392505050565b6000806000614d988585614f08565b509050600080614da9888888614356565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015614de157600080fd5b505afa158015614df5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e199190615441565b506001600160701b031691506001600160701b03169150826001600160a01b0316876001600160a01b031614614e50578082614e53565b81815b90999098509650505050505050565b6000808411614e835760405162461bcd60e51b815260040161073f9061574c565b600083118015614e935750600082115b614eaf5760405162461bcd60e51b815260040161073f90615abc565b6000614ec3856126f263ffffffff614d1d16565b90506000614ed7828563ffffffff614d1d16565b90506000614ef183611e828861271063ffffffff614d1d16565b9050808281614efc57fe5b04979650505050505050565b600080826001600160a01b0316846001600160a01b03161415614f3d5760405162461bcd60e51b815260040161073f90615a03565b826001600160a01b0316846001600160a01b031610614f5d578284614f60565b83835b90925090506001600160a01b038216614f8b5760405162461bcd60e51b815260040161073f90615b69565b9250929050565b6000808411614fb35760405162461bcd60e51b815260040161073f90615842565b600083118015614fc35750600082115b614fdf5760405162461bcd60e51b815260040161073f90615abc565b6000615003612710614ff7868863ffffffff614d1d16565b9063ffffffff614d1d16565b9050600061501d6126f2614ff7868963ffffffff61468016565b905061503a600182848161502d57fe5b049063ffffffff61455c16565b9695505050505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106150855782800160ff198235161785556150b2565b828001600101855582156150b2579182015b828111156150b2578235825591602001919060010190615097565b506150be9291506150c2565b5090565b61272091905b808211156150be57600081556001016150c8565b60008083601f8401126150ed578182fd5b5081356001600160401b03811115615103578182fd5b6020830191508360208083028501011115614f8b57600080fd5b60008083601f84011261512e578182fd5b5081356001600160401b03811115615144578182fd5b602083019150836020828501011115614f8b57600080fd5b60006060828403121561516d578081fd5b50919050565b600060208284031215615184578081fd5b81356140e681615d82565b6000602082840312156151a0578081fd5b81516140e681615d82565b600080604083850312156151bd578081fd5b82356151c881615d82565b946020939093013593505050565b6000806000606084860312156151ea578081fd5b83356151f581615d82565b9250602084013561520581615d82565b929592945050506040919091013590565b60008060006040848603121561522a578283fd5b833561523581615d82565b925060208401356001600160401b0381111561524f578283fd5b61525b8682870161511d565b9497909650939450505050565b6000806000806060858703121561527d578081fd5b843561528881615d82565b935060208501356001600160401b038111156152a2578182fd5b6152ae8782880161511d565b90945092505060408501356152c281615d9a565b939692955090935050565b600080604083850312156152df578182fd5b82356152ea81615d82565b9150602083013561ffff81168114615300578182fd5b809150509250929050565b60006020828403121561531c578081fd5b81356140e681615d9a565b600060208284031215615338578081fd5b81516140e681615d9a565b600060208284031215615354578081fd5b81356001600160401b03811115615369578182fd5b80830160e0818603121561537b578283fd5b949350505050565b60008060008060a08587031215615398578384fd5b6153a2868661515c565b93506060850135925060808501356001600160401b038111156153c3578283fd5b6153cf878288016150dc565b95989497509550505050565b600080600080600060c086880312156153f2578283fd5b6153fc878761515c565b9450606086013593506080860135925060a08601356001600160401b03811115615424578182fd5b615430888289016150dc565b969995985093965092949392505050565b600080600060608486031215615455578081fd5b835161546081615da8565b602085015190935061547181615da8565b604085015190925063ffffffff8116811461548a578182fd5b809150509250925092565b6000602082840312156154a6578081fd5b813561ffff811681146140e6578182fd5b6000602082840312156154c8578081fd5b5051919050565b600081518084526154e7816020860160208601615d56565b601f01601f19169290920160200192915050565b6bffffffffffffffffffffffff19606093841b811682529190921b16601482015260280190565b6000828483379101908152919050565b60008251615544818460208701615d56565b9190910192915050565b600060ff60f81b825260016bffffffffffffffffffffffff198660601b168184015284601584015260358285548381166000811461559357600181146155ae576155e2565b60ff1982168785015260028204607f168701840192506155e2565b600282046155bb89615d4a565b875b828110156155d95781548a8201880152908701906020016155bd565b50508701840192505b509098975050505050505050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0392831681529116602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156156bd578351835292840192918401916001016156a1565b50909695505050505050565b901515815260200190565b6000602082526140e660208301846154cf565b6020808252601f908201527f5472616e7366657248656c7065723a205452414e534645525f4641494c454400604082015260600190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526026908201527f466c6f6f7a526f757465723a20494e53554646494349454e545f494e5055545f604082015265105353d5539560d21b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b602080825260199082015278466c6f6f7a526f757465723a204c4f575f534c49505041474560381b604082015260600190565b60208082526027908201527f466c6f6f7a526f757465723a20494e53554646494349454e545f4f555450555460408201526617d05353d5539560ca1b606082015260800190565b6020808252818101527f466c6f6f7a526f757465723a20494e53554646494349454e545f4f5554505554604082015260600190565b6020808252601a908201527f466c6f6f7a526f757465723a2053454c465f524546455252414c000000000000604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b60208082526023908201527f466c6f6f7a526f757465723a204558434553534956455f494e5055545f414d4f60408201526215539560ea1b606082015260800190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526019908201527808cd8dedef4a4deeae8cae47440929cac82989288bea082a89603b1b604082015260600190565b60208082526023908201527f50616e63616b654c6962726172793a204944454e544943414c5f41444452455360408201526253455360e81b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526023908201527f466c6f6f7a526f757465723a20494e53554646494349454e545f4c495155494460408201526249545960e81b606082015260800190565b6020808252601c908201527f466c6f6f7a526f757465723a20494e56414c49445f464143544f525900000000604082015260600190565b602080825260199082015278466c6f6f7a526f757465723a20494e56414c49445f5241544560381b604082015260600190565b6020808252601c908201527f50616e63616b654c6962726172793a205a45524f5f4144445245535300000000604082015260600190565b602080825260159082015274119b1bdbde949bdd5d195c8e881491559154951151605a1b604082015260600190565b60208082526023908201527f5472616e7366657248656c7065723a204554485f5452414e534645525f46414960408201526213115160ea1b606082015260800190565b60208082526024908201527f5472616e7366657248656c7065723a205452414e534645525f46524f4d5f46416040820152631253115160e21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b602080825260189082015277466c6f6f7a526f757465723a204143544956455f464f524b60401b604082015260600190565b61ffff91909116815260200190565b90815260200190565b600085825284602083015260018060a01b03841660408301526080606083015261503a60808301846154cf565b6000808335601e19843603018112615d1a578283fd5b808401803592506001600160401b03831115615d34578384fd5b60200192505036819003821315614f8b57600080fd5b60009081526020902090565b60005b83811015615d71578181015183820152602001615d59565b83811115614bc55750506000910152565b6001600160a01b0381168114615d9757600080fd5b50565b8015158114615d9757600080fd5b6001600160701b0381168114615d9757600080fdfea264697066735822122048af43cf298667e9ff1ff52de5179d94d4882cec0f955ed5bd2d66d1844c843d64736f6c63430006060033000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000003e80000000000000000000000007b66162866067d1b0dd6537f0fac445ff7f56c86000000000000000000000000c967387f1dc6d350a3732e69581708462d2afffa000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d

Deployed Bytecode

0x60806040526004361061024a5760003560e01c80638456cb5911610139578063c69bebe4116100b6578063e96b2f501161007a578063e96b2f501461063f578063ea043e271461065f578063f01e063a1461067f578063f2fde38b1461069f578063fe4ad446146106bf578063fe7d4f34146106d457610251565b8063c69bebe4146105aa578063caa9b5cb146105ca578063d113efc4146105ea578063d73792a91461060a578063e5ae0c321461061f57610251565b8063a7a94fde116100fd578063a7a94fde14610520578063ad5c464814610540578063b3f0067414610555578063bdf771081461056a578063c00a31591461058a57610251565b80638456cb591461049657806388b28687146104ab5780638d18300a146104cb5780638da5cb5b146104eb578063927e897a1461050057610251565b80634ba4ecb1116101c757806357d1b31b1161018b57806357d1b31b146103ff5780635c975abb1461041f578063692247c314610434578063715018a6146104615780637cde0c741461047657610251565b80634ba4ecb1146103735780634e627e62146103865780634fb5df081461039b57806352ab413b146103c857806354cf2aeb146103dd57610251565b80633149f47f1161020e5780633149f47f146103055780633b74651c146103185780633f4ba83a1461032b5780633f9f5ecb146103405780634782f7791461035357610251565b8063045c08d514610256578063279c186814610281578063279f3291146102a15780632def48b1146102c35780632f912005146102e557610251565b3661025157005b600080fd5b34801561026257600080fd5b5061026b6106f4565b60405161027891906155f0565b60405180910390f35b61029461028f366004615383565b610718565b6040516102789190615685565b3480156102ad57600080fd5b506102b6610b3f565b60405161027891906156c9565b3480156102cf57600080fd5b506102e36102de366004615173565b610b4f565b005b3480156102f157600080fd5b506102b6610300366004615173565b610beb565b6102e3610313366004615343565b610c00565b6102e3610326366004615343565b6113d7565b34801561033757600080fd5b506102e3611c5b565b61029461034e366004615383565b611ca4565b34801561035f57600080fd5b506102e361036e3660046151ab565b61210e565b6102e3610381366004615383565b61215b565b34801561039257600080fd5b5061026b6125e5565b3480156103a757600080fd5b506103bb6103b6366004615173565b6125fa565b60405161027891906156d4565b3480156103d457600080fd5b5061026b612695565b3480156103e957600080fd5b506103f26126b9565b6040516102789190615cbf565b34801561040b57600080fd5b506102e361041a3660046151d6565b6126c3565b34801561042b57600080fd5b506102b6612712565b34801561044057600080fd5b5061045461044f3660046152cd565b612723565b6040516102789190615cce565b34801561046d57600080fd5b506102e36127ef565b34801561048257600080fd5b506103f2610491366004615173565b612878565b3480156104a257600080fd5b506102e361288e565b3480156104b757600080fd5b506102946104c63660046153db565b6128d5565b3480156104d757600080fd5b506102946104e63660046153db565b612c3b565b3480156104f757600080fd5b5061026b612e44565b34801561050c57600080fd5b506102b661051b366004615173565b612e53565b34801561052c57600080fd5b5061029461053b3660046153db565b612ee0565b34801561054c57600080fd5b5061026b6130a4565b34801561056157600080fd5b5061026b6130c8565b34801561057657600080fd5b506102e3610585366004615216565b6130d7565b34801561059657600080fd5b506102e36105a5366004615268565b6131c4565b3480156105b657600080fd5b506102e36105c5366004615173565b61327a565b3480156105d657600080fd5b506102e36105e5366004615495565b613304565b3480156105f657600080fd5b5061026b610605366004615173565b613384565b34801561061657600080fd5b5061045461340b565b34801561062b57600080fd5b506102e361063a366004615495565b613411565b34801561064b57600080fd5b506102e361065a36600461530b565b6134c0565b34801561066b57600080fd5b506102e361067a3660046153db565b613546565b34801561068b57600080fd5b506102e361069a3660046153db565b6137a4565b3480156106ab57600080fd5b506102e36106ba366004615173565b613b47565b3480156106cb57600080fd5b506103f2613c07565b3480156106e057600080fd5b506102946106ef3660046153db565b613c18565b7f0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d81565b6060610722612712565b156107485760405162461bcd60e51b815260040161073f906159a6565b60405180910390fd5b6107556020860186615173565b6001600160a01b03811660009081526005602052604090205460ff1661078d5760405162461bcd60e51b815260040161073f90615aff565b61079d6040870160208801615173565b336001600160a01b03821614156107c65760405162461bcd60e51b815260040161073f906158be565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316858560008181106107fd57fe5b90506020020160208101906108129190615173565b6001600160a01b0316146108385760405162461bcd60e51b815260040161073f906159d0565b600061085261084d60408a0160208b01615173565b613f53565b90506000808061087461086b60608d0160408e0161530b565b348660006140ed565b919450925090506108c561088b60208d018d615173565b848b8b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061424092505050565b965089876001895103815181106108d857fe5b602002602001015110156108fe5760405162461bcd60e51b815260040161073f90615842565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db08860008151811061093a57fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b15801561096d57600080fd5b505af1158015610981573d6000803e3d6000fd5b50506001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216925063a9059cbb9150610a1190506109c860208f018f615173565b8c8c60008181106109d557fe5b90506020020160208101906109ea9190615173565b8d8d60018181106109f757fe5b9050602002016020810190610a0c9190615173565b614356565b89600081518110610a1e57fe5b60200260200101516040518363ffffffff1660e01b8152600401610a43929190615652565b602060405180830381600087803b158015610a5d57600080fd5b505af1158015610a71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a959190615327565b610a9b57fe5b610ae7610aab60208d018d615173565b888b8b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503392506143db915050565b6000610af9838363ffffffff61455c16565b1115610b3157610b3160008a8a6000198101818110610b1457fe5b9050602002016020810190610b299190615173565b868585614581565b505050505050949350505050565b600354600160b01b900460ff1681565b610b5761467c565b6001600160a01b0316610b68612e44565b6001600160a01b031614610b8e5760405162461bcd60e51b815260040161073f90615a87565b6002805462010000600160b01b031916620100006001600160a01b038416021790556040517f9d4414af8d61d821c1ad25f0aadfa28aa386c452716a31fc1f7fdbd9b9d364dc90610be09083906155f0565b60405180910390a150565b60056020526000908152604090205460ff1681565b60026001541415610c235760405162461bcd60e51b815260040161073f90615c56565b6002600155610c30612712565b15610c4d5760405162461bcd60e51b815260040161073f906159a6565b610c5d60a0820160808301615173565b336001600160a01b0382161415610c865760405162461bcd60e51b815260040161073f906158be565b6000610c9b61084d60a0850160808601615173565b9050600080610cb06060860160408701615173565b6001600160a01b03161415610cc757503331610d55565b610cd76060850160408601615173565b6001600160a01b03166370a08231336040518263ffffffff1660e01b8152600401610d0291906155f0565b60206040518083038186803b158015610d1a57600080fd5b505afa158015610d2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5291906154b7565b90505b610d6560e0850160c0860161530b565b610f82576000610d7b6040860160208701615173565b6001600160a01b031614610ed457610d996040850160208601615173565b6001600160a01b03166323b872dd333087606001356040518463ffffffff1660e01b8152600401610dcc93929190615604565b602060405180830381600087803b158015610de657600080fd5b505af1158015610dfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1e9190615327565b50610e2f6040850160208601615173565b6001600160a01b031663095ea7b37f0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d86606001356040518363ffffffff1660e01b8152600401610e80929190615652565b602060405180830381600087803b158015610e9a57600080fd5b505af1158015610eae573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed29190615327565b505b60006001600160a01b037f0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d1634610f0b8780615d04565b604051610f19929190615522565b60006040518083038185875af1925050503d8060008114610f56576040519150601f19603f3d011682016040523d82523d6000602084013e610f5b565b606091505b5050905080610f7c5760405162461bcd60e51b815260040161073f90615ba0565b506113cd565b600034118015610faa57506000610f9f6040860160208701615173565b6001600160a01b0316145b156110a45760008080610fcf610fc660e0890160c08a0161530b565b348760006140ed565b9194509250905060006001600160a01b037f0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d168461100d8a80615d04565b60405161101b929190615522565b60006040518083038185875af1925050503d8060008114611058576040519150601f19603f3d011682016040523d82523d6000602084013e61105d565b606091505b505090508061107e5760405162461bcd60e51b815260040161073f90615ba0565b61109b600061109360608b0160408c01615173565b888686614581565b505050506112e0565b600080806110c86110bb60e0890160c08a0161530b565b88606001358760006140ed565b919450925090506110df6040880160208901615173565b6001600160a01b03166323b872dd3330866040518463ffffffff1660e01b815260040161110e93929190615604565b602060405180830381600087803b15801561112857600080fd5b505af115801561113c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111609190615327565b506111716040880160208901615173565b6001600160a01b031663095ea7b37f0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d856040518363ffffffff1660e01b81526004016111be929190615652565b602060405180830381600087803b1580156111d857600080fd5b505af11580156111ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112109190615327565b5060006001600160a01b037f0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d166112478980615d04565b604051611255929190615522565b6000604051808303816000865af19150503d8060008114611292576040519150601f19603f3d011682016040523d82523d6000602084013e611297565b606091505b50509050806112b85760405162461bcd60e51b815260040161073f90615ba0565b6112db6112cb60408a0160208b01615173565b61109360608b0160408c01615173565b505050505b6000806112f36060870160408801615173565b6001600160a01b0316141561130a57503331611398565b61131a6060860160408701615173565b6001600160a01b03166370a08231336040518263ffffffff1660e01b815260040161134591906155f0565b60206040518083038186803b15801561135d57600080fd5b505afa158015611371573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139591906154b7565b90505b60a08501356113ad828463ffffffff61468016565b10156113cb5760405162461bcd60e51b815260040161073f90615889565b505b5050600180555050565b600260015414156113fa5760405162461bcd60e51b815260040161073f90615c56565b6002600155611407612712565b156114245760405162461bcd60e51b815260040161073f906159a6565b61143460a0820160808301615173565b336001600160a01b038216141561145d5760405162461bcd60e51b815260040161073f906158be565b600061147261084d60a0850160808601615173565b90506000806114876060860160408701615173565b6001600160a01b0316141561149e5750333161152c565b6114ae6060850160408601615173565b6001600160a01b03166370a08231336040518263ffffffff1660e01b81526004016114d991906155f0565b60206040518083038186803b1580156114f157600080fd5b505afa158015611505573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061152991906154b7565b90505b61153c60e0850160c0860161530b565b6118fa576000341180156115685750600061155d6040860160208701615173565b6001600160a01b0316145b156116bf5760006001600160a01b037f000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff16346115a48780615d04565b6040516115b2929190615522565b60006040518083038185875af1925050503d80600081146115ef576040519150601f19603f3d011682016040523d82523d6000602084013e6115f4565b606091505b50509050806116155760405162461bcd60e51b815260040161073f90615ba0565b6116b96116286060870160408801615173565b336116396060890160408a01615173565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161166491906155f0565b60206040518083038186803b15801561167c57600080fd5b505afa158015611690573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b491906154b7565b6146a8565b506118f5565b6116cf6040850160208601615173565b6001600160a01b03166323b872dd333087606001356040518463ffffffff1660e01b815260040161170293929190615604565b602060405180830381600087803b15801561171c57600080fd5b505af1158015611730573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117549190615327565b506117656040850160208601615173565b6001600160a01b031663095ea7b37f000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff86606001356040518363ffffffff1660e01b81526004016117b6929190615652565b602060405180830381600087803b1580156117d057600080fd5b505af11580156117e4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118089190615327565b5060006001600160a01b037f000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff1661183f8680615d04565b60405161184d929190615522565b6000604051808303816000865af19150503d806000811461188a576040519150601f19603f3d011682016040523d82523d6000602084013e61188f565b606091505b50509050806118b05760405162461bcd60e51b815260040161073f90615ba0565b60006118c26060870160408801615173565b6001600160a01b031614156118e0576118db334761478f565b6118f3565b6118f36116286060870160408801615173565b505b6112e0565b600034118015611922575060006119176040860160208701615173565b6001600160a01b0316145b15611a11576000808061193e610fc660e0890160c08a0161530b565b9194509250905060006001600160a01b037f000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff168461197c8a80615d04565b60405161198a929190615522565b60006040518083038185875af1925050503d80600081146119c7576040519150601f19603f3d011682016040523d82523d6000602084013e6119cc565b606091505b50509050806119ed5760405162461bcd60e51b815260040161073f90615ba0565b61107e611a0060608a0160408b01615173565b3361163960608c0160408d01615173565b60008080611a286110bb60e0890160c08a0161530b565b91945092509050611a3f6040880160208901615173565b6001600160a01b03166323b872dd3330866040518463ffffffff1660e01b8152600401611a6e93929190615604565b602060405180830381600087803b158015611a8857600080fd5b505af1158015611a9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac09190615327565b50611ad16040880160208901615173565b6001600160a01b031663095ea7b37f000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff856040518363ffffffff1660e01b8152600401611b1e929190615652565b602060405180830381600087803b158015611b3857600080fd5b505af1158015611b4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b709190615327565b5060006001600160a01b037f000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff16611ba78980615d04565b604051611bb5929190615522565b6000604051808303816000865af19150503d8060008114611bf2576040519150601f19603f3d011682016040523d82523d6000602084013e611bf7565b606091505b5050905080611c185760405162461bcd60e51b815260040161073f90615ba0565b6000611c2a60608a0160408b01615173565b6001600160a01b03161415611c4857611c43334761478f565b6112b8565b6112b8611a0060608a0160408b01615173565b611c6361467c565b6001600160a01b0316611c74612e44565b6001600160a01b031614611c9a5760405162461bcd60e51b815260040161073f90615a87565b611ca261481c565b565b6060611cae612712565b15611ccb5760405162461bcd60e51b815260040161073f906159a6565b611cd86020860186615173565b6001600160a01b03811660009081526005602052604090205460ff16611d105760405162461bcd60e51b815260040161073f90615aff565b611d206040870160208801615173565b336001600160a01b0382161415611d495760405162461bcd60e51b815260040161073f906158be565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031685856000818110611d8057fe5b9050602002016020810190611d959190615173565b6001600160a01b031614611dbb5760405162461bcd60e51b815260040161073f906159d0565b6000611dd061084d60408a0160208b01615173565b9050611e1c611de260208a018a615173565b8888888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061488d92505050565b9350600080611e51611e3460608c0160408d0161530b565b87600081518110611e4157fe5b60200260200101518560016140ed565b925092505034611e8e82611e82858a600081518110611e6c57fe5b602002602001015161455c90919063ffffffff16565b9063ffffffff61455c16565b1115611eac5760405162461bcd60e51b815260040161073f9061592c565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db087600081518110611ee857fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b158015611f1b57600080fd5b505af1158015611f2f573d6000803e3d6000fd5b50506001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216925063a9059cbb9150611fa59050611f7660208e018e615173565b8b8b6000818110611f8357fe5b9050602002016020810190611f989190615173565b8c8c60018181106109f757fe5b88600081518110611fb257fe5b60200260200101516040518363ffffffff1660e01b8152600401611fd7929190615652565b602060405180830381600087803b158015611ff157600080fd5b505af1158015612005573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120299190615327565b61202f57fe5b61207b61203f60208c018c615173565b878a8a808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503392506143db915050565b61209081611e828489600081518110611e6c57fe5b3411156120b7576120b7336120b083611e82868b600081518110611e6c57fe5b340361478f565b60006120c9838363ffffffff61455c16565b1115612101576121016000898960001981018181106120e457fe5b90506020020160208101906120f99190615173565b858585614581565b5050505050949350505050565b61211661467c565b6001600160a01b0316612127612e44565b6001600160a01b03161461214d5760405162461bcd60e51b815260040161073f90615a87565b612157828261478f565b5050565b612163612712565b156121805760405162461bcd60e51b815260040161073f906159a6565b61218d6020850185615173565b6001600160a01b03811660009081526005602052604090205460ff166121c55760405162461bcd60e51b815260040161073f90615aff565b6121d56040860160208701615173565b336001600160a01b03821614156121fe5760405162461bcd60e51b815260040161073f906158be565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03168484600081811061223557fe5b905060200201602081019061224a9190615173565b6001600160a01b0316146122705760405162461bcd60e51b815260040161073f906159d0565b600061228561084d6040890160208a01615173565b90506000808061229e61086b60608c0160408d0161530b565b9250925092507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156122ff57600080fd5b505af1158015612313573d6000803e3d6000fd5b50506001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216925063a9059cbb915061235a9050611f7660208e018e615173565b856040518363ffffffff1660e01b8152600401612378929190615652565b602060405180830381600087803b15801561239257600080fd5b505af11580156123a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123ca9190615327565b6123d057fe5b6000888860001981018181106123e257fe5b90506020020160208101906123f79190615173565b6001600160a01b03166370a08231336040518263ffffffff1660e01b815260040161242291906155f0565b60206040518083038186803b15801561243a57600080fd5b505afa15801561244e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247291906154b7565b90506124bf61248460208d018d615173565b8a8a8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525033925061498f915050565b89612570828b8b60001981018181106124d457fe5b90506020020160208101906124e99190615173565b6001600160a01b03166370a08231336040518263ffffffff1660e01b815260040161251491906155f0565b60206040518083038186803b15801561252c57600080fd5b505afa158015612540573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256491906154b7565b9063ffffffff61468016565b101561258e5760405162461bcd60e51b815260040161073f90615842565b60006125a0848463ffffffff61455c16565b11156125d8576125d860008a8a60001981018181106125bb57fe5b90506020020160208101906125d09190615173565b878686614581565b5050505050505050505050565b6002546201000090046001600160a01b031681565b60066020908152600091825260409182902080548351601f60026000196101006001861615020190931692909204918201849004840281018401909452808452909183018282801561268d5780601f106126625761010080835404028352916020019161268d565b820191906000526020600020905b81548152906001019060200180831161267057829003601f168201915b505050505081565b7f000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff81565b60025461ffff1681565b6126cb61467c565b6001600160a01b03166126dc612e44565b6001600160a01b0316146127025760405162461bcd60e51b815260040161073f90615a87565b61270d8383836146a8565b505050565b600054600160a01b900460ff165b90565b600061272d61467c565b6001600160a01b031661273e612e44565b6001600160a01b0316146127645760405162461bcd60e51b815260040161073f90615a87565b6127108261ffff16111561278a5760405162461bcd60e51b815260040161073f90615b36565b6001600160a01b03831660008181526004602052604090819020805461ffff191661ffff8616179055517f9b182573c5f49d27d10ab506c71acd90f3b44f15c35eb906f9a40d9c35412e41906127e1908590615cbf565b60405180910390a292915050565b6127f761467c565b6001600160a01b0316612808612e44565b6001600160a01b03161461282e5760405162461bcd60e51b815260040161073f90615a87565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60046020526000908152604090205461ffff1681565b61289661467c565b6001600160a01b03166128a7612e44565b6001600160a01b0316146128cd5760405162461bcd60e51b815260040161073f90615a87565b611ca2614bcb565b60606128df612712565b156128fc5760405162461bcd60e51b815260040161073f906159a6565b6129096020870187615173565b6001600160a01b03811660009081526005602052604090205460ff166129415760405162461bcd60e51b815260040161073f90615aff565b6129516040880160208901615173565b336001600160a01b038216141561297a5760405162461bcd60e51b815260040161073f906158be565b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216858560001981018181106129b457fe5b90506020020160208101906129c99190615173565b6001600160a01b0316146129ef5760405162461bcd60e51b815260040161073f906159d0565b6000612a0461084d60408b0160208c01615173565b9050600080612a25612a1c60608d0160408e0161530b565b8b8560016140ed565b9093509150612a899050612a3c60208d018d615173565b612a5083611e828e8763ffffffff61455c16565b8a8a8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061488d92505050565b955088612aa182611e82858a600081518110611e6c57fe5b1115612abf5760405162461bcd60e51b815260040161073f9061592c565b612b1588886000818110612acf57fe5b9050602002016020810190612ae49190615173565b33612afb8e60000160208101906109c89190615173565b89600081518110612b0857fe5b6020026020010151614c2c565b612b61612b2560208d018d615173565b878a8a808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503092506143db915050565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d87600189510381518110612ba057fe5b60200260200101516040518263ffffffff1660e01b8152600401612bc49190615cce565b600060405180830381600087803b158015612bde57600080fd5b505af1158015612bf2573d6000803e3d6000fd5b50505050612c00338b61478f565b6000612c12838363ffffffff61455c16565b1115612c2d57612c2d6000898960001981018181106120e457fe5b505050505095945050505050565b6060612c45612712565b15612c625760405162461bcd60e51b815260040161073f906159a6565b612c6f6020870187615173565b6001600160a01b03811660009081526005602052604090205460ff16612ca75760405162461bcd60e51b815260040161073f90615aff565b612cb76040880160208901615173565b336001600160a01b0382161415612ce05760405162461bcd60e51b815260040161073f906158be565b6000612cf561084d60408b0160208c01615173565b905060008080612d17612d0e60608e0160408f0161530b565b8c8660006140ed565b91945092509050612d2e61088b60208e018e615173565b96508987600189510381518110612d4157fe5b60200260200101511015612d675760405162461bcd60e51b815260040161073f90615842565b612dd889896000818110612d7757fe5b9050602002016020810190612d8c9190615173565b33612dd28f6000016020810190612da39190615173565b8d8d6000818110612db057fe5b9050602002016020810190612dc59190615173565b8e8e60018181106109f757fe5b86614c2c565b612de8610aab60208e018e615173565b6000612dfa838363ffffffff61455c16565b1115612e3557612e3589896000818110612e1057fe5b9050602002016020810190612e259190615173565b8a8a6000198101818110610b1457fe5b50505050505095945050505050565b6000546001600160a01b031690565b60025460405163493f44bd60e11b81526000916201000090046001600160a01b03169063927e897a90612e8a9085906004016155f0565b60206040518083038186803b158015612ea257600080fd5b505afa158015612eb6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eda9190615327565b92915050565b6060612eea612712565b15612f075760405162461bcd60e51b815260040161073f906159a6565b612f146020870187615173565b6001600160a01b03811660009081526005602052604090205460ff16612f4c5760405162461bcd60e51b815260040161073f90615aff565b612f5c6040880160208901615173565b336001600160a01b0382161415612f855760405162461bcd60e51b815260040161073f906158be565b6000612f9a61084d60408b0160208c01615173565b9050612fe6612fac60208b018b615173565b8988888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061488d92505050565b9350600080612ffe611e3460608d0160408e0161530b565b92509250508861301982611e82858a600081518110611e6c57fe5b11156130375760405162461bcd60e51b815260040161073f9061592c565b61304788886000818110612acf57fe5b61305761203f60208d018d615173565b6000613069838363ffffffff61455c16565b1115612c2d57612c2d8888600081811061307f57fe5b90506020020160208101906130949190615173565b898960001981018181106120e457fe5b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6003546001600160a01b031681565b6130df61467c565b6001600160a01b03166130f0612e44565b6001600160a01b0316146131165760405162461bcd60e51b815260040161073f90615a87565b6001600160a01b03831660009081526005602052604090205460ff161561314f5760405162461bcd60e51b815260040161073f90615c8d565b6001600160a01b0383166000908152600560209081526040808320805460ff1916600117905560069091529020613187908383615044565b507f18191c6cb9d1bb0cd78a863c5efffb51200f41513b93a678d368156b26d7cc94836040516131b791906155f0565b60405180910390a1505050565b6131cc61467c565b6001600160a01b03166131dd612e44565b6001600160a01b0316146132035760405162461bcd60e51b815260040161073f90615a87565b6001600160a01b0384166000908152600560209081526040808320805460ff19168515151790556006909152902061323c908484615044565b507fd3e17274581b648825e308eb9fca7b795aa9ca651ee0953b1f66dd35cbc099788460405161326c91906155f0565b60405180910390a150505050565b61328261467c565b6001600160a01b0316613293612e44565b6001600160a01b0316146132b95760405162461bcd60e51b815260040161073f90615a87565b600380546001600160a01b0319166001600160a01b0383161790556040517f27aae5db36d94179909d019ae0b1ac7c16d96d953148f63c0f6a0a9c8ead79ee90610be09083906155f0565b61330c61467c565b6001600160a01b031661331d612e44565b6001600160a01b0316146133435760405162461bcd60e51b815260040161073f90615a87565b6002805461ffff191661ffff83161790556040517fc8d25ca8616825eb60e022dde2d5ec038bdac6dd1bd8bba3fb5f74de553d062890610be0908390615cbf565b600254604051633444fbf160e21b81526000916201000090046001600160a01b03169063d113efc4906133bb9085906004016155f0565b60206040518083038186803b1580156133d357600080fd5b505afa1580156133e7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eda919061518f565b61271081565b61341961467c565b6001600160a01b031661342a612e44565b6001600160a01b0316146134505760405162461bcd60e51b815260040161073f90615a87565b6127108161ffff1611156134765760405162461bcd60e51b815260040161073f90615b36565b6003805461ffff60a01b1916600160a01b61ffff8416021790556040517f2e8b87e2b3dff0b7b11ce73a61e3bb94498159c531480d9abf1307014b650af990610be0908390615cbf565b6134c861467c565b6001600160a01b03166134d9612e44565b6001600160a01b0316146134ff5760405162461bcd60e51b815260040161073f90615a87565b6003805460ff60b01b1916600160b01b831515021790556040517f13a5d968457cb650b136b77bb4a3ff25f31b92939f2d8df0010911117b7ba9e090610be09083906156c9565b61354e612712565b1561356b5760405162461bcd60e51b815260040161073f906159a6565b6135786020860186615173565b6001600160a01b03811660009081526005602052604090205460ff166135b05760405162461bcd60e51b815260040161073f90615aff565b6135c06040870160208801615173565b336001600160a01b03821614156135e95760405162461bcd60e51b815260040161073f906158be565b60006135fe61084d60408a0160208b01615173565b90506000808061362061361760608d0160408e0161530b565b8b8660006140ed565b9250925092506136628888600081811061363657fe5b905060200201602081019061364b9190615173565b33612dd28e60000160208101906109c89190615173565b60008888600019810181811061367457fe5b90506020020160208101906136899190615173565b6001600160a01b03166370a08231336040518263ffffffff1660e01b81526004016136b491906155f0565b60206040518083038186803b1580156136cc57600080fd5b505afa1580156136e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061370491906154b7565b905061371661248460208e018e615173565b8961372b828b8b60001981018181106124d457fe5b10156137495760405162461bcd60e51b815260040161073f90615842565b600061375b848463ffffffff61455c16565b1115613796576137968989600081811061377157fe5b90506020020160208101906137869190615173565b8a8a60001981018181106125bb57fe5b505050505050505050505050565b6137ac612712565b156137c95760405162461bcd60e51b815260040161073f906159a6565b6137d66020860186615173565b6001600160a01b03811660009081526005602052604090205460ff1661380e5760405162461bcd60e51b815260040161073f90615aff565b61381e6040870160208801615173565b336001600160a01b03821614156138475760405162461bcd60e51b815260040161073f906158be565b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2168484600019810181811061388157fe5b90506020020160208101906138969190615173565b6001600160a01b0316146138bc5760405162461bcd60e51b815260040161073f906159d0565b60006138d161084d60408a0160208b01615173565b905061393e858560008181106138e357fe5b90506020020160208101906138f89190615173565b3361393861390960208d018d615173565b8989600081811061391657fe5b905060200201602081019061392b9190615173565b8a8a60018181106109f757fe5b8a614c2c565b61398961394e60208a018a615173565b86868080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525030925061498f915050565b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216906370a08231906139d89030906004016155f0565b60206040518083038186803b1580156139f057600080fd5b505afa158015613a04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a2891906154b7565b604051632e1a7d4d60e01b81529091506001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21690632e1a7d4d90613a77908490600401615cce565b600060405180830381600087803b158015613a9157600080fd5b505af1158015613aa5573d6000803e3d6000fd5b505050506000806000613acd8c6040016020810190613ac4919061530b565b858760006140ed565b92509250925089831015613af35760405162461bcd60e51b815260040161073f9061580f565b613afd338461478f565b6000613b0f838363ffffffff61455c16565b11156137965761379660008a8a6000198101818110613b2a57fe5b9050602002016020810190613b3f9190615173565b878585614581565b613b4f61467c565b6001600160a01b0316613b60612e44565b6001600160a01b031614613b865760405162461bcd60e51b815260040161073f90615a87565b6001600160a01b038116613bac5760405162461bcd60e51b815260040161073f90615792565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600354600160a01b900461ffff1681565b6060613c22612712565b15613c3f5760405162461bcd60e51b815260040161073f906159a6565b613c4c6020870187615173565b6001600160a01b03811660009081526005602052604090205460ff16613c845760405162461bcd60e51b815260040161073f90615aff565b613c946040880160208901615173565b336001600160a01b0382161415613cbd5760405162461bcd60e51b815260040161073f906158be565b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21685856000198101818110613cf757fe5b9050602002016020810190613d0c9190615173565b6001600160a01b031614613d325760405162461bcd60e51b815260040161073f906159d0565b6000613d4761084d60408b0160208c01615173565b9050613d93613d5960208b018b615173565b8988888080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061424092505050565b935060008080613dcc613dac60608e0160408f0161530b565b8860018a510381518110613dbc57fe5b60200260200101518660006140ed565b92509250925089831015613df25760405162461bcd60e51b815260040161073f90615842565b613e3b89896000818110613e0257fe5b9050602002016020810190613e179190615173565b33613e2e8f6000016020810190612da39190615173565b8a600081518110612b0857fe5b613e87613e4b60208e018e615173565b888b8b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503092506143db915050565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316632e1a7d4d8860018a510381518110613ec657fe5b60200260200101516040518263ffffffff1660e01b8152600401613eea9190615cce565b600060405180830381600087803b158015613f0457600080fd5b505af1158015613f18573d6000803e3d6000fd5b50505050613f26338461478f565b6000613f38838363ffffffff61455c16565b1115612e3557612e3560008a8a6000198101818110610b1457fe5b60025460405163493f44bd60e11b81526000913391620100009091046001600160a01b03169063927e897a90613f8d9084906004016155f0565b60206040518083038186803b158015613fa557600080fd5b505afa158015613fb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fdd9190615327565b158015613ff257506001600160a01b03831615155b15614061576002546040516364e0b15960e01b8152620100009091046001600160a01b0316906364e0b1599061402e908490879060040161566b565b600060405180830381600087803b15801561404857600080fd5b505af115801561405c573d6000803e3d6000fd5b505050505b600254604051633444fbf160e21b8152620100009091046001600160a01b03169063d113efc4906140969084906004016155f0565b60206040518083038186803b1580156140ae57600080fd5b505afa1580156140c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140e6919061518f565b9392505050565b6002546000908190819061ffff168761410857869350614235565b84156141535786935061414c8461256461412e61271061ffff861663ffffffff61468016565b6141408861271063ffffffff614d1d16565b9063ffffffff614d5716565b9250614182565b61416d6127106141408961ffff851663ffffffff614d1d16565b925061417f878463ffffffff61468016565b93505b6001600160a01b038616158015906141a35750600354600160b01b900460ff165b15614230576001600160a01b03861660009081526004602052604081205461ffff166141dc57600354600160a01b900461ffff166141fa565b6001600160a01b03871660009081526004602052604090205461ffff165b90506142166127106141408661ffff851663ffffffff614d1d16565b9250614228848463ffffffff61468016565b935050614235565b600091505b509450945094915050565b60606002825110156142645760405162461bcd60e51b815260040161073f906159d0565b81516001600160401b038111801561427b57600080fd5b506040519080825280602002602001820160405280156142a5578160200160208202803683370190505b50905082816000815181106142b657fe5b60200260200101818152505060005b600183510381101561434e57600080614308878685815181106142e457fe5b60200260200101518786600101815181106142fb57fe5b6020026020010151614d89565b9150915061432a84848151811061431b57fe5b60200260200101518383614e62565b84846001018151811061433957fe5b602090810291909101015250506001016142c5565b509392505050565b60008060006143658585614f08565b9150915085828260405160200161437d9291906154fb565b60408051601f1981840301815282825280516020918201206001600160a01b038b16600090815260068352929092206143b9949390910161554e565b60408051601f1981840301815291905280516020909101209695505050505050565b60005b6001835103811015614555576000808483815181106143f957fe5b602002602001015185846001018151811061441057fe5b60200260200101519150915060006144288383614f08565b509050600087856001018151811061443c57fe5b60200260200101519050600080836001600160a01b0316866001600160a01b03161461446a5782600061446e565b6000835b91509150600060028a5103881061448557886144a6565b6144a68c878c8b6002018151811061449957fe5b6020026020010151614356565b90506144b38c8888614356565b6001600160a01b031663022c0d9f84848460006040519080825280601f01601f1916602001820160405280156144f0576020820181803683370190505b506040518563ffffffff1660e01b81526004016145109493929190615cd7565b600060405180830381600087803b15801561452a57600080fd5b505af115801561453e573d6000803e3d6000fd5b5050600190990198506143de975050505050505050565b5050505050565b6000828201838110156140e65760405162461bcd60e51b815260040161073f906157d8565b6001600160a01b038516614602576003546145a5906001600160a01b03168361478f565b80156145fd576145b5838261478f565b826001600160a01b03167f84ff16114f882a54c4748006b5e4b0b7ac76bd911d135145a6d063fd76a38a40338688856040516145f49493929190615628565b60405180910390a25b614555565b60035461461c90869033906001600160a01b031685614c2c565b80156145555761462e85338584614c2c565b826001600160a01b03167f84ff16114f882a54c4748006b5e4b0b7ac76bd911d135145a6d063fd76a38a403386888560405161466d9493929190615628565b60405180910390a25050505050565b3390565b6000828211156146a25760405162461bcd60e51b815260040161073f906158f5565b50900390565b60006060846001600160a01b031663a9059cbb85856040516024016146ce929190615652565b6040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040516147079190615532565b6000604051808303816000865af19150503d8060008114614744576040519150601f19603f3d011682016040523d82523d6000602084013e614749565b606091505b50915091508180156147735750805115806147735750808060200190518101906147739190615327565b6145555760405162461bcd60e51b815260040161073f906156e7565b604080516000808252602082019092526001600160a01b0384169083906040516147b99190615532565b60006040518083038185875af1925050503d80600081146147f6576040519150601f19603f3d011682016040523d82523d6000602084013e6147fb565b606091505b505090508061270d5760405162461bcd60e51b815260040161073f90615bcf565b614824612712565b6148405760405162461bcd60e51b815260040161073f9061571e565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61487661467c565b60405161488391906155f0565b60405180910390a1565b60606002825110156148b15760405162461bcd60e51b815260040161073f906159d0565b81516001600160401b03811180156148c857600080fd5b506040519080825280602002602001820160405280156148f2578160200160208202803683370190505b509050828160018351038151811061490657fe5b60209081029190910101528151600019015b801561434e576000806149488786600186038151811061493457fe5b60200260200101518786815181106142fb57fe5b9150915061496a84848151811061495b57fe5b60200260200101518383614f92565b84600185038151811061497957fe5b6020908102919091010152505060001901614918565b60005b6001835103811015614bc5576000808483815181106149ad57fe5b60200260200101518584600101815181106149c457fe5b60200260200101519150915060006149dc8383614f08565b50905060006149ec888585614356565b9050600080600080846001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015614a2d57600080fd5b505afa158015614a41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a659190615441565b506001600160701b031691506001600160701b03169150600080876001600160a01b03168a6001600160a01b031614614a9f578284614aa2565b83835b91509150614ad6828b6001600160a01b03166370a082318a6040518263ffffffff1660e01b815260040161251491906155f0565b9550614ae3868383614e62565b945050505050600080856001600160a01b0316886001600160a01b031614614b0d57826000614b11565b6000835b91509150600060028c51038a10614b28578a614b3c565b614b3c8d898e8d6002018151811061449957fe5b6040805160008152602081019182905263022c0d9f60e01b9091529091506001600160a01b0387169063022c0d9f90614b7e9086908690869060248101615cd7565b600060405180830381600087803b158015614b9857600080fd5b505af1158015614bac573d6000803e3d6000fd5b50506001909b019a506149929950505050505050505050565b50505050565b614bd3612712565b15614bf05760405162461bcd60e51b815260040161073f906159a6565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861487661467c565b60006060856001600160a01b03166323b872dd868686604051602401614c5493929190615604565b6040516020818303038152906040529060e01b6020820180516001600160e01b038381831617835250505050604051614c8d9190615532565b6000604051808303816000865af19150503d8060008114614cca576040519150601f19603f3d011682016040523d82523d6000602084013e614ccf565b606091505b5091509150818015614cf9575080511580614cf9575080806020019051810190614cf99190615327565b614d155760405162461bcd60e51b815260040161073f90615c12565b505050505050565b600082614d2c57506000612eda565b82820282848281614d3957fe5b04146140e65760405162461bcd60e51b815260040161073f90615a46565b6000808211614d785760405162461bcd60e51b815260040161073f9061596f565b818381614d8157fe5b049392505050565b6000806000614d988585614f08565b509050600080614da9888888614356565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015614de157600080fd5b505afa158015614df5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e199190615441565b506001600160701b031691506001600160701b03169150826001600160a01b0316876001600160a01b031614614e50578082614e53565b81815b90999098509650505050505050565b6000808411614e835760405162461bcd60e51b815260040161073f9061574c565b600083118015614e935750600082115b614eaf5760405162461bcd60e51b815260040161073f90615abc565b6000614ec3856126f263ffffffff614d1d16565b90506000614ed7828563ffffffff614d1d16565b90506000614ef183611e828861271063ffffffff614d1d16565b9050808281614efc57fe5b04979650505050505050565b600080826001600160a01b0316846001600160a01b03161415614f3d5760405162461bcd60e51b815260040161073f90615a03565b826001600160a01b0316846001600160a01b031610614f5d578284614f60565b83835b90925090506001600160a01b038216614f8b5760405162461bcd60e51b815260040161073f90615b69565b9250929050565b6000808411614fb35760405162461bcd60e51b815260040161073f90615842565b600083118015614fc35750600082115b614fdf5760405162461bcd60e51b815260040161073f90615abc565b6000615003612710614ff7868863ffffffff614d1d16565b9063ffffffff614d1d16565b9050600061501d6126f2614ff7868963ffffffff61468016565b905061503a600182848161502d57fe5b049063ffffffff61455c16565b9695505050505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106150855782800160ff198235161785556150b2565b828001600101855582156150b2579182015b828111156150b2578235825591602001919060010190615097565b506150be9291506150c2565b5090565b61272091905b808211156150be57600081556001016150c8565b60008083601f8401126150ed578182fd5b5081356001600160401b03811115615103578182fd5b6020830191508360208083028501011115614f8b57600080fd5b60008083601f84011261512e578182fd5b5081356001600160401b03811115615144578182fd5b602083019150836020828501011115614f8b57600080fd5b60006060828403121561516d578081fd5b50919050565b600060208284031215615184578081fd5b81356140e681615d82565b6000602082840312156151a0578081fd5b81516140e681615d82565b600080604083850312156151bd578081fd5b82356151c881615d82565b946020939093013593505050565b6000806000606084860312156151ea578081fd5b83356151f581615d82565b9250602084013561520581615d82565b929592945050506040919091013590565b60008060006040848603121561522a578283fd5b833561523581615d82565b925060208401356001600160401b0381111561524f578283fd5b61525b8682870161511d565b9497909650939450505050565b6000806000806060858703121561527d578081fd5b843561528881615d82565b935060208501356001600160401b038111156152a2578182fd5b6152ae8782880161511d565b90945092505060408501356152c281615d9a565b939692955090935050565b600080604083850312156152df578182fd5b82356152ea81615d82565b9150602083013561ffff81168114615300578182fd5b809150509250929050565b60006020828403121561531c578081fd5b81356140e681615d9a565b600060208284031215615338578081fd5b81516140e681615d9a565b600060208284031215615354578081fd5b81356001600160401b03811115615369578182fd5b80830160e0818603121561537b578283fd5b949350505050565b60008060008060a08587031215615398578384fd5b6153a2868661515c565b93506060850135925060808501356001600160401b038111156153c3578283fd5b6153cf878288016150dc565b95989497509550505050565b600080600080600060c086880312156153f2578283fd5b6153fc878761515c565b9450606086013593506080860135925060a08601356001600160401b03811115615424578182fd5b615430888289016150dc565b969995985093965092949392505050565b600080600060608486031215615455578081fd5b835161546081615da8565b602085015190935061547181615da8565b604085015190925063ffffffff8116811461548a578182fd5b809150509250925092565b6000602082840312156154a6578081fd5b813561ffff811681146140e6578182fd5b6000602082840312156154c8578081fd5b5051919050565b600081518084526154e7816020860160208601615d56565b601f01601f19169290920160200192915050565b6bffffffffffffffffffffffff19606093841b811682529190921b16601482015260280190565b6000828483379101908152919050565b60008251615544818460208701615d56565b9190910192915050565b600060ff60f81b825260016bffffffffffffffffffffffff198660601b168184015284601584015260358285548381166000811461559357600181146155ae576155e2565b60ff1982168785015260028204607f168701840192506155e2565b600282046155bb89615d4a565b875b828110156155d95781548a8201880152908701906020016155bd565b50508701840192505b509098975050505050505050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0392831681529116602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156156bd578351835292840192918401916001016156a1565b50909695505050505050565b901515815260200190565b6000602082526140e660208301846154cf565b6020808252601f908201527f5472616e7366657248656c7065723a205452414e534645525f4641494c454400604082015260600190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526026908201527f466c6f6f7a526f757465723a20494e53554646494349454e545f494e5055545f604082015265105353d5539560d21b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b602080825260199082015278466c6f6f7a526f757465723a204c4f575f534c49505041474560381b604082015260600190565b60208082526027908201527f466c6f6f7a526f757465723a20494e53554646494349454e545f4f555450555460408201526617d05353d5539560ca1b606082015260800190565b6020808252818101527f466c6f6f7a526f757465723a20494e53554646494349454e545f4f5554505554604082015260600190565b6020808252601a908201527f466c6f6f7a526f757465723a2053454c465f524546455252414c000000000000604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b60208082526023908201527f466c6f6f7a526f757465723a204558434553534956455f494e5055545f414d4f60408201526215539560ea1b606082015260800190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526019908201527808cd8dedef4a4deeae8cae47440929cac82989288bea082a89603b1b604082015260600190565b60208082526023908201527f50616e63616b654c6962726172793a204944454e544943414c5f41444452455360408201526253455360e81b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526023908201527f466c6f6f7a526f757465723a20494e53554646494349454e545f4c495155494460408201526249545960e81b606082015260800190565b6020808252601c908201527f466c6f6f7a526f757465723a20494e56414c49445f464143544f525900000000604082015260600190565b602080825260199082015278466c6f6f7a526f757465723a20494e56414c49445f5241544560381b604082015260600190565b6020808252601c908201527f50616e63616b654c6962726172793a205a45524f5f4144445245535300000000604082015260600190565b602080825260159082015274119b1bdbde949bdd5d195c8e881491559154951151605a1b604082015260600190565b60208082526023908201527f5472616e7366657248656c7065723a204554485f5452414e534645525f46414960408201526213115160ea1b606082015260800190565b60208082526024908201527f5472616e7366657248656c7065723a205452414e534645525f46524f4d5f46416040820152631253115160e21b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b602080825260189082015277466c6f6f7a526f757465723a204143544956455f464f524b60401b604082015260600190565b61ffff91909116815260200190565b90815260200190565b600085825284602083015260018060a01b03841660408301526080606083015261503a60808301846154cf565b6000808335601e19843603018112615d1a578283fd5b808401803592506001600160401b03831115615d34578384fd5b60200192505036819003821315614f8b57600080fd5b60009081526020902090565b60005b83811015615d71578181015183820152602001615d59565b83811115614bc55750506000910152565b6001600160a01b0381168114615d9757600080fd5b50565b8015158114615d9757600080fd5b6001600160701b0381168114615d9757600080fdfea264697066735822122048af43cf298667e9ff1ff52de5179d94d4882cec0f955ed5bd2d66d1844c843d64736f6c63430006060033

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

000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000003e80000000000000000000000007b66162866067d1b0dd6537f0fac445ff7f56c86000000000000000000000000c967387f1dc6d350a3732e69581708462d2afffa000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d

-----Decoded View---------------
Arg [0] : _WETH (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [1] : _swapFee (uint16): 50
Arg [2] : _referralRewardRate (uint16): 1000
Arg [3] : _feeReceiver (address): 0x7b66162866067d1B0dD6537F0faC445Ff7f56c86
Arg [4] : _referralRegistry (address): 0xC967387f1dc6D350a3732e69581708462D2AfFFa
Arg [5] : _zeroEx (address): 0xDef1C0ded9bec7F1a1670819833240f027b25EfF
Arg [6] : _oneInch (address): 0x1111111254fb6c44bAC0beD2854e76F90643097d

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000032
Arg [2] : 00000000000000000000000000000000000000000000000000000000000003e8
Arg [3] : 0000000000000000000000007b66162866067d1b0dd6537f0fac445ff7f56c86
Arg [4] : 000000000000000000000000c967387f1dc6d350a3732e69581708462d2afffa
Arg [5] : 000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff
Arg [6] : 0000000000000000000000001111111254fb6c44bac0bed2854e76f90643097d


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.