ETH Price: $1,879.78 (-4.85%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Remote Swap213379382024-12-05 17:59:11444 days ago1733421551IN
0xcF688e5B...AeFbc4dc9
0 ETH0.0028057727.15829615
Remote Swap212768202024-11-27 4:52:47453 days ago1732683167IN
0xcF688e5B...AeFbc4dc9
0 ETH0.00042038.29321853
Remote Swap212261192024-11-20 2:59:23460 days ago1732071563IN
0xcF688e5B...AeFbc4dc9
0 ETH0.000721814.24558798
Remote Swap212261152024-11-20 2:58:35460 days ago1732071515IN
0xcF688e5B...AeFbc4dc9
0 ETH0.0011662413.80545321
Remote Swap197189602024-04-23 15:23:11670 days ago1713885791IN
0xcF688e5B...AeFbc4dc9
0 ETH0.0028868722.70344007
Remote Swap197118112024-04-22 15:23:35671 days ago1713799415IN
0xcF688e5B...AeFbc4dc9
0 ETH0.0018716218.98527169
Set Stargate Rou...185665182023-11-14 0:19:59832 days ago1699921199IN
0xcF688e5B...AeFbc4dc9
0 ETH0.0010763735.76697589

Latest 9 internal transactions

Advanced mode:
Parent Transaction Hash Method Block
From
To
Transfer216346312025-01-16 4:22:59403 days ago1737001379
0xcF688e5B...AeFbc4dc9
0.00068949 ETH
Transfer215278962025-01-01 6:42:47417 days ago1735713767
0xcF688e5B...AeFbc4dc9
0.00068949 ETH
Transfer212768202024-11-27 4:52:47453 days ago1732683167
0xcF688e5B...AeFbc4dc9
0.00604256 ETH
Transfer212641212024-11-25 10:16:59454 days ago1732529819
0xcF688e5B...AeFbc4dc9
0.00604256 ETH
Transfer212261192024-11-20 2:59:23460 days ago1732071563
0xcF688e5B...AeFbc4dc9
0.01341326 ETH
Transfer211983662024-11-16 6:08:47464 days ago1731737327
0xcF688e5B...AeFbc4dc9
0.00700256 ETH
Transfer207125842024-09-09 10:53:23531 days ago1725879203
0xcF688e5B...AeFbc4dc9
0.00215419 ETH
Transfer201958972024-06-29 7:37:11603 days ago1719646631
0xcF688e5B...AeFbc4dc9
0.00290703 ETH
Transfer193871692024-03-08 1:28:11717 days ago1709861291
0xcF688e5B...AeFbc4dc9
0.00134947 ETH
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SwitchStargateReceiver

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

import "../dexs/Switch.sol";
import { IStargateReceiver } from "../interfaces/IStargateReceiver.sol";
import "../lib/DataTypes.sol";

contract SwitchStargateReceiver is Switch, IStargateReceiver {
    using UniversalERC20 for IERC20;

    address public stargateRouter;
    uint8 public constant TYPE_SWAP_REMOTE = 1;

    struct StargateSwapRequest {
        bytes32 id;
        bytes32 bridge;
        address srcToken;
        address bridgeToken;
        address dstToken;
        address recipient;
        uint256 srcAmount;
        uint256 bridgeDstAmount;
        uint256 estimatedDstAmount;
        uint256 minDstAmount;
        DataTypes.ParaswapUsageStatus paraswapUsageStatus;
        uint256[] dstDistribution;
        bytes dstParaswapData;
    }

    event StargateRouterSet(address stargateRouter);

    constructor(
        address _weth,
        address _otherToken,
        uint256 _pathCount,
        uint256 _pathSplit,
        address[] memory _factories,
        address[] memory _switchViewAndEventAddresses,
        address _stargateRouter,
        address _paraswapProxy,
        address _augustusSwapper,
        address _feeCollector
    ) Switch(_weth, _otherToken, _pathCount, _pathSplit, _factories, _switchViewAndEventAddresses[0], _switchViewAndEventAddresses[1], _paraswapProxy, _augustusSwapper, feeCollector)
        public
    {
        stargateRouter = _stargateRouter;
    }

    modifier onlyStargateRouter() {
        require(msg.sender == stargateRouter, "caller is not stargate router");
        _;
    }

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

    // STARGATE RECEIVER - the destination contract must implement this function to receive the tokens and payload
    function sgReceive(
        uint16,
        bytes memory,
        uint256,
        address token,
        uint amount,
        bytes memory payload
    )
        override
        external
        onlyStargateRouter
    {
        StargateSwapRequest memory m = abi.decode((payload), (StargateSwapRequest));
        require(token == m.bridgeToken, "bridged token must be the same as the first token in destination swap path");

        uint256 reserveGas = 100000;

        if(gasleft() < reserveGas) {
            _sendToRecipient(token, m.recipient, amount);
            _emitCrosschainSwapDone(m, amount, 0, DataTypes.SwapStatus.Failed);
            return;
        }

        // 100000 -> exit gas
        uint256 limit = gasleft() - reserveGas;

        if (m.bridgeToken == m.dstToken) {
            _sendToRecipient(m.bridgeToken, m.recipient, amount);
            _emitCrosschainSwapDone(m, amount, amount, DataTypes.SwapStatus.Succeeded);
        } else {
            try
                this.remoteSwap{gas: limit}(m, amount, token)
            {} catch Error(string memory) {
                _sendToRecipient(token, m.recipient, amount);
                _emitCrosschainSwapDone(m, amount, 0, DataTypes.SwapStatus.Failed);
            } catch (bytes memory) {
                _sendToRecipient(token, m.recipient, amount);
                _emitCrosschainSwapDone(m, amount, 0, DataTypes.SwapStatus.Failed);
            }
        }
    }

    function remoteSwap(
        StargateSwapRequest memory m,
        uint256 amount,
        address token
    )
        external
    {
        if (m.paraswapUsageStatus == DataTypes.ParaswapUsageStatus.OnDestChain ||
            m.paraswapUsageStatus == DataTypes.ParaswapUsageStatus.Both)
        {
            if (amount >= m.bridgeDstAmount) {
                _callParaswap(IERC20(token), m.bridgeDstAmount, m.dstParaswapData);
                _sendToRecipient(token, m.recipient, amount - m.bridgeDstAmount);
                _emitCrosschainSwapDone(m, m.bridgeDstAmount, m.estimatedDstAmount, DataTypes.SwapStatus.Succeeded);
            } else {
                uint256 returnAmount = _executeWithDistribution(m, amount);
                require(returnAmount >= m.minDstAmount, "return amount was not enough");
            }
        } else {
            uint256 returnAmount = _executeWithDistribution(m, amount);
            require(returnAmount >= m.minDstAmount, "return amount was not enough");
        }
    }

    function _sendToRecipient(
        address token,
        address recipient,
        uint256 amount
    )
        internal
    {
        if (IERC20(token).isETH()) {
            payable(recipient).transfer(amount);
        } else {
            IERC20(token).universalTransfer(recipient, amount);
        }
    }

    function _swapInternalForStargate(
        uint256 amount,
        uint256 parts,
        uint256 lastNonZeroIndex,
        StargateSwapRequest memory m // callData
    )
        internal
        returns (
            DataTypes.SwapStatus status,
            uint256 returnAmount
        )
    {
        returnAmount = _swapInternalForSingleSwap(m.dstDistribution, amount, parts, lastNonZeroIndex, IERC20(m.bridgeToken), IERC20(m.dstToken));
        if (returnAmount > 0) {
            IERC20(m.dstToken).universalTransfer(m.recipient, returnAmount);
            status = DataTypes.SwapStatus.Succeeded;
            switchEvent.emitSwapped(msg.sender, address(this), IERC20(m.bridgeToken), IERC20(m.dstToken), amount, returnAmount, 0);
        } else {
            // handle swap failure, send the received token directly to recipient
            IERC20(m.bridgeToken).universalTransfer(m.recipient, amount);
            returnAmount = amount;
            status = DataTypes.SwapStatus.Fallback;
        }
    }

    function _executeWithDistribution(
        StargateSwapRequest memory m,
        uint256 srcAmount
    )
        internal
        returns (
            uint256 dstAmount
        )
    {
        DataTypes.SwapStatus status = DataTypes.SwapStatus.Succeeded;
        uint256 parts = 0;
        uint256 lastNonZeroIndex = 0;
        for (uint i = 0; i < m.dstDistribution.length; i++) {
            if (m.dstDistribution[i] > 0) {
                parts += m.dstDistribution[i];
                lastNonZeroIndex = i;
            }
        }

        require(parts > 0, "invalid distribution param");
        (status, dstAmount) = _swapInternalForStargate(srcAmount, parts, lastNonZeroIndex, m);
        _emitCrosschainSwapDone(m, srcAmount, dstAmount, status);
    }

    function _emitCrosschainSwapDone(StargateSwapRequest memory m, uint256 srcAmount, uint256 dstAmount, DataTypes.SwapStatus status) internal {
        switchEvent.emitCrosschainSwapDone(m.id, m.bridge, m.recipient, m.bridgeToken, m.dstToken, srcAmount, dstAmount, status);
    }
}

// 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);
    }
}

// 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;
    }
}

// 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);
}

// 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);
}

// 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");
        }
    }
}

// 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);
        }
    }
}

