ETH Price: $3,251.09 (+3.78%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Swap With Aggreg...217388802025-01-30 17:34:474 hrs ago1738258487IN
0x4d9cDB3F...D2B68220E
0 ETH0.004263816.87640158
Swap With Aggreg...217374672025-01-30 12:51:359 hrs ago1738241495IN
0x4d9cDB3F...D2B68220E
0.035 ETH0.000769123.80970533
Swap With Aggreg...217374592025-01-30 12:49:599 hrs ago1738241399IN
0x4d9cDB3F...D2B68220E
0.034 ETH0.000825453.99372345
Swap With Aggreg...217367582025-01-30 10:28:5912 hrs ago1738232939IN
0x4d9cDB3F...D2B68220E
0.095 ETH0.000613172.39817143
Swap With Aggreg...217360112025-01-30 7:58:1114 hrs ago1738223891IN
0x4d9cDB3F...D2B68220E
0.03 ETH0.000396471.84438942
Swap With Aggreg...217344872025-01-30 2:52:4719 hrs ago1738205567IN
0x4d9cDB3F...D2B68220E
0.01 ETH0.000351351.47354006
Swap With Aggreg...217334532025-01-29 23:25:1123 hrs ago1738193111IN
0x4d9cDB3F...D2B68220E
0.165 ETH0.000698523.49463843
Swap With Aggreg...217334242025-01-29 23:19:1123 hrs ago1738192751IN
0x4d9cDB3F...D2B68220E
0.165 ETH0.000956353.92059463
Swap With Aggreg...217326932025-01-29 20:52:2325 hrs ago1738183943IN
0x4d9cDB3F...D2B68220E
0.060364 ETH0.001458687.43243037
Swap With Aggreg...217323302025-01-29 19:39:1126 hrs ago1738179551IN
0x4d9cDB3F...D2B68220E
0.29 ETH0.001516746.3014734
Swap With Aggreg...217322712025-01-29 19:27:2327 hrs ago1738178843IN
0x4d9cDB3F...D2B68220E
0.05 ETH0.001527267.1
Swap With Aggreg...217319772025-01-29 18:28:1128 hrs ago1738175291IN
0x4d9cDB3F...D2B68220E
0.015 ETH0.00083274.02857051
Swap With Aggreg...217311512025-01-29 15:42:3530 hrs ago1738165355IN
0x4d9cDB3F...D2B68220E
2.23 ETH0.001044515.13459978
Swap With Aggreg...217302392025-01-29 12:38:4733 hrs ago1738154327IN
0x4d9cDB3F...D2B68220E
0.03 ETH0.000690693.21310674
Swap With Aggreg...217286102025-01-29 7:11:2339 hrs ago1738134683IN
0x4d9cDB3F...D2B68220E
0.33 ETH0.000414562.18625229
Swap With Aggreg...217271632025-01-29 2:20:5944 hrs ago1738117259IN
0x4d9cDB3F...D2B68220E
0.004 ETH0.000358342
Swap With Aggreg...217271632025-01-29 2:20:5944 hrs ago1738117259IN
0x4d9cDB3F...D2B68220E
0.057 ETH0.00041342
Swap With Aggreg...217250972025-01-28 19:25:232 days ago1738092323IN
0x4d9cDB3F...D2B68220E
0.33 ETH0.001422946.88451386
Swap With Aggreg...217250822025-01-28 19:22:232 days ago1738092143IN
0x4d9cDB3F...D2B68220E
0.33 ETH0.00155626.70562613
Swap With Aggreg...217250632025-01-28 19:18:352 days ago1738091915IN
0x4d9cDB3F...D2B68220E
0.34 ETH0.001661857.35439537
Swap With Aggreg...217193442025-01-28 0:08:232 days ago1738022903IN
0x4d9cDB3F...D2B68220E
0.02 ETH0.001406346.80417045
Swap With Aggreg...217189822025-01-27 22:55:232 days ago1738018523IN
0x4d9cDB3F...D2B68220E
0.32 ETH0.000955184
Swap With Aggreg...217184082025-01-27 21:00:233 days ago1738011623IN
0x4d9cDB3F...D2B68220E
0.045 ETH0.00215859.04721791
Swap With Aggreg...217178912025-01-27 19:16:473 days ago1738005407IN
0x4d9cDB3F...D2B68220E
0.05 ETH0.001922169
Swap With Aggreg...217154192025-01-27 10:59:233 days ago1737975563IN
0x4d9cDB3F...D2B68220E
0.151 ETH0.0022066310.67552265
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block
From
To
217374672025-01-30 12:51:359 hrs ago1738241495
0x4d9cDB3F...D2B68220E
0.03465 ETH
217374672025-01-30 12:51:359 hrs ago1738241495
0x4d9cDB3F...D2B68220E
0.00035 ETH
217374592025-01-30 12:49:599 hrs ago1738241399
0x4d9cDB3F...D2B68220E
0.03366 ETH
217374592025-01-30 12:49:599 hrs ago1738241399
0x4d9cDB3F...D2B68220E
0.00034 ETH
217367582025-01-30 10:28:5912 hrs ago1738232939
0x4d9cDB3F...D2B68220E
0.09481 ETH
217367582025-01-30 10:28:5912 hrs ago1738232939
0x4d9cDB3F...D2B68220E
0.00019 ETH
217360112025-01-30 7:58:1114 hrs ago1738223891
0x4d9cDB3F...D2B68220E
0.0297 ETH
217360112025-01-30 7:58:1114 hrs ago1738223891
0x4d9cDB3F...D2B68220E
0.0003 ETH
217344872025-01-30 2:52:4719 hrs ago1738205567
0x4d9cDB3F...D2B68220E
0.00998 ETH
217344872025-01-30 2:52:4719 hrs ago1738205567
0x4d9cDB3F...D2B68220E
0.00002 ETH
217334532025-01-29 23:25:1123 hrs ago1738193111
0x4d9cDB3F...D2B68220E
0.16335 ETH
217334532025-01-29 23:25:1123 hrs ago1738193111
0x4d9cDB3F...D2B68220E
0.00165 ETH
217334242025-01-29 23:19:1123 hrs ago1738192751
0x4d9cDB3F...D2B68220E
0.16335 ETH
217334242025-01-29 23:19:1123 hrs ago1738192751
0x4d9cDB3F...D2B68220E
0.00165 ETH
217326932025-01-29 20:52:2325 hrs ago1738183943
0x4d9cDB3F...D2B68220E
0.05976036 ETH
217326932025-01-29 20:52:2325 hrs ago1738183943
0x4d9cDB3F...D2B68220E
0.00060364 ETH
217323302025-01-29 19:39:1126 hrs ago1738179551
0x4d9cDB3F...D2B68220E
0.28942 ETH
217323302025-01-29 19:39:1126 hrs ago1738179551
0x4d9cDB3F...D2B68220E
0.00058 ETH
217322712025-01-29 19:27:2327 hrs ago1738178843
0x4d9cDB3F...D2B68220E
0.0499 ETH
217322712025-01-29 19:27:2327 hrs ago1738178843
0x4d9cDB3F...D2B68220E
0.0001 ETH
217319772025-01-29 18:28:1128 hrs ago1738175291
0x4d9cDB3F...D2B68220E
0.01485 ETH
217319772025-01-29 18:28:1128 hrs ago1738175291
0x4d9cDB3F...D2B68220E
0.00015 ETH
217311512025-01-29 15:42:3530 hrs ago1738165355
0x4d9cDB3F...D2B68220E
2.22554 ETH
217311512025-01-29 15:42:3530 hrs ago1738165355
0x4d9cDB3F...D2B68220E
0.00446 ETH
217302392025-01-29 12:38:4733 hrs ago1738154327
0x4d9cDB3F...D2B68220E
0.0297 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SwitchV2

Compiler Version
v0.8.22+commit.4fc1097e

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 21 : SwitchV2.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

import "../core/ISwitchView.sol";
import "../core/SwitchRoot.sol";
import "../interfaces/ISwitchEvent.sol";
import "../interfaces/IFeeCollector.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "../lib/DataTypes.sol";
import "../core/Allowlist.sol";

contract SwitchV2 is Ownable, SwitchRoot, ReentrancyGuard, OnChainAllowList {
    using UniswapExchangeLib for IUniswapExchange;
    using UniversalERC20 for IERC20;
    using SafeERC20 for IERC20;

    ISwitchView public switchView;
    ISwitchEvent public switchEvent;
    address public reward;

    address public feeCollector;
    uint256 public defaultSwingCut = 1500; // swing takes a cut of 15% from partner fee by default

    uint256 public constant FEE_BASE = 10000;

    struct SwapArgs {
        IERC20 fromToken;
        IERC20 destToken;
        uint256 amount;
        uint256 expectedReturn;
        uint256 minReturn;
        address partner;
        uint256 partnerFeeRate;
        address recipient;
        uint256[] distribution;
    }

    event RewardSet(address reward);
    event FeeCollectorSet(address feeCollector);
    event DefaultSwingCutSet(uint256 defaultSwingCut);
    event SwitchEventSet(ISwitchEvent switchEvent);

    

    constructor(
        address _weth,
        address _otherToken,
        uint256 _pathCount,
        uint256 _pathSplit,
        address[] memory _factories,
        address _switchViewAddress,
        address _switchEventAddress,
        address _feeCollector
    ) SwitchRoot(_weth, _otherToken, _pathCount, _pathSplit, _factories)
        public
    {
        switchView = ISwitchView(_switchViewAddress);
        switchEvent = ISwitchEvent(_switchEventAddress);
        feeCollector = _feeCollector;
        reward = msg.sender;
    }

    fallback() external payable {
        // solium-disable-next-line security/no-tx-origin
        require(msg.sender != tx.origin);
    }

    function setReward(address _reward) external onlyOwner {
        reward = _reward;
        emit RewardSet(_reward);
    }

    function setFeeCollector(address _feeCollector) external onlyOwner {
        feeCollector = _feeCollector;
        emit FeeCollectorSet(_feeCollector);
    }


    function setDefaultSwingCut(uint256 _defaultSwingCut) external onlyOwner {
        defaultSwingCut = _defaultSwingCut;
        emit DefaultSwingCutSet(_defaultSwingCut);
    }

    function setSwitchEvent(ISwitchEvent _switchEvent) external onlyOwner {
        switchEvent = _switchEvent;
        emit SwitchEventSet(_switchEvent);
    }


    function getTokenBalance(address token) external view returns(uint256 amount) {
        amount = IERC20(token).universalBalanceOf(address(this));
    }

    function transferToken(address token, uint256 amount, address recipient) external onlyOwner {
        IERC20(token).universalTransfer(recipient, amount);
    }

    function getExpectedReturn(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        uint256 parts
    )
        public
        override
        view
        returns (
            uint256 returnAmount,
            uint256[] memory distribution
        )
    {
        (returnAmount, distribution) = switchView.getExpectedReturn(fromToken, destToken, amount, parts);
    }

    function swap(
        SwapArgs calldata swapArgs
    )
        public
        payable
        nonReentrant
        returns (uint256 returnAmount)
    {
        require(swapArgs.expectedReturn >= swapArgs.minReturn, "expectedReturn must be equal or larger than minReturn");
        if (swapArgs.fromToken == swapArgs.destToken) {
            revert("it's not allowed to swap with same token");
        }

        uint256 parts = 0;
        uint256 lastNonZeroIndex = 0;
        for (uint i = 0; i < swapArgs.distribution.length; i++) {
            if (swapArgs.distribution[i] > 0) {
                parts += swapArgs.distribution[i];
                lastNonZeroIndex = i;
            }
        }

        if (parts == 0) {
            if (swapArgs.fromToken.isETH()) {
                payable(msg.sender).transfer(msg.value);
                return msg.value;
            }
            return swapArgs.amount;
        }

        swapArgs.fromToken.universalTransferFrom(msg.sender, address(this), swapArgs.amount);
        uint256 amountAfterFee = _getAmountAfterFee(swapArgs.fromToken, swapArgs.amount, swapArgs.partner, swapArgs.partnerFeeRate);
        returnAmount = _swapInternalForSingleSwap(swapArgs.distribution, amountAfterFee, parts, lastNonZeroIndex, swapArgs.fromToken, swapArgs.destToken);
        if (returnAmount > 0) {
            require(returnAmount >= swapArgs.minReturn, "Switch: Return amount was not enough");

            if (returnAmount > swapArgs.expectedReturn) {
                swapArgs.destToken.universalTransfer(swapArgs.recipient, swapArgs.expectedReturn);
                swapArgs.destToken.universalTransfer(reward, returnAmount - swapArgs.expectedReturn);
                switchEvent.emitSwapped(msg.sender, swapArgs.recipient, swapArgs.fromToken, swapArgs.destToken, swapArgs.amount, swapArgs.expectedReturn, returnAmount - swapArgs.expectedReturn);
            } else {
                swapArgs.destToken.universalTransfer(swapArgs.recipient, returnAmount);
                switchEvent.emitSwapped(msg.sender, swapArgs.recipient, swapArgs.fromToken, swapArgs.destToken, swapArgs.amount, returnAmount, 0);
            }
        } else {
            if (swapArgs.fromToken.universalBalanceOf(address(this)) > swapArgs.amount) {
                swapArgs.fromToken.universalTransfer(msg.sender, swapArgs.amount);
            } else {
                swapArgs.fromToken.universalTransfer(msg.sender, swapArgs.fromToken.universalBalanceOf(address(this)));
            }
        }
    }

    function getFeeInfo(
        uint256 amount,
        address partner,
        uint256 partnerFeeRate
    )
        public
        view
        returns (
            uint256 partnerFee,
            uint256 remainAmount
        )
    {
        partnerFee = partnerFeeRate * amount / FEE_BASE;
        remainAmount = amount - partnerFee;
    }

    function swapWithAggregator(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        address partner,
        uint256 partnerFeeRate,
        address recipient,
        bytes calldata aggregatorInfo
    )
        public
        payable
        nonReentrant
    {
        if (fromToken == destToken) {
            revert("it's not allowed to swap with same token");
        }
        fromToken.universalTransferFrom(msg.sender, address(this), amount);
        uint256 amountAfterFee = _getAmountAfterFee(IERC20(fromToken), amount, partner, partnerFeeRate);
        _swapInternalWithAggregator(fromToken, destToken, amountAfterFee, recipient, aggregatorInfo);
    }

    
    function _swapInternalWithAggregator(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        address recipient,
        bytes memory aggregatorInfo
    )
        internal
        returns (
            uint256 totalAmount
        )
    {
        if (fromToken == destToken) {
            revert("it's not allowed to swap with same token");
        }

        DataTypes.FullSwapData memory fullSwapData = abi.decode(
                    aggregatorInfo,
                    (DataTypes.FullSwapData));
        
        _callAggregator(fromToken, amount, fullSwapData);
        totalAmount = destToken.universalBalanceOf(address(this));
        if (totalAmount > 0) {
            destToken.universalTransfer(recipient, totalAmount);
        }
        switchEvent.emitSwapped(msg.sender, recipient, fromToken, destToken, amount, totalAmount, 0);
    }

    function _callAggregator(
        IERC20 token,
        uint256 amount,
        DataTypes.FullSwapData memory swapData 
    )
        internal
        onlyInAllowlist(swapData.spender) onlyInAllowlist(swapData.swapContract)
    {
        uint256 ethAmountToTransfert = 0;
        if (token.isETH()) {
            require(address(this).balance >= amount, "ETH balance is insufficient");
            ethAmountToTransfert = amount;
        } else {
            token.universalApprove(swapData.spender, amount);
        }

        (bool success,) = swapData.swapContract.call{ value: ethAmountToTransfert }(swapData.swapData);
        require(success, "Dex Aggregator execution failed");
    }

    function _swapInternalForSingleSwap(
        uint256[] memory distribution,
        uint256 amount,
        uint256 parts,
        uint256 lastNonZeroIndex,
        IERC20 fromToken,
        IERC20 destToken
    )
        internal
        returns (
            uint256 totalAmount
        )
    {
        require(distribution.length <= dexCount*pathCount, "Switch: Distribution array should not exceed factories array size");

        uint256 remainingAmount = amount;
        uint256 swappedAmount = 0;
        for (uint i = 0; i < distribution.length; i++) {
            if (distribution[i] == 0) {
                continue;
            }
            uint256 swapAmount = amount * distribution[i] / parts;
            if (i == lastNonZeroIndex) {
                swapAmount = remainingAmount;
            }
            remainingAmount -= swapAmount;
            if (i % pathCount == 0) {
                swappedAmount = _swap(fromToken, destToken, swapAmount, IUniswapFactory(factories[i/pathCount]));
            } else if (i % pathCount == 1) {
                swappedAmount = _swapETH(fromToken, destToken, swapAmount, IUniswapFactory(factories[i/pathCount]));
            } else {
                swappedAmount = _swapOtherToken(fromToken, destToken, swapAmount, IUniswapFactory(factories[i/pathCount]));
            }
            totalAmount += swappedAmount;
        }
    }

    function _getAmountAfterFee(
        IERC20 token,
        uint256 amount,
        address partner,
        uint256 partnerFeeRate
    )
        internal
        returns (
            uint256 amountAfterFee
        )
    {
        amountAfterFee = amount;
        if (partnerFeeRate > 0) {
            uint256 swingCut = IFeeCollector(feeCollector).getPartnerSwingCut(partner);
            if (swingCut == 0) swingCut = defaultSwingCut;
            uint256 swingFee = partnerFeeRate * amount * swingCut / (FEE_BASE * FEE_BASE);
            uint256 partnerFee = partnerFeeRate * amount / FEE_BASE - swingFee;
            if (IERC20(token).isETH()) {
                IFeeCollector(feeCollector).collectTokenFees{ value: partnerFee + swingFee }(address(token), partnerFee, swingFee, partner);
            } else {
                IERC20(token).safeApprove(feeCollector, 0);
                IERC20(token).safeApprove(feeCollector, partnerFee + swingFee);
                IFeeCollector(feeCollector).collectTokenFees(address(token), partnerFee, swingFee, partner);
            }
            amountAfterFee = amount - partnerFeeRate * amount / FEE_BASE;
        }
    }

    // Swap helpers
    function _swapInternal(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        IUniswapFactory factory
    )
        internal
        returns (
            uint256 returnAmount
        )
    {
        if (fromToken.isETH()) {
            weth.deposit{value: amount}();
        }

        IERC20 fromTokenReal = fromToken.isETH() ? weth : fromToken;
        IERC20 toTokenReal = destToken.isETH() ? weth : destToken;
        IUniswapExchange exchange = factory.getPair(fromTokenReal, toTokenReal);
        bool needSync;
        bool needSkim;
        (returnAmount, needSync, needSkim) = exchange.getReturn(fromTokenReal, toTokenReal, amount);
        if (needSync) {
            exchange.sync();
        } else if (needSkim) {
            exchange.skim(0x46Fd07da395799F113a7584563b8cB886F33c2bc);
        }

        fromTokenReal.universalTransfer(address(exchange), amount);
        if (uint160(address(fromTokenReal)) < uint160(address(toTokenReal))) {
            exchange.swap(0, returnAmount, address(this), "");
        } else {
            exchange.swap(returnAmount, 0, address(this), "");
        }

        if (destToken.isETH()) {
            weth.withdraw(weth.balanceOf(address(this)));
        }
    }

    function _swapOverMid(
        IERC20 fromToken,
        IERC20 midToken,
        IERC20 destToken,
        uint256 amount,
        IUniswapFactory factory
    )
        internal
        returns (
            uint256 returnAmount
        )
    {
        returnAmount = _swapInternal(
            midToken,
            destToken,
            _swapInternal(
                fromToken,
                midToken,
                amount,
                factory
            ),
            factory
        );
    }

    function _swap(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        IUniswapFactory factory
    )
        internal
        returns (
            uint256 returnAmount
        )
    {
        returnAmount = _swapInternal(
            fromToken,
            destToken,
            amount,
            factory
        );
    }

    function _swapETH(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        IUniswapFactory factory
    )
        internal
        returns (
            uint256 returnAmount
        )
    {
        returnAmount = _swapOverMid(
            fromToken,
            weth,
            destToken,
            amount,
            factory
        );
    }

    function _swapOtherToken(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        IUniswapFactory factory
    )
        internal
        returns (
            uint256 returnAmount
        )
    {
        returnAmount = _swapOverMid(
            fromToken,
            otherToken,
            destToken,
            amount,
            factory
        );
    }

}

File 2 of 21 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^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() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(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");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 3 of 21 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^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() {
        _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 making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}

File 4 of 21 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 5 of 21 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

    /**
     * @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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool);
}

File 6 of 21 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

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

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 7 of 21 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 8 of 21 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^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 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) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 9 of 21 : Allowlist.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

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

contract OnChainAllowList is Ownable {

    mapping(address => bool) public allowlist;

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyInAllowlist(address _addresses) {
        _checkAllowlist(_addresses);
        _;
    }

    /**
     * @notice Add to allowlist
     */
    function addToAllowlist(address address_) external onlyOwner
    {
        allowlist[address_] = true;
    }

    /**
     * @notice Add to allowlist in batch
     */
    function addToAllowlistBatch(address[] calldata addresses) external onlyOwner
    {
        for (uint i = 0; i < addresses.length; i++) {
            allowlist[addresses[i]] = true;
        }
    }

    /**
     * @notice Remove from allowlist
     */
    function removeFromAllowlist(address address_) external onlyOwner
    {
        delete allowlist[address_];
    }

    /**
     * @notice Remove from allowlist in batch
     */
    function removeFromAllowlistBatch(address[] calldata addresses) external onlyOwner
    {
        for (uint i = 0; i < addresses.length; i++) {
            delete allowlist[addresses[i]];
        }
    }

    /**
     * @notice Function with allowlist 
     */
    function addressInAllowlist(address address_) external view returns(bool)
    {
        return allowlist[address_];
    }

    /**
     * @dev Throws if address is not in allowlist
     */
    function _checkAllowlist(address address_) internal view virtual {
        require(allowlist[address_], "Address is not in allowlist");
    }

}

