ETH Price: $2,423.51 (-0.02%)
 

Overview

ETH Balance

0.000155987375096362 ETH

Eth Value

$0.38 (@ $2,423.51/ETH)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Contract Call By...205155882024-08-12 22:41:3583 days ago1723502495IN
0x08cB5679...90adfB1f0
0.00035203 ETH0.001490222.39149272
Set Max Partner ...204875932024-08-09 0:55:4787 days ago1723164947IN
0x08cB5679...90adfB1f0
0 ETH0.000090013.02529316
Contract Call By...201594702024-06-24 5:31:11133 days ago1719207071IN
0x08cB5679...90adfB1f0
0.00311448 ETH0.00194452.68051264
Contract Call By...200971822024-06-15 12:26:11142 days ago1718454371IN
0x08cB5679...90adfB1f0
0.01629835 ETH0.004232065.84944994
Contract Call By...200855242024-06-13 21:17:11143 days ago1718313431IN
0x08cB5679...90adfB1f0
0.01630167 ETH0.006505799.29448536
Contract Call By...200596042024-06-10 6:20:59147 days ago1718000459IN
0x08cB5679...90adfB1f0
0.00027503 ETH0.002287993.59742276
Contract Call By...200559552024-06-09 18:07:47148 days ago1717956467IN
0x08cB5679...90adfB1f0
0.50027655 ETH0.00678259.35720762
Contract Call By...200343512024-06-06 17:43:35151 days ago1717695815IN
0x08cB5679...90adfB1f0
0.0153006 ETH0.0232256232.96761775
Contract Call By...200257662024-06-05 12:55:59152 days ago1717592159IN
0x08cB5679...90adfB1f0
0.0134888 ETH0.0155464321.53466127
Contract Call By...200203052024-06-04 18:39:23152 days ago1717526363IN
0x08cB5679...90adfB1f0
0.0502782 ETH0.009569513.6636683
Contract Call By...200197552024-06-04 16:49:23153 days ago1717519763IN
0x08cB5679...90adfB1f0
0.02028749 ETH0.0144123820
Contract Call By...200120362024-06-03 14:57:35154 days ago1717426655IN
0x08cB5679...90adfB1f0
0.0137831 ETH0.0056450525.25097294
Contract Call By...200060452024-06-02 18:51:59154 days ago1717354319IN
0x08cB5679...90adfB1f0
0.01427817 ETH0.007224310.27395619
Contract Call By...199871752024-05-31 3:37:11157 days ago1717126631IN
0x08cB5679...90adfB1f0
0.0152782 ETH0.0074796410.68576611
Contract Call By...199843002024-05-30 17:59:35158 days ago1717091975IN
0x08cB5679...90adfB1f0
0.00028944 ETH0.0153960823.44270441
Contract Call By...199836952024-05-30 15:57:35158 days ago1717084655IN
0x08cB5679...90adfB1f0
0.02028926 ETH0.0133524518.34024951
Contract Call By...199817282024-05-30 9:19:47158 days ago1717060787IN
0x08cB5679...90adfB1f0
0.0202798 ETH0.0072772610.17389244
Contract Call By...199813632024-05-30 8:06:47158 days ago1717056407IN
0x08cB5679...90adfB1f0
0.02029553 ETH0.0117251116.69641989
Contract Call By...199799802024-05-30 3:28:23158 days ago1717039703IN
0x08cB5679...90adfB1f0
0.02527476 ETH0.004858156.94022612
Contract Call By...199786762024-05-29 23:05:23158 days ago1717023923IN
0x08cB5679...90adfB1f0
0.10027517 ETH0.003179598.15406375
Contract Call By...199647562024-05-28 0:22:35160 days ago1716855755IN
0x08cB5679...90adfB1f0
0.00227667 ETH0.006731099.63548829
Contract Call By...199646082024-05-27 23:52:59160 days ago1716853979IN
0x08cB5679...90adfB1f0
0.00027824 ETH0.006352810.57315229
Contract Call By...199643892024-05-27 23:08:35160 days ago1716851315IN
0x08cB5679...90adfB1f0
0.00027608 ETH0.0058665310.01897971
Contract Call By...199643762024-05-27 23:05:59160 days ago1716851159IN
0x08cB5679...90adfB1f0
0.00027683 ETH0.0080415713.16190103
Contract Call By...199559792024-05-26 18:55:59161 days ago1716749759IN
0x08cB5679...90adfB1f0
0.00024975 ETH0.003818426.89448478
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
205155882024-08-12 22:41:3583 days ago1723502495
0x08cB5679...90adfB1f0
0.00035203 ETH
201594702024-06-24 5:31:11133 days ago1719207071
0x08cB5679...90adfB1f0
0.00111448 ETH
201594702024-06-24 5:31:11133 days ago1719207071
0x08cB5679...90adfB1f0
0.001998 ETH
201594702024-06-24 5:31:11133 days ago1719207071
0x08cB5679...90adfB1f0
0.000002 ETH
200971822024-06-15 12:26:11142 days ago1718454371
0x08cB5679...90adfB1f0
0.00029835 ETH
200971822024-06-15 12:26:11142 days ago1718454371
0x08cB5679...90adfB1f0
0.015984 ETH
200971822024-06-15 12:26:11142 days ago1718454371
0x08cB5679...90adfB1f0
0.000016 ETH
200855242024-06-13 21:17:11143 days ago1718313431
0x08cB5679...90adfB1f0
0.00030167 ETH
200855242024-06-13 21:17:11143 days ago1718313431
0x08cB5679...90adfB1f0
0.015984 ETH
200855242024-06-13 21:17:11143 days ago1718313431
0x08cB5679...90adfB1f0
0.000016 ETH
200596042024-06-10 6:20:59147 days ago1718000459
0x08cB5679...90adfB1f0
0.00027503 ETH
200559552024-06-09 18:07:47148 days ago1717956467
0x08cB5679...90adfB1f0
0.00027655 ETH
200559552024-06-09 18:07:47148 days ago1717956467
0x08cB5679...90adfB1f0
0.4995 ETH
200559552024-06-09 18:07:47148 days ago1717956467
0x08cB5679...90adfB1f0
0.0005 ETH
200343512024-06-06 17:43:35151 days ago1717695815
0x08cB5679...90adfB1f0
0.0003006 ETH
200343512024-06-06 17:43:35151 days ago1717695815
0x08cB5679...90adfB1f0
0.014985 ETH
200343512024-06-06 17:43:35151 days ago1717695815
0x08cB5679...90adfB1f0
0.000015 ETH
200257662024-06-05 12:55:59152 days ago1717592159
0x08cB5679...90adfB1f0
0.0002888 ETH
200257662024-06-05 12:55:59152 days ago1717592159
0x08cB5679...90adfB1f0
0.0131868 ETH
200257662024-06-05 12:55:59152 days ago1717592159
0x08cB5679...90adfB1f0
0.0000132 ETH
200203052024-06-04 18:39:23152 days ago1717526363
0x08cB5679...90adfB1f0
0.0002782 ETH
200203052024-06-04 18:39:23152 days ago1717526363
0x08cB5679...90adfB1f0
0.04995 ETH
200203052024-06-04 18:39:23152 days ago1717526363
0x08cB5679...90adfB1f0
0.00005 ETH
200197552024-06-04 16:49:23153 days ago1717519763
0x08cB5679...90adfB1f0
0.00028749 ETH
200197552024-06-04 16:49:23153 days ago1717519763
0x08cB5679...90adfB1f0
0.01998 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SwitchContractCallStargateSender

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 23 : SwitchContractCallStargateSender.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

import "../dexs/Switch.sol";
import { IStargateRouter, IFactory, IPool } from "../interfaces/IStargateRouter.sol";
import { IStargateEthRouter } from "../interfaces/IStargateEthRouter.sol";
import "../lib/DataTypes.sol";

