false
true
0

Contract Address Details

0x69033829f50244FD1be7BDC8e74aE0fF97E47126

Contract Name
SwitchRouter
Creator
0xf3b5e2–b7ead4 at 0xbfefae–601c1f
Balance
0 PLS ( )
Tokens
Fetching tokens...
Transactions
694 Transactions
Transfers
4,462 Transfers
Gas Used
593,477,774
Last Balance Update
25963429
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
SwitchRouter




Optimization enabled
true
Compiler version
v0.8.20+commit.a1b79de6




Optimization runs
999
EVM Version
shanghai




Verified at
2026-02-12T04:34:12.543233Z

Constructor Arguments

0x00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000260000000000000000000000000feaaa55b94b5cee8159244c49a44d0de79659817000000000000000000000000a1077a294dde1b09bb078844df40758a5d0f9a27000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000008730c3e2cf2c8cda8e6166837a1ed26f46aa9e59000000000000000000000000ff6b56d3f444eb5b7fa1db047f57140c84810376000000000000000000000000c8c50c6fac75b0d082d5b99f52581ca25ccb719f0000000000000000000000005d3ef85adcf1532e9111e4a6a331f6e5ddfb2d25000000000000000000000000a09a014f29812ec3aeefb85a5022a2f30b086c79000000000000000000000000161cdedee4d68bbd3c1c6214f5356c8394f065e50000000000000000000000007bbb21bdc6c94b90367a0b1835e1f233ab39d6a700000000000000000000000042cf246e6271feb2c3e6d14fc405ed0bf5152be2000000000000000000000000bb017a0da988b72f202cd19655361cdb57383802000000000000000000000000b2141992cb4500e7099bc6d7d3da405e63259dcf000000000000000000000000e3073faaed1490eab7b3e65f2a1659c9853d537900000000000000000000000020b13c2e3714c586b4969bd1a2eb8bdc8de8ada20000000000000000000000005fb575612178c6fc1e9570e78e0bcb1135d8cdd600000000000000000000000040cbcc9344090707cf858e41f551bedea332da770000000000000000000000000000000000000000000000000000000000000010000000000000000000000000a1077a294dde1b09bb078844df40758a5d0f9a270000000000000000000000002b591e99afe9f32eaa6214f7b7629768c40eeb3900000000000000000000000057fde0a71132198bbec939b98976993d8d89d22500000000000000000000000095b303987a60c71504d99aa1b13b4da07b0790ab0000000000000000000000002fa878ab3f87cc1c9737fc071108f904c0b0c95d00000000000000000000000002dcdd04e3f455d838cd1249292c58f3b79e3c3c00000000000000000000000015d38573d2feeb82e7ad5187ab8c1d52810b1f070000000000000000000000000cb6f5a34ad42ec934882a05265a7d5f59b51a2f000000000000000000000000efd766ccb38eaf1dfd701853bfce31359239f305000000000000000000000000cc78a0acdf847a2c1714d2a925bb4477df5d48a60000000000000000000000006ba0876e30cce2a9afc4b82d8bd8a8349df4ca96000000000000000000000000d6c31ba0754c4383a41c0e9df042c62b5e918f6d0000000000000000000000008da17db850315a34532108f0f5458fc0401525f6000000000000000000000000b17d901469b9208b17d916112988a3fed19b5ca1000000000000000000000000c10a4ed9b4042222d69ff0b374eddd47ed90fc1f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f
              

src/SwitchRouter.sol

// SPDX-License-Identifier: GPL-3.0-only
/*
             ++++++++++++++++++                                                                     
          +++++++++++++++++++++++++                                                                 
        ++++++++++++++++++++++++++++++                  +++++++++                                   
      +=++++++++++++++++++++++++++++++=++          ++=+++++===++++++++                              
    +++++++++++++++++++++++++++++++++++++++     ++++=++++++++++++++++++++                           
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                         
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                        
  +=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++==                       
 +=+++++++++++++++         +++++++++++++++++++++++++++++++++++++++++++++++++=++                     
 +++++++++++++++              ++=+++++++++++++++++++++++++++++++++++++++++++++++                    
 +++++++++++++++                 +++++++++++++++++++++++++    ++++++++++++++++++                    
 ++++++++++++++                    ++++++++++++++++++++         =++++++++++++++++                   
+++++++++++++++                     ++++++++++++++++++           ++++++++++++++++                   
+++++++++++++++                       ++++++++++++++              +++++++++++++=++                  
+++++++++++++++                         +++++++++++               ++++++++++++++++                  
 ++++++++++++++                          ++++++++                  +++++++++++++++                  
 +++++++++++++++                          ++++++                   ++=++++++++++++                  
 +++++++++++++++                            ++++                   +++++++++++++++                  
 ++++++++++++++++                            +=                    +++++++++++++++                  
  +++++++++++++++                                                  ++++++++++++++++                 
  ++++++++++++++++                                                 ++++++++++++++++++++             
   ++++++++++++++++                                               ++++++++++++++++++++++++          
   ++++++++++++++++                                               +++++++++++++++++++++++++++       
    +=++++++++++++++                                              ++++++++++++++++++++++++++++      
     +=++++++++++++++                                            +++++++++++++++++++++++++++++++    
     +++++++++++++++++                                           ++++++++++++++++++++++++++++++++   
      +++++++++++++++++                                          +++++++++++++++++++++++++++++++++  
       +++++++++++++++++                                                       ++++++++++++++++++++ 
        ++=++++++++++++++                                                         =++++++++++++++++ 
         +++++++++++++++++                                                          ++++++++++++++++
          ++++++++++++++++++                                                         +++++++++++++++
           ++++++++++++++++++                                                         ++++++++++++++
            +++++++++++++++++++                                                       ++++++++++++++
              +++++++++++++++==+                                                      ++++++++++++++
               +++++++++++++++++++                               ..                   ++++++++++++++
                ++++++++++++++++++                            .........               ++++++++++++++
                  ++=+++++++++++++                          .......                   ++++++++++++++
                  +==+++++++++++++                          .......                   ++++++++++++++
                  ++=+++++++++++++                          .......                   ++++++++++++++
                  ++=+++++++++++++                          ...                       ++++++++++++++
                  ++++++++++++++++                           ..                       ++++++++++++++
                  ++++++++++++++++                                                    ++++++++++++++
                  ++++++++++++++++                                                    ++++++++++++++
                  ++++++++++++++++                                                    ++++++++++++++
                  ++++++++++++++++                                                    ++++++++++++++
                  ++++++++++++++++                                                    ++++++++++++++
                  ++++++++++++++++                                                    ++++++++++++++
                  *++**++*******++                                                    ++++++++++++++
                  *++*************                                                    ++++++++++++++
                  **+*************                                                    **************
                  ****************                                                    **************
                   ***************                                                   ***************
                   ****************                                                  ***************
                   *****************#                                              *****************
                    *******************                                          ****************** 
                     *****************************************************************************  
                      ***************************************************************************   
                       *************************************************************************    
                         #################*****************************************************     
                          ##########################################################***#####*       
                            ###############################################################         
                               ###*######################################################           
                                  ###################################################    

                                  Switch.win
                                  https://Switch.win
                                  Built by: BuildTheTech.com           
*/

pragma solidity ^0.8.0;