// 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 22 : 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
        );
}

// 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;
}

// 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);
    }
}

// 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 22 : 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 22 : IStargateReceiver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

interface IStargateReceiver {
    function sgReceive(
        uint16 _chainId,
        bytes memory _srcAddress,
        uint _nonce,
        address _token,
        uint amountLD,
        bytes memory payload
    ) external;
}

// 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;
}

// 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;
}

// 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 18 of 22 : 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 19 of 22 : 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;
    }
}

// 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 21 of 22 : 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;
    }
}

// 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

API
[{"inputs":[{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_otherToken","type":"address"},{"internalType":"uint256","name":"_pathCount","type":"uint256"},{"internalType":"uint256","name":"_pathSplit","type":"uint256"},{"internalType":"address[]","name":"_factories","type":"address[]"},{"internalType":"address[]","name":"_switchViewAndEventAddresses","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":"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":"TYPE_SWAP_REMOTE","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"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":[],"name":"dexCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"factories","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"destToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"parts","type":"uint256"}],"name":"getExpectedReturn","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"partner","type":"address"},{"internalType":"uint256","name":"partnerFeeRate","type":"uint256"}],"name":"getFeeInfo","outputs":[{"internalType":"uint256","name":"partnerFee","type":"uint256"},{"internalType":"uint256","name":"remainAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenBalance","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"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":[{"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":"dstToken","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"bridgeDstAmount","type":"uint256"},{"internalType":"uint256","name":"estimatedDstAmount","type":"uint256"},{"internalType":"uint256","name":"minDstAmount","type":"uint256"},{"internalType":"enum DataTypes.ParaswapUsageStatus","name":"paraswapUsageStatus","type":"uint8"},{"internalType":"uint256[]","name":"dstDistribution","type":"uint256[]"},{"internalType":"bytes","name":"dstParaswapData","type":"bytes"}],"internalType":"struct SwitchStargateReceiver.StargateSwapRequest","name":"m","type":"tuple"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"token","type":"address"}],"name":"remoteSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reward","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"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":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"sgReceive","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"}]

