ETH Price: $3,128.65 (+0.94%)

Contract

0x7e01238227213C513010F5fAbD0634fEBee93EE5
Transaction Hash
Method
Block
From
To
Value
Cancel Increase ...130223312024-06-02 15:19:4540 days ago1717341585IN
0x7e012382...EBee93EE5
0 ETH0.000013970.20301
Update Increase ...130222832024-06-02 15:17:2240 days ago1717341442IN
0x7e012382...EBee93EE5
0 ETH0.000010180.23129
Create Increase ...130222202024-06-02 15:14:1340 days ago1717341253IN
0x7e012382...EBee93EE5
0.005 ETH0.000090380.2525
Cancel Increase ...128994402024-05-29 7:57:5444 days ago1716969474IN
0x7e012382...EBee93EE5
0 ETH0.000007270.14
Create Increase ...128992262024-05-29 7:47:0944 days ago1716968829IN
0x7e012382...EBee93EE5
0.015 ETH0.000050560.15
Create Increase ...128508902024-05-27 15:07:5946 days ago1716822479IN
0x7e012382...EBee93EE5
0.005 ETH0.000144660.427
Create Decrease ...128420212024-05-27 7:42:3846 days ago1716795758IN
0x7e012382...EBee93EE5
0.0051 ETH0.000042850.18
Cancel Decrease ...128150402024-05-26 9:08:0147 days ago1716714481IN
0x7e012382...EBee93EE5
0 ETH0.000002790.0573
Update Decrease ...128150272024-05-26 9:07:2147 days ago1716714441IN
0x7e012382...EBee93EE5
0 ETH0.000002550.0547
Create Decrease ...128124992024-05-26 7:00:5847 days ago1716706858IN
0x7e012382...EBee93EE5
0.0051 ETH0.000010960.0503
Create Increase ...128095842024-05-26 4:34:5047 days ago1716698090IN
0x7e012382...EBee93EE5
0.005 ETH0.000013060.0355
Cancel Increase ...127792062024-05-25 3:10:2648 days ago1716606626IN
0x7e012382...EBee93EE5
0 ETH0.000003670.0609
Create Increase ...127791652024-05-25 3:08:2648 days ago1716606506IN
0x7e012382...EBee93EE5
0.005 ETH0.000022250.06
Cancel Increase ...127791452024-05-25 3:07:2748 days ago1716606447IN
0x7e012382...EBee93EE5
0 ETH0.000002740.0592
Cancel Increase ...127791422024-05-25 3:07:1748 days ago1716606437IN
0x7e012382...EBee93EE5
0 ETH0.000003560.0592
Create Increase ...127791082024-05-25 3:05:3648 days ago1716606336IN
0x7e012382...EBee93EE5
0.005 ETH0.000022690.0612
Cancel Increase ...127790502024-05-25 3:02:4348 days ago1716606163IN
0x7e012382...EBee93EE5
0 ETH0.000003610.0599
Cancel Increase ...127790332024-05-25 3:01:5148 days ago1716606111IN
0x7e012382...EBee93EE5
0 ETH0.000003460.0575
Create Increase ...127789802024-05-25 2:59:1248 days ago1716605952IN
0x7e012382...EBee93EE5
0.005 ETH0.000021720.0614
Create Increase ...127789702024-05-25 2:58:4248 days ago1716605922IN
0x7e012382...EBee93EE5
0.005 ETH0.000023250.0627
Cancel Increase ...127789422024-05-25 2:57:1748 days ago1716605837IN
0x7e012382...EBee93EE5
0 ETH0.000004020.0668
Create Increase ...127789032024-05-25 2:55:1948 days ago1716605719IN
0x7e012382...EBee93EE5
0.005 ETH0.000025660.0692
Cancel Increase ...127788892024-05-25 2:54:3648 days ago1716605676IN
0x7e012382...EBee93EE5
0 ETH0.000003210.0693
Cancel Increase ...127788882024-05-25 2:54:3348 days ago1716605673IN
0x7e012382...EBee93EE5
0 ETH0.000004170.0693
Create Increase ...127788702024-05-25 2:53:4048 days ago1716605620IN
0x7e012382...EBee93EE5
0.005 ETH0.000029440.0759
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To Value
130223312024-06-02 15:19:4540 days ago1717341585
0x7e012382...EBee93EE5
0.005 ETH
130223312024-06-02 15:19:4540 days ago1717341585
0x7e012382...EBee93EE5
0.005 ETH
130222202024-06-02 15:14:1340 days ago1717341253
0x7e012382...EBee93EE5
0.005 ETH
128994402024-05-29 7:57:5444 days ago1716969474
0x7e012382...EBee93EE5
0.015 ETH
128994402024-05-29 7:57:5444 days ago1716969474
0x7e012382...EBee93EE5
0.015 ETH
128992262024-05-29 7:47:0944 days ago1716968829
0x7e012382...EBee93EE5
0.015 ETH
128835832024-05-28 18:43:5145 days ago1716921831
0x7e012382...EBee93EE5
0.005 ETH
128835832024-05-28 18:43:5145 days ago1716921831
0x7e012382...EBee93EE5
0.005 ETH
128508902024-05-27 15:07:5946 days ago1716822479
0x7e012382...EBee93EE5
0.005 ETH
128429232024-05-27 8:27:5046 days ago1716798470
0x7e012382...EBee93EE5
0.0051 ETH
128429232024-05-27 8:27:5046 days ago1716798470
0x7e012382...EBee93EE5
0.0051 ETH
128429232024-05-27 8:27:5046 days ago1716798470
0x7e012382...EBee93EE5
0.01635018 ETH
128429232024-05-27 8:27:5046 days ago1716798470
0x7e012382...EBee93EE5
0.01635018 ETH
128420212024-05-27 7:42:3846 days ago1716795758
0x7e012382...EBee93EE5
0.0051 ETH
128150402024-05-26 9:08:0147 days ago1716714481
0x7e012382...EBee93EE5
0.0051 ETH
128150402024-05-26 9:08:0147 days ago1716714481
0x7e012382...EBee93EE5
0.0051 ETH
128124992024-05-26 7:00:5847 days ago1716706858
0x7e012382...EBee93EE5
0.0051 ETH
128114692024-05-26 6:09:2347 days ago1716703763
0x7e012382...EBee93EE5
0.005 ETH
128114692024-05-26 6:09:2347 days ago1716703763
0x7e012382...EBee93EE5
0.005 ETH
128095842024-05-26 4:34:5047 days ago1716698090
0x7e012382...EBee93EE5
0.005 ETH
127792062024-05-25 3:10:2648 days ago1716606626
0x7e012382...EBee93EE5
0.005 ETH
127792062024-05-25 3:10:2648 days ago1716606626
0x7e012382...EBee93EE5
0.005 ETH
127791652024-05-25 3:08:2648 days ago1716606506
0x7e012382...EBee93EE5
0.005 ETH
127791422024-05-25 3:07:1748 days ago1716606437
0x7e012382...EBee93EE5
0.005 ETH
127791422024-05-25 3:07:1748 days ago1716606437
0x7e012382...EBee93EE5
0.005 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
OrderBook

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 1 runs

Other Settings:
default evmVersion
File 1 of 11 : OrderBook.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

import "../libraries/math/SafeMath.sol";
import "../libraries/token/IERC20.sol";
import "../tokens/interfaces/IWETH.sol";
import "../libraries/token/SafeERC20.sol";
import "../libraries/utils/Address.sol";
import "../libraries/utils/ReentrancyGuard.sol";

import "./interfaces/IRouter.sol";
import "./interfaces/IVault.sol";
import "./interfaces/IOrderBook.sol";
import "./interfaces/IVaultUtils.sol";