import "./interface/ISwitchRouter.sol";
import "./interface/IAdapter.sol";
import "./interface/IERC20.sol";
import "./interface/IWETH.sol";
import "./lib/SafeERC20.sol";
import "./lib/Maintainable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract SwitchRouter is Maintainable, ReentrancyGuard {
    using SafeERC20 for IERC20;

    address public constant NATIVE = address(0);
    uint256 public constant FEE_DENOMINATOR = 1e4;
    uint256 public constant MAX_FEE = 100; // 1% maximum fee
    uint256 public MIN_FEE = 0;
    address public FEE_CLAIMER;
    address[] public TRUSTED_TOKENS;
    address[] public ADAPTERS;
    mapping(address => bool) public FEE_EXEMPT;
    mapping(address => bool) public MIN_FEE_EXEMPT;
    mapping(address => bool) public APPROVED_ADAPTERS;
    address public immutable WNATIVE;

    uint256 public constant PARTNER_FEE_SHARE = 5000; // 50% of fee goes to partner (in basis points of fee)

    // Events
    event SwitchSwap(address indexed _tokenIn, address indexed _tokenOut, uint256 _amountIn, uint256 _amountOut, address _partnerAddress);

    // Custom errors
    error InsufficientFee();
    error ExcessiveFee();
    error FinalAmountOutTooLow();
    error EmptySplit();
    error SplitMixedTokenIn();
    error SplitMixedTokenOut();
    error ZeroInput();
    error MsgValueMismatch();
    error PathNeedsBeginWithWPLS();
    error PathNeedsEndWithWPLS();
    error AdapterNotApproved(address adapter);
    error EmptyHop();
    error FeeNotSupported();

    struct MultiHopContext {
        address tokenIn;
        address tokenOut;
        uint256 grossIn;
        uint256 netIn;
        uint256 balanceBefore;
        uint256 totalOut;
        bool takeFee;
        address partnerAddress;
        address recipient;
        bool feeOnOutput;
        bool unwrapOutput;
        uint256 minTotalAmountOut;
    }

    constructor(
        address[] memory _adapters,
        address[] memory _trustedTokens,
        address _feeClaimer,
        address _wrapped_native
    ) {
        WNATIVE = _wrapped_native;
        setTrustedTokens(_trustedTokens);
        setFeeClaimer(_feeClaimer);
        setAdapters(_adapters);
    }

    // -- SETTERS --

    function setTrustedTokens(address[] memory _trustedTokens) public onlyMaintainer {
        TRUSTED_TOKENS = _trustedTokens;
    }

    function setAdapters(address[] memory _adapters) public onlyMaintainer {
        for (uint256 i = 0; i < ADAPTERS.length; i++) {
            APPROVED_ADAPTERS[ADAPTERS[i]] = false;
        }
        for (uint256 i = 0; i < _adapters.length; i++) {
            address adapter = _adapters[i];
            require(adapter != address(0), "Adapter address zero");
            APPROVED_ADAPTERS[adapter] = true;
        }
        ADAPTERS = _adapters;
    }


    function setMinFee(uint256 _fee) external onlyMaintainer {
        MIN_FEE = _fee;
    }

    function setFeeClaimer(address _claimer) public onlyMaintainer {
        FEE_CLAIMER = _claimer;
    }

    function setFeeExempt(address account, bool exempt) public onlyMaintainer {
        FEE_EXEMPT[account] = exempt;
    }

    function setMinFeeExempt(address account, bool exempt) public onlyMaintainer {
        MIN_FEE_EXEMPT[account] = exempt;
    }

    receive() external payable {}

    function adaptersCount() external view returns (uint256) {
        return ADAPTERS.length;
    }

    function trustedTokensCount() external view returns (uint256) {
        return TRUSTED_TOKENS.length;
    }

    function _requireApprovedAdapters(address[] calldata adapters) private view {
        for (uint256 i = 0; i < adapters.length; i++) {
            if (!APPROVED_ADAPTERS[adapters[i]]) revert AdapterNotApproved(adapters[i]);
        }
    }

    function _applyFee(uint256 _amountIn, uint256 _fee, bool _minFeeExempt) private view returns (uint256) {
        if (_fee > MAX_FEE) revert ExcessiveFee();
        if (!_minFeeExempt && _fee < MIN_FEE) revert InsufficientFee();
        return (_amountIn * (FEE_DENOMINATOR - _fee)) / FEE_DENOMINATOR;
    }

    /**
     * @notice Return tokens to user
     * @dev Pass address(0) for PLS
     * @param _token address
     * @param _amount tokens to return
     * @param _to address where funds should be sent to
     */
    function _returnTokensTo(
        address _token,
        uint256 _amount,
        address _to
    ) private {
        if (address(this) != _to) {
            if (_token == NATIVE) {
                (bool ok, ) = payable(_to).call{value: _amount}("");
                require(ok, "SwitchRouter: PLS transfer failed");
            } else {
                IERC20(_token).safeTransfer(_to, _amount);
            }
        }
    }

    function _transferFrom(address token, address _from, address _to, uint _amount) private {
        if (_from != address(this))
            IERC20(token).safeTransferFrom(_from, _to, _amount);
        else
            IERC20(token).safeTransfer(_to, _amount);
    }

    function _getPairAddr(address adapter, address tokenIn, address tokenOut) private view returns (address pair) {
        if (adapter.code.length == 0) return address(0);
        (bool ok, bytes memory data) = adapter.staticcall(abi.encodeWithSelector(0xe6a43905, tokenIn, tokenOut));
        if (ok && data.length >= 32) {
            pair = abi.decode(data, (address));
        }
    }

    function _prepareHopLegInput(
        address tokenIn,
        address tokenOut,
        address adapter,
        address source,
        uint256 plannedAmount
    ) private returns (uint256 actualAmount) {
        if (plannedAmount == 0) {
            return 0;
        }

        address target = _getPairAddr(adapter, tokenIn, tokenOut);
        if (target == address(0)) {
            target = adapter;
        }

        uint256 balBefore = IERC20(tokenIn).balanceOf(target);
        _transferFrom(tokenIn, source, target, plannedAmount);
        uint256 balAfter = IERC20(tokenIn).balanceOf(target);
        actualAmount = balAfter - balBefore;
        if (actualAmount == 0) revert ZeroInput();
    }

    function _executeHopLegSwap(
        address adapter,
        address tokenIn,
        address tokenOut,
        uint256 amountIn,
        address recipient
    ) private returns (uint256 actualOut) {
        uint256 balBefore = IERC20(tokenOut).balanceOf(recipient);
        IAdapter(adapter).swap(amountIn, 0, tokenIn, tokenOut, recipient);
        uint256 balAfter = IERC20(tokenOut).balanceOf(recipient);
        actualOut = balAfter - balBefore;
    }

    function _executeHopAllocation(
        HopAllocation calldata hop,
        address source,
        uint256 availableIn,
        address recipient
    ) private returns (uint256 hopOut) {
    if (hop.legs.length == 0) revert EmptyHop();
        if (availableIn == 0) revert ZeroInput();

        uint256 targetSum;
        for (uint256 i = 0; i < hop.legs.length; i++) {
            targetSum += hop.legs[i].amountIn;
        }
        if (targetSum == 0) revert ZeroInput();

        uint256 allocatedAvailable;

        for (uint256 i = 0; i < hop.legs.length; i++) {
            HopAdapterAllocation calldata leg = hop.legs[i];
            if (!APPROVED_ADAPTERS[leg.adapter]) revert AdapterNotApproved(leg.adapter);

            uint256 plannedIn;
            uint256 remainingAvailable = availableIn - allocatedAvailable;
            if (i + 1 == hop.legs.length) {
                plannedIn = remainingAvailable;
            } else if (targetSum == 0) {
                plannedIn = 0;
            } else {
                plannedIn = (leg.amountIn * availableIn) / targetSum;
                if (plannedIn > remainingAvailable) {
                    plannedIn = remainingAvailable;
                }
            }

            allocatedAvailable += plannedIn;

            if (plannedIn == 0) {
                continue;
            }

            {
                uint256 actualIn = _prepareHopLegInput(
                    hop.tokenIn,
                    hop.tokenOut,
                    leg.adapter,
                    source,
                    plannedIn
                );

                hopOut += _executeHopLegSwap(
                    leg.adapter,
                    hop.tokenIn,
                    hop.tokenOut,
                    actualIn,
                    recipient
                );
            }
        }
    }

    function _executeRouteAllocation(
        RouteAllocation calldata route,
        address payer,
        uint256 initialAmount,
        address finalRecipient
    ) private returns (uint256 routeOut, address finalToken) {
        uint256 hopCount = route.hops.length;
        if (hopCount == 0) revert EmptyHop();

        uint256 currentAmount = initialAmount;
        address currentSource = payer;
        address currentToken = route.hops[0].tokenIn;

        for (uint256 i = 0; i < hopCount; i++) {
            HopAllocation calldata hop = route.hops[i];
            if (hop.tokenIn != currentToken) revert SplitMixedTokenIn();
            address hopRecipient = (i == hopCount - 1 && finalRecipient != address(0))
                ? finalRecipient
                : address(this);
            uint256 hopOut = _executeHopAllocation(hop, currentSource, currentAmount, hopRecipient);
            currentSource = hopRecipient;
            currentAmount = hopOut;
            currentToken = hop.tokenOut;
        }

        return (currentAmount, currentToken);
    }

    /**
     * @notice Unified swap function supporting multi-path routes from the API
     * @param _routes Array of route allocations from the path-finding API
     * @param _to Recipient address for the output tokens
     * @param _minTotalAmountOut Minimum total output (slippage protection)
     * @param _fee Fee in basis points (FEE_DENOMINATOR = 1e4, so 100 = 1%)
     * @param _feeOnOutput If true, fee is taken from output token; if false, from input token
     * @param _unwrapOutput If true and output is WNATIVE, unwrap to native PLS
     * @param _partnerAddress Partner address to receive 50% of fees. Use address(0) for no partner.
     */
    function goSwitch(
        RouteAllocation[] calldata _routes,
        address _to,
        uint256 _minTotalAmountOut,
        uint256 _fee,
        bool _feeOnOutput,
        bool _unwrapOutput,
        address _partnerAddress
    ) public payable nonReentrant {
        if (_routes.length == 0) revert EmptySplit();
        
        MultiHopContext memory ctx;
        ctx.partnerAddress = _partnerAddress;
        ctx.recipient = _to;
        ctx.feeOnOutput = _feeOnOutput;
        ctx.unwrapOutput = _unwrapOutput;
        ctx.minTotalAmountOut = _minTotalAmountOut;
        (ctx.tokenIn, ctx.tokenOut, ctx.grossIn) = _validateRoutesMeta(_routes);

        {
            bool exempt = FEE_EXEMPT[msg.sender];
            if (exempt && _fee != 0) revert FeeNotSupported();
            ctx.takeFee = !exempt && (_fee > 0 || (MIN_FEE > 0 && !MIN_FEE_EXEMPT[msg.sender]));
        }

        bool minFeeExempt = MIN_FEE_EXEMPT[msg.sender];
        bool usingNativeIn = msg.value > 0;
        if (usingNativeIn) {
            if (ctx.tokenIn != WNATIVE) revert MsgValueMismatch();
            if (msg.value != ctx.grossIn) revert MsgValueMismatch();
            IWETH(WNATIVE).deposit{value: msg.value}();
        } else if (msg.value != 0) {
            revert MsgValueMismatch();
        }

        ctx.netIn = ctx.grossIn;
        if (ctx.takeFee && !ctx.feeOnOutput) {
            ctx.netIn = _applyFee(ctx.grossIn, _fee, minFeeExempt);
        }

        _executeGoSwitch(_routes, ctx, _fee, usingNativeIn, minFeeExempt);
    }

    function _executeGoSwitch(
        RouteAllocation[] calldata _routes,
        MultiHopContext memory ctx,
        uint256 _fee,
        bool usingNativeIn,
        bool minFeeExempt
    ) private {
        uint256[] memory scaledInputs = _scaleRouteAllocations(_routes, ctx.grossIn, ctx.netIn);

        // Take fee on input if applicable
        if (ctx.takeFee && !ctx.feeOnOutput) {
            _distributeFee(ctx.tokenIn, ctx.grossIn - ctx.netIn, ctx.partnerAddress, usingNativeIn);
        }

        // Determine settlement target
        bool unwrapToNative = ctx.unwrapOutput && (ctx.tokenOut == WNATIVE);
        address settlementTarget = ((ctx.takeFee && ctx.feeOnOutput) || unwrapToNative) ? address(this) : ctx.recipient;

        if (settlementTarget == address(this)) {
            ctx.balanceBefore = IERC20(ctx.tokenOut).balanceOf(address(this));
        }

        ctx.totalOut = _executeRoutes(
            _routes,
            scaledInputs,
            ctx.tokenOut,
            usingNativeIn ? address(this) : msg.sender,
            settlementTarget
        );

        if (settlementTarget == address(this)) {
            uint256 produced = IERC20(ctx.tokenOut).balanceOf(address(this)) - ctx.balanceBefore;
            if (produced < ctx.totalOut) {
                ctx.totalOut = produced;
            }
        }

        // Take fee on output if applicable
        if (ctx.takeFee && ctx.feeOnOutput) {
            uint256 netOut = _applyFee(ctx.totalOut, _fee, minFeeExempt);
            uint256 feeAmount = ctx.totalOut - netOut;
            if (feeAmount > 0) {
                _distributeOutputFee(ctx.tokenOut, feeAmount, ctx.partnerAddress);
            }
            ctx.totalOut = netOut;
        }

        if (ctx.totalOut < ctx.minTotalAmountOut) revert FinalAmountOutTooLow();

        // Finalize
        _finalizeSwap(ctx, usingNativeIn, unwrapToNative, settlementTarget);
    }

    function _finalizeSwap(
        MultiHopContext memory ctx,
        bool usingNativeIn,
        bool unwrapToNative,
        address settlementTarget
    ) private {
        address reportedTokenIn = usingNativeIn ? NATIVE : ctx.tokenIn;
        if (unwrapToNative) {
            IWETH(WNATIVE).withdraw(ctx.totalOut);
            _returnTokensTo(NATIVE, ctx.totalOut, ctx.recipient);
            emit SwitchSwap(reportedTokenIn, NATIVE, ctx.grossIn, ctx.totalOut, ctx.partnerAddress);
        } else if (settlementTarget == address(this)) {
            _returnTokensTo(ctx.tokenOut, ctx.totalOut, ctx.recipient);
            emit SwitchSwap(reportedTokenIn, ctx.tokenOut, ctx.grossIn, ctx.totalOut, ctx.partnerAddress);
        } else {
            emit SwitchSwap(reportedTokenIn, ctx.tokenOut, ctx.grossIn, ctx.totalOut, ctx.partnerAddress);
        }
    }

    /**
     * @notice Distributes input-side fee between partner (50%) and protocol (50%)
     */
    function _distributeFee(address token, uint256 feeAmount, address partner, bool fromContract) private {
        if (feeAmount == 0) return;
        if (partner != address(0)) {
            uint256 partnerShare = (feeAmount * PARTNER_FEE_SHARE) / FEE_DENOMINATOR;
            uint256 protocolShare = feeAmount - partnerShare;
            if (fromContract) {
                if (partnerShare > 0) IERC20(token).safeTransfer(partner, partnerShare);
                if (protocolShare > 0) IERC20(token).safeTransfer(FEE_CLAIMER, protocolShare);
            } else {
                if (partnerShare > 0) IERC20(token).safeTransferFrom(msg.sender, partner, partnerShare);
                if (protocolShare > 0) IERC20(token).safeTransferFrom(msg.sender, FEE_CLAIMER, protocolShare);
            }
        } else {
            if (fromContract) {
                IERC20(token).safeTransfer(FEE_CLAIMER, feeAmount);
            } else {
                IERC20(token).safeTransferFrom(msg.sender, FEE_CLAIMER, feeAmount);
            }
        }
    }

    /**
     * @notice Distributes output-side fee between partner (50%) and protocol (50%)
     */
    function _distributeOutputFee(address token, uint256 feeAmount, address partner) private {
        if (partner != address(0)) {
            uint256 partnerShare = (feeAmount * PARTNER_FEE_SHARE) / FEE_DENOMINATOR;
            uint256 protocolShare = feeAmount - partnerShare;
            if (partnerShare > 0) IERC20(token).safeTransfer(partner, partnerShare);
            if (protocolShare > 0) IERC20(token).safeTransfer(FEE_CLAIMER, protocolShare);
        } else {
            IERC20(token).safeTransfer(FEE_CLAIMER, feeAmount);
        }
    }

    function _finalizeMultiHopSwap(
        address tokenIn,
        address tokenOut,
        uint256 grossIn,
        uint256 totalOut,
        address recipient,
        address partnerAddress
    ) private {
        _returnTokensTo(tokenOut, totalOut, recipient);
        emit SwitchSwap(tokenIn, tokenOut, grossIn, totalOut, partnerAddress);
    }

    function _executeSingleRoute(
        RouteAllocation calldata route,
        address payer,
        uint256 routeInput,
        address expectedTokenOut,
        address finalRecipient
    ) private returns (uint256 routeOut) {
        address finalToken;
        (routeOut, finalToken) = _executeRouteAllocation(
            route,
            payer,
            routeInput,
            finalRecipient
        );

        if (finalToken != expectedTokenOut) revert SplitMixedTokenOut();
    }

    function _executeRoutes(
        RouteAllocation[] calldata routes,
        uint256[] memory scaledInputs,
        address expectedTokenOut,
        address payer,
        address finalRecipient
    ) private returns (uint256 totalOut) {
        uint256 routeCount = routes.length;
        for (uint256 i = 0; i < routeCount; i++) {
            RouteAllocation calldata route = routes[i];
            uint256 routeInput = scaledInputs[i];
            if (routeInput == 0) {
                continue;
            }

            uint256 routeOut = _executeSingleRoute(
                route,
                payer,
                routeInput,
                expectedTokenOut,
                finalRecipient
            );

            totalOut += routeOut;
        }
    }

    function _validateRoutesMeta(RouteAllocation[] calldata routes)
        private
        pure
        returns (address tokenIn, address tokenOut, uint256 grossIn)
    {
        RouteAllocation calldata firstRoute = routes[0];
        if (firstRoute.hops.length == 0) revert EmptyHop();
        tokenIn = firstRoute.hops[0].tokenIn;
        if (tokenIn == NATIVE) revert PathNeedsBeginWithWPLS();

        uint256 routeCount = routes.length;
        for (uint256 i = 0; i < routeCount; i++) {
            RouteAllocation calldata route = routes[i];
            if (route.hops.length == 0) revert EmptyHop();
            if (route.hops[0].tokenIn != tokenIn) revert SplitMixedTokenIn();

            address routeTokenOut = route.hops[route.hops.length - 1].tokenOut;
            if (routeTokenOut == NATIVE) revert PathNeedsEndWithWPLS();
            if (tokenOut == address(0)) {
                tokenOut = routeTokenOut;
            } else if (tokenOut != routeTokenOut) {
                revert SplitMixedTokenOut();
            }

            grossIn += route.amountIn;
        }

        if (grossIn == 0) revert ZeroInput();
        if (tokenOut == address(0)) revert SplitMixedTokenOut();
    }

    function _scaleRouteAllocations(
        RouteAllocation[] calldata routes,
        uint256 grossIn,
        uint256 netIn
    ) private pure returns (uint256[] memory inputs) {
        uint256 routeCount = routes.length;
        inputs = new uint256[](routeCount);

        uint256 remainingNet = netIn;

        for (uint256 i = 0; i < routeCount; i++) {
            RouteAllocation calldata route = routes[i];
            uint256 scaledIn;
            if (netIn == grossIn) {
                scaledIn = route.amountIn;
            } else if (i == routeCount - 1) {
                scaledIn = remainingNet;
            } else {
                scaledIn = (route.amountIn * netIn) / grossIn;
                if (scaledIn > remainingNet) {
                    scaledIn = remainingNet;
                }
            }

            inputs[i] = scaledIn;
            remainingNet -= scaledIn;
        }

        if (remainingNet > 0 && routeCount > 0) {
            inputs[routeCount - 1] += remainingNet;
        }
    }

    /**
     * @notice Recover ERC20 from contract
     * @param _tokenAddress token address
     * @param _tokenAmount amount to recover
     */
    function recoverERC20(address _tokenAddress, uint _tokenAmount) external onlyMaintainer {
        require(_tokenAmount > 0, "Nothing to recover");
        IERC20(_tokenAddress).safeTransfer(msg.sender, _tokenAmount);
    }

    /**
     * @notice Recover native asset from contract
     * @param _amount amount
     */
    function recoverNative(uint _amount) external onlyMaintainer {
        require(_amount > 0, "Nothing to recover");
        (bool ok, ) = payable(msg.sender).call{value: _amount}("");
        require(ok, "SwitchRouter: Native asset transfer failed");
    }
}
        