6080604052600180546001600160a01b031990811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee179091556002805490911690556103e86010556105dc6011553480156200004f57600080fd5b5060405162003e4c38038062003e4c833981016040819052620000729162000353565b8989898989896000815181106200008d576200008d62000444565b60200260200101518a600181518110620000ab57620000ab62000444565b6020908102919091010151600f548a908a906001600160a01b03168989898989620000d63362000223565b600680546001600160a01b038088166001600160a01b031992831617909255600780549287169290911691909117905560048390556005829055805160035560005b81518110156200018957600882828151811062000139576200013962000444565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b039092169190911790558062000180816200045a565b91505062000118565b505060016009555050600a80546001600160a01b03199081166001600160a01b03998a1617909155600b80548216978916979097179096555050600d8054851693861693909317909255600e80548416918516919091179055600f80548316918416919091179055600c805433908316179055601280549091169a9091169990991790985550620004849c50505050505050505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146200028b57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620002b857600080fd5b815160206001600160401b0380831115620002d757620002d762000290565b8260051b604051601f19603f83011681018181108482111715620002ff57620002ff62000290565b6040529384528581018301938381019250878511156200031e57600080fd5b83870191505b848210156200034857620003388262000273565b8352918301919083019062000324565b979650505050505050565b6000806000806000806000806000806101408b8d0312156200037457600080fd5b6200037f8b62000273565b99506200038f60208c0162000273565b60408c015160608d015160808e0151929b5090995097506001600160401b0380821115620003bc57600080fd5b620003ca8e838f01620002a6565b975060a08d0151915080821115620003e157600080fd5b50620003f08d828e01620002a6565b9550506200040160c08c0162000273565b93506200041160e08c0162000273565b9250620004226101008c0162000273565b9150620004336101208c0162000273565b90509295989b9194979a5092959850565b634e487b7160e01b600052603260045260246000fd5b60006000198214156200047d57634e487b7160e01b600052601160045260246000fd5b5060010190565b6139b880620004946000396000f3fe60806040526004361061025c5760003560e01c806390f3f20811610144578063bbe8caa2116100b6578063e5932c401161007a578063e5932c4014610707578063e8984c5f14610727578063ea15afc314610747578063ecefc70514610767578063f2fde38b1461077d578063f640d5081461079d5761025c565b8063bbe8caa214610669578063c415b95c1461067c578063ca1ab6041461069c578063d6821ed8146106bc578063e37c4250146106f15761025c565b8063ab30469511610108578063ab304695146105b3578063ab8236f3146105c9578063ae551c66146105e9578063b4c76fe014610609578063b58468cf14610629578063b9d52d3c146106495761025c565b806390f3f2081461051d578063a42dce8014610533578063a734f06e14610553578063a85f329814610573578063a9e56f3c146105935761025c565b806348c4d781116101dd5780635b769f3c116101a15780635b769f3c146104665780636076a0b414610486578063672383c4146104b4578063715018a6146104d45780638c821e90146104e95780638da5cb5b146104ff5761025c565b806348c4d781146103c657806351b78b47146103e6578063538ba4f91461040657806353fd7bf1146104265780635b18075e146104465761025c565b80633aecd0e3116102245780633aecd0e3146103305780633fc8cef314610350578063433b3c05146103705780634399fa5614610390578063458f9723146103b05761025c565b8063081a54001461026b57806312e4a6d914610297578063228cb733146102b857806323a9495e146102f057806331428a8714610310575b3332141561026957600080fd5b005b34801561027757600080fd5b50610280600181565b60405160ff90911681526020015b60405180910390f35b6102aa6102a5366004612c4c565b6107bd565b60405190815260200161028e565b3480156102c457600080fd5b50600c546102d8906001600160a01b031681565b6040516001600160a01b03909116815260200161028e565b3480156102fc57600080fd5b5061026961030b366004612cde565b610b4a565b34801561031c57600080fd5b50600a546102d8906001600160a01b031681565b34801561033c57600080fd5b506102aa61034b366004612cf7565b610b8e565b34801561035c57600080fd5b506006546102d8906001600160a01b031681565b34801561037c57600080fd5b506007546102d8906001600160a01b031681565b34801561039c57600080fd5b50600b546102d8906001600160a01b031681565b3480156103bc57600080fd5b506102aa60115481565b3480156103d257600080fd5b506102696103e1366004612cde565b610bb1565b3480156103f257600080fd5b50610269610401366004612cf7565b610c2c565b34801561041257600080fd5b506002546102d8906001600160a01b031681565b34801561043257600080fd5b50610269610441366004612cf7565b610c82565b34801561045257600080fd5b50600d546102d8906001600160a01b031681565b34801561047257600080fd5b50610269610481366004612cf7565b610cd8565b34801561049257600080fd5b506104a66104a1366004612d14565b610d2e565b60405161028e929190612d5a565b3480156104c057600080fd5b506102d86104cf366004612cde565b610dd7565b3480156104e057600080fd5b50610269610e01565b3480156104f557600080fd5b506102aa60045481565b34801561050b57600080fd5b506000546001600160a01b03166102d8565b34801561052957600080fd5b506102aa60055481565b34801561053f57600080fd5b5061026961054e366004612cf7565b610e15565b34801561055f57600080fd5b506001546102d8906001600160a01b031681565b34801561057f57600080fd5b5061026961058e366004612cde565b610e6b565b34801561059f57600080fd5b506012546102d8906001600160a01b031681565b3480156105bf57600080fd5b506102aa60035481565b3480156105d557600080fd5b506102696105e4366004612e2c565b610ea8565b3480156105f557600080fd5b50600e546102d8906001600160a01b031681565b34801561061557600080fd5b50610269610624366004612cf7565b611130565b34801561063557600080fd5b50610269610644366004612cde565b611186565b34801561065557600080fd5b50610269610664366004612cf7565b6111c3565b610269610677366004612ed0565b611219565b34801561068857600080fd5b50600f546102d8906001600160a01b031681565b3480156106a857600080fd5b506102696106b7366004612f62565b6112ec565b3480156106c857600080fd5b506106dc6106d73660046130aa565b6113ed565b6040805192835260208301919091520161028e565b3480156106fd57600080fd5b506102aa60105481565b34801561071357600080fd5b50610269610722366004612cf7565b61141d565b34801561073357600080fd5b50610269610742366004612cf7565b611473565b34801561075357600080fd5b506102696107623660046130e2565b6114c9565b34801561077357600080fd5b506102aa61271081565b34801561078957600080fd5b50610269610798366004612cf7565b611573565b3480156107a957600080fd5b506102696107b836600461317c565b6115ec565b60006107c7611608565b8385101561083a5760405162461bcd60e51b815260206004820152603560248201527f657870656374656452657475726e206d75737420626520657175616c206f72206044820152743630b933b2b9103a3430b71036b4b72932ba3ab93760591b60648201526084015b60405180910390fd5b866001600160a01b0316886001600160a01b0316141561086c5760405162461bcd60e51b8152600401610831906131be565b60008060005b84518110156108da57600085828151811061088f5761088f613206565b602002602001015111156108c8578481815181106108af576108af613206565b6020026020010151836108c29190613232565b92508091505b806108d28161324a565b915050610872565b5081610938576108f28a6001600160a01b0316611662565b1561092e5760405133903480156108fc02916000818181858888f19350505050158015610923573d6000803e3d6000fd5b503492505050610b35565b8792505050610b35565b61094d6001600160a01b038b1633308b61169b565b61095b848984848e8e61178d565b92508215610ad457858310156109bf5760405162461bcd60e51b8152602060048201526024808201527f5377697463683a2052657475726e20616d6f756e7420776173206e6f7420656e6044820152630deeaced60e31b6064820152608401610831565b86831115610a82576109db6001600160a01b038a1686896119bd565b50600c54610a07906001600160a01b03166109f68986613265565b6001600160a01b038c1691906119bd565b50600b546001600160a01b031663391fdc2433878d8d8d8d610a29818c613265565b6040518863ffffffff1660e01b8152600401610a4b979695949392919061327c565b600060405180830381600087803b158015610a6557600080fd5b505af1158015610a79573d6000803e3d6000fd5b50505050610b32565b610a966001600160a01b038a1686856119bd565b50600b54604051630e47f70960e21b81526001600160a01b039091169063391fdc2490610a4b90339089908f908f908f908b9060009060040161327c565b87610ae86001600160a01b038c1630611a39565b1115610b0857610b026001600160a01b038b16338a6119bd565b50610b32565b610b3033610b1f6001600160a01b038d1630611a39565b6001600160a01b038d1691906119bd565b505b50505b610b3f6001600955565b979650505050505050565b610b52611ad3565b60058190556040518181527f11e8ee12d79dc7314b845f4e82465af5bd3d2214081526061af36de8364eaa2e906020015b60405180910390a150565b6000610b98611ad3565b610bab6001600160a01b03831630611a39565b92915050565b610bb9611ad3565b611388811115610bf75760405162461bcd60e51b8152602060048201526009602482015268746f6f206c6172676560b81b6044820152606401610831565b60108190556040518181527fa28aac6f4ba79029a647ee085b0ae88419c6aa87bae5dcf77d303dba45b3681b90602001610b83565b610c34611ad3565b601280546001600160a01b0319166001600160a01b0383169081179091556040519081527f806d08432293677cc7e3e0f9443dcf0459f82567573d5094da6e9e6129dea4ab90602001610b83565b610c8a611ad3565b600b80546001600160a01b0319166001600160a01b0383169081179091556040519081527f35e63b7fefc2b1fb2ed78adeed6688b187514d96c2d7d56222e52f3e41c2fb2f90602001610b83565b610ce0611ad3565b600680546001600160a01b0319166001600160a01b0383169081179091556040519081527f41408be49f75701fe4bb8484ce88d68f1d82e03cb4eb44263b6682ce2dbd32f090602001610b83565b600a5460405163181da82d60e21b81526001600160a01b03868116600483015285811660248301526044820185905260648201849052600092606092911690636076a0b49060840160006040518083038186803b158015610d8e57600080fd5b505afa158015610da2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610dca9190810190613326565b9097909650945050505050565b60088181548110610de757600080fd5b6000918252602090912001546001600160a01b0316905081565b610e09611ad3565b610e136000611b2d565b565b610e1d611ad3565b600f80546001600160a01b0319166001600160a01b0383169081179091556040519081527f12e1d17016b94668449f97876f4a8d5cc2c19f314db337418894734037cc19d490602001610b83565b610e73611ad3565b60048190556040518181527f70f24e12a9db25e0d80cbcde19ffef47d6a7c52c1089db4c71e53ce1856577fc90602001610b83565b6012546001600160a01b03163314610f025760405162461bcd60e51b815260206004820152601d60248201527f63616c6c6572206973206e6f7420737461726761746520726f757465720000006044820152606401610831565b600081806020019051810190610f1891906133fe565b905080606001516001600160a01b0316846001600160a01b031614610fb85760405162461bcd60e51b815260206004820152604a60248201527f6272696467656420746f6b656e206d757374206265207468652073616d65206160448201527f732074686520666972737420746f6b656e20696e2064657374696e6174696f6e606482015269040e6eec2e040e0c2e8d60b31b608482015260a401610831565b620186a0805a1015610fe857610fd3858360a0015186611b7d565b610fe1828560006002611bde565b5050611128565b6000815a610ff69190613265565b905082608001516001600160a01b031683606001516001600160a01b0316141561103f5761102d83606001518460a0015187611b7d565b61103a8386876001611bde565b611124565b604051633286ad8160e21b8152309063ca1ab6049083906110689087908a908c906004016135d4565b600060405180830381600088803b15801561108257600080fd5b5087f193505050508015611094575060015b611124576110a06136f7565b806308c379a014156110e357506110b5613713565b806110c057506110e5565b6110cf878560a0015188611b7d565b6110dd848760006002611bde565b50611124565b505b3d80801561110f576040519150601f19603f3d011682016040523d82523d6000602084013e611114565b606091505b506110cf878560a0015188611b7d565b5050505b505050505050565b611138611ad3565b600780546001600160a01b0319166001600160a01b0383169081179091556040519081527f17780f3919f73af11f29e4157534858a06c91294d64b679fe4e49340122cd32290602001610b83565b61118e611ad3565b60118190556040518181527f25677c92398d23f2071292abdbfc08a652d124b76716d2cee83f7f2fe2fbe1e290602001610b83565b6111cb611ad3565b600e80546001600160a01b0319166001600160a01b0383169081179091556040519081527fe0209b1ff5892dc27d9ffb30000e308317645f928d78a0a018dd2e9289ecc29290602001610b83565b611221611608565b846001600160a01b0316866001600160a01b031614156112535760405162461bcd60e51b8152600401610831906131be565b6112686001600160a01b03871633308761169b565b611273868583611c68565b600b54604051630e47f70960e21b81526001600160a01b039091169063391fdc24906112b090339086908b908b908b908b9060009060040161327c565b600060405180830381600087803b1580156112ca57600080fd5b505af11580156112de573d6000803e3d6000fd5b505050506111286001600955565b600283610140015160038111156113055761130561352c565b14806113275750600383610140015160038111156113255761132561352c565b145b15611384578260e0015182106113845761134b818460e00151856101800151611c68565b611369818460a001518560e00151856113649190613265565b611b7d565b61137f838460e001518561010001516001611bde565b505050565b60006113908484611dac565b90508361012001518110156113e75760405162461bcd60e51b815260206004820152601c60248201527f72657475726e20616d6f756e7420776173206e6f7420656e6f756768000000006044820152606401610831565b50505050565b6000806127106113fd868561379d565b61140791906137d2565b91506114138286613265565b9050935093915050565b611425611ad3565b600c80546001600160a01b0319166001600160a01b0383169081179091556040519081527f53a596d7be747a5a4f4d39a6a36476d2eed407c93f6f2ba8a96c8b971240d5cd90602001610b83565b61147b611ad3565b600d80546001600160a01b0319166001600160a01b0383169081179091556040519081527f4528d04696417deba6006cd6c7e5bbb56b9874ac9d954a956e14b8d74f08d72b90602001610b83565b6114d1611ad3565b805160035560005b81518110156115435760088282815181106114f6576114f6613206565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b039092169190911790558061153b8161324a565b9150506114d9565b507fbbc63a7f378af7e269ef19f3fe0d08f044c91ee72930c0d045a58be58580f3d381604051610b8391906137e6565b61157b611ad3565b6001600160a01b0381166115e05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610831565b6115e981611b2d565b50565b6115f4611ad3565b6113e76001600160a01b03841682846119bd565b6002600954141561165b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610831565b6002600955565b60006001600160a01b0382161580610bab57506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1492915050565b806116a5576113e7565b6116ae84611662565b15611778576001600160a01b038316331480156116cb5750803410155b61172b5760405162461bcd60e51b815260206004820152602b60248201527f57726f6e6720757365616765206f66204554482e756e6976657273616c54726160448201526a6e7366657246726f6d282960a81b6064820152608401610831565b6001600160a01b0382163014611773576040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015611771573d6000803e3d6000fd5b505b6113e7565b6113e76001600160a01b038516848484611ea1565b600060045460035461179f919061379d565b8751111561181f5760405162461bcd60e51b815260206004820152604160248201527f5377697463683a20446973747269627574696f6e2061727261792073686f756c60448201527f64206e6f742065786365656420666163746f726965732061727261792073697a6064820152606560f81b608482015260a401610831565b856000805b89518110156119b05789818151811061183f5761183f613206565b6020026020010151600014156118545761199e565b6000888b838151811061186957611869613206565b60200260200101518b61187c919061379d565b61188691906137d2565b9050878214156118935750825b61189d8185613265565b9350600454826118ad9190613833565b6118f8576118f18787836008600454876118c791906137d2565b815481106118d7576118d7613206565b6000918252602090912001546001600160a01b0316611f0c565b9250611990565b6004546119059083613833565b6001141561194d576118f187878360086004548761192391906137d2565b8154811061193357611933613206565b6000918252602090912001546001600160a01b0316611f23565b61198d87878360086004548761196391906137d2565b8154811061197357611973613206565b6000918252602090912001546001600160a01b0316611f40565b92505b61199a8386613232565b9450505b806119a88161324a565b915050611824565b5050509695505050505050565b6000816119cc57506001611a32565b6119d584611662565b15611a1a576040516001600160a01b0384169083156108fc029084906000818181858888f19350505050158015611a10573d6000803e3d6000fd5b5060019050611a32565b611a2e6001600160a01b0385168484611f5d565b5060015b9392505050565b6000611a4483611662565b15611a5a57506001600160a01b03811631610bab565b6040516370a0823160e01b81526001600160a01b0383811660048301528416906370a082319060240160206040518083038186803b158015611a9b57600080fd5b505afa158015611aaf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a329190613847565b6000546001600160a01b03163314610e135760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610831565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611b8f836001600160a01b0316611662565b15611bca576040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156113e7573d6000803e3d6000fd5b6113e76001600160a01b03841683836119bd565b600b548451602086015160a08701516060880151608089015160405163424971a960e11b81526001600160a01b0390961695638492e35295611c309590949093909290918b908b908b90600401613860565b600060405180830381600087803b158015611c4a57600080fd5b505af1158015611c5e573d6000803e3d6000fd5b5050505050505050565b6000611c7c846001600160a01b0316611662565b15611cd85782471015611cd15760405162461bcd60e51b815260206004820152601b60248201527f4554482062616c616e636520697320696e73756666696369656e7400000000006044820152606401610831565b5081611cf2565b600d54611cf2906001600160a01b03868116911685611f8d565b600e546040516000916001600160a01b0316908390611d129086906138b8565b60006040518083038185875af1925050503d8060008114611d4f576040519150601f19603f3d011682016040523d82523d6000602084013e611d54565b606091505b5050905080611da55760405162461bcd60e51b815260206004820152601960248201527f506172617377617020657865637574696f6e206661696c6564000000000000006044820152606401610831565b5050505050565b600060018180805b86610160015151811015611e2b5760008761016001518281518110611ddb57611ddb613206565b60200260200101511115611e19578661016001518181518110611e0057611e00613206565b602002602001015183611e139190613232565b92508091505b80611e238161324a565b915050611db4565b5060008211611e7c5760405162461bcd60e51b815260206004820152601a60248201527f696e76616c696420646973747269627574696f6e20706172616d0000000000006044820152606401610831565b611e8885838389612068565b94509250611e9886868686611bde565b50505092915050565b6040516001600160a01b03808516602483015283166044820152606481018290526113e79085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261216d565b6000611f1a8585858561223f565b95945050505050565b600654600090611f1a9086906001600160a01b03168686866126ab565b600754600090611f1a9086906001600160a01b03168686866126ab565b6040516001600160a01b03831660248201526044810182905261137f90849063a9059cbb60e01b90606401611ed5565b611f9683611662565b61137f5780611fb45761137f6001600160a01b0384168360006126ce565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e9060440160206040518083038186803b158015611fff57600080fd5b505afa158015612013573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120379190613847565b90508015612054576120546001600160a01b0385168460006126ce565b6113e76001600160a01b03851684846126ce565b6000806120868361016001518787878760600151886080015161178d565b90508015612135576120b48360a001518285608001516001600160a01b03166119bd9092919063ffffffff16565b50600b5460608401516080850151604051630e47f70960e21b8152600195506001600160a01b039093169263391fdc24926120fe923392309291908d90899060009060040161327c565b600060405180830381600087803b15801561211857600080fd5b505af115801561212c573d6000803e3d6000fd5b50505050612164565b61215b8360a001518785606001516001600160a01b03166119bd9092919063ffffffff16565b50859050600391505b94509492505050565b60006121c2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166127f29092919063ffffffff16565b80519091501561137f57808060200190518101906121e091906138d4565b61137f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610831565b6000612253856001600160a01b0316611662565b156122c257600660009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156122a857600080fd5b505af11580156122bc573d6000803e3d6000fd5b50505050505b60006122d6866001600160a01b0316611662565b6122e057856122ed565b6006546001600160a01b03165b90506000612303866001600160a01b0316611662565b61230d578561231a565b6006546001600160a01b03165b60405163e6a4390560e01b81526001600160a01b038481166004830152808316602483015291925060009186169063e6a439059060440160206040518083038186803b15801561236957600080fd5b505afa15801561237d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a191906138f6565b90506000806123bb6001600160a01b03841686868b612809565b91975092509050811561242057826001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561240357600080fd5b505af1158015612417573d6000803e3d6000fd5b50505050612494565b80156124945760405163bc25cf7760e01b81527346fd07da395799f113a7584563b8cb886f33c2bc60048201526001600160a01b0384169063bc25cf7790602401600060405180830381600087803b15801561247b57600080fd5b505af115801561248f573d6000803e3d6000fd5b505050505b6124a86001600160a01b038616848a6119bd565b50836001600160a01b0316856001600160a01b0316101561253d5760405163022c0d9f60e01b8152600060048201819052602482018890523060448301526080606483015260848201526001600160a01b0384169063022c0d9f9060a401600060405180830381600087803b15801561252057600080fd5b505af1158015612534573d6000803e3d6000fd5b505050506125b3565b60405163022c0d9f60e01b8152600481018790526000602482018190523060448301526080606483015260848201526001600160a01b0384169063022c0d9f9060a401600060405180830381600087803b15801561259a57600080fd5b505af11580156125ae573d6000803e3d6000fd5b505050505b6125c5896001600160a01b0316611662565b1561269e576006546040516370a0823160e01b81523060048201526001600160a01b0390911690632e1a7d4d9082906370a082319060240160206040518083038186803b15801561261557600080fd5b505afa158015612629573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264d9190613847565b6040518263ffffffff1660e01b815260040161266b91815260200190565b600060405180830381600087803b15801561268557600080fd5b505af1158015612699573d6000803e3d6000fd5b505050505b5050505050949350505050565b60006126c485856126be8989888861223f565b8561223f565b9695505050505050565b8015806127575750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561271d57600080fd5b505afa158015612731573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127559190613847565b155b6127c25760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610831565b6040516001600160a01b03831660248201526044810182905261137f90849063095ea7b360e01b90606401611ed5565b606061280184846000856129a4565b949350505050565b60008080806128216001600160a01b03881689611a39565b905060006128386001600160a01b0388168a611a39565b90506000808a6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561287657600080fd5b505afa15801561288a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ae919061392a565b5091509150886001600160a01b03168a6001600160a01b031611156128cf57905b816001600160701b03168410806128ee5750806001600160701b031683105b9550851580156129185750816001600160701b03168411806129185750806001600160701b031683115b94506000612928896103e561379d565b9050600061293f85846001600160701b0316612a74565b612949908361379d565b905060008261296188876001600160701b0316612a74565b61296d906103e861379d565b6129779190613232565b9050801561298e5761298981836137d2565b612991565b60005b9950505050505050509450945094915050565b606082471015612a055760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610831565b600080866001600160a01b03168587604051612a2191906138b8565b60006040518083038185875af1925050503d8060008114612a5e576040519150601f19603f3d011682016040523d82523d6000602084013e612a63565b606091505b5091509150610b3f87838387612a8a565b6000818310612a835781611a32565b5090919050565b60608315612af6578251612aef576001600160a01b0385163b612aef5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610831565b5081612801565b6128018383815115612b0b5781518083602001fd5b8060405162461bcd60e51b8152600401610831919061396f565b6001600160a01b03811681146115e957600080fd5b8035612b4581612b25565b919050565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff81118282101715612b8657612b86612b4a565b6040525050565b6040516101a0810167ffffffffffffffff81118282101715612bb157612bb1612b4a565b60405290565b600067ffffffffffffffff821115612bd157612bd1612b4a565b5060051b60200190565b600082601f830112612bec57600080fd5b81356020612bf982612bb7565b604051612c068282612b60565b83815260059390931b8501820192828101915086841115612c2657600080fd5b8286015b84811015612c415780358352918301918301612c2a565b509695505050505050565b600080600080600080600060e0888a031215612c6757600080fd5b8735612c7281612b25565b96506020880135612c8281612b25565b955060408801359450606088013593506080880135925060a0880135612ca781612b25565b915060c088013567ffffffffffffffff811115612cc357600080fd5b612ccf8a828b01612bdb565b91505092959891949750929550565b600060208284031215612cf057600080fd5b5035919050565b600060208284031215612d0957600080fd5b8135611a3281612b25565b60008060008060808587031215612d2a57600080fd5b8435612d3581612b25565b93506020850135612d4581612b25565b93969395505050506040820135916060013590565b6000604082018483526020604081850152818551808452606086019150828701935060005b81811015612d9b57845183529383019391830191600101612d7f565b5090979650505050505050565b600067ffffffffffffffff821115612dc257612dc2612b4a565b50601f01601f191660200190565b600082601f830112612de157600080fd5b8135612dec81612da8565b604051612df98282612b60565b828152856020848701011115612e0e57600080fd5b82602086016020830137600092810160200192909252509392505050565b60008060008060008060c08789031215612e4557600080fd5b863561ffff81168114612e5757600080fd5b9550602087013567ffffffffffffffff80821115612e7457600080fd5b612e808a838b01612dd0565b96506040890135955060608901359150612e9982612b25565b9093506080880135925060a08801359080821115612eb657600080fd5b50612ec389828a01612dd0565b9150509295509295509295565b60008060008060008060c08789031215612ee957600080fd5b8635612ef481612b25565b95506020870135612f0481612b25565b945060408701359350606087013592506080870135612f2281612b25565b915060a087013567ffffffffffffffff811115612f3e57600080fd5b612ec389828a01612dd0565b600481106115e957600080fd5b8035612b4581612f4a565b600080600060608486031215612f7757600080fd5b833567ffffffffffffffff80821115612f8f57600080fd5b908501906101a08288031215612fa457600080fd5b612fac612b8d565b8235815260208301356020820152612fc660408401612b3a565b6040820152612fd760608401612b3a565b6060820152612fe860808401612b3a565b6080820152612ff960a08401612b3a565b60a082015260c083013560c082015260e083013560e0820152610100808401358183015250610120808401358183015250610140613038818501612f57565b90820152610160838101358381111561305057600080fd5b61305c8a828701612bdb565b828401525050610180808401358381111561307657600080fd5b6130828a828701612dd0565b828401525050809550505050602084013591506130a160408501612b3a565b90509250925092565b6000806000606084860312156130bf57600080fd5b8335925060208401356130d181612b25565b929592945050506040919091013590565b600060208083850312156130f557600080fd5b823567ffffffffffffffff81111561310c57600080fd5b8301601f8101851361311d57600080fd5b803561312881612bb7565b6040516131358282612b60565b82815260059290921b830184019184810191508783111561315557600080fd5b928401925b82841015610b3f57833561316d81612b25565b8252928401929084019061315a565b60008060006060848603121561319157600080fd5b833561319c81612b25565b92506020840135915060408401356131b381612b25565b809150509250925092565b60208082526028908201527f69742773206e6f7420616c6c6f77656420746f2073776170207769746820736160408201526736b2903a37b5b2b760c11b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082198211156132455761324561321c565b500190565b600060001982141561325e5761325e61321c565b5060010190565b6000828210156132775761327761321c565b500390565b6001600160a01b03978816815295871660208701529386166040860152919094166060840152608083019390935260a082019290925260c081019190915260e00190565b600082601f8301126132d157600080fd5b815160206132de82612bb7565b6040516132eb8282612b60565b83815260059390931b850182019282810191508684111561330b57600080fd5b8286015b84811015612c41578051835291830191830161330f565b6000806040838503121561333957600080fd5b82519150602083015167ffffffffffffffff81111561335757600080fd5b613363858286016132c0565b9150509250929050565b8051612b4581612b25565b8051612b4581612f4a565b60005b8381101561339e578181015183820152602001613386565b838111156113e75750506000910152565b600082601f8301126133c057600080fd5b81516133cb81612da8565b6040516133d88282612b60565b8281528560208487010111156133ed57600080fd5b611f1a836020830160208801613383565b60006020828403121561341057600080fd5b815167ffffffffffffffff8082111561342857600080fd5b908301906101a0828603121561343d57600080fd5b613445612b8d565b825181526020830151602082015261345f6040840161336d565b60408201526134706060840161336d565b60608201526134816080840161336d565b608082015261349260a0840161336d565b60a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015181830152506101406134d1818501613378565b9082015261016083810151838111156134e957600080fd5b6134f5888287016132c0565b828401525050610180808401518381111561350f57600080fd5b61351b888287016133af565b918301919091525095945050505050565b634e487b7160e01b600052602160045260246000fd5b600481106115e957634e487b7160e01b600052602160045260246000fd5b61356981613542565b9052565b600081518084526020808501945080840160005b8381101561359d57815187529582019590820190600101613581565b509495945050505050565b600081518084526135c0816020860160208601613383565b601f01601f19169290920160200192915050565b6060815283516060820152602084015160808201526000604085015161360560a08401826001600160a01b03169052565b5060608501516001600160a01b03811660c08401525060808501516001600160a01b03811660e08401525060a085015161010061364c818501836001600160a01b03169052565b60c08701516101208581019190915260e08801516101408087019190915291880151610160808701919091529088015161018080870191909152918801519250906101a061369c81870185613560565b828901519350806101c0870152506136b861020086018461356d565b90880151858203605f19016101e087015290925090506136d882826135a8565b9250505083602083015261280160408301846001600160a01b03169052565b600060033d11156137105760046000803e5060005160e01c5b90565b600060443d10156137215790565b6040516003193d81016004833e81513d67ffffffffffffffff816024840111818411171561375157505050505090565b82850191508151818111156137695750505050505090565b843d87010160208285010111156137835750505050505090565b61379260208286010187612b60565b509095945050505050565b60008160001904831182151516156137b7576137b761321c565b500290565b634e487b7160e01b600052601260045260246000fd5b6000826137e1576137e16137bc565b500490565b6020808252825182820181905260009190848201906040850190845b818110156138275783516001600160a01b031683529284019291840191600101613802565b50909695505050505050565b600082613842576138426137bc565b500690565b60006020828403121561385957600080fd5b5051919050565b888152602081018890526001600160a01b03878116604083015286811660608301528516608082015260a0810184905260c0810183905261010081016138a583613542565b8260e08301529998505050505050505050565b600082516138ca818460208701613383565b9190910192915050565b6000602082840312156138e657600080fd5b81518015158114611a3257600080fd5b60006020828403121561390857600080fd5b8151611a3281612b25565b80516001600160701b0381168114612b4557600080fd5b60008060006060848603121561393f57600080fd5b61394884613913565b925061395660208501613913565b9150604084015163ffffffff811681146131b357600080fd5b602081526000611a3260208301846135a856fea2646970667358221220f1d42498b1ed639222db51ee2a13d999a8b7518588b7ff7a008ce9ab51b4262064736f6c63430008090033000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000008731d54e9d02c286767d56ac03e8037c07e01e98000000000000000000000000216b4b4ba9f3e719726886d34a177484278bfcae000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee570000000000000000000000007ace1d4bb90d19826a88875ba0f60bd783bef31200000000000000000000000000000000000000000000000000000000000000030000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac000000000000000000000000115934131916c8b277dd010ee02de363c09d037c00000000000000000000000000000000000000000000000000000000000000020000000000000000000000006b4aafe0a2c03b223b73a681b544b1617a976ccb000000000000000000000000410f724847c92bc3cdacbcd4922f1d7833ec280a