contract OrderBook is ReentrancyGuard, IOrderBook {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;
    using Address for address payable;

    uint256 public constant PRICE_PRECISION = 1e30;
    uint256 public constant USDQ_PRECISION = 1e18;

    struct IncreaseOrder {
        address account;
        address purchaseToken;
        uint256 purchaseTokenAmount;
        address collateralToken;
        address indexToken;
        uint256 sizeDelta;
        uint256 triggerPrice;
        uint256 executionFee;
        bool isLong;
        bool triggerAboveThreshold;
    }
    struct DecreaseOrder {
        address account;
        address collateralToken;
        address receiveToken;
        uint256 collateralDelta;
        address indexToken;
        uint256 sizeDelta;
        uint256 triggerPrice;
        uint256 minOut;
        uint256 executionFee;
        bool isLong;
        bool triggerAboveThreshold;
        bool withdrawETH;
    }
    struct SwapOrder {
        address account;
        address[] path;
        uint256 amountIn;
        uint256 minOut;
        uint256 triggerRatio;
                uint256 executionFee;
        bool triggerAboveThreshold;
        bool shouldUnwrap;

    }

    mapping(address => mapping(uint256 => IncreaseOrder)) public increaseOrders;
    mapping(address => uint256) public increaseOrdersIndex;
    mapping(address => mapping(uint256 => DecreaseOrder)) public decreaseOrders;
    mapping(address => uint256) public decreaseOrdersIndex;
    mapping(address => mapping(uint256 => SwapOrder)) public swapOrders;
    mapping(address => uint256) public swapOrdersIndex;

    address public gov;
    address public weth;
    address public usdq;
    address public router;
    address public vault;
    address public orderExecutor;
    uint256 public minExecutionFee;
    uint256 public minPurchaseTokenAmountUsd;
    bool public isInitialized = false;

    event CreateIncreaseOrder(
        address indexed account,
        uint256 orderIndex,
        address purchaseToken,
        uint256 purchaseTokenAmount,
        address collateralToken,
        address indexToken,
        uint256 sizeDelta,
        bool isLong,
        uint256 triggerPrice,
        bool triggerAboveThreshold,
        uint256 executionFee
    );
    event CancelIncreaseOrder(
        address indexed account,
        uint256 orderIndex,
        address purchaseToken,
        uint256 purchaseTokenAmount,
        address collateralToken,
        address indexToken,
        uint256 sizeDelta,
        bool isLong,
        uint256 triggerPrice,
        bool triggerAboveThreshold,
        uint256 executionFee
    );
    event ExecuteIncreaseOrder(
        address indexed account,
        uint256 orderIndex,
        address purchaseToken,
        uint256 purchaseTokenAmount,
        address collateralToken,
        address indexToken,
        uint256 sizeDelta,
        bool isLong,
        uint256 triggerPrice,
        bool triggerAboveThreshold,
        uint256 executionFee,
        uint256 executionPrice
    );
    event UpdateIncreaseOrder(
        address indexed account,
        uint256 orderIndex,
        address collateralToken,
        address indexToken,
        bool isLong,
        uint256 sizeDelta,
        uint256 triggerPrice,
        bool triggerAboveThreshold
    );
    event CreateDecreaseOrder(
        address indexed account,
        uint256 orderIndex,
        address collateralToken,
        address receiveToken,
        uint256 collateralDelta,
        address indexToken,
        uint256 sizeDelta,
        bool isLong,
        uint256 triggerPrice,
        bool triggerAboveThreshold,
        uint256 executionFee,
        uint256 minOut,
        bool withdrawETH
    );

    event CancelDecreaseOrder(
        address indexed account,
        uint256 orderIndex,
        address collateralToken,
        uint256 collateralDelta,
        address indexToken,
        uint256 sizeDelta,
        bool isLong,
        uint256 triggerPrice,
        bool triggerAboveThreshold,
        uint256 executionFee
    );
    event ExecuteDecreaseOrder(
        address indexed account,
        uint256 orderIndex,
        address collateralToken,
        uint256 collateralDelta,
        address indexToken,
        uint256 sizeDelta,
        bool isLong,
        uint256 triggerPrice,
        bool triggerAboveThreshold,
        uint256 executionFee,
        uint256 executionPrice
    );
    event UpdateDecreaseOrder(
        address indexed account,
        uint256 orderIndex,
        address collateralToken,
        uint256 collateralDelta,
        address indexToken,
        uint256 sizeDelta,
        bool isLong,
        uint256 triggerPrice,
        bool triggerAboveThreshold
    );
    event CreateSwapOrder(
        address indexed account,
        uint256 orderIndex,
        address[] path,
        uint256 amountIn,
        uint256 minOut,
        uint256 triggerRatio,
        bool triggerAboveThreshold,
        bool shouldUnwrap,
        uint256 executionFee
    );
    event CancelSwapOrder(
        address indexed account,
        uint256 orderIndex,
        address[] path,
        uint256 amountIn,
        uint256 minOut,
        uint256 triggerRatio,
        bool triggerAboveThreshold,
        bool shouldUnwrap,
        uint256 executionFee
    );
    event UpdateSwapOrder(
        address indexed account,
        uint256 ordexIndex,
        address[] path,
        uint256 amountIn,
        uint256 minOut,
        uint256 triggerRatio,
        bool triggerAboveThreshold,
        bool shouldUnwrap,
        uint256 executionFee
    );
    event ExecuteSwapOrder(
        address indexed account,
        uint256 orderIndex,
        address[] path,
        uint256 amountIn,
        uint256 minOut,
        uint256 amountOut,
        uint256 triggerRatio,
        bool triggerAboveThreshold,
        bool shouldUnwrap,
        uint256 executionFee
    );

    event Initialize(
        address router,
        address vault,
        address weth,
        address usdq,
        uint256 minExecutionFee,
        uint256 minPurchaseTokenAmountUsd
    );
    event UpdateMinExecutionFee(uint256 minExecutionFee);
    event UpdateMinPurchaseTokenAmountUsd(uint256 minPurchaseTokenAmountUsd);
    event UpdateGov(address gov);
    event UpdateOrderExecutor(address orderExecutor);



    constructor() public {
        gov = msg.sender;
    }

    function _onlyGov() private view {
        require(msg.sender == gov, "OB: forbidden");
    }

    function _onlyOrderExecutor() private view {
        require(msg.sender == orderExecutor, "OB: forbidden");
    }

    function initialize(
        address _router,
        address _vault,
        address _weth,
        address _usdq,
        uint256 _minExecutionFee,
        uint256 _minPurchaseTokenAmountUsd
    ) external {
        _onlyGov();
        require(!isInitialized, "OB: error");
        isInitialized = true;

        router = _router;
        vault = _vault;
        weth = _weth;
        usdq = _usdq;
        minExecutionFee = _minExecutionFee;
        minPurchaseTokenAmountUsd = _minPurchaseTokenAmountUsd;

        emit Initialize(_router, _vault, _weth, _usdq, _minExecutionFee, _minPurchaseTokenAmountUsd);
    }

    receive() external payable {
        require(msg.sender == weth, "OB: invalid sender");
    }

    function setOrderExecutor(
        address _orderExecutor
    )external  {
        _onlyGov();
        orderExecutor = _orderExecutor;

        emit UpdateOrderExecutor(_orderExecutor);
    }


    function setMinExecutionFee(uint256 _minExecutionFee) external  {
        _onlyGov();
        minExecutionFee = _minExecutionFee;

        emit UpdateMinExecutionFee(_minExecutionFee);
    }

    function setMinPurchaseTokenAmountUsd(uint256 _minPurchaseTokenAmountUsd) external  {
        _onlyGov();
        minPurchaseTokenAmountUsd = _minPurchaseTokenAmountUsd;

        emit UpdateMinPurchaseTokenAmountUsd(_minPurchaseTokenAmountUsd);
    }

    function setGov(address _gov) external  {
        _onlyGov();
        require(_gov != address(0), "OB: new gov is the zero address");
        gov = _gov;

        emit UpdateGov(_gov);
    }

    function getSwapOrder(address _account, uint256 _orderIndex)
        public
        view
        override
        returns (
            address path0,
            address path1,
            address path2,
            uint256 amountIn,
            uint256 minOut,
            uint256 triggerRatio,
            bool triggerAboveThreshold,
            bool shouldUnwrap,
            uint256 executionFee
        )
    {
        SwapOrder memory order = swapOrders[_account][_orderIndex];
        return (
            order.path.length > 0 ? order.path[0] : address(0),
            order.path.length > 1 ? order.path[1] : address(0),
            order.path.length > 2 ? order.path[2] : address(0),
            order.amountIn,
            order.minOut,
            order.triggerRatio,
            order.triggerAboveThreshold,
            order.shouldUnwrap,
            order.executionFee
        );
    }

    function createSwapOrder(
        address[] memory _path,
        uint256 _amountIn,
        uint256 _minOut,
        uint256 _triggerRatio, // tokenB / tokenA
        bool _triggerAboveThreshold,
        uint256 _executionFee,
        bool _shouldWrap,
        bool _shouldUnwrap
    ) external payable nonReentrant {
        require(_path.length == 2 || _path.length == 3, "OB: invalid _path.length");
        require(_path[0] != _path[_path.length - 1], "OB: invalid _path");
        require(_path[0] != usdq && _path[_path.length - 1] != usdq, "OB: invalid token");
        require(_amountIn > 0, "OB: invalid _amountIn");
        require(_executionFee >= minExecutionFee, "OB: insufficient execution fee");

        // always need this call because of mandatory executionFee user has to transfer in ETH
        _transferInETH();

        if (_shouldWrap) {
            require(_path[0] == weth, "OB: only weth could be wrapped");
            require(msg.value == _executionFee.add(_amountIn), "OB: incorrect value transferred");
        } else {
            require(msg.value == _executionFee, "OB: incorrect execution fee transferred");
            IRouter(router).pluginTransfer(_path[0], msg.sender, address(this), _amountIn);
        }

        _createSwapOrder(msg.sender, _path, _amountIn, _minOut, _triggerRatio, _triggerAboveThreshold, _shouldUnwrap, _executionFee);
    }

    function _createSwapOrder(
        address _account,
        address[] memory _path,
        uint256 _amountIn,
        uint256 _minOut,
        uint256 _triggerRatio,
        bool _triggerAboveThreshold,
        bool _shouldUnwrap,
        uint256 _executionFee
    ) private {
        uint256 _orderIndex = swapOrdersIndex[_account];
        SwapOrder memory order = SwapOrder(_account, _path, _amountIn, _minOut, _triggerRatio, _executionFee, _triggerAboveThreshold, _shouldUnwrap);
        swapOrdersIndex[_account] = _orderIndex.add(1);
        swapOrders[_account][_orderIndex] = order;

        emit CreateSwapOrder(_account, _orderIndex, _path, _amountIn, _minOut, _triggerRatio, _triggerAboveThreshold, _shouldUnwrap, _executionFee);
    }

    function cancelMultiple(
        uint256[] memory _swapOrderIndexes,
        uint256[] memory _increaseOrderIndexes,
        uint256[] memory _decreaseOrderIndexes
    ) external {
        for (uint256 i = 0; i < _swapOrderIndexes.length; i++) {
            cancelSwapOrder(_swapOrderIndexes[i]);
        }
        for (uint256 i = 0; i < _increaseOrderIndexes.length; i++) {
            cancelIncreaseOrder(_increaseOrderIndexes[i]);
        }
        for (uint256 i = 0; i < _decreaseOrderIndexes.length; i++) {
            cancelDecreaseOrder(_decreaseOrderIndexes[i]);
        }
    }

    function cancelSwapOrder(uint256 _orderIndex) public nonReentrant {
        SwapOrder memory order = swapOrders[msg.sender][_orderIndex];
        require(order.account != address(0), "OB: no order");

        delete swapOrders[msg.sender][_orderIndex];

        if (order.path[0] == weth) {
            _transferOutETH(order.executionFee.add(order.amountIn), msg.sender);
        } else {
            IERC20(order.path[0]).safeTransfer(msg.sender, order.amountIn);
            _transferOutETH(order.executionFee, msg.sender);
        }

        emit CancelSwapOrder(
            msg.sender,
            _orderIndex,
            order.path,
            order.amountIn,
            order.minOut,
            order.triggerRatio,
            order.triggerAboveThreshold,
            order.shouldUnwrap,
            order.executionFee
        );
    }

    function validateSwapOrderPriceWithTriggerAboveThreshold(address[] memory _path, uint256 _triggerRatio) public view returns (bool) {
        require(_path.length == 2 || _path.length == 3, "OB: invalid _path.length");

        // limit orders don't need this validation because minOut is enough
        // so this validation handles scenarios for stop orders only
        // when a user wants to swap when a price of tokenB increases relative to tokenA
        address tokenA = _path[0];
        address tokenB = _path[_path.length - 1];
        uint256 tokenAPrice;
        uint256 tokenBPrice;

        tokenAPrice = IVault(vault).getMinPrice(tokenA);
        tokenBPrice = IVault(vault).getMaxPrice(tokenB);

        uint256 currentRatio = tokenBPrice.mul(PRICE_PRECISION).div(tokenAPrice);

        bool isValid = currentRatio > _triggerRatio;
        return isValid;
    }

    function updateSwapOrder(
        uint256 _orderIndex,
        uint256 _minOut,
        uint256 _triggerRatio,
        bool _triggerAboveThreshold
    ) external nonReentrant {
        SwapOrder storage order = swapOrders[msg.sender][_orderIndex];
        require(order.account != address(0), "OB: no order");

        order.minOut = _minOut;
        order.triggerRatio = _triggerRatio;
        order.triggerAboveThreshold = _triggerAboveThreshold;

        emit UpdateSwapOrder(msg.sender, _orderIndex, order.path, order.amountIn, _minOut, _triggerRatio, _triggerAboveThreshold, order.shouldUnwrap, order.executionFee);
    }

    function executeSwapOrder(
        address _account,
        uint256 _orderIndex,
        address payable _feeReceiver
    ) external override nonReentrant {
        _onlyOrderExecutor();
        SwapOrder memory order = swapOrders[_account][_orderIndex];
        require(order.account != address(0), "OB: no order");

        if (order.triggerAboveThreshold) {
            // gas optimisation
            // order.minAmount should prevent wrong price execution in case of simple limit order
            require(validateSwapOrderPriceWithTriggerAboveThreshold(order.path, order.triggerRatio), "OB: invalid price for execution");
        }

        delete swapOrders[_account][_orderIndex];

        IERC20(order.path[0]).safeTransfer(vault, order.amountIn);

        uint256 _amountOut;
        if (order.path[order.path.length - 1] == weth && order.shouldUnwrap) {
            _amountOut = _swap(order.path, order.minOut, address(this));
            _transferOutETH(_amountOut, payable(order.account));
        } else {
            _amountOut = _swap(order.path, order.minOut, order.account);
        }

        // pay executor
        _transferOutETH(order.executionFee, _feeReceiver);

        emit ExecuteSwapOrder(
            _account,
            _orderIndex,
            order.path,
            order.amountIn,
            order.minOut,
            _amountOut,
            order.triggerRatio,
            order.triggerAboveThreshold,
            order.shouldUnwrap,
            order.executionFee
        );
    }

    function validatePositionOrderPrice(
        bool _triggerAboveThreshold,
        uint256 _triggerPrice,
        address _indexToken,
        bool _maximizePrice,
        bool _raise
    ) public view returns (uint256, bool) {
        uint256 currentPrice = _maximizePrice ? IVault(vault).getMaxPrice(_indexToken) : IVault(vault).getMinPrice(_indexToken);
        bool isPriceValid = _triggerAboveThreshold ? currentPrice > _triggerPrice : currentPrice < _triggerPrice;
        if (_raise) {
            require(isPriceValid, "OB: invalid price for execution");
        }
        return (currentPrice, isPriceValid);
    }

    function getDecreaseOrder(address _account, uint256 _orderIndex)
        public
        view
        override
        returns (
            address collateralToken,
            uint256 collateralDelta,
            address indexToken,
            uint256 sizeDelta,
            bool isLong,
            uint256 triggerPrice,
            bool triggerAboveThreshold,
            uint256 executionFee
        )
    {
        DecreaseOrder memory order = decreaseOrders[_account][_orderIndex];
        return (order.collateralToken, order.collateralDelta, order.indexToken, order.sizeDelta, order.isLong, order.triggerPrice, order.triggerAboveThreshold, order.executionFee);
    }

    function getDecreaseOrderV2(address _account, uint256 _orderIndex)
        public
        view
        returns (
            address collateralToken,
            address receiveToken,
            uint256 collateralDelta,
            address indexToken,
            uint256 sizeDelta,
            bool isLong,
            uint256 triggerPrice,
            bool triggerAboveThreshold,
            uint256 executionFee
        )
    {
        DecreaseOrder memory order = decreaseOrders[_account][_orderIndex];
        return (order.collateralToken, order.receiveToken, order.collateralDelta, order.indexToken, order.sizeDelta, order.isLong, order.triggerPrice, order.triggerAboveThreshold, order.executionFee);
    }

    function getIncreaseOrder(address _account, uint256 _orderIndex)
        public
        view
        override
        returns (
            address purchaseToken,
            uint256 purchaseTokenAmount,
            address collateralToken,
            address indexToken,
            uint256 sizeDelta,
            bool isLong,
            uint256 triggerPrice,
            bool triggerAboveThreshold,
            uint256 executionFee
        )
    {
        IncreaseOrder memory order = increaseOrders[_account][_orderIndex];
        return (
            order.purchaseToken,
            order.purchaseTokenAmount,
            order.collateralToken,
            order.indexToken,
            order.sizeDelta,
            order.isLong,
            order.triggerPrice,
            order.triggerAboveThreshold,
            order.executionFee
        );
    }

    function createIncreaseOrder(
        address[] memory _path,
        uint256 _amountIn,
        address _indexToken,
        uint256 _minOut,
        uint256 _sizeDelta,
        address _collateralToken,
        bool _isLong,
        uint256 _triggerPrice,
        bool _triggerAboveThreshold,
        uint256 _executionFee,
        bool _shouldWrap
    ) external payable nonReentrant {
        // always need this call because of mandatory executionFee user has to transfer in ETH
        _transferInETH();

        require(_executionFee >= minExecutionFee, "OB: insufficient execution fee");
        if (_shouldWrap) {
            require(_path[0] == weth, "OB: only weth could be wrapped");
            require(msg.value == _executionFee.add(_amountIn), "OB: incorrect value transferred");
        } else {
            require(msg.value == _executionFee, "OB: incorrect execution fee transferred");
            IRouter(router).pluginTransfer(_path[0], msg.sender, address(this), _amountIn);
        }

        address _purchaseToken = _path[_path.length - 1];
        uint256 _purchaseTokenAmount;
        if (_path.length > 1) {
            require(_path[0] != _purchaseToken, "OB: invalid _path");
            IERC20(_path[0]).safeTransfer(vault, _amountIn);
            _purchaseTokenAmount = _swap(_path, _minOut, address(this));
        } else {
            _purchaseTokenAmount = _amountIn;
        }

        {
            uint256 _purchaseTokenAmountUsd = IVault(vault).tokenToUsdMin(_purchaseToken, _purchaseTokenAmount);
            require(_purchaseTokenAmountUsd >= minPurchaseTokenAmountUsd, "OB: insufficient collateral");
        }

        _createIncreaseOrder(
            msg.sender,
            _purchaseToken,
            _purchaseTokenAmount,
            _collateralToken,
            _indexToken,
            _sizeDelta,
            _isLong,
            _triggerPrice,
            _triggerAboveThreshold,
            _executionFee
        );
    }

    function _createIncreaseOrder(
        address _account,
        address _purchaseToken,
        uint256 _purchaseTokenAmount,
        address _collateralToken,
        address _indexToken,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _triggerPrice,
        bool _triggerAboveThreshold,
        uint256 _executionFee
    ) private {
        uint256 _orderIndex = increaseOrdersIndex[_account];
        IncreaseOrder memory order = IncreaseOrder(
            _account,
            _purchaseToken,
            _purchaseTokenAmount,
            _collateralToken,
            _indexToken,
            _sizeDelta,
            _triggerPrice,
            _executionFee,
            _isLong,
            _triggerAboveThreshold
        );
        increaseOrdersIndex[_account] = _orderIndex.add(1);
        increaseOrders[_account][_orderIndex] = order;

        emit CreateIncreaseOrder(
            _account,
            _orderIndex,
            _purchaseToken,
            _purchaseTokenAmount,
            _collateralToken,
            _indexToken,
            _sizeDelta,
            _isLong,
            _triggerPrice,
            _triggerAboveThreshold,
            _executionFee
        );
    }

    function updateIncreaseOrder(
        uint256 _orderIndex,
        uint256 _sizeDelta,
        uint256 _triggerPrice,
        bool _triggerAboveThreshold
    ) external nonReentrant {
        IncreaseOrder storage order = increaseOrders[msg.sender][_orderIndex];
        require(order.account != address(0), "OB: no order");

        order.triggerPrice = _triggerPrice;
        order.triggerAboveThreshold = _triggerAboveThreshold;
        order.sizeDelta = _sizeDelta;

        emit UpdateIncreaseOrder(msg.sender, _orderIndex, order.collateralToken, order.indexToken, order.isLong, _sizeDelta, _triggerPrice, _triggerAboveThreshold);
    }

    function cancelIncreaseOrder(uint256 _orderIndex) public nonReentrant {
        IncreaseOrder memory order = increaseOrders[msg.sender][_orderIndex];
        require(order.account != address(0), "OB: no order");

        delete increaseOrders[msg.sender][_orderIndex];

        if (order.purchaseToken == weth) {
            _transferOutETH(order.executionFee.add(order.purchaseTokenAmount), msg.sender);
        } else {
            IERC20(order.purchaseToken).safeTransfer(msg.sender, order.purchaseTokenAmount);
            _transferOutETH(order.executionFee, msg.sender);
        }

        emit CancelIncreaseOrder(
            order.account,
            _orderIndex,
            order.purchaseToken,
            order.purchaseTokenAmount,
            order.collateralToken,
            order.indexToken,
            order.sizeDelta,
            order.isLong,
            order.triggerPrice,
            order.triggerAboveThreshold,
            order.executionFee
        );
    }

    function executeIncreaseOrder(
        address _address,
        uint256 _orderIndex,
        address payable _feeReceiver
    ) external override nonReentrant {
        _onlyOrderExecutor();
        IncreaseOrder memory order = increaseOrders[_address][_orderIndex];
        require(order.account != address(0), "OB: no order");

        // increase long should use max price
        // increase short should use min price
        (uint256 currentPrice, ) = validatePositionOrderPrice(order.triggerAboveThreshold, order.triggerPrice, order.indexToken, order.isLong, true);

        delete increaseOrders[_address][_orderIndex];

        IERC20(order.purchaseToken).safeTransfer(vault, order.purchaseTokenAmount);

        if (order.purchaseToken != order.collateralToken) {
            address[] memory path = new address[](2);
            path[0] = order.purchaseToken;
            path[1] = order.collateralToken;

            uint256 amountOut = _swap(path, 0, address(this));
            IERC20(order.collateralToken).safeTransfer(vault, amountOut);
        }

        IRouter(router).pluginIncreasePosition(order.account, order.collateralToken, order.indexToken, order.sizeDelta, order.isLong);

        // pay executor
        _transferOutETH(order.executionFee, _feeReceiver);

        emit ExecuteIncreaseOrder(
            order.account,
            _orderIndex,
            order.purchaseToken,
            order.purchaseTokenAmount,
            order.collateralToken,
            order.indexToken,
            order.sizeDelta,
            order.isLong,
            order.triggerPrice,
            order.triggerAboveThreshold,
            order.executionFee,
            currentPrice
        );
    }

    function createDecreaseOrder(
        address _indexToken,
        uint256 _sizeDelta,
        address _collateralToken,
        address _receiveToken,
        uint256 _collateralDelta,
        bool _isLong,
        uint256 _triggerPrice,
        bool _triggerAboveThreshold,
        uint256 _minOut,
        bool _withdrawETH
    ) external payable nonReentrant {

        _transferInETH();
        
        require(msg.value > minExecutionFee, "OB: insufficient execution fee");
        if (_withdrawETH) {
            if(_receiveToken != address(0))
                require(_receiveToken == weth, "OB: invalid _receiveToken");
            else   
                require(_collateralToken == weth, "OB: invalid _collateralToken");  
        }

        

        _createDecreaseOrder(msg.sender, _collateralToken,_receiveToken, _collateralDelta, _indexToken, _sizeDelta, _isLong, _triggerPrice, _triggerAboveThreshold, _minOut, _withdrawETH);
    }

    function _createDecreaseOrder(
        address _account,
        address _collateralToken,
        address _receiveToken,
        uint256 _collateralDelta,
        address _indexToken,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _triggerPrice,
        bool _triggerAboveThreshold,
        uint256 _minOut,
        bool _withdrawETH
    ) private {
        uint256 _orderIndex = decreaseOrdersIndex[_account];
        DecreaseOrder memory order = DecreaseOrder(
            _account,
            _collateralToken,
            _receiveToken,
            _collateralDelta,
            _indexToken,
            _sizeDelta,
            _triggerPrice,
            _minOut,
            msg.value,
            _isLong,
            _triggerAboveThreshold,
            _withdrawETH
        );
        decreaseOrdersIndex[_account] = _orderIndex.add(1);
        decreaseOrders[_account][_orderIndex] = order;

        emit CreateDecreaseOrder(_account, _orderIndex, _collateralToken, _receiveToken, _collateralDelta, _indexToken, _sizeDelta, _isLong, _triggerPrice, _triggerAboveThreshold, msg.value,_minOut,_withdrawETH);

    }


    function executeDecreaseOrder(
        address _address,
        uint256 _orderIndex,
        address payable _feeReceiver
    ) external override nonReentrant {
        _onlyOrderExecutor();
        DecreaseOrder memory order = decreaseOrders[_address][_orderIndex];
        require(order.account != address(0), "OB: no order");

        // decrease long should use min price
        // decrease short should use max price
        (uint256 currentPrice, ) = validatePositionOrderPrice(order.triggerAboveThreshold, order.triggerPrice, order.indexToken, !order.isLong, true);

        delete decreaseOrders[_address][_orderIndex];

        uint256 amountOut = IRouter(router).pluginDecreasePosition(
            order.account,
            order.collateralToken,
            order.indexToken,
            order.collateralDelta,
            order.sizeDelta,
            order.isLong,
            address(this)
        );

        bool isSwapExecuted;

        if (order.receiveToken != address(0)) {
            IVaultUtils vaultUtils = IVault(vault).vaultUtils();
            
            uint256 maxIn =vaultUtils.getMaxAmountIn(order.collateralToken, order.receiveToken);

            if(amountOut<=maxIn){                
                IERC20(order.collateralToken).safeTransfer(vault, amountOut);
                amountOut = _vaultSwap(order.collateralToken, order.receiveToken, order.minOut, address(this));
                isSwapExecuted = true;
            }
        }
 

        if (order.withdrawETH && (isSwapExecuted || order.receiveToken == address(0))) {
            _transferOutETH(amountOut, payable(order.account));
        } else {
            if (order.receiveToken != address(0) && isSwapExecuted) {
                IERC20(order.receiveToken).safeTransfer(order.account, amountOut);
            }else{
                IERC20(order.collateralToken).safeTransfer(order.account, amountOut);
            }    
        }

        _transferOutETH(order.executionFee, _feeReceiver);

        emit ExecuteDecreaseOrder(
            order.account,
            _orderIndex,
            order.collateralToken,
            order.collateralDelta,
            order.indexToken,
            order.sizeDelta,
            order.isLong,
            order.triggerPrice,
            order.triggerAboveThreshold,
            order.executionFee,
            currentPrice
        );
    }

    function cancelDecreaseOrder(uint256 _orderIndex) public nonReentrant {
        DecreaseOrder memory order = decreaseOrders[msg.sender][_orderIndex];
        require(order.account != address(0), "OB: no order");

        delete decreaseOrders[msg.sender][_orderIndex];
        _transferOutETH(order.executionFee, msg.sender);

        emit CancelDecreaseOrder(
            order.account,
            _orderIndex,
            order.collateralToken,
            order.collateralDelta,
            order.indexToken,
            order.sizeDelta,
            order.isLong,
            order.triggerPrice,
            order.triggerAboveThreshold,
            order.executionFee
        );
    }

    function updateDecreaseOrder(
        uint256 _orderIndex,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        uint256 _triggerPrice,
        bool _triggerAboveThreshold
    ) external nonReentrant {
        DecreaseOrder storage order = decreaseOrders[msg.sender][_orderIndex];
        require(order.account != address(0), "OB: no order");

        order.triggerPrice = _triggerPrice;
        order.triggerAboveThreshold = _triggerAboveThreshold;
        order.sizeDelta = _sizeDelta;
        order.collateralDelta = _collateralDelta;

        emit UpdateDecreaseOrder(
            msg.sender,
            _orderIndex,
            order.collateralToken,
            _collateralDelta,
            order.indexToken,
            _sizeDelta,
            order.isLong,
            _triggerPrice,
            _triggerAboveThreshold
        );
    }

    function _transferInETH() private {
        if (msg.value != 0) {
            IWETH(weth).deposit{value: msg.value}();
        }
    }

    function _transferOutETH(uint256 _amountOut, address payable _receiver) private {
        IWETH(weth).withdraw(_amountOut);
        _receiver.sendValue(_amountOut);
    }

    function _swap(address[] memory _path, uint256 _minOut, address _receiver) private returns (uint256) {
        if (_path.length == 2) {
            return _vaultSwap(_path[0], _path[1], _minOut, _receiver);
        }
        if (_path.length == 3) {
            uint256 midOut = _vaultSwap(_path[0], _path[1], 0, address(this));
            IERC20(_path[1]).safeTransfer(vault, midOut);
            return _vaultSwap(_path[1], _path[2], _minOut, _receiver);
        }

        revert("OB: invalid _path.length");
    }

    function _vaultSwap(
        address _tokenIn,
        address _tokenOut,
        uint256 _minOut,
        address _receiver
    ) private returns (uint256) {
        uint256 amountOut;

        // if (_tokenOut == usdq) {
        //     // buyUSDQ
        //     amountOut = IVault(vault).buyUSDQ(_tokenIn, _receiver);
        // } else if (_tokenIn == usdq) {
        //     // sellUSDQ
        //     amountOut = IVault(vault).sellUSDQ(_tokenOut, _receiver);
        // } else {
            // swap
            amountOut = IVault(vault).swap(_tokenIn, _tokenOut, _receiver);
        // }

        require(amountOut >= _minOut, "OB: insufficient amountOut");
        return amountOut;
    }
}