File 10 of 21 : ISwitchView.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

import "../interfaces/IUniswapFactory.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

abstract contract ISwitchView {

    struct ReturnArgs {
        IERC20 fromToken;
        IERC20 destToken;
        uint256 amount;
        uint256 parts;
    }

    struct CalculateArgs {
        IERC20 fromToken;
        IERC20 destToken;
        IUniswapFactory factory;
        uint256 amount;
        uint256 parts;
    }

    function getExpectedReturn(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        uint256 parts
    )
        public
        virtual
        view
        returns (
            uint256 returnAmount,
            uint256[] memory distribution
        );
}

File 11 of 21 : IWETH.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

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

abstract contract IWETH is IERC20 {
    function deposit() external virtual payable;
    function withdraw(uint256 amount) virtual external;
}

File 12 of 21 : SwitchRoot.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

import "./ISwitchView.sol";
import "./IWETH.sol";
import "../lib/DisableFlags.sol";
import "../lib/UniversalERC20.sol";
import "../interfaces/IUniswapFactory.sol";
import "../lib/UniswapExchangeLib.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

abstract contract SwitchRoot is Ownable, ISwitchView {
    using DisableFlags for uint256;
    using UniversalERC20 for IERC20;
    using UniversalERC20 for IWETH;
    using UniswapExchangeLib for IUniswapExchange;

    address public ETH_ADDRESS = address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
    address public ZERO_ADDRESS = address(0);

    uint256 public dexCount;
    uint256 public pathCount;
    uint256 public pathSplit;
    IWETH public weth; // chain's native token
    IWETH public otherToken; //could be weth on a non-eth chain or other mid token(like busd)

    address[] public factories;

    int256 internal constant VERY_NEGATIVE_VALUE = -1e72;

    constructor(address _weth, address _otherToken, uint256 _pathCount, uint256 _pathSplit, address[] memory _factories) {
        weth = IWETH(_weth);
        otherToken = IWETH(_otherToken);
        pathCount = _pathCount;
        pathSplit = _pathSplit;
        dexCount = _factories.length;
        for (uint256 i = 0; i < _factories.length; i++) {
            factories.push(_factories[i]);
        }
    }

    event WETHSet(address _weth);
    event OtherTokenSet(address _otherToken);
    event PathCountSet(uint256 _pathCount);
    event PathSplitSet(uint256 _pathSplit);
    event FactoriesSet(address[] _factories);

    function setWETH(address _weth) external onlyOwner {
        weth = IWETH(_weth);
        emit WETHSet(_weth);
    }

    function setOtherToken(address _otherToken) external onlyOwner {
        otherToken = IWETH(_otherToken);
        emit OtherTokenSet(_otherToken);
    }

    function setPathCount(uint256 _pathCount) external onlyOwner {
        pathCount = _pathCount;
        emit PathCountSet(_pathCount);
    }

    function setPathSplit(uint256 _pathSplit) external onlyOwner {
        pathSplit = _pathSplit;
        emit PathSplitSet(_pathSplit);
    }

    function setFactories(address[] memory _factories) external onlyOwner {
        dexCount += _factories.length;
        for (uint256 i = 0; i < _factories.length; i++) {
            factories.push(_factories[i]);
        }
        emit FactoriesSet(_factories);
    }

    function _findBestDistribution(
        uint256 s,                // parts
        int256[][] memory amounts // exchangesReturns
    )
        internal
        view
        returns (
            int256 returnAmount,
            uint256[] memory distribution
        )
    {
        uint256 n = amounts.length;

        int256[][] memory answer = new int256[][](n); // int[n][s+1]
        uint256[][] memory parent = new uint256[][](n); // int[n][s+1]

        for (uint i = 0; i < n; i++) {
            answer[i] = new int256[](s + 1);
            parent[i] = new uint256[](s + 1);
        }

        for (uint j = 0; j <= s; j++) {
            answer[0][j] = amounts[0][j];
            for (uint i = 1; i < n; i++) {
                answer[i][j] = -1e72;
            }
            parent[0][j] = 0;
        }

        for (uint i = 1; i < n; i++) {
            for (uint j = 0; j <= s; j++) {
                answer[i][j] = answer[i - 1][j];
                parent[i][j] = j;

                for (uint k = 1; k <= j; k++) {
                    if (answer[i - 1][j - k] + amounts[i][k] > answer[i][j]) {
                        answer[i][j] = answer[i - 1][j - k] + amounts[i][k];
                        parent[i][j] = j - k;
                    }
                }
            }
        }

        distribution = new uint256[](dexCount*pathCount*pathSplit);

        uint256 partsLeft = s;
        unchecked {
            for (uint curExchange = n - 1; partsLeft > 0; curExchange--) {
                distribution[curExchange] = partsLeft - parent[curExchange][partsLeft];
                partsLeft = parent[curExchange][partsLeft];
            }
        }

        returnAmount = (answer[n - 1][s] == VERY_NEGATIVE_VALUE) ? int256(0) : answer[n - 1][s];
    }

    function _linearInterpolation(
        uint256 value,
        uint256 parts
    )
        internal
        pure
        returns (uint256[] memory rets)
    {
        rets = new uint256[](parts);
        for (uint i = 0; i < parts; i++) {
            rets[i] = value * (i + 1) / parts;
        }
    }

    function _tokensEqual(
        IERC20 tokenA,
        IERC20 tokenB
    )
        internal
        pure
        returns (bool)
    {
        return ((tokenA.isETH() && tokenB.isETH()) || tokenA == tokenB);
    }

    /**
     * @notice Occurred when msg.sender does not have permission to call the operation
     */
    error Forbidden();
}