contract SwitchContractCallStargateSender is Switch {
    using UniversalERC20 for IERC20;
    using SafeERC20 for IERC20;

    address public stargateRouter;

    struct ContractCallArgsStargate {
        DataTypes.SwapInfo srcSwap;
        DataTypes.SwapInfo dstSwap;
        address payable recipient;
        address partner;
        uint256 partnerFeeRate;
        uint256 srcPoolId;
        uint256 dstPoolId;
        uint256 amount;
        uint256 minSrcReturn; // min return from swap on src chain
        uint256 minDstAmount;
        uint256 bridgeDstAmount;
        uint256 dstGasForCall;
        uint256 dstNativeAmount;
        uint256 estimatedCallAmount;
        uint256[] srcDistribution;
        uint256[] dstDistribution;
        uint16  dstChainId;
        bytes32 id;
        bytes32 bridge;
        bytes callTo;
        bytes srcParaswapData;
        bytes dstParaswapData;
        DataTypes.ParaswapUsageStatus paraswapUsageStatus;
        DataTypes.ContractCallInfo callInfo;
    }

    event StargateRouterSet(address stargateRouter);
    event StargateEthRouterSet(address stargateEthRouter);

    constructor(
        address _weth,
        address _otherToken,
        uint256[] memory _pathCountAndSplit,
        address[] memory _factories,
        address _switchViewAddress,
        address _switchEventAddress,
        address _stargateRouter,
        address _paraswapProxy,
        address _augustusSwapper,
        address _feeCollector
    ) Switch(
        _weth,
        _otherToken,
        _pathCountAndSplit[0],
        _pathCountAndSplit[1],
        _factories,
        _switchViewAddress,
        _switchEventAddress,
        _paraswapProxy,
        _augustusSwapper,
        _feeCollector
    )
        public
    {
        stargateRouter = _stargateRouter;
    }

    function setStargateRouter(address _newStargateRouter) external onlyOwner {
        stargateRouter = _newStargateRouter;
        emit StargateRouterSet(_newStargateRouter);
    }

    function getLayerZeroFee(
        DataTypes.ContractCallRequest calldata request,
        uint16 dstChainId,
        uint256 dstGasForCall,
        uint256 dstNativeAmount,
        address receiver
    )
        external
        view
        returns (uint256, uint256)
    {
        bytes memory message = abi.encode(
            DataTypes.ContractCallRequest({
                id: request.id,
                bridge: request.bridge,
                srcToken: request.srcToken,
                bridgeToken: request.bridgeToken,
                callToken: request.callToken,
                recipient: request.recipient,
                srcAmount: request.srcAmount,
                dstDistribution: request.dstDistribution,
                bridgeDstAmount: request.bridgeDstAmount,
                estimatedCallAmount: request.estimatedCallAmount,
                paraswapUsageStatus: request.paraswapUsageStatus,
                dstParaswapData: request.dstParaswapData,
                callInfo: request.callInfo
            })
        );

        return IStargateRouter(stargateRouter).quoteLayerZeroFee(
            dstChainId,
            1,                  // TYPE_SWAP_REMOTE on Bridge
            abi.encodePacked(receiver),
            message,
            IStargateRouter.lzTxObj(
                dstGasForCall,
                dstNativeAmount,
                abi.encodePacked(receiver)
            )
        );
    }

    function contractCallByStargate(
        ContractCallArgsStargate calldata callArgs
    )
        external
        payable
        nonReentrant
    {
        IERC20(callArgs.srcSwap.srcToken).universalTransferFrom(msg.sender, address(this), callArgs.amount);

        uint256 returnAmount = 0;
        uint256 amountAfterFee = _getAmountAfterFee(IERC20(callArgs.srcSwap.srcToken), callArgs.amount, callArgs.partner, callArgs.partnerFeeRate);

        if (callArgs.srcSwap.srcToken == callArgs.srcSwap.dstToken) {
            returnAmount = amountAfterFee;
        } else {
            if ((callArgs.paraswapUsageStatus == DataTypes.ParaswapUsageStatus.OnSrcChain) ||
                (callArgs.paraswapUsageStatus == DataTypes.ParaswapUsageStatus.Both))
            {
                returnAmount = _swapFromParaswap(callArgs, amountAfterFee);
            } else {
                (returnAmount, ) = _swapBeforeStargate(callArgs, amountAfterFee);
            }
        }
        require(returnAmount >= callArgs.minSrcReturn, 'The return amount is too small');

        bytes memory message = abi.encode(
            DataTypes.ContractCallRequest({
                id: callArgs.id,
                bridge: callArgs.bridge,
                srcToken: callArgs.srcSwap.srcToken,
                bridgeToken: callArgs.dstSwap.srcToken,
                callToken: callArgs.dstSwap.dstToken,
                recipient: callArgs.recipient,
                srcAmount: amountAfterFee,
                dstParaswapData: callArgs.dstParaswapData,
                paraswapUsageStatus: callArgs.paraswapUsageStatus,
                bridgeDstAmount: callArgs.bridgeDstAmount,
                estimatedCallAmount: callArgs.estimatedCallAmount,
                dstDistribution: callArgs.dstDistribution,
                callInfo: callArgs.callInfo
            })
        );

        (uint256 nativeFee, ) = _getLayerZeroFee(
            message,
            callArgs.dstChainId,
            callArgs.dstGasForCall,
            callArgs.dstNativeAmount,
            callArgs.callTo
        );

        if (IERC20(callArgs.srcSwap.srcToken).isETH()) {
            require(msg.value >= callArgs.amount + nativeFee, 'native token is not enough');
        } else {
            require(msg.value >= nativeFee, 'native token is not enough');
        }

        if (!IERC20(callArgs.srcSwap.dstToken).isETH()) {
            IERC20(callArgs.srcSwap.dstToken).universalApprove(stargateRouter, returnAmount);
        }

        IStargateRouter(stargateRouter).swap{ value: nativeFee }(
            callArgs.dstChainId,
            callArgs.srcPoolId,                         // source pool id
            callArgs.dstPoolId,                         // dest pool id
            callArgs.recipient,                         // refund adddress. extra gas (if any) is returned to this address
            returnAmount,                               // quantity to swap
            callArgs.minDstAmount,                      // the min qty you would accept on the destination
            IStargateRouter.lzTxObj(
                callArgs.dstGasForCall,
                callArgs.dstNativeAmount,
                callArgs.callTo
            ),
            callArgs.callTo,                            // the address to send the tokens to on the destination
            message                                     // bytes param, if you wish to send additional payload you can abi.encode() them here
        );

        _emitCrossChainContractCallRequest(
            callArgs,
            bytes32(0),
            returnAmount,
            msg.sender,
            DataTypes.ContractCallStatus.Succeeded
        );
    }

    function _swapFromParaswap(
        ContractCallArgsStargate calldata callArgs,
        uint256 amount
    )
        private
        returns (uint256 returnAmount)
    {
        // break function to avoid stack too deep error
        returnAmount = _swapInternalWithParaSwap(
            IERC20(callArgs.srcSwap.srcToken),
            IERC20(callArgs.srcSwap.dstToken),
            amount,
            callArgs.srcParaswapData
        );
    }

    function _swapBeforeStargate(
        ContractCallArgsStargate calldata callArgs,
        uint256 amount
    )
        private
        returns (
            uint256 returnAmount,
            uint256 parts
        )
    {
        parts = 0;
        uint256 lastNonZeroIndex = 0;
        for (uint i = 0; i < callArgs.srcDistribution.length; i++) {
            if (callArgs.srcDistribution[i] > 0) {
                parts += callArgs.srcDistribution[i];
                lastNonZeroIndex = i;
            }
        }

        require(parts > 0, "invalid distribution param");
        // break function to avoid stack too deep error
        returnAmount = _swapInternalForSingleSwap(
            callArgs.srcDistribution,
            amount,
            parts,
            lastNonZeroIndex,
            IERC20(callArgs.srcSwap.srcToken),
            IERC20(callArgs.srcSwap.dstToken)
        );
        require(returnAmount > 0, "Swap failed from dex");

        switchEvent.emitSwapped(
            msg.sender,
            address(this),
            IERC20(callArgs.srcSwap.srcToken),
            IERC20(callArgs.srcSwap.dstToken),
            amount,
            returnAmount,
            0
        );
    }

    function _getLayerZeroFee(
        bytes memory message,
        uint16 dstChainId,
        uint256 dstGasForCall,
        uint256 dstNativeAmount,
        bytes memory receiver
    )
        internal
        view
        returns(uint256, uint256)
    {

        return IStargateRouter(stargateRouter).quoteLayerZeroFee(
            dstChainId,
            1,                  // TYPE_SWAP_REMOTE on Bridge
            receiver,
            message,
            IStargateRouter.lzTxObj(
                dstGasForCall,
                dstNativeAmount,
                receiver
            )
        );
    }

    function _emitCrossChainContractCallRequest(
        ContractCallArgsStargate calldata callArgs,
        bytes32 transferId,
        uint256 returnAmount,
        address sender,
        DataTypes.ContractCallStatus status
    )
        internal
    {
        switchEvent.emitCrosschainContractCallRequest(
            callArgs.id,
            transferId,
            callArgs.bridge,
            sender,
            callArgs.callInfo.toContractAddress,
            callArgs.callInfo.toApprovalAddress,
            callArgs.srcSwap.srcToken,
            callArgs.dstSwap.dstToken,
            returnAmount,
            callArgs.estimatedCallAmount,
            status
        );
    }
}

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

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

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

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

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

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

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

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

File 3 of 23 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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;
    }
}

File 4 of 23 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 8 of 23 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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;
    }
}

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

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