File 2 of 11 : IOrderBook.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IOrderBook {
	function getSwapOrder(address _account, uint256 _orderIndex) external view returns (
        address path0, 
        address path1,
        address path2,
        uint256 amountIn,
        uint256 minOut,
        uint256 triggerRatio,
        bool triggerAboveThreshold,
        bool shouldUnwrap,
        uint256 executionFee
    );

    function getIncreaseOrder(address _account, uint256 _orderIndex) external view returns (
        address purchaseToken, 
        uint256 purchaseTokenAmount,
        address collateralToken,
        address indexToken,
        uint256 sizeDelta,
        bool isLong,
        uint256 triggerPrice,
        bool triggerAboveThreshold,
        uint256 executionFee
    );

    function getDecreaseOrder(address _account, uint256 _orderIndex) external view returns (
        address collateralToken,
        uint256 collateralDelta,
        address indexToken,
        uint256 sizeDelta,
        bool isLong,
        uint256 triggerPrice,
        bool triggerAboveThreshold,
        uint256 executionFee
    );

    function executeSwapOrder(address, uint256, address payable) external;
    function executeDecreaseOrder(address, uint256, address payable) external;
    function executeIncreaseOrder(address, uint256, address payable) external;
}

File 3 of 11 : IRouter.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IRouter {
    function addPlugin(address _plugin) external;
    function pluginTransfer(address _token, address _account, address _receiver, uint256 _amount) external;
    function pluginIncreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _sizeDelta, bool _isLong) external;
    function pluginDecreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address _receiver) external returns (uint256);
    function swap(address[] memory _path, uint256 _amountIn, uint256 _minOut, address _receiver) external;
}

File 4 of 11 : IVault.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "./IVaultUtils.sol";

interface IVault {
    function isInitialized() external view returns (bool);
    function isSwapEnabled() external view returns (bool);
    function isLeverageEnabled() external view returns (bool);

    function setVaultUtils(IVaultUtils _vaultUtils) external;
    function setError(uint256 _errorCode, string calldata _error) external;

    function router() external view returns (address);
    function usdq() external view returns (address);
    function gov() external view returns (address);
    function vaultUtils() external view returns (IVaultUtils);

    function whitelistedTokenCount() external view returns (uint256);
    function maxLeverage() external view returns (uint256);

    function minProfitTime() external view returns (uint256);
    function hasDynamicFees() external view returns (bool);
    function fundingInterval() external view returns (uint256);
    function totalTokenWeights() external view returns (uint256);
    function getTargetUsdqAmount(address _token) external view returns (uint256);

    function inManagerMode() external view returns (bool);
    function inPrivateLiquidationMode() external view returns (bool);

    function maxGasPrice() external view returns (uint256);

    function approvedRouters(address _account, address _router) external view returns (bool);
    function isLiquidator(address _account) external view returns (bool);
    function isManager(address _account) external view returns (bool);

    function minProfitBasisPoints(address _token) external view returns (uint256);
    function tokenBalances(address _token) external view returns (uint256);
    function lastFundingTimes(address _token) external view returns (uint256);

    function setMaxLeverage(uint256 _maxLeverage) external;
    function setInManagerMode(bool _inManagerMode) external;
    function setManager(address _manager, bool _isManager) external;
    function setIsSwapEnabled(bool _isSwapEnabled) external;
    function setIsLeverageEnabled(bool _isLeverageEnabled) external;
    function setMaxGasPrice(uint256 _maxGasPrice) external;
    function setUsdqAmount(address _token, uint256 _amount) external;
    function setBufferAmount(address _token, uint256 _amount) external;
    function setMaxGlobalShortSize(address _token, uint256 _amount) external;
    function setInPrivateLiquidationMode(bool _inPrivateLiquidationMode) external;
    function setLiquidator(address _liquidator, bool _isActive) external;

    function setFundingRate(uint256 _fundingInterval, uint256 _fundingRateFactor, uint256 _stableFundingRateFactor) external;

    function setFees(
        uint256 _taxBasisPoints,
        uint256 _stableTaxBasisPoints,
        uint256 _mintBurnFeeBasisPoints,
        uint256 _swapFeeBasisPoints,
        uint256 _stableSwapFeeBasisPoints,
        uint256 _marginFeeBasisPoints,
        uint256 _liquidationFeeUsd,
        uint256 _minProfitTime,
        bool _hasDynamicFees
    ) external;

    function setTokenConfig(
        address _token,
        uint256 _tokenDecimals,
        uint256 _redemptionBps,
        uint256 _minProfitBps,
        uint256 _maxUsdqAmount,
        bool _isStable,
        bool _isShortable
    ) external;

    function setPriceFeed(address _priceFeed) external;
    function withdrawFees(address _token, address _receiver) external returns (uint256);

    function directPoolDeposit(address _token) external;
    function buyUSDQ(address _token, address _receiver) external returns (uint256);
    function sellUSDQ(address _token, address _receiver) external returns (uint256);
    function swap(address _tokenIn, address _tokenOut, address _receiver) external returns (uint256);
    function increasePosition(address _account, address _collateralToken, address _indexToken, uint256 _sizeDelta, bool _isLong) external;
    function decreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address _receiver) external returns (uint256);
    function validateLiquidation(address _account, address _collateralToken, address _indexToken, bool _isLong, bool _raise) external view returns (uint256, uint256);
    function liquidatePosition(address _account, address _collateralToken, address _indexToken, bool _isLong, address _feeReceiver) external;
    function tokenToUsdMin(address _token, uint256 _tokenAmount) external view returns (uint256);

    function priceFeed() external view returns (address);
    function fundingRateFactor() external view returns (uint256);
    function stableFundingRateFactor() external view returns (uint256);
    function cumulativeFundingRates(address _token) external view returns (uint256);
    function getNextFundingRate(address _token) external view returns (uint256);
    function getFeeBasisPoints(address _token, uint256 _usdqDelta, uint256 _feeBasisPoints, uint256 _taxBasisPoints, bool _increment) external view returns (uint256);

    function liquidationFeeUsd() external view returns (uint256);
    function taxBasisPoints() external view returns (uint256);
    function stableTaxBasisPoints() external view returns (uint256);
    function mintBurnFeeBasisPoints() external view returns (uint256);
    function swapFeeBasisPoints() external view returns (uint256);
    function stableSwapFeeBasisPoints() external view returns (uint256);
    function marginFeeBasisPoints() external view returns (uint256);

    function allWhitelistedTokensLength() external view returns (uint256);
    function allWhitelistedTokens(uint256) external view returns (address);
    function whitelistedTokens(address _token) external view returns (bool);
    function stableTokens(address _token) external view returns (bool);
    function shortableTokens(address _token) external view returns (bool);
    function feeReserves(address _token) external view returns (uint256);
    function globalShortSizes(address _token) external view returns (uint256);
    function globalShortAveragePrices(address _token) external view returns (uint256);
    function maxGlobalShortSizes(address _token) external view returns (uint256);
    function tokenDecimals(address _token) external view returns (uint256);
    function tokenWeights(address _token) external view returns (uint256);
    function guaranteedUsd(address _token) external view returns (uint256);
    function poolAmounts(address _token) external view returns (uint256);
    function bufferAmounts(address _token) external view returns (uint256);
    function reservedAmounts(address _token) external view returns (uint256);
    function usdqAmounts(address _token) external view returns (uint256);
    function maxUsdqAmounts(address _token) external view returns (uint256);
    function getRedemptionAmount(address _token, uint256 _usdqAmount) external view returns (uint256);
    function getMaxPrice(address _token) external view returns (uint256);
    function getMinPrice(address _token) external view returns (uint256);

    function getDelta(address _indexToken, uint256 _size, uint256 _averagePrice, bool _isLong, uint256 _lastIncreasedTime) external view returns (bool, uint256);
    function getPosition(address _account, address _collateralToken, address _indexToken, bool _isLong) external view returns (uint256, uint256, uint256, uint256, uint256, uint256, bool, uint256);
}

File 5 of 11 : IVaultUtils.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IVaultUtils {
    function updateCumulativeFundingRate(address _collateralToken, address _indexToken) external returns (bool);
    function validateIncreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _sizeDelta, bool _isLong) external view;
    function validateDecreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address _receiver) external view;
    function validateLiquidation(address _account, address _collateralToken, address _indexToken, bool _isLong, bool _raise) external view returns (uint256, uint256);
    function getEntryFundingRate(address _collateralToken, address _indexToken, bool _isLong) external view returns (uint256);
    function getPositionFee(address _account, address _collateralToken, address _indexToken, bool _isLong, uint256 _sizeDelta) external view returns (uint256);
    function getFundingFee(address _account, address _collateralToken, address _indexToken, bool _isLong, uint256 _size, uint256 _entryFundingRate) external view returns (uint256);
    function getBuyUsdqFeeBasisPoints(address _token, uint256 _usdqAmount) external view returns (uint256);
    function getSellUsdqFeeBasisPoints(address _token, uint256 _usdqAmount) external view returns (uint256);
    function getSwapFeeBasisPoints(address _tokenIn, address _tokenOut, uint256 _usdqAmount) external view returns (uint256);
    function getFeeBasisPoints(address _token, uint256 _usdqDelta, uint256 _feeBasisPoints, uint256 _taxBasisPoints, bool _increment) external view returns (uint256);
    function getMaxAmountIn(
        address _tokenIn,
        address _tokenOut
    ) external view returns (uint256);
}