File 13 of 21 : IFeeCollector.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

interface IFeeCollector {
    function collectTokenFees(
        address tokenAddress,
        uint256 partnerFee,
        uint256 swingFee,
        address partnerAddress
    ) payable external;
    function getPartnerSwingCut(address partnerAddress) external view returns (uint256);
}

File 14 of 21 : ISwitchEvent.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../lib/DataTypes.sol";

interface ISwitchEvent {
    function emitSwapped(
        address from,
        address recipient,
        IERC20 fromToken,
        IERC20 destToken,
        uint256 fromAmount,
        uint256 destAmount,
        uint256 reward
    ) external;

    function emitParaswapSwapped(
        address from,
        IERC20 fromToken,
        uint256 fromAmount
    ) external;

    function emitCrosschainSwapRequest(
        bytes32 id,
        bytes32 bridgeTransferId,
        bytes32 bridge, // bridge slug
        address from, // user address
        address fromToken, // source token on sending chain
        address bridgeToken, // bridge token on sending chain
        address destToken, // dest token on receiving chain
        uint256 fromAmount, // source token amount on sending chain
        uint256 bridgeAmount, // swapped amount on sending chain
        uint256 dstAmount, // estimated amount of dest token on receiving chain
        DataTypes.SwapStatus status
    ) external;

    function emitCrosschainContractCallRequest(
        bytes32 id,
        bytes32 bridgeTransferId,
        bytes32 bridge, // bridge slug
        address from, // user address
        address toContractAddress, // The address of the contract to interact with
        address toApprovalAddress, // the approval address for contract call
        address fromToken, // source token on sending chain
        address callToken, // contract call token on receiving chain
        uint256 fromAmount, // source token amount on sending chain
        uint256 estimatedCallAmount, // estimated amount of contract call token on receiving chain
        DataTypes.ContractCallStatus status
    ) external;

    function emitCrosschainSwapDone(
        bytes32 id,
        bytes32 bridge,
        address from, // user address
        address bridgeToken, // source token on receiving chain
        address destToken, // dest token on receiving chain
        uint256 bridgeAmount, // bridge token amount on receiving chain
        uint256 destAmount, //dest token amount on receiving chain
        DataTypes.SwapStatus status
    ) external;

    function emitCrosschainContractCallDone(
        bytes32 id,
        bytes32 bridge,
        address from, // user address
        address toContractAddress, // The address of the contract to interact with
        address toApprovalAddress, // the approval address for contract call
        address bridgeToken, // source token on receiving chain
        address callToken, // call token on receiving chain
        uint256 bridgeAmount, // bridge token amount on receiving chain
        uint256 estimatedCallAmount, //dest token amount on receiving chain
        DataTypes.ContractCallStatus status
    ) external;

    function emitSingleChainContractCallDone(
        address from, // user address
        address toContractAddress, // The address of the contract to interact with
        address toApprovalAddress, // the approval address for contract call
        address fromToken, // source token on receiving chain
        address callToken, // call token on receiving chain
        uint256 fromAmount, // from token amount on receiving chain
        uint256 callAmount, //dest token amount on receiving chain
        DataTypes.ContractCallStatus status
    ) external;
}

File 15 of 21 : IUniswapExchange.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

interface IUniswapExchange {
    function getReserves() external view returns(uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;
}

File 16 of 21 : IUniswapFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./IUniswapExchange.sol";

interface IUniswapFactory {
    function getPair(IERC20 tokenA, IERC20 tokenB) external view returns (IUniswapExchange pair);
}

File 17 of 21 : DataTypes.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;
/**
 * @title DataTypes
 * @dev Definition of shared types
 */
library DataTypes {
    /// @notice Type for representing a swapping status type
    enum SwapStatus {
        Null,
        Succeeded,
        Failed,
        Fallback
    }

    enum ContractCallStatus {
        Null,
        Succeeded,
        Failed,
        Fallback
    }

    /// @notice Type for representing a paraswap usage status
    enum ParaswapUsageStatus {
        None,
        OnSrcChain,
        OnDestChain,
        Both
    }

    /// @notice Split Swap params
    struct SplitSwapInfo {
        uint256 amount;
        address swapContract;
        address spender;
        bytes swapData;
    }

    /// @notice Swap params
    struct SwapInfo {
        address srcToken;
        address dstToken;
        bytes aggregatorInfo; // Dex aggregation swap info
    }

    struct ContractCallInfo {
        address toContractAddress; // The address of the contract to interact with.
        address toApprovalAddress; // the approval address for contract call
        address contractOutputsToken; // Some contract interactions will output a token (e.g. staking)
        uint32 toContractGasLimit; // The estimated gas used by the destination call.
        bytes toContractCallData; // The callData to be sent to the contract for the interaction on the destination chain.
    }

    struct ContractCallRequest {
        bytes32 id;
        bytes32 bridge;
        address srcToken;
        address bridgeToken;
        address callToken;
        address recipient;
        uint256 srcAmount;
        uint256 bridgeDstAmount;
        uint256 estimatedCallAmount;
        uint256[] dstDistribution;
        bytes dstParaswapData;
        ContractCallInfo callInfo;
        ParaswapUsageStatus paraswapUsageStatus;
    }

    struct StargateContractCallRequest {
        bytes32 id;
        bytes32 bridge;
        address srcToken;
        address bridgeToken;
        address callToken;
        address recipient;
        uint256 srcAmount;
        uint256 bridgeDstAmount;
        uint256 estimatedCallAmount;
        uint256[] dstDistribution;
        ContractCallInfo callInfo;
        bytes dstAggregatorInfo; // Dex aggregation swap info
    }

    /// @notice Dex Aggregator Swap Info
    struct FullSwapData {
        address swapContract;
        address spender;
        bytes swapData;
    }
}

File 18 of 21 : DisableFlags.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

library DisableFlags {
    function check(
        uint256 flags,
        uint256 flag
    )
        internal
        pure
        returns (bool)
    {
        return (flags & flag) != 0;
    }
}

File 19 of 21 : Math.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

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

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

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

File 20 of 21 : UniswapExchangeLib.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

import "../interfaces/IUniswapExchange.sol";
import "./Math.sol";
import "./UniversalERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

library UniswapExchangeLib {
    using Math for uint256;
    using UniversalERC20 for IERC20;

    function getReturn(
        IUniswapExchange exchange,
        IERC20 fromToken,
        IERC20 destToken,
        uint amountIn
    )
        internal
        view
        returns (uint256 result, bool needSync, bool needSkim)
    {
        uint256 reserveIn = fromToken.universalBalanceOf(address(exchange));
        uint256 reserveOut = destToken.universalBalanceOf(address(exchange));
        (uint112 reserve0, uint112 reserve1,) = exchange.getReserves();
        if (fromToken > destToken) {
            (reserve0, reserve1) = (reserve1, reserve0);
        }
        needSync = (reserveIn < reserve0 || reserveOut < reserve1);
        needSkim = !needSync && (reserveIn > reserve0 || reserveOut > reserve1);

        uint256 amountInWithFee = amountIn * 997;
        uint256 numerator = amountInWithFee * Math.min(reserveOut, reserve1);
        uint256 denominator = Math.min(reserveIn, reserve0) * 1000 + amountInWithFee;
        result = (denominator == 0) ? 0 : numerator / denominator;
    }
}

File 21 of 21 : UniversalERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

library UniversalERC20 {

    using SafeERC20 for IERC20;

    address private constant ZERO_ADDRESS = address(0x0000000000000000000000000000000000000000);
    address private constant ETH_ADDRESS = address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);