dependencies/openzeppelin-contracts/contracts/access/AccessControl.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(account),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}
          

dependencies/openzeppelin-contracts/contracts/access/IAccessControl.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}
          

dependencies/openzeppelin-contracts/contracts/security/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;
    }
}
          

dependencies/openzeppelin-contracts/contracts/utils/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;
    }
}
          

dependencies/openzeppelin-contracts/contracts/utils/Strings.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}
          

dependencies/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
          

dependencies/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
          

dependencies/openzeppelin-contracts/contracts/utils/math/Math.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @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.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}
          

dependencies/openzeppelin-contracts/contracts/utils/math/SignedMath.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}
          

src/interface/IAdapter.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IAdapter {
    function name() external view returns (string memory);

    function swapGasEstimate() external view returns (uint256);

    function swap(
        uint256,
        uint256,
        address,
        address,
        address
    ) external;

    function query(
        uint256,
        address,
        address
    ) external view returns (uint256);
}
          

src/interface/IERC20.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IERC20 {
    event Approval(address, address, uint256);
    event Transfer(address, address, uint256);

    function name() external view returns (string memory);

    function decimals() external view returns (uint8);

    function transferFrom(
        address,
        address,
        uint256
    ) external returns (bool);

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

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

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

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

    function nonces(address) external view returns (uint256); // Only tokens that support permit

    function permit(
        address,
        address,
        uint256,
        uint256,
        uint8,
        bytes32,
        bytes32
    ) external; // Only tokens that support permit

    function swap(address, uint256) external; // Only Avalanche bridge tokens

    function swapSupply(address) external view returns (uint256); // Only Avalanche bridge tokens

    function totalSupply() external view returns (uint256);
}
          

src/interface/ISwitchRouter.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;


struct Query {
    address adapter;
    address tokenIn;
    address tokenOut;
    uint256 amountOut;
}
struct Offer {
    bytes amounts;
    bytes adapters;
    bytes path;
    uint256 gasEstimate;
}
struct FormattedOffer {
    uint256[] amounts;
    address[] adapters;
    address[] path;
    uint256 gasEstimate;
}
struct Trade {
    uint256 amountIn;
    uint256 amountOut;
    address[] path;
    address[] adapters;
}

struct HopAdapterAllocation {
    address adapter;
    uint256 amountIn;
}

struct HopAllocation {
    address tokenIn;
    address tokenOut;
    HopAdapterAllocation[] legs;
}

struct RouteAllocation {
    uint256 amountIn;
    HopAllocation[] hops;
}

interface ISwitchRouter {

    event UpdatedTrustedTokens(address[] _newTrustedTokens);
    event UpdatedAdapters(address[] _newAdapters);
    event UpdatedMinFee(uint256 _oldMinFee, uint256 _newMinFee);
    event UpdatedFeeClaimer(address _oldFeeClaimer, address _newFeeClaimer);
    event SwitchSwap(address indexed _tokenIn, address indexed _tokenOut, uint256 _amountIn, uint256 _amountOut, address _partnerAddress);
    event UpdatedFeeExempt(address indexed account, bool exempt);

    // admin
    function setTrustedTokens(address[] memory _trustedTokens) external;
    function setAdapters(address[] memory _adapters) external;
    function setFeeClaimer(address _claimer) external;
    function setMinFee(uint256 _fee) external;
    function setFeeExempt(address account, bool exempt) external;
    function setMinFeeExempt(address account, bool exempt) external;
    function setFeeExemptBatch(address[] calldata accounts, bool[] calldata flags) external;
    function adaptersCount() external view returns (uint256);
    function trustedTokensCount() external view returns (uint256);
    function ADAPTERS(uint256 index) external view returns (address);
    function TRUSTED_TOKENS(uint256 index) external view returns (address);

    // query

    function queryAdapter(
        uint256 _amountIn,
        address _tokenIn,
        address _tokenOut,
        uint8 _index
    ) external returns (uint256);

    function queryNoSplit(
        uint256 _amountIn,
        address _tokenIn,
        address _tokenOut,
        uint8[] calldata _options
    ) external view returns (Query memory);

    function queryNoSplit(
        uint256 _amountIn,
        address _tokenIn,
        address _tokenOut
    ) external view returns (Query memory);

    function findBestPathWithGas(
        uint256 _amountIn,
        address _tokenIn,
        address _tokenOut,
        uint256 _maxSteps,
        uint256 _gasPrice
    ) external view returns (FormattedOffer memory);

    function findBestPath(
        uint256 _amountIn,
        address _tokenIn,
        address _tokenOut,
        uint256 _maxSteps
    ) external view returns (FormattedOffer memory);

    function findBestPathRange(
        uint256 _amountIn,
        address _tokenIn,
        address _tokenOut,
        uint256 _maxSteps,
        uint256 _trustedStart,
        uint256 _trustedCount
    ) external view returns (FormattedOffer memory);

    function findBestPathRangeWithGas(
        uint256 _amountIn,
        address _tokenIn,
        address _tokenOut,
        uint256 _maxSteps,
        uint256 _gasPrice,
        uint256 _trustedStart,
        uint256 _trustedCount
    ) external view returns (FormattedOffer memory);

    function queryAdaptersRange(
        uint256 _amountIn,
        address _tokenIn,
        address _tokenOut,
        uint256 _start,
        uint256 _count
    ) external view returns (Query[] memory results);

    function quoteSplit(Trade[] calldata _trades) external view returns (uint256 totalOut);

    // Unified swap function
    function goSwitch(
        RouteAllocation[] calldata _routes,
        address _to,
        uint256 _minTotalAmountOut,
        uint256 _fee,
        bool _feeOnOutput,
        bool _unwrapOutput,
        address _partnerAddress
    ) external payable;
}
          

src/interface/IWETH.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IERC20.sol";

interface IWETH is IERC20 {
    function withdraw(uint256 amount) external;

    function deposit() external payable;
}
          

src/lib/Maintainable.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which extends the basic access control mechanism of Ownable
 * to include many maintainers, whom only the owner (DEFAULT_ADMIN_ROLE) may add and
 * remove.
 *
 * 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 this modifier:
 * `onlyMaintainer`, which can be applied to your functions to restrict their use to
 * the accounts with the role of maintainer.
 */