File 6 of 11 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @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, 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) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * 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);
        uint256 c = a - b;

        return c;
    }

    /**
     * @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) {
        // 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 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts 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) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts 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) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message 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,
        string memory errorMessage
    ) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 7 of 11 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @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 8 of 11 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "./IERC20.sol";
import "../math/SafeMath.sol";
import "../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using 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 9 of 11 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.12;

/**
 * @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.3._
     */
    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.3._
     */
    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 11 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() internal {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 11 of 11 : IWETH.sol
//SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

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

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"orderIndex","type":"uint256"},{"indexed":false,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"indexed":false,"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"}],"name":"CancelDecreaseOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"orderIndex","type":"uint256"},{"indexed":false,"internalType":"address","name":"purchaseToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"purchaseTokenAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"indexed":false,"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"}],"name":"CancelIncreaseOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"orderIndex","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"path","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"triggerRatio","type":"uint256"},{"indexed":false,"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"indexed":false,"internalType":"bool","name":"shouldUnwrap","type":"bool"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"}],"name":"CancelSwapOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"orderIndex","type":"uint256"},{"indexed":false,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"address","name":"receiveToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"indexed":false,"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minOut","type":"uint256"},{"indexed":false,"internalType":"bool","name":"withdrawETH","type":"bool"}],"name":"CreateDecreaseOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"orderIndex","type":"uint256"},{"indexed":false,"internalType":"address","name":"purchaseToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"purchaseTokenAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"indexed":false,"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"}],"name":"CreateIncreaseOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"orderIndex","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"path","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"triggerRatio","type":"uint256"},{"indexed":false,"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"indexed":false,"internalType":"bool","name":"shouldUnwrap","type":"bool"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"}],"name":"CreateSwapOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"orderIndex","type":"uint256"},{"indexed":false,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"indexed":false,"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionPrice","type":"uint256"}],"name":"ExecuteDecreaseOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"orderIndex","type":"uint256"},{"indexed":false,"internalType":"address","name":"purchaseToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"purchaseTokenAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"indexed":false,"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionPrice","type":"uint256"}],"name":"ExecuteIncreaseOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"orderIndex","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"path","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"triggerRatio","type":"uint256"},{"indexed":false,"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"indexed":false,"internalType":"bool","name":"shouldUnwrap","type":"bool"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"}],"name":"ExecuteSwapOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"router","type":"address"},{"indexed":false,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"address","name":"weth","type":"address"},{"indexed":false,"internalType":"address","name":"usdq","type":"address"},{"indexed":false,"internalType":"uint256","name":"minExecutionFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minPurchaseTokenAmountUsd","type":"uint256"}],"name":"Initialize","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"orderIndex","type":"uint256"},{"indexed":false,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"indexed":false,"internalType":"bool","name":"triggerAboveThreshold","type":"bool"}],"name":"UpdateDecreaseOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"gov","type":"address"}],"name":"UpdateGov","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"orderIndex","type":"uint256"},{"indexed":false,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"indexed":false,"internalType":"bool","name":"triggerAboveThreshold","type":"bool"}],"name":"UpdateIncreaseOrder","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minExecutionFee","type":"uint256"}],"name":"UpdateMinExecutionFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minPurchaseTokenAmountUsd","type":"uint256"}],"name":"UpdateMinPurchaseTokenAmountUsd","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"orderExecutor","type":"address"}],"name":"UpdateOrderExecutor","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"ordexIndex","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"path","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"triggerRatio","type":"uint256"},{"indexed":false,"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"indexed":false,"internalType":"bool","name":"shouldUnwrap","type":"bool"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"}],"name":"UpdateSwapOrder","type":"event"},{"inputs":[],"name":"PRICE_PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDQ_PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_orderIndex","type":"uint256"}],"name":"cancelDecreaseOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_orderIndex","type":"uint256"}],"name":"cancelIncreaseOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_swapOrderIndexes","type":"uint256[]"},{"internalType":"uint256[]","name":"_increaseOrderIndexes","type":"uint256[]"},{"internalType":"uint256[]","name":"_decreaseOrderIndexes","type":"uint256[]"}],"name":"cancelMultiple","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_orderIndex","type":"uint256"}],"name":"cancelSwapOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"_receiveToken","type":"address"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_triggerPrice","type":"uint256"},{"internalType":"bool","name":"_triggerAboveThreshold","type":"bool"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"bool","name":"_withdrawETH","type":"bool"}],"name":"createDecreaseOrder","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_triggerPrice","type":"uint256"},{"internalType":"bool","name":"_triggerAboveThreshold","type":"bool"},{"internalType":"uint256","name":"_executionFee","type":"uint256"},{"internalType":"bool","name":"_shouldWrap","type":"bool"}],"name":"createIncreaseOrder","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"uint256","name":"_triggerRatio","type":"uint256"},{"internalType":"bool","name":"_triggerAboveThreshold","type":"bool"},{"internalType":"uint256","name":"_executionFee","type":"uint256"},{"internalType":"bool","name":"_shouldWrap","type":"bool"},{"internalType":"bool","name":"_shouldUnwrap","type":"bool"}],"name":"createSwapOrder","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"decreaseOrders","outputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"collateralToken","type":"address"},{"internalType":"address","name":"receiveToken","type":"address"},{"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"internalType":"uint256","name":"minOut","type":"uint256"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"internalType":"bool","name":"withdrawETH","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"decreaseOrdersIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"},{"internalType":"address payable","name":"_feeReceiver","type":"address"}],"name":"executeDecreaseOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"},{"internalType":"address payable","name":"_feeReceiver","type":"address"}],"name":"executeIncreaseOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"},{"internalType":"address payable","name":"_feeReceiver","type":"address"}],"name":"executeSwapOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"}],"name":"getDecreaseOrder","outputs":[{"internalType":"address","name":"collateralToken","type":"address"},{"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"internalType":"uint256","name":"executionFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"}],"name":"getDecreaseOrderV2","outputs":[{"internalType":"address","name":"collateralToken","type":"address"},{"internalType":"address","name":"receiveToken","type":"address"},{"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"internalType":"uint256","name":"executionFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"}],"name":"getIncreaseOrder","outputs":[{"internalType":"address","name":"purchaseToken","type":"address"},{"internalType":"uint256","name":"purchaseTokenAmount","type":"uint256"},{"internalType":"address","name":"collateralToken","type":"address"},{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"internalType":"uint256","name":"executionFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"}],"name":"getSwapOrder","outputs":[{"internalType":"address","name":"path0","type":"address"},{"internalType":"address","name":"path1","type":"address"},{"internalType":"address","name":"path2","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"minOut","type":"uint256"},{"internalType":"uint256","name":"triggerRatio","type":"uint256"},{"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"internalType":"bool","name":"shouldUnwrap","type":"bool"},{"internalType":"uint256","name":"executionFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gov","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"increaseOrders","outputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"purchaseToken","type":"address"},{"internalType":"uint256","name":"purchaseTokenAmount","type":"uint256"},{"internalType":"address","name":"collateralToken","type":"address"},{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"internalType":"uint256","name":"triggerPrice","type":"uint256"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"bool","name":"triggerAboveThreshold","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"increaseOrdersIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"},{"internalType":"address","name":"_vault","type":"address"},{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_usdq","type":"address"},{"internalType":"uint256","name":"_minExecutionFee","type":"uint256"},{"internalType":"uint256","name":"_minPurchaseTokenAmountUsd","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minExecutionFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minPurchaseTokenAmountUsd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"orderExecutor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_gov","type":"address"}],"name":"setGov","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minExecutionFee","type":"uint256"}],"name":"setMinExecutionFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minPurchaseTokenAmountUsd","type":"uint256"}],"name":"setMinPurchaseTokenAmountUsd","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_orderExecutor","type":"address"}],"name":"setOrderExecutor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"swapOrders","outputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"minOut","type":"uint256"},{"internalType":"uint256","name":"triggerRatio","type":"uint256"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bool","name":"triggerAboveThreshold","type":"bool"},{"internalType":"bool","name":"shouldUnwrap","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"swapOrdersIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_orderIndex","type":"uint256"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"uint256","name":"_triggerPrice","type":"uint256"},{"internalType":"bool","name":"_triggerAboveThreshold","type":"bool"}],"name":"updateDecreaseOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_orderIndex","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"uint256","name":"_triggerPrice","type":"uint256"},{"internalType":"bool","name":"_triggerAboveThreshold","type":"bool"}],"name":"updateIncreaseOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_orderIndex","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"uint256","name":"_triggerRatio","type":"uint256"},{"internalType":"bool","name":"_triggerAboveThreshold","type":"bool"}],"name":"updateSwapOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usdq","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_triggerAboveThreshold","type":"bool"},{"internalType":"uint256","name":"_triggerPrice","type":"uint256"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"bool","name":"_maximizePrice","type":"bool"},{"internalType":"bool","name":"_raise","type":"bool"}],"name":"validatePositionOrderPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"uint256","name":"_triggerRatio","type":"uint256"}],"name":"validateSwapOrderPriceWithTriggerAboveThreshold","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