abstract contract ISwitchView {

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

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

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

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

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

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

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

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

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

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

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

    address[] public factories;

    int256 internal constant VERY_NEGATIVE_VALUE = -1e72;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    address public feeCollector;
    uint256 public maxPartnerFeeRate = 1000; // max partner fee rate is 10%
    uint256 public swingCut = 1500; // swing takes a cut of 15% from partner fee

    uint256 public constant FEE_BASE = 10000;

    event RewardSet(address reward);
    event FeeCollectorSet(address feeCollector);
    event MaxPartnerFeeRateSet(uint256 maxPartnerFeeRate);
    event SwingCutSet(uint256 swingCut);
    event SwitchEventSet(ISwitchEvent switchEvent);
    event ParaswapProxySet(address paraswapProxy);
    event AugustusSwapperSet(address augustusSwapper);

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

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

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

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

    function setMaxPartnerFeeRate(uint256 _maxPartnerFeeRate) external onlyOwner {
        require(_maxPartnerFeeRate <= 5000, "too large");
        maxPartnerFeeRate = _maxPartnerFeeRate;
        emit MaxPartnerFeeRateSet(_maxPartnerFeeRate);
    }

    function setSwingCut(uint256 _swingCut) external onlyOwner {
        swingCut = _swingCut;
        emit SwingCutSet(_swingCut);
    }

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

    function setParaswapProxy(address _paraswapProxy) external onlyOwner {
        paraswapProxy = _paraswapProxy;
        emit ParaswapProxySet(_paraswapProxy);
    }

    function setAugustusSwapper(address _augustusSwapper) external onlyOwner {
        augustusSwapper = _augustusSwapper;
        emit AugustusSwapperSet(_augustusSwapper);
    }

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

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

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

    function swap(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        uint256 expectedReturn,
        uint256 minReturn,
        address recipient,
        uint256[] memory distribution
    )
        public
        payable
        nonReentrant
        returns (uint256 returnAmount)
    {
        require(expectedReturn >= minReturn, "expectedReturn must be equal or larger than minReturn");
        if (fromToken == destToken) {
            revert("it's not allowed to swap with same token");
        }

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

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

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

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

    function swapWithParaswap(
        IERC20 fromToken,
        IERC20 destToken,
        uint256 amount,
        uint256 destAmount,
        address recipient,
        bytes memory callData
    )
        public
        payable
        nonReentrant
    {
        if (fromToken == destToken) {
            revert("it's not allowed to swap with same token");
        }
        fromToken.universalTransferFrom(msg.sender, address(this), amount);
        _callParaswap(fromToken, amount, callData);
        switchEvent.emitSwapped(msg.sender, recipient, fromToken, destToken, amount, destAmount, 0);
    }


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

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

        _callParaswap(fromToken, amount, callData);
        totalAmount = destToken.universalBalanceOf(address(this));
        switchEvent.emitSwapped(msg.sender, address(this), fromToken, destToken, amount, totalAmount, 0);
    }

    function _callParaswap(
        IERC20 token,
        uint256 amount,
        bytes memory callData
    )
        internal
    {
        uint256 ethAmountToTransfert = 0;
        if (token.isETH()) {
            require(address(this).balance >= amount, "ETH balance is insufficient");
            ethAmountToTransfert = amount;
        } else {
            token.universalApprove(paraswapProxy, amount);
        }

        (bool success,) = augustusSwapper.call{ value: ethAmountToTransfert }(callData);
        require(success, "Paraswap execution failed");
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

interface IStargateEthRouter {
    function swapETH(
        uint16 _dstChainId,                         // destination Stargate chainId
        address payable _refundAddress,             // refund additional messageFee to this address
        bytes calldata _toAddress,                  // the receiver of the destination ETH
        uint256 _amountLD,                          // the amount, in Local Decimals, to be swapped
        uint256 _minAmountLD                        // the minimum amount accepted out on destination
    ) external payable;
}

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

interface IStargateRouter {
    struct lzTxObj {
        uint256 _dstGasForCall;
        uint256 _dstNativeAmount;
        bytes _dstNativeAddr;
    }

    function factory() external view returns (address);

    function swap(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLD,
        uint256 _minAmountLD,
        lzTxObj memory _lzTxParams,
        bytes calldata _to,
        bytes calldata _payload
    ) external payable;

    function redeemRemote(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLP,
        uint256 _minAmountLD,
        bytes calldata _to,
        lzTxObj memory _lzTxParams
    ) external payable;

    function redeemLocal(
        uint16 _dstChainId,
        uint256 _srcPoolId,
        uint256 _dstPoolId,
        address payable _refundAddress,
        uint256 _amountLP,
        bytes calldata _to,
        lzTxObj memory _lzTxParams
    ) external payable;

    function quoteLayerZeroFee(
        uint16 _dstChainId,
        uint8 _functionType,
        bytes calldata _toAddress,
        bytes calldata _transferAndCallPayload,
        lzTxObj memory _lzTxParams
    ) external view returns (uint256, uint256);
}

interface IFactory {
    function getPool(uint256) external view returns (address);
}

interface IPool {
    function token() external view returns (address);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    enum ContractCallStatus {
        Null,
        Succeeded,
        Failed,
        Fallback
    }

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

    /// @notice Swap params
    struct SwapInfo {
        address srcToken;
        address dstToken;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

library UniversalERC20 {

    using SafeERC20 for IERC20;

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

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

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

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

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

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

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

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

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

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_otherToken","type":"address"},{"internalType":"uint256[]","name":"_pathCountAndSplit","type":"uint256[]"},{"internalType":"address[]","name":"_factories","type":"address[]"},{"internalType":"address","name":"_switchViewAddress","type":"address"},{"internalType":"address","name":"_switchEventAddress","type":"address"},{"internalType":"address","name":"_stargateRouter","type":"address"},{"internalType":"address","name":"_paraswapProxy","type":"address"},{"internalType":"address","name":"_augustusSwapper","type":"address"},{"internalType":"address","name":"_feeCollector","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"augustusSwapper","type":"address"}],"name":"AugustusSwapperSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"_factories","type":"address[]"}],"name":"FactoriesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"feeCollector","type":"address"}],"name":"FeeCollectorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxPartnerFeeRate","type":"uint256"}],"name":"MaxPartnerFeeRateSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_otherToken","type":"address"}],"name":"OtherTokenSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"paraswapProxy","type":"address"}],"name":"ParaswapProxySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_pathCount","type":"uint256"}],"name":"PathCountSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_pathSplit","type":"uint256"}],"name":"PathSplitSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"reward","type":"address"}],"name":"RewardSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"stargateEthRouter","type":"address"}],"name":"StargateEthRouterSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"stargateRouter","type":"address"}],"name":"StargateRouterSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"swingCut","type":"uint256"}],"name":"SwingCutSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ISwitchEvent","name":"switchEvent","type":"address"}],"name":"SwitchEventSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_weth","type":"address"}],"name":"WETHSet","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"ETH_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEE_BASE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ZERO_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"augustusSwapper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"}],"internalType":"struct DataTypes.SwapInfo","name":"srcSwap","type":"tuple"},{"components":[{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"}],"internalType":"struct DataTypes.SwapInfo","name":"dstSwap","type":"tuple"},{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"address","name":"partner","type":"address"},{"internalType":"uint256","name":"partnerFeeRate","type":"uint256"},{"internalType":"uint256","name":"srcPoolId","type":"uint256"},{"internalType":"uint256","name":"dstPoolId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"minSrcReturn","type":"uint256"},{"internalType":"uint256","name":"minDstAmount","type":"uint256"},{"internalType":"uint256","name":"bridgeDstAmount","type":"uint256"},{"internalType":"uint256","name":"dstGasForCall","type":"uint256"},{"internalType":"uint256","name":"dstNativeAmount","type":"uint256"},{"internalType":"uint256","name":"estimatedCallAmount","type":"uint256"},{"internalType":"uint256[]","name":"srcDistribution","type":"uint256[]"},{"internalType":"uint256[]","name":"dstDistribution","type":"uint256[]"},{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"bytes32","name":"id","type":"bytes32"},{"internalType":"bytes32","name":"bridge","type":"bytes32"},{"internalType":"bytes","name":"callTo","type":"bytes"},{"internalType":"bytes","name":"srcParaswapData","type":"bytes"},{"internalType":"bytes","name":"dstParaswapData","type":"bytes"},{"internalType":"enum DataTypes.ParaswapUsageStatus","name":"paraswapUsageStatus","type":"uint8"},{"components":[{"internalType":"address","name":"toContractAddress","type":"address"},{"internalType":"address","name":"toApprovalAddress","type":"address"},{"internalType":"address","name":"contractOutputsToken","type":"address"},{"internalType":"uint32","name":"toContractGasLimit","type":"uint32"},{"internalType":"bytes","name":"toContractCallData","type":"bytes"}],"internalType":"struct DataTypes.ContractCallInfo","name":"callInfo","type":"tuple"}],"internalType":"struct SwitchContractCallStargateSender.ContractCallArgsStargate","name":"callArgs","type":"tuple"}],"name":"contractCallByStargate","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"dexCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"factories","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"destToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"parts","type":"uint256"}],"name":"getExpectedReturn","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"partner","type":"address"},{"internalType":"uint256","name":"partnerFeeRate","type":"uint256"}],"name":"getFeeInfo","outputs":[{"internalType":"uint256","name":"partnerFee","type":"uint256"},{"internalType":"uint256","name":"remainAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"id","type":"bytes32"},{"internalType":"bytes32","name":"bridge","type":"bytes32"},{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"bridgeToken","type":"address"},{"internalType":"address","name":"callToken","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"bridgeDstAmount","type":"uint256"},{"internalType":"uint256","name":"estimatedCallAmount","type":"uint256"},{"internalType":"uint256[]","name":"dstDistribution","type":"uint256[]"},{"internalType":"bytes","name":"dstParaswapData","type":"bytes"},{"components":[{"internalType":"address","name":"toContractAddress","type":"address"},{"internalType":"address","name":"toApprovalAddress","type":"address"},{"internalType":"address","name":"contractOutputsToken","type":"address"},{"internalType":"uint32","name":"toContractGasLimit","type":"uint32"},{"internalType":"bytes","name":"toContractCallData","type":"bytes"}],"internalType":"struct DataTypes.ContractCallInfo","name":"callInfo","type":"tuple"},{"internalType":"enum DataTypes.ParaswapUsageStatus","name":"paraswapUsageStatus","type":"uint8"}],"internalType":"struct DataTypes.ContractCallRequest","name":"request","type":"tuple"},{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"uint256","name":"dstGasForCall","type":"uint256"},{"internalType":"uint256","name":"dstNativeAmount","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"getLayerZeroFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenBalance","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPartnerFeeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"otherToken","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paraswapProxy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pathCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pathSplit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reward","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_augustusSwapper","type":"address"}],"name":"setAugustusSwapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_factories","type":"address[]"}],"name":"setFactories","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeCollector","type":"address"}],"name":"setFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxPartnerFeeRate","type":"uint256"}],"name":"setMaxPartnerFeeRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_otherToken","type":"address"}],"name":"setOtherToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_paraswapProxy","type":"address"}],"name":"setParaswapProxy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pathCount","type":"uint256"}],"name":"setPathCount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pathSplit","type":"uint256"}],"name":"setPathSplit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_reward","type":"address"}],"name":"setReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newStargateRouter","type":"address"}],"name":"setStargateRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_swingCut","type":"uint256"}],"name":"setSwingCut","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISwitchEvent","name":"_switchEvent","type":"address"}],"name":"setSwitchEvent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_weth","type":"address"}],"name":"setWETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stargateRouter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"destToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expectedReturn","type":"uint256"},{"internalType":"uint256","name":"minReturn","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"}],"name":"swap","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"destToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"destAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"name":"swapWithParaswap","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"swingCut","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"switchEvent","outputs":[{"internalType":"contract ISwitchEvent","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"switchView","outputs":[{"internalType":"contract ISwitchView","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"transferToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

6080604052600180546001600160a01b031990811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee179091556002805490911690556103e86010556105dc6011553480156200004f57600080fd5b5060405162004771380380620047718339810160408190526200007291620003e0565b8989896000815181106200008a576200008a620004e2565b60200260200101518a600181518110620000a857620000a8620004e2565b60200260200101518a8a8a8989898989898989620000d5620000cf6200022260201b60201c565b62000226565b600680546001600160a01b038088166001600160a01b031992831617909255600780549287169290911691909117905560048390556005829055805160035560005b815181101562000188576008828281518110620001385762000138620004e2565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b03909216919091179055806200017f81620004f8565b91505062000117565b505060016009555050600a80546001600160a01b03199081166001600160a01b03998a1617909155600b80548216978916979097179096555050600d8054851693861693909317909255600e80548416918516919091179055600f80548316918416919091179055600c805433908316179055601280549091169a9091169990991790985550620005229c50505050505050505050505050565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146200028e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715620002d457620002d462000293565b604052919050565b60006001600160401b03821115620002f857620002f862000293565b5060051b60200190565b600082601f8301126200031457600080fd5b815160206200032d6200032783620002dc565b620002a9565b82815260059290921b840181019181810190868411156200034d57600080fd5b8286015b848110156200036a578051835291830191830162000351565b509695505050505050565b600082601f8301126200038757600080fd5b815160206200039a6200032783620002dc565b82815260059290921b84018101918181019086841115620003ba57600080fd5b8286015b848110156200036a57620003d28162000276565b8352918301918301620003be565b6000806000806000806000806000806101408b8d0312156200040157600080fd5b6200040c8b62000276565b99506200041c60208c0162000276565b60408c01519099506001600160401b03808211156200043a57600080fd5b620004488e838f0162000302565b995060608d01519150808211156200045f57600080fd5b506200046e8d828e0162000375565b9750506200047f60808c0162000276565b95506200048f60a08c0162000276565b94506200049f60c08c0162000276565b9350620004af60e08c0162000276565b9250620004c06101008c0162000276565b9150620004d16101208c0162000276565b90509295989b9194979a5092959850565b634e487b7160e01b600052603260045260246000fd5b60006000198214156200051b57634e487b7160e01b600052601160045260246000fd5b5060010190565b61423f80620005326000396000f3fe6080604052600436106102515760003560e01c80638da5cb5b11610139578063b9d52d3c116100b6578063e5932c401161007a578063e5932c40146106c8578063e8984c5f146106e8578063ea15afc314610708578063ecefc70514610728578063f2fde38b1461073e578063f640d5081461075e57610251565b8063b9d52d3c1461063f578063bbe8caa21461065f578063c415b95c14610672578063d6821ed814610692578063e37c4250146106b257610251565b8063a9e56f3c116100fd578063a9e56f3c146105a9578063ab304695146105c9578063ae551c66146105df578063b4c76fe0146105ff578063b58468cf1461061f57610251565b80638da5cb5b1461051557806390f3f20814610533578063a42dce8014610549578063a734f06e14610569578063a85f32981461058957610251565b806348c4d781116101d25780635b18075e116101965780635b18075e1461045c5780635b769f3c1461047c5780636076a0b41461049c578063672383c4146104ca578063715018a6146104ea5780638c821e90146104ff57610251565b806348c4d781146103c957806351b78b47146103e9578063538ba4f91461040957806353fd7bf114610429578063578c71bd1461044957610251565b80633aecd0e3116102195780633aecd0e3146103335780633fc8cef314610353578063433b3c05146103735780634399fa5614610393578063458f9723146103b357610251565b80630416a4d51461026057806312e4a6d91461029a578063228cb733146102bb57806323a9495e146102f357806331428a8714610313575b3332141561025e57600080fd5b005b34801561026c57600080fd5b5061028061027b36600461346b565b61077e565b604080519283526020830191909152015b60405180910390f35b6102ad6102a8366004613552565b610a1c565b604051908152602001610291565b3480156102c757600080fd5b50600c546102db906001600160a01b031681565b6040516001600160a01b039091168152602001610291565b3480156102ff57600080fd5b5061025e61030e36600461363f565b610da9565b34801561031f57600080fd5b50600a546102db906001600160a01b031681565b34801561033f57600080fd5b506102ad61034e366004613658565b610ded565b34801561035f57600080fd5b506006546102db906001600160a01b031681565b34801561037f57600080fd5b506007546102db906001600160a01b031681565b34801561039f57600080fd5b50600b546102db906001600160a01b031681565b3480156103bf57600080fd5b506102ad60115481565b3480156103d557600080fd5b5061025e6103e436600461363f565b610e10565b3480156103f557600080fd5b5061025e610404366004613658565b610e8b565b34801561041557600080fd5b506002546102db906001600160a01b031681565b34801561043557600080fd5b5061025e610444366004613658565b610ee1565b61025e610457366004613675565b610f37565b34801561046857600080fd5b50600d546102db906001600160a01b031681565b34801561048857600080fd5b5061025e610497366004613658565b611525565b3480156104a857600080fd5b506104bc6104b73660046136b1565b61157b565b6040516102919291906136f7565b3480156104d657600080fd5b506102db6104e536600461363f565b611624565b3480156104f657600080fd5b5061025e61164e565b34801561050b57600080fd5b506102ad60045481565b34801561052157600080fd5b506000546001600160a01b03166102db565b34801561053f57600080fd5b506102ad60055481565b34801561055557600080fd5b5061025e610564366004613658565b611662565b34801561057557600080fd5b506001546102db906001600160a01b031681565b34801561059557600080fd5b5061025e6105a436600461363f565b6116b8565b3480156105b557600080fd5b506012546102db906001600160a01b031681565b3480156105d557600080fd5b506102ad60035481565b3480156105eb57600080fd5b50600e546102db906001600160a01b031681565b34801561060b57600080fd5b5061025e61061a366004613658565b6116f5565b34801561062b57600080fd5b5061025e61063a36600461363f565b61174b565b34801561064b57600080fd5b5061025e61065a366004613658565b611788565b61025e61066d3660046137b5565b6117de565b34801561067e57600080fd5b50600f546102db906001600160a01b031681565b34801561069e57600080fd5b506102806106ad36600461383c565b6118b9565b3480156106be57600080fd5b506102ad60105481565b3480156106d457600080fd5b5061025e6106e3366004613658565b6118e9565b3480156106f457600080fd5b5061025e610703366004613658565b61193f565b34801561071457600080fd5b5061025e610723366004613874565b611995565b34801561073457600080fd5b506102ad61271081565b34801561074a57600080fd5b5061025e610759366004613658565b611a3f565b34801561076a57600080fd5b5061025e610779366004613903565b611ab5565b6000806000604051806101a0016040528089600001358152602001896020013581526020018960400160208101906107b69190613658565b6001600160a01b031681526020016107d460808b0160608c01613658565b6001600160a01b031681526020016107f260a08b0160808c01613658565b6001600160a01b0316815260200161081060c08b0160a08c01613658565b6001600160a01b0316815260c08a0135602082015260e08a013560408201526101008a0135606082015260800161084b6101208b018b613945565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020016108906101408b018b613996565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506020016108d86101608b018b6139dd565b6108e190613a0f565b81526020016108f86101a08b016101808c01613ac7565b600381111561090957610909613ae8565b905260405161091b9190602001613c0d565b60408051601f19818403018152828252601254606088901b6bffffffffffffffffffffffff19166020808601829052845160148188038101825260948801875260348089018f815260548a018f9052885194850195909552875180850390920182529290920186526074909601529251630a51236960e01b81529194506001600160a01b031692630a512369926109be928c926001929091889190600401613d4d565b604080518083038186803b1580156109d557600080fd5b505afa1580156109e9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0d9190613da5565b92509250509550959350505050565b6000610a26611ad7565b83851015610a995760405162461bcd60e51b815260206004820152603560248201527f657870656374656452657475726e206d75737420626520657175616c206f72206044820152743630b933b2b9103a3430b71036b4b72932ba3ab93760591b60648201526084015b60405180910390fd5b866001600160a01b0316886001600160a01b03161415610acb5760405162461bcd60e51b8152600401610a9090613dc9565b60008060005b8451811015610b39576000858281518110610aee57610aee613e11565b60200260200101511115610b2757848181518110610b0e57610b0e613e11565b602002602001015183610b219190613e3d565b92508091505b80610b3181613e55565b915050610ad1565b5081610b9757610b518a6001600160a01b0316611b31565b15610b8d5760405133903480156108fc02916000818181858888f19350505050158015610b82573d6000803e3d6000fd5b503492505050610d94565b8792505050610d94565b610bac6001600160a01b038b1633308b611b6a565b610bba848984848e8e611c5c565b92508215610d335785831015610c1e5760405162461bcd60e51b8152602060048201526024808201527f5377697463683a2052657475726e20616d6f756e7420776173206e6f7420656e6044820152630deeaced60e31b6064820152608401610a90565b86831115610ce157610c3a6001600160a01b038a168689611e8c565b50600c54610c66906001600160a01b0316610c558986613e70565b6001600160a01b038c169190611e8c565b50600b546001600160a01b031663391fdc2433878d8d8d8d610c88818c613e70565b6040518863ffffffff1660e01b8152600401610caa9796959493929190613e87565b600060405180830381600087803b158015610cc457600080fd5b505af1158015610cd8573d6000803e3d6000fd5b50505050610d91565b610cf56001600160a01b038a168685611e8c565b50600b54604051630e47f70960e21b81526001600160a01b039091169063391fdc2490610caa90339089908f908f908f908b90600090600401613e87565b87610d476001600160a01b038c1630611f08565b1115610d6757610d616001600160a01b038b16338a611e8c565b50610d91565b610d8f33610d7e6001600160a01b038d1630611f08565b6001600160a01b038d169190611e8c565b505b50505b610d9e6001600955565b979650505050505050565b610db1611fa2565b60058190556040518181527f11e8ee12d79dc7314b845f4e82465af5bd3d2214081526061af36de8364eaa2e906020015b60405180910390a150565b6000610df7611fa2565b610e0a6001600160a01b03831630611f08565b92915050565b610e18611fa2565b611388811115610e565760405162461bcd60e51b8152602060048201526009602482015268746f6f206c6172676560b81b6044820152606401610a90565b60108190556040518181527fa28aac6f4ba79029a647ee085b0ae88419c6aa87bae5dcf77d303dba45b3681b90602001610de2565b610e93611fa2565b601280546001600160a01b0319166001600160a01b0383169081179091556040519081527f806d08432293677cc7e3e0f9443dcf0459f82567573d5094da6e9e6129dea4ab90602001610de2565b610ee9611fa2565b600b80546001600160a01b0319166001600160a01b0383169081179091556040519081527f35e63b7fefc2b1fb2ed78adeed6688b187514d96c2d7d56222e52f3e41c2fb2f90602001610de2565b610f3f611ad7565b610f683330610120840135610f576020860186613658565b6001600160a01b0316929190611b6a565b600080610f9b610f7b6020850185613658565b610120850135610f9160c0870160a08801613658565b8660c00135611ffc565b9050610fad6040840160208501613658565b6001600160a01b0316610fc36020850185613658565b6001600160a01b03161415610fda57809150611051565b6001610fee61032085016103008601613ac7565b6003811115610fff57610fff613ae8565b148061102d5750600361101a61032085016103008601613ac7565b600381111561102b5761102b613ae8565b145b156110435761103c838261223e565b9150611051565b61104d83826122a9565b5091505b8261014001358210156110a65760405162461bcd60e51b815260206004820152601e60248201527f5468652072657475726e20616d6f756e7420697320746f6f20736d616c6c00006044820152606401610a90565b604080516101a08101825261026085013581526102808501356020808301919091526000928201906110da90870187613658565b6001600160a01b031681526020016110f86060870160408801613658565b6001600160a01b031681526020016111166080870160608801613658565b6001600160a01b0316815260200161113460a0870160808801613658565b6001600160a01b031681526020810184905261018086013560408201526101e0860135606082015260800161116d610220870187613945565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020016111b26102e0870187613996565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506020016111fa6103208701876139dd565b61120390613a0f565b815260200161121a61032087016103008801613ac7565b600381111561122b5761122b613ae8565b905260405161123d9190602001613c0d565b60408051601f19818403018152919052905060006112bb8261126761026088016102408901613ecb565b6101a08801356101c08901356112816102a08b018b613996565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506124cf92505050565b5090506112dc6112ce6020870187613658565b6001600160a01b0316611b31565b15611344576112f081610120870135613e3d565b34101561133f5760405162461bcd60e51b815260206004820152601a60248201527f6e617469766520746f6b656e206973206e6f7420656e6f7567680000000000006044820152606401610a90565b611394565b803410156113945760405162461bcd60e51b815260206004820152601a60248201527f6e617469766520746f6b656e206973206e6f7420656e6f7567680000000000006044820152606401610a90565b6113a76112ce6040870160208801613658565b6113dc576012546113dc906001600160a01b0316856113cc6040890160208a01613658565b6001600160a01b03169190612581565b6012546001600160a01b0316639fbf10fc8261140061026089016102408a01613ecb565b60e08901356101008a013561141b60a08c0160808d01613658565b8a8c610160013560405180606001604052808f6101a0013581526020018f6101c0013581526020018f806102a001906114549190613996565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508152508e806102a001906114ab9190613996565b8d6040518c63ffffffff1660e01b81526004016114d19a99989796959493929190613ee6565b6000604051808303818588803b1580156114ea57600080fd5b505af11580156114fe573d6000803e3d6000fd5b5050505050611514856000801b86336001612661565b505050506115226001600955565b50565b61152d611fa2565b600680546001600160a01b0319166001600160a01b0383169081179091556040519081527f41408be49f75701fe4bb8484ce88d68f1d82e03cb4eb44263b6682ce2dbd32f090602001610de2565b600a5460405163181da82d60e21b81526001600160a01b03868116600483015285811660248301526044820185905260648201849052600092606092911690636076a0b49060840160006040518083038186803b1580156115db57600080fd5b505afa1580156115ef573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116179190810190613f7d565b9097909650945050505050565b6008818154811061163457600080fd5b6000918252602090912001546001600160a01b0316905081565b611656611fa2565b6116606000612745565b565b61166a611fa2565b600f80546001600160a01b0319166001600160a01b0383169081179091556040519081527f12e1d17016b94668449f97876f4a8d5cc2c19f314db337418894734037cc19d490602001610de2565b6116c0611fa2565b60048190556040518181527f70f24e12a9db25e0d80cbcde19ffef47d6a7c52c1089db4c71e53ce1856577fc90602001610de2565b6116fd611fa2565b600780546001600160a01b0319166001600160a01b0383169081179091556040519081527f17780f3919f73af11f29e4157534858a06c91294d64b679fe4e49340122cd32290602001610de2565b611753611fa2565b60118190556040518181527f25677c92398d23f2071292abdbfc08a652d124b76716d2cee83f7f2fe2fbe1e290602001610de2565b611790611fa2565b600e80546001600160a01b0319166001600160a01b0383169081179091556040519081527fe0209b1ff5892dc27d9ffb30000e308317645f928d78a0a018dd2e9289ecc29290602001610de2565b6117e6611ad7565b846001600160a01b0316866001600160a01b031614156118185760405162461bcd60e51b8152600401610a9090613dc9565b61182d6001600160a01b038716333087611b6a565b611838868583612795565b600b54604051630e47f70960e21b81526001600160a01b039091169063391fdc249061187590339086908b908b908b908b90600090600401613e87565b600060405180830381600087803b15801561188f57600080fd5b505af11580156118a3573d6000803e3d6000fd5b505050506118b16001600955565b505050505050565b6000806127106118c9868561401a565b6118d3919061404f565b91506118df8286613e70565b9050935093915050565b6118f1611fa2565b600c80546001600160a01b0319166001600160a01b0383169081179091556040519081527f53a596d7be747a5a4f4d39a6a36476d2eed407c93f6f2ba8a96c8b971240d5cd90602001610de2565b611947611fa2565b600d80546001600160a01b0319166001600160a01b0383169081179091556040519081527f4528d04696417deba6006cd6c7e5bbb56b9874ac9d954a956e14b8d74f08d72b90602001610de2565b61199d611fa2565b805160035560005b8151811015611a0f5760088282815181106119c2576119c2613e11565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b0390921691909117905580611a0781613e55565b9150506119a5565b507fbbc63a7f378af7e269ef19f3fe0d08f044c91ee72930c0d045a58be58580f3d381604051610de29190614063565b611a47611fa2565b6001600160a01b038116611aac5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a90565b61152281612745565b611abd611fa2565b611ad16001600160a01b0384168284611e8c565b50505050565b60026009541415611b2a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a90565b6002600955565b60006001600160a01b0382161580610e0a57506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1492915050565b80611b7457611ad1565b611b7d84611b31565b15611c47576001600160a01b03831633148015611b9a5750803410155b611bfa5760405162461bcd60e51b815260206004820152602b60248201527f57726f6e6720757365616765206f66204554482e756e6976657273616c54726160448201526a6e7366657246726f6d282960a81b6064820152608401610a90565b6001600160a01b0382163014611c42576040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015611c40573d6000803e3d6000fd5b505b611ad1565b611ad16001600160a01b0385168484846128d9565b6000600454600354611c6e919061401a565b87511115611cee5760405162461bcd60e51b815260206004820152604160248201527f5377697463683a20446973747269627574696f6e2061727261792073686f756c60448201527f64206e6f742065786365656420666163746f726965732061727261792073697a6064820152606560f81b608482015260a401610a90565b856000805b8951811015611e7f57898181518110611d0e57611d0e613e11565b602002602001015160001415611d2357611e6d565b6000888b8381518110611d3857611d38613e11565b60200260200101518b611d4b919061401a565b611d55919061404f565b905087821415611d625750825b611d6c8185613e70565b935060045482611d7c91906140b0565b611dc757611dc0878783600860045487611d96919061404f565b81548110611da657611da6613e11565b6000918252602090912001546001600160a01b0316612944565b9250611e5f565b600454611dd490836140b0565b60011415611e1c57611dc0878783600860045487611df2919061404f565b81548110611e0257611e02613e11565b6000918252602090912001546001600160a01b031661295b565b611e5c878783600860045487611e32919061404f565b81548110611e4257611e42613e11565b6000918252602090912001546001600160a01b0316612978565b92505b611e698386613e3d565b9450505b80611e7781613e55565b915050611cf3565b5050509695505050505050565b600081611e9b57506001611f01565b611ea484611b31565b15611ee9576040516001600160a01b0384169083156108fc029084906000818181858888f19350505050158015611edf573d6000803e3d6000fd5b5060019050611f01565b611efd6001600160a01b0385168484612995565b5060015b9392505050565b6000611f1383611b31565b15611f2957506001600160a01b03811631610e0a565b6040516370a0823160e01b81526001600160a01b0383811660048301528416906370a082319060240160206040518083038186803b158015611f6a57600080fd5b505afa158015611f7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0191906140c4565b6000546001600160a01b031633146116605760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a90565b60006010548211156120505760405162461bcd60e51b815260206004820152601860248201527f706172746e65724665655261746520746f6f206c6172676500000000000000006044820152606401610a90565b508281156122365760006120666127108061401a565b601154612073878661401a565b61207d919061401a565b612087919061404f565b9050600081612710612099888761401a565b6120a3919061404f565b6120ad9190613e70565b90506120c1876001600160a01b0316611b31565b1561215457600f546001600160a01b031663eedd56e16120e18484613e3d565b6040516001600160e01b031960e084901b1681526001600160a01b03808c1660048301526024820186905260448201879052891660648201526084016000604051808303818588803b15801561213657600080fd5b505af115801561214a573d6000803e3d6000fd5b5050505050612210565b600f5461216f906001600160a01b03898116911660006129c5565b600f5461219a906001600160a01b03166121898484613e3d565b6001600160a01b038a1691906129c5565b600f5460405163eedd56e160e01b81526001600160a01b038981166004830152602482018490526044820185905287811660648301529091169063eedd56e190608401600060405180830381600087803b1580156121f757600080fd5b505af115801561220b573d6000803e3d6000fd5b505050505b61271061221d878661401a565b612227919061404f565b6122319087613e70565b925050505b949350505050565b6000611f016122506020850185613658565b6122606040860160208701613658565b8461226f6102c0880188613996565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612ae992505050565b60008080805b6122bd610200870187613945565b905081101561233b5760006122d6610200880188613945565b838181106122e6576122e6613e11565b90506020020135111561232957612301610200870187613945565b8281811061231157612311613e11565b90506020020135836123239190613e3d565b92508091505b8061233381613e55565b9150506122af565b506000821161238c5760405162461bcd60e51b815260206004820152601a60248201527f696e76616c696420646973747269627574696f6e20706172616d0000000000006044820152606401610a90565b6123f661239d610200870187613945565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508892508691508590506123e160208b018b613658565b6123f160408c0160208d01613658565b611c5c565b92506000831161243f5760405162461bcd60e51b81526020600482015260146024820152730a6eec2e040ccc2d2d8cac840cce4deda40c8caf60631b6044820152606401610a90565b600b546001600160a01b031663391fdc24333061245f60208a018a613658565b61246f60408b0160208c01613658565b898960006040518863ffffffff1660e01b81526004016124959796959493929190613e87565b600060405180830381600087803b1580156124af57600080fd5b505af11580156124c3573d6000803e3d6000fd5b50505050509250929050565b60125460408051606081018252858152602081018590528082018490529051630a51236960e01b815260009283926001600160a01b0390911691630a51236991612524918a9160019189918e91600401613d4d565b604080518083038186803b15801561253b57600080fd5b505afa15801561254f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125739190613da5565b915091509550959350505050565b61258a83611b31565b6125a857806125ad576125a86001600160a01b0384168360006129c5565b505050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e9060440160206040518083038186803b1580156125f857600080fd5b505afa15801561260c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263091906140c4565b9050801561264d5761264d6001600160a01b0385168460006129c5565b611ad16001600160a01b03851684846129c5565b600b546001600160a01b0316636fde7601610260870135866102808901358661268e6103208c018c6139dd565b61269c906020810190613658565b6126aa6103208d018d6139dd565b6126bb906040810190602001613658565b6126c860208e018e613658565b8d60400160200160208101906126de9190613658565b8c8f6101e001358c6040518c63ffffffff1660e01b815260040161270c9b9a999897969594939291906140dd565b600060405180830381600087803b15801561272657600080fd5b505af115801561273a573d6000803e3d6000fd5b505050505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006127a9846001600160a01b0316611b31565b1561280557824710156127fe5760405162461bcd60e51b815260206004820152601b60248201527f4554482062616c616e636520697320696e73756666696369656e7400000000006044820152606401610a90565b508161281f565b600d5461281f906001600160a01b03868116911685612581565b600e546040516000916001600160a01b031690839061283f908690614152565b60006040518083038185875af1925050503d806000811461287c576040519150601f19603f3d011682016040523d82523d6000602084013e612881565b606091505b50509050806128d25760405162461bcd60e51b815260206004820152601960248201527f506172617377617020657865637574696f6e206661696c6564000000000000006044820152606401610a90565b5050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611ad19085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612bb3565b600061295285858585612c85565b95945050505050565b6006546000906129529086906001600160a01b03168686866130f1565b6007546000906129529086906001600160a01b03168686866130f1565b6040516001600160a01b0383166024820152604481018290526125a890849063a9059cbb60e01b9060640161290d565b801580612a4e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015612a1457600080fd5b505afa158015612a28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a4c91906140c4565b155b612ab95760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610a90565b6040516001600160a01b0383166024820152604481018290526125a890849063095ea7b360e01b9060640161290d565b6000836001600160a01b0316856001600160a01b03161415612b1d5760405162461bcd60e51b8152600401610a9090613dc9565b612b28858484612795565b612b3b6001600160a01b03851630611f08565b600b54604051630e47f70960e21b81529192506001600160a01b03169063391fdc2490612b7990339030908a908a908a908990600090600401613e87565b600060405180830381600087803b158015612b9357600080fd5b505af1158015612ba7573d6000803e3d6000fd5b50505050949350505050565b6000612c08826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166131149092919063ffffffff16565b8051909150156125a85780806020019051810190612c269190614164565b6125a85760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a90565b6000612c99856001600160a01b0316611b31565b15612d0857600660009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b158015612cee57600080fd5b505af1158015612d02573d6000803e3d6000fd5b50505050505b6000612d1c866001600160a01b0316611b31565b612d265785612d33565b6006546001600160a01b03165b90506000612d49866001600160a01b0316611b31565b612d535785612d60565b6006546001600160a01b03165b60405163e6a4390560e01b81526001600160a01b038481166004830152808316602483015291925060009186169063e6a439059060440160206040518083038186803b158015612daf57600080fd5b505afa158015612dc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612de79190614186565b9050600080612e016001600160a01b03841686868b613123565b919750925090508115612e6657826001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612e4957600080fd5b505af1158015612e5d573d6000803e3d6000fd5b50505050612eda565b8015612eda5760405163bc25cf7760e01b81527346fd07da395799f113a7584563b8cb886f33c2bc60048201526001600160a01b0384169063bc25cf7790602401600060405180830381600087803b158015612ec157600080fd5b505af1158015612ed5573d6000803e3d6000fd5b505050505b612eee6001600160a01b038616848a611e8c565b50836001600160a01b0316856001600160a01b03161015612f835760405163022c0d9f60e01b8152600060048201819052602482018890523060448301526080606483015260848201526001600160a01b0384169063022c0d9f9060a401600060405180830381600087803b158015612f6657600080fd5b505af1158015612f7a573d6000803e3d6000fd5b50505050612ff9565b60405163022c0d9f60e01b8152600481018790526000602482018190523060448301526080606483015260848201526001600160a01b0384169063022c0d9f9060a401600060405180830381600087803b158015612fe057600080fd5b505af1158015612ff4573d6000803e3d6000fd5b505050505b61300b896001600160a01b0316611b31565b156130e4576006546040516370a0823160e01b81523060048201526001600160a01b0390911690632e1a7d4d9082906370a082319060240160206040518083038186803b15801561305b57600080fd5b505afa15801561306f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061309391906140c4565b6040518263ffffffff1660e01b81526004016130b191815260200190565b600060405180830381600087803b1580156130cb57600080fd5b505af11580156130df573d6000803e3d6000fd5b505050505b5050505050949350505050565b600061310a858561310489898888612c85565b85612c85565b9695505050505050565b606061223684846000856132be565b600080808061313b6001600160a01b03881689611f08565b905060006131526001600160a01b0388168a611f08565b90506000808a6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561319057600080fd5b505afa1580156131a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131c891906141ba565b5091509150886001600160a01b03168a6001600160a01b031611156131e957905b816001600160701b03168410806132085750806001600160701b031683105b9550851580156132325750816001600160701b03168411806132325750806001600160701b031683115b94506000613242896103e561401a565b9050600061325985846001600160701b031661338e565b613263908361401a565b905060008261327b88876001600160701b031661338e565b613287906103e861401a565b6132919190613e3d565b905080156132a8576132a3818361404f565b6132ab565b60005b9950505050505050509450945094915050565b60608247101561331f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610a90565b600080866001600160a01b0316858760405161333b9190614152565b60006040518083038185875af1925050503d8060008114613378576040519150601f19603f3d011682016040523d82523d6000602084013e61337d565b606091505b5091509150612231878383876133a4565b600081831061339d5781611f01565b5090919050565b60608315613410578251613409576001600160a01b0385163b6134095760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a90565b5081612236565b61223683838151156134255781518083602001fd5b8060405162461bcd60e51b8152600401610a9091906141f6565b803561ffff8116811461345157600080fd5b919050565b6001600160a01b038116811461152257600080fd5b600080600080600060a0868803121561348357600080fd5b853567ffffffffffffffff81111561349a57600080fd5b86016101a081890312156134ad57600080fd5b94506134bb6020870161343f565b9350604086013592506060860135915060808601356134d981613456565b809150509295509295909350565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715613526576135266134e7565b604052919050565b600067ffffffffffffffff821115613548576135486134e7565b5060051b60200190565b600080600080600080600060e0888a03121561356d57600080fd5b873561357881613456565b965060208881013561358981613456565b965060408901359550606089013594506080890135935060a08901356135ae81613456565b925060c089013567ffffffffffffffff8111156135ca57600080fd5b8901601f81018b136135db57600080fd5b80356135ee6135e98261352e565b6134fd565b81815260059190911b8201830190838101908d83111561360d57600080fd5b928401925b8284101561362b57833582529284019290840190613612565b809550505050505092959891949750929550565b60006020828403121561365157600080fd5b5035919050565b60006020828403121561366a57600080fd5b8135611f0181613456565b60006020828403121561368757600080fd5b813567ffffffffffffffff81111561369e57600080fd5b82016103408185031215611f0157600080fd5b600080600080608085870312156136c757600080fd5b84356136d281613456565b935060208501356136e281613456565b93969395505050506040820135916060013590565b6000604082018483526020604081850152818551808452606086019150828701935060005b818110156137385784518352938301939183019160010161371c565b5090979650505050505050565b600082601f83011261375657600080fd5b813567ffffffffffffffff811115613770576137706134e7565b613783601f8201601f19166020016134fd565b81815284602083860101111561379857600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060c087890312156137ce57600080fd5b86356137d981613456565b955060208701356137e981613456565b94506040870135935060608701359250608087013561380781613456565b915060a087013567ffffffffffffffff81111561382357600080fd5b61382f89828a01613745565b9150509295509295509295565b60008060006060848603121561385157600080fd5b83359250602084013561386381613456565b929592945050506040919091013590565b6000602080838503121561388757600080fd5b823567ffffffffffffffff81111561389e57600080fd5b8301601f810185136138af57600080fd5b80356138bd6135e98261352e565b81815260059190911b820183019083810190878311156138dc57600080fd5b928401925b82841015610d9e5783356138f481613456565b825292840192908401906138e1565b60008060006060848603121561391857600080fd5b833561392381613456565b925060208401359150604084013561393a81613456565b809150509250925092565b6000808335601e1984360301811261395c57600080fd5b83018035915067ffffffffffffffff82111561397757600080fd5b6020019150600581901b360382131561398f57600080fd5b9250929050565b6000808335601e198436030181126139ad57600080fd5b83018035915067ffffffffffffffff8211156139c857600080fd5b60200191503681900382131561398f57600080fd5b60008235609e198336030181126139f357600080fd5b9190910192915050565b63ffffffff8116811461152257600080fd5b600060a08236031215613a2157600080fd5b60405160a0810167ffffffffffffffff8282108183111715613a4557613a456134e7565b8160405284359150613a5682613456565b908252602084013590613a6882613456565b81602084015260408501359150613a7e82613456565b81604084015260608501359150613a94826139fd565b8160608401526080850135915080821115613aae57600080fd5b50613abb36828601613745565b60808301525092915050565b600060208284031215613ad957600080fd5b813560048110611f0157600080fd5b634e487b7160e01b600052602160045260246000fd5b600081518084526020808501945080840160005b83811015613b2e57815187529582019590820190600101613b12565b509495945050505050565b60005b83811015613b54578181015183820152602001613b3c565b83811115611ad15750506000910152565b60008151808452613b7d816020860160208601613b39565b601f01601f19169290920160200192915050565b600060018060a01b038083511684528060208401511660208501528060408401511660408501525063ffffffff6060830151166060840152608082015160a0608085015261223660a0850182613b65565b6004811061152257634e487b7160e01b600052602160045260246000fd5b613c0981613be2565b9052565b60208152815160208201526020820151604082015260006040830151613c3e60608401826001600160a01b03169052565b5060608301516001600160a01b03811660808401525060808301516001600160a01b03811660a08401525060a08301516001600160a01b03811660c08401525060c083015160e083015260e08301516101008181850152808501519150506101208181850152808501519150506101a06101408181860152613cc46101c0860184613afe565b9250808601519050601f19610160818786030181880152613ce58584613b65565b945080880151925050610180818786030181880152613d048584613b91565b94508088015192505050613d1a82860182613c00565b5090949350505050565b805182526020810151602083015260006040820151606060408501526122366060850182613b65565b61ffff8616815260ff8516602082015260a060408201526000613d7360a0830186613b65565b8281036060840152613d858186613b65565b90508281036080840152613d998185613d24565b98975050505050505050565b60008060408385031215613db857600080fd5b505080516020909101519092909150565b60208082526028908201527f69742773206e6f7420616c6c6f77656420746f2073776170207769746820736160408201526736b2903a37b5b2b760c11b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115613e5057613e50613e27565b500190565b6000600019821415613e6957613e69613e27565b5060010190565b600082821015613e8257613e82613e27565b500390565b6001600160a01b03978816815295871660208701529386166040860152919094166060840152608083019390935260a082019290925260c081019190915260e00190565b600060208284031215613edd57600080fd5b611f018261343f565b600061012061ffff8d1683528b60208401528a604084015260018060a01b038a1660608401528860808401528760a08401528060c0840152613f2a81840188613d24565b905082810360e084015284815284866020830137600060208683010152601f19601f86011681019050602083820301610100840152613f6c6020820185613b65565b9d9c50505050505050505050505050565b60008060408385031215613f9057600080fd5b8251915060208084015167ffffffffffffffff811115613faf57600080fd5b8401601f81018613613fc057600080fd5b8051613fce6135e98261352e565b81815260059190911b82018301908381019088831115613fed57600080fd5b928401925b8284101561400b57835182529284019290840190613ff2565b80955050505050509250929050565b600081600019048311821515161561403457614034613e27565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261405e5761405e614039565b500490565b6020808252825182820181905260009190848201906040850190845b818110156140a45783516001600160a01b03168352928401929184019160010161407f565b50909695505050505050565b6000826140bf576140bf614039565b500690565b6000602082840312156140d657600080fd5b5051919050565b8b8152602081018b9052604081018a90526001600160a01b038981166060830152888116608083015287811660a083015286811660c0830152851660e082015261010081018490526101208101839052610160810161413b83613be2565b826101408301529c9b505050505050505050505050565b600082516139f3818460208701613b39565b60006020828403121561417657600080fd5b81518015158114611f0157600080fd5b60006020828403121561419857600080fd5b8151611f0181613456565b80516001600160701b038116811461345157600080fd5b6000806000606084860312156141cf57600080fd5b6141d8846141a3565b92506141e6602085016141a3565b9150604084015161393a816139fd565b602081526000611f016020830184613b6556fea2646970667358221220558cf9c640e8fc2c86a368181c6eea20d6f44f3e219f4b96d1e3d2e05ea2e41964736f6c63430008090033000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000006b4aafe0a2c03b223b73a681b544b1617a976ccb000000000000000000000000410f724847c92bc3cdacbcd4922f1d7833ec280a0000000000000000000000008731d54e9d02c286767d56ac03e8037c07e01e98000000000000000000000000216b4b4ba9f3e719726886d34a177484278bfcae000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee570000000000000000000000007ace1d4bb90d19826a88875ba0f60bd783bef31200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac000000000000000000000000115934131916c8b277dd010ee02de363c09d037c

Deployed Bytecode

0x6080604052600436106102515760003560e01c80638da5cb5b11610139578063b9d52d3c116100b6578063e5932c401161007a578063e5932c40146106c8578063e8984c5f146106e8578063ea15afc314610708578063ecefc70514610728578063f2fde38b1461073e578063f640d5081461075e57610251565b8063b9d52d3c1461063f578063bbe8caa21461065f578063c415b95c14610672578063d6821ed814610692578063e37c4250146106b257610251565b8063a9e56f3c116100fd578063a9e56f3c146105a9578063ab304695146105c9578063ae551c66146105df578063b4c76fe0146105ff578063b58468cf1461061f57610251565b80638da5cb5b1461051557806390f3f20814610533578063a42dce8014610549578063a734f06e14610569578063a85f32981461058957610251565b806348c4d781116101d25780635b18075e116101965780635b18075e1461045c5780635b769f3c1461047c5780636076a0b41461049c578063672383c4146104ca578063715018a6146104ea5780638c821e90146104ff57610251565b806348c4d781146103c957806351b78b47146103e9578063538ba4f91461040957806353fd7bf114610429578063578c71bd1461044957610251565b80633aecd0e3116102195780633aecd0e3146103335780633fc8cef314610353578063433b3c05146103735780634399fa5614610393578063458f9723146103b357610251565b80630416a4d51461026057806312e4a6d91461029a578063228cb733146102bb57806323a9495e146102f357806331428a8714610313575b3332141561025e57600080fd5b005b34801561026c57600080fd5b5061028061027b36600461346b565b61077e565b604080519283526020830191909152015b60405180910390f35b6102ad6102a8366004613552565b610a1c565b604051908152602001610291565b3480156102c757600080fd5b50600c546102db906001600160a01b031681565b6040516001600160a01b039091168152602001610291565b3480156102ff57600080fd5b5061025e61030e36600461363f565b610da9565b34801561031f57600080fd5b50600a546102db906001600160a01b031681565b34801561033f57600080fd5b506102ad61034e366004613658565b610ded565b34801561035f57600080fd5b506006546102db906001600160a01b031681565b34801561037f57600080fd5b506007546102db906001600160a01b031681565b34801561039f57600080fd5b50600b546102db906001600160a01b031681565b3480156103bf57600080fd5b506102ad60115481565b3480156103d557600080fd5b5061025e6103e436600461363f565b610e10565b3480156103f557600080fd5b5061025e610404366004613658565b610e8b565b34801561041557600080fd5b506002546102db906001600160a01b031681565b34801561043557600080fd5b5061025e610444366004613658565b610ee1565b61025e610457366004613675565b610f37565b34801561046857600080fd5b50600d546102db906001600160a01b031681565b34801561048857600080fd5b5061025e610497366004613658565b611525565b3480156104a857600080fd5b506104bc6104b73660046136b1565b61157b565b6040516102919291906136f7565b3480156104d657600080fd5b506102db6104e536600461363f565b611624565b3480156104f657600080fd5b5061025e61164e565b34801561050b57600080fd5b506102ad60045481565b34801561052157600080fd5b506000546001600160a01b03166102db565b34801561053f57600080fd5b506102ad60055481565b34801561055557600080fd5b5061025e610564366004613658565b611662565b34801561057557600080fd5b506001546102db906001600160a01b031681565b34801561059557600080fd5b5061025e6105a436600461363f565b6116b8565b3480156105b557600080fd5b506012546102db906001600160a01b031681565b3480156105d557600080fd5b506102ad60035481565b3480156105eb57600080fd5b50600e546102db906001600160a01b031681565b34801561060b57600080fd5b5061025e61061a366004613658565b6116f5565b34801561062b57600080fd5b5061025e61063a36600461363f565b61174b565b34801561064b57600080fd5b5061025e61065a366004613658565b611788565b61025e61066d3660046137b5565b6117de565b34801561067e57600080fd5b50600f546102db906001600160a01b031681565b34801561069e57600080fd5b506102806106ad36600461383c565b6118b9565b3480156106be57600080fd5b506102ad60105481565b3480156106d457600080fd5b5061025e6106e3366004613658565b6118e9565b3480156106f457600080fd5b5061025e610703366004613658565b61193f565b34801561071457600080fd5b5061025e610723366004613874565b611995565b34801561073457600080fd5b506102ad61271081565b34801561074a57600080fd5b5061025e610759366004613658565b611a3f565b34801561076a57600080fd5b5061025e610779366004613903565b611ab5565b6000806000604051806101a0016040528089600001358152602001896020013581526020018960400160208101906107b69190613658565b6001600160a01b031681526020016107d460808b0160608c01613658565b6001600160a01b031681526020016107f260a08b0160808c01613658565b6001600160a01b0316815260200161081060c08b0160a08c01613658565b6001600160a01b0316815260c08a0135602082015260e08a013560408201526101008a0135606082015260800161084b6101208b018b613945565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020016108906101408b018b613996565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506020016108d86101608b018b6139dd565b6108e190613a0f565b81526020016108f86101a08b016101808c01613ac7565b600381111561090957610909613ae8565b905260405161091b9190602001613c0d565b60408051601f19818403018152828252601254606088901b6bffffffffffffffffffffffff19166020808601829052845160148188038101825260948801875260348089018f815260548a018f9052885194850195909552875180850390920182529290920186526074909601529251630a51236960e01b81529194506001600160a01b031692630a512369926109be928c926001929091889190600401613d4d565b604080518083038186803b1580156109d557600080fd5b505afa1580156109e9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0d9190613da5565b92509250509550959350505050565b6000610a26611ad7565b83851015610a995760405162461bcd60e51b815260206004820152603560248201527f657870656374656452657475726e206d75737420626520657175616c206f72206044820152743630b933b2b9103a3430b71036b4b72932ba3ab93760591b60648201526084015b60405180910390fd5b866001600160a01b0316886001600160a01b03161415610acb5760405162461bcd60e51b8152600401610a9090613dc9565b60008060005b8451811015610b39576000858281518110610aee57610aee613e11565b60200260200101511115610b2757848181518110610b0e57610b0e613e11565b602002602001015183610b219190613e3d565b92508091505b80610b3181613e55565b915050610ad1565b5081610b9757610b518a6001600160a01b0316611b31565b15610b8d5760405133903480156108fc02916000818181858888f19350505050158015610b82573d6000803e3d6000fd5b503492505050610d94565b8792505050610d94565b610bac6001600160a01b038b1633308b611b6a565b610bba848984848e8e611c5c565b92508215610d335785831015610c1e5760405162461bcd60e51b8152602060048201526024808201527f5377697463683a2052657475726e20616d6f756e7420776173206e6f7420656e6044820152630deeaced60e31b6064820152608401610a90565b86831115610ce157610c3a6001600160a01b038a168689611e8c565b50600c54610c66906001600160a01b0316610c558986613e70565b6001600160a01b038c169190611e8c565b50600b546001600160a01b031663391fdc2433878d8d8d8d610c88818c613e70565b6040518863ffffffff1660e01b8152600401610caa9796959493929190613e87565b600060405180830381600087803b158015610cc457600080fd5b505af1158015610cd8573d6000803e3d6000fd5b50505050610d91565b610cf56001600160a01b038a168685611e8c565b50600b54604051630e47f70960e21b81526001600160a01b039091169063391fdc2490610caa90339089908f908f908f908b90600090600401613e87565b87610d476001600160a01b038c1630611f08565b1115610d6757610d616001600160a01b038b16338a611e8c565b50610d91565b610d8f33610d7e6001600160a01b038d1630611f08565b6001600160a01b038d169190611e8c565b505b50505b610d9e6001600955565b979650505050505050565b610db1611fa2565b60058190556040518181527f11e8ee12d79dc7314b845f4e82465af5bd3d2214081526061af36de8364eaa2e906020015b60405180910390a150565b6000610df7611fa2565b610e0a6001600160a01b03831630611f08565b92915050565b610e18611fa2565b611388811115610e565760405162461bcd60e51b8152602060048201526009602482015268746f6f206c6172676560b81b6044820152606401610a90565b60108190556040518181527fa28aac6f4ba79029a647ee085b0ae88419c6aa87bae5dcf77d303dba45b3681b90602001610de2565b610e93611fa2565b601280546001600160a01b0319166001600160a01b0383169081179091556040519081527f806d08432293677cc7e3e0f9443dcf0459f82567573d5094da6e9e6129dea4ab90602001610de2565b610ee9611fa2565b600b80546001600160a01b0319166001600160a01b0383169081179091556040519081527f35e63b7fefc2b1fb2ed78adeed6688b187514d96c2d7d56222e52f3e41c2fb2f90602001610de2565b610f3f611ad7565b610f683330610120840135610f576020860186613658565b6001600160a01b0316929190611b6a565b600080610f9b610f7b6020850185613658565b610120850135610f9160c0870160a08801613658565b8660c00135611ffc565b9050610fad6040840160208501613658565b6001600160a01b0316610fc36020850185613658565b6001600160a01b03161415610fda57809150611051565b6001610fee61032085016103008601613ac7565b6003811115610fff57610fff613ae8565b148061102d5750600361101a61032085016103008601613ac7565b600381111561102b5761102b613ae8565b145b156110435761103c838261223e565b9150611051565b61104d83826122a9565b5091505b8261014001358210156110a65760405162461bcd60e51b815260206004820152601e60248201527f5468652072657475726e20616d6f756e7420697320746f6f20736d616c6c00006044820152606401610a90565b604080516101a08101825261026085013581526102808501356020808301919091526000928201906110da90870187613658565b6001600160a01b031681526020016110f86060870160408801613658565b6001600160a01b031681526020016111166080870160608801613658565b6001600160a01b0316815260200161113460a0870160808801613658565b6001600160a01b031681526020810184905261018086013560408201526101e0860135606082015260800161116d610220870187613945565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020016111b26102e0870187613996565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050908252506020016111fa6103208701876139dd565b61120390613a0f565b815260200161121a61032087016103008801613ac7565b600381111561122b5761122b613ae8565b905260405161123d9190602001613c0d565b60408051601f19818403018152919052905060006112bb8261126761026088016102408901613ecb565b6101a08801356101c08901356112816102a08b018b613996565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506124cf92505050565b5090506112dc6112ce6020870187613658565b6001600160a01b0316611b31565b15611344576112f081610120870135613e3d565b34101561133f5760405162461bcd60e51b815260206004820152601a60248201527f6e617469766520746f6b656e206973206e6f7420656e6f7567680000000000006044820152606401610a90565b611394565b803410156113945760405162461bcd60e51b815260206004820152601a60248201527f6e617469766520746f6b656e206973206e6f7420656e6f7567680000000000006044820152606401610a90565b6113a76112ce6040870160208801613658565b6113dc576012546113dc906001600160a01b0316856113cc6040890160208a01613658565b6001600160a01b03169190612581565b6012546001600160a01b0316639fbf10fc8261140061026089016102408a01613ecb565b60e08901356101008a013561141b60a08c0160808d01613658565b8a8c610160013560405180606001604052808f6101a0013581526020018f6101c0013581526020018f806102a001906114549190613996565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508152508e806102a001906114ab9190613996565b8d6040518c63ffffffff1660e01b81526004016114d19a99989796959493929190613ee6565b6000604051808303818588803b1580156114ea57600080fd5b505af11580156114fe573d6000803e3d6000fd5b5050505050611514856000801b86336001612661565b505050506115226001600955565b50565b61152d611fa2565b600680546001600160a01b0319166001600160a01b0383169081179091556040519081527f41408be49f75701fe4bb8484ce88d68f1d82e03cb4eb44263b6682ce2dbd32f090602001610de2565b600a5460405163181da82d60e21b81526001600160a01b03868116600483015285811660248301526044820185905260648201849052600092606092911690636076a0b49060840160006040518083038186803b1580156115db57600080fd5b505afa1580156115ef573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116179190810190613f7d565b9097909650945050505050565b6008818154811061163457600080fd5b6000918252602090912001546001600160a01b0316905081565b611656611fa2565b6116606000612745565b565b61166a611fa2565b600f80546001600160a01b0319166001600160a01b0383169081179091556040519081527f12e1d17016b94668449f97876f4a8d5cc2c19f314db337418894734037cc19d490602001610de2565b6116c0611fa2565b60048190556040518181527f70f24e12a9db25e0d80cbcde19ffef47d6a7c52c1089db4c71e53ce1856577fc90602001610de2565b6116fd611fa2565b600780546001600160a01b0319166001600160a01b0383169081179091556040519081527f17780f3919f73af11f29e4157534858a06c91294d64b679fe4e49340122cd32290602001610de2565b611753611fa2565b60118190556040518181527f25677c92398d23f2071292abdbfc08a652d124b76716d2cee83f7f2fe2fbe1e290602001610de2565b611790611fa2565b600e80546001600160a01b0319166001600160a01b0383169081179091556040519081527fe0209b1ff5892dc27d9ffb30000e308317645f928d78a0a018dd2e9289ecc29290602001610de2565b6117e6611ad7565b846001600160a01b0316866001600160a01b031614156118185760405162461bcd60e51b8152600401610a9090613dc9565b61182d6001600160a01b038716333087611b6a565b611838868583612795565b600b54604051630e47f70960e21b81526001600160a01b039091169063391fdc249061187590339086908b908b908b908b90600090600401613e87565b600060405180830381600087803b15801561188f57600080fd5b505af11580156118a3573d6000803e3d6000fd5b505050506118b16001600955565b505050505050565b6000806127106118c9868561401a565b6118d3919061404f565b91506118df8286613e70565b9050935093915050565b6118f1611fa2565b600c80546001600160a01b0319166001600160a01b0383169081179091556040519081527f53a596d7be747a5a4f4d39a6a36476d2eed407c93f6f2ba8a96c8b971240d5cd90602001610de2565b611947611fa2565b600d80546001600160a01b0319166001600160a01b0383169081179091556040519081527f4528d04696417deba6006cd6c7e5bbb56b9874ac9d954a956e14b8d74f08d72b90602001610de2565b61199d611fa2565b805160035560005b8151811015611a0f5760088282815181106119c2576119c2613e11565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b0390921691909117905580611a0781613e55565b9150506119a5565b507fbbc63a7f378af7e269ef19f3fe0d08f044c91ee72930c0d045a58be58580f3d381604051610de29190614063565b611a47611fa2565b6001600160a01b038116611aac5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a90565b61152281612745565b611abd611fa2565b611ad16001600160a01b0384168284611e8c565b50505050565b60026009541415611b2a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a90565b6002600955565b60006001600160a01b0382161580610e0a57506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1492915050565b80611b7457611ad1565b611b7d84611b31565b15611c47576001600160a01b03831633148015611b9a5750803410155b611bfa5760405162461bcd60e51b815260206004820152602b60248201527f57726f6e6720757365616765206f66204554482e756e6976657273616c54726160448201526a6e7366657246726f6d282960a81b6064820152608401610a90565b6001600160a01b0382163014611c42576040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015611c40573d6000803e3d6000fd5b505b611ad1565b611ad16001600160a01b0385168484846128d9565b6000600454600354611c6e919061401a565b87511115611cee5760405162461bcd60e51b815260206004820152604160248201527f5377697463683a20446973747269627574696f6e2061727261792073686f756c60448201527f64206e6f742065786365656420666163746f726965732061727261792073697a6064820152606560f81b608482015260a401610a90565b856000805b8951811015611e7f57898181518110611d0e57611d0e613e11565b602002602001015160001415611d2357611e6d565b6000888b8381518110611d3857611d38613e11565b60200260200101518b611d4b919061401a565b611d55919061404f565b905087821415611d625750825b611d6c8185613e70565b935060045482611d7c91906140b0565b611dc757611dc0878783600860045487611d96919061404f565b81548110611da657611da6613e11565b6000918252602090912001546001600160a01b0316612944565b9250611e5f565b600454611dd490836140b0565b60011415611e1c57611dc0878783600860045487611df2919061404f565b81548110611e0257611e02613e11565b6000918252602090912001546001600160a01b031661295b565b611e5c878783600860045487611e32919061404f565b81548110611e4257611e42613e11565b6000918252602090912001546001600160a01b0316612978565b92505b611e698386613e3d565b9450505b80611e7781613e55565b915050611cf3565b5050509695505050505050565b600081611e9b57506001611f01565b611ea484611b31565b15611ee9576040516001600160a01b0384169083156108fc029084906000818181858888f19350505050158015611edf573d6000803e3d6000fd5b5060019050611f01565b611efd6001600160a01b0385168484612995565b5060015b9392505050565b6000611f1383611b31565b15611f2957506001600160a01b03811631610e0a565b6040516370a0823160e01b81526001600160a01b0383811660048301528416906370a082319060240160206040518083038186803b158015611f6a57600080fd5b505afa158015611f7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0191906140c4565b6000546001600160a01b031633146116605760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a90565b60006010548211156120505760405162461bcd60e51b815260206004820152601860248201527f706172746e65724665655261746520746f6f206c6172676500000000000000006044820152606401610a90565b508281156122365760006120666127108061401a565b601154612073878661401a565b61207d919061401a565b612087919061404f565b9050600081612710612099888761401a565b6120a3919061404f565b6120ad9190613e70565b90506120c1876001600160a01b0316611b31565b1561215457600f546001600160a01b031663eedd56e16120e18484613e3d565b6040516001600160e01b031960e084901b1681526001600160a01b03808c1660048301526024820186905260448201879052891660648201526084016000604051808303818588803b15801561213657600080fd5b505af115801561214a573d6000803e3d6000fd5b5050505050612210565b600f5461216f906001600160a01b03898116911660006129c5565b600f5461219a906001600160a01b03166121898484613e3d565b6001600160a01b038a1691906129c5565b600f5460405163eedd56e160e01b81526001600160a01b038981166004830152602482018490526044820185905287811660648301529091169063eedd56e190608401600060405180830381600087803b1580156121f757600080fd5b505af115801561220b573d6000803e3d6000fd5b505050505b61271061221d878661401a565b612227919061404f565b6122319087613e70565b925050505b949350505050565b6000611f016122506020850185613658565b6122606040860160208701613658565b8461226f6102c0880188613996565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612ae992505050565b60008080805b6122bd610200870187613945565b905081101561233b5760006122d6610200880188613945565b838181106122e6576122e6613e11565b90506020020135111561232957612301610200870187613945565b8281811061231157612311613e11565b90506020020135836123239190613e3d565b92508091505b8061233381613e55565b9150506122af565b506000821161238c5760405162461bcd60e51b815260206004820152601a60248201527f696e76616c696420646973747269627574696f6e20706172616d0000000000006044820152606401610a90565b6123f661239d610200870187613945565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508892508691508590506123e160208b018b613658565b6123f160408c0160208d01613658565b611c5c565b92506000831161243f5760405162461bcd60e51b81526020600482015260146024820152730a6eec2e040ccc2d2d8cac840cce4deda40c8caf60631b6044820152606401610a90565b600b546001600160a01b031663391fdc24333061245f60208a018a613658565b61246f60408b0160208c01613658565b898960006040518863ffffffff1660e01b81526004016124959796959493929190613e87565b600060405180830381600087803b1580156124af57600080fd5b505af11580156124c3573d6000803e3d6000fd5b50505050509250929050565b60125460408051606081018252858152602081018590528082018490529051630a51236960e01b815260009283926001600160a01b0390911691630a51236991612524918a9160019189918e91600401613d4d565b604080518083038186803b15801561253b57600080fd5b505afa15801561254f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125739190613da5565b915091509550959350505050565b61258a83611b31565b6125a857806125ad576125a86001600160a01b0384168360006129c5565b505050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e9060440160206040518083038186803b1580156125f857600080fd5b505afa15801561260c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263091906140c4565b9050801561264d5761264d6001600160a01b0385168460006129c5565b611ad16001600160a01b03851684846129c5565b600b546001600160a01b0316636fde7601610260870135866102808901358661268e6103208c018c6139dd565b61269c906020810190613658565b6126aa6103208d018d6139dd565b6126bb906040810190602001613658565b6126c860208e018e613658565b8d60400160200160208101906126de9190613658565b8c8f6101e001358c6040518c63ffffffff1660e01b815260040161270c9b9a999897969594939291906140dd565b600060405180830381600087803b15801561272657600080fd5b505af115801561273a573d6000803e3d6000fd5b505050505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006127a9846001600160a01b0316611b31565b1561280557824710156127fe5760405162461bcd60e51b815260206004820152601b60248201527f4554482062616c616e636520697320696e73756666696369656e7400000000006044820152606401610a90565b508161281f565b600d5461281f906001600160a01b03868116911685612581565b600e546040516000916001600160a01b031690839061283f908690614152565b60006040518083038185875af1925050503d806000811461287c576040519150601f19603f3d011682016040523d82523d6000602084013e612881565b606091505b50509050806128d25760405162461bcd60e51b815260206004820152601960248201527f506172617377617020657865637574696f6e206661696c6564000000000000006044820152606401610a90565b5050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611ad19085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612bb3565b600061295285858585612c85565b95945050505050565b6006546000906129529086906001600160a01b03168686866130f1565b6007546000906129529086906001600160a01b03168686866130f1565b6040516001600160a01b0383166024820152604481018290526125a890849063a9059cbb60e01b9060640161290d565b801580612a4e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015612a1457600080fd5b505afa158015612a28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a4c91906140c4565b155b612ab95760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610a90565b6040516001600160a01b0383166024820152604481018290526125a890849063095ea7b360e01b9060640161290d565b6000836001600160a01b0316856001600160a01b03161415612b1d5760405162461bcd60e51b8152600401610a9090613dc9565b612b28858484612795565b612b3b6001600160a01b03851630611f08565b600b54604051630e47f70960e21b81529192506001600160a01b03169063391fdc2490612b7990339030908a908a908a908990600090600401613e87565b600060405180830381600087803b158015612b9357600080fd5b505af1158015612ba7573d6000803e3d6000fd5b50505050949350505050565b6000612c08826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166131149092919063ffffffff16565b8051909150156125a85780806020019051810190612c269190614164565b6125a85760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a90565b6000612c99856001600160a01b0316611b31565b15612d0857600660009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b158015612cee57600080fd5b505af1158015612d02573d6000803e3d6000fd5b50505050505b6000612d1c866001600160a01b0316611b31565b612d265785612d33565b6006546001600160a01b03165b90506000612d49866001600160a01b0316611b31565b612d535785612d60565b6006546001600160a01b03165b60405163e6a4390560e01b81526001600160a01b038481166004830152808316602483015291925060009186169063e6a439059060440160206040518083038186803b158015612daf57600080fd5b505afa158015612dc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612de79190614186565b9050600080612e016001600160a01b03841686868b613123565b919750925090508115612e6657826001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612e4957600080fd5b505af1158015612e5d573d6000803e3d6000fd5b50505050612eda565b8015612eda5760405163bc25cf7760e01b81527346fd07da395799f113a7584563b8cb886f33c2bc60048201526001600160a01b0384169063bc25cf7790602401600060405180830381600087803b158015612ec157600080fd5b505af1158015612ed5573d6000803e3d6000fd5b505050505b612eee6001600160a01b038616848a611e8c565b50836001600160a01b0316856001600160a01b03161015612f835760405163022c0d9f60e01b8152600060048201819052602482018890523060448301526080606483015260848201526001600160a01b0384169063022c0d9f9060a401600060405180830381600087803b158015612f6657600080fd5b505af1158015612f7a573d6000803e3d6000fd5b50505050612ff9565b60405163022c0d9f60e01b8152600481018790526000602482018190523060448301526080606483015260848201526001600160a01b0384169063022c0d9f9060a401600060405180830381600087803b158015612fe057600080fd5b505af1158015612ff4573d6000803e3d6000fd5b505050505b61300b896001600160a01b0316611b31565b156130e4576006546040516370a0823160e01b81523060048201526001600160a01b0390911690632e1a7d4d9082906370a082319060240160206040518083038186803b15801561305b57600080fd5b505afa15801561306f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061309391906140c4565b6040518263ffffffff1660e01b81526004016130b191815260200190565b600060405180830381600087803b1580156130cb57600080fd5b505af11580156130df573d6000803e3d6000fd5b505050505b5050505050949350505050565b600061310a858561310489898888612c85565b85612c85565b9695505050505050565b606061223684846000856132be565b600080808061313b6001600160a01b03881689611f08565b905060006131526001600160a01b0388168a611f08565b90506000808a6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561319057600080fd5b505afa1580156131a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131c891906141ba565b5091509150886001600160a01b03168a6001600160a01b031611156131e957905b816001600160701b03168410806132085750806001600160701b031683105b9550851580156132325750816001600160701b03168411806132325750806001600160701b031683115b94506000613242896103e561401a565b9050600061325985846001600160701b031661338e565b613263908361401a565b905060008261327b88876001600160701b031661338e565b613287906103e861401a565b6132919190613e3d565b905080156132a8576132a3818361404f565b6132ab565b60005b9950505050505050509450945094915050565b60608247101561331f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610a90565b600080866001600160a01b0316858760405161333b9190614152565b60006040518083038185875af1925050503d8060008114613378576040519150601f19603f3d011682016040523d82523d6000602084013e61337d565b606091505b5091509150612231878383876133a4565b600081831061339d5781611f01565b5090919050565b60608315613410578251613409576001600160a01b0385163b6134095760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a90565b5081612236565b61223683838151156134255781518083602001fd5b8060405162461bcd60e51b8152600401610a9091906141f6565b803561ffff8116811461345157600080fd5b919050565b6001600160a01b038116811461152257600080fd5b600080600080600060a0868803121561348357600080fd5b853567ffffffffffffffff81111561349a57600080fd5b86016101a081890312156134ad57600080fd5b94506134bb6020870161343f565b9350604086013592506060860135915060808601356134d981613456565b809150509295509295909350565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715613526576135266134e7565b604052919050565b600067ffffffffffffffff821115613548576135486134e7565b5060051b60200190565b600080600080600080600060e0888a03121561356d57600080fd5b873561357881613456565b965060208881013561358981613456565b965060408901359550606089013594506080890135935060a08901356135ae81613456565b925060c089013567ffffffffffffffff8111156135ca57600080fd5b8901601f81018b136135db57600080fd5b80356135ee6135e98261352e565b6134fd565b81815260059190911b8201830190838101908d83111561360d57600080fd5b928401925b8284101561362b57833582529284019290840190613612565b809550505050505092959891949750929550565b60006020828403121561365157600080fd5b5035919050565b60006020828403121561366a57600080fd5b8135611f0181613456565b60006020828403121561368757600080fd5b813567ffffffffffffffff81111561369e57600080fd5b82016103408185031215611f0157600080fd5b600080600080608085870312156136c757600080fd5b84356136d281613456565b935060208501356136e281613456565b93969395505050506040820135916060013590565b6000604082018483526020604081850152818551808452606086019150828701935060005b818110156137385784518352938301939183019160010161371c565b5090979650505050505050565b600082601f83011261375657600080fd5b813567ffffffffffffffff811115613770576137706134e7565b613783601f8201601f19166020016134fd565b81815284602083860101111561379857600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060008060c087890312156137ce57600080fd5b86356137d981613456565b955060208701356137e981613456565b94506040870135935060608701359250608087013561380781613456565b915060a087013567ffffffffffffffff81111561382357600080fd5b61382f89828a01613745565b9150509295509295509295565b60008060006060848603121561385157600080fd5b83359250602084013561386381613456565b929592945050506040919091013590565b6000602080838503121561388757600080fd5b823567ffffffffffffffff81111561389e57600080fd5b8301601f810185136138af57600080fd5b80356138bd6135e98261352e565b81815260059190911b820183019083810190878311156138dc57600080fd5b928401925b82841015610d9e5783356138f481613456565b825292840192908401906138e1565b60008060006060848603121561391857600080fd5b833561392381613456565b925060208401359150604084013561393a81613456565b809150509250925092565b6000808335601e1984360301811261395c57600080fd5b83018035915067ffffffffffffffff82111561397757600080fd5b6020019150600581901b360382131561398f57600080fd5b9250929050565b6000808335601e198436030181126139ad57600080fd5b83018035915067ffffffffffffffff8211156139c857600080fd5b60200191503681900382131561398f57600080fd5b60008235609e198336030181126139f357600080fd5b9190910192915050565b63ffffffff8116811461152257600080fd5b600060a08236031215613a2157600080fd5b60405160a0810167ffffffffffffffff8282108183111715613a4557613a456134e7565b8160405284359150613a5682613456565b908252602084013590613a6882613456565b81602084015260408501359150613a7e82613456565b81604084015260608501359150613a94826139fd565b8160608401526080850135915080821115613aae57600080fd5b50613abb36828601613745565b60808301525092915050565b600060208284031215613ad957600080fd5b813560048110611f0157600080fd5b634e487b7160e01b600052602160045260246000fd5b600081518084526020808501945080840160005b83811015613b2e57815187529582019590820190600101613b12565b509495945050505050565b60005b83811015613b54578181015183820152602001613b3c565b83811115611ad15750506000910152565b60008151808452613b7d816020860160208601613b39565b601f01601f19169290920160200192915050565b600060018060a01b038083511684528060208401511660208501528060408401511660408501525063ffffffff6060830151166060840152608082015160a0608085015261223660a0850182613b65565b6004811061152257634e487b7160e01b600052602160045260246000fd5b613c0981613be2565b9052565b60208152815160208201526020820151604082015260006040830151613c3e60608401826001600160a01b03169052565b5060608301516001600160a01b03811660808401525060808301516001600160a01b03811660a08401525060a08301516001600160a01b03811660c08401525060c083015160e083015260e08301516101008181850152808501519150506101208181850152808501519150506101a06101408181860152613cc46101c0860184613afe565b9250808601519050601f19610160818786030181880152613ce58584613b65565b945080880151925050610180818786030181880152613d048584613b91565b94508088015192505050613d1a82860182613c00565b5090949350505050565b805182526020810151602083015260006040820151606060408501526122366060850182613b65565b61ffff8616815260ff8516602082015260a060408201526000613d7360a0830186613b65565b8281036060840152613d858186613b65565b90508281036080840152613d998185613d24565b98975050505050505050565b60008060408385031215613db857600080fd5b505080516020909101519092909150565b60208082526028908201527f69742773206e6f7420616c6c6f77656420746f2073776170207769746820736160408201526736b2903a37b5b2b760c11b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115613e5057613e50613e27565b500190565b6000600019821415613e6957613e69613e27565b5060010190565b600082821015613e8257613e82613e27565b500390565b6001600160a01b03978816815295871660208701529386166040860152919094166060840152608083019390935260a082019290925260c081019190915260e00190565b600060208284031215613edd57600080fd5b611f018261343f565b600061012061ffff8d1683528b60208401528a604084015260018060a01b038a1660608401528860808401528760a08401528060c0840152613f2a81840188613d24565b905082810360e084015284815284866020830137600060208683010152601f19601f86011681019050602083820301610100840152613f6c6020820185613b65565b9d9c50505050505050505050505050565b60008060408385031215613f9057600080fd5b8251915060208084015167ffffffffffffffff811115613faf57600080fd5b8401601f81018613613fc057600080fd5b8051613fce6135e98261352e565b81815260059190911b82018301908381019088831115613fed57600080fd5b928401925b8284101561400b57835182529284019290840190613ff2565b80955050505050509250929050565b600081600019048311821515161561403457614034613e27565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261405e5761405e614039565b500490565b6020808252825182820181905260009190848201906040850190845b818110156140a45783516001600160a01b03168352928401929184019160010161407f565b50909695505050505050565b6000826140bf576140bf614039565b500690565b6000602082840312156140d657600080fd5b5051919050565b8b8152602081018b9052604081018a90526001600160a01b038981166060830152888116608083015287811660a083015286811660c0830152851660e082015261010081018490526101208101839052610160810161413b83613be2565b826101408301529c9b505050505050505050505050565b600082516139f3818460208701613b39565b60006020828403121561417657600080fd5b81518015158114611f0157600080fd5b60006020828403121561419857600080fd5b8151611f0181613456565b80516001600160701b038116811461345157600080fd5b6000806000606084860312156141cf57600080fd5b6141d8846141a3565b92506141e6602085016141a3565b9150604084015161393a816139fd565b602081526000611f016020830184613b6556fea2646970667358221220558cf9c640e8fc2c86a368181c6eea20d6f44f3e219f4b96d1e3d2e05ea2e41964736f6c63430008090033

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

000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000006b4aafe0a2c03b223b73a681b544b1617a976ccb000000000000000000000000410f724847c92bc3cdacbcd4922f1d7833ec280a0000000000000000000000008731d54e9d02c286767d56ac03e8037c07e01e98000000000000000000000000216b4b4ba9f3e719726886d34a177484278bfcae000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee570000000000000000000000007ace1d4bb90d19826a88875ba0f60bd783bef31200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac000000000000000000000000115934131916c8b277dd010ee02de363c09d037c

-----Decoded View---------------
Arg [0] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [1] : _otherToken (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [2] : _pathCountAndSplit (uint256[]): 2,2
Arg [3] : _factories (address[]): 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f,0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac,0x115934131916C8b277DD010Ee02de363c09d037c
Arg [4] : _switchViewAddress (address): 0x6B4AAFE0A2C03B223b73a681b544b1617A976CcB
Arg [5] : _switchEventAddress (address): 0x410f724847C92Bc3CdACBCD4922F1D7833Ec280A
Arg [6] : _stargateRouter (address): 0x8731d54E9D02c286767d56ac03e8037C07e01e98
Arg [7] : _paraswapProxy (address): 0x216B4B4Ba9F3e719726886d34a177484278Bfcae
Arg [8] : _augustusSwapper (address): 0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57
Arg [9] : _feeCollector (address): 0x7ACe1D4BB90d19826A88875BA0F60bd783beF312

-----Encoded View---------------
17 Constructor Arguments found :
Arg [0] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [1] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [3] : 00000000000000000000000000000000000000000000000000000000000001a0
Arg [4] : 0000000000000000000000006b4aafe0a2c03b223b73a681b544b1617a976ccb
Arg [5] : 000000000000000000000000410f724847c92bc3cdacbcd4922f1d7833ec280a
Arg [6] : 0000000000000000000000008731d54e9d02c286767d56ac03e8037c07e01e98
Arg [7] : 000000000000000000000000216b4b4ba9f3e719726886d34a177484278bfcae
Arg [8] : 000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57
Arg [9] : 0000000000000000000000007ace1d4bb90d19826a88875ba0f60bd783bef312
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [12] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [13] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [14] : 0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
Arg [15] : 000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac
Arg [16] : 000000000000000000000000115934131916c8b277dd010ee02de363c09d037c


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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