    function universalTransfer(
        IERC20 token,
        address to,
        uint256 amount
    )
        internal
        returns (bool)
    {
        if (amount == 0) {
            return true;
        }
        if (isETH(token)) {
            payable(to).transfer(amount);
            return true;
        } else {
            token.safeTransfer(to, amount);
            return true;
        }
    }

    function universalTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 amount
    )
        internal
    {
        if (amount == 0) {
            return;
        }

        if (isETH(token)) {
            require(from == msg.sender && msg.value >= amount, "Wrong useage of ETH.universalTransferFrom()");
            if (to != address(this)) {
                payable(to).transfer(amount);
            }
            // commented following lines for passing celer fee properly.
//            if (msg.value > amount) {
//                payable(msg.sender).transfer(msg.value - amount);
//            }
        } else {
            token.safeTransferFrom(from, to, amount);
        }
    }

    function universalTransferFromSenderToThis(
        IERC20 token,
        uint256 amount
    )
        internal
    {
        if (amount == 0) {
            return;
        }

        if (isETH(token)) {
            if (msg.value > amount) {
                // Return remainder if exist
                payable(msg.sender).transfer(msg.value - amount);
            }
        } else {
            token.safeTransferFrom(msg.sender, address(this), amount);
        }
    }

    function universalApprove(
        IERC20 token,
        address to,
        uint256 amount
    )
        internal
    {
        if (!isETH(token)) {
            if (amount == 0) {
                token.safeApprove(to, 0);
                return;
            }

            uint256 approvedAmount = token.allowance(address(this), to);
            if (approvedAmount > 0) {
                token.safeApprove(to, 0);
            }
            token.safeApprove(to, amount);
        }
    }

    function universalBalanceOf(IERC20 token, address who) internal view returns (uint256) {
        if (isETH(token)) {
            return who.balance;
        } else {
            return token.balanceOf(who);
        }
    }

    function isETH(IERC20 token) internal pure returns(bool) {
        return (address(token) == address(ZERO_ADDRESS) || address(token) == address(ETH_ADDRESS));
    }

    // function notExist(IERC20 token) internal pure returns(bool) {
    //     return (address(token) == address(-1));
    // }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_otherToken","type":"address"},{"internalType":"uint256","name":"_pathCount","type":"uint256"},{"internalType":"uint256","name":"_pathSplit","type":"uint256"},{"internalType":"address[]","name":"_factories","type":"address[]"},{"internalType":"address","name":"_switchViewAddress","type":"address"},{"internalType":"address","name":"_switchEventAddress","type":"address"},{"internalType":"address","name":"_feeCollector","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"Forbidden","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"defaultSwingCut","type":"uint256"}],"name":"DefaultSwingCutSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"_factories","type":"address[]"}],"name":"FactoriesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"feeCollector","type":"address"}],"name":"FeeCollectorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_otherToken","type":"address"}],"name":"OtherTokenSet","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":"uint256","name":"_pathCount","type":"uint256"}],"name":"PathCountSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_pathSplit","type":"uint256"}],"name":"PathSplitSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"reward","type":"address"}],"name":"RewardSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ISwitchEvent","name":"switchEvent","type":"address"}],"name":"SwitchEventSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_weth","type":"address"}],"name":"WETHSet","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"ETH_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_BASE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ZERO_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"address_","type":"address"}],"name":"addToAllowlist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"}],"name":"addToAllowlistBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"address_","type":"address"}],"name":"addressInAllowlist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"allowlist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultSwingCut","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dexCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"factories","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"destToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"parts","type":"uint256"}],"name":"getExpectedReturn","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"partner","type":"address"},{"internalType":"uint256","name":"partnerFeeRate","type":"uint256"}],"name":"getFeeInfo","outputs":[{"internalType":"uint256","name":"partnerFee","type":"uint256"},{"internalType":"uint256","name":"remainAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenBalance","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"otherToken","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pathCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pathSplit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"address_","type":"address"}],"name":"removeFromAllowlist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"addresses","type":"address[]"}],"name":"removeFromAllowlistBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reward","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_defaultSwingCut","type":"uint256"}],"name":"setDefaultSwingCut","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_factories","type":"address[]"}],"name":"setFactories","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeCollector","type":"address"}],"name":"setFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_otherToken","type":"address"}],"name":"setOtherToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pathCount","type":"uint256"}],"name":"setPathCount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pathSplit","type":"uint256"}],"name":"setPathSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_reward","type":"address"}],"name":"setReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISwitchEvent","name":"_switchEvent","type":"address"}],"name":"setSwitchEvent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_weth","type":"address"}],"name":"setWETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"destToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expectedReturn","type":"uint256"},{"internalType":"uint256","name":"minReturn","type":"uint256"},{"internalType":"address","name":"partner","type":"address"},{"internalType":"uint256","name":"partnerFeeRate","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"}],"internalType":"struct SwitchV2.SwapArgs","name":"swapArgs","type":"tuple"}],"name":"swap","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"destToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"partner","type":"address"},{"internalType":"uint256","name":"partnerFeeRate","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes","name":"aggregatorInfo","type":"bytes"}],"name":"swapWithAggregator","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"switchEvent","outputs":[{"internalType":"contract ISwitchEvent","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"switchView","outputs":[{"internalType":"contract ISwitchView","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"transferToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6080604052600180546001600160a01b031990811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee179091556002805490911690556105dc600f553480156200004957600080fd5b506040516200350f3803806200350f8339810160408190526200006c9162000209565b87878787876200007c3362000186565b600680546001600160a01b038088166001600160a01b031992831617909255600780549287169290911691909117905560048390556005829055805160035560005b815181101562000125576008828281518110620000df57620000df62000350565b60209081029190910181015182546001808201855560009485529290932090920180546001600160a01b0319166001600160a01b039093169290921790915501620000be565b505060016009555050600b80546001600160a01b039687166001600160a01b031991821617909155600c8054958716958216959095179094555050600e80549190931690821617909155600d80549091163317905550620003669350505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620001ee57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600080600080600080600080610100898b0312156200022757600080fd5b6200023289620001d6565b9750602062000243818b01620001d6565b60408b015160608c015160808d0151929a5090985096506001600160401b03808211156200027057600080fd5b818c0191508c601f8301126200028557600080fd5b8151818111156200029a576200029a620001f3565b8060051b604051601f19603f83011681018181108582111715620002c257620002c2620001f3565b60405291825284820192508381018501918f831115620002e157600080fd5b938501935b828510156200030a57620002fa85620001d6565b84529385019392850192620002e6565b8099505050505050506200032160a08a01620001d6565b92506200033160c08a01620001d6565b91506200034160e08a01620001d6565b90509295985092959890939650565b634e487b7160e01b600052603260045260246000fd5b61319980620003766000396000f3fe6080604052600436106102255760003560e01c80638da5cb5b11610123578063c93d732d116100ab578063ea15afc31161006f578063ea15afc31461068b578063ecefc705146106ab578063f2fde38b146106c1578063f640d508146106e1578063f8e86ece1461070157610225565b8063c93d732d146105ca578063d08508bf146105dd578063d6821ed8146105fd578063e5932c4014610632578063e772ff371461065257610225565b8063a7cd52cb116100f2578063a7cd52cb14610514578063a85f329814610554578063ab30469514610574578063b4c76fe01461058a578063c415b95c146105aa57610225565b80638da5cb5b146104a057806390f3f208146104be578063a42dce80146104d4578063a734f06e146104f457610225565b806353fd7bf1116101b15780636076a0b4116101755780636076a0b4146104145780636184305c14610442578063672383c414610455578063715018a6146104755780638c821e901461048a57610225565b806353fd7bf11461037457806356230573146103945780635b769f3c146103b45780635c3d258f146103d45780635da93d7e146103f457610225565b80633fc8cef3116101f85780633fc8cef3146102de578063433b3c05146102fe5780634399fa561461031e57806352b721f81461033e578063538ba4f91461035457610225565b8063228cb7331461023357806323a9495e1461027057806331428a87146102905780633aecd0e3146102b0575b32330361023157600080fd5b005b34801561023f57600080fd5b50600d54610253906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561027c57600080fd5b5061023161028b3660046128e3565b610721565b34801561029c57600080fd5b50600b54610253906001600160a01b031681565b3480156102bc57600080fd5b506102d06102cb366004612911565b610765565b604051908152602001610267565b3480156102ea57600080fd5b50600654610253906001600160a01b031681565b34801561030a57600080fd5b50600754610253906001600160a01b031681565b34801561032a57600080fd5b50600c54610253906001600160a01b031681565b34801561034a57600080fd5b506102d0600f5481565b34801561036057600080fd5b50600254610253906001600160a01b031681565b34801561038057600080fd5b5061023161038f366004612911565b610780565b3480156103a057600080fd5b506102316103af36600461292e565b6107d6565b3480156103c057600080fd5b506102316103cf366004612911565b610842565b3480156103e057600080fd5b506102316103ef3660046128e3565b610898565b34801561040057600080fd5b5061023161040f366004612911565b6108d5565b34801561042057600080fd5b5061043461042f3660046129a3565b6108fe565b6040516102679291906129e9565b610231610450366004612a39565b610998565b34801561046157600080fd5b506102536104703660046128e3565b610a58565b34801561048157600080fd5b50610231610a82565b34801561049657600080fd5b506102d060045481565b3480156104ac57600080fd5b506000546001600160a01b0316610253565b3480156104ca57600080fd5b506102d060055481565b3480156104e057600080fd5b506102316104ef366004612911565b610a96565b34801561050057600080fd5b50600154610253906001600160a01b031681565b34801561052057600080fd5b5061054461052f366004612911565b600a6020526000908152604090205460ff1681565b6040519015158152602001610267565b34801561056057600080fd5b5061023161056f3660046128e3565b610aec565b34801561058057600080fd5b506102d060035481565b34801561059657600080fd5b506102316105a5366004612911565b610b29565b3480156105b657600080fd5b50600e54610253906001600160a01b031681565b6102d06105d8366004612b09565b610b7f565b3480156105e957600080fd5b506102316105f836600461292e565b6110a0565b34801561060957600080fd5b5061061d610618366004612b45565b611110565b60408051928352602083019190915201610267565b34801561063e57600080fd5b5061023161064d366004612911565b611140565b34801561065e57600080fd5b5061054461066d366004612911565b6001600160a01b03166000908152600a602052604090205460ff1690565b34801561069757600080fd5b506102316106a6366004612c11565b611196565b3480156106b757600080fd5b506102d061271081565b3480156106cd57600080fd5b506102316106dc366004612911565b61124c565b3480156106ed57600080fd5b506102316106fc366004612ca5565b6112c5565b34801561070d57600080fd5b5061023161071c366004612911565b6112e7565b610729611313565b60058190556040518181527f11e8ee12d79dc7314b845f4e82465af5bd3d2214081526061af36de8364eaa2e906020015b60405180910390a150565b600061077a6001600160a01b0383163061136d565b92915050565b610788611313565b600c80546001600160a01b0319166001600160a01b0383169081179091556040519081527f35e63b7fefc2b1fb2ed78adeed6688b187514d96c2d7d56222e52f3e41c2fb2f9060200161075a565b6107de611313565b60005b8181101561083d57600a60008484848181106107ff576107ff612ce7565b90506020020160208101906108149190612911565b6001600160a01b031681526020810191909152604001600020805460ff191690556001016107e1565b505050565b61084a611313565b600680546001600160a01b0319166001600160a01b0383169081179091556040519081527f41408be49f75701fe4bb8484ce88d68f1d82e03cb4eb44263b6682ce2dbd32f09060200161075a565b6108a0611313565b600f8190556040518181527f8f817f25bf47abe304b519d80d1a633064758c57d280731736fe82ad20816c559060200161075a565b6108dd611313565b6001600160a01b03166000908152600a60205260409020805460ff19169055565b600b5460405163181da82d60e21b81526001600160a01b03868116600483015285811660248301526044820185905260648201849052600092606092911690636076a0b490608401600060405180830381865afa158015610963573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261098b9190810190612cfd565b9097909650945050505050565b6109a06113ff565b866001600160a01b0316886001600160a01b0316036109da5760405162461bcd60e51b81526004016109d190612d9a565b60405180910390fd5b6109ef6001600160a01b038916333089611458565b60006109fd89888888611546565b9050610a428989838787878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506117b092505050565b5050610a4e6001600955565b5050505050505050565b60088181548110610a6857600080fd5b6000918252602090912001546001600160a01b0316905081565b610a8a611313565b610a9460006118b0565b565b610a9e611313565b600e80546001600160a01b0319166001600160a01b0383169081179091556040519081527f12e1d17016b94668449f97876f4a8d5cc2c19f314db337418894734037cc19d49060200161075a565b610af4611313565b60048190556040518181527f70f24e12a9db25e0d80cbcde19ffef47d6a7c52c1089db4c71e53ce1856577fc9060200161075a565b610b31611313565b600780546001600160a01b0319166001600160a01b0383169081179091556040519081527f17780f3919f73af11f29e4157534858a06c91294d64b679fe4e49340122cd3229060200161075a565b6000610b896113ff565b816080013582606001351015610bff5760405162461bcd60e51b815260206004820152603560248201527f657870656374656452657475726e206d75737420626520657175616c206f72206044820152743630b933b2b9103a3430b71036b4b72932ba3ab93760591b60648201526084016109d1565b610c0f6040830160208401612911565b6001600160a01b0316610c256020840184612911565b6001600160a01b031603610c4b5760405162461bcd60e51b81526004016109d190612d9a565b60008060005b610c5f610100860186612de2565b9050811015610cd3576000610c78610100870187612de2565b83818110610c8857610c88612ce7565b905060200201351115610ccb57610ca3610100860186612de2565b82818110610cb357610cb3612ce7565b9050602002013583610cc59190612e49565b92508091505b600101610c51565b5081600003610d4357610cfa610cec6020860186612911565b6001600160a01b0316611900565b15610d365760405133903480156108fc02916000818181858888f19350505050158015610d2b573d6000803e3d6000fd5b503492505050611091565b5050506040810135611091565b610d6b33306040870135610d5a6020890189612911565b6001600160a01b0316929190611458565b6000610d9c610d7d6020870187612911565b6040870135610d9260c0890160a08a01612911565b8860c00135611546565b9050610e08610daf610100870187612de2565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250859250879150869050610df360208b018b612911565b610e0360408c0160208d01612911565b611939565b93508315611022578460800135841015610e705760405162461bcd60e51b8152602060048201526024808201527f5377697463683a2052657475726e20616d6f756e7420776173206e6f7420656e6044820152630deeaced60e31b60648201526084016109d1565b8460600135841115610f9257610eb5610e90610100870160e08801612911565b6060870135610ea56040890160208a01612911565b6001600160a01b03169190611b5b565b50600d54610ee4906001600160a01b0316610ed4606088013587612e5c565b610ea56040890160208a01612911565b50600c546001600160a01b031663391fdc2433610f08610100890160e08a01612911565b610f1560208a018a612911565b610f2560408b0160208c01612911565b60408b013560608c0135610f39818d612e5c565b6040518863ffffffff1660e01b8152600401610f5b9796959493929190612e6f565b600060405180830381600087803b158015610f7557600080fd5b505af1158015610f89573d6000803e3d6000fd5b5050505061108d565b610fb7610fa6610100870160e08801612911565b85610ea56040890160208a01612911565b50600c546001600160a01b031663391fdc2433610fdb610100890160e08a01612911565b610fe860208a018a612911565b610ff860408b0160208c01612911565b8a604001358a60006040518863ffffffff1660e01b8152600401610f5b9796959493929190612e6f565b6040850135611047306110386020890189612911565b6001600160a01b03169061136d565b111561106957611063336040870135610ea56020890189612911565b5061108d565b61108b3361107e3061103860208a018a612911565b610ea56020890189612911565b505b5050505b61109b6001600955565b919050565b6110a8611313565b60005b8181101561083d576001600a60008585858181106110cb576110cb612ce7565b90506020020160208101906110e09190612911565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556001016110ab565b6000806127106111208685612eb3565b61112a9190612ee0565b91506111368286612e5c565b9050935093915050565b611148611313565b600d80546001600160a01b0319166001600160a01b0383169081179091556040519081527f53a596d7be747a5a4f4d39a6a36476d2eed407c93f6f2ba8a96c8b971240d5cd9060200161075a565b61119e611313565b8051600360008282546111b19190612e49565b90915550600090505b815181101561121c5760088282815181106111d7576111d7612ce7565b60209081029190910181015182546001808201855560009485529290932090920180546001600160a01b0319166001600160a01b0390931692909217909155016111ba565b507fbbc63a7f378af7e269ef19f3fe0d08f044c91ee72930c0d045a58be58580f3d38160405161075a9190612ef4565b611254611313565b6001600160a01b0381166112b95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109d1565b6112c2816118b0565b50565b6112cd611313565b6112e16001600160a01b0384168284611b5b565b50505050565b6112ef611313565b6001600160a01b03166000908152600a60205260409020805460ff19166001179055565b6000546001600160a01b03163314610a945760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109d1565b600061137883611900565b1561138e57506001600160a01b0381163161077a565b6040516370a0823160e01b81526001600160a01b0383811660048301528416906370a0823190602401602060405180830381865afa1580156113d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f89190612f41565b9392505050565b6002600954036114515760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109d1565b6002600955565b80156112e15761146784611900565b15611531576001600160a01b038316331480156114845750803410155b6114e45760405162461bcd60e51b815260206004820152602b60248201527f57726f6e6720757365616765206f66204554482e756e6976657273616c54726160448201526a6e7366657246726f6d282960a81b60648201526084016109d1565b6001600160a01b038216301461152c576040516001600160a01b0383169082156108fc029083906000818181858888f1935050505015801561152a573d6000803e3d6000fd5b505b6112e1565b6112e16001600160a01b038516848484611bd9565b8281156117a857600e54604051637b8c4cdf60e01b81526001600160a01b0385811660048301526000921690637b8c4cdf90602401602060405180830381865afa158015611598573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115bc9190612f41565b9050806000036115cb5750600f545b60006115d961271080612eb3565b826115e48887612eb3565b6115ee9190612eb3565b6115f89190612ee0565b905060008161271061160a8988612eb3565b6116149190612ee0565b61161e9190612e5c565b9050611632886001600160a01b0316611900565b156116c557600e546001600160a01b031663eedd56e16116528484612e49565b6040516001600160e01b031960e084901b1681526001600160a01b03808d16600483015260248201869052604482018790528a1660648201526084016000604051808303818588803b1580156116a757600080fd5b505af11580156116bb573d6000803e3d6000fd5b5050505050611781565b600e546116e0906001600160a01b038a811691166000611c44565b600e5461170b906001600160a01b03166116fa8484612e49565b6001600160a01b038b169190611c44565b600e5460405163eedd56e160e01b81526001600160a01b038a81166004830152602482018490526044820185905288811660648301529091169063eedd56e190608401600060405180830381600087803b15801561176857600080fd5b505af115801561177c573d6000803e3d6000fd5b505050505b61271061178e8887612eb3565b6117989190612ee0565b6117a29088612e5c565b93505050505b949350505050565b6000846001600160a01b0316866001600160a01b0316036117e35760405162461bcd60e51b81526004016109d190612d9a565b6000828060200190518101906117f99190612f7e565b9050611806878683611d59565b6118196001600160a01b0387163061136d565b91508115611837576118356001600160a01b0387168584611b5b565b505b600c54604051630e47f70960e21b81526001600160a01b039091169063391fdc249061187490339088908c908c908c908a90600090600401612e6f565b600060405180830381600087803b15801561188e57600080fd5b505af11580156118a2573d6000803e3d6000fd5b505050505095945050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006001600160a01b038216158061077a57506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1492915050565b600060045460035461194b9190612eb3565b875111156119cb5760405162461bcd60e51b815260206004820152604160248201527f5377697463683a20446973747269627574696f6e2061727261792073686f756c60448201527f64206e6f742065786365656420666163746f726965732061727261792073697a6064820152606560f81b608482015260a4016109d1565b856000805b8951811015611b4e578981815181106119eb576119eb612ce7565b602002602001015160000315611b46576000888b8381518110611a1057611a10612ce7565b60200260200101518b611a239190612eb3565b611a2d9190612ee0565b9050878203611a395750825b611a438185612e5c565b935060045482611a539190613065565b600003611aa157611a9a878783600860045487611a709190612ee0565b81548110611a8057611a80612ce7565b6000918252602090912001546001600160a01b0316611ebb565b9250611b38565b600454611aae9083613065565b600103611af557611a9a878783600860045487611acb9190612ee0565b81548110611adb57611adb612ce7565b6000918252602090912001546001600160a01b0316611ed2565b611b35878783600860045487611b0b9190612ee0565b81548110611b1b57611b1b612ce7565b6000918252602090912001546001600160a01b0316611eef565b92505b611b428386612e49565b9450505b6001016119d0565b5050509695505050505050565b600081600003611b6d575060016113f8565b611b7684611900565b15611bbb576040516001600160a01b0384169083156108fc029084906000818181858888f19350505050158015611bb1573d6000803e3d6000fd5b50600190506113f8565b611bcf6001600160a01b0385168484611f0c565b5060019392505050565b6040516001600160a01b03808516602483015283166044820152606481018290526112e19085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611f3c565b801580611cbe5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015611c98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cbc9190612f41565b155b611d295760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016109d1565b6040516001600160a01b03831660248201526044810182905261083d90849063095ea7b360e01b90606401611c0d565b8060200151611d6781612011565b8151611d7281612011565b6000611d86866001600160a01b0316611900565b15611de25784471015611ddb5760405162461bcd60e51b815260206004820152601b60248201527f4554482062616c616e636520697320696e73756666696369656e74000000000060448201526064016109d1565b5083611dfc565b6020840151611dfc906001600160a01b0388169087612079565b600084600001516001600160a01b0316828660400151604051611e1f9190613079565b60006040518083038185875af1925050503d8060008114611e5c576040519150601f19603f3d011682016040523d82523d6000602084013e611e61565b606091505b5050905080611eb25760405162461bcd60e51b815260206004820152601f60248201527f4465782041676772656761746f7220657865637574696f6e206661696c65640060448201526064016109d1565b50505050505050565b6000611ec985858585612148565b95945050505050565b600654600090611ec99086906001600160a01b0316868686612596565b600754600090611ec99086906001600160a01b0316868686612596565b6040516001600160a01b03831660248201526044810182905261083d90849063a9059cbb60e01b90606401611c0d565b6000611f91826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166125b99092919063ffffffff16565b9050805160001480611fb2575080806020019051810190611fb29190613095565b61083d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109d1565b6001600160a01b0381166000908152600a602052604090205460ff166112c25760405162461bcd60e51b815260206004820152601b60248201527f41646472657373206973206e6f7420696e20616c6c6f776c697374000000000060448201526064016109d1565b61208283611900565b61083d57806000036120a35761083d6001600160a01b038416836000611c44565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156120f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121179190612f41565b90508015612134576121346001600160a01b038516846000611c44565b6112e16001600160a01b0385168484611c44565b600061215c856001600160a01b0316611900565b156121cb57600660009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156121b157600080fd5b505af11580156121c5573d6000803e3d6000fd5b50505050505b60006121df866001600160a01b0316611900565b6121e957856121f6565b6006546001600160a01b03165b9050600061220c866001600160a01b0316611900565b6122165785612223565b6006546001600160a01b03165b60405163e6a4390560e01b81526001600160a01b038481166004830152808316602483015291925060009186169063e6a4390590604401602060405180830381865afa158015612277573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229b91906130b7565b90506000806122b56001600160a01b03841686868b6125c8565b91975092509050811561231a57826001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156122fd57600080fd5b505af1158015612311573d6000803e3d6000fd5b5050505061238e565b801561238e5760405163bc25cf7760e01b81527346fd07da395799f113a7584563b8cb886f33c2bc60048201526001600160a01b0384169063bc25cf7790602401600060405180830381600087803b15801561237557600080fd5b505af1158015612389573d6000803e3d6000fd5b505050505b6123a26001600160a01b038616848a611b5b565b50836001600160a01b0316856001600160a01b031610156124375760405163022c0d9f60e01b8152600060048201819052602482018890523060448301526080606483015260848201526001600160a01b0384169063022c0d9f9060a401600060405180830381600087803b15801561241a57600080fd5b505af115801561242e573d6000803e3d6000fd5b505050506124ad565b60405163022c0d9f60e01b8152600481018790526000602482018190523060448301526080606483015260848201526001600160a01b0384169063022c0d9f9060a401600060405180830381600087803b15801561249457600080fd5b505af11580156124a8573d6000803e3d6000fd5b505050505b6124bf896001600160a01b0316611900565b15612589576006546040516370a0823160e01b81523060048201526001600160a01b0390911690632e1a7d4d9082906370a0823190602401602060405180830381865afa158015612514573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125389190612f41565b6040518263ffffffff1660e01b815260040161255691815260200190565b600060405180830381600087803b15801561257057600080fd5b505af1158015612584573d6000803e3d6000fd5b505050505b5050505050949350505050565b60006125af85856125a989898888612148565b85612148565b9695505050505050565b60606117a88484600085612754565b60008080806125e06001600160a01b0388168961136d565b905060006125f76001600160a01b0388168a61136d565b90506000808a6001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561263a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061265e91906130eb565b5091509150886001600160a01b03168a6001600160a01b0316111561267f57905b816001600160701b031684108061269e5750806001600160701b031683105b9550851580156126c85750816001600160701b03168411806126c85750806001600160701b031683115b945060006126d8896103e5612eb3565b905060006126ef85846001600160701b031661282f565b6126f99083612eb3565b905060008261271188876001600160701b031661282f565b61271d906103e8612eb3565b6127279190612e49565b9050801561273e576127398183612ee0565b612741565b60005b9950505050505050509450945094915050565b6060824710156127b55760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109d1565b600080866001600160a01b031685876040516127d19190613079565b60006040518083038185875af1925050503d806000811461280e576040519150601f19603f3d011682016040523d82523d6000602084013e612813565b606091505b509150915061282487838387612845565b979650505050505050565b600081831061283e57816113f8565b5090919050565b606083156128b45782516000036128ad576001600160a01b0385163b6128ad5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109d1565b50816117a8565b6117a883838151156128c95781518083602001fd5b8060405162461bcd60e51b81526004016109d19190613130565b6000602082840312156128f557600080fd5b5035919050565b6001600160a01b03811681146112c257600080fd5b60006020828403121561292357600080fd5b81356113f8816128fc565b6000806020838503121561294157600080fd5b823567ffffffffffffffff8082111561295957600080fd5b818501915085601f83011261296d57600080fd5b81358181111561297c57600080fd5b8660208260051b850101111561299157600080fd5b60209290920196919550909350505050565b600080600080608085870312156129b957600080fd5b84356129c4816128fc565b935060208501356129d4816128fc565b93969395505050506040820135916060013590565b60006040820184835260206040602085015281855180845260608601915060208701935060005b81811015612a2c57845183529383019391830191600101612a10565b5090979650505050505050565b60008060008060008060008060e0898b031215612a5557600080fd5b8835612a60816128fc565b97506020890135612a70816128fc565b9650604089013595506060890135612a87816128fc565b94506080890135935060a0890135612a9e816128fc565b925060c089013567ffffffffffffffff80821115612abb57600080fd5b818b0191508b601f830112612acf57600080fd5b813581811115612ade57600080fd5b8c6020828501011115612af057600080fd5b6020830194508093505050509295985092959890939650565b600060208284031215612b1b57600080fd5b813567ffffffffffffffff811115612b3257600080fd5b820161012081850312156113f857600080fd5b600080600060608486031215612b5a57600080fd5b833592506020840135612b6c816128fc565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715612bb657612bb6612b7d565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715612be557612be5612b7d565b604052919050565b600067ffffffffffffffff821115612c0757612c07612b7d565b5060051b60200190565b60006020808385031215612c2457600080fd5b823567ffffffffffffffff811115612c3b57600080fd5b8301601f81018513612c4c57600080fd5b8035612c5f612c5a82612bed565b612bbc565b81815260059190911b82018301908381019087831115612c7e57600080fd5b928401925b82841015612824578335612c96816128fc565b82529284019290840190612c83565b600080600060608486031215612cba57600080fd5b8335612cc5816128fc565b9250602084013591506040840135612cdc816128fc565b809150509250925092565b634e487b7160e01b600052603260045260246000fd5b60008060408385031215612d1057600080fd5b8251915060208084015167ffffffffffffffff811115612d2f57600080fd5b8401601f81018613612d4057600080fd5b8051612d4e612c5a82612bed565b81815260059190911b82018301908381019088831115612d6d57600080fd5b928401925b82841015612d8b57835182529284019290840190612d72565b80955050505050509250929050565b60208082526028908201527f69742773206e6f7420616c6c6f77656420746f2073776170207769746820736160408201526736b2903a37b5b2b760c11b606082015260800190565b6000808335601e19843603018112612df957600080fd5b83018035915067ffffffffffffffff821115612e1457600080fd5b6020019150600581901b3603821315612e2c57600080fd5b9250929050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561077a5761077a612e33565b8181038181111561077a5761077a612e33565b6001600160a01b03978816815295871660208701529386166040860152919094166060840152608083019390935260a082019290925260c081019190915260e00190565b808202811582820484141761077a5761077a612e33565b634e487b7160e01b600052601260045260246000fd5b600082612eef57612eef612eca565b500490565b6020808252825182820181905260009190848201906040850190845b81811015612f355783516001600160a01b031683529284019291840191600101612f10565b50909695505050505050565b600060208284031215612f5357600080fd5b5051919050565b60005b83811015612f75578181015183820152602001612f5d565b50506000910152565b60006020808385031215612f9157600080fd5b825167ffffffffffffffff80821115612fa957600080fd5b9084019060608287031215612fbd57600080fd5b612fc5612b93565b8251612fd0816128fc565b815282840151612fdf816128fc565b81850152604083015182811115612ff557600080fd5b80840193505086601f84011261300a57600080fd5b82518281111561301c5761301c612b7d565b61302e601f8201601f19168601612bbc565b9250808352878582860101111561304457600080fd5b61305381868501878701612f5a565b50604081019190915295945050505050565b60008261307457613074612eca565b500690565b6000825161308b818460208701612f5a565b9190910192915050565b6000602082840312156130a757600080fd5b815180151581146113f857600080fd5b6000602082840312156130c957600080fd5b81516113f8816128fc565b80516001600160701b038116811461109b57600080fd5b60008060006060848603121561310057600080fd5b613109846130d4565b9250613117602085016130d4565b9150604084015163ffffffff81168114612cdc57600080fd5b602081526000825180602084015261314f816040850160208701612f5a565b601f01601f1916919091016040019291505056fea26469706673582212206b1bb1f8929109b1e4fe5e0b074a5b025070465484da66d6ea95f248ac70560664736f6c63430008160033000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001000000000000000000000000006b4aafe0a2c03b223b73a681b544b1617a976ccb000000000000000000000000410f724847c92bc3cdacbcd4922f1d7833ec280a00000000000000000000000028b9089b5f2724c1898e7dbb04a96c8c177fe46d00000000000000000000000000000000000000000000000000000000000000030000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac000000000000000000000000115934131916c8b277dd010ee02de363c09d037c