6080604052600f805460ff1916905534801561001a57600080fd5b506001600055600780546001600160a01b0319163317905561570780620000426000396000f3fe6080604052600436106101d95760003560e01c8062cf066b1461023957806301ff6b7a1461027e578063026032ee1461029357806307c7edc31461031e5780630d5cc9381461036157806311d9444a1461038b57806312d43a51146103ce578063269ae6c2146103ff5780632701808c146104ca5780632b7d62901461055e578063392e53cd146105fc5780633fc8cef31461062557806347e0bbd01461063a5780634c54f0b01461066457806356623185146106ce57806363ae2103146106e3578063756677a1146106f857806379221fa21461072b578063807c5600146107aa5780638de10c2e1461095c57806395082d25146109715780639983ee1b146109865780639e71b0f0146109c4578063a397ea54146109ee578063a849d64414610a32578063aec2245514610a47578063b142a4b014610a7a578063c4a1821b14610b64578063c86b0f7d14610c14578063cfad57a214610c52578063d0d40cd614610c85578063d38ab51914610d18578063d3bab1d114610d5b578063d566d0ca14610def578063d7c41c7914610e22578063f2d2e01b14610e7b578063f882ac0714610f28578063f887ea4014610f52578063fb8c099f14610f67578063fbfa77cf14610fd2578063fc2cee6214610fe757610234565b36610234576008546001600160a01b03163314610232576040805162461bcd60e51b815260206004820152601260248201527127a11d1034b73b30b634b21039b2b73232b960711b604482015290519081900360640190fd5b005b600080fd5b34801561024557600080fd5b5061026c6004803603602081101561025c57600080fd5b50356001600160a01b0316611011565b60408051918252519081900360200190f35b34801561028a57600080fd5b5061026c611023565b34801561029f57600080fd5b506102cc600480360360408110156102b657600080fd5b506001600160a01b03813516906020013561102f565b604080516001600160a01b03998a168152602081019890985295909716868601526060860193909352901515608085015260a0840152151560c083015260e08201929092529051908190036101000190f35b34801561032a57600080fd5b506102326004803603606081101561034157600080fd5b506001600160a01b0381358116916020810135916040909101351661112e565b34801561036d57600080fd5b506102326004803603602081101561038457600080fd5b5035611546565b34801561039757600080fd5b50610232600480360360608110156103ae57600080fd5b506001600160a01b03813581169160208101359160409091013516611589565b3480156103da57600080fd5b506103e3611b19565b604080516001600160a01b039092168252519081900360200190f35b610232600480360361010081101561041657600080fd5b810190602081018135600160201b81111561043057600080fd5b82018360208201111561044257600080fd5b803590602001918460208302840111600160201b8311171561046357600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955050823593505050602081013590604081013590606081013515159060808101359060a081013515159060c001351515611b28565b3480156104d657600080fd5b50610503600480360360408110156104ed57600080fd5b506001600160a01b038135169060200135611f5f565b604080516001600160a01b039a8b168152988a1660208a0152888101979097529490971660608701526080860192909252151560a085015260c084015292151560e08301526101008201929092529051908190036101200190f35b34801561056a57600080fd5b506105976004803603604081101561058157600080fd5b506001600160a01b038135169060200135612063565b604080516001600160a01b039b8c168152998b1660208b015289810198909852958916606089015293909716608087015260a086019190915260c085015260e08401949094529215156101008301529115156101208201529051908190036101400190f35b34801561060857600080fd5b506106116120d4565b604080519115158252519081900360200190f35b34801561063157600080fd5b506103e36120dd565b34801561064657600080fd5b506102326004803603602081101561065d57600080fd5b50356120ec565b34801561067057600080fd5b506106b5600480360360a081101561068757600080fd5b5080351515906020810135906001600160a01b036040820135169060608101351515906080013515156123e8565b6040805192835290151560208301528051918290030190f35b3480156106da57600080fd5b506103e3612555565b3480156106ef57600080fd5b5061026c612564565b34801561070457600080fd5b506102326004803603602081101561071b57600080fd5b50356001600160a01b031661256a565b34801561073757600080fd5b506107646004803603604081101561074e57600080fd5b506001600160a01b0381351690602001356125c6565b604080516001600160a01b03909816885260208801969096528686019490945260608601929092526080850152151560a0840152151560c0830152519081900360e00190f35b3480156107b657600080fd5b50610232600480360360608110156107cd57600080fd5b810190602081018135600160201b8111156107e757600080fd5b8201836020820111156107f957600080fd5b803590602001918460208302840111600160201b8311171561081a57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561086957600080fd5b82018360208201111561087b57600080fd5b803590602001918460208302840111600160201b8311171561089c57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156108eb57600080fd5b8201836020820111156108fd57600080fd5b803590602001918460208302840111600160201b8311171561091e57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550612619945050505050565b34801561096857600080fd5b5061026c6126b1565b34801561097d57600080fd5b5061026c6126b7565b34801561099257600080fd5b50610232600480360360808110156109a957600080fd5b508035906020810135906040810135906060013515156126c7565b3480156109d057600080fd5b50610232600480360360208110156109e757600080fd5b5035612827565b3480156109fa57600080fd5b50610232600480360360a0811015610a1157600080fd5b50803590602081013590604081013590606081013590608001351515612ad0565b348015610a3e57600080fd5b506103e3612c3b565b348015610a5357600080fd5b5061026c60048036036020811015610a6a57600080fd5b50356001600160a01b0316612c4a565b6102326004803603610160811015610a9157600080fd5b810190602081018135600160201b811115610aab57600080fd5b820183602082011115610abd57600080fd5b803590602001918460208302840111600160201b83111715610ade57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505082359350506001600160a01b036020830135811692604081013592506060810135916080820135169060a081013515159060c08101359060e08101351515906101008101359061012001351515612c5c565b348015610b7057600080fd5b5061061160048036036040811015610b8757600080fd5b810190602081018135600160201b811115610ba157600080fd5b820183602082011115610bb357600080fd5b803590602001918460208302840111600160201b83111715610bd457600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505091359250613077915050565b348015610c2057600080fd5b5061023260048036036080811015610c3757600080fd5b5080359060208101359060408101359060600135151561322b565b348015610c5e57600080fd5b5061023260048036036020811015610c7557600080fd5b50356001600160a01b03166133f5565b348015610c9157600080fd5b50610cbe60048036036040811015610ca857600080fd5b506001600160a01b0381351690602001356134ac565b604080516001600160a01b039a8b168152988a1660208a015296909816878701526060870194909452608086019290925260a0850152151560c0840152151560e08301526101008201929092529051908190036101200190f35b348015610d2457600080fd5b5061023260048036036060811015610d3b57600080fd5b506001600160a01b03813581169160208101359160409091013516613669565b348015610d6757600080fd5b50610d9460048036036040811015610d7e57600080fd5b506001600160a01b038135169060200135613ad4565b604080516001600160a01b039a8b1681526020810199909952968916888801529490971660608701526080860192909252151560a085015260c084015292151560e08301526101008201929092529051908190036101200190f35b348015610dfb57600080fd5b5061026c60048036036020811015610e1257600080fd5b50356001600160a01b0316613bb8565b348015610e2e57600080fd5b50610232600480360360c0811015610e4557600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359091169060808101359060a00135613bca565b348015610e8757600080fd5b50610eb460048036036040811015610e9e57600080fd5b506001600160a01b038135169060200135613cd7565b604080516001600160a01b039d8e1681529b8d1660208d0152998c168b8b015260608b019890985295909916608089015260a088019390935260c087019190915260e08601526101008501529315156101208401529215156101408301529115156101608201529051908190036101800190f35b348015610f3457600080fd5b5061023260048036036020811015610f4b57600080fd5b5035613d59565b348015610f5e57600080fd5b506103e3614097565b6102326004803603610140811015610f7e57600080fd5b506001600160a01b038135811691602081013591604082013581169160608101359091169060808101359060a081013515159060c08101359060e081013515159061010081013590610120013515156140a6565b348015610fde57600080fd5b506103e361423a565b348015610ff357600080fd5b506102326004803603602081101561100a57600080fd5b5035614249565b60066020526000908152604090205481565b670de0b6b3a764000081565b6000806000806000806000806110436153a4565b505050506001600160a01b03968716600090815260036020818152604080842099845298815291889020885161018081018a5281548b16815260018201548b1693810184905260028201548b16998101999099529081015460608901819052600482015490991660808901819052600582015460a08a01819052600683015460c08b01819052600784015460e08c01526008840154610100808d0182905260099095015460ff80821615156101208f01819052968204811615156101408f0181905262010000909204161515610160909d019c909c52949c929a919950929750919550909350909150565b60026000541415611174576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b600260005561118161428c565b611189615408565b6001600160a01b0380851660009081526005602090815260408083208784528252918290208251610100810184528154909416845260018101805484518185028101850190955280855291938584019390929083018282801561121557602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116111f7575b50505091835250506002820154602082015260038201546040820152600482015460608201526005820154608082015260069091015460ff808216151560a084015261010090910416151560c09091015280519091506001600160a01b03166112b4576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b8060c001511561130f576112d081602001518260800151613077565b61130f576040805162461bcd60e51b815260206004820152601f60248201526000805160206156b1833981519152604482015290519081900360640190fd5b6001600160a01b0384166000908152600560209081526040808320868452909152812080546001600160a01b03191681559061134e600183018261545a565b506000600282018190556003820181905560048201819055600582018190556006909101805461ffff19169055600b546040830151602084015180516113c1946001600160a01b0390941693906113a157fe5b60200260200101516001600160a01b03166142dd9092919063ffffffff16565b600854602082015180516000926001600160a01b0316919060001981019081106113e757fe5b60200260200101516001600160a01b031614801561140657508160e001515b156114335761141e8260200151836060015130614334565b905061142e818360000151614463565b61144d565b61144a826020015183606001518460000151614334565b90505b61145b8260a0015184614463565b846001600160a01b03167f7e1fe496989eea92b738a562dbf9c0ae6aa6fcf3f1ef09e95ee4f7603721706b858460200151856040015186606001518688608001518960c001518a60e001518b60a00151604051808a8152602001806020018981526020018881526020018781526020018681526020018515158152602001841515815260200183815260200182810382528a818151815260200191508051906020019060200280838360005b8381101561151f578181015183820152602001611507565b505050509050019a505050505050505050505060405180910390a250506001600055505050565b61154e6144e0565b600e8190556040805182815290517fe46d9daf6d25f7615efa1d0183b90ac6759d85014b598e409aadf0fd918d59a69181900360200190a150565b600260005414156115cf576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b60026000556115dc61428c565b6115e46153a4565b506001600160a01b038084166000908152600360208181526040808420878552825292839020835161018081018552815486168082526001830154871693820193909352600282015486169481019490945291820154606084015260048201549093166080830152600581015460a0830152600681015460c0830152600781015460e083015260088101546101008084019190915260099091015460ff808216151561012085015291810482161515610140840152620100009004161515610160820152906116e9576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b600061170c8261014001518360c0015184608001518561012001511560016123e8565b506001600160a01b0380871660009081526003602081815260408084208a8552825280842080546001600160a01b0319908116825560018201805482169055600282018054821690559381018590556004808201805490951690945560058101859055600681018590556007810185905560088101859055600901805462ffffff19169055600a5488518984015160808b015160608c015160a08d01516101208e01518751632662166b60e01b8152958c1699860199909952928a16602485015290891660448401526064830152608482015293151560a48501523060c4850152905195965092949290931692632662166b9260e48084019382900301818787803b15801561181a57600080fd5b505af115801561182e573d6000803e3d6000fd5b505050506040513d602081101561184457600080fd5b505160408401519091506000906001600160a01b0316156119a257600b5460408051630d577c1960e31b815290516000926001600160a01b031691636abbe0c8916004808301926020929190829003018186803b1580156118a457600080fd5b505afa1580156118b8573d6000803e3d6000fd5b505050506040513d60208110156118ce57600080fd5b505160208681015160408089015181516309374a1760e21b81526001600160a01b03938416600482015290831660248201529051939450600093918516926324dd285c92604480840193829003018186803b15801561192c57600080fd5b505afa158015611940573d6000803e3d6000fd5b505050506040513d602081101561195657600080fd5b5051905080841161199f57600b546020870151611980916001600160a01b039182169116866142dd565b611998866020015187604001518860e001513061452f565b9350600192505b50505b83610160015180156119c6575080806119c6575060408401516001600160a01b0316155b156119de576119d9828560000151614463565b611a36565b60408401516001600160a01b0316158015906119f75750805b15611a1957835160408501516119d9916001600160a01b0390911690846142dd565b83516020850151611a36916001600160a01b0390911690846142dd565b611a4584610100015186614463565b83600001516001600160a01b03167f9a382661d6573da86db000471303be6f0b2b1bb66089b08e3c16a85d7b6e94f8878660200151876060015188608001518960a001518a61012001518b60c001518c61014001518d61010001518d604051808b81526020018a6001600160a01b03168152602001898152602001886001600160a01b03168152602001878152602001861515815260200185815260200184151581526020018381526020018281526020019a505050505050505050505060405180910390a2505060016000555050505050565b6007546001600160a01b031681565b60026000541415611b6e576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b6002600081905588511480611b84575087516003145b611bc3576040805162461bcd60e51b81526020600482015260186024820152600080516020615650833981519152604482015290519081900360640190fd5b87600189510381518110611bd357fe5b60200260200101516001600160a01b031688600081518110611bf157fe5b60200260200101516001600160a01b03161415611c49576040805162461bcd60e51b815260206004820152601160248201527009e847440d2dcecc2d8d2c840bee0c2e8d607b1b604482015290519081900360640190fd5b60095488516001600160a01b03909116908990600090611c6557fe5b60200260200101516001600160a01b031614158015611cb4575060095488516001600160a01b039091169089906000198101908110611ca057fe5b60200260200101516001600160a01b031614155b611cf9576040805162461bcd60e51b815260206004820152601160248201527027a11d1034b73b30b634b2103a37b5b2b760791b604482015290519081900360640190fd5b60008711611d46576040805162461bcd60e51b815260206004820152601560248201527427a11d1034b73b30b634b2102fb0b6b7bab73a24b760591b604482015290519081900360640190fd5b600d54831015611d8b576040805162461bcd60e51b815260206004820152601e6024820152600080516020615610833981519152604482015290519081900360640190fd5b611d93614618565b8115611e565760085488516001600160a01b03909116908990600090611db557fe5b60200260200101516001600160a01b031614611e06576040805162461bcd60e51b815260206004820152601e6024820152600080516020615670833981519152604482015290519081900360640190fd5b611e108388614689565b3414611e51576040805162461bcd60e51b815260206004820152601f6024820152600080516020615630833981519152604482015290519081900360640190fd5b611f40565b823414611e945760405162461bcd60e51b81526004018080602001828103825260278152602001806155696027913960400191505060405180910390fd5b600a5488516001600160a01b0390911690631b827878908a90600090611eb657fe5b602002602001015133308b6040518563ffffffff1660e01b815260040180856001600160a01b03168152602001846001600160a01b03168152602001836001600160a01b03168152602001828152602001945050505050600060405180830381600087803b158015611f2757600080fd5b505af1158015611f3b573d6000803e3d6000fd5b505050505b611f50338989898989878a6146e1565b50506001600055505050505050565b6000806000806000806000806000611f756153a4565b505050506001600160a01b0397881660009081526003602081815260408084209a845299815291899020895161018081018b5281548c16815260018201548c1693810184905260028201548c169a81018b905291810154606083018190526004820154909b1660808301819052600582015460a08401819052600683015460c08501819052600784015460e0860152600884015461010080870182905260099095015460ff808216151561012089018190529682048116151561014089018190526201000090920416151561016090970196909652959e9c9d9c929b50909950919750909550909350909150565b600160208181526000938452604080852090915291835291208054918101546002820154600383015460048401546005850154600686015460078701546008909701546001600160a01b03988916989687169795969485169593909416939192909160ff808216916101009004168a565b600f5460ff1681565b6008546001600160a01b031681565b60026000541415612132576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b600260005561213f61547b565b5033600090815260016020818152604080842085855282529283902083516101408101855281546001600160a01b039081168083529483015481169382019390935260028201549481019490945260038101548216606085015260048101549091166080840152600581015460a0840152600681015460c0840152600781015460e08401526008015460ff808216151561010080860191909152909104161515610120830152612225576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b3360009081526001602081815260408084208685528252832080546001600160a01b031990811682559281018054841690556002810184905560038101805484169055600481018054909316909255600582018390556006820183905560078201929092556008908101805461ffff1916905554908201516001600160a01b03908116911614156122d9576122d46122ce82604001518360e0015161468990919063ffffffff16565b33614463565b61230d565b6122ff33826040015183602001516001600160a01b03166142dd9092919063ffffffff16565b61230d8160e0015133614463565b80600001516001600160a01b03167fd500f34e0ec655b7614ae42e1d9c666d5e4dde909a1297829f8c5ecf00805d328383602001518460400151856060015186608001518760a001518861010001518960c001518a61012001518b60e00151604051808b81526020018a6001600160a01b03168152602001898152602001886001600160a01b03168152602001876001600160a01b03168152602001868152602001851515815260200184815260200183151581526020018281526020019a505050505050505050505060405180910390a250506001600055565b60008060008461247057600b54604080516340d3096b60e11b81526001600160a01b038981166004830152915191909216916381a612d6916024808301926020929190829003018186803b15801561243f57600080fd5b505afa158015612453573d6000803e3d6000fd5b505050506040513d602081101561246957600080fd5b50516124ea565b600b5460408051637092736960e11b81526001600160a01b0389811660048301529151919092169163e124e6d2916024808301926020929190829003018186803b1580156124bd57600080fd5b505afa1580156124d1573d6000803e3d6000fd5b505050506040513d60208110156124e757600080fd5b50515b90506000886124fb578782106124ff565b8782115b905084156125475780612547576040805162461bcd60e51b815260206004820152601f60248201526000805160206156b1833981519152604482015290519081900360640190fd5b909890975095505050505050565b6009546001600160a01b031681565b600d5481565b6125726144e0565b600c80546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f137786eccca8fbeccb32feaef3be23f20ee9427b52ff1acf92511e5e093eaeab9181900360200190a150565b600560208181526000938452604080852090915291835291208054600282015460038301546004840154948401546006909401546001600160a01b03909316949193909260ff8082169161010090041687565b60005b83518110156126495761264184828151811061263457fe5b6020026020010151613d59565b60010161261c565b5060005b825181101561267a5761267283828151811061266557fe5b60200260200101516120ec565b60010161264d565b5060005b81518110156126ab576126a382828151811061269657fe5b6020026020010151612827565b60010161267e565b50505050565b600e5481565b68327cb2734119d3b7a9601e1b81565b6002600054141561270d576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b60026000908155338152600160209081526040808320878452909152902080546001600160a01b0316612776576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b60068101839055600881018054831515610100810261ff001990921691909117918290556005830186905560038301546004840154604080518a81526001600160a01b039384166020820152919092168183015260ff93909316151560608401526080830187905260a0830186905260c08301919091525133917f0a0360dd5c354235bbf8d386ba3b24ef8134088e0785677de1504df219d9149a919081900360e00190a250506001600055505050565b6002600054141561286d576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b600260005561287a6153a4565b5033600090815260036020818152604080842085855282529283902083516101808101855281546001600160a01b039081168083526001840154821694830194909452600283015481169582019590955292810154606084015260048101549093166080830152600583015460a0830152600683015460c0830152600783015460e083015260088301546101008084019190915260099093015460ff808216151561012085015293810484161515610140840152620100009004909216151561016082015290612980576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b336000818152600360208181526040808420878552909152822080546001600160a01b0319908116825560018201805482169055600282018054821690559181018390556004810180549092169091556005810182905560068101829055600781018290556008810191909155600901805462ffffff19169055610100820151612a0991614463565b80600001516001600160a01b03167f1154174c82984656b028c8021671988f60a346497e56fe02554761184f82a075838360200151846060015185608001518660a001518761012001518860c001518961014001518a6101000151604051808a8152602001896001600160a01b03168152602001888152602001876001600160a01b0316815260200186815260200185151581526020018481526020018315158152602001828152602001995050505050505050505060405180910390a250506001600055565b60026000541415612b16576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b60026000908155338152600360209081526040808320888452909152902080546001600160a01b0316612b7f576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b6006810183905560098101805461ff0019166101008415158181029290921792839055600584018790556003840188905560018401546004850154604080518c81526001600160a01b0393841660208201528082018c90529290911660608301526080820189905260ff909416151560a082015260c0810187905260e0810192909252915133927f75781255bc71c83f89f29e5a2599f2c174a562d2cd8f2e818a47f132e7280498928290030190a25050600160005550505050565b600c546001600160a01b031681565b60026020526000908152604090205481565b60026000541415612ca2576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b6002600055612caf614618565b600d54821015612cf4576040805162461bcd60e51b815260206004820152601e6024820152600080516020615610833981519152604482015290519081900360640190fd5b8015612db7576008548b516001600160a01b03909116908c90600090612d1657fe5b60200260200101516001600160a01b031614612d67576040805162461bcd60e51b815260206004820152601e6024820152600080516020615670833981519152604482015290519081900360640190fd5b612d71828b614689565b3414612db2576040805162461bcd60e51b815260206004820152601f6024820152600080516020615630833981519152604482015290519081900360640190fd5b612ea1565b813414612df55760405162461bcd60e51b81526004018080602001828103825260278152602001806155696027913960400191505060405180910390fd5b600a548b516001600160a01b0390911690631b827878908d90600090612e1757fe5b602002602001015133308e6040518563ffffffff1660e01b815260040180856001600160a01b03168152602001846001600160a01b03168152602001836001600160a01b03168152602001828152602001945050505050600060405180830381600087803b158015612e8857600080fd5b505af1158015612e9c573d6000803e3d6000fd5b505050505b60008b60018d510381518110612eb357fe5b60200260200101519050600060018d511115612f7157816001600160a01b03168d600081518110612ee057fe5b60200260200101516001600160a01b03161415612f38576040805162461bcd60e51b815260206004820152601160248201527009e847440d2dcecc2d8d2c840bee0c2e8d607b1b604482015290519081900360640190fd5b612f5f600b60009054906101000a90046001600160a01b03168d8f6000815181106113a157fe5b612f6a8d8b30614334565b9050612f74565b508a5b600b5460408051630a48d5a960e01b81526001600160a01b0385811660048301526024820185905291516000939290921691630a48d5a991604480820192602092909190829003018186803b158015612fcc57600080fd5b505afa158015612fe0573d6000803e3d6000fd5b505050506040513d6020811015612ff657600080fd5b5051600e54909150811015613050576040805162461bcd60e51b815260206004820152601b60248201527a13d08e881a5b9cdd59999a58da595b9d0818dbdb1b185d195c985b602a1b604482015290519081900360640190fd5b506130633383838b8f8e8d8d8d8d6148f0565b505060016000555050505050505050505050565b600082516002148061308a575082516003145b6130c9576040805162461bcd60e51b81526020600482015260186024820152600080516020615650833981519152604482015290519081900360640190fd5b6000836000815181106130d857fe5b602002602001015190506000846001865103815181106130f457fe5b602090810291909101810151600b54604080516340d3096b60e11b81526001600160a01b0387811660048301529151939550600094859492909316926381a612d692602480840193829003018186803b15801561315057600080fd5b505afa158015613164573d6000803e3d6000fd5b505050506040513d602081101561317a57600080fd5b5051600b5460408051637092736960e11b81526001600160a01b038781166004830152915193955091169163e124e6d291602480820192602092909190829003018186803b1580156131cb57600080fd5b505afa1580156131df573d6000803e3d6000fd5b505050506040513d60208110156131f557600080fd5b50519050600061321b836132158468327cb2734119d3b7a9601e1b614bcc565b90614c25565b8710955050505050505b92915050565b60026000541415613271576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b60026000908155338152600560209081526040808320878452909152902080546001600160a01b03166132da576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b838160030181905550828160040181905550818160060160006101000a81548160ff021916908315150217905550336001600160a01b03167fa7f9f4a25eb76f5ec01b1a429d95d6a00833f0f137c88827c58799a1c1ff0dfe868360010184600201548888888860060160019054906101000a900460ff16896005015460405180898152602001806020018881526020018781526020018681526020018515158152602001841515815260200183815260200182810382528981815481526020019150805480156133d457602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116133b6575b5050995050505050505050505060405180910390a250506001600055505050565b6133fd6144e0565b6001600160a01b038116613458576040805162461bcd60e51b815260206004820152601f60248201527f4f423a206e657720676f7620697320746865207a65726f206164647265737300604482015290519081900360640190fd5b600780546001600160a01b0383166001600160a01b0319909116811790915560408051918252517fe24c39186e9137521953beaa8446e71f55b8f12296984f9d4273ceb1af728d909181900360200190a150565b60008060008060008060008060006134c2615408565b6001600160a01b03808d1660009081526005602090815260408083208f84528252918290208251610100810184528154909416845260018101805484518185028101850190955280855291938584019390929083018282801561354e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613530575b5050509183525050600282015460208083019190915260038301546040830152600483015460608301526005830154608083015260069092015460ff808216151560a084015261010090910416151560c090910152810151519091506135b55760006135cf565b80602001516000815181106135c657fe5b60200260200101515b6001826020015151116135e35760006135fd565b81602001516001815181106135f457fe5b60200260200101515b60028360200151511161361157600061362b565b826020015160028151811061362257fe5b60200260200101515b8360400151846060015185608001518660c001518760e001518860a00151995099509950995099509950995099509950509295985092959850929598565b600260005414156136af576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b60026000556136bc61428c565b6136c461547b565b506001600160a01b038084166000908152600160208181526040808420878552825292839020835161014081018552815486168082529382015486169281019290925260028101549382019390935260038301548416606082015260048301549093166080840152600582015460a0840152600682015460c0840152600782015460e084015260089091015460ff8082161515610100808601919091529091041615156101208301526137ad576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b60006137cf8261012001518360c00151846080015185610100015160016123e8565b506001600160a01b0380871660009081526001602081815260408084208a8552825280842080546001600160a01b031990811682559381018054851690556002810185905560038101805485169055600481018054909416909355600583018490556006830184905560078301939093556008909101805461ffff19169055600b54918601519086015193945061386d9383169291909116906142dd565b81606001516001600160a01b031682602001516001600160a01b0316146139455760408051600280825260608083018452926020830190803683370190505090508260200151816000815181106138c057fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508260600151816001815181106138f257fe5b60200260200101906001600160a01b031690816001600160a01b031681525050600061392082600030614334565b600b546060860151919250613942916001600160a01b039081169116836142dd565b50505b600a5482516060840151608085015160a086015161010087015160408051630f8ee8bb60e11b81526001600160a01b03968716600482015294861660248601529285166044850152606484019190915215156084830152519190921691631f1dd1769160a480830192600092919082900301818387803b1580156139c857600080fd5b505af11580156139dc573d6000803e3d6000fd5b505050506139ee8260e0015184614463565b81600001516001600160a01b03167f7fb1c74d1ea6aa1c9c585e17ce8274c8ff98745e85e7459b73f87d784494f58e8584602001518560400151866060015187608001518860a001518961010001518a60c001518b61012001518c60e001518c604051808c81526020018b6001600160a01b031681526020018a8152602001896001600160a01b03168152602001886001600160a01b03168152602001878152602001861515815260200185815260200184151581526020018381526020018281526020019b50505050505050505050505060405180910390a250506001600055505050565b6000806000806000806000806000613aea61547b565b505050506001600160a01b0397881660009081526001602081815260408084209a845299815291899020895161014081018b5281548c168152918101548b1692820183905260028101549982018a905260038101548b16606083018190526004820154909b1660808301819052600582015460a08401819052600683015460c08501819052600784015460e0860181905260089094015460ff8082161515610100808901829052909204161515610120909601869052959e9c9d9c929b509099509397509295509093509150565b60046020526000908152604090205481565b613bd26144e0565b600f5460ff1615613c16576040805162461bcd60e51b815260206004820152600960248201526827a11d1032b93937b960b91b604482015290519081900360640190fd5b600f805460ff19166001179055600a80546001600160a01b038089166001600160a01b03199283168117909355600b8054898316908416811790915560088054898416908516811790915560098054938916939094168317909355600d869055600e8590556040805194855260208501919091528381019290925260608301526080820184905260a08201839052517fcfb7ef8749fafc8da2af1ba3d025479ffc4e58f7dc420113e112512a3bda59639181900360c00190a1505050505050565b6003602081815260009384526040808520909152918352912080546001820154600283015493830154600484015460058501546006860154600787015460088801546009909801546001600160a01b039788169996881698968816979596959094169492939192909160ff80821691610100810482169162010000909104168c565b60026000541415613d9f576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b6002600055613dac615408565b33600090815260056020908152604080832085845282529182902082516101008101845281546001600160a01b0316815260018201805485518186028101860190965280865291949293858101939290830182828015613e3557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613e17575b50505091835250506002820154602082015260038201546040820152600482015460608201526005820154608082015260069091015460ff808216151560a084015261010090910416151560c09091015280519091506001600160a01b0316613ed4576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b336000908152600560209081526040808320858452909152812080546001600160a01b031916815590613f0a600183018261545a565b506000600282018190556003820181905560048201819055600582018190556006909101805461ffff19169055600854602083015180516001600160a01b03909216929091613f5557fe5b60200260200101516001600160a01b03161415613f8f57613f8a6122ce82604001518360a0015161468990919063ffffffff16565b613fb7565b613fa933826040015183602001516000815181106113a157fe5b613fb78160a0015133614463565b336001600160a01b03167fefd66d4f9c2f880c70aedeb5b26a44fb474cea07e5d6c533f2d27c303d5d94538383602001518460400151856060015186608001518760c001518860e001518960a00151604051808981526020018060200188815260200187815260200186815260200185151581526020018415158152602001838152602001828103825289818151815260200191508051906020019060200280838360005b8381101561407457818101518382015260200161405c565b50505050905001995050505050505050505060405180910390a250506001600055565b600a546001600160a01b031681565b600260005414156140ec576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b60026000556140f9614618565b600d54341161413d576040805162461bcd60e51b815260206004820152601e6024820152600080516020615610833981519152604482015290519081900360640190fd5b8015614216576001600160a01b038716156141b5576008546001600160a01b038881169116146141b0576040805162461bcd60e51b815260206004820152601960248201527827a11d1034b73b30b634b2102fb932b1b2b4bb32aa37b5b2b760391b604482015290519081900360640190fd5b614216565b6008546001600160a01b03898116911614614216576040805162461bcd60e51b815260206004820152601c60248201527b27a11d1034b73b30b634b2102fb1b7b63630ba32b930b62a37b5b2b760211b604482015290519081900360640190fd5b614229338989898e8e8b8b8b8b8b614c64565b505060016000555050505050505050565b600b546001600160a01b031681565b6142516144e0565b600d8190556040805182815290517fbde5eafdc37b81830d70124cddccaaa6d034e71dda3c8fc18a959ca76a7cbcfc9181900360200190a150565b600c546001600160a01b031633146142db576040805162461bcd60e51b815260206004820152600d60248201526c27a11d103337b93134b23232b760991b604482015290519081900360640190fd5b565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261432f908490614f8d565b505050565b600083516002141561437b576143748460008151811061435057fe5b60200260200101518560018151811061436557fe5b6020026020010151858561452f565b905061445c565b8351600314156144215760006143bc8560008151811061439757fe5b6020026020010151866001815181106143ac57fe5b602002602001015160003061452f565b90506143e5600b60009054906101000a90046001600160a01b031682876001815181106113a157fe5b614419856001815181106143f557fe5b60200260200101518660028151811061440a57fe5b6020026020010151868661452f565b91505061445c565b6040805162461bcd60e51b81526020600482015260186024820152600080516020615650833981519152604482015290519081900360640190fd5b9392505050565b60085460408051632e1a7d4d60e01b81526004810185905290516001600160a01b0390921691632e1a7d4d9160248082019260009290919082900301818387803b1580156144b057600080fd5b505af11580156144c4573d6000803e3d6000fd5b506144dc925050506001600160a01b0382168361503e565b5050565b6007546001600160a01b031633146142db576040805162461bcd60e51b815260206004820152600d60248201526c27a11d103337b93134b23232b760991b604482015290519081900360640190fd5b600b5460408051634998b10960e11b81526001600160a01b03878116600483015286811660248301528481166044830152915160009384931691639331621291606480830192602092919082900301818787803b15801561458f57600080fd5b505af11580156145a3573d6000803e3d6000fd5b505050506040513d60208110156145b957600080fd5b505190508381101561460f576040805162461bcd60e51b815260206004820152601a60248201527913d08e881a5b9cdd59999a58da595b9d08185b5bdd5b9d13dd5d60321b604482015290519081900360640190fd5b95945050505050565b34156142db57600860009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561466e57600080fd5b505af1158015614682573d6000803e3d6000fd5b5050505050565b60008282018381101561445c576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b6001600160a01b038816600090815260066020526040902054614702615408565b6040518061010001604052808b6001600160a01b031681526020018a81526020018981526020018881526020018781526020018481526020018615158152602001851515815250905061475f60018361468990919063ffffffff16565b6001600160a01b038b8116600090815260066020908152604080832094909455600581528382208683528152929020835181546001600160a01b031916921691909117815582820151805184936147bd9260018501929101906154cf565b5060408201518160020155606082015181600301556080820151816004015560a0820151816005015560c08201518160060160006101000a81548160ff02191690831515021790555060e08201518160060160016101000a81548160ff021916908315150217905550905050896001600160a01b03167fdf06bb56ffc4029dc0b62b68bb5bbadea93a38b530cefc9b81afb742a6555d88838b8b8b8b8b8b8b604051808981526020018060200188815260200187815260200186815260200185151581526020018415158152602001838152602001828103825289818151815260200191508051906020019060200280838360005b838110156148ca5781810151838201526020016148b2565b50505050905001995050505050505050505060405180910390a250505050505050505050565b6001600160a01b038a1660009081526002602052604090205461491161547b565b6040518061014001604052808d6001600160a01b031681526020018c6001600160a01b031681526020018b81526020018a6001600160a01b03168152602001896001600160a01b031681526020018881526020018681526020018481526020018715158152602001851515815250905061499560018361468990919063ffffffff16565b600260008e6001600160a01b03166001600160a01b031681526020019081526020016000208190555080600160008e6001600160a01b03166001600160a01b03168152602001908152602001600020600084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506040820151816002015560608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a0820151816005015560c0820151816006015560e082015181600701556101008201518160080160006101000a81548160ff0219169083151502179055506101208201518160080160016101000a81548160ff0219169083151502179055509050508b6001600160a01b03167fb27b9afe3043b93788c40cfc3cc73f5d928a2e40f3ba01820b246426de8fa1b9838d8d8d8d8d8d8d8d8d604051808b81526020018a6001600160a01b03168152602001898152602001886001600160a01b03168152602001876001600160a01b03168152602001868152602001851515815260200184815260200183151581526020018281526020019a505050505050505050505060405180910390a2505050505050505050505050565b600082614bdb57506000613225565b82820282848281614be857fe5b041461445c5760405162461bcd60e51b81526004018080602001828103825260218152602001806156906021913960400191505060405180910390fd5b600061445c83836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b815250615123565b6001600160a01b038b16600090815260046020526040902054614c856153a4565b6040518061018001604052808e6001600160a01b031681526020018d6001600160a01b031681526020018c6001600160a01b031681526020018b81526020018a6001600160a01b03168152602001898152602001878152602001858152602001348152602001881515815260200186151581526020018415158152509050614d1760018361468990919063ffffffff16565b600460008f6001600160a01b03166001600160a01b031681526020019081526020016000208190555080600360008f6001600160a01b03166001600160a01b03168152602001908152602001600020600084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160020160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506060820151816003015560808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a0820151816005015560c0820151816006015560e0820151816007015561010082015181600801556101208201518160090160006101000a81548160ff0219169083151502179055506101408201518160090160016101000a81548160ff0219169083151502179055506101608201518160090160026101000a81548160ff0219169083151502179055509050508c6001600160a01b03167fc61ede3cf3bb8f4f08fc3a1da4329703fe53fe2708ea53bc7f260026dc03a4be838e8e8e8e8e8e8e8e348f8f604051808d81526020018c6001600160a01b031681526020018b6001600160a01b031681526020018a8152602001896001600160a01b031681526020018881526020018715158152602001868152602001851515815260200184815260200183815260200182151581526020019c5050505050505050505050505060405180910390a250505050505050505050505050565b6060614fe2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166151c59092919063ffffffff16565b80519091501561432f5780806020019051602081101561500157600080fd5b505161432f5760405162461bcd60e51b815260040180806020018281038252602a8152602001806156d1602a913960400191505060405180910390fd5b80471015615093576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d80600081146150de576040519150601f19603f3d011682016040523d82523d6000602084013e6150e3565b606091505b505090508061432f5760405162461bcd60e51b815260040180806020018281038252603a8152602001806155b0603a913960400191505060405180910390fd5b600081836151af5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561517457818101518382015260200161515c565b50505050905090810190601f1680156151a15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816151bb57fe5b0495945050505050565b60606151d484846000856151dc565b949350505050565b60608247101561521d5760405162461bcd60e51b81526004018080602001828103825260268152602001806155ea6026913960400191505060405180910390fd5b61522685615338565b615277576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106152b65780518252601f199092019160209182019101615297565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114615318576040519150601f19603f3d011682016040523d82523d6000602084013e61531d565b606091505b509150915061532d82828661533e565b979650505050505050565b3b151590565b6060831561534d57508161445c565b82511561535d5782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561517457818101518382015260200161515c565b6040805161018081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081019190915290565b60405180610100016040528060006001600160a01b0316815260200160608152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b50805460008255906000526020600020908101906154789190615534565b50565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915290565b828054828255906000526020600020908101928215615524579160200282015b8281111561552457825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906154ef565b50615530929150615549565b5090565b5b808211156155305760008155600101615535565b5b808211156155305780546001600160a01b031916815560010161554a56fe4f423a20696e636f727265637420657865637574696f6e20666565207472616e736665727265645265656e7472616e637947756172643a207265656e7472616e742063616c6c00416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4f423a20696e73756666696369656e7420657865637574696f6e2066656500004f423a20696e636f72726563742076616c7565207472616e73666572726564004f423a20696e76616c6964205f706174682e6c656e67746800000000000000004f423a206f6e6c79207765746820636f756c6420626520777261707065640000536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f423a20696e76616c696420707269636520666f7220657865637574696f6e005361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c634300060c000a