Deployed Bytecode

0x60806040526004361061025c5760003560e01c806390f3f20811610144578063bbe8caa2116100b6578063e5932c401161007a578063e5932c4014610707578063e8984c5f14610727578063ea15afc314610747578063ecefc70514610767578063f2fde38b1461077d578063f640d5081461079d5761025c565b8063bbe8caa214610669578063c415b95c1461067c578063ca1ab6041461069c578063d6821ed8146106bc578063e37c4250146106f15761025c565b8063ab30469511610108578063ab304695146105b3578063ab8236f3146105c9578063ae551c66146105e9578063b4c76fe014610609578063b58468cf14610629578063b9d52d3c146106495761025c565b806390f3f2081461051d578063a42dce8014610533578063a734f06e14610553578063a85f329814610573578063a9e56f3c146105935761025c565b806348c4d781116101dd5780635b769f3c116101a15780635b769f3c146104665780636076a0b414610486578063672383c4146104b4578063715018a6146104d45780638c821e90146104e95780638da5cb5b146104ff5761025c565b806348c4d781146103c657806351b78b47146103e6578063538ba4f91461040657806353fd7bf1146104265780635b18075e146104465761025c565b80633aecd0e3116102245780633aecd0e3146103305780633fc8cef314610350578063433b3c05146103705780634399fa5614610390578063458f9723146103b05761025c565b8063081a54001461026b57806312e4a6d914610297578063228cb733146102b857806323a9495e146102f057806331428a8714610310575b3332141561026957600080fd5b005b34801561027757600080fd5b50610280600181565b60405160ff90911681526020015b60405180910390f35b6102aa6102a5366004612c4c565b6107bd565b60405190815260200161028e565b3480156102c457600080fd5b50600c546102d8906001600160a01b031681565b6040516001600160a01b03909116815260200161028e565b3480156102fc57600080fd5b5061026961030b366004612cde565b610b4a565b34801561031c57600080fd5b50600a546102d8906001600160a01b031681565b34801561033c57600080fd5b506102aa61034b366004612cf7565b610b8e565b34801561035c57600080fd5b506006546102d8906001600160a01b031681565b34801561037c57600080fd5b506007546102d8906001600160a01b031681565b34801561039c57600080fd5b50600b546102d8906001600160a01b031681565b3480156103bc57600080fd5b506102aa60115481565b3480156103d257600080fd5b506102696103e1366004612cde565b610bb1565b3480156103f257600080fd5b50610269610401366004612cf7565b610c2c565b34801561041257600080fd5b506002546102d8906001600160a01b031681565b34801561043257600080fd5b50610269610441366004612cf7565b610c82565b34801561045257600080fd5b50600d546102d8906001600160a01b031681565b34801561047257600080fd5b50610269610481366004612cf7565b610cd8565b34801561049257600080fd5b506104a66104a1366004612d14565b610d2e565b60405161028e929190612d5a565b3480156104c057600080fd5b506102d86104cf366004612cde565b610dd7565b3480156104e057600080fd5b50610269610e01565b3480156104f557600080fd5b506102aa60045481565b34801561050b57600080fd5b506000546001600160a01b03166102d8565b34801561052957600080fd5b506102aa60055481565b34801561053f57600080fd5b5061026961054e366004612cf7565b610e15565b34801561055f57600080fd5b506001546102d8906001600160a01b031681565b34801561057f57600080fd5b5061026961058e366004612cde565b610e6b565b34801561059f57600080fd5b506012546102d8906001600160a01b031681565b3480156105bf57600080fd5b506102aa60035481565b3480156105d557600080fd5b506102696105e4366004612e2c565b610ea8565b3480156105f557600080fd5b50600e546102d8906001600160a01b031681565b34801561061557600080fd5b50610269610624366004612cf7565b611130565b34801561063557600080fd5b50610269610644366004612cde565b611186565b34801561065557600080fd5b50610269610664366004612cf7565b6111c3565b610269610677366004612ed0565b611219565b34801561068857600080fd5b50600f546102d8906001600160a01b031681565b3480156106a857600080fd5b506102696106b7366004612f62565b6112ec565b3480156106c857600080fd5b506106dc6106d73660046130aa565b6113ed565b6040805192835260208301919091520161028e565b3480156106fd57600080fd5b506102aa60105481565b34801561071357600080fd5b50610269610722366004612cf7565b61141d565b34801561073357600080fd5b50610269610742366004612cf7565b611473565b34801561075357600080fd5b506102696107623660046130e2565b6114c9565b34801561077357600080fd5b506102aa61271081565b34801561078957600080fd5b50610269610798366004612cf7565b611573565b3480156107a957600080fd5b506102696107b836600461317c565b6115ec565b60006107c7611608565b8385101561083a5760405162461bcd60e51b815260206004820152603560248201527f657870656374656452657475726e206d75737420626520657175616c206f72206044820152743630b933b2b9103a3430b71036b4b72932ba3ab93760591b60648201526084015b60405180910390fd5b866001600160a01b0316886001600160a01b0316141561086c5760405162461bcd60e51b8152600401610831906131be565b60008060005b84518110156108da57600085828151811061088f5761088f613206565b602002602001015111156108c8578481815181106108af576108af613206565b6020026020010151836108c29190613232565b92508091505b806108d28161324a565b915050610872565b5081610938576108f28a6001600160a01b0316611662565b1561092e5760405133903480156108fc02916000818181858888f19350505050158015610923573d6000803e3d6000fd5b503492505050610b35565b8792505050610b35565b61094d6001600160a01b038b1633308b61169b565b61095b848984848e8e61178d565b92508215610ad457858310156109bf5760405162461bcd60e51b8152602060048201526024808201527f5377697463683a2052657475726e20616d6f756e7420776173206e6f7420656e6044820152630deeaced60e31b6064820152608401610831565b86831115610a82576109db6001600160a01b038a1686896119bd565b50600c54610a07906001600160a01b03166109f68986613265565b6001600160a01b038c1691906119bd565b50600b546001600160a01b031663391fdc2433878d8d8d8d610a29818c613265565b6040518863ffffffff1660e01b8152600401610a4b979695949392919061327c565b600060405180830381600087803b158015610a6557600080fd5b505af1158015610a79573d6000803e3d6000fd5b50505050610b32565b610a966001600160a01b038a1686856119bd565b50600b54604051630e47f70960e21b81526001600160a01b039091169063391fdc2490610a4b90339089908f908f908f908b9060009060040161327c565b87610ae86001600160a01b038c1630611a39565b1115610b0857610b026001600160a01b038b16338a6119bd565b50610b32565b610b3033610b1f6001600160a01b038d1630611a39565b6001600160a01b038d1691906119bd565b505b50505b610b3f6001600955565b979650505050505050565b610b52611ad3565b60058190556040518181527f11e8ee12d79dc7314b845f4e82465af5bd3d2214081526061af36de8364eaa2e906020015b60405180910390a150565b6000610b98611ad3565b610bab6001600160a01b03831630611a39565b92915050565b610bb9611ad3565b611388811115610bf75760405162461bcd60e51b8152602060048201526009602482015268746f6f206c6172676560b81b6044820152606401610831565b60108190556040518181527fa28aac6f4ba79029a647ee085b0ae88419c6aa87bae5dcf77d303dba45b3681b90602001610b83565b610c34611ad3565b601280546001600160a01b0319166001600160a01b0383169081179091556040519081527f806d08432293677cc7e3e0f9443dcf0459f82567573d5094da6e9e6129dea4ab90602001610b83565b610c8a611ad3565b600b80546001600160a01b0319166001600160a01b0383169081179091556040519081527f35e63b7fefc2b1fb2ed78adeed6688b187514d96c2d7d56222e52f3e41c2fb2f90602001610b83565b610ce0611ad3565b600680546001600160a01b0319166001600160a01b0383169081179091556040519081527f41408be49f75701fe4bb8484ce88d68f1d82e03cb4eb44263b6682ce2dbd32f090602001610b83565b600a5460405163181da82d60e21b81526001600160a01b03868116600483015285811660248301526044820185905260648201849052600092606092911690636076a0b49060840160006040518083038186803b158015610d8e57600080fd5b505afa158015610da2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610dca9190810190613326565b9097909650945050505050565b60088181548110610de757600080fd5b6000918252602090912001546001600160a01b0316905081565b610e09611ad3565b610e136000611b2d565b565b610e1d611ad3565b600f80546001600160a01b0319166001600160a01b0383169081179091556040519081527f12e1d17016b94668449f97876f4a8d5cc2c19f314db337418894734037cc19d490602001610b83565b610e73611ad3565b60048190556040518181527f70f24e12a9db25e0d80cbcde19ffef47d6a7c52c1089db4c71e53ce1856577fc90602001610b83565b6012546001600160a01b03163314610f025760405162461bcd60e51b815260206004820152601d60248201527f63616c6c6572206973206e6f7420737461726761746520726f757465720000006044820152606401610831565b600081806020019051810190610f1891906133fe565b905080606001516001600160a01b0316846001600160a01b031614610fb85760405162461bcd60e51b815260206004820152604a60248201527f6272696467656420746f6b656e206d757374206265207468652073616d65206160448201527f732074686520666972737420746f6b656e20696e2064657374696e6174696f6e606482015269040e6eec2e040e0c2e8d60b31b608482015260a401610831565b620186a0805a1015610fe857610fd3858360a0015186611b7d565b610fe1828560006002611bde565b5050611128565b6000815a610ff69190613265565b905082608001516001600160a01b031683606001516001600160a01b0316141561103f5761102d83606001518460a0015187611b7d565b61103a8386876001611bde565b611124565b604051633286ad8160e21b8152309063ca1ab6049083906110689087908a908c906004016135d4565b600060405180830381600088803b15801561108257600080fd5b5087f193505050508015611094575060015b611124576110a06136f7565b806308c379a014156110e357506110b5613713565b806110c057506110e5565b6110cf878560a0015188611b7d565b6110dd848760006002611bde565b50611124565b505b3d80801561110f576040519150601f19603f3d011682016040523d82523d6000602084013e611114565b606091505b506110cf878560a0015188611b7d565b5050505b505050505050565b611138611ad3565b600780546001600160a01b0319166001600160a01b0383169081179091556040519081527f17780f3919f73af11f29e4157534858a06c91294d64b679fe4e49340122cd32290602001610b83565b61118e611ad3565b60118190556040518181527f25677c92398d23f2071292abdbfc08a652d124b76716d2cee83f7f2fe2fbe1e290602001610b83565b6111cb611ad3565b600e80546001600160a01b0319166001600160a01b0383169081179091556040519081527fe0209b1ff5892dc27d9ffb30000e308317645f928d78a0a018dd2e9289ecc29290602001610b83565b611221611608565b846001600160a01b0316866001600160a01b031614156112535760405162461bcd60e51b8152600401610831906131be565b6112686001600160a01b03871633308761169b565b611273868583611c68565b600b54604051630e47f70960e21b81526001600160a01b039091169063391fdc24906112b090339086908b908b908b908b9060009060040161327c565b600060405180830381600087803b1580156112ca57600080fd5b505af11580156112de573d6000803e3d6000fd5b505050506111286001600955565b600283610140015160038111156113055761130561352c565b14806113275750600383610140015160038111156113255761132561352c565b145b15611384578260e0015182106113845761134b818460e00151856101800151611c68565b611369818460a001518560e00151856113649190613265565b611b7d565b61137f838460e001518561010001516001611bde565b505050565b60006113908484611dac565b90508361012001518110156113e75760405162461bcd60e51b815260206004820152601c60248201527f72657475726e20616d6f756e7420776173206e6f7420656e6f756768000000006044820152606401610831565b50505050565b6000806127106113fd868561379d565b61140791906137d2565b91506114138286613265565b9050935093915050565b611425611ad3565b600c80546001600160a01b0319166001600160a01b0383169081179091556040519081527f53a596d7be747a5a4f4d39a6a36476d2eed407c93f6f2ba8a96c8b971240d5cd90602001610b83565b61147b611ad3565b600d80546001600160a01b0319166001600160a01b0383169081179091556040519081527f4528d04696417deba6006cd6c7e5bbb56b9874ac9d954a956e14b8d74f08d72b90602001610b83565b6114d1611ad3565b805160035560005b81518110156115435760088282815181106114f6576114f6613206565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b039092169190911790558061153b8161324a565b9150506114d9565b507fbbc63a7f378af7e269ef19f3fe0d08f044c91ee72930c0d045a58be58580f3d381604051610b8391906137e6565b61157b611ad3565b6001600160a01b0381166115e05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610831565b6115e981611b2d565b50565b6115f4611ad3565b6113e76001600160a01b03841682846119bd565b6002600954141561165b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610831565b6002600955565b60006001600160a01b0382161580610bab57506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1492915050565b806116a5576113e7565b6116ae84611662565b15611778576001600160a01b038316331480156116cb5750803410155b61172b5760405162461bcd60e51b815260206004820152602b60248201527f57726f6e6720757365616765206f66204554482e756e6976657273616c54726160448201526a6e7366657246726f6d282960a81b6064820152608401610831565b6001600160a01b0382163014611773576040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015611771573d6000803e3d6000fd5b505b6113e7565b6113e76001600160a01b038516848484611ea1565b600060045460035461179f919061379d565b8751111561181f5760405162461bcd60e51b815260206004820152604160248201527f5377697463683a20446973747269627574696f6e2061727261792073686f756c60448201527f64206e6f742065786365656420666163746f726965732061727261792073697a6064820152606560f81b608482015260a401610831565b856000805b89518110156119b05789818151811061183f5761183f613206565b6020026020010151600014156118545761199e565b6000888b838151811061186957611869613206565b60200260200101518b61187c919061379d565b61188691906137d2565b9050878214156118935750825b61189d8185613265565b9350600454826118ad9190613833565b6118f8576118f18787836008600454876118c791906137d2565b815481106118d7576118d7613206565b6000918252602090912001546001600160a01b0316611f0c565b9250611990565b6004546119059083613833565b6001141561194d576118f187878360086004548761192391906137d2565b8154811061193357611933613206565b6000918252602090912001546001600160a01b0316611f23565b61198d87878360086004548761196391906137d2565b8154811061197357611973613206565b6000918252602090912001546001600160a01b0316611f40565b92505b61199a8386613232565b9450505b806119a88161324a565b915050611824565b5050509695505050505050565b6000816119cc57506001611a32565b6119d584611662565b15611a1a576040516001600160a01b0384169083156108fc029084906000818181858888f19350505050158015611a10573d6000803e3d6000fd5b5060019050611a32565b611a2e6001600160a01b0385168484611f5d565b5060015b9392505050565b6000611a4483611662565b15611a5a57506001600160a01b03811631610bab565b6040516370a0823160e01b81526001600160a01b0383811660048301528416906370a082319060240160206040518083038186803b158015611a9b57600080fd5b505afa158015611aaf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a329190613847565b6000546001600160a01b03163314610e135760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610831565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611b8f836001600160a01b0316611662565b15611bca576040516001600160a01b0383169082156108fc029083906000818181858888f193505050501580156113e7573d6000803e3d6000fd5b6113e76001600160a01b03841683836119bd565b600b548451602086015160a08701516060880151608089015160405163424971a960e11b81526001600160a01b0390961695638492e35295611c309590949093909290918b908b908b90600401613860565b600060405180830381600087803b158015611c4a57600080fd5b505af1158015611c5e573d6000803e3d6000fd5b5050505050505050565b6000611c7c846001600160a01b0316611662565b15611cd85782471015611cd15760405162461bcd60e51b815260206004820152601b60248201527f4554482062616c616e636520697320696e73756666696369656e7400000000006044820152606401610831565b5081611cf2565b600d54611cf2906001600160a01b03868116911685611f8d565b600e546040516000916001600160a01b0316908390611d129086906138b8565b60006040518083038185875af1925050503d8060008114611d4f576040519150601f19603f3d011682016040523d82523d6000602084013e611d54565b606091505b5050905080611da55760405162461bcd60e51b815260206004820152601960248201527f506172617377617020657865637574696f6e206661696c6564000000000000006044820152606401610831565b5050505050565b600060018180805b86610160015151811015611e2b5760008761016001518281518110611ddb57611ddb613206565b60200260200101511115611e19578661016001518181518110611e0057611e00613206565b602002602001015183611e139190613232565b92508091505b80611e238161324a565b915050611db4565b5060008211611e7c5760405162461bcd60e51b815260206004820152601a60248201527f696e76616c696420646973747269627574696f6e20706172616d0000000000006044820152606401610831565b611e8885838389612068565b94509250611e9886868686611bde565b50505092915050565b6040516001600160a01b03808516602483015283166044820152606481018290526113e79085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261216d565b6000611f1a8585858561223f565b95945050505050565b600654600090611f1a9086906001600160a01b03168686866126ab565b600754600090611f1a9086906001600160a01b03168686866126ab565b6040516001600160a01b03831660248201526044810182905261137f90849063a9059cbb60e01b90606401611ed5565b611f9683611662565b61137f5780611fb45761137f6001600160a01b0384168360006126ce565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e9060440160206040518083038186803b158015611fff57600080fd5b505afa158015612013573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120379190613847565b90508015612054576120546001600160a01b0385168460006126ce565b6113e76001600160a01b03851684846126ce565b6000806120868361016001518787878760600151886080015161178d565b90508015612135576120b48360a001518285608001516001600160a01b03166119bd9092919063ffffffff16565b50600b5460608401516080850151604051630e47f70960e21b8152600195506001600160a01b039093169263391fdc24926120fe923392309291908d90899060009060040161327c565b600060405180830381600087803b15801561211857600080fd5b505af115801561212c573d6000803e3d6000fd5b50505050612164565b61215b8360a001518785606001516001600160a01b03166119bd9092919063ffffffff16565b50859050600391505b94509492505050565b60006121c2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166127f29092919063ffffffff16565b80519091501561137f57808060200190518101906121e091906138d4565b61137f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610831565b6000612253856001600160a01b0316611662565b156122c257600660009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156122a857600080fd5b505af11580156122bc573d6000803e3d6000fd5b50505050505b60006122d6866001600160a01b0316611662565b6122e057856122ed565b6006546001600160a01b03165b90506000612303866001600160a01b0316611662565b61230d578561231a565b6006546001600160a01b03165b60405163e6a4390560e01b81526001600160a01b038481166004830152808316602483015291925060009186169063e6a439059060440160206040518083038186803b15801561236957600080fd5b505afa15801561237d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123a191906138f6565b90506000806123bb6001600160a01b03841686868b612809565b91975092509050811561242057826001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561240357600080fd5b505af1158015612417573d6000803e3d6000fd5b50505050612494565b80156124945760405163bc25cf7760e01b81527346fd07da395799f113a7584563b8cb886f33c2bc60048201526001600160a01b0384169063bc25cf7790602401600060405180830381600087803b15801561247b57600080fd5b505af115801561248f573d6000803e3d6000fd5b505050505b6124a86001600160a01b038616848a6119bd565b50836001600160a01b0316856001600160a01b0316101561253d5760405163022c0d9f60e01b8152600060048201819052602482018890523060448301526080606483015260848201526001600160a01b0384169063022c0d9f9060a401600060405180830381600087803b15801561252057600080fd5b505af1158015612534573d6000803e3d6000fd5b505050506125b3565b60405163022c0d9f60e01b8152600481018790526000602482018190523060448301526080606483015260848201526001600160a01b0384169063022c0d9f9060a401600060405180830381600087803b15801561259a57600080fd5b505af11580156125ae573d6000803e3d6000fd5b505050505b6125c5896001600160a01b0316611662565b1561269e576006546040516370a0823160e01b81523060048201526001600160a01b0390911690632e1a7d4d9082906370a082319060240160206040518083038186803b15801561261557600080fd5b505afa158015612629573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061264d9190613847565b6040518263ffffffff1660e01b815260040161266b91815260200190565b600060405180830381600087803b15801561268557600080fd5b505af1158015612699573d6000803e3d6000fd5b505050505b5050505050949350505050565b60006126c485856126be8989888861223f565b8561223f565b9695505050505050565b8015806127575750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561271d57600080fd5b505afa158015612731573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127559190613847565b155b6127c25760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610831565b6040516001600160a01b03831660248201526044810182905261137f90849063095ea7b360e01b90606401611ed5565b606061280184846000856129a4565b949350505050565b60008080806128216001600160a01b03881689611a39565b905060006128386001600160a01b0388168a611a39565b90506000808a6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561287657600080fd5b505afa15801561288a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ae919061392a565b5091509150886001600160a01b03168a6001600160a01b031611156128cf57905b816001600160701b03168410806128ee5750806001600160701b031683105b9550851580156129185750816001600160701b03168411806129185750806001600160701b031683115b94506000612928896103e561379d565b9050600061293f85846001600160701b0316612a74565b612949908361379d565b905060008261296188876001600160701b0316612a74565b61296d906103e861379d565b6129779190613232565b9050801561298e5761298981836137d2565b612991565b60005b9950505050505050509450945094915050565b606082471015612a055760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610831565b600080866001600160a01b03168587604051612a2191906138b8565b60006040518083038185875af1925050503d8060008114612a5e576040519150601f19603f3d011682016040523d82523d6000602084013e612a63565b606091505b5091509150610b3f87838387612a8a565b6000818310612a835781611a32565b5090919050565b60608315612af6578251612aef576001600160a01b0385163b612aef5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610831565b5081612801565b6128018383815115612b0b5781518083602001fd5b8060405162461bcd60e51b8152600401610831919061396f565b6001600160a01b03811681146115e957600080fd5b8035612b4581612b25565b919050565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff81118282101715612b8657612b86612b4a565b6040525050565b6040516101a0810167ffffffffffffffff81118282101715612bb157612bb1612b4a565b60405290565b600067ffffffffffffffff821115612bd157612bd1612b4a565b5060051b60200190565b600082601f830112612bec57600080fd5b81356020612bf982612bb7565b604051612c068282612b60565b83815260059390931b8501820192828101915086841115612c2657600080fd5b8286015b84811015612c415780358352918301918301612c2a565b509695505050505050565b600080600080600080600060e0888a031215612c6757600080fd5b8735612c7281612b25565b96506020880135612c8281612b25565b955060408801359450606088013593506080880135925060a0880135612ca781612b25565b915060c088013567ffffffffffffffff811115612cc357600080fd5b612ccf8a828b01612bdb565b91505092959891949750929550565b600060208284031215612cf057600080fd5b5035919050565b600060208284031215612d0957600080fd5b8135611a3281612b25565b60008060008060808587031215612d2a57600080fd5b8435612d3581612b25565b93506020850135612d4581612b25565b93969395505050506040820135916060013590565b6000604082018483526020604081850152818551808452606086019150828701935060005b81811015612d9b57845183529383019391830191600101612d7f565b5090979650505050505050565b600067ffffffffffffffff821115612dc257612dc2612b4a565b50601f01601f191660200190565b600082601f830112612de157600080fd5b8135612dec81612da8565b604051612df98282612b60565b828152856020848701011115612e0e57600080fd5b82602086016020830137600092810160200192909252509392505050565b60008060008060008060c08789031215612e4557600080fd5b863561ffff81168114612e5757600080fd5b9550602087013567ffffffffffffffff80821115612e7457600080fd5b612e808a838b01612dd0565b96506040890135955060608901359150612e9982612b25565b9093506080880135925060a08801359080821115612eb657600080fd5b50612ec389828a01612dd0565b9150509295509295509295565b60008060008060008060c08789031215612ee957600080fd5b8635612ef481612b25565b95506020870135612f0481612b25565b945060408701359350606087013592506080870135612f2281612b25565b915060a087013567ffffffffffffffff811115612f3e57600080fd5b612ec389828a01612dd0565b600481106115e957600080fd5b8035612b4581612f4a565b600080600060608486031215612f7757600080fd5b833567ffffffffffffffff80821115612f8f57600080fd5b908501906101a08288031215612fa457600080fd5b612fac612b8d565b8235815260208301356020820152612fc660408401612b3a565b6040820152612fd760608401612b3a565b6060820152612fe860808401612b3a565b6080820152612ff960a08401612b3a565b60a082015260c083013560c082015260e083013560e0820152610100808401358183015250610120808401358183015250610140613038818501612f57565b90820152610160838101358381111561305057600080fd5b61305c8a828701612bdb565b828401525050610180808401358381111561307657600080fd5b6130828a828701612dd0565b828401525050809550505050602084013591506130a160408501612b3a565b90509250925092565b6000806000606084860312156130bf57600080fd5b8335925060208401356130d181612b25565b929592945050506040919091013590565b600060208083850312156130f557600080fd5b823567ffffffffffffffff81111561310c57600080fd5b8301601f8101851361311d57600080fd5b803561312881612bb7565b6040516131358282612b60565b82815260059290921b830184019184810191508783111561315557600080fd5b928401925b82841015610b3f57833561316d81612b25565b8252928401929084019061315a565b60008060006060848603121561319157600080fd5b833561319c81612b25565b92506020840135915060408401356131b381612b25565b809150509250925092565b60208082526028908201527f69742773206e6f7420616c6c6f77656420746f2073776170207769746820736160408201526736b2903a37b5b2b760c11b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082198211156132455761324561321c565b500190565b600060001982141561325e5761325e61321c565b5060010190565b6000828210156132775761327761321c565b500390565b6001600160a01b03978816815295871660208701529386166040860152919094166060840152608083019390935260a082019290925260c081019190915260e00190565b600082601f8301126132d157600080fd5b815160206132de82612bb7565b6040516132eb8282612b60565b83815260059390931b850182019282810191508684111561330b57600080fd5b8286015b84811015612c41578051835291830191830161330f565b6000806040838503121561333957600080fd5b82519150602083015167ffffffffffffffff81111561335757600080fd5b613363858286016132c0565b9150509250929050565b8051612b4581612b25565b8051612b4581612f4a565b60005b8381101561339e578181015183820152602001613386565b838111156113e75750506000910152565b600082601f8301126133c057600080fd5b81516133cb81612da8565b6040516133d88282612b60565b8281528560208487010111156133ed57600080fd5b611f1a836020830160208801613383565b60006020828403121561341057600080fd5b815167ffffffffffffffff8082111561342857600080fd5b908301906101a0828603121561343d57600080fd5b613445612b8d565b825181526020830151602082015261345f6040840161336d565b60408201526134706060840161336d565b60608201526134816080840161336d565b608082015261349260a0840161336d565b60a082015260c083015160c082015260e083015160e08201526101008084015181830152506101208084015181830152506101406134d1818501613378565b9082015261016083810151838111156134e957600080fd5b6134f5888287016132c0565b828401525050610180808401518381111561350f57600080fd5b61351b888287016133af565b918301919091525095945050505050565b634e487b7160e01b600052602160045260246000fd5b600481106115e957634e487b7160e01b600052602160045260246000fd5b61356981613542565b9052565b600081518084526020808501945080840160005b8381101561359d57815187529582019590820190600101613581565b509495945050505050565b600081518084526135c0816020860160208601613383565b601f01601f19169290920160200192915050565b6060815283516060820152602084015160808201526000604085015161360560a08401826001600160a01b03169052565b5060608501516001600160a01b03811660c08401525060808501516001600160a01b03811660e08401525060a085015161010061364c818501836001600160a01b03169052565b60c08701516101208581019190915260e08801516101408087019190915291880151610160808701919091529088015161018080870191909152918801519250906101a061369c81870185613560565b828901519350806101c0870152506136b861020086018461356d565b90880151858203605f19016101e087015290925090506136d882826135a8565b9250505083602083015261280160408301846001600160a01b03169052565b600060033d11156137105760046000803e5060005160e01c5b90565b600060443d10156137215790565b6040516003193d81016004833e81513d67ffffffffffffffff816024840111818411171561375157505050505090565b82850191508151818111156137695750505050505090565b843d87010160208285010111156137835750505050505090565b61379260208286010187612b60565b509095945050505050565b60008160001904831182151516156137b7576137b761321c565b500290565b634e487b7160e01b600052601260045260246000fd5b6000826137e1576137e16137bc565b500490565b6020808252825182820181905260009190848201906040850190845b818110156138275783516001600160a01b031683529284019291840191600101613802565b50909695505050505050565b600082613842576138426137bc565b500690565b60006020828403121561385957600080fd5b5051919050565b888152602081018890526001600160a01b03878116604083015286811660608301528516608082015260a0810184905260c0810183905261010081016138a583613542565b8260e08301529998505050505050505050565b600082516138ca818460208701613383565b9190910192915050565b6000602082840312156138e657600080fd5b81518015158114611a3257600080fd5b60006020828403121561390857600080fd5b8151611a3281612b25565b80516001600160701b0381168114612b4557600080fd5b60008060006060848603121561393f57600080fd5b61394884613913565b925061395660208501613913565b9150604084015163ffffffff811681146131b357600080fd5b602081526000611a3260208301846135a856fea2646970667358221220f1d42498b1ed639222db51ee2a13d999a8b7518588b7ff7a008ce9ab51b4262064736f6c63430008090033

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

