ETH Price: $2,690.52 (-1.41%)

Contract

0x420a50A62b17C18b36C64478784536bA980feAc8
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Update Factories160469342022-11-25 12:14:47813 days ago1669378487IN
0x420a50A6...A980feAc8
0 ETH0.0013966210.92360429

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block
From
To
165443992023-02-02 23:30:23743 days ago1675380623
0x420a50A6...A980feAc8
0.29424626 ETH
165443992023-02-02 23:30:23743 days ago1675380623
0x420a50A6...A980feAc8
0.29424626 ETH
164783832023-01-24 18:12:47753 days ago1674583967
0x420a50A6...A980feAc8
0.32680005 ETH
164783832023-01-24 18:12:47753 days ago1674583967
0x420a50A6...A980feAc8
0.32680005 ETH
164379742023-01-19 2:49:23758 days ago1674096563
0x420a50A6...A980feAc8
0.27046773 ETH
164379742023-01-19 2:49:23758 days ago1674096563
0x420a50A6...A980feAc8
0.27046773 ETH
164221082023-01-16 21:42:35760 days ago1673905355
0x420a50A6...A980feAc8
0.06173755 ETH
164221082023-01-16 21:42:35760 days ago1673905355
0x420a50A6...A980feAc8
0.06173755 ETH
164123882023-01-15 13:05:35762 days ago1673787935
0x420a50A6...A980feAc8
0.28184077 ETH
164123882023-01-15 13:05:35762 days ago1673787935
0x420a50A6...A980feAc8
0.28184077 ETH
163791042023-01-10 21:29:35766 days ago1673386175
0x420a50A6...A980feAc8
0.12463445 ETH
163791042023-01-10 21:29:35766 days ago1673386175
0x420a50A6...A980feAc8
0.12463445 ETH
163412062023-01-05 14:32:23772 days ago1672929143
0x420a50A6...A980feAc8
0.28960827 ETH
163412062023-01-05 14:32:23772 days ago1672929143
0x420a50A6...A980feAc8
0.28960827 ETH
163299262023-01-04 0:45:23773 days ago1672793123
0x420a50A6...A980feAc8
0.75456694 ETH
163299262023-01-04 0:45:23773 days ago1672793123
0x420a50A6...A980feAc8
0.75456694 ETH
163077512022-12-31 22:32:11776 days ago1672525931
0x420a50A6...A980feAc8
0.17100038 ETH
163077512022-12-31 22:32:11776 days ago1672525931
0x420a50A6...A980feAc8
0.17100038 ETH
162662192022-12-26 3:23:47782 days ago1672025027
0x420a50A6...A980feAc8
2 ETH
162662192022-12-26 3:23:47782 days ago1672025027
0x420a50A6...A980feAc8
2 ETH
162206712022-12-19 18:55:35789 days ago1671476135
0x420a50A6...A980feAc8
0.33897364 ETH
162206712022-12-19 18:55:35789 days ago1671476135
0x420a50A6...A980feAc8
0.33897364 ETH
162035122022-12-17 9:26:35791 days ago1671269195
0x420a50A6...A980feAc8
1.88226666 ETH
162035122022-12-17 9:26:35791 days ago1671269195
0x420a50A6...A980feAc8
1.88226666 ETH
161774432022-12-13 18:04:11795 days ago1670954651
0x420a50A6...A980feAc8
0.34236362 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PoolFunctionality

Compiler Version
v0.7.4+commit.3f05b770

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 18 : PoolFunctionality.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

import "../interfaces/IERC20.sol";
import "../utils/fromOZ/SafeMath.sol";
import "../utils/fromOZ/SafeERC20.sol";
import "../utils/fromOZ/Ownable.sol";

import "../interfaces/IPoolFunctionality.sol";
import "../interfaces/IPoolSwapCallback.sol";
import "./SafeTransferHelper.sol";
import "../utils/orionpool/OrionMultiPoolLibrary.sol";
import "../utils/orionpool/periphery/interfaces/ICurvePool.sol";
import "./LibUnitConverter.sol";