abstract contract Maintainable is Context, AccessControl {
    bytes32 public constant MAINTAINER_ROLE = keccak256("MAINTAINER_ROLE");

    constructor() {
        address msgSender = _msgSender();
        // members of the DEFAULT_ADMIN_ROLE alone may revoke and grant role membership
        _setupRole(DEFAULT_ADMIN_ROLE, msgSender);
        _setupRole(MAINTAINER_ROLE, msgSender);
    }

    function addMaintainer(address addedMaintainer) public virtual {
        grantRole(MAINTAINER_ROLE, addedMaintainer);
    }

    function removeMaintainer(address removedMaintainer) public virtual {
        revokeRole(MAINTAINER_ROLE, removedMaintainer);
    }

    function renounceRole(bytes32 role) public virtual {
        address msgSender = _msgSender();
        renounceRole(role, msgSender);
    }

    function transferOwnership(address newOwner) public virtual {
        address msgSender = _msgSender();
        grantRole(DEFAULT_ADMIN_ROLE, newOwner);
        renounceRole(DEFAULT_ADMIN_ROLE, msgSender);
    }

    modifier onlyMaintainer() {
        address msgSender = _msgSender();
        require(hasRole(MAINTAINER_ROLE, msgSender), "Maintainable: Caller is not a maintainer");
        _;
    }
}
          

src/lib/SafeERC20.sol

// This is a simplified version of OpenZepplin's SafeERC20 library
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