Deployed Bytecode

0x6080604052600436106102255760003560e01c80638da5cb5b11610123578063c93d732d116100ab578063ea15afc31161006f578063ea15afc31461068b578063ecefc705146106ab578063f2fde38b146106c1578063f640d508146106e1578063f8e86ece1461070157610225565b8063c93d732d146105ca578063d08508bf146105dd578063d6821ed8146105fd578063e5932c4014610632578063e772ff371461065257610225565b8063a7cd52cb116100f2578063a7cd52cb14610514578063a85f329814610554578063ab30469514610574578063b4c76fe01461058a578063c415b95c146105aa57610225565b80638da5cb5b146104a057806390f3f208146104be578063a42dce80146104d4578063a734f06e146104f457610225565b806353fd7bf1116101b15780636076a0b4116101755780636076a0b4146104145780636184305c14610442578063672383c414610455578063715018a6146104755780638c821e901461048a57610225565b806353fd7bf11461037457806356230573146103945780635b769f3c146103b45780635c3d258f146103d45780635da93d7e146103f457610225565b80633fc8cef3116101f85780633fc8cef3146102de578063433b3c05146102fe5780634399fa561461031e57806352b721f81461033e578063538ba4f91461035457610225565b8063228cb7331461023357806323a9495e1461027057806331428a87146102905780633aecd0e3146102b0575b32330361023157600080fd5b005b34801561023f57600080fd5b50600d54610253906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561027c57600080fd5b5061023161028b3660046128e3565b610721565b34801561029c57600080fd5b50600b54610253906001600160a01b031681565b3480156102bc57600080fd5b506102d06102cb366004612911565b610765565b604051908152602001610267565b3480156102ea57600080fd5b50600654610253906001600160a01b031681565b34801561030a57600080fd5b50600754610253906001600160a01b031681565b34801561032a57600080fd5b50600c54610253906001600160a01b031681565b34801561034a57600080fd5b506102d0600f5481565b34801561036057600080fd5b50600254610253906001600160a01b031681565b34801561038057600080fd5b5061023161038f366004612911565b610780565b3480156103a057600080fd5b506102316103af36600461292e565b6107d6565b3480156103c057600080fd5b506102316103cf366004612911565b610842565b3480156103e057600080fd5b506102316103ef3660046128e3565b610898565b34801561040057600080fd5b5061023161040f366004612911565b6108d5565b34801561042057600080fd5b5061043461042f3660046129a3565b6108fe565b6040516102679291906129e9565b610231610450366004612a39565b610998565b34801561046157600080fd5b506102536104703660046128e3565b610a58565b34801561048157600080fd5b50610231610a82565b34801561049657600080fd5b506102d060045481565b3480156104ac57600080fd5b506000546001600160a01b0316610253565b3480156104ca57600080fd5b506102d060055481565b3480156104e057600080fd5b506102316104ef366004612911565b610a96565b34801561050057600080fd5b50600154610253906001600160a01b031681565b34801561052057600080fd5b5061054461052f366004612911565b600a6020526000908152604090205460ff1681565b6040519015158152602001610267565b34801561056057600080fd5b5061023161056f3660046128e3565b610aec565b34801561058057600080fd5b506102d060035481565b34801561059657600080fd5b506102316105a5366004612911565b610b29565b3480156105b657600080fd5b50600e54610253906001600160a01b031681565b6102d06105d8366004612b09565b610b7f565b3480156105e957600080fd5b506102316105f836600461292e565b6110a0565b34801561060957600080fd5b5061061d610618366004612b45565b611110565b60408051928352602083019190915201610267565b34801561063e57600080fd5b5061023161064d366004612911565b611140565b34801561065e57600080fd5b5061054461066d366004612911565b6001600160a01b03166000908152600a602052604090205460ff1690565b34801561069757600080fd5b506102316106a6366004612c11565b611196565b3480156106b757600080fd5b506102d061271081565b3480156106cd57600080fd5b506102316106dc366004612911565b61124c565b3480156106ed57600080fd5b506102316106fc366004612ca5565b6112c5565b34801561070d57600080fd5b5061023161071c366004612911565b6112e7565b610729611313565b60058190556040518181527f11e8ee12d79dc7314b845f4e82465af5bd3d2214081526061af36de8364eaa2e906020015b60405180910390a150565b600061077a6001600160a01b0383163061136d565b92915050565b610788611313565b600c80546001600160a01b0319166001600160a01b0383169081179091556040519081527f35e63b7fefc2b1fb2ed78adeed6688b187514d96c2d7d56222e52f3e41c2fb2f9060200161075a565b6107de611313565b60005b8181101561083d57600a60008484848181106107ff576107ff612ce7565b90506020020160208101906108149190612911565b6001600160a01b031681526020810191909152604001600020805460ff191690556001016107e1565b505050565b61084a611313565b600680546001600160a01b0319166001600160a01b0383169081179091556040519081527f41408be49f75701fe4bb8484ce88d68f1d82e03cb4eb44263b6682ce2dbd32f09060200161075a565b6108a0611313565b600f8190556040518181527f8f817f25bf47abe304b519d80d1a633064758c57d280731736fe82ad20816c559060200161075a565b6108dd611313565b6001600160a01b03166000908152600a60205260409020805460ff19169055565b600b5460405163181da82d60e21b81526001600160a01b03868116600483015285811660248301526044820185905260648201849052600092606092911690636076a0b490608401600060405180830381865afa158015610963573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261098b9190810190612cfd565b9097909650945050505050565b6109a06113ff565b866001600160a01b0316886001600160a01b0316036109da5760405162461bcd60e51b81526004016109d190612d9a565b60405180910390fd5b6109ef6001600160a01b038916333089611458565b60006109fd89888888611546565b9050610a428989838787878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506117b092505050565b5050610a4e6001600955565b5050505050505050565b60088181548110610a6857600080fd5b6000918252602090912001546001600160a01b0316905081565b610a8a611313565b610a9460006118b0565b565b610a9e611313565b600e80546001600160a01b0319166001600160a01b0383169081179091556040519081527f12e1d17016b94668449f97876f4a8d5cc2c19f314db337418894734037cc19d49060200161075a565b610af4611313565b60048190556040518181527f70f24e12a9db25e0d80cbcde19ffef47d6a7c52c1089db4c71e53ce1856577fc9060200161075a565b610b31611313565b600780546001600160a01b0319166001600160a01b0383169081179091556040519081527f17780f3919f73af11f29e4157534858a06c91294d64b679fe4e49340122cd3229060200161075a565b6000610b896113ff565b816080013582606001351015610bff5760405162461bcd60e51b815260206004820152603560248201527f657870656374656452657475726e206d75737420626520657175616c206f72206044820152743630b933b2b9103a3430b71036b4b72932ba3ab93760591b60648201526084016109d1565b610c0f6040830160208401612911565b6001600160a01b0316610c256020840184612911565b6001600160a01b031603610c4b5760405162461bcd60e51b81526004016109d190612d9a565b60008060005b610c5f610100860186612de2565b9050811015610cd3576000610c78610100870187612de2565b83818110610c8857610c88612ce7565b905060200201351115610ccb57610ca3610100860186612de2565b82818110610cb357610cb3612ce7565b9050602002013583610cc59190612e49565b92508091505b600101610c51565b5081600003610d4357610cfa610cec6020860186612911565b6001600160a01b0316611900565b15610d365760405133903480156108fc02916000818181858888f19350505050158015610d2b573d6000803e3d6000fd5b503492505050611091565b5050506040810135611091565b610d6b33306040870135610d5a6020890189612911565b6001600160a01b0316929190611458565b6000610d9c610d7d6020870187612911565b6040870135610d9260c0890160a08a01612911565b8860c00135611546565b9050610e08610daf610100870187612de2565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250859250879150869050610df360208b018b612911565b610e0360408c0160208d01612911565b611939565b93508315611022578460800135841015610e705760405162461bcd60e51b8152602060048201526024808201527f5377697463683a2052657475726e20616d6f756e7420776173206e6f7420656e6044820152630deeaced60e31b60648201526084016109d1565b8460600135841115610f9257610eb5610e90610100870160e08801612911565b6060870135610ea56040890160208a01612911565b6001600160a01b03169190611b5b565b50600d54610ee4906001600160a01b0316610ed4606088013587612e5c565b610ea56040890160208a01612911565b50600c546001600160a01b031663391fdc2433610f08610100890160e08a01612911565b610f1560208a018a612911565b610f2560408b0160208c01612911565b60408b013560608c0135610f39818d612e5c565b6040518863ffffffff1660e01b8152600401610f5b9796959493929190612e6f565b600060405180830381600087803b158015610f7557600080fd5b505af1158015610f89573d6000803e3d6000fd5b5050505061108d565b610fb7610fa6610100870160e08801612911565b85610ea56040890160208a01612911565b50600c546001600160a01b031663391fdc2433610fdb610100890160e08a01612911565b610fe860208a018a612911565b610ff860408b0160208c01612911565b8a604001358a60006040518863ffffffff1660e01b8152600401610f5b9796959493929190612e6f565b6040850135611047306110386020890189612911565b6001600160a01b03169061136d565b111561106957611063336040870135610ea56020890189612911565b5061108d565b61108b3361107e3061103860208a018a612911565b610ea56020890189612911565b505b5050505b61109b6001600955565b919050565b6110a8611313565b60005b8181101561083d576001600a60008585858181106110cb576110cb612ce7565b90506020020160208101906110e09190612911565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556001016110ab565b6000806127106111208685612eb3565b61112a9190612ee0565b91506111368286612e5c565b9050935093915050565b611148611313565b600d80546001600160a01b0319166001600160a01b0383169081179091556040519081527f53a596d7be747a5a4f4d39a6a36476d2eed407c93f6f2ba8a96c8b971240d5cd9060200161075a565b61119e611313565b8051600360008282546111b19190612e49565b90915550600090505b815181101561121c5760088282815181106111d7576111d7612ce7565b60209081029190910181015182546001808201855560009485529290932090920180546001600160a01b0319166001600160a01b0390931692909217909155016111ba565b507fbbc63a7f378af7e269ef19f3fe0d08f044c91ee72930c0d045a58be58580f3d38160405161075a9190612ef4565b611254611313565b6001600160a01b0381166112b95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109d1565b6112c2816118b0565b50565b6112cd611313565b6112e16001600160a01b0384168284611b5b565b50505050565b6112ef611313565b6001600160a01b03166000908152600a60205260409020805460ff19166001179055565b6000546001600160a01b03163314610a945760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109d1565b600061137883611900565b1561138e57506001600160a01b0381163161077a565b6040516370a0823160e01b81526001600160a01b0383811660048301528416906370a0823190602401602060405180830381865afa1580156113d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f89190612f41565b9392505050565b6002600954036114515760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109d1565b6002600955565b80156112e15761146784611900565b15611531576001600160a01b038316331480156114845750803410155b6114e45760405162461bcd60e51b815260206004820152602b60248201527f57726f6e6720757365616765206f66204554482e756e6976657273616c54726160448201526a6e7366657246726f6d282960a81b60648201526084016109d1565b6001600160a01b038216301461152c576040516001600160a01b0383169082156108fc029083906000818181858888f1935050505015801561152a573d6000803e3d6000fd5b505b6112e1565b6112e16001600160a01b038516848484611bd9565b8281156117a857600e54604051637b8c4cdf60e01b81526001600160a01b0385811660048301526000921690637b8c4cdf90602401602060405180830381865afa158015611598573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115bc9190612f41565b9050806000036115cb5750600f545b60006115d961271080612eb3565b826115e48887612eb3565b6115ee9190612eb3565b6115f89190612ee0565b905060008161271061160a8988612eb3565b6116149190612ee0565b61161e9190612e5c565b9050611632886001600160a01b0316611900565b156116c557600e546001600160a01b031663eedd56e16116528484612e49565b6040516001600160e01b031960e084901b1681526001600160a01b03808d16600483015260248201869052604482018790528a1660648201526084016000604051808303818588803b1580156116a757600080fd5b505af11580156116bb573d6000803e3d6000fd5b5050505050611781565b600e546116e0906001600160a01b038a811691166000611c44565b600e5461170b906001600160a01b03166116fa8484612e49565b6001600160a01b038b169190611c44565b600e5460405163eedd56e160e01b81526001600160a01b038a81166004830152602482018490526044820185905288811660648301529091169063eedd56e190608401600060405180830381600087803b15801561176857600080fd5b505af115801561177c573d6000803e3d6000fd5b505050505b61271061178e8887612eb3565b6117989190612ee0565b6117a29088612e5c565b93505050505b949350505050565b6000846001600160a01b0316866001600160a01b0316036117e35760405162461bcd60e51b81526004016109d190612d9a565b6000828060200190518101906117f99190612f7e565b9050611806878683611d59565b6118196001600160a01b0387163061136d565b91508115611837576118356001600160a01b0387168584611b5b565b505b600c54604051630e47f70960e21b81526001600160a01b039091169063391fdc249061187490339088908c908c908c908a90600090600401612e6f565b600060405180830381600087803b15801561188e57600080fd5b505af11580156118a2573d6000803e3d6000fd5b505050505095945050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006001600160a01b038216158061077a57506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1492915050565b600060045460035461194b9190612eb3565b875111156119cb5760405162461bcd60e51b815260206004820152604160248201527f5377697463683a20446973747269627574696f6e2061727261792073686f756c60448201527f64206e6f742065786365656420666163746f726965732061727261792073697a6064820152606560f81b608482015260a4016109d1565b856000805b8951811015611b4e578981815181106119eb576119eb612ce7565b602002602001015160000315611b46576000888b8381518110611a1057611a10612ce7565b60200260200101518b611a239190612eb3565b611a2d9190612ee0565b9050878203611a395750825b611a438185612e5c565b935060045482611a539190613065565b600003611aa157611a9a878783600860045487611a709190612ee0565b81548110611a8057611a80612ce7565b6000918252602090912001546001600160a01b0316611ebb565b9250611b38565b600454611aae9083613065565b600103611af557611a9a878783600860045487611acb9190612ee0565b81548110611adb57611adb612ce7565b6000918252602090912001546001600160a01b0316611ed2565b611b35878783600860045487611b0b9190612ee0565b81548110611b1b57611b1b612ce7565b6000918252602090912001546001600160a01b0316611eef565b92505b611b428386612e49565b9450505b6001016119d0565b5050509695505050505050565b600081600003611b6d575060016113f8565b611b7684611900565b15611bbb576040516001600160a01b0384169083156108fc029084906000818181858888f19350505050158015611bb1573d6000803e3d6000fd5b50600190506113f8565b611bcf6001600160a01b0385168484611f0c565b5060019392505050565b6040516001600160a01b03808516602483015283166044820152606481018290526112e19085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611f3c565b801580611cbe5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015611c98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cbc9190612f41565b155b611d295760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016109d1565b6040516001600160a01b03831660248201526044810182905261083d90849063095ea7b360e01b90606401611c0d565b8060200151611d6781612011565b8151611d7281612011565b6000611d86866001600160a01b0316611900565b15611de25784471015611ddb5760405162461bcd60e51b815260206004820152601b60248201527f4554482062616c616e636520697320696e73756666696369656e74000000000060448201526064016109d1565b5083611dfc565b6020840151611dfc906001600160a01b0388169087612079565b600084600001516001600160a01b0316828660400151604051611e1f9190613079565b60006040518083038185875af1925050503d8060008114611e5c576040519150601f19603f3d011682016040523d82523d6000602084013e611e61565b606091505b5050905080611eb25760405162461bcd60e51b815260206004820152601f60248201527f4465782041676772656761746f7220657865637574696f6e206661696c65640060448201526064016109d1565b50505050505050565b6000611ec985858585612148565b95945050505050565b600654600090611ec99086906001600160a01b0316868686612596565b600754600090611ec99086906001600160a01b0316868686612596565b6040516001600160a01b03831660248201526044810182905261083d90849063a9059cbb60e01b90606401611c0d565b6000611f91826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166125b99092919063ffffffff16565b9050805160001480611fb2575080806020019051810190611fb29190613095565b61083d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109d1565b6001600160a01b0381166000908152600a602052604090205460ff166112c25760405162461bcd60e51b815260206004820152601b60248201527f41646472657373206973206e6f7420696e20616c6c6f776c697374000000000060448201526064016109d1565b61208283611900565b61083d57806000036120a35761083d6001600160a01b038416836000611c44565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa1580156120f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121179190612f41565b90508015612134576121346001600160a01b038516846000611c44565b6112e16001600160a01b0385168484611c44565b600061215c856001600160a01b0316611900565b156121cb57600660009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156121b157600080fd5b505af11580156121c5573d6000803e3d6000fd5b50505050505b60006121df866001600160a01b0316611900565b6121e957856121f6565b6006546001600160a01b03165b9050600061220c866001600160a01b0316611900565b6122165785612223565b6006546001600160a01b03165b60405163e6a4390560e01b81526001600160a01b038481166004830152808316602483015291925060009186169063e6a4390590604401602060405180830381865afa158015612277573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229b91906130b7565b90506000806122b56001600160a01b03841686868b6125c8565b91975092509050811561231a57826001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156122fd57600080fd5b505af1158015612311573d6000803e3d6000fd5b5050505061238e565b801561238e5760405163bc25cf7760e01b81527346fd07da395799f113a7584563b8cb886f33c2bc60048201526001600160a01b0384169063bc25cf7790602401600060405180830381600087803b15801561237557600080fd5b505af1158015612389573d6000803e3d6000fd5b505050505b6123a26001600160a01b038616848a611b5b565b50836001600160a01b0316856001600160a01b031610156124375760405163022c0d9f60e01b8152600060048201819052602482018890523060448301526080606483015260848201526001600160a01b0384169063022c0d9f9060a401600060405180830381600087803b15801561241a57600080fd5b505af115801561242e573d6000803e3d6000fd5b505050506124ad565b60405163022c0d9f60e01b8152600481018790526000602482018190523060448301526080606483015260848201526001600160a01b0384169063022c0d9f9060a401600060405180830381600087803b15801561249457600080fd5b505af11580156124a8573d6000803e3d6000fd5b505050505b6124bf896001600160a01b0316611900565b15612589576006546040516370a0823160e01b81523060048201526001600160a01b0390911690632e1a7d4d9082906370a0823190602401602060405180830381865afa158015612514573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125389190612f41565b6040518263ffffffff1660e01b815260040161255691815260200190565b600060405180830381600087803b15801561257057600080fd5b505af1158015612584573d6000803e3d6000fd5b505050505b5050505050949350505050565b60006125af85856125a989898888612148565b85612148565b9695505050505050565b60606117a88484600085612754565b60008080806125e06001600160a01b0388168961136d565b905060006125f76001600160a01b0388168a61136d565b90506000808a6001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561263a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061265e91906130eb565b5091509150886001600160a01b03168a6001600160a01b0316111561267f57905b816001600160701b031684108061269e5750806001600160701b031683105b9550851580156126c85750816001600160701b03168411806126c85750806001600160701b031683115b945060006126d8896103e5612eb3565b905060006126ef85846001600160701b031661282f565b6126f99083612eb3565b905060008261271188876001600160701b031661282f565b61271d906103e8612eb3565b6127279190612e49565b9050801561273e576127398183612ee0565b612741565b60005b9950505050505050509450945094915050565b6060824710156127b55760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109d1565b600080866001600160a01b031685876040516127d19190613079565b60006040518083038185875af1925050503d806000811461280e576040519150601f19603f3d011682016040523d82523d6000602084013e612813565b606091505b509150915061282487838387612845565b979650505050505050565b600081831061283e57816113f8565b5090919050565b606083156128b45782516000036128ad576001600160a01b0385163b6128ad5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109d1565b50816117a8565b6117a883838151156128c95781518083602001fd5b8060405162461bcd60e51b81526004016109d19190613130565b6000602082840312156128f557600080fd5b5035919050565b6001600160a01b03811681146112c257600080fd5b60006020828403121561292357600080fd5b81356113f8816128fc565b6000806020838503121561294157600080fd5b823567ffffffffffffffff8082111561295957600080fd5b818501915085601f83011261296d57600080fd5b81358181111561297c57600080fd5b8660208260051b850101111561299157600080fd5b60209290920196919550909350505050565b600080600080608085870312156129b957600080fd5b84356129c4816128fc565b935060208501356129d4816128fc565b93969395505050506040820135916060013590565b60006040820184835260206040602085015281855180845260608601915060208701935060005b81811015612a2c57845183529383019391830191600101612a10565b5090979650505050505050565b60008060008060008060008060e0898b031215612a5557600080fd5b8835612a60816128fc565b97506020890135612a70816128fc565b9650604089013595506060890135612a87816128fc565b94506080890135935060a0890135612a9e816128fc565b925060c089013567ffffffffffffffff80821115612abb57600080fd5b818b0191508b601f830112612acf57600080fd5b813581811115612ade57600080fd5b8c6020828501011115612af057600080fd5b6020830194508093505050509295985092959890939650565b600060208284031215612b1b57600080fd5b813567ffffffffffffffff811115612b3257600080fd5b820161012081850312156113f857600080fd5b600080600060608486031215612b5a57600080fd5b833592506020840135612b6c816128fc565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715612bb657612bb6612b7d565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715612be557612be5612b7d565b604052919050565b600067ffffffffffffffff821115612c0757612c07612b7d565b5060051b60200190565b60006020808385031215612c2457600080fd5b823567ffffffffffffffff811115612c3b57600080fd5b8301601f81018513612c4c57600080fd5b8035612c5f612c5a82612bed565b612bbc565b81815260059190911b82018301908381019087831115612c7e57600080fd5b928401925b82841015612824578335612c96816128fc565b82529284019290840190612c83565b600080600060608486031215612cba57600080fd5b8335612cc5816128fc565b9250602084013591506040840135612cdc816128fc565b809150509250925092565b634e487b7160e01b600052603260045260246000fd5b60008060408385031215612d1057600080fd5b8251915060208084015167ffffffffffffffff811115612d2f57600080fd5b8401601f81018613612d4057600080fd5b8051612d4e612c5a82612bed565b81815260059190911b82018301908381019088831115612d6d57600080fd5b928401925b82841015612d8b57835182529284019290840190612d72565b80955050505050509250929050565b60208082526028908201527f69742773206e6f7420616c6c6f77656420746f2073776170207769746820736160408201526736b2903a37b5b2b760c11b606082015260800190565b6000808335601e19843603018112612df957600080fd5b83018035915067ffffffffffffffff821115612e1457600080fd5b6020019150600581901b3603821315612e2c57600080fd5b9250929050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561077a5761077a612e33565b8181038181111561077a5761077a612e33565b6001600160a01b03978816815295871660208701529386166040860152919094166060840152608083019390935260a082019290925260c081019190915260e00190565b808202811582820484141761077a5761077a612e33565b634e487b7160e01b600052601260045260246000fd5b600082612eef57612eef612eca565b500490565b6020808252825182820181905260009190848201906040850190845b81811015612f355783516001600160a01b031683529284019291840191600101612f10565b50909695505050505050565b600060208284031215612f5357600080fd5b5051919050565b60005b83811015612f75578181015183820152602001612f5d565b50506000910152565b60006020808385031215612f9157600080fd5b825167ffffffffffffffff80821115612fa957600080fd5b9084019060608287031215612fbd57600080fd5b612fc5612b93565b8251612fd0816128fc565b815282840151612fdf816128fc565b81850152604083015182811115612ff557600080fd5b80840193505086601f84011261300a57600080fd5b82518281111561301c5761301c612b7d565b61302e601f8201601f19168601612bbc565b9250808352878582860101111561304457600080fd5b61305381868501878701612f5a565b50604081019190915295945050505050565b60008261307457613074612eca565b500690565b6000825161308b818460208701612f5a565b9190910192915050565b6000602082840312156130a757600080fd5b815180151581146113f857600080fd5b6000602082840312156130c957600080fd5b81516113f8816128fc565b80516001600160701b038116811461109b57600080fd5b60008060006060848603121561310057600080fd5b613109846130d4565b9250613117602085016130d4565b9150604084015163ffffffff81168114612cdc57600080fd5b602081526000825180602084015261314f816040850160208701612f5a565b601f01601f1916919091016040019291505056fea26469706673582212206b1bb1f8929109b1e4fe5e0b074a5b025070465484da66d6ea95f248ac70560664736f6c63430008160033

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