Deployed Bytecode

0x6080604052600436106101d95760003560e01c8062cf066b1461023957806301ff6b7a1461027e578063026032ee1461029357806307c7edc31461031e5780630d5cc9381461036157806311d9444a1461038b57806312d43a51146103ce578063269ae6c2146103ff5780632701808c146104ca5780632b7d62901461055e578063392e53cd146105fc5780633fc8cef31461062557806347e0bbd01461063a5780634c54f0b01461066457806356623185146106ce57806363ae2103146106e3578063756677a1146106f857806379221fa21461072b578063807c5600146107aa5780638de10c2e1461095c57806395082d25146109715780639983ee1b146109865780639e71b0f0146109c4578063a397ea54146109ee578063a849d64414610a32578063aec2245514610a47578063b142a4b014610a7a578063c4a1821b14610b64578063c86b0f7d14610c14578063cfad57a214610c52578063d0d40cd614610c85578063d38ab51914610d18578063d3bab1d114610d5b578063d566d0ca14610def578063d7c41c7914610e22578063f2d2e01b14610e7b578063f882ac0714610f28578063f887ea4014610f52578063fb8c099f14610f67578063fbfa77cf14610fd2578063fc2cee6214610fe757610234565b36610234576008546001600160a01b03163314610232576040805162461bcd60e51b815260206004820152601260248201527127a11d1034b73b30b634b21039b2b73232b960711b604482015290519081900360640190fd5b005b600080fd5b34801561024557600080fd5b5061026c6004803603602081101561025c57600080fd5b50356001600160a01b0316611011565b60408051918252519081900360200190f35b34801561028a57600080fd5b5061026c611023565b34801561029f57600080fd5b506102cc600480360360408110156102b657600080fd5b506001600160a01b03813516906020013561102f565b604080516001600160a01b03998a168152602081019890985295909716868601526060860193909352901515608085015260a0840152151560c083015260e08201929092529051908190036101000190f35b34801561032a57600080fd5b506102326004803603606081101561034157600080fd5b506001600160a01b0381358116916020810135916040909101351661112e565b34801561036d57600080fd5b506102326004803603602081101561038457600080fd5b5035611546565b34801561039757600080fd5b50610232600480360360608110156103ae57600080fd5b506001600160a01b03813581169160208101359160409091013516611589565b3480156103da57600080fd5b506103e3611b19565b604080516001600160a01b039092168252519081900360200190f35b610232600480360361010081101561041657600080fd5b810190602081018135600160201b81111561043057600080fd5b82018360208201111561044257600080fd5b803590602001918460208302840111600160201b8311171561046357600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955050823593505050602081013590604081013590606081013515159060808101359060a081013515159060c001351515611b28565b3480156104d657600080fd5b50610503600480360360408110156104ed57600080fd5b506001600160a01b038135169060200135611f5f565b604080516001600160a01b039a8b168152988a1660208a0152888101979097529490971660608701526080860192909252151560a085015260c084015292151560e08301526101008201929092529051908190036101200190f35b34801561056a57600080fd5b506105976004803603604081101561058157600080fd5b506001600160a01b038135169060200135612063565b604080516001600160a01b039b8c168152998b1660208b015289810198909852958916606089015293909716608087015260a086019190915260c085015260e08401949094529215156101008301529115156101208201529051908190036101400190f35b34801561060857600080fd5b506106116120d4565b604080519115158252519081900360200190f35b34801561063157600080fd5b506103e36120dd565b34801561064657600080fd5b506102326004803603602081101561065d57600080fd5b50356120ec565b34801561067057600080fd5b506106b5600480360360a081101561068757600080fd5b5080351515906020810135906001600160a01b036040820135169060608101351515906080013515156123e8565b6040805192835290151560208301528051918290030190f35b3480156106da57600080fd5b506103e3612555565b3480156106ef57600080fd5b5061026c612564565b34801561070457600080fd5b506102326004803603602081101561071b57600080fd5b50356001600160a01b031661256a565b34801561073757600080fd5b506107646004803603604081101561074e57600080fd5b506001600160a01b0381351690602001356125c6565b604080516001600160a01b03909816885260208801969096528686019490945260608601929092526080850152151560a0840152151560c0830152519081900360e00190f35b3480156107b657600080fd5b50610232600480360360608110156107cd57600080fd5b810190602081018135600160201b8111156107e757600080fd5b8201836020820111156107f957600080fd5b803590602001918460208302840111600160201b8311171561081a57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561086957600080fd5b82018360208201111561087b57600080fd5b803590602001918460208302840111600160201b8311171561089c57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156108eb57600080fd5b8201836020820111156108fd57600080fd5b803590602001918460208302840111600160201b8311171561091e57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550612619945050505050565b34801561096857600080fd5b5061026c6126b1565b34801561097d57600080fd5b5061026c6126b7565b34801561099257600080fd5b50610232600480360360808110156109a957600080fd5b508035906020810135906040810135906060013515156126c7565b3480156109d057600080fd5b50610232600480360360208110156109e757600080fd5b5035612827565b3480156109fa57600080fd5b50610232600480360360a0811015610a1157600080fd5b50803590602081013590604081013590606081013590608001351515612ad0565b348015610a3e57600080fd5b506103e3612c3b565b348015610a5357600080fd5b5061026c60048036036020811015610a6a57600080fd5b50356001600160a01b0316612c4a565b6102326004803603610160811015610a9157600080fd5b810190602081018135600160201b811115610aab57600080fd5b820183602082011115610abd57600080fd5b803590602001918460208302840111600160201b83111715610ade57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505082359350506001600160a01b036020830135811692604081013592506060810135916080820135169060a081013515159060c08101359060e08101351515906101008101359061012001351515612c5c565b348015610b7057600080fd5b5061061160048036036040811015610b8757600080fd5b810190602081018135600160201b811115610ba157600080fd5b820183602082011115610bb357600080fd5b803590602001918460208302840111600160201b83111715610bd457600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505091359250613077915050565b348015610c2057600080fd5b5061023260048036036080811015610c3757600080fd5b5080359060208101359060408101359060600135151561322b565b348015610c5e57600080fd5b5061023260048036036020811015610c7557600080fd5b50356001600160a01b03166133f5565b348015610c9157600080fd5b50610cbe60048036036040811015610ca857600080fd5b506001600160a01b0381351690602001356134ac565b604080516001600160a01b039a8b168152988a1660208a015296909816878701526060870194909452608086019290925260a0850152151560c0840152151560e08301526101008201929092529051908190036101200190f35b348015610d2457600080fd5b5061023260048036036060811015610d3b57600080fd5b506001600160a01b03813581169160208101359160409091013516613669565b348015610d6757600080fd5b50610d9460048036036040811015610d7e57600080fd5b506001600160a01b038135169060200135613ad4565b604080516001600160a01b039a8b1681526020810199909952968916888801529490971660608701526080860192909252151560a085015260c084015292151560e08301526101008201929092529051908190036101200190f35b348015610dfb57600080fd5b5061026c60048036036020811015610e1257600080fd5b50356001600160a01b0316613bb8565b348015610e2e57600080fd5b50610232600480360360c0811015610e4557600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359091169060808101359060a00135613bca565b348015610e8757600080fd5b50610eb460048036036040811015610e9e57600080fd5b506001600160a01b038135169060200135613cd7565b604080516001600160a01b039d8e1681529b8d1660208d0152998c168b8b015260608b019890985295909916608089015260a088019390935260c087019190915260e08601526101008501529315156101208401529215156101408301529115156101608201529051908190036101800190f35b348015610f3457600080fd5b5061023260048036036020811015610f4b57600080fd5b5035613d59565b348015610f5e57600080fd5b506103e3614097565b6102326004803603610140811015610f7e57600080fd5b506001600160a01b038135811691602081013591604082013581169160608101359091169060808101359060a081013515159060c08101359060e081013515159061010081013590610120013515156140a6565b348015610fde57600080fd5b506103e361423a565b348015610ff357600080fd5b506102326004803603602081101561100a57600080fd5b5035614249565b60066020526000908152604090205481565b670de0b6b3a764000081565b6000806000806000806000806110436153a4565b505050506001600160a01b03968716600090815260036020818152604080842099845298815291889020885161018081018a5281548b16815260018201548b1693810184905260028201548b16998101999099529081015460608901819052600482015490991660808901819052600582015460a08a01819052600683015460c08b01819052600784015460e08c01526008840154610100808d0182905260099095015460ff80821615156101208f01819052968204811615156101408f0181905262010000909204161515610160909d019c909c52949c929a919950929750919550909350909150565b60026000541415611174576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b600260005561118161428c565b611189615408565b6001600160a01b0380851660009081526005602090815260408083208784528252918290208251610100810184528154909416845260018101805484518185028101850190955280855291938584019390929083018282801561121557602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116111f7575b50505091835250506002820154602082015260038201546040820152600482015460608201526005820154608082015260069091015460ff808216151560a084015261010090910416151560c09091015280519091506001600160a01b03166112b4576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b8060c001511561130f576112d081602001518260800151613077565b61130f576040805162461bcd60e51b815260206004820152601f60248201526000805160206156b1833981519152604482015290519081900360640190fd5b6001600160a01b0384166000908152600560209081526040808320868452909152812080546001600160a01b03191681559061134e600183018261545a565b506000600282018190556003820181905560048201819055600582018190556006909101805461ffff19169055600b546040830151602084015180516113c1946001600160a01b0390941693906113a157fe5b60200260200101516001600160a01b03166142dd9092919063ffffffff16565b600854602082015180516000926001600160a01b0316919060001981019081106113e757fe5b60200260200101516001600160a01b031614801561140657508160e001515b156114335761141e8260200151836060015130614334565b905061142e818360000151614463565b61144d565b61144a826020015183606001518460000151614334565b90505b61145b8260a0015184614463565b846001600160a01b03167f7e1fe496989eea92b738a562dbf9c0ae6aa6fcf3f1ef09e95ee4f7603721706b858460200151856040015186606001518688608001518960c001518a60e001518b60a00151604051808a8152602001806020018981526020018881526020018781526020018681526020018515158152602001841515815260200183815260200182810382528a818151815260200191508051906020019060200280838360005b8381101561151f578181015183820152602001611507565b505050509050019a505050505050505050505060405180910390a250506001600055505050565b61154e6144e0565b600e8190556040805182815290517fe46d9daf6d25f7615efa1d0183b90ac6759d85014b598e409aadf0fd918d59a69181900360200190a150565b600260005414156115cf576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b60026000556115dc61428c565b6115e46153a4565b506001600160a01b038084166000908152600360208181526040808420878552825292839020835161018081018552815486168082526001830154871693820193909352600282015486169481019490945291820154606084015260048201549093166080830152600581015460a0830152600681015460c0830152600781015460e083015260088101546101008084019190915260099091015460ff808216151561012085015291810482161515610140840152620100009004161515610160820152906116e9576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b600061170c8261014001518360c0015184608001518561012001511560016123e8565b506001600160a01b0380871660009081526003602081815260408084208a8552825280842080546001600160a01b0319908116825560018201805482169055600282018054821690559381018590556004808201805490951690945560058101859055600681018590556007810185905560088101859055600901805462ffffff19169055600a5488518984015160808b015160608c015160a08d01516101208e01518751632662166b60e01b8152958c1699860199909952928a16602485015290891660448401526064830152608482015293151560a48501523060c4850152905195965092949290931692632662166b9260e48084019382900301818787803b15801561181a57600080fd5b505af115801561182e573d6000803e3d6000fd5b505050506040513d602081101561184457600080fd5b505160408401519091506000906001600160a01b0316156119a257600b5460408051630d577c1960e31b815290516000926001600160a01b031691636abbe0c8916004808301926020929190829003018186803b1580156118a457600080fd5b505afa1580156118b8573d6000803e3d6000fd5b505050506040513d60208110156118ce57600080fd5b505160208681015160408089015181516309374a1760e21b81526001600160a01b03938416600482015290831660248201529051939450600093918516926324dd285c92604480840193829003018186803b15801561192c57600080fd5b505afa158015611940573d6000803e3d6000fd5b505050506040513d602081101561195657600080fd5b5051905080841161199f57600b546020870151611980916001600160a01b039182169116866142dd565b611998866020015187604001518860e001513061452f565b9350600192505b50505b83610160015180156119c6575080806119c6575060408401516001600160a01b0316155b156119de576119d9828560000151614463565b611a36565b60408401516001600160a01b0316158015906119f75750805b15611a1957835160408501516119d9916001600160a01b0390911690846142dd565b83516020850151611a36916001600160a01b0390911690846142dd565b611a4584610100015186614463565b83600001516001600160a01b03167f9a382661d6573da86db000471303be6f0b2b1bb66089b08e3c16a85d7b6e94f8878660200151876060015188608001518960a001518a61012001518b60c001518c61014001518d61010001518d604051808b81526020018a6001600160a01b03168152602001898152602001886001600160a01b03168152602001878152602001861515815260200185815260200184151581526020018381526020018281526020019a505050505050505050505060405180910390a2505060016000555050505050565b6007546001600160a01b031681565b60026000541415611b6e576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b6002600081905588511480611b84575087516003145b611bc3576040805162461bcd60e51b81526020600482015260186024820152600080516020615650833981519152604482015290519081900360640190fd5b87600189510381518110611bd357fe5b60200260200101516001600160a01b031688600081518110611bf157fe5b60200260200101516001600160a01b03161415611c49576040805162461bcd60e51b815260206004820152601160248201527009e847440d2dcecc2d8d2c840bee0c2e8d607b1b604482015290519081900360640190fd5b60095488516001600160a01b03909116908990600090611c6557fe5b60200260200101516001600160a01b031614158015611cb4575060095488516001600160a01b039091169089906000198101908110611ca057fe5b60200260200101516001600160a01b031614155b611cf9576040805162461bcd60e51b815260206004820152601160248201527027a11d1034b73b30b634b2103a37b5b2b760791b604482015290519081900360640190fd5b60008711611d46576040805162461bcd60e51b815260206004820152601560248201527427a11d1034b73b30b634b2102fb0b6b7bab73a24b760591b604482015290519081900360640190fd5b600d54831015611d8b576040805162461bcd60e51b815260206004820152601e6024820152600080516020615610833981519152604482015290519081900360640190fd5b611d93614618565b8115611e565760085488516001600160a01b03909116908990600090611db557fe5b60200260200101516001600160a01b031614611e06576040805162461bcd60e51b815260206004820152601e6024820152600080516020615670833981519152604482015290519081900360640190fd5b611e108388614689565b3414611e51576040805162461bcd60e51b815260206004820152601f6024820152600080516020615630833981519152604482015290519081900360640190fd5b611f40565b823414611e945760405162461bcd60e51b81526004018080602001828103825260278152602001806155696027913960400191505060405180910390fd5b600a5488516001600160a01b0390911690631b827878908a90600090611eb657fe5b602002602001015133308b6040518563ffffffff1660e01b815260040180856001600160a01b03168152602001846001600160a01b03168152602001836001600160a01b03168152602001828152602001945050505050600060405180830381600087803b158015611f2757600080fd5b505af1158015611f3b573d6000803e3d6000fd5b505050505b611f50338989898989878a6146e1565b50506001600055505050505050565b6000806000806000806000806000611f756153a4565b505050506001600160a01b0397881660009081526003602081815260408084209a845299815291899020895161018081018b5281548c16815260018201548c1693810184905260028201548c169a81018b905291810154606083018190526004820154909b1660808301819052600582015460a08401819052600683015460c08501819052600784015460e0860152600884015461010080870182905260099095015460ff808216151561012089018190529682048116151561014089018190526201000090920416151561016090970196909652959e9c9d9c929b50909950919750909550909350909150565b600160208181526000938452604080852090915291835291208054918101546002820154600383015460048401546005850154600686015460078701546008909701546001600160a01b03988916989687169795969485169593909416939192909160ff808216916101009004168a565b600f5460ff1681565b6008546001600160a01b031681565b60026000541415612132576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b600260005561213f61547b565b5033600090815260016020818152604080842085855282529283902083516101408101855281546001600160a01b039081168083529483015481169382019390935260028201549481019490945260038101548216606085015260048101549091166080840152600581015460a0840152600681015460c0840152600781015460e08401526008015460ff808216151561010080860191909152909104161515610120830152612225576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b3360009081526001602081815260408084208685528252832080546001600160a01b031990811682559281018054841690556002810184905560038101805484169055600481018054909316909255600582018390556006820183905560078201929092556008908101805461ffff1916905554908201516001600160a01b03908116911614156122d9576122d46122ce82604001518360e0015161468990919063ffffffff16565b33614463565b61230d565b6122ff33826040015183602001516001600160a01b03166142dd9092919063ffffffff16565b61230d8160e0015133614463565b80600001516001600160a01b03167fd500f34e0ec655b7614ae42e1d9c666d5e4dde909a1297829f8c5ecf00805d328383602001518460400151856060015186608001518760a001518861010001518960c001518a61012001518b60e00151604051808b81526020018a6001600160a01b03168152602001898152602001886001600160a01b03168152602001876001600160a01b03168152602001868152602001851515815260200184815260200183151581526020018281526020019a505050505050505050505060405180910390a250506001600055565b60008060008461247057600b54604080516340d3096b60e11b81526001600160a01b038981166004830152915191909216916381a612d6916024808301926020929190829003018186803b15801561243f57600080fd5b505afa158015612453573d6000803e3d6000fd5b505050506040513d602081101561246957600080fd5b50516124ea565b600b5460408051637092736960e11b81526001600160a01b0389811660048301529151919092169163e124e6d2916024808301926020929190829003018186803b1580156124bd57600080fd5b505afa1580156124d1573d6000803e3d6000fd5b505050506040513d60208110156124e757600080fd5b50515b90506000886124fb578782106124ff565b8782115b905084156125475780612547576040805162461bcd60e51b815260206004820152601f60248201526000805160206156b1833981519152604482015290519081900360640190fd5b909890975095505050505050565b6009546001600160a01b031681565b600d5481565b6125726144e0565b600c80546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f137786eccca8fbeccb32feaef3be23f20ee9427b52ff1acf92511e5e093eaeab9181900360200190a150565b600560208181526000938452604080852090915291835291208054600282015460038301546004840154948401546006909401546001600160a01b03909316949193909260ff8082169161010090041687565b60005b83518110156126495761264184828151811061263457fe5b6020026020010151613d59565b60010161261c565b5060005b825181101561267a5761267283828151811061266557fe5b60200260200101516120ec565b60010161264d565b5060005b81518110156126ab576126a382828151811061269657fe5b6020026020010151612827565b60010161267e565b50505050565b600e5481565b68327cb2734119d3b7a9601e1b81565b6002600054141561270d576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b60026000908155338152600160209081526040808320878452909152902080546001600160a01b0316612776576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b60068101839055600881018054831515610100810261ff001990921691909117918290556005830186905560038301546004840154604080518a81526001600160a01b039384166020820152919092168183015260ff93909316151560608401526080830187905260a0830186905260c08301919091525133917f0a0360dd5c354235bbf8d386ba3b24ef8134088e0785677de1504df219d9149a919081900360e00190a250506001600055505050565b6002600054141561286d576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b600260005561287a6153a4565b5033600090815260036020818152604080842085855282529283902083516101808101855281546001600160a01b039081168083526001840154821694830194909452600283015481169582019590955292810154606084015260048101549093166080830152600583015460a0830152600683015460c0830152600783015460e083015260088301546101008084019190915260099093015460ff808216151561012085015293810484161515610140840152620100009004909216151561016082015290612980576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b336000818152600360208181526040808420878552909152822080546001600160a01b0319908116825560018201805482169055600282018054821690559181018390556004810180549092169091556005810182905560068101829055600781018290556008810191909155600901805462ffffff19169055610100820151612a0991614463565b80600001516001600160a01b03167f1154174c82984656b028c8021671988f60a346497e56fe02554761184f82a075838360200151846060015185608001518660a001518761012001518860c001518961014001518a6101000151604051808a8152602001896001600160a01b03168152602001888152602001876001600160a01b0316815260200186815260200185151581526020018481526020018315158152602001828152602001995050505050505050505060405180910390a250506001600055565b60026000541415612b16576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b60026000908155338152600360209081526040808320888452909152902080546001600160a01b0316612b7f576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b6006810183905560098101805461ff0019166101008415158181029290921792839055600584018790556003840188905560018401546004850154604080518c81526001600160a01b0393841660208201528082018c90529290911660608301526080820189905260ff909416151560a082015260c0810187905260e0810192909252915133927f75781255bc71c83f89f29e5a2599f2c174a562d2cd8f2e818a47f132e7280498928290030190a25050600160005550505050565b600c546001600160a01b031681565b60026020526000908152604090205481565b60026000541415612ca2576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b6002600055612caf614618565b600d54821015612cf4576040805162461bcd60e51b815260206004820152601e6024820152600080516020615610833981519152604482015290519081900360640190fd5b8015612db7576008548b516001600160a01b03909116908c90600090612d1657fe5b60200260200101516001600160a01b031614612d67576040805162461bcd60e51b815260206004820152601e6024820152600080516020615670833981519152604482015290519081900360640190fd5b612d71828b614689565b3414612db2576040805162461bcd60e51b815260206004820152601f6024820152600080516020615630833981519152604482015290519081900360640190fd5b612ea1565b813414612df55760405162461bcd60e51b81526004018080602001828103825260278152602001806155696027913960400191505060405180910390fd5b600a548b516001600160a01b0390911690631b827878908d90600090612e1757fe5b602002602001015133308e6040518563ffffffff1660e01b815260040180856001600160a01b03168152602001846001600160a01b03168152602001836001600160a01b03168152602001828152602001945050505050600060405180830381600087803b158015612e8857600080fd5b505af1158015612e9c573d6000803e3d6000fd5b505050505b60008b60018d510381518110612eb357fe5b60200260200101519050600060018d511115612f7157816001600160a01b03168d600081518110612ee057fe5b60200260200101516001600160a01b03161415612f38576040805162461bcd60e51b815260206004820152601160248201527009e847440d2dcecc2d8d2c840bee0c2e8d607b1b604482015290519081900360640190fd5b612f5f600b60009054906101000a90046001600160a01b03168d8f6000815181106113a157fe5b612f6a8d8b30614334565b9050612f74565b508a5b600b5460408051630a48d5a960e01b81526001600160a01b0385811660048301526024820185905291516000939290921691630a48d5a991604480820192602092909190829003018186803b158015612fcc57600080fd5b505afa158015612fe0573d6000803e3d6000fd5b505050506040513d6020811015612ff657600080fd5b5051600e54909150811015613050576040805162461bcd60e51b815260206004820152601b60248201527a13d08e881a5b9cdd59999a58da595b9d0818dbdb1b185d195c985b602a1b604482015290519081900360640190fd5b506130633383838b8f8e8d8d8d8d6148f0565b505060016000555050505050505050505050565b600082516002148061308a575082516003145b6130c9576040805162461bcd60e51b81526020600482015260186024820152600080516020615650833981519152604482015290519081900360640190fd5b6000836000815181106130d857fe5b602002602001015190506000846001865103815181106130f457fe5b602090810291909101810151600b54604080516340d3096b60e11b81526001600160a01b0387811660048301529151939550600094859492909316926381a612d692602480840193829003018186803b15801561315057600080fd5b505afa158015613164573d6000803e3d6000fd5b505050506040513d602081101561317a57600080fd5b5051600b5460408051637092736960e11b81526001600160a01b038781166004830152915193955091169163e124e6d291602480820192602092909190829003018186803b1580156131cb57600080fd5b505afa1580156131df573d6000803e3d6000fd5b505050506040513d60208110156131f557600080fd5b50519050600061321b836132158468327cb2734119d3b7a9601e1b614bcc565b90614c25565b8710955050505050505b92915050565b60026000541415613271576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b60026000908155338152600560209081526040808320878452909152902080546001600160a01b03166132da576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b838160030181905550828160040181905550818160060160006101000a81548160ff021916908315150217905550336001600160a01b03167fa7f9f4a25eb76f5ec01b1a429d95d6a00833f0f137c88827c58799a1c1ff0dfe868360010184600201548888888860060160019054906101000a900460ff16896005015460405180898152602001806020018881526020018781526020018681526020018515158152602001841515815260200183815260200182810382528981815481526020019150805480156133d457602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116133b6575b5050995050505050505050505060405180910390a250506001600055505050565b6133fd6144e0565b6001600160a01b038116613458576040805162461bcd60e51b815260206004820152601f60248201527f4f423a206e657720676f7620697320746865207a65726f206164647265737300604482015290519081900360640190fd5b600780546001600160a01b0383166001600160a01b0319909116811790915560408051918252517fe24c39186e9137521953beaa8446e71f55b8f12296984f9d4273ceb1af728d909181900360200190a150565b60008060008060008060008060006134c2615408565b6001600160a01b03808d1660009081526005602090815260408083208f84528252918290208251610100810184528154909416845260018101805484518185028101850190955280855291938584019390929083018282801561354e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613530575b5050509183525050600282015460208083019190915260038301546040830152600483015460608301526005830154608083015260069092015460ff808216151560a084015261010090910416151560c090910152810151519091506135b55760006135cf565b80602001516000815181106135c657fe5b60200260200101515b6001826020015151116135e35760006135fd565b81602001516001815181106135f457fe5b60200260200101515b60028360200151511161361157600061362b565b826020015160028151811061362257fe5b60200260200101515b8360400151846060015185608001518660c001518760e001518860a00151995099509950995099509950995099509950509295985092959850929598565b600260005414156136af576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b60026000556136bc61428c565b6136c461547b565b506001600160a01b038084166000908152600160208181526040808420878552825292839020835161014081018552815486168082529382015486169281019290925260028101549382019390935260038301548416606082015260048301549093166080840152600582015460a0840152600682015460c0840152600782015460e084015260089091015460ff8082161515610100808601919091529091041615156101208301526137ad576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b60006137cf8261012001518360c00151846080015185610100015160016123e8565b506001600160a01b0380871660009081526001602081815260408084208a8552825280842080546001600160a01b031990811682559381018054851690556002810185905560038101805485169055600481018054909416909355600583018490556006830184905560078301939093556008909101805461ffff19169055600b54918601519086015193945061386d9383169291909116906142dd565b81606001516001600160a01b031682602001516001600160a01b0316146139455760408051600280825260608083018452926020830190803683370190505090508260200151816000815181106138c057fe5b60200260200101906001600160a01b031690816001600160a01b0316815250508260600151816001815181106138f257fe5b60200260200101906001600160a01b031690816001600160a01b031681525050600061392082600030614334565b600b546060860151919250613942916001600160a01b039081169116836142dd565b50505b600a5482516060840151608085015160a086015161010087015160408051630f8ee8bb60e11b81526001600160a01b03968716600482015294861660248601529285166044850152606484019190915215156084830152519190921691631f1dd1769160a480830192600092919082900301818387803b1580156139c857600080fd5b505af11580156139dc573d6000803e3d6000fd5b505050506139ee8260e0015184614463565b81600001516001600160a01b03167f7fb1c74d1ea6aa1c9c585e17ce8274c8ff98745e85e7459b73f87d784494f58e8584602001518560400151866060015187608001518860a001518961010001518a60c001518b61012001518c60e001518c604051808c81526020018b6001600160a01b031681526020018a8152602001896001600160a01b03168152602001886001600160a01b03168152602001878152602001861515815260200185815260200184151581526020018381526020018281526020019b50505050505050505050505060405180910390a250506001600055505050565b6000806000806000806000806000613aea61547b565b505050506001600160a01b0397881660009081526001602081815260408084209a845299815291899020895161014081018b5281548c168152918101548b1692820183905260028101549982018a905260038101548b16606083018190526004820154909b1660808301819052600582015460a08401819052600683015460c08501819052600784015460e0860181905260089094015460ff8082161515610100808901829052909204161515610120909601869052959e9c9d9c929b509099509397509295509093509150565b60046020526000908152604090205481565b613bd26144e0565b600f5460ff1615613c16576040805162461bcd60e51b815260206004820152600960248201526827a11d1032b93937b960b91b604482015290519081900360640190fd5b600f805460ff19166001179055600a80546001600160a01b038089166001600160a01b03199283168117909355600b8054898316908416811790915560088054898416908516811790915560098054938916939094168317909355600d869055600e8590556040805194855260208501919091528381019290925260608301526080820184905260a08201839052517fcfb7ef8749fafc8da2af1ba3d025479ffc4e58f7dc420113e112512a3bda59639181900360c00190a1505050505050565b6003602081815260009384526040808520909152918352912080546001820154600283015493830154600484015460058501546006860154600787015460088801546009909801546001600160a01b039788169996881698968816979596959094169492939192909160ff80821691610100810482169162010000909104168c565b60026000541415613d9f576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b6002600055613dac615408565b33600090815260056020908152604080832085845282529182902082516101008101845281546001600160a01b0316815260018201805485518186028101860190965280865291949293858101939290830182828015613e3557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613e17575b50505091835250506002820154602082015260038201546040820152600482015460608201526005820154608082015260069091015460ff808216151560a084015261010090910416151560c09091015280519091506001600160a01b0316613ed4576040805162461bcd60e51b815260206004820152600c60248201526b27a11d1037379037b93232b960a11b604482015290519081900360640190fd5b336000908152600560209081526040808320858452909152812080546001600160a01b031916815590613f0a600183018261545a565b506000600282018190556003820181905560048201819055600582018190556006909101805461ffff19169055600854602083015180516001600160a01b03909216929091613f5557fe5b60200260200101516001600160a01b03161415613f8f57613f8a6122ce82604001518360a0015161468990919063ffffffff16565b613fb7565b613fa933826040015183602001516000815181106113a157fe5b613fb78160a0015133614463565b336001600160a01b03167fefd66d4f9c2f880c70aedeb5b26a44fb474cea07e5d6c533f2d27c303d5d94538383602001518460400151856060015186608001518760c001518860e001518960a00151604051808981526020018060200188815260200187815260200186815260200185151581526020018415158152602001838152602001828103825289818151815260200191508051906020019060200280838360005b8381101561407457818101518382015260200161405c565b50505050905001995050505050505050505060405180910390a250506001600055565b600a546001600160a01b031681565b600260005414156140ec576040805162461bcd60e51b815260206004820152601f6024820152600080516020615590833981519152604482015290519081900360640190fd5b60026000556140f9614618565b600d54341161413d576040805162461bcd60e51b815260206004820152601e6024820152600080516020615610833981519152604482015290519081900360640190fd5b8015614216576001600160a01b038716156141b5576008546001600160a01b038881169116146141b0576040805162461bcd60e51b815260206004820152601960248201527827a11d1034b73b30b634b2102fb932b1b2b4bb32aa37b5b2b760391b604482015290519081900360640190fd5b614216565b6008546001600160a01b03898116911614614216576040805162461bcd60e51b815260206004820152601c60248201527b27a11d1034b73b30b634b2102fb1b7b63630ba32b930b62a37b5b2b760211b604482015290519081900360640190fd5b614229338989898e8e8b8b8b8b8b614c64565b505060016000555050505050505050565b600b546001600160a01b031681565b6142516144e0565b600d8190556040805182815290517fbde5eafdc37b81830d70124cddccaaa6d034e71dda3c8fc18a959ca76a7cbcfc9181900360200190a150565b600c546001600160a01b031633146142db576040805162461bcd60e51b815260206004820152600d60248201526c27a11d103337b93134b23232b760991b604482015290519081900360640190fd5b565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261432f908490614f8d565b505050565b600083516002141561437b576143748460008151811061435057fe5b60200260200101518560018151811061436557fe5b6020026020010151858561452f565b905061445c565b8351600314156144215760006143bc8560008151811061439757fe5b6020026020010151866001815181106143ac57fe5b602002602001015160003061452f565b90506143e5600b60009054906101000a90046001600160a01b031682876001815181106113a157fe5b614419856001815181106143f557fe5b60200260200101518660028151811061440a57fe5b6020026020010151868661452f565b91505061445c565b6040805162461bcd60e51b81526020600482015260186024820152600080516020615650833981519152604482015290519081900360640190fd5b9392505050565b60085460408051632e1a7d4d60e01b81526004810185905290516001600160a01b0390921691632e1a7d4d9160248082019260009290919082900301818387803b1580156144b057600080fd5b505af11580156144c4573d6000803e3d6000fd5b506144dc925050506001600160a01b0382168361503e565b5050565b6007546001600160a01b031633146142db576040805162461bcd60e51b815260206004820152600d60248201526c27a11d103337b93134b23232b760991b604482015290519081900360640190fd5b600b5460408051634998b10960e11b81526001600160a01b03878116600483015286811660248301528481166044830152915160009384931691639331621291606480830192602092919082900301818787803b15801561458f57600080fd5b505af11580156145a3573d6000803e3d6000fd5b505050506040513d60208110156145b957600080fd5b505190508381101561460f576040805162461bcd60e51b815260206004820152601a60248201527913d08e881a5b9cdd59999a58da595b9d08185b5bdd5b9d13dd5d60321b604482015290519081900360640190fd5b95945050505050565b34156142db57600860009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561466e57600080fd5b505af1158015614682573d6000803e3d6000fd5b5050505050565b60008282018381101561445c576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b6001600160a01b038816600090815260066020526040902054614702615408565b6040518061010001604052808b6001600160a01b031681526020018a81526020018981526020018881526020018781526020018481526020018615158152602001851515815250905061475f60018361468990919063ffffffff16565b6001600160a01b038b8116600090815260066020908152604080832094909455600581528382208683528152929020835181546001600160a01b031916921691909117815582820151805184936147bd9260018501929101906154cf565b5060408201518160020155606082015181600301556080820151816004015560a0820151816005015560c08201518160060160006101000a81548160ff02191690831515021790555060e08201518160060160016101000a81548160ff021916908315150217905550905050896001600160a01b03167fdf06bb56ffc4029dc0b62b68bb5bbadea93a38b530cefc9b81afb742a6555d88838b8b8b8b8b8b8b604051808981526020018060200188815260200187815260200186815260200185151581526020018415158152602001838152602001828103825289818151815260200191508051906020019060200280838360005b838110156148ca5781810151838201526020016148b2565b50505050905001995050505050505050505060405180910390a250505050505050505050565b6001600160a01b038a1660009081526002602052604090205461491161547b565b6040518061014001604052808d6001600160a01b031681526020018c6001600160a01b031681526020018b81526020018a6001600160a01b03168152602001896001600160a01b031681526020018881526020018681526020018481526020018715158152602001851515815250905061499560018361468990919063ffffffff16565b600260008e6001600160a01b03166001600160a01b031681526020019081526020016000208190555080600160008e6001600160a01b03166001600160a01b03168152602001908152602001600020600084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506040820151816002015560608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a0820151816005015560c0820151816006015560e082015181600701556101008201518160080160006101000a81548160ff0219169083151502179055506101208201518160080160016101000a81548160ff0219169083151502179055509050508b6001600160a01b03167fb27b9afe3043b93788c40cfc3cc73f5d928a2e40f3ba01820b246426de8fa1b9838d8d8d8d8d8d8d8d8d604051808b81526020018a6001600160a01b03168152602001898152602001886001600160a01b03168152602001876001600160a01b03168152602001868152602001851515815260200184815260200183151581526020018281526020019a505050505050505050505060405180910390a2505050505050505050505050565b600082614bdb57506000613225565b82820282848281614be857fe5b041461445c5760405162461bcd60e51b81526004018080602001828103825260218152602001806156906021913960400191505060405180910390fd5b600061445c83836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b815250615123565b6001600160a01b038b16600090815260046020526040902054614c856153a4565b6040518061018001604052808e6001600160a01b031681526020018d6001600160a01b031681526020018c6001600160a01b031681526020018b81526020018a6001600160a01b03168152602001898152602001878152602001858152602001348152602001881515815260200186151581526020018415158152509050614d1760018361468990919063ffffffff16565b600460008f6001600160a01b03166001600160a01b031681526020019081526020016000208190555080600360008f6001600160a01b03166001600160a01b03168152602001908152602001600020600084815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160020160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506060820151816003015560808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a0820151816005015560c0820151816006015560e0820151816007015561010082015181600801556101208201518160090160006101000a81548160ff0219169083151502179055506101408201518160090160016101000a81548160ff0219169083151502179055506101608201518160090160026101000a81548160ff0219169083151502179055509050508c6001600160a01b03167fc61ede3cf3bb8f4f08fc3a1da4329703fe53fe2708ea53bc7f260026dc03a4be838e8e8e8e8e8e8e8e348f8f604051808d81526020018c6001600160a01b031681526020018b6001600160a01b031681526020018a8152602001896001600160a01b031681526020018881526020018715158152602001868152602001851515815260200184815260200183815260200182151581526020019c5050505050505050505050505060405180910390a250505050505050505050505050565b6060614fe2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166151c59092919063ffffffff16565b80519091501561432f5780806020019051602081101561500157600080fd5b505161432f5760405162461bcd60e51b815260040180806020018281038252602a8152602001806156d1602a913960400191505060405180910390fd5b80471015615093576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d80600081146150de576040519150601f19603f3d011682016040523d82523d6000602084013e6150e3565b606091505b505090508061432f5760405162461bcd60e51b815260040180806020018281038252603a8152602001806155b0603a913960400191505060405180910390fd5b600081836151af5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561517457818101518382015260200161515c565b50505050905090810190601f1680156151a15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816151bb57fe5b0495945050505050565b60606151d484846000856151dc565b949350505050565b60608247101561521d5760405162461bcd60e51b81526004018080602001828103825260268152602001806155ea6026913960400191505060405180910390fd5b61522685615338565b615277576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106152b65780518252601f199092019160209182019101615297565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114615318576040519150601f19603f3d011682016040523d82523d6000602084013e61531d565b606091505b509150915061532d82828661533e565b979650505050505050565b3b151590565b6060831561534d57508161445c565b82511561535d5782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561517457818101518382015260200161515c565b6040805161018081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081019190915290565b60405180610100016040528060006001600160a01b0316815260200160608152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b50805460008255906000526020600020908101906154789190615534565b50565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915290565b828054828255906000526020600020908101928215615524579160200282015b8281111561552457825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906154ef565b50615530929150615549565b5090565b5b808211156155305760008155600101615535565b5b808211156155305780546001600160a01b031916815560010161554a56fe4f423a20696e636f727265637420657865637574696f6e20666565207472616e736665727265645265656e7472616e637947756172643a207265656e7472616e742063616c6c00416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4f423a20696e73756666696369656e7420657865637574696f6e2066656500004f423a20696e636f72726563742076616c7565207472616e73666572726564004f423a20696e76616c6964205f706174682e6c656e67746800000000000000004f423a206f6e6c79207765746820636f756c6420626520777261707065640000536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f423a20696e76616c696420707269636520666f7220657865637574696f6e005361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c634300060c000a

Block Transaction Gas Used Reward
view all blocks sequenced

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
[ 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.