import "../interface/IERC20.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 ERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

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

    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    /**
     * @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.

        // A Solidity high level call has three parts:
        //  1. The target address is checked to verify it contains contract code
        //  2. The call itself is made, and success asserted
        //  3. The return value is decoded, which in turn checks the size of the returned data.
        // solhint-disable-next-line max-line-length

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = address(token).call(data);
        require(success, "SafeERC20: low-level call failed");

        if (returndata.length > 0) {
            // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}
          

Compiler Settings

{"viaIR":false,"remappings":["@openzeppelin/contracts/=dependencies/openzeppelin-contracts/contracts/","forge-std/=dependencies/forge-std/src/","ds-test/=dependencies/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/","erc4626-tests/=dependencies/openzeppelin-contracts/lib/erc4626-tests/","openzeppelin-contracts/=dependencies/openzeppelin-contracts/","openzeppelin/=dependencies/openzeppelin-contracts/contracts/"],"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":999,"enabled":true},"metadata":{"useLiteralContent":false,"bytecodeHash":"ipfs","appendCBOR":true},"libraries":{},"evmVersion":"shanghai"}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address[]","name":"_adapters","internalType":"address[]"},{"type":"address[]","name":"_trustedTokens","internalType":"address[]"},{"type":"address","name":"_feeClaimer","internalType":"address"},{"type":"address","name":"_wrapped_native","internalType":"address"}]},{"type":"error","name":"AdapterNotApproved","inputs":[{"type":"address","name":"adapter","internalType":"address"}]},{"type":"error","name":"EmptyHop","inputs":[]},{"type":"error","name":"EmptySplit","inputs":[]},{"type":"error","name":"ExcessiveFee","inputs":[]},{"type":"error","name":"FeeNotSupported","inputs":[]},{"type":"error","name":"FinalAmountOutTooLow","inputs":[]},{"type":"error","name":"InsufficientFee","inputs":[]},{"type":"error","name":"MsgValueMismatch","inputs":[]},{"type":"error","name":"PathNeedsBeginWithWPLS","inputs":[]},{"type":"error","name":"PathNeedsEndWithWPLS","inputs":[]},{"type":"error","name":"SplitMixedTokenIn","inputs":[]},{"type":"error","name":"SplitMixedTokenOut","inputs":[]},{"type":"error","name":"ZeroInput","inputs":[]},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SwitchSwap","inputs":[{"type":"address","name":"_tokenIn","internalType":"address","indexed":true},{"type":"address","name":"_tokenOut","internalType":"address","indexed":true},{"type":"uint256","name":"_amountIn","internalType":"uint256","indexed":false},{"type":"uint256","name":"_amountOut","internalType":"uint256","indexed":false},{"type":"address","name":"_partnerAddress","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"ADAPTERS","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"APPROVED_ADAPTERS","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"FEE_CLAIMER","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"FEE_DENOMINATOR","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"FEE_EXEMPT","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"MAINTAINER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAX_FEE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MIN_FEE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"MIN_FEE_EXEMPT","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"NATIVE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PARTNER_FEE_SHARE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"TRUSTED_TOKENS","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"WNATIVE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"adaptersCount","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addMaintainer","inputs":[{"type":"address","name":"addedMaintainer","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"goSwitch","inputs":[{"type":"tuple[]","name":"_routes","internalType":"struct RouteAllocation[]","components":[{"type":"uint256","name":"amountIn","internalType":"uint256"},{"type":"tuple[]","name":"hops","internalType":"struct HopAllocation[]","components":[{"type":"address","name":"tokenIn","internalType":"address"},{"type":"address","name":"tokenOut","internalType":"address"},{"type":"tuple[]","name":"legs","internalType":"struct HopAdapterAllocation[]","components":[{"type":"address","name":"adapter","internalType":"address"},{"type":"uint256","name":"amountIn","internalType":"uint256"}]}]}]},{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_minTotalAmountOut","internalType":"uint256"},{"type":"uint256","name":"_fee","internalType":"uint256"},{"type":"bool","name":"_feeOnOutput","internalType":"bool"},{"type":"bool","name":"_unwrapOutput","internalType":"bool"},{"type":"address","name":"_partnerAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"recoverERC20","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256","name":"_tokenAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"recoverNative","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeMaintainer","inputs":[{"type":"address","name":"removedMaintainer","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setAdapters","inputs":[{"type":"address[]","name":"_adapters","internalType":"address[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFeeClaimer","inputs":[{"type":"address","name":"_claimer","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFeeExempt","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"bool","name":"exempt","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMinFee","inputs":[{"type":"uint256","name":"_fee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMinFeeExempt","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"bool","name":"exempt","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTrustedTokens","inputs":[{"type":"address[]","name":"_trustedTokens","internalType":"address[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"trustedTokensCount","inputs":[]},{"type":"receive","stateMutability":"payable"}]
              

Contract Creation Code

0x60a06040525f60025534801562000014575f80fd5b5060405162003bf738038062003bf7833981016040819052620000379162000583565b33620000445f82620000ad565b620000707f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab9582620000ad565b50600180556001600160a01b0381166080526200008d83620000bd565b620000988262000147565b620000a384620001d6565b5050505062000646565b620000b982826200038d565b5050565b335f8181525f8051602062003bb7833981519152602052604090205460ff166200012d5760405162461bcd60e51b815260206004820152602860248201525f8051602062003bd783398151915260448201526734b73a30b4b732b960c11b60648201526084015b60405180910390fd5b8151620001429060049060208501906200042b565b505050565b335f8181525f8051602062003bb7833981519152602052604090205460ff16620001b35760405162461bcd60e51b815260206004820152602860248201525f8051602062003bd783398151915260448201526734b73a30b4b732b960c11b606482015260840162000124565b50600380546001600160a01b0319166001600160a01b0392909216919091179055565b335f8181525f8051602062003bb7833981519152602052604090205460ff16620002425760405162461bcd60e51b815260206004820152602860248201525f8051602062003bd783398151915260448201526734b73a30b4b732b960c11b606482015260840162000124565b5f5b600554811015620002b1575f60085f600584815481106200026957620002696200060d565b5f918252602080832091909101546001600160a01b031683528201929092526040019020805460ff191691151591909117905580620002a88162000621565b91505062000244565b505f5b825181101562000377575f838281518110620002d457620002d46200060d565b602002602001015190505f6001600160a01b0316816001600160a01b031603620003415760405162461bcd60e51b815260206004820152601460248201527f416461707465722061646472657373207a65726f000000000000000000000000604482015260640162000124565b6001600160a01b03165f908152600860205260409020805460ff19166001179055806200036e8162000621565b915050620002b4565b508151620001429060059060208501906200042b565b5f828152602081815260408083206001600160a01b038516845290915290205460ff16620000b9575f828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620003e73390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b828054828255905f5260205f2090810192821562000481579160200282015b828111156200048157825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906200044a565b506200048f92915062000493565b5090565b5b808211156200048f575f815560010162000494565b634e487b7160e01b5f52604160045260245ffd5b80516001600160a01b0381168114620004d4575f80fd5b919050565b5f82601f830112620004e9575f80fd5b815160206001600160401b0380831115620005085762000508620004a9565b8260051b604051601f19603f83011681018181108482111715620005305762000530620004a9565b6040529384528581018301938381019250878511156200054e575f80fd5b83870191505b8482101562000578576200056882620004bd565b8352918301919083019062000554565b979650505050505050565b5f805f806080858703121562000597575f80fd5b84516001600160401b0380821115620005ae575f80fd5b620005bc88838901620004d9565b95506020870151915080821115620005d2575f80fd5b50620005e187828801620004d9565b935050620005f260408601620004bd565b91506200060260608601620004bd565b905092959194509250565b634e487b7160e01b5f52603260045260245ffd5b5f600182016200063f57634e487b7160e01b5f52601160045260245ffd5b5060010190565b60805161353c6200067b5f395f81816105a601528181610bd501528181610c4e015281816118f2015261203e015261353c5ff3fe60806040526004361061022b575f3560e01c80638ebfc79611610131578063bc063e1a116100ac578063d73792a91161007c578063f2fde38b11610062578063f2fde38b1461066d578063f36cbd351461068c578063f8742254146106a1575f80fd5b8063d73792a914610639578063d8baf7cf1461064e575f80fd5b8063bc063e1a146105c8578063c3accd48146105dc578063c8a3a5c6146105fb578063d547741f1461061a575f80fd5b8063a217fddf11610101578063a58ce279116100e7578063a58ce27914610548578063aede369314610576578063b381cf4014610595575f80fd5b8063a217fddf14610516578063a261e24614610529575f80fd5b80638ebfc7961461048357806391d14854146104a2578063952e9012146104e4578063a0cf0aea14610503575f80fd5b80633a9a4081116101c157806376c7a3c7116101915780637c7a561b116101775780637c7a561b146104315780638980f11f146104455780638bb9c5bf14610464575f80fd5b806376c7a3c71461040857806376ebe69c1461041d575f80fd5b80633a9a4081146103985780634d170179146103b757806352a52ab0146103ca5780636b453c1f146103e9575f80fd5b8063248a9ca3116101fc578063248a9ca3146102fd5780632f2ff15d1461033957806331ac99201461035a57806336568abe14610379575f80fd5b8062b99e361461023657806301ffc9a71461027257806313f7b889146102a1578063141b3e47146102cf575f80fd5b3661023257005b5f80fd5b348015610241575f80fd5b50600354610255906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561027d575f80fd5b5061029161028c366004612fbd565b6106d4565b6040519015158152602001610269565b3480156102ac575f80fd5b506102916102bb366004613008565b60076020525f908152604090205460ff1681565b3480156102da575f80fd5b506102916102e9366004613008565b60086020525f908152604090205460ff1681565b348015610308575f80fd5b5061032b610317366004613023565b5f9081526020819052604090206001015490565b604051908152602001610269565b348015610344575f80fd5b5061035861035336600461303a565b61073c565b005b348015610365575f80fd5b50610358610374366004613023565b610765565b348015610384575f80fd5b5061035861039336600461303a565b6107fe565b3480156103a3575f80fd5b506103586103b236600461307c565b61088a565b6103586103c5366004613148565b610a51565b3480156103d5575f80fd5b506102556103e4366004613023565b610d3c565b3480156103f4575f80fd5b50610358610403366004613008565b610d64565b348015610413575f80fd5b5061032b60025481565b348015610428575f80fd5b5060045461032b565b34801561043c575f80fd5b5060055461032b565b348015610450575f80fd5b5061035861045f366004613208565b610d91565b34801561046f575f80fd5b5061035861047e366004613023565b610e82565b34801561048e575f80fd5b5061035861049d366004613232565b610e8d565b3480156104ad575f80fd5b506102916104bc36600461303a565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156104ef575f80fd5b506102556104fe366004613023565b610f46565b34801561050e575f80fd5b506102555f81565b348015610521575f80fd5b5061032b5f81565b348015610534575f80fd5b50610358610543366004613232565b610f55565b348015610553575f80fd5b50610291610562366004613008565b60066020525f908152604090205460ff1681565b348015610581575f80fd5b50610358610590366004613023565b61100e565b3480156105a0575f80fd5b506102557f000000000000000000000000000000000000000000000000000000000000000081565b3480156105d3575f80fd5b5061032b606481565b3480156105e7575f80fd5b506103586105f6366004613008565b6111a6565b348015610606575f80fd5b5061035861061536600461307c565b611264565b348015610625575f80fd5b5061035861063436600461303a565b611305565b348015610644575f80fd5b5061032b61271081565b348015610659575f80fd5b50610358610668366004613008565b611329565b348015610678575f80fd5b50610358610687366004613008565b611353565b348015610697575f80fd5b5061032b61138881565b3480156106ac575f80fd5b5061032b7f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab9581565b5f6001600160e01b031982167f7965db0b00000000000000000000000000000000000000000000000000000000148061073657507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b5f8281526020819052604090206001015461075681611368565b6107608383611372565b505050565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff166107f85760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084015b60405180910390fd5b50600255565b6001600160a01b038116331461087c5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016107ef565b610886828261140e565b5050565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff166109185760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b5f5b600554811015610980575f60085f6005848154811061093b5761093b61325e565b5f918252602080832091909101546001600160a01b031683528201929092526040019020805460ff19169115159190911790558061097881613286565b91505061091a565b505f5b8251811015610a3d575f83828151811061099f5761099f61325e565b602002602001015190505f6001600160a01b0316816001600160a01b031603610a0a5760405162461bcd60e51b815260206004820152601460248201527f416461707465722061646472657373207a65726f00000000000000000000000060448201526064016107ef565b6001600160a01b03165f908152600860205260409020805460ff1916600117905580610a3581613286565b915050610983565b508151610760906005906020850190612f39565b610a5961148b565b5f879003610a93576040517f5725cad200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051610180810182525f80825260208201819052918101829052606081018290526080810182905260a0810182905260c08101919091526001600160a01b0382811660e083015287166101008201528315156101208201528215156101408201526101608101869052610b0889896114e4565b6040808501919091526001600160a01b03918216602080860191909152929091168352335f908152600690925290205460ff16808015610b4757508515155b15610b7e576040517f7362012200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80158015610bb057505f861180610bb057505f600254118015610bb05750335f9081526007602052604090205460ff16155b151560c083015250335f9081526007602052604090205460ff163415801590610cc1577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316835f01516001600160a01b031614610c285760405163bc6f88c560e01b815260040160405180910390fd5b82604001513414610c4c5760405163bc6f88c560e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004015f604051808303818588803b158015610ca5575f80fd5b505af1158015610cb7573d5f803e3d5ffd5b5050505050610ce0565b3415610ce05760405163bc6f88c560e01b815260040160405180910390fd5b6040830151606084015260c08301518015610cfe5750826101200151155b15610d1857610d12836040015188846117e0565b60608401525b610d268b8b858a858761188d565b505050610d3260018055565b5050505050505050565b60048181548110610d4b575f80fd5b5f918252602090912001546001600160a01b0316905081565b610d8e7f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab958261073c565b50565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff16610e1f5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b5f8211610e6e5760405162461bcd60e51b815260206004820152601260248201527f4e6f7468696e6720746f207265636f766572000000000000000000000000000060448201526064016107ef565b6107606001600160a01b0384163384611b5b565b3361088682826107fe565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff16610f1b5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b506001600160a01b03919091165f908152600660205260409020805460ff1916911515919091179055565b60058181548110610d4b575f80fd5b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff16610fe35760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b506001600160a01b03919091165f908152600760205260409020805460ff1916911515919091179055565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff1661109c5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b5f82116110eb5760405162461bcd60e51b815260206004820152601260248201527f4e6f7468696e6720746f207265636f766572000000000000000000000000000060448201526064016107ef565b6040515f90339084908381818185875af1925050503d805f811461112a576040519150601f19603f3d011682016040523d82523d5f602084013e61112f565b606091505b50509050806107605760405162461bcd60e51b815260206004820152602a60248201527f537769746368526f757465723a204e6174697665206173736574207472616e7360448201527f666572206661696c65640000000000000000000000000000000000000000000060648201526084016107ef565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff166112345760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b506003805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff166112f25760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b8151610760906004906020850190612f39565b5f8281526020819052604090206001015461131f81611368565b610760838361140e565b610d8e7f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab9582611305565b3361135e5f8361073c565b6108865f826107fe565b610d8e8133611bec565b5f828152602081815260408083206001600160a01b038516845290915290205460ff16610886575f828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556113ca3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f828152602081815260408083206001600160a01b038516845290915290205460ff1615610886575f828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6002600154036114dd5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107ef565b6002600155565b5f805f3685855f8181106114fa576114fa61325e565b905060200281019061150c919061329e565b905061151b60208201826132bc565b90505f0361153c576040516358cf7ac560e11b815260040160405180910390fd5b61154960208201826132bc565b5f8181106115595761155961325e565b905060200281019061156b9190613309565b611579906020810190613008565b93506001600160a01b0384166115bb576040517f906478dc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845f5b8181101561178f57368888838181106115d9576115d961325e565b90506020028101906115eb919061329e565b90506115fa60208201826132bc565b90505f0361161b576040516358cf7ac560e11b815260040160405180910390fd5b6001600160a01b03871661163260208301836132bc565b5f8181106116425761164261325e565b90506020028101906116549190613309565b611662906020810190613008565b6001600160a01b03161461168957604051636e75c5bd60e11b815260040160405180910390fd5b5f61169760208301836132bc565b60016116a660208601866132bc565b6116b192915061331d565b8181106116c0576116c061325e565b90506020028101906116d29190613309565b6116e3906040810190602001613008565b90506001600160a01b038116611725576040517f037ccaee00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03871661173b5780965061176d565b806001600160a01b0316876001600160a01b03161461176d57604051631169a32360e21b815260040160405180910390fd5b611778823587613330565b95505050808061178790613286565b9150506115be565b50825f036117b05760405163af458c0760e01b815260040160405180910390fd5b6001600160a01b0384166117d757604051631169a32360e21b815260040160405180910390fd5b50509250925092565b5f606483111561181c576040517f2977da4400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8115801561182b575060025483105b15611862576040517f025dbdd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61271061186f848261331d565b6118799086613343565b611883919061335a565b90505b9392505050565b5f6118a2878787604001518860600151611c5e565b90508460c0015180156118b85750846101200151155b156118e2578451606086015160408701516118e292916118d79161331d565b8760e0015186611db5565b5f856101400151801561192a57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031686602001516001600160a01b0316145b90505f8660c00151801561194057508661012001515b806119485750815b61195757866101000151611959565b305b9050306001600160a01b038216036119dd5760208701516040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156119b3573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119d79190613379565b60808801525b6119fb8989858a60200151896119f357336119f5565b305b86611ec3565b60a0880152306001600160a01b03821603611aa457608087015160208801516040516370a0823160e01b81523060048201525f92916001600160a01b0316906370a0823190602401602060405180830381865afa158015611a5e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a829190613379565b611a8c919061331d565b90508760a00151811015611aa25760a088018190525b505b8660c001518015611ab757508661012001515b15611b01575f611acc8860a0015188876117e0565b90505f818960a00151611adf919061331d565b90508015611afa57611afa8960200151828b60e00151611f5f565b5060a08801525b8661016001518760a001511015611b44576040517f4a2ab02300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611b5087868484611ff2565b505050505050505050565b6040516001600160a01b0383166024820152604481018290526107609084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990931692909217909152612244565b5f828152602081815260408083206001600160a01b038516845290915290205460ff1661088657611c1c8161237b565b611c2783602061238d565b604051602001611c389291906133b2565b60408051601f198184030181529082905262461bcd60e51b82526107ef91600401613432565b6060838067ffffffffffffffff811115611c7a57611c7a613068565b604051908082528060200260200182016040528015611ca3578160200160208202803683370190505b509150825f5b82811015611d625736888883818110611cc457611cc461325e565b9050602002810190611cd6919061329e565b90505f878703611ce857508035611d23565b611cf360018661331d565b8303611d00575082611d23565b87611d0c888435613343565b611d16919061335a565b905083811115611d235750825b80868481518110611d3657611d3661325e565b6020908102919091010152611d4b818561331d565b935050508080611d5a90613286565b915050611ca9565b505f81118015611d7157505f82115b15611dab578083611d8360018561331d565b81518110611d9357611d9361325e565b60200260200101818151611da79190613330565b9052505b5050949350505050565b8215611ebd576001600160a01b03821615611e7c575f612710611dda61138886613343565b611de4919061335a565b90505f611df1828661331d565b90508215611e38578115611e1357611e136001600160a01b0387168584611b5b565b8015611e3357600354611e33906001600160a01b03888116911683611b5b565b611e75565b8115611e5357611e536001600160a01b038716338685612568565b8015611e7557600354611e75906001600160a01b038881169133911684612568565b5050611ebd565b8015611ea157600354611e9c906001600160a01b03868116911685611b5b565b611ebd565b600354611ebd906001600160a01b038681169133911686612568565b50505050565b5f85815b81811015611f535736898983818110611ee257611ee261325e565b9050602002810190611ef4919061329e565b90505f888381518110611f0957611f0961325e565b60200260200101519050805f03611f21575050611f41565b5f611f2f8389848c8b6125b9565b9050611f3b8187613330565b95505050505b80611f4b81613286565b915050611ec7565b50509695505050505050565b6001600160a01b03811615611fd8575f612710611f7e61138885613343565b611f88919061335a565b90505f611f95828561331d565b90508115611fb157611fb16001600160a01b0386168484611b5b565b8015611fd157600354611fd1906001600160a01b03878116911683611b5b565b5050505050565b600354610760906001600160a01b03858116911684611b5b565b5f83611fff578451612001565b5f5b9050821561212b5760a08501516040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815260048101919091527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d906024015f604051808303815f87803b158015612087575f80fd5b505af1158015612099573d5f803e3d5ffd5b505050506120b15f8660a00151876101000151612602565b5f6001600160a01b0316816001600160a01b03167ffdf6a636f583731c29d5073a94997855dcc027a1a3eb9567c005ff60dc0570e987604001518860a001518960e0015160405161211e9392919092835260208301919091526001600160a01b0316604082015260600190565b60405180910390a3611fd1565b306001600160a01b038316036121c45761215385602001518660a00151876101000151612602565b84602001516001600160a01b0316816001600160a01b03167ffdf6a636f583731c29d5073a94997855dcc027a1a3eb9567c005ff60dc0570e987604001518860a001518960e0015160405161211e9392919092835260208301919091526001600160a01b0316604082015260600190565b84602001516001600160a01b0316816001600160a01b03167ffdf6a636f583731c29d5073a94997855dcc027a1a3eb9567c005ff60dc0570e987604001518860a001518960e001516040516122359392919092835260208301919091526001600160a01b0316604082015260600190565b60405180910390a35050505050565b5f80836001600160a01b03168360405161225e9190613464565b5f604051808303815f865af19150503d805f8114612297576040519150601f19603f3d011682016040523d82523d5f602084013e61229c565b606091505b5091509150816122ee5760405162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656460448201526064016107ef565b805115611ebd57808060200190518101906123099190613475565b611ebd5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107ef565b60606107366001600160a01b03831660145b60605f61239b836002613343565b6123a6906002613330565b67ffffffffffffffff8111156123be576123be613068565b6040519080825280601f01601f1916602001820160405280156123e8576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000815f8151811061241e5761241e61325e565b60200101906001600160f81b03191690815f1a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106124685761246861325e565b60200101906001600160f81b03191690815f1a9053505f61248a846002613343565b612495906001613330565b90505b6001811115612519577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106124d6576124d661325e565b1a60f81b8282815181106124ec576124ec61325e565b60200101906001600160f81b03191690815f1a90535060049490941c9361251281613490565b9050612498565b5083156118865760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107ef565b6040516001600160a01b0380851660248301528316604482015260648101829052611ebd9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401611ba0565b5f806125c7878787866126f9565b90925090506001600160a01b03808216908516146125f857604051631169a32360e21b815260040160405180910390fd5b5095945050505050565b306001600160a01b03821614610760576001600160a01b0383166126e5575f816001600160a01b0316836040515f6040518083038185875af1925050503d805f8114612669576040519150601f19603f3d011682016040523d82523d5f602084013e61266e565b606091505b5050905080611ebd5760405162461bcd60e51b815260206004820152602160248201527f537769746368526f757465723a20504c53207472616e73666572206661696c6560448201527f640000000000000000000000000000000000000000000000000000000000000060648201526084016107ef565b6107606001600160a01b0384168284611b5b565b5f808061270960208801886132bc565b90509050805f0361272d576040516358cf7ac560e11b815260040160405180910390fd5b84865f61273d60208b018b6132bc565b5f81811061274d5761274d61325e565b905060200281019061275f9190613309565b61276d906020810190613008565b90505f5b84811015612857573661278760208d018d6132bc565b838181106127975761279761325e565b90506020028101906127a99190613309565b90506001600160a01b0383166127c26020830183613008565b6001600160a01b0316146127e957604051636e75c5bd60e11b815260040160405180910390fd5b5f6127f560018861331d565b8314801561280b57506001600160a01b038a1615155b6128155730612817565b895b90505f61282683878985612868565b96509094508490508561283f6040840160208501613008565b9450505050808061284f90613286565b915050612771565b509199919850909650505050505050565b5f61287660408601866134a5565b90505f03612897576040516358cf7ac560e11b815260040160405180910390fd5b825f036128b75760405163af458c0760e01b815260040160405180910390fd5b5f805b6128c760408801886134a5565b9050811015612916576128dd60408801886134a5565b828181106128ed576128ed61325e565b90506040020160200135826129029190613330565b91508061290e81613286565b9150506128ba565b50805f036129375760405163af458c0760e01b815260040160405180910390fd5b5f805b61294760408901896134a5565b9050811015612b0e573661295e60408a018a6134a5565b8381811061296e5761296e61325e565b604002919091019150600890505f6129896020840184613008565b6001600160a01b0316815260208101919091526040015f205460ff166129f4576129b66020820182613008565b6040517f0c48343e0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201526024016107ef565b5f80612a00858a61331d565b9050612a0f60408c018c6134a5565b9050612a1c856001613330565b03612a2957809150612a5f565b855f03612a38575f9150612a5f565b85612a478a6020860135613343565b612a51919061335a565b915080821115612a5f578091505b612a698286613330565b9450815f03612a7a57505050612afc565b5f612ab2612a8b60208e018e613008565b8d6020016020810190612a9e9190613008565b612aab6020880188613008565b8e87612b19565b9050612aeb612ac46020860186613008565b612ad160208f018f613008565b8e6020016020810190612ae49190613008565b848d612c66565b612af59089613330565b9750505050505b80612b0681613286565b91505061293a565b505050949350505050565b5f815f03612b2857505f612c5d565b5f612b34858888612de4565b90506001600160a01b038116612b475750835b6040516370a0823160e01b81526001600160a01b0382811660048301525f91908916906370a0823190602401602060405180830381865afa158015612b8e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612bb29190613379565b9050612bc088868487612f00565b6040516370a0823160e01b81526001600160a01b0383811660048301525f91908a16906370a0823190602401602060405180830381865afa158015612c07573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c2b9190613379565b9050612c37828261331d565b9350835f03612c595760405163af458c0760e01b815260040160405180910390fd5b5050505b95945050505050565b6040516370a0823160e01b81526001600160a01b0382811660048301525f9182918616906370a0823190602401602060405180830381865afa158015612cae573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612cd29190613379565b6040517feab90da6000000000000000000000000000000000000000000000000000000008152600481018690525f60248201526001600160a01b038881166044830152878116606483015285811660848301529192509088169063eab90da69060a4015f604051808303815f87803b158015612d4c575f80fd5b505af1158015612d5e573d5f803e3d5ffd5b50506040516370a0823160e01b81526001600160a01b0386811660048301525f9350881691506370a0823190602401602060405180830381865afa158015612da8573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612dcc9190613379565b9050612dd8828261331d565b98975050505050505050565b5f836001600160a01b03163b5f03612dfd57505f611886565b604080516001600160a01b03858116602483015284811660448084019190915283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fe6a439050000000000000000000000000000000000000000000000000000000017905291515f92839290881691612e8a9190613464565b5f60405180830381855afa9150503d805f8114612ec2576040519150601f19603f3d011682016040523d82523d5f602084013e612ec7565b606091505b5091509150818015612edb57506020815110155b15612ef75780806020019051810190612ef491906134eb565b92505b50509392505050565b6001600160a01b0383163014612f2557611e9c6001600160a01b038516848484612568565b611ebd6001600160a01b0385168383611b5b565b828054828255905f5260205f20908101928215612f99579160200282015b82811115612f99578251825473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03909116178255602090920191600190910190612f57565b50612fa5929150612fa9565b5090565b5b80821115612fa5575f8155600101612faa565b5f60208284031215612fcd575f80fd5b81356001600160e01b031981168114611886575f80fd5b6001600160a01b0381168114610d8e575f80fd5b803561300381612fe4565b919050565b5f60208284031215613018575f80fd5b813561188681612fe4565b5f60208284031215613033575f80fd5b5035919050565b5f806040838503121561304b575f80fd5b82359150602083013561305d81612fe4565b809150509250929050565b634e487b7160e01b5f52604160045260245ffd5b5f602080838503121561308d575f80fd5b823567ffffffffffffffff808211156130a4575f80fd5b818501915085601f8301126130b7575f80fd5b8135818111156130c9576130c9613068565b8060051b604051601f19603f830116810181811085821117156130ee576130ee613068565b60405291825284820192508381018501918883111561310b575f80fd5b938501935b82851015612dd85761312185612ff8565b84529385019392850192613110565b8015158114610d8e575f80fd5b803561300381613130565b5f805f805f805f8060e0898b03121561315f575f80fd5b883567ffffffffffffffff80821115613176575f80fd5b818b0191508b601f830112613189575f80fd5b813581811115613197575f80fd5b8c60208260051b85010111156131ab575f80fd5b60209283019a5098506131c1918b019050612ff8565b955060408901359450606089013593506131dd60808a0161313d565b92506131eb60a08a0161313d565b91506131f960c08a01612ff8565b90509295985092959890939650565b5f8060408385031215613219575f80fd5b823561322481612fe4565b946020939093013593505050565b5f8060408385031215613243575f80fd5b823561324e81612fe4565b9150602083013561305d81613130565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b5f6001820161329757613297613272565b5060010190565b5f8235603e198336030181126132b2575f80fd5b9190910192915050565b5f808335601e198436030181126132d1575f80fd5b83018035915067ffffffffffffffff8211156132eb575f80fd5b6020019150600581901b3603821315613302575f80fd5b9250929050565b5f8235605e198336030181126132b2575f80fd5b8181038181111561073657610736613272565b8082018082111561073657610736613272565b808202811582820484141761073657610736613272565b5f8261337457634e487b7160e01b5f52601260045260245ffd5b500490565b5f60208284031215613389575f80fd5b5051919050565b5f5b838110156133aa578181015183820152602001613392565b50505f910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f83516133e9816017850160208801613390565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613426816028840160208801613390565b01602801949350505050565b602081525f8251806020840152613450816040850160208701613390565b601f01601f19169190910160400192915050565b5f82516132b2818460208701613390565b5f60208284031215613485575f80fd5b815161188681613130565b5f8161349e5761349e613272565b505f190190565b5f808335601e198436030181126134ba575f80fd5b83018035915067ffffffffffffffff8211156134d4575f80fd5b6020019150600681901b3603821315613302575f80fd5b5f602082840312156134fb575f80fd5b815161188681612fe456fea26469706673582212200639e9d2180a6d7ea603c786f22e78d10ea99f9665272ea6ce15c4c74c3c10e064736f6c63430008140033a54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d394d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000260000000000000000000000000feaaa55b94b5cee8159244c49a44d0de79659817000000000000000000000000a1077a294dde1b09bb078844df40758a5d0f9a27000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000008730c3e2cf2c8cda8e6166837a1ed26f46aa9e59000000000000000000000000ff6b56d3f444eb5b7fa1db047f57140c84810376000000000000000000000000c8c50c6fac75b0d082d5b99f52581ca25ccb719f0000000000000000000000005d3ef85adcf1532e9111e4a6a331f6e5ddfb2d25000000000000000000000000a09a014f29812ec3aeefb85a5022a2f30b086c79000000000000000000000000161cdedee4d68bbd3c1c6214f5356c8394f065e50000000000000000000000007bbb21bdc6c94b90367a0b1835e1f233ab39d6a700000000000000000000000042cf246e6271feb2c3e6d14fc405ed0bf5152be2000000000000000000000000bb017a0da988b72f202cd19655361cdb57383802000000000000000000000000b2141992cb4500e7099bc6d7d3da405e63259dcf000000000000000000000000e3073faaed1490eab7b3e65f2a1659c9853d537900000000000000000000000020b13c2e3714c586b4969bd1a2eb8bdc8de8ada20000000000000000000000005fb575612178c6fc1e9570e78e0bcb1135d8cdd600000000000000000000000040cbcc9344090707cf858e41f551bedea332da770000000000000000000000000000000000000000000000000000000000000010000000000000000000000000a1077a294dde1b09bb078844df40758a5d0f9a270000000000000000000000002b591e99afe9f32eaa6214f7b7629768c40eeb3900000000000000000000000057fde0a71132198bbec939b98976993d8d89d22500000000000000000000000095b303987a60c71504d99aa1b13b4da07b0790ab0000000000000000000000002fa878ab3f87cc1c9737fc071108f904c0b0c95d00000000000000000000000002dcdd04e3f455d838cd1249292c58f3b79e3c3c00000000000000000000000015d38573d2feeb82e7ad5187ab8c1d52810b1f070000000000000000000000000cb6f5a34ad42ec934882a05265a7d5f59b51a2f000000000000000000000000efd766ccb38eaf1dfd701853bfce31359239f305000000000000000000000000cc78a0acdf847a2c1714d2a925bb4477df5d48a60000000000000000000000006ba0876e30cce2a9afc4b82d8bd8a8349df4ca96000000000000000000000000d6c31ba0754c4383a41c0e9df042c62b5e918f6d0000000000000000000000008da17db850315a34532108f0f5458fc0401525f6000000000000000000000000b17d901469b9208b17d916112988a3fed19b5ca1000000000000000000000000c10a4ed9b4042222d69ff0b374eddd47ed90fc1f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f

Deployed ByteCode

0x60806040526004361061022b575f3560e01c80638ebfc79611610131578063bc063e1a116100ac578063d73792a91161007c578063f2fde38b11610062578063f2fde38b1461066d578063f36cbd351461068c578063f8742254146106a1575f80fd5b8063d73792a914610639578063d8baf7cf1461064e575f80fd5b8063bc063e1a146105c8578063c3accd48146105dc578063c8a3a5c6146105fb578063d547741f1461061a575f80fd5b8063a217fddf11610101578063a58ce279116100e7578063a58ce27914610548578063aede369314610576578063b381cf4014610595575f80fd5b8063a217fddf14610516578063a261e24614610529575f80fd5b80638ebfc7961461048357806391d14854146104a2578063952e9012146104e4578063a0cf0aea14610503575f80fd5b80633a9a4081116101c157806376c7a3c7116101915780637c7a561b116101775780637c7a561b146104315780638980f11f146104455780638bb9c5bf14610464575f80fd5b806376c7a3c71461040857806376ebe69c1461041d575f80fd5b80633a9a4081146103985780634d170179146103b757806352a52ab0146103ca5780636b453c1f146103e9575f80fd5b8063248a9ca3116101fc578063248a9ca3146102fd5780632f2ff15d1461033957806331ac99201461035a57806336568abe14610379575f80fd5b8062b99e361461023657806301ffc9a71461027257806313f7b889146102a1578063141b3e47146102cf575f80fd5b3661023257005b5f80fd5b348015610241575f80fd5b50600354610255906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561027d575f80fd5b5061029161028c366004612fbd565b6106d4565b6040519015158152602001610269565b3480156102ac575f80fd5b506102916102bb366004613008565b60076020525f908152604090205460ff1681565b3480156102da575f80fd5b506102916102e9366004613008565b60086020525f908152604090205460ff1681565b348015610308575f80fd5b5061032b610317366004613023565b5f9081526020819052604090206001015490565b604051908152602001610269565b348015610344575f80fd5b5061035861035336600461303a565b61073c565b005b348015610365575f80fd5b50610358610374366004613023565b610765565b348015610384575f80fd5b5061035861039336600461303a565b6107fe565b3480156103a3575f80fd5b506103586103b236600461307c565b61088a565b6103586103c5366004613148565b610a51565b3480156103d5575f80fd5b506102556103e4366004613023565b610d3c565b3480156103f4575f80fd5b50610358610403366004613008565b610d64565b348015610413575f80fd5b5061032b60025481565b348015610428575f80fd5b5060045461032b565b34801561043c575f80fd5b5060055461032b565b348015610450575f80fd5b5061035861045f366004613208565b610d91565b34801561046f575f80fd5b5061035861047e366004613023565b610e82565b34801561048e575f80fd5b5061035861049d366004613232565b610e8d565b3480156104ad575f80fd5b506102916104bc36600461303a565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156104ef575f80fd5b506102556104fe366004613023565b610f46565b34801561050e575f80fd5b506102555f81565b348015610521575f80fd5b5061032b5f81565b348015610534575f80fd5b50610358610543366004613232565b610f55565b348015610553575f80fd5b50610291610562366004613008565b60066020525f908152604090205460ff1681565b348015610581575f80fd5b50610358610590366004613023565b61100e565b3480156105a0575f80fd5b506102557f000000000000000000000000a1077a294dde1b09bb078844df40758a5d0f9a2781565b3480156105d3575f80fd5b5061032b606481565b3480156105e7575f80fd5b506103586105f6366004613008565b6111a6565b348015610606575f80fd5b5061035861061536600461307c565b611264565b348015610625575f80fd5b5061035861063436600461303a565b611305565b348015610644575f80fd5b5061032b61271081565b348015610659575f80fd5b50610358610668366004613008565b611329565b348015610678575f80fd5b50610358610687366004613008565b611353565b348015610697575f80fd5b5061032b61138881565b3480156106ac575f80fd5b5061032b7f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab9581565b5f6001600160e01b031982167f7965db0b00000000000000000000000000000000000000000000000000000000148061073657507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b5f8281526020819052604090206001015461075681611368565b6107608383611372565b505050565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff166107f85760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084015b60405180910390fd5b50600255565b6001600160a01b038116331461087c5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016107ef565b610886828261140e565b5050565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff166109185760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b5f5b600554811015610980575f60085f6005848154811061093b5761093b61325e565b5f918252602080832091909101546001600160a01b031683528201929092526040019020805460ff19169115159190911790558061097881613286565b91505061091a565b505f5b8251811015610a3d575f83828151811061099f5761099f61325e565b602002602001015190505f6001600160a01b0316816001600160a01b031603610a0a5760405162461bcd60e51b815260206004820152601460248201527f416461707465722061646472657373207a65726f00000000000000000000000060448201526064016107ef565b6001600160a01b03165f908152600860205260409020805460ff1916600117905580610a3581613286565b915050610983565b508151610760906005906020850190612f39565b610a5961148b565b5f879003610a93576040517f5725cad200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051610180810182525f80825260208201819052918101829052606081018290526080810182905260a0810182905260c08101919091526001600160a01b0382811660e083015287166101008201528315156101208201528215156101408201526101608101869052610b0889896114e4565b6040808501919091526001600160a01b03918216602080860191909152929091168352335f908152600690925290205460ff16808015610b4757508515155b15610b7e576040517f7362012200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80158015610bb057505f861180610bb057505f600254118015610bb05750335f9081526007602052604090205460ff16155b151560c083015250335f9081526007602052604090205460ff163415801590610cc1577f000000000000000000000000a1077a294dde1b09bb078844df40758a5d0f9a276001600160a01b0316835f01516001600160a01b031614610c285760405163bc6f88c560e01b815260040160405180910390fd5b82604001513414610c4c5760405163bc6f88c560e01b815260040160405180910390fd5b7f000000000000000000000000a1077a294dde1b09bb078844df40758a5d0f9a276001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004015f604051808303818588803b158015610ca5575f80fd5b505af1158015610cb7573d5f803e3d5ffd5b5050505050610ce0565b3415610ce05760405163bc6f88c560e01b815260040160405180910390fd5b6040830151606084015260c08301518015610cfe5750826101200151155b15610d1857610d12836040015188846117e0565b60608401525b610d268b8b858a858761188d565b505050610d3260018055565b5050505050505050565b60048181548110610d4b575f80fd5b5f918252602090912001546001600160a01b0316905081565b610d8e7f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab958261073c565b50565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff16610e1f5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b5f8211610e6e5760405162461bcd60e51b815260206004820152601260248201527f4e6f7468696e6720746f207265636f766572000000000000000000000000000060448201526064016107ef565b6107606001600160a01b0384163384611b5b565b3361088682826107fe565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff16610f1b5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b506001600160a01b03919091165f908152600660205260409020805460ff1916911515919091179055565b60058181548110610d4b575f80fd5b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff16610fe35760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b506001600160a01b03919091165f908152600760205260409020805460ff1916911515919091179055565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff1661109c5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b5f82116110eb5760405162461bcd60e51b815260206004820152601260248201527f4e6f7468696e6720746f207265636f766572000000000000000000000000000060448201526064016107ef565b6040515f90339084908381818185875af1925050503d805f811461112a576040519150601f19603f3d011682016040523d82523d5f602084013e61112f565b606091505b50509050806107605760405162461bcd60e51b815260206004820152602a60248201527f537769746368526f757465723a204e6174697665206173736574207472616e7360448201527f666572206661696c65640000000000000000000000000000000000000000000060648201526084016107ef565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff166112345760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b506003805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff166112f25760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b60648201526084016107ef565b8151610760906004906020850190612f39565b5f8281526020819052604090206001015461131f81611368565b610760838361140e565b610d8e7f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab9582611305565b3361135e5f8361073c565b6108865f826107fe565b610d8e8133611bec565b5f828152602081815260408083206001600160a01b038516845290915290205460ff16610886575f828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556113ca3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f828152602081815260408083206001600160a01b038516845290915290205460ff1615610886575f828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6002600154036114dd5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107ef565b6002600155565b5f805f3685855f8181106114fa576114fa61325e565b905060200281019061150c919061329e565b905061151b60208201826132bc565b90505f0361153c576040516358cf7ac560e11b815260040160405180910390fd5b61154960208201826132bc565b5f8181106115595761155961325e565b905060200281019061156b9190613309565b611579906020810190613008565b93506001600160a01b0384166115bb576040517f906478dc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845f5b8181101561178f57368888838181106115d9576115d961325e565b90506020028101906115eb919061329e565b90506115fa60208201826132bc565b90505f0361161b576040516358cf7ac560e11b815260040160405180910390fd5b6001600160a01b03871661163260208301836132bc565b5f8181106116425761164261325e565b90506020028101906116549190613309565b611662906020810190613008565b6001600160a01b03161461168957604051636e75c5bd60e11b815260040160405180910390fd5b5f61169760208301836132bc565b60016116a660208601866132bc565b6116b192915061331d565b8181106116c0576116c061325e565b90506020028101906116d29190613309565b6116e3906040810190602001613008565b90506001600160a01b038116611725576040517f037ccaee00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03871661173b5780965061176d565b806001600160a01b0316876001600160a01b03161461176d57604051631169a32360e21b815260040160405180910390fd5b611778823587613330565b95505050808061178790613286565b9150506115be565b50825f036117b05760405163af458c0760e01b815260040160405180910390fd5b6001600160a01b0384166117d757604051631169a32360e21b815260040160405180910390fd5b50509250925092565b5f606483111561181c576040517f2977da4400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8115801561182b575060025483105b15611862576040517f025dbdd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61271061186f848261331d565b6118799086613343565b611883919061335a565b90505b9392505050565b5f6118a2878787604001518860600151611c5e565b90508460c0015180156118b85750846101200151155b156118e2578451606086015160408701516118e292916118d79161331d565b8760e0015186611db5565b5f856101400151801561192a57507f000000000000000000000000a1077a294dde1b09bb078844df40758a5d0f9a276001600160a01b031686602001516001600160a01b0316145b90505f8660c00151801561194057508661012001515b806119485750815b61195757866101000151611959565b305b9050306001600160a01b038216036119dd5760208701516040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa1580156119b3573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119d79190613379565b60808801525b6119fb8989858a60200151896119f357336119f5565b305b86611ec3565b60a0880152306001600160a01b03821603611aa457608087015160208801516040516370a0823160e01b81523060048201525f92916001600160a01b0316906370a0823190602401602060405180830381865afa158015611a5e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a829190613379565b611a8c919061331d565b90508760a00151811015611aa25760a088018190525b505b8660c001518015611ab757508661012001515b15611b01575f611acc8860a0015188876117e0565b90505f818960a00151611adf919061331d565b90508015611afa57611afa8960200151828b60e00151611f5f565b5060a08801525b8661016001518760a001511015611b44576040517f4a2ab02300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611b5087868484611ff2565b505050505050505050565b6040516001600160a01b0383166024820152604481018290526107609084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990931692909217909152612244565b5f828152602081815260408083206001600160a01b038516845290915290205460ff1661088657611c1c8161237b565b611c2783602061238d565b604051602001611c389291906133b2565b60408051601f198184030181529082905262461bcd60e51b82526107ef91600401613432565b6060838067ffffffffffffffff811115611c7a57611c7a613068565b604051908082528060200260200182016040528015611ca3578160200160208202803683370190505b509150825f5b82811015611d625736888883818110611cc457611cc461325e565b9050602002810190611cd6919061329e565b90505f878703611ce857508035611d23565b611cf360018661331d565b8303611d00575082611d23565b87611d0c888435613343565b611d16919061335a565b905083811115611d235750825b80868481518110611d3657611d3661325e565b6020908102919091010152611d4b818561331d565b935050508080611d5a90613286565b915050611ca9565b505f81118015611d7157505f82115b15611dab578083611d8360018561331d565b81518110611d9357611d9361325e565b60200260200101818151611da79190613330565b9052505b5050949350505050565b8215611ebd576001600160a01b03821615611e7c575f612710611dda61138886613343565b611de4919061335a565b90505f611df1828661331d565b90508215611e38578115611e1357611e136001600160a01b0387168584611b5b565b8015611e3357600354611e33906001600160a01b03888116911683611b5b565b611e75565b8115611e5357611e536001600160a01b038716338685612568565b8015611e7557600354611e75906001600160a01b038881169133911684612568565b5050611ebd565b8015611ea157600354611e9c906001600160a01b03868116911685611b5b565b611ebd565b600354611ebd906001600160a01b038681169133911686612568565b50505050565b5f85815b81811015611f535736898983818110611ee257611ee261325e565b9050602002810190611ef4919061329e565b90505f888381518110611f0957611f0961325e565b60200260200101519050805f03611f21575050611f41565b5f611f2f8389848c8b6125b9565b9050611f3b8187613330565b95505050505b80611f4b81613286565b915050611ec7565b50509695505050505050565b6001600160a01b03811615611fd8575f612710611f7e61138885613343565b611f88919061335a565b90505f611f95828561331d565b90508115611fb157611fb16001600160a01b0386168484611b5b565b8015611fd157600354611fd1906001600160a01b03878116911683611b5b565b5050505050565b600354610760906001600160a01b03858116911684611b5b565b5f83611fff578451612001565b5f5b9050821561212b5760a08501516040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815260048101919091527f000000000000000000000000a1077a294dde1b09bb078844df40758a5d0f9a276001600160a01b031690632e1a7d4d906024015f604051808303815f87803b158015612087575f80fd5b505af1158015612099573d5f803e3d5ffd5b505050506120b15f8660a00151876101000151612602565b5f6001600160a01b0316816001600160a01b03167ffdf6a636f583731c29d5073a94997855dcc027a1a3eb9567c005ff60dc0570e987604001518860a001518960e0015160405161211e9392919092835260208301919091526001600160a01b0316604082015260600190565b60405180910390a3611fd1565b306001600160a01b038316036121c45761215385602001518660a00151876101000151612602565b84602001516001600160a01b0316816001600160a01b03167ffdf6a636f583731c29d5073a94997855dcc027a1a3eb9567c005ff60dc0570e987604001518860a001518960e0015160405161211e9392919092835260208301919091526001600160a01b0316604082015260600190565b84602001516001600160a01b0316816001600160a01b03167ffdf6a636f583731c29d5073a94997855dcc027a1a3eb9567c005ff60dc0570e987604001518860a001518960e001516040516122359392919092835260208301919091526001600160a01b0316604082015260600190565b60405180910390a35050505050565b5f80836001600160a01b03168360405161225e9190613464565b5f604051808303815f865af19150503d805f8114612297576040519150601f19603f3d011682016040523d82523d5f602084013e61229c565b606091505b5091509150816122ee5760405162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656460448201526064016107ef565b805115611ebd57808060200190518101906123099190613475565b611ebd5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107ef565b60606107366001600160a01b03831660145b60605f61239b836002613343565b6123a6906002613330565b67ffffffffffffffff8111156123be576123be613068565b6040519080825280601f01601f1916602001820160405280156123e8576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000815f8151811061241e5761241e61325e565b60200101906001600160f81b03191690815f1a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106124685761246861325e565b60200101906001600160f81b03191690815f1a9053505f61248a846002613343565b612495906001613330565b90505b6001811115612519577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106124d6576124d661325e565b1a60f81b8282815181106124ec576124ec61325e565b60200101906001600160f81b03191690815f1a90535060049490941c9361251281613490565b9050612498565b5083156118865760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107ef565b6040516001600160a01b0380851660248301528316604482015260648101829052611ebd9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401611ba0565b5f806125c7878787866126f9565b90925090506001600160a01b03808216908516146125f857604051631169a32360e21b815260040160405180910390fd5b5095945050505050565b306001600160a01b03821614610760576001600160a01b0383166126e5575f816001600160a01b0316836040515f6040518083038185875af1925050503d805f8114612669576040519150601f19603f3d011682016040523d82523d5f602084013e61266e565b606091505b5050905080611ebd5760405162461bcd60e51b815260206004820152602160248201527f537769746368526f757465723a20504c53207472616e73666572206661696c6560448201527f640000000000000000000000000000000000000000000000000000000000000060648201526084016107ef565b6107606001600160a01b0384168284611b5b565b5f808061270960208801886132bc565b90509050805f0361272d576040516358cf7ac560e11b815260040160405180910390fd5b84865f61273d60208b018b6132bc565b5f81811061274d5761274d61325e565b905060200281019061275f9190613309565b61276d906020810190613008565b90505f5b84811015612857573661278760208d018d6132bc565b838181106127975761279761325e565b90506020028101906127a99190613309565b90506001600160a01b0383166127c26020830183613008565b6001600160a01b0316146127e957604051636e75c5bd60e11b815260040160405180910390fd5b5f6127f560018861331d565b8314801561280b57506001600160a01b038a1615155b6128155730612817565b895b90505f61282683878985612868565b96509094508490508561283f6040840160208501613008565b9450505050808061284f90613286565b915050612771565b509199919850909650505050505050565b5f61287660408601866134a5565b90505f03612897576040516358cf7ac560e11b815260040160405180910390fd5b825f036128b75760405163af458c0760e01b815260040160405180910390fd5b5f805b6128c760408801886134a5565b9050811015612916576128dd60408801886134a5565b828181106128ed576128ed61325e565b90506040020160200135826129029190613330565b91508061290e81613286565b9150506128ba565b50805f036129375760405163af458c0760e01b815260040160405180910390fd5b5f805b61294760408901896134a5565b9050811015612b0e573661295e60408a018a6134a5565b8381811061296e5761296e61325e565b604002919091019150600890505f6129896020840184613008565b6001600160a01b0316815260208101919091526040015f205460ff166129f4576129b66020820182613008565b6040517f0c48343e0000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201526024016107ef565b5f80612a00858a61331d565b9050612a0f60408c018c6134a5565b9050612a1c856001613330565b03612a2957809150612a5f565b855f03612a38575f9150612a5f565b85612a478a6020860135613343565b612a51919061335a565b915080821115612a5f578091505b612a698286613330565b9450815f03612a7a57505050612afc565b5f612ab2612a8b60208e018e613008565b8d6020016020810190612a9e9190613008565b612aab6020880188613008565b8e87612b19565b9050612aeb612ac46020860186613008565b612ad160208f018f613008565b8e6020016020810190612ae49190613008565b848d612c66565b612af59089613330565b9750505050505b80612b0681613286565b91505061293a565b505050949350505050565b5f815f03612b2857505f612c5d565b5f612b34858888612de4565b90506001600160a01b038116612b475750835b6040516370a0823160e01b81526001600160a01b0382811660048301525f91908916906370a0823190602401602060405180830381865afa158015612b8e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612bb29190613379565b9050612bc088868487612f00565b6040516370a0823160e01b81526001600160a01b0383811660048301525f91908a16906370a0823190602401602060405180830381865afa158015612c07573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c2b9190613379565b9050612c37828261331d565b9350835f03612c595760405163af458c0760e01b815260040160405180910390fd5b5050505b95945050505050565b6040516370a0823160e01b81526001600160a01b0382811660048301525f9182918616906370a0823190602401602060405180830381865afa158015612cae573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612cd29190613379565b6040517feab90da6000000000000000000000000000000000000000000000000000000008152600481018690525f60248201526001600160a01b038881166044830152878116606483015285811660848301529192509088169063eab90da69060a4015f604051808303815f87803b158015612d4c575f80fd5b505af1158015612d5e573d5f803e3d5ffd5b50506040516370a0823160e01b81526001600160a01b0386811660048301525f9350881691506370a0823190602401602060405180830381865afa158015612da8573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612dcc9190613379565b9050612dd8828261331d565b98975050505050505050565b5f836001600160a01b03163b5f03612dfd57505f611886565b604080516001600160a01b03858116602483015284811660448084019190915283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fe6a439050000000000000000000000000000000000000000000000000000000017905291515f92839290881691612e8a9190613464565b5f60405180830381855afa9150503d805f8114612ec2576040519150601f19603f3d011682016040523d82523d5f602084013e612ec7565b606091505b5091509150818015612edb57506020815110155b15612ef75780806020019051810190612ef491906134eb565b92505b50509392505050565b6001600160a01b0383163014612f2557611e9c6001600160a01b038516848484612568565b611ebd6001600160a01b0385168383611b5b565b828054828255905f5260205f20908101928215612f99579160200282015b82811115612f99578251825473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03909116178255602090920191600190910190612f57565b50612fa5929150612fa9565b5090565b5b80821115612fa5575f8155600101612faa565b5f60208284031215612fcd575f80fd5b81356001600160e01b031981168114611886575f80fd5b6001600160a01b0381168114610d8e575f80fd5b803561300381612fe4565b919050565b5f60208284031215613018575f80fd5b813561188681612fe4565b5f60208284031215613033575f80fd5b5035919050565b5f806040838503121561304b575f80fd5b82359150602083013561305d81612fe4565b809150509250929050565b634e487b7160e01b5f52604160045260245ffd5b5f602080838503121561308d575f80fd5b823567ffffffffffffffff808211156130a4575f80fd5b818501915085601f8301126130b7575f80fd5b8135818111156130c9576130c9613068565b8060051b604051601f19603f830116810181811085821117156130ee576130ee613068565b60405291825284820192508381018501918883111561310b575f80fd5b938501935b82851015612dd85761312185612ff8565b84529385019392850192613110565b8015158114610d8e575f80fd5b803561300381613130565b5f805f805f805f8060e0898b03121561315f575f80fd5b883567ffffffffffffffff80821115613176575f80fd5b818b0191508b601f830112613189575f80fd5b813581811115613197575f80fd5b8c60208260051b85010111156131ab575f80fd5b60209283019a5098506131c1918b019050612ff8565b955060408901359450606089013593506131dd60808a0161313d565b92506131eb60a08a0161313d565b91506131f960c08a01612ff8565b90509295985092959890939650565b5f8060408385031215613219575f80fd5b823561322481612fe4565b946020939093013593505050565b5f8060408385031215613243575f80fd5b823561324e81612fe4565b9150602083013561305d81613130565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b5f6001820161329757613297613272565b5060010190565b5f8235603e198336030181126132b2575f80fd5b9190910192915050565b5f808335601e198436030181126132d1575f80fd5b83018035915067ffffffffffffffff8211156132eb575f80fd5b6020019150600581901b3603821315613302575f80fd5b9250929050565b5f8235605e198336030181126132b2575f80fd5b8181038181111561073657610736613272565b8082018082111561073657610736613272565b808202811582820484141761073657610736613272565b5f8261337457634e487b7160e01b5f52601260045260245ffd5b500490565b5f60208284031215613389575f80fd5b5051919050565b5f5b838110156133aa578181015183820152602001613392565b50505f910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f83516133e9816017850160208801613390565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613426816028840160208801613390565b01602801949350505050565b602081525f8251806020840152613450816040850160208701613390565b601f01601f19169190910160400192915050565b5f82516132b2818460208701613390565b5f60208284031215613485575f80fd5b815161188681613130565b5f8161349e5761349e613272565b505f190190565b5f808335601e198436030181126134ba575f80fd5b83018035915067ffffffffffffffff8211156134d4575f80fd5b6020019150600681901b3603821315613302575f80fd5b5f602082840312156134fb575f80fd5b815161188681612fe456fea26469706673582212200639e9d2180a6d7ea603c786f22e78d10ea99f9665272ea6ce15c4c74c3c10e064736f6c63430008140033