000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000001000000000000000000000000006b4aafe0a2c03b223b73a681b544b1617a976ccb000000000000000000000000410f724847c92bc3cdacbcd4922f1d7833ec280a00000000000000000000000028b9089b5f2724c1898e7dbb04a96c8c177fe46d00000000000000000000000000000000000000000000000000000000000000030000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac000000000000000000000000115934131916c8b277dd010ee02de363c09d037c

-----Decoded View---------------
Arg [0] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [1] : _otherToken (address): 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
Arg [2] : _pathCount (uint256): 2
Arg [3] : _pathSplit (uint256): 2
Arg [4] : _factories (address[]): 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f,0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac,0x115934131916C8b277DD010Ee02de363c09d037c
Arg [5] : _switchViewAddress (address): 0x6B4AAFE0A2C03B223b73a681b544b1617A976CcB
Arg [6] : _switchEventAddress (address): 0x410f724847C92Bc3CdACBCD4922F1D7833Ec280A
Arg [7] : _feeCollector (address): 0x28B9089b5f2724c1898E7dbb04a96C8C177fE46d

-----Encoded View---------------
12 Constructor Arguments found :
Arg [0] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [1] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [5] : 0000000000000000000000006b4aafe0a2c03b223b73a681b544b1617a976ccb
Arg [6] : 000000000000000000000000410f724847c92bc3cdacbcd4922f1d7833ec280a
Arg [7] : 00000000000000000000000028b9089b5f2724c1898e7dbb04a96c8c177fe46d
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [9] : 0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
Arg [10] : 000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac
Arg [11] : 000000000000000000000000115934131916c8b277dd010ee02de363c09d037c


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.