contract PoolFunctionality is Ownable, IPoolFunctionality {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    address public immutable factory;
    address public immutable WETH;

    address[] public factories;

    mapping(address => FactoryType) public supportedFactories;

    event OrionPoolSwap(
        address sender,
        address st,
        address rt,
        uint256 st_r,
        uint256 st_a,
        uint256 rt_r,
        uint256 rt_a,
        address f
    );

    constructor(address _factory, FactoryType _type, address _WETH) {
        factory = _factory;
        WETH = _WETH;
        factories = [_factory];
        supportedFactories[_factory] = _type;
    }

    receive() external payable {
        assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract
    }

    function getWETH() external view override returns (address) {
        return WETH;
    }

    function getFactoriesLength() public view returns (uint256) {
        return factories.length;
    }

    function updateFactories(
        address[] calldata _factories,
        FactoryType[] calldata _types
    ) public onlyOwner {
        require(_factories.length > 0, "PoolFunctionality: FL");
        for (uint256 i = 0; i < factories.length; ++i) {
            supportedFactories[factories[i]] = FactoryType.UNSUPPORTED;
        }

        factories = _factories;

        for (uint256 i = 0; i < factories.length; i++) {
            supportedFactories[factories[i]] = _types[i];
        }
    }

    function isFactory(address a) external view override returns (bool) {
        return supportedFactories[a] != FactoryType.UNSUPPORTED;
    }

    function doSwapThroughOrionPool(
        address user,
        address to,
        IPoolFunctionality.SwapData calldata swapData
    ) external override returns (uint256 amountOut, uint256 amountIn) {
        bool withFactory = swapData.path.length > 2 &&
            (supportedFactories[swapData.path[0]] != FactoryType.UNSUPPORTED);
        address curFactory = withFactory ? swapData.path[0] : factory;
        address[] memory new_path;

        uint256 tokenIndex = withFactory ? 1 : 0;
        new_path = new address[](swapData.path.length - tokenIndex);

        for ((uint256 i, uint256 j) = (tokenIndex, 0); i < swapData.path.length; (++i, ++j)) {
            new_path[j] = swapData.path[i] == address(0) ? WETH : swapData.path[i];
        }

        (uint256 amount_spend_base_units, uint256 amount_receive_base_units) = (
            LibUnitConverter.decimalToBaseUnit(
                swapData.path[tokenIndex],
                swapData.amount_spend
            ),
            LibUnitConverter.decimalToBaseUnit(
                swapData.path[swapData.path.length - 1],
                swapData.amount_receive
            )
        );
        {
        (uint256 userAmountIn, uint256 userAmountOut) = _doSwapTokens(InternalSwapData(
            user,
            amount_spend_base_units,
            amount_receive_base_units,
            withFactory ? swapData.path[1] : swapData.path[0],
            new_path,
            swapData.is_exact_spend,
            to,
            curFactory,
            supportedFactories[curFactory],
            swapData.supportingFee
        ));

        //  Anyway user gave amounts[0] and received amounts[len-1]
        amountOut = LibUnitConverter.baseUnitToDecimal(
            swapData.path[tokenIndex],
            userAmountIn
        );
        amountIn = LibUnitConverter.baseUnitToDecimal(
            swapData.path[swapData.path.length - 1],
            userAmountOut
        );
        }
    }

    function convertFromWETH(address a) internal view returns (address) {
        return a == WETH ? address(0) : a;
    }

    function pairFor(
        address curFactory,
        address tokenA,
        address tokenB
    ) public view returns (address pair) {
        return OrionMultiPoolLibrary.pairFor(curFactory, tokenA, tokenB);
    }

    function _doSwapTokens(InternalSwapData memory swapData) internal returns (uint256 amountIn, uint256 amountOut) {
        bool isLastWETH = swapData.path[swapData.path.length - 1] == WETH;
        address toAuto = isLastWETH || swapData.curFactoryType == FactoryType.CURVE ? address(this) : swapData.to;
        uint256[] memory amounts;
        if (!swapData.supportingFee) {
            if (swapData.isExactIn) {
                amounts = OrionMultiPoolLibrary.getAmountsOut(
                    swapData.curFactory,
                    swapData.curFactoryType,
                    swapData.amountIn,
                    swapData.path
                );
                require(amounts[amounts.length - 1] >= swapData.amountOut, "PoolFunctionality: IOA");
            } else {
                amounts = OrionMultiPoolLibrary.getAmountsIn(
                    swapData.curFactory,
                    swapData.curFactoryType,
                    swapData.amountOut,
                    swapData.path
                );
                require(amounts[0] <= swapData.amountIn, "PoolFunctionality: EIA");
            }
        } else {
            amounts = new uint256[](1);
            amounts[0] = swapData.amountIn;
        }
        amountIn = amounts[0];

        {
            uint256 curBalance;
            address initialTransferSource = swapData.curFactoryType == FactoryType.CURVE ? address(this)
                : OrionMultiPoolLibrary.pairFor(swapData.curFactory, swapData.path[0], swapData.path[1]);

            if (swapData.supportingFee) curBalance = IERC20(swapData.path[0]).balanceOf(initialTransferSource);

            IPoolSwapCallback(msg.sender).safeAutoTransferFrom(
                swapData.asset_spend,
                swapData.user,
                initialTransferSource,
                amountIn
            );
            if (swapData.supportingFee) amounts[0] = IERC20(swapData.path[0]).balanceOf(initialTransferSource) - curBalance;
        }

        {
            uint256 curBalance = IERC20(swapData.path[swapData.path.length - 1]).balanceOf(toAuto);
            if (swapData.curFactoryType == FactoryType.CURVE) {
                _swapCurve(swapData.curFactory, amounts, swapData.path, swapData.supportingFee);
            } else if (swapData.curFactoryType == FactoryType.UNISWAPLIKE) {
                _swap(swapData.curFactory, amounts, swapData.path, toAuto, swapData.supportingFee);
            }
            amountOut = IERC20(swapData.path[swapData.path.length - 1]).balanceOf(toAuto) - curBalance;
        }

        require(
            swapData.amountIn == 0 || swapData.amountOut == 0 ||
            amountIn * 1e18 / swapData.amountIn <= amountOut * 1e18 / swapData.amountOut,
            "PoolFunctionality: OOS"
        );

        if (isLastWETH) {
            SafeTransferHelper.safeAutoTransferTo(
                WETH,
                address(0),
                swapData.to,
                amountOut
            );
        } else if (swapData.curFactoryType == FactoryType.CURVE) {
            IERC20(swapData.path[swapData.path.length - 1]).safeTransfer(swapData.to, amountOut);
        }

        emit OrionPoolSwap(
            tx.origin,
            convertFromWETH(swapData.path[0]),
            convertFromWETH(swapData.path[swapData.path.length - 1]),
            swapData.amountIn,
            amountIn,
            swapData.amountOut,
            amountOut,
            swapData.curFactory
        );
    }

    function _swap(
        address curFactory,
        uint256[] memory amounts,
        address[] memory path,
        address _to,
        bool supportingFee
    ) internal {
        for (uint256 i; i < path.length - 1; ++i) {
            (address input, address output) = (path[i], path[i + 1]);
            IOrionPoolV2Pair pair = IOrionPoolV2Pair(OrionMultiPoolLibrary.pairFor(curFactory, input, output));
            (address token0, ) = OrionMultiPoolLibrary.sortTokens(input, output);
            uint256 amountOut;

            if (supportingFee) {
                (uint reserve0, uint reserve1,) = pair.getReserves();
                (uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
                uint256 amountIn = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
                amountOut = OrionMultiPoolLibrary.getAmountOutUv2(amountIn, reserveInput, reserveOutput);
            } else {
                amountOut = amounts[i + 1];
            }

            (uint256 amount0Out, uint256 amount1Out) = input == token0 ? (uint256(0), amountOut) : (amountOut, uint256(0));
            address to = i < path.length - 2 ? OrionMultiPoolLibrary.pairFor(curFactory, output, path[i + 2]) : _to;

            pair.swap(amount0Out, amount1Out, to, new bytes(0));
        }
    }

    function _swapCurve(
        address curFactory,
        uint256[] memory amounts,
        address[] memory path,
        bool supportingFee
    ) internal {
        for (uint256 i; i < path.length - 1; ++i) {
            (address input, address output) = (path[i], path[i + 1]);
            address pool = OrionMultiPoolLibrary.pairForCurve(curFactory, input, output);
            (int128 inputInd, int128 outputInd,) = ICurveRegistry(curFactory).get_coin_indices(pool, input, output);

            uint256 curBalance;
            uint amountsIndex = supportingFee ? 0 : i;
            if (supportingFee) curBalance = IERC20(path[i + 1]).balanceOf(address(this));
            
            if (IERC20(input).allowance(address(this), pool) < amounts[amountsIndex]) {
                IERC20(input).safeIncreaseAllowance(pool, type(uint256).max);
            }
            ICurvePool(pool).exchange(inputInd, outputInd, amounts[amountsIndex], 0);
            
            if (supportingFee) amounts[0] = IERC20(path[i + 1]).balanceOf(address(this)) - curBalance;
        }
    }

    function addLiquidityFromExchange(
        address tokenA,
        address tokenB,
        uint256 amountADesired,
        uint256 amountBDesired,
        uint256 amountAMin,
        uint256 amountBMin,
        address to
    )
        external
        override
        returns (
            uint256 amountA,
            uint256 amountB,
            uint256 liquidity
        )
    {
        amountADesired = LibUnitConverter.decimalToBaseUnit(
            tokenA,
            amountADesired
        );
        amountBDesired = LibUnitConverter.decimalToBaseUnit(
            tokenB,
            amountBDesired
        );
        amountAMin = LibUnitConverter.decimalToBaseUnit(tokenA, amountAMin);
        amountBMin = LibUnitConverter.decimalToBaseUnit(tokenB, amountBMin);

        address tokenAOrWETH = tokenA;
        if (tokenAOrWETH == address(0)) {
            tokenAOrWETH = WETH;
        }

        (amountA, amountB) = _addLiquidity(
            tokenAOrWETH,
            tokenB,
            amountADesired,
            amountBDesired,
            amountAMin,
            amountBMin
        );

        address pair = IOrionPoolV2Factory(factory).getPair(
            tokenAOrWETH,
            tokenB
        );
        IPoolSwapCallback(msg.sender).safeAutoTransferFrom(
            tokenA,
            msg.sender,
            pair,
            amountA
        );
        IPoolSwapCallback(msg.sender).safeAutoTransferFrom(
            tokenB,
            msg.sender,
            pair,
            amountB
        );

        liquidity = IOrionPoolV2Pair(pair).mint(to);

        amountA = LibUnitConverter.baseUnitToDecimal(tokenA, amountA);
        amountB = LibUnitConverter.baseUnitToDecimal(tokenB, amountB);
    }

    function _addLiquidity(
        address tokenA,
        address tokenB,
        uint256 amountADesired,
        uint256 amountBDesired,
        uint256 amountAMin,
        uint256 amountBMin
    ) internal returns (uint256 amountA, uint256 amountB) {
        // create the pair if it doesn't exist yet
        if (
            IOrionPoolV2Factory(factory).getPair(tokenA, tokenB) == address(0)
        ) {
            IOrionPoolV2Factory(factory).createPair(tokenA, tokenB);
        }
        (uint256 reserveA, uint256 reserveB) = OrionMultiPoolLibrary.getReserves(
            factory,
            tokenA,
            tokenB
        );
        if (reserveA == 0 && reserveB == 0) {
            (amountA, amountB) = (amountADesired, amountBDesired);
        } else {
            uint256 amountBOptimal = OrionMultiPoolLibrary.quoteUv2(
                amountADesired,
                reserveA,
                reserveB
            );
            if (amountBOptimal <= amountBDesired) {
                require(
                    amountBOptimal >= amountBMin,
                    "PoolFunctionality: INSUFFICIENT_B_AMOUNT"
                );
                (amountA, amountB) = (amountADesired, amountBOptimal);
            } else {
                uint256 amountAOptimal = OrionMultiPoolLibrary.quoteUv2(
                    amountBDesired,
                    reserveB,
                    reserveA
                );
                assert(amountAOptimal <= amountADesired);
                require(
                    amountAOptimal >= amountAMin,
                    "PoolFunctionality: INSUFFICIENT_A_AMOUNT"
                );
                (amountA, amountB) = (amountAOptimal, amountBDesired);
            }
        }
    }
}

File 2 of 18 : IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 3 of 18 : IERC20Simple.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

interface IERC20Simple {
    function decimals() external view virtual returns (uint8);
}

File 4 of 18 : IPoolFunctionality.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

interface IPoolFunctionality {

    struct SwapData {
        uint112     amount_spend;
        uint112     amount_receive;
        address     orionpool_router;
        bool        is_exact_spend;
        bool        supportingFee;
        bool        isInContractTrade;
        bool        isSentETHEnough;
        bool        isFromWallet;
        address     asset_spend;
        address[]   path;
    }

    struct InternalSwapData {
        address user;
        uint256 amountIn;
        uint256 amountOut;
        address asset_spend;
        address[] path;
        bool isExactIn;
        address to;
        address curFactory;
        FactoryType curFactoryType;
        bool supportingFee;
    }

    enum FactoryType {
        UNSUPPORTED,
        UNISWAPLIKE,
        CURVE
    }

    function doSwapThroughOrionPool(
        address user,
        address to,
        IPoolFunctionality.SwapData calldata swapData
    ) external returns (uint amountOut, uint amountIn);

    function getWETH() external view returns (address);

    function addLiquidityFromExchange(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to
    ) external returns (uint amountA, uint amountB, uint liquidity);

    function isFactory(address a) external view returns (bool);
}

File 5 of 18 : IPoolSwapCallback.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

interface IPoolSwapCallback {
    function safeAutoTransferFrom(address token, address from, address to, uint value) external;
}

File 6 of 18 : IWETH.sol
// SPDX-License-Identifier: GNU
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

interface IWETH {
    function deposit() external payable;
    function transfer(address to, uint value) external returns (bool);
    function withdraw(uint) external;
}

File 7 of 18 : LibUnitConverter.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

import '../interfaces/IERC20Simple.sol';
import '../utils/fromOZ/SafeMath.sol';

library LibUnitConverter {

    using SafeMath for uint;

    /**
        @notice convert asset amount from8 decimals (10^8) to its base unit
     */
    function decimalToBaseUnit(address assetAddress, uint amount) internal view returns(uint112 baseValue){
        uint256 result;

        if(assetAddress == address(0)){
            result =  amount.mul(1 ether).div(10**8); // 18 decimals
        } else {
            uint decimals = IERC20Simple(assetAddress).decimals();

            result = amount.mul(10**decimals).div(10**8);
        }

        require(result < uint256(type(int112).max), "E3U");
        baseValue = uint112(result);
    }

    /**
        @notice convert asset amount from its base unit to 8 decimals (10^8)
     */
    function baseUnitToDecimal(address assetAddress, uint amount) internal view returns(uint112 decimalValue){
        uint256 result;

        if(assetAddress == address(0)){
            result = amount.mul(10**8).div(1 ether);
        } else {
            uint decimals = IERC20Simple(assetAddress).decimals();

            result = amount.mul(10**8).div(10**decimals);
        }
        require(result < uint256(type(int112).max), "E3U");
        decimalValue = uint112(result);
    }
}

File 8 of 18 : SafeTransferHelper.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

import "../interfaces/IWETH.sol";
import "../utils/fromOZ/SafeERC20.sol";
import "../interfaces/IERC20.sol";
import "../utils/fromOZ/Address.sol";

library SafeTransferHelper {

    function safeAutoTransferFrom(address weth, address token, address from, address to, uint value) internal {
        if (token == address(0)) {
            require(from == address(this), "TransferFrom: this");
            IWETH(weth).deposit{value: value}();
            assert(IWETH(weth).transfer(to, value));
        } else {
            if (from == address(this)) {
                SafeERC20.safeTransfer(IERC20(token), to, value);
            } else {
                SafeERC20.safeTransferFrom(IERC20(token), from, to, value);
            }
        }
    }

    function safeAutoTransferTo(address weth, address token, address to, uint value) internal {
        if (address(this) != to) {
            if (token == address(0)) {
                IWETH(weth).withdraw(value);
                Address.sendValue(payable(to), value);
            } else {
                SafeERC20.safeTransfer(IERC20(token), to, value);
            }
        }
    }

    function safeTransferTokenOrETH(address token, address to, uint value) internal {
        if (address(this) != to) {
            if (token == address(0)) {
                Address.sendValue(payable(to), value);
            } else {
                SafeERC20.safeTransfer(IERC20(token), to, value);
            }
        }
    }
}

File 9 of 18 : Address.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // 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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 10 of 18 : Context.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

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

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

File 11 of 18 : Ownable.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

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

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

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

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

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

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

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

File 12 of 18 : SafeERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

import "../../interfaces/IERC20.sol";
import "./SafeMath.sol";
import "./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 SafeMath for uint256;
    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'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

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

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

    /**
     * @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
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 13 of 18 : SafeMath.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

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

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

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

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

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

File 14 of 18 : IOrionPoolV2Factory.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

interface IOrionPoolV2Factory {
    event PairCreated(address indexed token0, address indexed token1, address pair, uint);

    function feeTo() external view returns (address);
    function feeToSetter() external view returns (address);

    function getPair(address tokenA, address tokenB) external view returns (address pair);
    function allPairs(uint) external view returns (address pair);
    function allPairsLength() external view returns (uint);

    function createPair(address tokenA, address tokenB) external returns (address pair);

    function setFeeTo(address) external;
    function setFeeToSetter(address) external;
}

File 15 of 18 : IOrionPoolV2Pair.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

interface IOrionPoolV2Pair {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

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

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

    function MINIMUM_LIQUIDITY() external pure returns (uint);
    function factory() external view returns (address);
    function token0() external view returns (address);
    function token1() external view returns (address);
    function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
    function price0CumulativeLast() external view returns (uint);
    function price1CumulativeLast() external view returns (uint);
    function kLast() external view returns (uint);

    function mint(address to) external returns (uint liquidity);
    function burn(address to) external returns (uint amount0, uint amount1);
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function skim(address to) external;
    function sync() external;

    function initialize(address, address) external;
}

File 16 of 18 : OrionMultiPoolLibrary.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

import './core/interfaces/IOrionPoolV2Pair.sol';
import './core/interfaces/IOrionPoolV2Factory.sol';
import "./periphery/interfaces/ICurveRegistry.sol";
import "./periphery/interfaces/ICurvePool.sol";
import "../../interfaces/IPoolFunctionality.sol";
import "../../interfaces/IERC20Simple.sol";

import "../fromOZ/SafeMath.sol";

library OrionMultiPoolLibrary {
    using SafeMath for uint;

    // returns sorted token addresses, used to handle return values from pairs sorted in this order
    function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
        require(tokenA != tokenB, 'OMPL: IDENTICAL_ADDRESSES');
        (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
        require(token0 != address(0), 'OMPL: ZERO_ADDRESS');
    }

    // calculates the CREATE2 address for a pair without making any external calls
    function pairFor(address factory, address tokenA, address tokenB) internal view returns (address pair) {
        pair = IOrionPoolV2Factory(factory).getPair(tokenA, tokenB);
    }

    function pairForCurve(address factory, address tokenA, address tokenB) internal view returns (address pool) {
        pool = ICurveRegistry(factory).find_pool_for_coins(tokenA, tokenB, 0);
    }

    // fetches and sorts the reserves for a pair
    function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
        (address token0,) = sortTokens(tokenA, tokenB);
        (uint reserve0, uint reserve1,) = IOrionPoolV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
        (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
    }

    function get_D(uint256[] memory xp, uint256 amp) internal pure returns(uint256) {
        uint N_COINS = xp.length;
        uint256 S = 0;
        for(uint i; i < N_COINS; ++i)
            S += xp[i];
        if(S == 0)
            return 0;

        uint256 Dprev = 0;
        uint256 D = S;
        uint256 Ann = amp * N_COINS;
        for(uint _i; _i < 255; ++_i) {
            uint256 D_P = D;
            for(uint j; j < N_COINS; ++j) {
                D_P = D_P * D / (xp[j] * N_COINS);  // If division by 0, this will be borked: only withdrawal will work. And that is good
            }
            Dprev = D;
            D = (Ann * S + D_P * N_COINS) * D / ((Ann - 1) * D + (N_COINS + 1) * D_P);
            // Equality with the precision of 1
            if (D > Dprev) {
                if (D - Dprev <= 1)
                    break;
            } else  {
                if (Dprev - D <= 1)
                    break;
            }
        }
        return D;
    }

    function get_y(int128 i, int128 j, uint256 x, uint256[] memory xp_, uint256 amp) pure internal returns(uint256)
    {
        // x in the input is converted to the same price/precision
        uint N_COINS = xp_.length;
        require(i != j, "same coin");
        require(j >= 0, "j below zero");
        require(uint128(j) < N_COINS, "j above N_COINS");

        require(i >= 0, "i below zero");
        require(uint128(i) < N_COINS, "i above N_COINS");

        uint256 D = get_D(xp_, amp);
        uint256 c = D;
        uint256 S_ = 0;
        uint256 Ann = amp * N_COINS;

        uint256 _x = 0;
        for(uint _i; _i < N_COINS; ++_i) {
            if(_i == uint128(i))
                _x = x;
            else if(_i != uint128(j))
                _x = xp_[_i];
            else
                continue;
            S_ += _x;
            c = c * D / (_x * N_COINS);
        }
        c = c * D / (Ann * N_COINS);
        uint256 b = S_ + D / Ann;  // - D
        uint256 y_prev = 0;
        uint256 y = D;
        for(uint _i; _i < 255; ++_i) {
            y_prev = y;
            y = (y*y + c) / (2 * y + b - D);
            // Equality with the precision of 1
            if(y > y_prev) {
                if (y - y_prev <= 1)
                    break;
            } else {
                if(y_prev - y <= 1)
                    break;
            }
        }
        return y;
    }

    function get_xp(address factory, address pool) internal view returns(uint256[] memory xp) {
        xp = new uint256[](MAX_COINS);

        address[MAX_COINS] memory coins = ICurveRegistry(factory).get_coins(pool);
        uint256[MAX_COINS] memory balances = ICurveRegistry(factory).get_balances(pool);

        uint i = 0;
        for (; i < balances.length; ++i) {
            if (balances[i] == 0)
                break;
            xp[i] = baseUnitToCurveDecimal(coins[i], balances[i]);
        }
        assembly { mstore(xp, sub(mload(xp), sub(MAX_COINS, i))) } // remove trail zeros from array
    }

    function getAmountOutCurve(address factory, address from, address to, uint256 amount) view internal returns(uint256) {
        address pool = pairForCurve(factory, from, to);
        (int128 i, int128 j,) = ICurveRegistry(factory).get_coin_indices(pool, from, to);
        uint256[] memory xp = get_xp(factory, pool);

        uint256 y;
        {
            uint256 A = ICurveRegistry(factory).get_A(pool);
            uint256 x = xp[uint(i)] + baseUnitToCurveDecimal(from, amount);
            y = get_y(i, j, x, xp, A);
        }

        (uint256 fee,) = ICurveRegistry(factory).get_fees(pool);
        uint256 dy = xp[uint(j)] - y - 1;
        uint256 dy_fee = dy * fee / FEE_DENOMINATOR;
        dy = curveDecimalToBaseUnit(to, dy - dy_fee);

        return dy;
    }

    function getAmountInCurve(address factory, address from, address to, uint256 amount) view internal returns(uint256) {
        address pool = pairForCurve(factory, from, to);
        (int128 i, int128 j,) = ICurveRegistry(factory).get_coin_indices(pool, from, to);
        uint256[] memory xp = get_xp(factory, pool);

        uint256 x;
        {
            (uint256 fee,) = ICurveRegistry(factory).get_fees(pool);
            uint256 A = ICurveRegistry(factory).get_A(pool);
            uint256 y = xp[uint256(j)] - baseUnitToCurveDecimal(to, (amount + 1)) * FEE_DENOMINATOR / (FEE_DENOMINATOR - fee);
            x = get_y(j, i, y, xp, A);
        }

        uint256 dx = curveDecimalToBaseUnit(from, x - xp[uint256(i)]);
        return dx;
    }

    function getAmountOutUniversal(
        address factory,
        IPoolFunctionality.FactoryType factoryType,
        address from,
        address to,
        uint256 amountIn
    ) view internal returns(uint256 amountOut) {
        if (factoryType == IPoolFunctionality.FactoryType.UNISWAPLIKE) {
            (uint reserveIn, uint reserveOut) = getReserves(factory, from, to);
            amountOut = getAmountOutUv2(amountIn, reserveIn, reserveOut);
        } else if (factoryType == IPoolFunctionality.FactoryType.CURVE) {
            amountOut = getAmountOutCurve(factory, from, to, amountIn);
        } else if (factoryType == IPoolFunctionality.FactoryType.UNSUPPORTED) {
            revert("OMPL: FACTORY_UNSUPPORTED");
        }
    }

    function getAmountInUniversal(
        address factory,
        IPoolFunctionality.FactoryType factoryType,
        address from,
        address to,
        uint256 amountOut
    ) view internal returns(uint256 amountIn) {
        if (factoryType == IPoolFunctionality.FactoryType.UNISWAPLIKE) {
            (uint reserveIn, uint reserveOut) = getReserves(factory, from, to);
            amountIn = getAmountInUv2(amountOut, reserveIn, reserveOut);
        } else if (factoryType == IPoolFunctionality.FactoryType.CURVE) {
            amountIn = getAmountInCurve(factory, from, to, amountOut);
        } else if (factoryType == IPoolFunctionality.FactoryType.UNSUPPORTED) {
            revert("OMPL: FACTORY_UNSUPPORTED");
        }
    }

    // performs chained getAmountOut calculations on any number of pairs
    function getAmountsOut(
        address factory,
        IPoolFunctionality.FactoryType factoryType,
        uint amountIn,
        address[] memory path
    ) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'OMPL: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[0] = amountIn;

        for (uint i = 1; i < path.length; ++i) {
            amounts[i] = getAmountOutUniversal(factory, factoryType, path[i - 1], path[i], amounts[i - 1]);
        }
    }

    // performs chained getAmountIn calculations on any number of pairs
    function getAmountsIn(
        address factory,
        IPoolFunctionality.FactoryType factoryType,
        uint amountOut,
        address[] memory path
    ) internal view returns (uint[] memory amounts) {
        require(path.length >= 2, 'OMPL: INVALID_PATH');
        amounts = new uint[](path.length);
        amounts[amounts.length - 1] = amountOut;
        for (uint i = path.length - 1; i > 0; --i) {
            amounts[i - 1] = getAmountInUniversal(factory, factoryType, path[i - 1], path[i], amounts[i]);
        }
    }

    /**
        @notice convert asset amount from decimals (10^18) to its base unit
    */
    function curveDecimalToBaseUnit(address assetAddress, uint amount) internal view returns(uint256 baseValue){
        uint256 result;

        if(assetAddress == address(0)){
            result = amount; // 18 decimals
        } else {
            uint decimals = IERC20Simple(assetAddress).decimals();

            result = amount.mul(10**decimals).div(10**18);
        }

        baseValue = result;
    }

    /**
        @notice convert asset amount from its base unit to 18 decimals (10^18)
    */
    function baseUnitToCurveDecimal(address assetAddress, uint amount) internal view returns(uint256 decimalValue){
        uint256 result;

        if(assetAddress == address(0)){
            result = amount;
        } else {
            uint decimals = IERC20Simple(assetAddress).decimals();

            result = amount.mul(10**18).div(10**decimals);
        }
        decimalValue = result;
    }

    // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
    function getAmountOutUv2(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
        require(amountIn > 0, 'OMPL: INSUFFICIENT_INPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'OMPL: INSUFFICIENT_LIQUIDITY');
        uint amountInWithFee = amountIn.mul(997);
        uint numerator = amountInWithFee.mul(reserveOut);
        uint denominator = reserveIn.mul(1000).add(amountInWithFee);
        amountOut = numerator / denominator;
    }

    // given an output amount of an asset and pair reserves, returns a required input amount of the other asset
    function getAmountInUv2(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
        require(amountOut > 0, 'OMPL: INSUFFICIENT_OUTPUT_AMOUNT');
        require(reserveIn > 0 && reserveOut > 0, 'OMPL: INSUFFICIENT_LIQUIDITY');
        uint numerator = reserveIn.mul(amountOut).mul(1000);
        uint denominator = reserveOut.sub(amountOut).mul(997);
        amountIn = (numerator / denominator).add(1);
    }

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

}

File 17 of 18 : ICurvePool.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

interface ICurvePool {
    function exchange(int128 i, int128 j, uint256 dx, uint256 min_dy) external;
    function get_dy(int128 i, int128 j, uint256 dx) external view returns(uint256);
}

File 18 of 18 : ICurveRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.4;
pragma experimental ABIEncoderV2;

uint256 constant FEE_DENOMINATOR = 10**10;
uint256 constant PRECISION = 10**18;
uint256 constant MAX_COINS = 8;

interface ICurveRegistry {
    function find_pool_for_coins(address _from, address _to, uint256 i) view external returns(address);
    function get_coin_indices(address _pool, address _from, address _to) view external returns(int128, int128, bool);
    function get_balances(address _pool) view external returns (uint256[MAX_COINS] memory);
    function get_rates(address _pool) view external returns (uint256[MAX_COINS] memory);
    function get_A(address _pool) view external returns (uint256);
    function get_fees(address _pool) view external returns (uint256, uint256);
    function get_coins(address _pool) view external returns (address[MAX_COINS] memory);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"enum IPoolFunctionality.FactoryType","name":"_type","type":"uint8"},{"internalType":"address","name":"_WETH","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"st","type":"address"},{"indexed":false,"internalType":"address","name":"rt","type":"address"},{"indexed":false,"internalType":"uint256","name":"st_r","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"st_a","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rt_r","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rt_a","type":"uint256"},{"indexed":false,"internalType":"address","name":"f","type":"address"}],"name":"OrionPoolSwap","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"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"amountADesired","type":"uint256"},{"internalType":"uint256","name":"amountBDesired","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"addLiquidityFromExchange","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"to","type":"address"},{"components":[{"internalType":"uint112","name":"amount_spend","type":"uint112"},{"internalType":"uint112","name":"amount_receive","type":"uint112"},{"internalType":"address","name":"orionpool_router","type":"address"},{"internalType":"bool","name":"is_exact_spend","type":"bool"},{"internalType":"bool","name":"supportingFee","type":"bool"},{"internalType":"bool","name":"isInContractTrade","type":"bool"},{"internalType":"bool","name":"isSentETHEnough","type":"bool"},{"internalType":"bool","name":"isFromWallet","type":"bool"},{"internalType":"address","name":"asset_spend","type":"address"},{"internalType":"address[]","name":"path","type":"address[]"}],"internalType":"struct IPoolFunctionality.SwapData","name":"swapData","type":"tuple"}],"name":"doSwapThroughOrionPool","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"factories","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFactoriesLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"a","type":"address"}],"name":"isFactory","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"curFactory","type":"address"},{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"}],"name":"pairFor","outputs":[{"internalType":"address","name":"pair","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supportedFactories","outputs":[{"internalType":"enum IPoolFunctionality.FactoryType","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_factories","type":"address[]"},{"internalType":"enum IPoolFunctionality.FactoryType[]","name":"_types","type":"uint8[]"}],"name":"updateFactories","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60c06040523480156200001157600080fd5b50604051620045ce380380620045ce8339810160408190526200003491620001b0565b6000620000406200010e565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506001600160601b0319606084811b821660805282901b1660a05260408051602081019091526001600160a01b0384168152620000ca906001908162000112565b506001600160a01b03831660009081526002602081905260409091208054849260ff199091169060019084908111156200010057fe5b0217905550505050620001fd565b3390565b8280548282559060005260206000209081019282156200016a579160200282015b828111156200016a57825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019062000133565b50620001789291506200017c565b5090565b5b808211156200017857600081556001016200017d565b80516001600160a01b0381168114620001ab57600080fd5b919050565b600080600060608486031215620001c5578283fd5b620001d08462000193565b9250602084015160038110620001e4578283fd5b9150620001f46040850162000193565b90509250925092565b60805160601c60a05160601c61436c620002626000398060f052806105d9528061082152806108695280610a605280611299528061188a5280612480525080610626528061084552806109135280610fba528061106f5280611102525061436c6000f3fe6080604052600436106100e05760003560e01c8063a25a58171161007f578063cae5f11e11610059578063cae5f11e14610266578063d5f724f31461027b578063de05051c146102a9578063f2fde38b146102d657610119565b8063a25a58171461020d578063ad5c46481461023c578063c45a01551461025157610119565b80636d91c0e2116100bb5780636d91c0e2146101a1578063715018a6146101c157806375eb0700146101d65780638da5cb5b146101f857610119565b806252c1fb1461011e5780630f04ba671461013e578063672383c41461017457610119565b3661011957336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461011757fe5b005b600080fd5b34801561012a57600080fd5b506101176101393660046137bf565b6102f6565b34801561014a57600080fd5b5061015e6101593660046135e8565b610459565b60405161016b9190613b50565b60405180910390f35b34801561018057600080fd5b5061019461018f366004613993565b61048f565b60405161016b9190613a52565b3480156101ad57600080fd5b506101946101bc366004613620565b6104b9565b3480156101cd57600080fd5b506101176104d0565b3480156101e257600080fd5b506101eb610559565b60405161016b919061422e565b34801561020457600080fd5b5061019461055f565b34801561021957600080fd5b5061022d6102283660046136c6565b61056e565b60405161016b93929190614272565b34801561024857600080fd5b5061019461081f565b34801561025d57600080fd5b50610194610843565b34801561027257600080fd5b50610194610867565b34801561028757600080fd5b5061029b61029636600461366a565b61088b565b60405161016b929190614237565b3480156102b557600080fd5b506102c96102c43660046135e8565b610d53565b60405161016b9190613b5b565b3480156102e257600080fd5b506101176102f13660046135e8565b610d68565b6102fe610e28565b6001600160a01b031661030f61055f565b6001600160a01b03161461033e5760405162461bcd60e51b815260040161033590614046565b60405180910390fd5b8261035b5760405162461bcd60e51b815260040161033590614017565b60005b6001548110156103c0576000600260006001848154811061037b57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020805460ff191660018360028111156103b357fe5b021790555060010161035e565b506103cd600185856134fd565b5060005b600154811015610452578282828181106103e757fe5b90506020020160208101906103fc91906138d4565b600260006001848154811061040d57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020805460ff1916600183600281111561044557fe5b02179055506001016103d1565b5050505050565b6000806001600160a01b03831660009081526002602081905260409091205460ff169081111561048557fe5b141590505b919050565b6001818154811061049f57600080fd5b6000918252602090912001546001600160a01b0316905081565b60006104c6848484610e2c565b90505b9392505050565b6104d8610e28565b6001600160a01b03166104e961055f565b6001600160a01b03161461050f5760405162461bcd60e51b815260040161033590614046565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60015490565b6000546001600160a01b031690565b600080600061057d8a89610ead565b6001600160701b031697506105928988610ead565b6001600160701b031696506105a78a87610ead565b6001600160701b031695506105bc8986610ead565b6001600160701b03169450896001600160a01b0381166105f957507f00000000000000000000000000000000000000000000000000000000000000005b610607818b8b8b8b8b610fa4565b60405163e6a4390560e01b815291955093506000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e6a439059061065d9085908f90600401613a66565b60206040518083038186803b15801561067557600080fd5b505afa158015610689573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ad9190613604565b6040516353664c0160e01b815290915033906353664c01906106d9908f90849086908b90600401613ac6565b600060405180830381600087803b1580156106f357600080fd5b505af1158015610707573d6000803e3d6000fd5b50506040516353664c0160e01b81523392506353664c019150610734908e90849086908a90600401613ac6565b600060405180830381600087803b15801561074e57600080fd5b505af1158015610762573d6000803e3d6000fd5b50506040516335313c2160e11b81526001600160a01b0384169250636a6278429150610792908990600401613a52565b602060405180830381600087803b1580156107ac57600080fd5b505af11580156107c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e491906139ab565b92506107f08c866111d9565b6001600160701b031694506108058b856111d9565b6001600160701b0316935050509750975097945050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000090565b60008080600261089f610120860186614288565b905011801561090857506000600260006108bd610120880188614288565b60008181106108c857fe5b90506020020160208101906108dd91906135e8565b6001600160a01b0316815260208101919091526040016000205460ff16600281111561090557fe5b14155b9050600081610937577f0000000000000000000000000000000000000000000000000000000000000000610965565b610945610120860186614288565b600081811061095057fe5b905060200201602081019061096591906135e8565b9050606060008361097757600061097a565b60015b60ff1690508061098e610120890189614288565b90500367ffffffffffffffff811180156109a757600080fd5b506040519080825280602002602001820160405280156109d1578160200160208202803683370190505b5091508060005b6109e66101208a018a614288565b9050821015610ab05760006109ff6101208b018b614288565b84818110610a0957fe5b9050602002016020810190610a1e91906135e8565b6001600160a01b031614610a5e57610a3a6101208a018a614288565b83818110610a4457fe5b9050602002016020810190610a5991906135e8565b610a80565b7f00000000000000000000000000000000000000000000000000000000000000005b848281518110610a8c57fe5b6001600160a01b0390921660209283029190910190910152600191820191016109d8565b506000905080610b01610ac76101208b018b614288565b85818110610ad157fe5b9050602002016020810190610ae691906135e8565b610af360208c018c61392e565b6001600160701b0316610ead565b610b53610b126101208c018c614288565b6001610b226101208f018f614288565b905003818110610b2e57fe5b9050602002016020810190610b4391906135e8565b610af360408d0160208e0161392e565b6001600160701b031691506001600160701b03169150600080610ca76040518061014001604052808f6001600160a01b031681526020018681526020018581526020018a610bce57610ba96101208f018f614288565b6000818110610bb457fe5b9050602002016020810190610bc991906135e8565b610bfc565b610bdc6101208f018f614288565b6001818110610be757fe5b9050602002016020810190610bfc91906135e8565b6001600160a01b031681526020018881526020018d6060016020810190610c23919061389c565b151581526020018e6001600160a01b03168152602001896001600160a01b03168152602001600260008b6001600160a01b03166001600160a01b0316815260200190815260200160002060009054906101000a900460ff166002811115610c8657fe5b81526020018d6080016020810190610c9e919061389c565b15159052611292565b9092509050610ce2610cbd6101208d018d614288565b87818110610cc757fe5b9050602002016020810190610cdc91906135e8565b836111d9565b6001600160701b03169950610d38610cfe6101208d018d614288565b60018e806101200190610d119190614288565b905003818110610d1d57fe5b9050602002016020810190610d3291906135e8565b826111d9565b6001600160701b031698505050505050505050935093915050565b60026020526000908152604090205460ff1681565b610d70610e28565b6001600160a01b0316610d8161055f565b6001600160a01b031614610da75760405162461bcd60e51b815260040161033590614046565b6001600160a01b038116610dcd5760405162461bcd60e51b815260040161033590613c5b565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b60405163e6a4390560e01b81526000906001600160a01b0385169063e6a4390590610e5d9086908690600401613a66565b60206040518083038186803b158015610e7557600080fd5b505afa158015610e89573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104c69190613604565b6000806001600160a01b038416610ee557610ede6305f5e100610ed885670de0b6b3a76400006119a7565b906119e7565b9050610f77565b6000846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610f2057600080fd5b505afa158015610f34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5891906139e6565b60ff169050610f736305f5e100610ed886600a85900a6119a7565b9150505b6d7fffffffffffffffffffffffffff81106104c95760405162461bcd60e51b815260040161033590613ca1565b60405163e6a4390560e01b8152600090819081907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e6a4390590610ff9908c908c90600401613a66565b60206040518083038186803b15801561101157600080fd5b505afa158015611025573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110499190613604565b6001600160a01b031614156110fa576040516364e329cb60e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c9c65396906110a6908b908b90600401613a66565b602060405180830381600087803b1580156110c057600080fd5b505af11580156110d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f89190613604565b505b6000806111287f00000000000000000000000000000000000000000000000000000000000000008b8b611a19565b9150915081600014801561113a575080155b1561114a578793508692506111cc565b6000611157898484611af2565b905087811161118b57858110156111805760405162461bcd60e51b815260040161033590613c13565b8894509250826111ca565b6000611198898486611af2565b9050898111156111a457fe5b878110156111c45760405162461bcd60e51b815260040161033590613d56565b94508793505b505b5050965096945050505050565b6000806001600160a01b03841661120457610ede670de0b6b3a7640000610ed8856305f5e1006119a7565b6000846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561123f57600080fd5b505afa158015611253573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127791906139e6565b60ff169050610f73600a82900a610ed8866305f5e1006119a7565b60008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168460800151600186608001515103815181106112d957fe5b60200260200101516001600160a01b03161490506000818061130b57506002856101000151600281111561130957fe5b145b611319578460c0015161131b565b305b905060608561012001516113ee578560a0015115611392576113508660e0015187610100015188602001518960800151611b5a565b905085604001518160018351038151811061136757fe5b6020026020010151101561138d5760405162461bcd60e51b815260040161033590613f1d565b6113e9565b6113af8660e0015187610100015188604001518960800151611c5c565b90508560200151816000815181106113c357fe5b602002602001015111156113e95760405162461bcd60e51b81526004016103359061407b565b61142d565b604080516001808252818301909252906020808301908036833701905050905085602001518160008151811061142057fe5b6020026020010181815250505b8060008151811061143a57fe5b6020026020010151945060008060028081111561145357fe5b886101000151600281111561146457fe5b146114ad576114a88860e00151896080015160008151811061148257fe5b60200260200101518a6080015160018151811061149b57fe5b6020026020010151610e2c565b6114af565b305b9050876101200151156115535787608001516000815181106114cd57fe5b60200260200101516001600160a01b03166370a08231826040518263ffffffff1660e01b81526004016115009190613a52565b60206040518083038186803b15801561151857600080fd5b505afa15801561152c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155091906139ab565b91505b606088015188516040516353664c0160e01b815233926353664c019261157f9286908d90600401613ac6565b600060405180830381600087803b15801561159957600080fd5b505af11580156115ad573d6000803e3d6000fd5b505050508761012001511561166c578188608001516000815181106115ce57fe5b60200260200101516001600160a01b03166370a08231836040518263ffffffff1660e01b81526004016116019190613a52565b60206040518083038186803b15801561161957600080fd5b505afa15801561162d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165191906139ab565b038360008151811061165f57fe5b6020026020010181815250505b50506080860151805160009190600019810190811061168757fe5b60200260200101516001600160a01b03166370a08231846040518263ffffffff1660e01b81526004016116ba9190613a52565b60206040518083038186803b1580156116d257600080fd5b505afa1580156116e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170a91906139ab565b90506002876101000151600281111561171f57fe5b14156117435761173e8760e001518389608001518a6101200151611d5a565b611776565b6001876101000151600281111561175657fe5b1415611776576117768760e00151838960800151868b61012001516120cc565b60808701518051829190600019810190811061178e57fe5b60200260200101516001600160a01b03166370a08231856040518263ffffffff1660e01b81526004016117c19190613a52565b60206040518083038186803b1580156117d957600080fd5b505afa1580156117ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181191906139ab565b0394505085602001516000148061182a57506040860151155b806118635750856040015184670de0b6b3a7640000028161184757fe5b04866020015186670de0b6b3a7640000028161185f57fe5b0411155b61187f5760405162461bcd60e51b815260040161033590614168565b82156118bb576118b67f000000000000000000000000000000000000000000000000000000000000000060008860c0015187612385565b611915565b600286610100015160028111156118ce57fe5b1415611915576119158660c0015185886080015160018a608001515103815181106118f557fe5b60200260200101516001600160a01b03166124219092919063ffffffff16565b7f6cea247822cc220200c559ac8275982608dbf8d8448dea1c08ec3d4fffab219c32611958886080015160008151811061194b57fe5b602002602001015161247c565b608089015180516119729190600019810190811061194b57fe5b8960200151898b604001518a8d60e00151604051611997989796959493929190613a80565b60405180910390a1505050915091565b6000826119b6575060006119e1565b828202828482816119c357fe5b04146104c95760405162461bcd60e51b815260040161033590613fd6565b92915050565b6000808211611a085760405162461bcd60e51b815260040161033590613ee6565b818381611a1157fe5b049392505050565b6000806000611a2885856124c5565b509050600080611a39888888610e2c565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015611a7157600080fd5b505afa158015611a85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa9919061394a565b506001600160701b031691506001600160701b03169150826001600160a01b0316876001600160a01b031614611ae0578082611ae3565b81815b90999098509650505050505050565b6000808411611b135760405162461bcd60e51b815260040161033590613f4d565b600083118015611b235750600082115b611b3f5760405162461bcd60e51b815260040161033590613bdc565b82611b4a85846119a7565b81611b5157fe5b04949350505050565b6060600282511015611b7e5760405162461bcd60e51b815260040161033590613f84565b815167ffffffffffffffff81118015611b9657600080fd5b50604051908082528060200260200182016040528015611bc0578160200160208202803683370190505b5090508281600081518110611bd157fe5b602090810291909101015260015b8251811015611c5357611c348686856001850381518110611bfc57fe5b6020026020010151868581518110611c1057fe5b6020026020010151866001870381518110611c2757fe5b602002602001015161254f565b828281518110611c4057fe5b6020908102919091010152600101611bdf565b50949350505050565b6060600282511015611c805760405162461bcd60e51b815260040161033590613f84565b815167ffffffffffffffff81118015611c9857600080fd5b50604051908082528060200260200182016040528015611cc2578160200160208202803683370190505b5090508281600183510381518110611cd657fe5b60209081029190910101528151600019015b8015611c5357611d378686856001850381518110611d0257fe5b6020026020010151868581518110611d1657fe5b6020026020010151868681518110611d2a57fe5b60200260200101516125e7565b826001830381518110611d4657fe5b602090810291909101015260001901611ce8565b60005b600183510381101561045257600080848381518110611d7857fe5b6020026020010151858460010181518110611d8f57fe5b6020026020010151915091506000611da888848461263a565b9050600080896001600160a01b031663eb85226d8487876040518463ffffffff1660e01b8152600401611ddd93929190613af0565b60606040518083038186803b158015611df557600080fd5b505afa158015611e09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2d91906138f3565b509150915060008088611e405787611e43565b60005b90508815611ee057898860010181518110611e5a57fe5b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611e8d9190613a52565b60206040518083038186803b158015611ea557600080fd5b505afa158015611eb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611edd91906139ab565b91505b8a8181518110611eec57fe5b6020026020010151876001600160a01b031663dd62ed3e30886040518363ffffffff1660e01b8152600401611f22929190613a66565b60206040518083038186803b158015611f3a57600080fd5b505afa158015611f4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f7291906139ab565b1015611f8e57611f8e6001600160a01b0388168660001961266d565b846001600160a01b0316633df0212485858e8581518110611fab57fe5b602002602001015160006040518563ffffffff1660e01b8152600401611fd49493929190613b6f565b600060405180830381600087803b158015611fee57600080fd5b505af1158015612002573d6000803e3d6000fd5b5050505088156120ba57818a896001018151811061201c57fe5b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161204f9190613a52565b60206040518083038186803b15801561206757600080fd5b505afa15801561207b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061209f91906139ab565b038b6000815181106120ad57fe5b6020026020010181815250505b50505050505050806001019050611d5d565b60005b600184510381101561237d576000808583815181106120ea57fe5b602002602001015186846001018151811061210157fe5b602002602001015191509150600061211a898484610e2c565b9050600061212884846124c5565b5090506000861561228957600080846001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561216f57600080fd5b505afa158015612183573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121a7919061394a565b506001600160701b031691506001600160701b03169150600080856001600160a01b0316896001600160a01b0316146121e15782846121e4565b83835b915091506000612270838b6001600160a01b03166370a082318b6040518263ffffffff1660e01b815260040161221a9190613a52565b60206040518083038186803b15801561223257600080fd5b505afa158015612246573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061226a91906139ab565b90612718565b905061227d818484612740565b955050505050506122a3565b89866001018151811061229857fe5b602002602001015190505b600080836001600160a01b0316876001600160a01b0316146122c7578260006122cb565b6000835b91509150600060028c510389106122e2578a6122f6565b6122f68e888e8c6002018151811061149b57fe5b6040805160008152602081019182905263022c0d9f60e01b9091529091506001600160a01b0387169063022c0d9f906123389086908690869060248101614245565b600060405180830381600087803b15801561235257600080fd5b505af1158015612366573d6000803e3d6000fd5b5050505050505050505050508060010190506120cf565b505050505050565b306001600160a01b0383161461241b576001600160a01b03831661241057604051632e1a7d4d60e01b81526001600160a01b03851690632e1a7d4d906123cf90849060040161422e565b600060405180830381600087803b1580156123e957600080fd5b505af11580156123fd573d6000803e3d6000fd5b5050505061240b82826127d4565b61241b565b61241b838383612421565b50505050565b6124778363a9059cbb60e01b8484604051602401612440929190613b37565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612870565b505050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316146124bd57816119e1565b600092915050565b600080826001600160a01b0316846001600160a01b031614156124fa5760405162461bcd60e51b8152600401610335906140ab565b826001600160a01b0316846001600160a01b03161061251a57828461251d565b83835b90925090506001600160a01b0382166125485760405162461bcd60e51b815260040161033590613d2a565b9250929050565b6000600185600281111561255f57fe5b141561258b57600080612573888787611a19565b91509150612582848383612740565b925050506125de565b600285600281111561259957fe5b14156125b2576125ab868585856128ff565b90506125de565b60008560028111156125c057fe5b14156125de5760405162461bcd60e51b815260040161033590613ba5565b95945050505050565b600060018560028111156125f757fe5b141561261a5760008061260b888787611a19565b91509150612582848383612b2f565b600285600281111561262857fe5b14156125b2576125ab86858585612bc9565b604051636982eb0b60e01b81526000906001600160a01b03851690636982eb0b90610e5d90869086908690600401613b13565b60006126f782856001600160a01b031663dd62ed3e30876040518363ffffffff1660e01b81526004016126a1929190613a66565b60206040518083038186803b1580156126b957600080fd5b505afa1580156126cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f191906139ab565b90612df5565b905061241b8463095ea7b360e01b8584604051602401612440929190613b37565b60008282111561273a5760405162461bcd60e51b815260040161033590613dd5565b50900390565b60008084116127615760405162461bcd60e51b815260040161033590613d9e565b6000831180156127715750600082115b61278d5760405162461bcd60e51b815260040161033590613bdc565b600061279b856103e56119a7565b905060006127a982856119a7565b905060006127bd836126f1886103e86119a7565b90508082816127c857fe5b04979650505050505050565b804710156127f45760405162461bcd60e51b815260040161033590613e69565b6000826001600160a01b03168260405161280d90613a4f565b60006040518083038185875af1925050503d806000811461284a576040519150601f19603f3d011682016040523d82523d6000602084013e61284f565b606091505b50509050806124775760405162461bcd60e51b815260040161033590613e0c565b60606128c5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e1a9092919063ffffffff16565b80519091501561247757808060200190518101906128e391906138b8565b6124775760405162461bcd60e51b8152600401610335906141c1565b60008061290d86868661263a565b9050600080876001600160a01b031663eb85226d8489896040518463ffffffff1660e01b815260040161294293929190613af0565b60606040518083038186803b15801561295a57600080fd5b505afa15801561296e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299291906138f3565b509150915060606129a38985612e29565b90506000808a6001600160a01b03166355b30b19876040518263ffffffff1660e01b81526004016129d49190613a52565b60206040518083038186803b1580156129ec57600080fd5b505afa158015612a00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a2491906139ab565b90506000612a328b8a612fdd565b8487600f0b81518110612a4157fe5b6020026020010151019050612a598686838786613087565b9250505060008a6001600160a01b0316637cdb72b0876040518263ffffffff1660e01b8152600401612a8b9190613a52565b604080518083038186803b158015612aa257600080fd5b505afa158015612ab6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ada91906139c3565b50905060006001838587600f0b81518110612af157fe5b60200260200101510303905060006402540be40083830281612b0f57fe5b049050612b1e8b828403613260565b9d9c50505050505050505050505050565b6000808411612b505760405162461bcd60e51b815260040161033590613cbe565b600083118015612b605750600082115b612b7c5760405162461bcd60e51b815260040161033590613bdc565b6000612b946103e8612b8e86886119a7565b906119a7565b90506000612ba86103e5612b8e8689612718565b9050612bbf6001828481612bb857fe5b0490612df5565b9695505050505050565b600080612bd786868661263a565b9050600080876001600160a01b031663eb85226d8489896040518463ffffffff1660e01b8152600401612c0c93929190613af0565b60606040518083038186803b158015612c2457600080fd5b505afa158015612c38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c5c91906138f3565b50915091506060612c6d8985612e29565b90506000808a6001600160a01b0316637cdb72b0876040518263ffffffff1660e01b8152600401612c9e9190613a52565b604080518083038186803b158015612cb557600080fd5b505afa158015612cc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ced91906139c3565b50905060008b6001600160a01b03166355b30b19886040518263ffffffff1660e01b8152600401612d1e9190613a52565b60206040518083038186803b158015612d3657600080fd5b505afa158015612d4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6e91906139ab565b90506000826402540be400036402540be400612d8d8d8d600101612fdd565b0281612d9557fe5b048587600f0b81518110612da557fe5b6020026020010151039050612dbd8688838886613087565b93505050506000612de68a8487600f0b81518110612dd757fe5b60200260200101518403613260565b9b9a5050505050505050505050565b6000828201838110156104c95760405162461bcd60e51b815260040161033590613cf3565b60606104c6848460008561330a565b60408051600880825261012082019092526060916020820161010080368337019050509050612e56613560565b604051639ac90d3d60e01b81526001600160a01b03851690639ac90d3d90612e82908690600401613a52565b6101006040518083038186803b158015612e9b57600080fd5b505afa158015612eaf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ed39190613737565b9050612edd613560565b6040516392e3cc2d60e01b81526001600160a01b038616906392e3cc2d90612f09908790600401613a52565b6101006040518083038186803b158015612f2257600080fd5b505afa158015612f36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5a9190613828565b905060005b6008811015612fcb57818160088110612f7457fe5b6020020151612f8257612fcb565b612fac838260088110612f9157fe5b6020020151838360088110612fa257fe5b6020020151612fdd565b848281518110612fb857fe5b6020908102919091010152600101612f5f565b80600803845103845250505092915050565b6000806001600160a01b038416612ff55750816104c9565b6000846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561303057600080fd5b505afa158015613044573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061306891906139e6565b60ff1690506125de600a82900a610ed886670de0b6b3a76400006119a7565b6000808351905085600f0b87600f0b14156130b45760405162461bcd60e51b81526004016103359061420b565b600086600f0b12156130d85760405162461bcd60e51b8152600401610335906140e2565b80866001600160801b0316106131005760405162461bcd60e51b81526004016103359061413f565b600087600f0b12156131245760405162461bcd60e51b815260040161033590613fb0565b80876001600160801b03161061314c5760405162461bcd60e51b815260040161033590614198565b600061315885856133cb565b905080600085840281805b868110156131d1578c6001600160801b0316811415613184578a91506131b4565b8b6001600160801b031681146131af578981815181106131a057fe5b602002602001015191506131b4565b6131c9565b92810192868202858702816131c557fe5b0494505b600101613163565b50858202858502816131df57fe5b04935060008286816131ed57fe5b0484019050600086815b60ff81101561324d57819250888483600202010388838402018161321757fe5b04915082821115613236576001838303116132315761324d565b613245565b6001828403116132455761324d565b6001016131f7565b509e9d5050505050505050505050505050565b6000806001600160a01b0384166132785750816104c9565b6000846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156132b357600080fd5b505afa1580156132c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132eb91906139e6565b60ff1690506125de670de0b6b3a7640000610ed886600a85900a6119a7565b60608247101561332c5760405162461bcd60e51b815260040161033590613ea0565b613335856134be565b6133515760405162461bcd60e51b815260040161033590614108565b60006060866001600160a01b0316858760405161336e9190613a33565b60006040518083038185875af1925050503d80600081146133ab576040519150601f19603f3d011682016040523d82523d6000602084013e6133b0565b606091505b50915091506133c08282866134c4565b979650505050505050565b815160009081805b828110156133fe578581815181106133e757fe5b6020026020010151820191508060010190506133d3565b508061340f576000925050506119e1565b600081858402825b60ff8110156134b1578260005b8781101561345757878b828151811061343957fe5b6020026020010151028583028161344c57fe5b049150600101613424565b50839450808760010102846001850302018488830288860201028161347857fe5b049350848411156134985760018585031161349357506134b1565b6134a8565b6001848603116134a857506134b1565b50600101613417565b5090979650505050505050565b3b151590565b606083156134d35750816104c9565b8251156134e35782518084602001fd5b8160405162461bcd60e51b81526004016103359190613b92565b828054828255906000526020600020908101928215613550579160200282015b828111156135505781546001600160a01b0319166001600160a01b0384351617825560209092019160019091019061351d565b5061355c92915061357f565b5090565b6040518061010001604052806008906020820280368337509192915050565b5b8082111561355c5760008155600101613580565b60008083601f8401126135a5578081fd5b50813567ffffffffffffffff8111156135bc578182fd5b602083019150836020808302850101111561254857600080fd5b8051600f81900b811461048a57600080fd5b6000602082840312156135f9578081fd5b81356104c9816142fb565b600060208284031215613615578081fd5b81516104c9816142fb565b600080600060608486031215613634578182fd5b833561363f816142fb565b9250602084013561364f816142fb565b9150604084013561365f816142fb565b809150509250925092565b60008060006060848603121561367e578283fd5b8335613689816142fb565b92506020840135613699816142fb565b9150604084013567ffffffffffffffff8111156136b4578182fd5b8401610140818703121561365f578182fd5b600080600080600080600060e0888a0312156136e0578283fd5b87356136eb816142fb565b965060208801356136fb816142fb565b955060408801359450606088013593506080880135925060a0880135915060c0880135613727816142fb565b8091505092959891949750929550565b600061010080838503121561374a578182fd5b83601f840112613758578182fd5b60405181810181811067ffffffffffffffff8211171561377457fe5b6040528084838101871015613787578485fd5b8493505b60088410156137b457805161379f816142fb565b8252600193909301926020918201910161378b565b509095945050505050565b600080600080604085870312156137d4578384fd5b843567ffffffffffffffff808211156137eb578586fd5b6137f788838901613594565b9096509450602087013591508082111561380f578384fd5b5061381c87828801613594565b95989497509550505050565b600061010080838503121561383b578182fd5b83601f840112613849578182fd5b60405181810181811067ffffffffffffffff8211171561386557fe5b6040528084838101871015613878578485fd5b8493505b60088410156137b45780518252600193909301926020918201910161387c565b6000602082840312156138ad578081fd5b81356104c981614313565b6000602082840312156138c9578081fd5b81516104c981614313565b6000602082840312156138e5578081fd5b8135600381106104c9578182fd5b600080600060608486031215613907578081fd5b613910846135d6565b925061391e602085016135d6565b9150604084015161365f81614313565b60006020828403121561393f578081fd5b81356104c981614321565b60008060006060848603121561395e578081fd5b835161396981614321565b602085015190935061397a81614321565b604085015190925063ffffffff8116811461365f578182fd5b6000602082840312156139a4578081fd5b5035919050565b6000602082840312156139bc578081fd5b5051919050565b600080604083850312156139d5578182fd5b505080516020909101519092909150565b6000602082840312156139f7578081fd5b815160ff811681146104c9578182fd5b60008151808452613a1f8160208601602086016142cf565b601f01601f19169290920160200192915050565b60008251613a458184602087016142cf565b9190910192915050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039889168152968816602088015294871660408701526060860193909352608085019190915260a084015260c083015290911660e08201526101000190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6001600160a01b0393841681529183166020830152909116604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b6020810160038310613b6957fe5b91905290565b600f94850b81529290930b60208301526040820152606081019190915260800190565b6000602082526104c96020830184613a07565b60208082526019908201527f4f4d504c3a20464143544f52595f554e535550504f5254454400000000000000604082015260600190565b6020808252601c908201527f4f4d504c3a20494e53554646494349454e545f4c495155494449545900000000604082015260600190565b60208082526028908201527f506f6f6c46756e6374696f6e616c6974793a20494e53554646494349454e545f6040820152671097d05353d5539560c21b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526003908201526245335560e81b604082015260600190565b6020808252818101527f4f4d504c3a20494e53554646494349454e545f4f55545055545f414d4f554e54604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601290820152714f4d504c3a205a45524f5f4144445245535360701b604082015260600190565b60208082526028908201527f506f6f6c46756e6374696f6e616c6974793a20494e53554646494349454e545f6040820152671057d05353d5539560c21b606082015260800190565b6020808252601f908201527f4f4d504c3a20494e53554646494349454e545f494e5055545f414d4f554e5400604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252603a908201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260408201527f6563697069656e74206d61792068617665207265766572746564000000000000606082015260800190565b6020808252601d908201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b602080825260169082015275506f6f6c46756e6374696f6e616c6974793a20494f4160501b604082015260600190565b60208082526019908201527f4f4d504c3a20494e53554646494349454e545f414d4f554e5400000000000000604082015260600190565b60208082526012908201527109e9aa0987440929cac82989288bea082a8960731b604082015260600190565b6020808252600c908201526b692062656c6f77207a65726f60a01b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b602080825260159082015274141bdbdb119d5b98dd1a5bdb985b1a5d1e4e881193605a1b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b602080825260169082015275506f6f6c46756e6374696f6e616c6974793a2045494160501b604082015260600190565b60208082526019908201527f4f4d504c3a204944454e544943414c5f41444452455353455300000000000000604082015260600190565b6020808252600c908201526b6a2062656c6f77207a65726f60a01b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600f908201526e6a2061626f7665204e5f434f494e5360881b604082015260600190565b602080825260169082015275506f6f6c46756e6374696f6e616c6974793a204f4f5360501b604082015260600190565b6020808252600f908201526e692061626f7665204e5f434f494e5360881b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526009908201526839b0b6b29031b7b4b760b91b604082015260600190565b90815260200190565b918252602082015260400190565b600085825284602083015260018060a01b038416604083015260806060830152612bbf6080830184613a07565b9283526020830191909152604082015260600190565b6000808335601e1984360301811261429e578283fd5b83018035915067ffffffffffffffff8211156142b8578283fd5b602090810192508102360382131561254857600080fd5b60005b838110156142ea5781810151838201526020016142d2565b8381111561241b5750506000910152565b6001600160a01b038116811461431057600080fd5b50565b801515811461431057600080fd5b6001600160701b038116811461431057600080fdfea2646970667358221220eeb77f5ba6bd6c4e24a47a0997fef440ecf087f94ddab8b9d93d8b105008c69a64736f6c634300070400330000000000000000000000005fa0060fcfea35b31f7a5f6025f0ff399b98edf10000000000000000000000000000000000000000000000000000000000000001000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

Deployed Bytecode

0x6080604052600436106100e05760003560e01c8063a25a58171161007f578063cae5f11e11610059578063cae5f11e14610266578063d5f724f31461027b578063de05051c146102a9578063f2fde38b146102d657610119565b8063a25a58171461020d578063ad5c46481461023c578063c45a01551461025157610119565b80636d91c0e2116100bb5780636d91c0e2146101a1578063715018a6146101c157806375eb0700146101d65780638da5cb5b146101f857610119565b806252c1fb1461011e5780630f04ba671461013e578063672383c41461017457610119565b3661011957336001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2161461011757fe5b005b600080fd5b34801561012a57600080fd5b506101176101393660046137bf565b6102f6565b34801561014a57600080fd5b5061015e6101593660046135e8565b610459565b60405161016b9190613b50565b60405180910390f35b34801561018057600080fd5b5061019461018f366004613993565b61048f565b60405161016b9190613a52565b3480156101ad57600080fd5b506101946101bc366004613620565b6104b9565b3480156101cd57600080fd5b506101176104d0565b3480156101e257600080fd5b506101eb610559565b60405161016b919061422e565b34801561020457600080fd5b5061019461055f565b34801561021957600080fd5b5061022d6102283660046136c6565b61056e565b60405161016b93929190614272565b34801561024857600080fd5b5061019461081f565b34801561025d57600080fd5b50610194610843565b34801561027257600080fd5b50610194610867565b34801561028757600080fd5b5061029b61029636600461366a565b61088b565b60405161016b929190614237565b3480156102b557600080fd5b506102c96102c43660046135e8565b610d53565b60405161016b9190613b5b565b3480156102e257600080fd5b506101176102f13660046135e8565b610d68565b6102fe610e28565b6001600160a01b031661030f61055f565b6001600160a01b03161461033e5760405162461bcd60e51b815260040161033590614046565b60405180910390fd5b8261035b5760405162461bcd60e51b815260040161033590614017565b60005b6001548110156103c0576000600260006001848154811061037b57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020805460ff191660018360028111156103b357fe5b021790555060010161035e565b506103cd600185856134fd565b5060005b600154811015610452578282828181106103e757fe5b90506020020160208101906103fc91906138d4565b600260006001848154811061040d57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020805460ff1916600183600281111561044557fe5b02179055506001016103d1565b5050505050565b6000806001600160a01b03831660009081526002602081905260409091205460ff169081111561048557fe5b141590505b919050565b6001818154811061049f57600080fd5b6000918252602090912001546001600160a01b0316905081565b60006104c6848484610e2c565b90505b9392505050565b6104d8610e28565b6001600160a01b03166104e961055f565b6001600160a01b03161461050f5760405162461bcd60e51b815260040161033590614046565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60015490565b6000546001600160a01b031690565b600080600061057d8a89610ead565b6001600160701b031697506105928988610ead565b6001600160701b031696506105a78a87610ead565b6001600160701b031695506105bc8986610ead565b6001600160701b03169450896001600160a01b0381166105f957507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25b610607818b8b8b8b8b610fa4565b60405163e6a4390560e01b815291955093506000906001600160a01b037f0000000000000000000000005fa0060fcfea35b31f7a5f6025f0ff399b98edf1169063e6a439059061065d9085908f90600401613a66565b60206040518083038186803b15801561067557600080fd5b505afa158015610689573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ad9190613604565b6040516353664c0160e01b815290915033906353664c01906106d9908f90849086908b90600401613ac6565b600060405180830381600087803b1580156106f357600080fd5b505af1158015610707573d6000803e3d6000fd5b50506040516353664c0160e01b81523392506353664c019150610734908e90849086908a90600401613ac6565b600060405180830381600087803b15801561074e57600080fd5b505af1158015610762573d6000803e3d6000fd5b50506040516335313c2160e11b81526001600160a01b0384169250636a6278429150610792908990600401613a52565b602060405180830381600087803b1580156107ac57600080fd5b505af11580156107c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e491906139ab565b92506107f08c866111d9565b6001600160701b031694506108058b856111d9565b6001600160701b0316935050509750975097945050505050565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b7f0000000000000000000000005fa0060fcfea35b31f7a5f6025f0ff399b98edf181565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290565b60008080600261089f610120860186614288565b905011801561090857506000600260006108bd610120880188614288565b60008181106108c857fe5b90506020020160208101906108dd91906135e8565b6001600160a01b0316815260208101919091526040016000205460ff16600281111561090557fe5b14155b9050600081610937577f0000000000000000000000005fa0060fcfea35b31f7a5f6025f0ff399b98edf1610965565b610945610120860186614288565b600081811061095057fe5b905060200201602081019061096591906135e8565b9050606060008361097757600061097a565b60015b60ff1690508061098e610120890189614288565b90500367ffffffffffffffff811180156109a757600080fd5b506040519080825280602002602001820160405280156109d1578160200160208202803683370190505b5091508060005b6109e66101208a018a614288565b9050821015610ab05760006109ff6101208b018b614288565b84818110610a0957fe5b9050602002016020810190610a1e91906135e8565b6001600160a01b031614610a5e57610a3a6101208a018a614288565b83818110610a4457fe5b9050602002016020810190610a5991906135e8565b610a80565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25b848281518110610a8c57fe5b6001600160a01b0390921660209283029190910190910152600191820191016109d8565b506000905080610b01610ac76101208b018b614288565b85818110610ad157fe5b9050602002016020810190610ae691906135e8565b610af360208c018c61392e565b6001600160701b0316610ead565b610b53610b126101208c018c614288565b6001610b226101208f018f614288565b905003818110610b2e57fe5b9050602002016020810190610b4391906135e8565b610af360408d0160208e0161392e565b6001600160701b031691506001600160701b03169150600080610ca76040518061014001604052808f6001600160a01b031681526020018681526020018581526020018a610bce57610ba96101208f018f614288565b6000818110610bb457fe5b9050602002016020810190610bc991906135e8565b610bfc565b610bdc6101208f018f614288565b6001818110610be757fe5b9050602002016020810190610bfc91906135e8565b6001600160a01b031681526020018881526020018d6060016020810190610c23919061389c565b151581526020018e6001600160a01b03168152602001896001600160a01b03168152602001600260008b6001600160a01b03166001600160a01b0316815260200190815260200160002060009054906101000a900460ff166002811115610c8657fe5b81526020018d6080016020810190610c9e919061389c565b15159052611292565b9092509050610ce2610cbd6101208d018d614288565b87818110610cc757fe5b9050602002016020810190610cdc91906135e8565b836111d9565b6001600160701b03169950610d38610cfe6101208d018d614288565b60018e806101200190610d119190614288565b905003818110610d1d57fe5b9050602002016020810190610d3291906135e8565b826111d9565b6001600160701b031698505050505050505050935093915050565b60026020526000908152604090205460ff1681565b610d70610e28565b6001600160a01b0316610d8161055f565b6001600160a01b031614610da75760405162461bcd60e51b815260040161033590614046565b6001600160a01b038116610dcd5760405162461bcd60e51b815260040161033590613c5b565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b60405163e6a4390560e01b81526000906001600160a01b0385169063e6a4390590610e5d9086908690600401613a66565b60206040518083038186803b158015610e7557600080fd5b505afa158015610e89573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104c69190613604565b6000806001600160a01b038416610ee557610ede6305f5e100610ed885670de0b6b3a76400006119a7565b906119e7565b9050610f77565b6000846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610f2057600080fd5b505afa158015610f34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f5891906139e6565b60ff169050610f736305f5e100610ed886600a85900a6119a7565b9150505b6d7fffffffffffffffffffffffffff81106104c95760405162461bcd60e51b815260040161033590613ca1565b60405163e6a4390560e01b8152600090819081907f0000000000000000000000005fa0060fcfea35b31f7a5f6025f0ff399b98edf16001600160a01b03169063e6a4390590610ff9908c908c90600401613a66565b60206040518083038186803b15801561101157600080fd5b505afa158015611025573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110499190613604565b6001600160a01b031614156110fa576040516364e329cb60e11b81526001600160a01b037f0000000000000000000000005fa0060fcfea35b31f7a5f6025f0ff399b98edf1169063c9c65396906110a6908b908b90600401613a66565b602060405180830381600087803b1580156110c057600080fd5b505af11580156110d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f89190613604565b505b6000806111287f0000000000000000000000005fa0060fcfea35b31f7a5f6025f0ff399b98edf18b8b611a19565b9150915081600014801561113a575080155b1561114a578793508692506111cc565b6000611157898484611af2565b905087811161118b57858110156111805760405162461bcd60e51b815260040161033590613c13565b8894509250826111ca565b6000611198898486611af2565b9050898111156111a457fe5b878110156111c45760405162461bcd60e51b815260040161033590613d56565b94508793505b505b5050965096945050505050565b6000806001600160a01b03841661120457610ede670de0b6b3a7640000610ed8856305f5e1006119a7565b6000846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561123f57600080fd5b505afa158015611253573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127791906139e6565b60ff169050610f73600a82900a610ed8866305f5e1006119a7565b60008060007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03168460800151600186608001515103815181106112d957fe5b60200260200101516001600160a01b03161490506000818061130b57506002856101000151600281111561130957fe5b145b611319578460c0015161131b565b305b905060608561012001516113ee578560a0015115611392576113508660e0015187610100015188602001518960800151611b5a565b905085604001518160018351038151811061136757fe5b6020026020010151101561138d5760405162461bcd60e51b815260040161033590613f1d565b6113e9565b6113af8660e0015187610100015188604001518960800151611c5c565b90508560200151816000815181106113c357fe5b602002602001015111156113e95760405162461bcd60e51b81526004016103359061407b565b61142d565b604080516001808252818301909252906020808301908036833701905050905085602001518160008151811061142057fe5b6020026020010181815250505b8060008151811061143a57fe5b6020026020010151945060008060028081111561145357fe5b886101000151600281111561146457fe5b146114ad576114a88860e00151896080015160008151811061148257fe5b60200260200101518a6080015160018151811061149b57fe5b6020026020010151610e2c565b6114af565b305b9050876101200151156115535787608001516000815181106114cd57fe5b60200260200101516001600160a01b03166370a08231826040518263ffffffff1660e01b81526004016115009190613a52565b60206040518083038186803b15801561151857600080fd5b505afa15801561152c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155091906139ab565b91505b606088015188516040516353664c0160e01b815233926353664c019261157f9286908d90600401613ac6565b600060405180830381600087803b15801561159957600080fd5b505af11580156115ad573d6000803e3d6000fd5b505050508761012001511561166c578188608001516000815181106115ce57fe5b60200260200101516001600160a01b03166370a08231836040518263ffffffff1660e01b81526004016116019190613a52565b60206040518083038186803b15801561161957600080fd5b505afa15801561162d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061165191906139ab565b038360008151811061165f57fe5b6020026020010181815250505b50506080860151805160009190600019810190811061168757fe5b60200260200101516001600160a01b03166370a08231846040518263ffffffff1660e01b81526004016116ba9190613a52565b60206040518083038186803b1580156116d257600080fd5b505afa1580156116e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170a91906139ab565b90506002876101000151600281111561171f57fe5b14156117435761173e8760e001518389608001518a6101200151611d5a565b611776565b6001876101000151600281111561175657fe5b1415611776576117768760e00151838960800151868b61012001516120cc565b60808701518051829190600019810190811061178e57fe5b60200260200101516001600160a01b03166370a08231856040518263ffffffff1660e01b81526004016117c19190613a52565b60206040518083038186803b1580156117d957600080fd5b505afa1580156117ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061181191906139ab565b0394505085602001516000148061182a57506040860151155b806118635750856040015184670de0b6b3a7640000028161184757fe5b04866020015186670de0b6b3a7640000028161185f57fe5b0411155b61187f5760405162461bcd60e51b815260040161033590614168565b82156118bb576118b67f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc260008860c0015187612385565b611915565b600286610100015160028111156118ce57fe5b1415611915576119158660c0015185886080015160018a608001515103815181106118f557fe5b60200260200101516001600160a01b03166124219092919063ffffffff16565b7f6cea247822cc220200c559ac8275982608dbf8d8448dea1c08ec3d4fffab219c32611958886080015160008151811061194b57fe5b602002602001015161247c565b608089015180516119729190600019810190811061194b57fe5b8960200151898b604001518a8d60e00151604051611997989796959493929190613a80565b60405180910390a1505050915091565b6000826119b6575060006119e1565b828202828482816119c357fe5b04146104c95760405162461bcd60e51b815260040161033590613fd6565b92915050565b6000808211611a085760405162461bcd60e51b815260040161033590613ee6565b818381611a1157fe5b049392505050565b6000806000611a2885856124c5565b509050600080611a39888888610e2c565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015611a7157600080fd5b505afa158015611a85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa9919061394a565b506001600160701b031691506001600160701b03169150826001600160a01b0316876001600160a01b031614611ae0578082611ae3565b81815b90999098509650505050505050565b6000808411611b135760405162461bcd60e51b815260040161033590613f4d565b600083118015611b235750600082115b611b3f5760405162461bcd60e51b815260040161033590613bdc565b82611b4a85846119a7565b81611b5157fe5b04949350505050565b6060600282511015611b7e5760405162461bcd60e51b815260040161033590613f84565b815167ffffffffffffffff81118015611b9657600080fd5b50604051908082528060200260200182016040528015611bc0578160200160208202803683370190505b5090508281600081518110611bd157fe5b602090810291909101015260015b8251811015611c5357611c348686856001850381518110611bfc57fe5b6020026020010151868581518110611c1057fe5b6020026020010151866001870381518110611c2757fe5b602002602001015161254f565b828281518110611c4057fe5b6020908102919091010152600101611bdf565b50949350505050565b6060600282511015611c805760405162461bcd60e51b815260040161033590613f84565b815167ffffffffffffffff81118015611c9857600080fd5b50604051908082528060200260200182016040528015611cc2578160200160208202803683370190505b5090508281600183510381518110611cd657fe5b60209081029190910101528151600019015b8015611c5357611d378686856001850381518110611d0257fe5b6020026020010151868581518110611d1657fe5b6020026020010151868681518110611d2a57fe5b60200260200101516125e7565b826001830381518110611d4657fe5b602090810291909101015260001901611ce8565b60005b600183510381101561045257600080848381518110611d7857fe5b6020026020010151858460010181518110611d8f57fe5b6020026020010151915091506000611da888848461263a565b9050600080896001600160a01b031663eb85226d8487876040518463ffffffff1660e01b8152600401611ddd93929190613af0565b60606040518083038186803b158015611df557600080fd5b505afa158015611e09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2d91906138f3565b509150915060008088611e405787611e43565b60005b90508815611ee057898860010181518110611e5a57fe5b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401611e8d9190613a52565b60206040518083038186803b158015611ea557600080fd5b505afa158015611eb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611edd91906139ab565b91505b8a8181518110611eec57fe5b6020026020010151876001600160a01b031663dd62ed3e30886040518363ffffffff1660e01b8152600401611f22929190613a66565b60206040518083038186803b158015611f3a57600080fd5b505afa158015611f4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f7291906139ab565b1015611f8e57611f8e6001600160a01b0388168660001961266d565b846001600160a01b0316633df0212485858e8581518110611fab57fe5b602002602001015160006040518563ffffffff1660e01b8152600401611fd49493929190613b6f565b600060405180830381600087803b158015611fee57600080fd5b505af1158015612002573d6000803e3d6000fd5b5050505088156120ba57818a896001018151811061201c57fe5b60200260200101516001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161204f9190613a52565b60206040518083038186803b15801561206757600080fd5b505afa15801561207b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061209f91906139ab565b038b6000815181106120ad57fe5b6020026020010181815250505b50505050505050806001019050611d5d565b60005b600184510381101561237d576000808583815181106120ea57fe5b602002602001015186846001018151811061210157fe5b602002602001015191509150600061211a898484610e2c565b9050600061212884846124c5565b5090506000861561228957600080846001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561216f57600080fd5b505afa158015612183573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121a7919061394a565b506001600160701b031691506001600160701b03169150600080856001600160a01b0316896001600160a01b0316146121e15782846121e4565b83835b915091506000612270838b6001600160a01b03166370a082318b6040518263ffffffff1660e01b815260040161221a9190613a52565b60206040518083038186803b15801561223257600080fd5b505afa158015612246573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061226a91906139ab565b90612718565b905061227d818484612740565b955050505050506122a3565b89866001018151811061229857fe5b602002602001015190505b600080836001600160a01b0316876001600160a01b0316146122c7578260006122cb565b6000835b91509150600060028c510389106122e2578a6122f6565b6122f68e888e8c6002018151811061149b57fe5b6040805160008152602081019182905263022c0d9f60e01b9091529091506001600160a01b0387169063022c0d9f906123389086908690869060248101614245565b600060405180830381600087803b15801561235257600080fd5b505af1158015612366573d6000803e3d6000fd5b5050505050505050505050508060010190506120cf565b505050505050565b306001600160a01b0383161461241b576001600160a01b03831661241057604051632e1a7d4d60e01b81526001600160a01b03851690632e1a7d4d906123cf90849060040161422e565b600060405180830381600087803b1580156123e957600080fd5b505af11580156123fd573d6000803e3d6000fd5b5050505061240b82826127d4565b61241b565b61241b838383612421565b50505050565b6124778363a9059cbb60e01b8484604051602401612440929190613b37565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612870565b505050565b60007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316826001600160a01b0316146124bd57816119e1565b600092915050565b600080826001600160a01b0316846001600160a01b031614156124fa5760405162461bcd60e51b8152600401610335906140ab565b826001600160a01b0316846001600160a01b03161061251a57828461251d565b83835b90925090506001600160a01b0382166125485760405162461bcd60e51b815260040161033590613d2a565b9250929050565b6000600185600281111561255f57fe5b141561258b57600080612573888787611a19565b91509150612582848383612740565b925050506125de565b600285600281111561259957fe5b14156125b2576125ab868585856128ff565b90506125de565b60008560028111156125c057fe5b14156125de5760405162461bcd60e51b815260040161033590613ba5565b95945050505050565b600060018560028111156125f757fe5b141561261a5760008061260b888787611a19565b91509150612582848383612b2f565b600285600281111561262857fe5b14156125b2576125ab86858585612bc9565b604051636982eb0b60e01b81526000906001600160a01b03851690636982eb0b90610e5d90869086908690600401613b13565b60006126f782856001600160a01b031663dd62ed3e30876040518363ffffffff1660e01b81526004016126a1929190613a66565b60206040518083038186803b1580156126b957600080fd5b505afa1580156126cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f191906139ab565b90612df5565b905061241b8463095ea7b360e01b8584604051602401612440929190613b37565b60008282111561273a5760405162461bcd60e51b815260040161033590613dd5565b50900390565b60008084116127615760405162461bcd60e51b815260040161033590613d9e565b6000831180156127715750600082115b61278d5760405162461bcd60e51b815260040161033590613bdc565b600061279b856103e56119a7565b905060006127a982856119a7565b905060006127bd836126f1886103e86119a7565b90508082816127c857fe5b04979650505050505050565b804710156127f45760405162461bcd60e51b815260040161033590613e69565b6000826001600160a01b03168260405161280d90613a4f565b60006040518083038185875af1925050503d806000811461284a576040519150601f19603f3d011682016040523d82523d6000602084013e61284f565b606091505b50509050806124775760405162461bcd60e51b815260040161033590613e0c565b60606128c5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e1a9092919063ffffffff16565b80519091501561247757808060200190518101906128e391906138b8565b6124775760405162461bcd60e51b8152600401610335906141c1565b60008061290d86868661263a565b9050600080876001600160a01b031663eb85226d8489896040518463ffffffff1660e01b815260040161294293929190613af0565b60606040518083038186803b15801561295a57600080fd5b505afa15801561296e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299291906138f3565b509150915060606129a38985612e29565b90506000808a6001600160a01b03166355b30b19876040518263ffffffff1660e01b81526004016129d49190613a52565b60206040518083038186803b1580156129ec57600080fd5b505afa158015612a00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a2491906139ab565b90506000612a328b8a612fdd565b8487600f0b81518110612a4157fe5b6020026020010151019050612a598686838786613087565b9250505060008a6001600160a01b0316637cdb72b0876040518263ffffffff1660e01b8152600401612a8b9190613a52565b604080518083038186803b158015612aa257600080fd5b505afa158015612ab6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ada91906139c3565b50905060006001838587600f0b81518110612af157fe5b60200260200101510303905060006402540be40083830281612b0f57fe5b049050612b1e8b828403613260565b9d9c50505050505050505050505050565b6000808411612b505760405162461bcd60e51b815260040161033590613cbe565b600083118015612b605750600082115b612b7c5760405162461bcd60e51b815260040161033590613bdc565b6000612b946103e8612b8e86886119a7565b906119a7565b90506000612ba86103e5612b8e8689612718565b9050612bbf6001828481612bb857fe5b0490612df5565b9695505050505050565b600080612bd786868661263a565b9050600080876001600160a01b031663eb85226d8489896040518463ffffffff1660e01b8152600401612c0c93929190613af0565b60606040518083038186803b158015612c2457600080fd5b505afa158015612c38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c5c91906138f3565b50915091506060612c6d8985612e29565b90506000808a6001600160a01b0316637cdb72b0876040518263ffffffff1660e01b8152600401612c9e9190613a52565b604080518083038186803b158015612cb557600080fd5b505afa158015612cc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ced91906139c3565b50905060008b6001600160a01b03166355b30b19886040518263ffffffff1660e01b8152600401612d1e9190613a52565b60206040518083038186803b158015612d3657600080fd5b505afa158015612d4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6e91906139ab565b90506000826402540be400036402540be400612d8d8d8d600101612fdd565b0281612d9557fe5b048587600f0b81518110612da557fe5b6020026020010151039050612dbd8688838886613087565b93505050506000612de68a8487600f0b81518110612dd757fe5b60200260200101518403613260565b9b9a5050505050505050505050565b6000828201838110156104c95760405162461bcd60e51b815260040161033590613cf3565b60606104c6848460008561330a565b60408051600880825261012082019092526060916020820161010080368337019050509050612e56613560565b604051639ac90d3d60e01b81526001600160a01b03851690639ac90d3d90612e82908690600401613a52565b6101006040518083038186803b158015612e9b57600080fd5b505afa158015612eaf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ed39190613737565b9050612edd613560565b6040516392e3cc2d60e01b81526001600160a01b038616906392e3cc2d90612f09908790600401613a52565b6101006040518083038186803b158015612f2257600080fd5b505afa158015612f36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f5a9190613828565b905060005b6008811015612fcb57818160088110612f7457fe5b6020020151612f8257612fcb565b612fac838260088110612f9157fe5b6020020151838360088110612fa257fe5b6020020151612fdd565b848281518110612fb857fe5b6020908102919091010152600101612f5f565b80600803845103845250505092915050565b6000806001600160a01b038416612ff55750816104c9565b6000846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561303057600080fd5b505afa158015613044573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061306891906139e6565b60ff1690506125de600a82900a610ed886670de0b6b3a76400006119a7565b6000808351905085600f0b87600f0b14156130b45760405162461bcd60e51b81526004016103359061420b565b600086600f0b12156130d85760405162461bcd60e51b8152600401610335906140e2565b80866001600160801b0316106131005760405162461bcd60e51b81526004016103359061413f565b600087600f0b12156131245760405162461bcd60e51b815260040161033590613fb0565b80876001600160801b03161061314c5760405162461bcd60e51b815260040161033590614198565b600061315885856133cb565b905080600085840281805b868110156131d1578c6001600160801b0316811415613184578a91506131b4565b8b6001600160801b031681146131af578981815181106131a057fe5b602002602001015191506131b4565b6131c9565b92810192868202858702816131c557fe5b0494505b600101613163565b50858202858502816131df57fe5b04935060008286816131ed57fe5b0484019050600086815b60ff81101561324d57819250888483600202010388838402018161321757fe5b04915082821115613236576001838303116132315761324d565b613245565b6001828403116132455761324d565b6001016131f7565b509e9d5050505050505050505050505050565b6000806001600160a01b0384166132785750816104c9565b6000846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b1580156132b357600080fd5b505afa1580156132c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132eb91906139e6565b60ff1690506125de670de0b6b3a7640000610ed886600a85900a6119a7565b60608247101561332c5760405162461bcd60e51b815260040161033590613ea0565b613335856134be565b6133515760405162461bcd60e51b815260040161033590614108565b60006060866001600160a01b0316858760405161336e9190613a33565b60006040518083038185875af1925050503d80600081146133ab576040519150601f19603f3d011682016040523d82523d6000602084013e6133b0565b606091505b50915091506133c08282866134c4565b979650505050505050565b815160009081805b828110156133fe578581815181106133e757fe5b6020026020010151820191508060010190506133d3565b508061340f576000925050506119e1565b600081858402825b60ff8110156134b1578260005b8781101561345757878b828151811061343957fe5b6020026020010151028583028161344c57fe5b049150600101613424565b50839450808760010102846001850302018488830288860201028161347857fe5b049350848411156134985760018585031161349357506134b1565b6134a8565b6001848603116134a857506134b1565b50600101613417565b5090979650505050505050565b3b151590565b606083156134d35750816104c9565b8251156134e35782518084602001fd5b8160405162461bcd60e51b81526004016103359190613b92565b828054828255906000526020600020908101928215613550579160200282015b828111156135505781546001600160a01b0319166001600160a01b0384351617825560209092019160019091019061351d565b5061355c92915061357f565b5090565b6040518061010001604052806008906020820280368337509192915050565b5b8082111561355c5760008155600101613580565b60008083601f8401126135a5578081fd5b50813567ffffffffffffffff8111156135bc578182fd5b602083019150836020808302850101111561254857600080fd5b8051600f81900b811461048a57600080fd5b6000602082840312156135f9578081fd5b81356104c9816142fb565b600060208284031215613615578081fd5b81516104c9816142fb565b600080600060608486031215613634578182fd5b833561363f816142fb565b9250602084013561364f816142fb565b9150604084013561365f816142fb565b809150509250925092565b60008060006060848603121561367e578283fd5b8335613689816142fb565b92506020840135613699816142fb565b9150604084013567ffffffffffffffff8111156136b4578182fd5b8401610140818703121561365f578182fd5b600080600080600080600060e0888a0312156136e0578283fd5b87356136eb816142fb565b965060208801356136fb816142fb565b955060408801359450606088013593506080880135925060a0880135915060c0880135613727816142fb565b8091505092959891949750929550565b600061010080838503121561374a578182fd5b83601f840112613758578182fd5b60405181810181811067ffffffffffffffff8211171561377457fe5b6040528084838101871015613787578485fd5b8493505b60088410156137b457805161379f816142fb565b8252600193909301926020918201910161378b565b509095945050505050565b600080600080604085870312156137d4578384fd5b843567ffffffffffffffff808211156137eb578586fd5b6137f788838901613594565b9096509450602087013591508082111561380f578384fd5b5061381c87828801613594565b95989497509550505050565b600061010080838503121561383b578182fd5b83601f840112613849578182fd5b60405181810181811067ffffffffffffffff8211171561386557fe5b6040528084838101871015613878578485fd5b8493505b60088410156137b45780518252600193909301926020918201910161387c565b6000602082840312156138ad578081fd5b81356104c981614313565b6000602082840312156138c9578081fd5b81516104c981614313565b6000602082840312156138e5578081fd5b8135600381106104c9578182fd5b600080600060608486031215613907578081fd5b613910846135d6565b925061391e602085016135d6565b9150604084015161365f81614313565b60006020828403121561393f578081fd5b81356104c981614321565b60008060006060848603121561395e578081fd5b835161396981614321565b602085015190935061397a81614321565b604085015190925063ffffffff8116811461365f578182fd5b6000602082840312156139a4578081fd5b5035919050565b6000602082840312156139bc578081fd5b5051919050565b600080604083850312156139d5578182fd5b505080516020909101519092909150565b6000602082840312156139f7578081fd5b815160ff811681146104c9578182fd5b60008151808452613a1f8160208601602086016142cf565b601f01601f19169290920160200192915050565b60008251613a458184602087016142cf565b9190910192915050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039889168152968816602088015294871660408701526060860193909352608085019190915260a084015260c083015290911660e08201526101000190565b6001600160a01b039485168152928416602084015292166040820152606081019190915260800190565b6001600160a01b0393841681529183166020830152909116604082015260600190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b6020810160038310613b6957fe5b91905290565b600f94850b81529290930b60208301526040820152606081019190915260800190565b6000602082526104c96020830184613a07565b60208082526019908201527f4f4d504c3a20464143544f52595f554e535550504f5254454400000000000000604082015260600190565b6020808252601c908201527f4f4d504c3a20494e53554646494349454e545f4c495155494449545900000000604082015260600190565b60208082526028908201527f506f6f6c46756e6374696f6e616c6974793a20494e53554646494349454e545f6040820152671097d05353d5539560c21b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526003908201526245335560e81b604082015260600190565b6020808252818101527f4f4d504c3a20494e53554646494349454e545f4f55545055545f414d4f554e54604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601290820152714f4d504c3a205a45524f5f4144445245535360701b604082015260600190565b60208082526028908201527f506f6f6c46756e6374696f6e616c6974793a20494e53554646494349454e545f6040820152671057d05353d5539560c21b606082015260800190565b6020808252601f908201527f4f4d504c3a20494e53554646494349454e545f494e5055545f414d4f554e5400604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252603a908201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260408201527f6563697069656e74206d61792068617665207265766572746564000000000000606082015260800190565b6020808252601d908201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252601a908201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604082015260600190565b602080825260169082015275506f6f6c46756e6374696f6e616c6974793a20494f4160501b604082015260600190565b60208082526019908201527f4f4d504c3a20494e53554646494349454e545f414d4f554e5400000000000000604082015260600190565b60208082526012908201527109e9aa0987440929cac82989288bea082a8960731b604082015260600190565b6020808252600c908201526b692062656c6f77207a65726f60a01b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b602080825260159082015274141bdbdb119d5b98dd1a5bdb985b1a5d1e4e881193605a1b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b602080825260169082015275506f6f6c46756e6374696f6e616c6974793a2045494160501b604082015260600190565b60208082526019908201527f4f4d504c3a204944454e544943414c5f41444452455353455300000000000000604082015260600190565b6020808252600c908201526b6a2062656c6f77207a65726f60a01b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600f908201526e6a2061626f7665204e5f434f494e5360881b604082015260600190565b602080825260169082015275506f6f6c46756e6374696f6e616c6974793a204f4f5360501b604082015260600190565b6020808252600f908201526e692061626f7665204e5f434f494e5360881b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526009908201526839b0b6b29031b7b4b760b91b604082015260600190565b90815260200190565b918252602082015260400190565b600085825284602083015260018060a01b038416604083015260806060830152612bbf6080830184613a07565b9283526020830191909152604082015260600190565b6000808335601e1984360301811261429e578283fd5b83018035915067ffffffffffffffff8211156142b8578283fd5b602090810192508102360382131561254857600080fd5b60005b838110156142ea5781810151838201526020016142d2565b8381111561241b5750506000910152565b6001600160a01b038116811461431057600080fd5b50565b801515811461431057600080fd5b6001600160701b038116811461431057600080fdfea2646970667358221220eeb77f5ba6bd6c4e24a47a0997fef440ecf087f94ddab8b9d93d8b105008c69a64736f6c63430007040033

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

0000000000000000000000005fa0060fcfea35b31f7a5f6025f0ff399b98edf10000000000000000000000000000000000000000000000000000000000000001000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

-----Decoded View---------------
Arg [0] : _factory (address): 0x5FA0060FcfEa35B31F7A5f6025F0fF399b98Edf1
Arg [1] : _type (uint8): 1
Arg [2] : _WETH (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000005fa0060fcfea35b31f7a5f6025f0ff399b98edf1
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [2] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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