000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000008731d54e9d02c286767d56ac03e8037c07e01e98000000000000000000000000216b4b4ba9f3e719726886d34a177484278bfcae000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee570000000000000000000000007ace1d4bb90d19826a88875ba0f60bd783bef31200000000000000000000000000000000000000000000000000000000000000030000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac000000000000000000000000115934131916c8b277dd010ee02de363c09d037c00000000000000000000000000000000000000000000000000000000000000020000000000000000000000006b4aafe0a2c03b223b73a681b544b1617a976ccb000000000000000000000000410f724847c92bc3cdacbcd4922f1d7833ec280a

-----Decoded View---------------
Arg [0] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [1] : _otherToken (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [2] : _pathCount (uint256): 2
Arg [3] : _pathSplit (uint256): 2
Arg [4] : _factories (address[]): 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f,0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac,0x115934131916C8b277DD010Ee02de363c09d037c
Arg [5] : _switchViewAndEventAddresses (address[]): 0x6B4AAFE0A2C03B223b73a681b544b1617A976CcB,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] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [5] : 00000000000000000000000000000000000000000000000000000000000001c0
Arg [6] : 0000000000000000000000008731d54e9d02c286767d56ac03e8037c07e01e98
Arg [7] : 000000000000000000000000216b4b4ba9f3e719726886d34a177484278bfcae
Arg [8] : 000000000000000000000000def171fe48cf0115b1d80b88dc8eab59176fee57
Arg [9] : 0000000000000000000000007ace1d4bb90d19826a88875ba0f60bd783bef312
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [11] : 0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
Arg [12] : 000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac
Arg [13] : 000000000000000000000000115934131916c8b277dd010ee02de363c09d037c
Arg [14] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [15] : 0000000000000000000000006b4aafe0a2c03b223b73a681b544b1617a976ccb
Arg [16] : 000000000000000000000000410f724847c92bc3cdacbcd4922f1d7833ec280a


Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
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.