ETH Price: $3,913.58 (+5.10%)

Contract

0x443Cf165B72e4b4331C0101A10553269972Ed4B8
Transaction Hash
Method
Block
From
To
Create Decrease ...177325672024-11-20 2:20:0815 days ago1732069208IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000131210.342
Create Decrease ...170082942024-10-22 9:08:2944 days ago1729588109IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000059120.154
Create Decrease ...160321092024-09-15 19:34:1880 days ago1726428858IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000012460.034
Create Decrease ...150287552024-08-11 18:57:53115 days ago1723402673IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000018340.05
Create Decrease ...149934852024-08-10 13:25:42116 days ago1723296342IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000007510.0196
Create Increase ...148420592024-08-05 6:27:28122 days ago1722839248IN
0x443Cf165...9972Ed4B8
0.005 ETH0.001746864.68
Create Increase ...148391472024-08-05 4:01:25122 days ago1722830485IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000174310.467
Create Increase ...148357612024-08-05 1:11:01122 days ago1722820261IN
0x443Cf165...9972Ed4B8
0.005 ETH0.002220835.95
Create Increase ...148355632024-08-05 1:00:59122 days ago1722819659IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000462841.24
Create Increase ...148260122024-08-04 16:59:48122 days ago1722790788IN
0x443Cf165...9972Ed4B8
0.005 ETH0.00005150.138
Create Increase ...139511522024-07-05 2:59:15153 days ago1720148355IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000067560.181
Create Increase ...139475802024-07-04 23:53:50153 days ago1720137230IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000044790.12
Create Decrease ...139301072024-07-04 9:05:54154 days ago1720083954IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000051580.12524
Create Increase ...139278682024-07-04 7:13:12154 days ago1720077192IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000021640.058
Create Decrease ...139132732024-07-03 18:47:24154 days ago1720032444IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000043990.12
Create Increase ...134639962024-06-18 1:30:01170 days ago1718674201IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000063450.17
Create Decrease ...134345012024-06-17 0:47:28171 days ago1718585248IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000062350.17
Create Increase ...133533022024-06-14 4:47:02174 days ago1718340422IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000063450.17
Create Increase ...132924782024-06-12 1:48:03176 days ago1718156883IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000066360.17
Create Decrease ...131364442024-06-06 15:00:48181 days ago1717686048IN
0x443Cf165...9972Ed4B8
0.005 ETH0.001806835.17
Create Decrease ...131158932024-06-05 21:46:20182 days ago1717623980IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000164260.47
Create Increase ...130856172024-06-04 20:22:21183 days ago1717532541IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000060540.17
Create Decrease ...130848942024-06-04 19:45:55183 days ago1717530355IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000069240.198
Create Increase ...130728032024-06-04 9:38:00184 days ago1717493880IN
0x443Cf165...9972Ed4B8
0.017 ETH0.000045770.132
Create Decrease ...130711192024-06-04 8:13:34184 days ago1717488814IN
0x443Cf165...9972Ed4B8
0.005 ETH0.000040710.111
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
177326152024-11-20 2:23:0015 days ago1732069380
0x443Cf165...9972Ed4B8
0.005 ETH
177326152024-11-20 2:23:0015 days ago1732069380
0x443Cf165...9972Ed4B8
0.005 ETH
177325672024-11-20 2:20:0815 days ago1732069208
0x443Cf165...9972Ed4B8
0.005 ETH
170083382024-10-22 9:11:0144 days ago1729588261
0x443Cf165...9972Ed4B8
0.005 ETH
170083382024-10-22 9:11:0144 days ago1729588261
0x443Cf165...9972Ed4B8
0.005 ETH
170083382024-10-22 9:11:0144 days ago1729588261
0x443Cf165...9972Ed4B8
0.07498074 ETH
170083382024-10-22 9:11:0144 days ago1729588261
0x443Cf165...9972Ed4B8
0.07498074 ETH
170082942024-10-22 9:08:2944 days ago1729588109
0x443Cf165...9972Ed4B8
0.005 ETH
160321192024-09-15 19:34:4880 days ago1726428888
0x443Cf165...9972Ed4B8
0.005 ETH
160321192024-09-15 19:34:4880 days ago1726428888
0x443Cf165...9972Ed4B8
0.005 ETH
160321092024-09-15 19:34:1880 days ago1726428858
0x443Cf165...9972Ed4B8
0.005 ETH
150287592024-08-11 18:58:05115 days ago1723402685
0x443Cf165...9972Ed4B8
0.005 ETH
150287592024-08-11 18:58:05115 days ago1723402685
0x443Cf165...9972Ed4B8
0.005 ETH
150287592024-08-11 18:58:05115 days ago1723402685
0x443Cf165...9972Ed4B8
0.25907448 ETH
150287592024-08-11 18:58:05115 days ago1723402685
0x443Cf165...9972Ed4B8
0.25907448 ETH
150287552024-08-11 18:57:53115 days ago1723402673
0x443Cf165...9972Ed4B8
0.005 ETH
149934912024-08-10 13:26:00116 days ago1723296360
0x443Cf165...9972Ed4B8
0.005 ETH
149934912024-08-10 13:26:00116 days ago1723296360
0x443Cf165...9972Ed4B8
0.005 ETH
149934852024-08-10 13:25:42116 days ago1723296342
0x443Cf165...9972Ed4B8
0.005 ETH
148420642024-08-05 6:27:41122 days ago1722839261
0x443Cf165...9972Ed4B8
0.005 ETH
148420642024-08-05 6:27:41122 days ago1722839261
0x443Cf165...9972Ed4B8
0.005 ETH
148420592024-08-05 6:27:28122 days ago1722839248
0x443Cf165...9972Ed4B8
0.005 ETH
148391552024-08-05 4:01:49122 days ago1722830509
0x443Cf165...9972Ed4B8
0.005 ETH
148391552024-08-05 4:01:49122 days ago1722830509
0x443Cf165...9972Ed4B8
0.005 ETH
148391472024-08-05 4:01:25122 days ago1722830485
0x443Cf165...9972Ed4B8
0.005 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PositionRouter

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 1 runs

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

pragma solidity ^0.6.0;

import "./interfaces/IRouter.sol";
import "./interfaces/IVault.sol";
import "./interfaces/IPositionRouter.sol";
import "./interfaces/IPositionRouterCallbackReceiver.sol";

import "../libraries/utils/Address.sol";
import "../peripherals/interfaces/ITimelock.sol";
import "./BasePositionManager.sol";

contract PositionRouter is BasePositionManager, IPositionRouter {
    using Address for address;

    struct IncreasePositionRequest {
        address account;
        address[] path;
        address indexToken;
        uint256 amountIn;
        uint256 minOut;
        uint256 sizeDelta;        
        uint256 acceptablePrice;
        uint256 executionFee;
        uint256 blockNumber;
        uint256 blockTime;
        bool isLong;
        bool hasCollateralInETH;
        address callbackTarget;
    }

    struct DecreasePositionRequest {
        address account;
        address[] path;
        address indexToken;
        uint256 collateralDelta;
        uint256 sizeDelta;        
        address receiver;
        uint256 acceptablePrice;
        uint256 minOut;
        uint256 executionFee;
        uint256 blockNumber;
        uint256 blockTime;
        bool isLong;
        bool withdrawETH;
        address callbackTarget;
    }

    uint256 public minExecutionFee;

    uint256 public minBlockDelayKeeper;
    uint256 public minTimeDelayPublic;
    uint256 public maxTimeDelay;

    bool public isLeverageEnabled = true;

    bytes32[] public override increasePositionRequestKeys;
    bytes32[] public override decreasePositionRequestKeys;

    uint256 public override increasePositionRequestKeysStart;
    uint256 public override decreasePositionRequestKeysStart;

    uint256 public callbackGasLimit;

    mapping (address => bool) public isPositionKeeper;

    mapping (address => uint256) public increasePositionsIndex;
    mapping (bytes32 => IncreasePositionRequest) public increasePositionRequests;

    mapping (address => uint256) public decreasePositionsIndex;
    mapping (bytes32 => DecreasePositionRequest) public decreasePositionRequests;

    event CreateIncreasePosition(
        address indexed account,
        address[] path,
        address indexToken,
        uint256 amountIn,
        uint256 minOut,
        uint256 sizeDelta,
        bool isLong,
        uint256 acceptablePrice,
        uint256 executionFee,
        uint256 index,
        uint256 queueIndex,
        uint256 blockNumber,
        uint256 blockTime,
        uint256 gasPrice
    );

    event ExecuteIncreasePosition(
        address indexed account,
        address[] path,
        address indexToken,
        uint256 amountIn,
        uint256 minOut,
        uint256 sizeDelta,
        bool isLong,
        uint256 acceptablePrice,
        uint256 executionFee,
        uint256 blockGap,
        uint256 timeGap
    );

    event CancelIncreasePosition(
        address indexed account,
        address[] path,
        address indexToken,
        uint256 amountIn,
        uint256 minOut,
        uint256 sizeDelta,
        bool isLong,
        uint256 acceptablePrice,
        uint256 executionFee,
        uint256 blockGap,
        uint256 timeGap
    );

    event CreateDecreasePosition(
        address indexed account,
        address[] path,
        address indexToken,
        uint256 collateralDelta,
        uint256 sizeDelta,
        bool isLong,
        address receiver,
        uint256 acceptablePrice,
        uint256 minOut,
        uint256 executionFee,
        uint256 index,
        uint256 queueIndex,
        uint256 blockNumber,
        uint256 blockTime
    );

    event ExecuteDecreasePosition(
        address indexed account,
        address[] path,
        address indexToken,
        uint256 collateralDelta,
        uint256 sizeDelta,
        bool isLong,
        address receiver,
        uint256 acceptablePrice,
        uint256 minOut,
        uint256 executionFee,
        uint256 blockGap,
        uint256 timeGap
    );

    event CancelDecreasePosition(
        address indexed account,
        address[] path,
        address indexToken,
        uint256 collateralDelta,
        uint256 sizeDelta,
        bool isLong,
        address receiver,
        uint256 acceptablePrice,
        uint256 minOut,
        uint256 executionFee,
        uint256 blockGap,
        uint256 timeGap
    );

    event SetPositionKeeper(address indexed account, bool isActive);
    event SetMinExecutionFee(uint256 minExecutionFee);
    event SetIsLeverageEnabled(bool isLeverageEnabled);
    event SetDelayValues(uint256 minBlockDelayKeeper, uint256 minTimeDelayPublic, uint256 maxTimeDelay);
    event SetRequestKeysStartValues(uint256 increasePositionRequestKeysStart, uint256 decreasePositionRequestKeysStart);
    event SetCallbackGasLimit(uint256 callbackGasLimit);
    event Callback(address callbackTarget, bool success, uint256 callbackGasLimit);

    modifier onlyPositionKeeper() {
        require(isPositionKeeper[msg.sender], "403");
        _;
    }

    constructor(
        address _vault,
        address _router,
        address _weth,
        address _shortsTracker,
        uint256 _depositFee,
        uint256 _minExecutionFee
    ) public BasePositionManager(_vault, _router, _shortsTracker, _weth, _depositFee) {
        minExecutionFee = _minExecutionFee;
    }

    function setPositionKeeper(address _account, bool _isActive) external onlyAdmin {
        isPositionKeeper[_account] = _isActive;
        emit SetPositionKeeper(_account, _isActive);
    }

    function setCallbackGasLimit(uint256 _callbackGasLimit) external onlyAdmin {
        callbackGasLimit = _callbackGasLimit;
        emit SetCallbackGasLimit(_callbackGasLimit);
    }

    function setMinExecutionFee(uint256 _minExecutionFee) external onlyAdmin {
        minExecutionFee = _minExecutionFee;
        emit SetMinExecutionFee(_minExecutionFee);
    }

    function setIsLeverageEnabled(bool _isLeverageEnabled) external onlyAdmin {
        isLeverageEnabled = _isLeverageEnabled;
        emit SetIsLeverageEnabled(_isLeverageEnabled);
    }

    function setDelayValues(uint256 _minBlockDelayKeeper, uint256 _minTimeDelayPublic, uint256 _maxTimeDelay) external onlyAdmin {
        minBlockDelayKeeper = _minBlockDelayKeeper;
        minTimeDelayPublic = _minTimeDelayPublic;
        maxTimeDelay = _maxTimeDelay;
        emit SetDelayValues(_minBlockDelayKeeper, _minTimeDelayPublic, _maxTimeDelay);
    }

    function setRequestKeysStartValues(uint256 _increasePositionRequestKeysStart, uint256 _decreasePositionRequestKeysStart) external onlyAdmin {
        increasePositionRequestKeysStart = _increasePositionRequestKeysStart;
        decreasePositionRequestKeysStart = _decreasePositionRequestKeysStart;

        emit SetRequestKeysStartValues(_increasePositionRequestKeysStart, _decreasePositionRequestKeysStart);
    }

    function executeIncreasePositions(uint256 _endIndex, address payable _executionFeeReceiver) external override onlyPositionKeeper {
        uint256 index = increasePositionRequestKeysStart;
        uint256 length = increasePositionRequestKeys.length;

        if (index >= length) { return; }

        if (_endIndex > length) {
            _endIndex = length;
        }

        while (index < _endIndex) {
            bytes32 key = increasePositionRequestKeys[index];

            // if the request was executed then delete the key from the array
            // if the request was not executed then break from the loop, this can happen if the
            // minimum number of blocks has not yet passed
            // an error could be thrown if the request is too old or if the slippage is
            // higher than what the user specified, or if there is insufficient liquidity for the position
            // in case an error was thrown, cancel the request
            try this.executeIncreasePosition(key, _executionFeeReceiver) returns (bool _wasExecuted) {
                if (!_wasExecuted) { break; }
            } catch {
                // wrap this call in a try catch to prevent invalid cancels from blocking the loop
                try this.cancelIncreasePosition(key, _executionFeeReceiver) returns (bool _wasCancelled) {
                    if (!_wasCancelled) { break; }
                } catch {}
            }

            delete increasePositionRequestKeys[index];
            index++;
        }

        increasePositionRequestKeysStart = index;
    }

    function executeDecreasePositions(uint256 _endIndex, address payable _executionFeeReceiver) external override onlyPositionKeeper {
        uint256 index = decreasePositionRequestKeysStart;
        uint256 length = decreasePositionRequestKeys.length;

        if (index >= length) { return; }

        if (_endIndex > length) {
            _endIndex = length;
        }

        while (index < _endIndex) {
            bytes32 key = decreasePositionRequestKeys[index];

            // if the request was executed then delete the key from the array
            // if the request was not executed then break from the loop, this can happen if the
            // minimum number of blocks has not yet passed
            // an error could be thrown if the request is too old
            // in case an error was thrown, cancel the request
            try this.executeDecreasePosition(key, _executionFeeReceiver) returns (bool _wasExecuted) {
                if (!_wasExecuted) { break; }
            } catch {
                // wrap this call in a try catch to prevent invalid cancels from blocking the loop
                try this.cancelDecreasePosition(key, _executionFeeReceiver) returns (bool _wasCancelled) {
                    if (!_wasCancelled) { break; }
                } catch {}
            }

            delete decreasePositionRequestKeys[index];
            index++;
        }

        decreasePositionRequestKeysStart = index;
    }

    function createIncreasePosition(
        address[] memory _path,
        address _indexToken,
        uint256 _amountIn,
        uint256 _minOut,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _acceptablePrice,
        uint256 _executionFee,
        bytes32 _referralCode,
        address _callbackTarget
    ) external payable nonReentrant returns (bytes32) {
        require(_executionFee >= minExecutionFee, "fee");
        require(msg.value == _executionFee, "val");
        require(_path.length == 1 || _path.length == 2, "len");
        _validateTokens(_path,_indexToken);

        _transferInETH();
        _setTraderReferralCode(_referralCode);

        if (_amountIn > 0) {
            IRouter(router).pluginTransfer(_path[0], msg.sender, address(this), _amountIn);
        }

        return _createIncreasePosition(
            msg.sender,
            _path,
            _indexToken,
            _amountIn,
            _minOut,
            _sizeDelta,
            _isLong,
            _acceptablePrice,
            _executionFee,
            false,
            _callbackTarget
        );
    }

    function createIncreasePositionETH(
        address[] memory _path,
        address _indexToken,
        uint256 _minOut,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _acceptablePrice,
        uint256 _executionFee,
        bytes32 _referralCode,
        address _callbackTarget
    ) external payable nonReentrant returns (bytes32) {
        require(_executionFee >= minExecutionFee, "fee");
        require(msg.value >= _executionFee, "val");
        require(_path.length == 1 || _path.length == 2, "len");
        require(_path[0] == weth, "path");
        _validateTokens(_path,_indexToken);
        _transferInETH();
        _setTraderReferralCode(_referralCode);

        uint256 amountIn = msg.value.sub(_executionFee);

        return _createIncreasePosition(
            msg.sender,
            _path,
            _indexToken,
            amountIn,
            _minOut,
            _sizeDelta,
            _isLong,
            _acceptablePrice,
            _executionFee,
            true,
            _callbackTarget
        );
    }

    function createDecreasePosition(
        address[] memory _path,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver,
        uint256 _acceptablePrice,
        uint256 _minOut,
        uint256 _executionFee,
        bool _withdrawETH,
        address _callbackTarget
    ) external payable nonReentrant returns (bytes32) {
        require(_executionFee >= minExecutionFee, "fee");
        require(msg.value == _executionFee, "val");
        require(_path.length == 1 || _path.length == 2, "len");
        if (_withdrawETH) {
            require(_path[_path.length - 1] == weth, "path");
        }
        _validateTokens(_path,_indexToken);

        _transferInETH();

        return _createDecreasePosition(
            msg.sender,
            _path,
            _indexToken,
            _collateralDelta,
            _sizeDelta,
            _isLong,
            _receiver,
            _acceptablePrice,
            _minOut,
            _executionFee,
            _withdrawETH,
            _callbackTarget
        );
    }

    function getRequestQueueLengths() external view override returns (uint256, uint256, uint256, uint256) {
        return (
            increasePositionRequestKeysStart,
            increasePositionRequestKeys.length,
            decreasePositionRequestKeysStart,
            decreasePositionRequestKeys.length
        );
    }

    function executeIncreasePosition(bytes32 _key, address payable _executionFeeReceiver) public nonReentrant returns (bool) {
        IncreasePositionRequest memory request = increasePositionRequests[_key];
        // if the request was already executed or cancelled, return true so that the executeIncreasePositions loop will continue executing the next request
        if (request.account == address(0)) { return true; }

        bool shouldExecute = _validateExecution(request.blockNumber, request.blockTime, request.account);
        if (!shouldExecute) { return false; }

        delete increasePositionRequests[_key];

        if (request.amountIn > 0) {
            uint256 amountIn = request.amountIn;

            if (request.path.length > 1) {
                IERC20(request.path[0]).safeTransfer(vault, request.amountIn);
                amountIn = _swap(request.path, request.minOut, address(this));
            }

            uint256 afterFeeAmount = _collectFees(request.account, request.path, amountIn, request.indexToken, request.isLong, request.sizeDelta);
            IERC20(request.path[request.path.length - 1]).safeTransfer(vault, afterFeeAmount);
        }

        _increasePosition(request.account, request.path[request.path.length - 1], request.indexToken, request.sizeDelta, request.isLong, request.acceptablePrice);

        _transferOutETHWithGasLimitFallbackToWeth(request.executionFee, _executionFeeReceiver);

        emit ExecuteIncreasePosition(
            request.account,
            request.path,
            request.indexToken,
            request.amountIn,
            request.minOut,
            request.sizeDelta,
            request.isLong,
            request.acceptablePrice,
            request.executionFee,
            block.number.sub(request.blockNumber),
            block.timestamp.sub(request.blockTime)
        );

        _callRequestCallback(request.callbackTarget, _key, true, true);

        return true;
    }

    function cancelIncreasePosition(bytes32 _key, address payable _executionFeeReceiver) public nonReentrant returns (bool) {
        IncreasePositionRequest memory request = increasePositionRequests[_key];
        // if the request was already executed or cancelled, return true so that the executeIncreasePositions loop will continue executing the next request
        if (request.account == address(0)) { return true; }

        bool shouldCancel = _validateCancellation(request.blockNumber, request.blockTime, request.account);
        if (!shouldCancel) { return false; }

        delete increasePositionRequests[_key];

        if (request.hasCollateralInETH) {
            _transferOutETHWithGasLimitFallbackToWeth(request.amountIn, payable(request.account));
        } else {
            IERC20(request.path[0]).safeTransfer(request.account, request.amountIn);
        }

       _transferOutETHWithGasLimitFallbackToWeth(request.executionFee, _executionFeeReceiver);

        emit CancelIncreasePosition(
            request.account,
            request.path,
            request.indexToken,
            request.amountIn,
            request.minOut,
            request.sizeDelta,
            request.isLong,
            request.acceptablePrice,
            request.executionFee,
            block.number.sub(request.blockNumber),
            block.timestamp.sub(request.blockTime)
        );

        _callRequestCallback(request.callbackTarget, _key, false, true);

        return true;
    }

    function executeDecreasePosition(bytes32 _key, address payable _executionFeeReceiver) public nonReentrant returns (bool) {
        DecreasePositionRequest memory request = decreasePositionRequests[_key];
        // if the request was already executed or cancelled, return true so that the executeDecreasePositions loop will continue executing the next request
        if (request.account == address(0)) { return true; }

        bool shouldExecute = _validateExecution(request.blockNumber, request.blockTime, request.account);
        if (!shouldExecute) { return false; }

        delete decreasePositionRequests[_key];

        uint256 amountOut = _decreasePosition(request.account, request.path[0], request.indexToken, request.collateralDelta, request.sizeDelta, request.isLong, address(this), request.acceptablePrice);

        if (amountOut > 0) {
            if (request.path.length > 1) {
                IERC20(request.path[0]).safeTransfer(vault, amountOut);
                amountOut = _swap(request.path, request.minOut, address(this));
            }

            if (request.withdrawETH) {
               _transferOutETHWithGasLimitFallbackToWeth(amountOut, payable(request.receiver));
            } else {
               IERC20(request.path[request.path.length - 1]).safeTransfer(request.receiver, amountOut);
            }
        }

       _transferOutETHWithGasLimitFallbackToWeth(request.executionFee, _executionFeeReceiver);

        emit ExecuteDecreasePosition(
            request.account,
            request.path,
            request.indexToken,
            request.collateralDelta,
            request.sizeDelta,
            request.isLong,
            request.receiver,
            request.acceptablePrice,
            request.minOut,
            request.executionFee,
            block.number.sub(request.blockNumber),
            block.timestamp.sub(request.blockTime)
        );

        _callRequestCallback(request.callbackTarget, _key, true, false);

        return true;
    }

    function cancelDecreasePosition(bytes32 _key, address payable _executionFeeReceiver) public nonReentrant returns (bool) {
        DecreasePositionRequest memory request = decreasePositionRequests[_key];
        // if the request was already executed or cancelled, return true so that the executeDecreasePositions loop will continue executing the next request
        if (request.account == address(0)) { return true; }

        bool shouldCancel = _validateCancellation(request.blockNumber, request.blockTime, request.account);
        if (!shouldCancel) { return false; }

        delete decreasePositionRequests[_key];

       _transferOutETHWithGasLimitFallbackToWeth(request.executionFee, _executionFeeReceiver);

        emit CancelDecreasePosition(
            request.account,
            request.path,
            request.indexToken,
            request.collateralDelta,
            request.sizeDelta,
            request.isLong,
            request.receiver,
            request.acceptablePrice,
            request.minOut,
            request.executionFee,
            block.number.sub(request.blockNumber),
            block.timestamp.sub(request.blockTime)
        );

        _callRequestCallback(request.callbackTarget, _key, false, false);

        return true;
    }

    function getRequestKey(address _account, uint256 _index) public pure returns (bytes32) {
        return keccak256(abi.encodePacked(_account, _index));
    }

    function getIncreasePositionRequestPath(bytes32 _key) public view override returns (address[] memory) {
        IncreasePositionRequest memory request = increasePositionRequests[_key];
        return request.path;
    }

    function getDecreasePositionRequestPath(bytes32 _key) public view override returns (address[] memory) {
        DecreasePositionRequest memory request = decreasePositionRequests[_key];
        return request.path;
    }

    function _setTraderReferralCode(bytes32 _referralCode) internal {
        if (_referralCode != bytes32(0) && referralStorage != address(0)) {
            IReferralStorage(referralStorage).setTraderReferralCode(msg.sender, _referralCode);
        }
    }

    function _validateExecution(uint256 _positionBlockNumber, uint256 _positionBlockTime, address _account) internal view returns (bool) {
        if (_positionBlockTime.add(maxTimeDelay) <= block.timestamp) {
            revert("expired");
        }

        return _validateExecutionOrCancellation(_positionBlockNumber, _positionBlockTime, _account);
    }

    function _validateCancellation(uint256 _positionBlockNumber, uint256 _positionBlockTime, address _account) internal view returns (bool) {
        return _validateExecutionOrCancellation(_positionBlockNumber, _positionBlockTime, _account);
    }

    function _validateExecutionOrCancellation(uint256 _positionBlockNumber, uint256 _positionBlockTime, address _account) internal view returns (bool) {
        bool isKeeperCall = msg.sender == address(this) || isPositionKeeper[msg.sender];

        if (!isLeverageEnabled && !isKeeperCall) {
            revert("403");
        }

        if (isKeeperCall) {
            return _positionBlockNumber.add(minBlockDelayKeeper) <= block.number;
        }

        require(msg.sender == _account, "403");

        require(_positionBlockTime.add(minTimeDelayPublic) <= block.timestamp, "delay");

        return true;
    }

    function _createIncreasePosition(
        address _account,
        address[] memory _path,
        address _indexToken,
        uint256 _amountIn,
        uint256 _minOut,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _acceptablePrice,
        uint256 _executionFee,
        bool _hasCollateralInETH,
        address _callbackTarget
    ) internal returns (bytes32) {
        IncreasePositionRequest memory request = IncreasePositionRequest(
            _account,
            _path,
            _indexToken,
            _amountIn,
            _minOut,
            _sizeDelta,            
            _acceptablePrice,
            _executionFee,
            block.number,
            block.timestamp,
            _isLong,
            _hasCollateralInETH,
            _callbackTarget
        );

        (uint256 index, bytes32 requestKey) = _storeIncreasePositionRequest(request);
        emit CreateIncreasePosition(
            _account,
            _path,
            _indexToken,
            _amountIn,
            _minOut,
            _sizeDelta,
            _isLong,
            _acceptablePrice,
            _executionFee,
            index,
            increasePositionRequestKeys.length - 1,
            block.number,
            block.timestamp,
            tx.gasprice
        );

        return requestKey;
    }

    function _storeIncreasePositionRequest(IncreasePositionRequest memory _request) internal returns (uint256, bytes32) {
        address account = _request.account;
        uint256 index = increasePositionsIndex[account].add(1);
        increasePositionsIndex[account] = index;
        bytes32 key = getRequestKey(account, index);

        increasePositionRequests[key] = _request;
        increasePositionRequestKeys.push(key);

        return (index, key);
    }

    function _storeDecreasePositionRequest(DecreasePositionRequest memory _request) internal returns (uint256, bytes32) {
        address account = _request.account;
        uint256 index = decreasePositionsIndex[account].add(1);
        decreasePositionsIndex[account] = index;
        bytes32 key = getRequestKey(account, index);

        decreasePositionRequests[key] = _request;
        decreasePositionRequestKeys.push(key);

        return (index, key);
    }

    function _createDecreasePosition(
        address _account,
        address[] memory _path,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver,
        uint256 _acceptablePrice,
        uint256 _minOut,
        uint256 _executionFee,
        bool _withdrawETH,
        address _callbackTarget
    ) internal returns (bytes32) {
        DecreasePositionRequest memory request = DecreasePositionRequest(
            _account,
            _path,
            _indexToken,
            _collateralDelta,
            _sizeDelta,            
            _receiver,
            _acceptablePrice,
            _minOut,
            _executionFee,
            block.number,
            block.timestamp,
            _isLong,
            _withdrawETH,
            _callbackTarget
        );

        (uint256 index, bytes32 requestKey) = _storeDecreasePositionRequest(request);
        emit CreateDecreasePosition(
            request.account,
            request.path,
            request.indexToken,
            request.collateralDelta,
            request.sizeDelta,
            request.isLong,
            request.receiver,
            request.acceptablePrice,
            request.minOut,
            request.executionFee,
            index,
            decreasePositionRequestKeys.length - 1,
            block.number,
            block.timestamp
        );
        return requestKey;
    }

    function _callRequestCallback(
        address _callbackTarget,
        bytes32 _key,
        bool _wasExecuted,
        bool _isIncrease
    ) internal {
        if (_callbackTarget == address(0)) {
            return;
        }

        if (!_callbackTarget.isContract()) {
            return;
        }

        uint256 _gasLimit = callbackGasLimit;

        if (_gasLimit == 0) {
            return;
        }

        bool success;
        try IPositionRouterCallbackReceiver(_callbackTarget).quickPositionCallback{ gas: _gasLimit }(_key, _wasExecuted, _isIncrease) {
            success = true;
        } catch {}

        emit Callback(_callbackTarget, success, _gasLimit);
    }

    function _validateTokens(address[] memory _path,address _indexToken) private view {
        require(IVault(vault).whitelistedTokens(_path[0]),"wl");
        if(_path.length==2){
            require(IVault(vault).whitelistedTokens(_path[1]),"wl");
        }
        require(IVault(vault).whitelistedTokens(_indexToken),"wl");
    }
}

File 2 of 20 : Governable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

contract Governable {
    address public gov;

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

    modifier onlyGov() {
        require(msg.sender == gov, "Governable: forbidden");
        _;
    }

    function setGov(address _gov) external onlyGov {
        gov = _gov;
    }
}

File 3 of 20 : BasePositionManager.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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/IShortsTracker.sol";
import "./interfaces/IOrderBook.sol";
import "./interfaces/IBasePositionManager.sol";

import "../access/Governable.sol";
import "../peripherals/interfaces/ITimelock.sol";
import "../referrals/interfaces/IReferralStorage.sol";

import "./PositionUtils.sol";

contract BasePositionManager is IBasePositionManager, ReentrancyGuard, Governable {

    using SafeMath for uint256;
    using SafeERC20 for IERC20;
    using Address for address payable;

    uint256 public constant BASIS_POINTS_DIVISOR = 10000;

    address public admin;

    address public vault;
    address public shortsTracker;
    address public router;
    address public weth;

    uint256 public ethTransferGasLimit = 500 * 1000;

    // to prevent using the deposit and withdrawal of collateral as a zero fee swap,
    // there is a small depositFee charged if a collateral deposit results in the decrease
    // of leverage for an existing position
    // increasePositionBufferBps allows for a small amount of decrease of leverage
    uint256 public depositFee;
    uint256 public increasePositionBufferBps = 100;

    address public referralStorage;

    mapping (address => uint256) public feeReserves;

    mapping (address => uint256) public override maxGlobalLongSizes;
    mapping (address => uint256) public override maxGlobalShortSizes;

    event SetDepositFee(uint256 depositFee);
    event SetEthTransferGasLimit(uint256 ethTransferGasLimit);
    event SetIncreasePositionBufferBps(uint256 increasePositionBufferBps);
    event SetReferralStorage(address referralStorage);
    event SetAdmin(address admin);
    event WithdrawFees(address token, address receiver, uint256 amount);

    event SetMaxGlobalSizes(
        address[] tokens,
        uint256[] longSizes,
        uint256[] shortSizes
    );

    event IncreasePositionReferral(
        address account,
        uint256 sizeDelta,
        uint256 marginFeeBasisPoints,
        bytes32 referralCode,
        address referrer
    );

    event DecreasePositionReferral(
        address account,
        uint256 sizeDelta,
        uint256 marginFeeBasisPoints,
        bytes32 referralCode,
        address referrer
    );

    modifier onlyAdmin() {
        require(msg.sender == admin, "forbidden");
        _;
    }

    constructor(
        address _vault,
        address _router,
        address _shortsTracker,
        address _weth,
        uint256 _depositFee
    ) public {
        vault = _vault;
        router = _router;
        weth = _weth;
        depositFee = _depositFee;
        shortsTracker = _shortsTracker;

        admin = msg.sender;
    }

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

    function setAdmin(address _admin) external onlyGov {
        admin = _admin;
        emit SetAdmin(_admin);
    }

    function setEthTransferGasLimit(uint256 _ethTransferGasLimit) external onlyAdmin {
        ethTransferGasLimit = _ethTransferGasLimit;
        emit SetEthTransferGasLimit(_ethTransferGasLimit);
    }

    function setDepositFee(uint256 _depositFee) external onlyAdmin {
        depositFee = _depositFee;
        emit SetDepositFee(_depositFee);
    }

    function setIncreasePositionBufferBps(uint256 _increasePositionBufferBps) external onlyAdmin {
        increasePositionBufferBps = _increasePositionBufferBps;
        emit SetIncreasePositionBufferBps(_increasePositionBufferBps);
    }

    function setReferralStorage(address _referralStorage) external onlyAdmin {
        referralStorage = _referralStorage;
        emit SetReferralStorage(_referralStorage);
    }

    function setMaxGlobalSizes(
        address[] memory _tokens,
        uint256[] memory _longSizes,
        uint256[] memory _shortSizes
    ) external onlyAdmin {
        for (uint256 i = 0; i < _tokens.length; i++) {
            address token = _tokens[i];
            maxGlobalLongSizes[token] = _longSizes[i];
            maxGlobalShortSizes[token] = _shortSizes[i];
        }

        emit SetMaxGlobalSizes(_tokens, _longSizes, _shortSizes);
    }

    function withdrawFees(address _token, address _receiver) external onlyAdmin {
        uint256 amount = feeReserves[_token];
        if (amount == 0) { return; }

        feeReserves[_token] = 0;
        IERC20(_token).safeTransfer(_receiver, amount);

        emit WithdrawFees(_token, _receiver, amount);
    }

    function approve(address _token, address _spender, uint256 _amount) external onlyGov {
        IERC20(_token).approve(_spender, _amount);
    }

    function sendValue(address payable _receiver, uint256 _amount) external onlyGov {
        _receiver.sendValue(_amount);
    }

    function _validateMaxGlobalSize(address _indexToken, bool _isLong, uint256 _sizeDelta) internal view {
        if (_sizeDelta == 0) {
            return;
        }

        if (_isLong) {
            uint256 maxGlobalLongSize = maxGlobalLongSizes[_indexToken];
            if (maxGlobalLongSize > 0 && IVault(vault).guaranteedUsd(_indexToken).add(_sizeDelta) > maxGlobalLongSize) {
                revert("max longs exceeded");
            }
        } else {
            uint256 maxGlobalShortSize = maxGlobalShortSizes[_indexToken];
            if (maxGlobalShortSize > 0 && IVault(vault).globalShortSizes(_indexToken).add(_sizeDelta) > maxGlobalShortSize) {
                revert("max shorts exceeded");
            }
        }
    }

    function _increasePosition(address _account, address _collateralToken, address _indexToken, uint256 _sizeDelta, bool _isLong, uint256 _price) internal {
        _validateMaxGlobalSize(_indexToken, _isLong, _sizeDelta);

        PositionUtils.increasePosition(
            vault,
            router,
            shortsTracker,
            _account,
            _collateralToken,
            _indexToken,
            _sizeDelta,
            _isLong,
            _price
        );

        _emitIncreasePositionReferral(_account, _sizeDelta);
    }

    function _decreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address _receiver, uint256 _price) internal returns (uint256) {
        address _vault = vault;

        uint256 markPrice = _isLong ? IVault(_vault).getMinPrice(_indexToken) : IVault(_vault).getMaxPrice(_indexToken);
        if (_isLong) {
            require(markPrice >= _price, "markPrice < price");
        } else {
            require(markPrice <= _price, "markPrice > price");
        }

        address timelock = IVault(_vault).gov();

        // should be called strictly before position is updated in Vault
        IShortsTracker(shortsTracker).updateGlobalShortData(_account, _collateralToken, _indexToken, _isLong, _sizeDelta, markPrice, false);

        ITimelock(timelock).enableLeverage(_vault);
        uint256 amountOut = IRouter(router).pluginDecreasePosition(_account, _collateralToken, _indexToken, _collateralDelta, _sizeDelta, _isLong, _receiver);
        ITimelock(timelock).disableLeverage(_vault);

        _emitDecreasePositionReferral(
            _account,
            _sizeDelta
        );

        return amountOut;
    }

    function _swap(address[] memory _path, uint256 _minOut, address _receiver) internal returns (uint256) {
        if (_path.length == 2) {
            return _vaultSwap(_path[0], _path[1], _minOut, _receiver);
        }
        revert("invalid _path.length");
    }

    function _vaultSwap(address _tokenIn, address _tokenOut, uint256 _minOut, address _receiver) internal returns (uint256) {
        uint256 amountOut = IVault(vault).swap(_tokenIn, _tokenOut, _receiver);
        require(amountOut >= _minOut, "insufficient amountOut");
        return amountOut;
    }

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

    function _transferOutETHWithGasLimitFallbackToWeth(uint256 _amountOut, address payable _receiver) internal {
        IWETH _weth = IWETH(weth);
        _weth.withdraw(_amountOut);

        (bool success, /* bytes memory data */) = _receiver.call{ value: _amountOut, gas: ethTransferGasLimit }("");

        if (success) { return; }

        // if the transfer failed, re-wrap the token and send it to the receiver
        _weth.deposit{ value: _amountOut }();
        _weth.transfer(address(_receiver), _amountOut);
    }

    function _collectFees(
        address _account,
        address[] memory _path,
        uint256 _amountIn,
        address _indexToken,
        bool _isLong,
        uint256 _sizeDelta
    ) internal returns (uint256) {
        bool shouldDeductFee = PositionUtils.shouldDeductFee(
            vault,
            _account,
            _path,
            _amountIn,
            _indexToken,
            _isLong,
            _sizeDelta,
            increasePositionBufferBps
        );

        if (shouldDeductFee) {
            uint256 afterFeeAmount = _amountIn.mul(BASIS_POINTS_DIVISOR.sub(depositFee)).div(BASIS_POINTS_DIVISOR);
            uint256 feeAmount = _amountIn.sub(afterFeeAmount);
            address feeToken = _path[_path.length - 1];
            feeReserves[feeToken] = feeReserves[feeToken].add(feeAmount);
            return afterFeeAmount;
        }

        return _amountIn;
    }

    function _emitIncreasePositionReferral(address _account, uint256 _sizeDelta) internal {
        address _referralStorage = referralStorage;
        if (_referralStorage == address(0)) { return; }


        (bytes32 referralCode, address referrer) = IReferralStorage(_referralStorage).getTraderReferralInfo(_account);
        if (referralCode == bytes32(0)) { return; }

        address timelock = IVault(vault).gov();

        emit IncreasePositionReferral(
            _account,
            _sizeDelta,
            ITimelock(timelock).marginFeeBasisPoints(),
            referralCode,
            referrer
        );
    }

    function _emitDecreasePositionReferral(address _account, uint256 _sizeDelta) internal {
        address _referralStorage = referralStorage;
        if (_referralStorage == address(0)) { return; }

        (bytes32 referralCode, address referrer) = IReferralStorage(_referralStorage).getTraderReferralInfo(_account);
        if (referralCode == bytes32(0)) { return; }

        address timelock = IVault(vault).gov();

        emit DecreasePositionReferral(
            _account,
            _sizeDelta,
            ITimelock(timelock).marginFeeBasisPoints(),
            referralCode,
            referrer
        );
    }
}

File 4 of 20 : IBasePositionManager.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IBasePositionManager {
    function maxGlobalLongSizes(address _token) external view returns (uint256);
    function maxGlobalShortSizes(address _token) external view returns (uint256);
}

File 5 of 20 : 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 6 of 20 : IPositionRouter.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IPositionRouter {
    function increasePositionRequestKeysStart() external view returns (uint256);
    function decreasePositionRequestKeysStart() external view returns (uint256);
    function increasePositionRequestKeys(uint256 index) external view returns (bytes32);
    function decreasePositionRequestKeys(uint256 index) external view returns (bytes32);
    function executeIncreasePositions(uint256 _count, address payable _executionFeeReceiver) external;
    function executeDecreasePositions(uint256 _count, address payable _executionFeeReceiver) external;
    function getRequestQueueLengths() external view returns (uint256, uint256, uint256, uint256);
    function getIncreasePositionRequestPath(bytes32 _key) external view returns (address[] memory);
    function getDecreasePositionRequestPath(bytes32 _key) external view returns (address[] memory);
}

File 7 of 20 : IPositionRouterCallbackReceiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

interface IPositionRouterCallbackReceiver {
    function quickPositionCallback(bytes32 positionKey, bool isExecuted, bool isIncrease) external;
}

File 8 of 20 : 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 9 of 20 : IShortsTracker.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IShortsTracker {
    function isGlobalShortDataReady() external view returns (bool);
    function globalShortAveragePrices(address _token) external view returns (uint256);
    function getNextGlobalShortData(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _nextPrice,
        uint256 _sizeDelta,
        bool _isIncrease
    ) external view returns (uint256, uint256);
    function updateGlobalShortData(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        uint256 _sizeDelta,
        uint256 _markPrice,
        bool _isIncrease
    ) external;
    function setIsGlobalShortDataReady(bool value) external;
    function setInitData(address[] calldata _tokens, uint256[] calldata _averagePrices) external;
}

File 10 of 20 : 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 11 of 20 : 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 12 of 20 : PositionUtils.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../libraries/math/SafeMath.sol";
import "../peripherals/interfaces/ITimelock.sol";

import "./interfaces/IVault.sol";
import "./interfaces/IRouter.sol";
import "./interfaces/IShortsTracker.sol";

library PositionUtils {
    using SafeMath for uint256;

    uint256 public constant BASIS_POINTS_DIVISOR = 10000;

    event LeverageDecreased(uint256 collateralDelta, uint256 prevLeverage, uint256 nextLeverage);

    function shouldDeductFee(
        address _vault,
        address _account,
        address[] memory _path,
        uint256 _amountIn,
        address _indexToken,
        bool _isLong,
        uint256 _sizeDelta,
        uint256 _increasePositionBufferBps
    ) external returns (bool) {
        // if the position is a short, do not charge a fee
        if (!_isLong) { return false; }

        // if the position size is not increasing, this is a collateral deposit
        if (_sizeDelta == 0) { return true; }

        address collateralToken = _path[_path.length - 1];

        IVault vault = IVault(_vault);
        (uint256 size, uint256 collateral, , , , , , ) = vault.getPosition(_account, collateralToken, _indexToken, _isLong);

        // if there is no existing position, do not charge a fee
        if (size == 0) { return false; }

        uint256 nextSize = size.add(_sizeDelta);
        uint256 collateralDelta = vault.tokenToUsdMin(collateralToken, _amountIn);
        uint256 nextCollateral = collateral.add(collateralDelta);

        uint256 prevLeverage = size.mul(BASIS_POINTS_DIVISOR).div(collateral);
        // allow for a maximum of a increasePositionBufferBps decrease since there might be some swap fees taken from the collateral
        uint256 nextLeverage = nextSize.mul(BASIS_POINTS_DIVISOR + _increasePositionBufferBps).div(nextCollateral);

        emit LeverageDecreased(collateralDelta, prevLeverage, nextLeverage);

        // deduct a fee if the leverage is decreased
        return nextLeverage < prevLeverage;
    }

    function increasePosition(
        address _vault,
        address _router,
        address _shortsTracker,
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _price
    ) external {
        uint256 markPrice = _isLong ? IVault(_vault).getMaxPrice(_indexToken) : IVault(_vault).getMinPrice(_indexToken);
        if (_isLong) {
            require(markPrice <= _price, "markPrice > price");
        } else {
            require(markPrice >= _price, "markPrice < price");
        }

        address timelock = IVault(_vault).gov();

        // should be called strictly before position is updated in Vault
        IShortsTracker(_shortsTracker).updateGlobalShortData(_account, _collateralToken, _indexToken, _isLong, _sizeDelta, markPrice, true);

        ITimelock(timelock).enableLeverage(_vault);
        IRouter(_router).pluginIncreasePosition(_account, _collateralToken, _indexToken, _sizeDelta, _isLong);
        ITimelock(timelock).disableLeverage(_vault);
    }
}

File 13 of 20 : 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 14 of 20 : 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 15 of 20 : 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 16 of 20 : 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 17 of 20 : 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 18 of 20 : ITimelock.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface ITimelock {
    function marginFeeBasisPoints() external returns (uint256);
    function setAdmin(address _admin) external;
    function enableLeverage(address _vault) external;
    function disableLeverage(address _vault) external;
    function setIsLeverageEnabled(address _vault, bool _isLeverageEnabled) external;
    function signalSetGov(address _target, address _gov) external;
}

File 19 of 20 : IReferralStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IReferralStorage {
    function codeOwners(bytes32 _code) external view returns (address);
    function traderReferralCodes(address _account) external view returns (bytes32);
    function referrerDiscountShares(address _account) external view returns (uint256);
    function referrerTiers(address _account) external view returns (uint256);
    function getTraderReferralInfo(address _account) external view returns (bytes32, address);
    function setTraderReferralCode(address _account, bytes32 _code) external;
    function setTier(uint256 _tierId, uint256 _totalRebate, uint256 _discountShare) external;
    function setReferrerTier(address _referrer, uint256 _tierId) external;
    function govSetCodeOwner(bytes32 _code, address _newAccount) external;
}

File 20 of 20 : 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": {
    "contracts/core/PositionUtils.sol": {
      "PositionUtils": "0x11e3657fcde2053db4ec0e6327c3908aaf449c7b"
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_vault","type":"address"},{"internalType":"address","name":"_router","type":"address"},{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_shortsTracker","type":"address"},{"internalType":"uint256","name":"_depositFee","type":"uint256"},{"internalType":"uint256","name":"_minExecutionFee","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"callbackTarget","type":"address"},{"indexed":false,"internalType":"bool","name":"success","type":"bool"},{"indexed":false,"internalType":"uint256","name":"callbackGasLimit","type":"uint256"}],"name":"Callback","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address[]","name":"path","type":"address[]"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"acceptablePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"blockGap","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timeGap","type":"uint256"}],"name":"CancelDecreasePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address[]","name":"path","type":"address[]"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"acceptablePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"blockGap","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timeGap","type":"uint256"}],"name":"CancelIncreasePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address[]","name":"path","type":"address[]"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"acceptablePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"queueIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"blockNumber","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"blockTime","type":"uint256"}],"name":"CreateDecreasePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address[]","name":"path","type":"address[]"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"acceptablePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"queueIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"blockNumber","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"blockTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"gasPrice","type":"uint256"}],"name":"CreateIncreasePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"marginFeeBasisPoints","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"referralCode","type":"bytes32"},{"indexed":false,"internalType":"address","name":"referrer","type":"address"}],"name":"DecreasePositionReferral","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address[]","name":"path","type":"address[]"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"acceptablePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"blockGap","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timeGap","type":"uint256"}],"name":"ExecuteDecreasePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address[]","name":"path","type":"address[]"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"acceptablePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"blockGap","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timeGap","type":"uint256"}],"name":"ExecuteIncreasePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"marginFeeBasisPoints","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"referralCode","type":"bytes32"},{"indexed":false,"internalType":"address","name":"referrer","type":"address"}],"name":"IncreasePositionReferral","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"admin","type":"address"}],"name":"SetAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"callbackGasLimit","type":"uint256"}],"name":"SetCallbackGasLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minBlockDelayKeeper","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minTimeDelayPublic","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxTimeDelay","type":"uint256"}],"name":"SetDelayValues","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"depositFee","type":"uint256"}],"name":"SetDepositFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"ethTransferGasLimit","type":"uint256"}],"name":"SetEthTransferGasLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"increasePositionBufferBps","type":"uint256"}],"name":"SetIncreasePositionBufferBps","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isLeverageEnabled","type":"bool"}],"name":"SetIsLeverageEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"longSizes","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"shortSizes","type":"uint256[]"}],"name":"SetMaxGlobalSizes","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minExecutionFee","type":"uint256"}],"name":"SetMinExecutionFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isActive","type":"bool"}],"name":"SetPositionKeeper","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"referralStorage","type":"address"}],"name":"SetReferralStorage","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"increasePositionRequestKeysStart","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"decreasePositionRequestKeysStart","type":"uint256"}],"name":"SetRequestKeysStartValues","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawFees","type":"event"},{"inputs":[],"name":"BASIS_POINTS_DIVISOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"callbackGasLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"},{"internalType":"address payable","name":"_executionFeeReceiver","type":"address"}],"name":"cancelDecreasePosition","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"},{"internalType":"address payable","name":"_executionFeeReceiver","type":"address"}],"name":"cancelIncreasePosition","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_collateralDelta","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_acceptablePrice","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"uint256","name":"_executionFee","type":"uint256"},{"internalType":"bool","name":"_withdrawETH","type":"bool"},{"internalType":"address","name":"_callbackTarget","type":"address"}],"name":"createDecreasePosition","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_amountIn","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_acceptablePrice","type":"uint256"},{"internalType":"uint256","name":"_executionFee","type":"uint256"},{"internalType":"bytes32","name":"_referralCode","type":"bytes32"},{"internalType":"address","name":"_callbackTarget","type":"address"}],"name":"createIncreasePosition","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_path","type":"address[]"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_minOut","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_acceptablePrice","type":"uint256"},{"internalType":"uint256","name":"_executionFee","type":"uint256"},{"internalType":"bytes32","name":"_referralCode","type":"bytes32"},{"internalType":"address","name":"_callbackTarget","type":"address"}],"name":"createIncreasePositionETH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"decreasePositionRequestKeys","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decreasePositionRequestKeysStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"decreasePositionRequests","outputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"acceptablePrice","type":"uint256"},{"internalType":"uint256","name":"minOut","type":"uint256"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"uint256","name":"blockTime","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"bool","name":"withdrawETH","type":"bool"},{"internalType":"address","name":"callbackTarget","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"decreasePositionsIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ethTransferGasLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"},{"internalType":"address payable","name":"_executionFeeReceiver","type":"address"}],"name":"executeDecreasePosition","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_endIndex","type":"uint256"},{"internalType":"address payable","name":"_executionFeeReceiver","type":"address"}],"name":"executeDecreasePositions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"},{"internalType":"address payable","name":"_executionFeeReceiver","type":"address"}],"name":"executeIncreasePosition","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_endIndex","type":"uint256"},{"internalType":"address payable","name":"_executionFeeReceiver","type":"address"}],"name":"executeIncreasePositions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feeReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"getDecreasePositionRequestPath","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_key","type":"bytes32"}],"name":"getIncreasePositionRequestPath","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getRequestKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getRequestQueueLengths","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gov","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"increasePositionBufferBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"increasePositionRequestKeys","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"increasePositionRequestKeysStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"increasePositionRequests","outputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"indexToken","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"minOut","type":"uint256"},{"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"internalType":"uint256","name":"acceptablePrice","type":"uint256"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"uint256","name":"blockTime","type":"uint256"},{"internalType":"bool","name":"isLong","type":"bool"},{"internalType":"bool","name":"hasCollateralInETH","type":"bool"},{"internalType":"address","name":"callbackTarget","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"increasePositionsIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isLeverageEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isPositionKeeper","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxGlobalLongSizes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxGlobalShortSizes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTimeDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minBlockDelayKeeper","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minExecutionFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minTimeDelayPublic","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referralStorage","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 payable","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"sendValue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_admin","type":"address"}],"name":"setAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_callbackGasLimit","type":"uint256"}],"name":"setCallbackGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minBlockDelayKeeper","type":"uint256"},{"internalType":"uint256","name":"_minTimeDelayPublic","type":"uint256"},{"internalType":"uint256","name":"_maxTimeDelay","type":"uint256"}],"name":"setDelayValues","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositFee","type":"uint256"}],"name":"setDepositFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_ethTransferGasLimit","type":"uint256"}],"name":"setEthTransferGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gov","type":"address"}],"name":"setGov","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_increasePositionBufferBps","type":"uint256"}],"name":"setIncreasePositionBufferBps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isLeverageEnabled","type":"bool"}],"name":"setIsLeverageEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_longSizes","type":"uint256[]"},{"internalType":"uint256[]","name":"_shortSizes","type":"uint256[]"}],"name":"setMaxGlobalSizes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minExecutionFee","type":"uint256"}],"name":"setMinExecutionFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_isActive","type":"bool"}],"name":"setPositionKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_referralStorage","type":"address"}],"name":"setReferralStorage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_increasePositionRequestKeysStart","type":"uint256"},{"internalType":"uint256","name":"_decreasePositionRequestKeysStart","type":"uint256"}],"name":"setRequestKeysStartValues","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shortsTracker","outputs":[{"internalType":"address","name":"","type":"address"}],"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"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"withdrawFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040526207a12060075560646009556012805460ff191660011790553480156200002a57600080fd5b50604051620060a2380380620060a2833981810160405260c08110156200005057600080fd5b508051602082015160408301516060840151608085015160a090950151600160008181558154336001600160a01b031991821681179093556003805482166001600160a01b03998a16179055600580548216978916979097179096556006805487169588169590951790945560089690965560048054851695909216949094179055600280549092169093179055600e55615fb0908190620000f290396000f3fe6080604052600436106102945760003560e01c80626cc35e146102f057806304225954146103215780630d4d003d1461035d5780631045c74e146103aa578063126082cf146103dd57806312d43a51146103f25780631bca8cf0146104075780631ce9cb8f1461041c5780631f2851061461044f578063225fc9fd146104f3578063233bfe3b1461052c57806324a084df1461055657806324f746971461058f57806327b42c0f146105a45780632d79cf42146105dd578063308aa81f146105f25780633422ead11461062257806336eba48a1461065d5780633a2a80c7146106905780633a9b52ad146106a55780633e72a262146106cf5780633fc8cef3146106e45780634067b132146106f95780634278555f1461072f578063490ae210146107595780635841fcaa146107835780635b88e8c6146107985780635d5c22e81461087157806360a362e2146108eb57806362f8a3fe14610924578063633451de1461095d57806363ae210314610990578063657bc5d0146109a557806367a52793146109ba578063704b6c02146109cf5780637be7d14114610a025780637c2eb9f714610aed5780638a54942f14610b1957806395e9bbd714610b435780639698d25a14610b6d57806398d1e03a14610ba05780639a20810014610bb55780639b57862014610bee578063ae4d7f9a14610c03578063cb0269c914610c36578063cfad57a214610c4b578063e1f21c6714610c7e578063ef12c67e14610cc1578063f255527814610e73578063f2ae372f14610eae578063f2cea6a514610f8d578063f3883d8b14610fc8578063f851a44014611001578063f887ea4014611016578063fa4445771461102b578063faf990f31461105e578063fbfa77cf146110f9578063fc2cee621461110e576102eb565b366102eb576006546001600160a01b031633146102e9576040805162461bcd60e51b815260206004820152600e60248201526d34b73b30b634b21039b2b73232b960911b604482015290519081900360640190fd5b005b600080fd5b3480156102fc57600080fd5b50610305611138565b604080516001600160a01b039092168252519081900360200190f35b34801561032d57600080fd5b5061034b6004803603602081101561034457600080fd5b5035611147565b60408051918252519081900360200190f35b34801561036957600080fd5b506103966004803603604081101561038057600080fd5b50803590602001356001600160a01b0316611165565b604080519115158252519081900360200190f35b3480156103b657600080fd5b5061034b600480360360208110156103cd57600080fd5b50356001600160a01b0316611609565b3480156103e957600080fd5b5061034b61161b565b3480156103fe57600080fd5b50610305611621565b34801561041357600080fd5b5061034b611630565b34801561042857600080fd5b5061034b6004803603602081101561043f57600080fd5b50356001600160a01b0316611636565b34801561045b57600080fd5b506104796004803603602081101561047257600080fd5b5035611648565b604080516001600160a01b039e8f1681529c8e1660208e01528c81019b909b5260608c0199909952968b1660808b015260a08a019590955260c089019390935260e0880191909152610100870152610120860152151561014085015215156101608401529092166101808201529051908190036101a00190f35b3480156104ff57600080fd5b506103966004803603604081101561051657600080fd5b50803590602001356001600160a01b03166116c6565b34801561053857600080fd5b506102e96004803603602081101561054f57600080fd5b5035611a84565b34801561056257600080fd5b506102e96004803603604081101561057957600080fd5b506001600160a01b038135169060200135611b0a565b34801561059b57600080fd5b5061034b611b6e565b3480156105b057600080fd5b50610396600480360360408110156105c757600080fd5b50803590602001356001600160a01b0316611b74565b3480156105e957600080fd5b5061034b611fd0565b3480156105fe57600080fd5b506102e96004803603604081101561061557600080fd5b5080359060200135611fd6565b34801561062e57600080fd5b506102e96004803603604081101561064557600080fd5b506001600160a01b038135169060200135151561206a565b34801561066957600080fd5b506103966004803603602081101561068057600080fd5b50356001600160a01b0316612115565b34801561069c57600080fd5b5061034b61212a565b3480156106b157600080fd5b506102e9600480360360208110156106c857600080fd5b5035612130565b3480156106db57600080fd5b506103966121b6565b3480156106f057600080fd5b506103056121bf565b34801561070557600080fd5b506102e96004803603606081101561071c57600080fd5b50803590602081013590604001356121ce565b34801561073b57600080fd5b5061034b6004803603602081101561075257600080fd5b503561226d565b34801561076557600080fd5b506102e96004803603602081101561077c57600080fd5b503561227a565b34801561078f57600080fd5b5061034b612300565b61034b60048036036101208110156107af57600080fd5b810190602081018135600160201b8111156107c957600080fd5b8201836020820111156107db57600080fd5b803590602001918460208302840111600160201b831117156107fc57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550505081356001600160a01b03908116935060208301359260408101359250606081013515159160808201359160a08101359160c08201359160e0013516612306565b34801561087d57600080fd5b5061089b6004803603602081101561089457600080fd5b50356124cc565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156108d75781810151838201526020016108bf565b505050509050019250505060405180910390f35b3480156108f757600080fd5b506103966004803603604081101561090e57600080fd5b50803590602001356001600160a01b0316612608565b34801561093057600080fd5b5061034b6004803603604081101561094757600080fd5b506001600160a01b0381351690602001356129a8565b34801561096957600080fd5b5061034b6004803603602081101561098057600080fd5b50356001600160a01b03166129ee565b34801561099c57600080fd5b5061034b612a00565b3480156109b157600080fd5b50610305612a06565b3480156109c657600080fd5b5061034b612a15565b3480156109db57600080fd5b506102e9600480360360208110156109f257600080fd5b50356001600160a01b0316612a1b565b61034b6004803603610160811015610a1957600080fd5b810190602081018135600160201b811115610a3357600080fd5b820183602082011115610a4557600080fd5b803590602001918460208302840111600160201b83111715610a6657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550505081356001600160a01b039081169350602083013592604081013592506060810135151591608082013581169160a08101359160c08201359160e081013591610100820135151591610120013516612abc565b348015610af957600080fd5b506102e960048036036020811015610b1057600080fd5b50351515612c76565b348015610b2557600080fd5b506102e960048036036020811015610b3c57600080fd5b5035612d08565b348015610b4f57600080fd5b5061089b60048036036020811015610b6657600080fd5b5035612d8e565b348015610b7957600080fd5b5061034b60048036036020811015610b9057600080fd5b50356001600160a01b0316612ebd565b348015610bac57600080fd5b5061034b612ecf565b348015610bc157600080fd5b506102e960048036036040811015610bd857600080fd5b50803590602001356001600160a01b0316612ed5565b348015610bfa57600080fd5b5061034b6130ad565b348015610c0f57600080fd5b506102e960048036036020811015610c2657600080fd5b50356001600160a01b03166130b3565b348015610c4257600080fd5b5061034b613152565b348015610c5757600080fd5b506102e960048036036020811015610c6e57600080fd5b50356001600160a01b0316613158565b348015610c8a57600080fd5b506102e960048036036060811015610ca157600080fd5b506001600160a01b038135811691602081013590911690604001356131c7565b348015610ccd57600080fd5b506102e960048036036060811015610ce457600080fd5b810190602081018135600160201b811115610cfe57600080fd5b820183602082011115610d1057600080fd5b803590602001918460208302840111600160201b83111715610d3157600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610d8057600080fd5b820183602082011115610d9257600080fd5b803590602001918460208302840111600160201b83111715610db357600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610e0257600080fd5b820183602082011115610e1457600080fd5b803590602001918460208302840111600160201b83111715610e3557600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061329c945050505050565b348015610e7f57600080fd5b506102e960048036036040811015610e9657600080fd5b506001600160a01b0381358116916020013516613489565b61034b6004803603610140811015610ec557600080fd5b810190602081018135600160201b811115610edf57600080fd5b820183602082011115610ef157600080fd5b803590602001918460208302840111600160201b83111715610f1257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550506001600160a01b038335811694506020840135936040810135935060608101359250608081013515159160a08201359160c08101359160e08201359161010001351661356b565b348015610f9957600080fd5b50610fa2613758565b604080519485526020850193909352838301919091526060830152519081900360800190f35b348015610fd457600080fd5b506102e960048036036040811015610feb57600080fd5b50803590602001356001600160a01b031661376a565b34801561100d57600080fd5b50610305613942565b34801561102257600080fd5b50610305613951565b34801561103757600080fd5b5061034b6004803603602081101561104e57600080fd5b50356001600160a01b0316613960565b34801561106a57600080fd5b506110886004803603602081101561108157600080fd5b5035613972565b604080516001600160a01b039d8e1681529b8d1660208d01528b81019a909a5260608b019890985260808a019690965260a089019490945260c088019290925260e0870152610100860152151561012085015215156101408401529092166101608201529051908190036101800190f35b34801561110557600080fd5b506103056139e6565b34801561111a57600080fd5b506102e96004803603602081101561113157600080fd5b50356139f5565b600a546001600160a01b031681565b6013818154811061115457fe5b600091825260209091200154905081565b6000600260005414156111ad576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b60026000556111ba615ce3565b6000848152601c602090815260409182902082516101c08101845281546001600160a01b031681526001820180548551818602810186019096528086529194929385810193929083018282801561123a57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161121c575b505050918352505060028201546001600160a01b0390811660208301526003830154604083015260048301546060830152600583015481166080830152600683015460a0830152600783015460c0830152600883015460e0830152600983015461010080840191909152600a840154610120840152600b9093015460ff80821615156101408501529381049093161515610160830152620100009092048216610180909101528151919250166112f45760019150506115fe565b600061130f8261012001518361014001518460000151613a7b565b905080611321576000925050506115fe565b6000858152601c6020526040812080546001600160a01b03191681559061134b6001830182615d7a565b506002810180546001600160a01b03199081169091556000600383018190556004830181905560058301805490921690915560068201819055600782018190556008820181905560098201819055600a8201819055600b90910180546001600160b01b03191690558251602084015180516113f292919084906113ca57fe5b6020026020010151856040015186606001518760800151886101600151308a60c00151613ae4565b905080156114a05760018360200151511115611461576003546020840151805161144b926001600160a01b031691849160009061142b57fe5b60200260200101516001600160a01b0316613f919092919063ffffffff16565b61145e83602001518460e0015130613fe8565b90505b8261018001511561147f5761147a818460a00151614073565b6114a0565b6114a08360a001518285602001516001876020015151038151811061142b57fe5b6114af83610100015186614073565b82600001516001600160a01b03167f21435c5b618d77ff3657140cd3318e2cffaebc5e0e1b7318f56a9ba4044c3ed284602001518560400151866060015187608001518861016001518960a001518a60c001518b60e001518c61010001516115258e61012001514361421b90919063ffffffff16565b6101408f015161153690429061421b565b60405180806020018c6001600160a01b031681526020018b81526020018a81526020018915158152602001886001600160a01b0316815260200187815260200186815260200185815260200184815260200183815260200182810382528d818151815260200191508051906020019060200280838360005b838110156115c65781810151838201526020016115ae565b505050509050019c5050505050505050505050505060405180910390a26115f6836101a00151876001600061425d565b600193505050505b600160005592915050565b600c6020526000908152604090205481565b61271081565b6001546001600160a01b031681565b60165481565b600b6020526000908152604090205481565b601c602052600090815260409020805460028201546003830154600484015460058501546006860154600787015460088801546009890154600a8a0154600b909a01546001600160a01b03998a169a988a1699979896979586169694959394929391929160ff8083169261010081049091169162010000909104168d565b60006002600054141561170e576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b600260005561171b615d98565b6000848152601a602090815260409182902082516101a08101845281546001600160a01b031681526001820180548551818602810186019096528086529194929385810193929083018282801561179b57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161177d575b505050918352505060028201546001600160a01b039081166020830152600383015460408301526004830154606083015260058301546080830152600683015460a0830152600783015460c0830152600883015460e0830152600983015461010080840191909152600a9093015460ff80821615156101208501529381049093161515610140830152620100009092048216610160909101528151919250166118485760019150506115fe565b60006118638261010001518361012001518460000151614368565b905080611875576000925050506115fe565b6000858152601a6020526040812080546001600160a01b03191681559061189f6001830182615d7a565b506002810180546001600160a01b031916905560006003820181905560048201819055600582018190556006820181905560078201819055600882018190556009820155600a0180546001600160b01b0319169055610160820151156119165761191182606001518360000151614073565b611934565b61193482600001518360600151846020015160008151811061142b57fe5b6119428260e0015185614073565b81600001516001600160a01b03167f35b638e650e2328786fb405bd69d2083dbedc018d086662e74b775b4f1dae4bf83602001518460400151856060015186608001518760a001518861014001518960c001518a60e001516119b28c61010001514361421b90919063ffffffff16565b6101208d01516119c390429061421b565b60405180806020018b6001600160a01b031681526020018a8152602001898152602001888152602001871515815260200186815260200185815260200184815260200183815260200182810382528c818151815260200191508051906020019060200280838360005b83811015611a44578181015183820152602001611a2c565b505050509050019b50505050505050505050505060405180910390a2611a73826101800151866000600161425d565b600192505050600160005592915050565b6002546001600160a01b03163314611acf576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b60098190556040805182815290517f21167d0d4661af93817ebce920f18986eed3d75d5e1c03f2aed05efcbafbc4529181900360200190a150565b6001546001600160a01b03163314611b57576040805162461bcd60e51b81526020600482015260156024820152600080516020615ed9833981519152604482015290519081900360640190fd5b611b6a6001600160a01b03831682614375565b5050565b60175481565b600060026000541415611bbc576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b6002600055611bc9615d98565b6000848152601a602090815260409182902082516101a08101845281546001600160a01b0316815260018201805485518186028101860190965280865291949293858101939290830182828015611c4957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611c2b575b505050918352505060028201546001600160a01b039081166020830152600383015460408301526004830154606083015260058301546080830152600683015460a0830152600783015460c0830152600883015460e0830152600983015461010080840191909152600a9093015460ff8082161515610120850152938104909316151561014083015262010000909204821661016090910152815191925016611cf65760019150506115fe565b6000611d118261010001518361012001518460000151613a7b565b905080611d23576000925050506115fe565b6000858152601a6020526040812080546001600160a01b031916815590611d4d6001830182615d7a565b506002810180546001600160a01b031916905560006003820181905560048201819055600582018190556006820181905560078201819055600882018190556009820155600a0180546001600160b01b0319169055606082015115611e5357606082015160208301515160011015611dfd57600354606084015160208501518051611de7936001600160a01b031692919060009061142b57fe5b611dfa8360200151846080015130613fe8565b90505b6000611e22846000015185602001518487604001518861014001518960a0015161445a565b60035460208601518051929350611e50926001600160a01b0390921691849190600019810190811061142b57fe5b50505b815160208301518051611e929291906000198101908110611e7057fe5b602002602001015184604001518560a001518661014001518760c00151614650565b611ea08260e0015185614073565b81600001516001600160a01b03167f1be316b94d38c07bd41cdb4913772d0a0a82802786a2f8b657b6e85dbcdfc64183602001518460400151856060015186608001518760a001518861014001518960c001518a60e00151611f108c61010001514361421b90919063ffffffff16565b6101208d0151611f2190429061421b565b60405180806020018b6001600160a01b031681526020018a8152602001898152602001888152602001871515815260200186815260200185815260200184815260200183815260200182810382528c818151815260200191508051906020019060200280838360005b83811015611fa2578181015183820152602001611f8a565b505050509050019b50505050505050505050505060405180910390a2611a738261018001518660018061425d565b60075481565b6002546001600160a01b03163314612021576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b60158290556016819055604080518381526020810183905281517febb0f666150f4be5b60c45df8f3e49992510b0128027fe58eea6110f296493bc929181900390910190a15050565b6002546001600160a01b031633146120b5576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b6001600160a01b038216600081815260186020908152604091829020805460ff1916851515908117909155825190815291517ffbabc02389290a451c6e600d05bf9887b99bfad39d8e1237e4e3df042e4941fe9281900390910190a25050565b60186020526000908152604090205460ff1681565b60105481565b6002546001600160a01b0316331461217b576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b60078190556040805182815290517f4d371d598d3a13f99ce992a17975bbaf1e1c256e072ec7d2f93ce88e40d9ba1c9181900360200190a150565b60125460ff1681565b6006546001600160a01b031681565b6002546001600160a01b03163314612219576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b600f83905560108290556011819055604080518481526020810184905280820183905290517fb98e759701eaca2e60c25e91109003c1c7442ef731b5d569037063005da8254d9181900360600190a1505050565b6014818154811061115457fe5b6002546001600160a01b031633146122c5576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b60088190556040805182815290517f974fd3c1fcb4653dfc4fb740c4c692cd212d55c28f163f310128cb64d83006759181900360200190a150565b600f5481565b60006002600054141561234e576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b6002600055600e54841015612390576040805162461bcd60e51b815260206004820152600360248201526266656560e81b604482015290519081900360640190fd5b833410156123cb576040805162461bcd60e51b81526020600482015260036024820152621d985b60ea1b604482015290519081900360640190fd5b8951600114806123dc575089516002145b612413576040805162461bcd60e51b81526020600482015260036024820152623632b760e91b604482015290519081900360640190fd5b6006548a516001600160a01b03909116908b9060009061242f57fe5b60200260200101516001600160a01b03161461247b576040805162461bcd60e51b815260206004808301919091526024820152630e0c2e8d60e31b604482015290519081900360640190fd5b6124858a8a614722565b61248d61496f565b612496836149db565b60006124a2348661421b565b90506124b8338c8c848d8d8d8d8d60018d614a4f565b60016000559b9a5050505050505050505050565b60606124d6615ce3565b6000838152601c602090815260409182902082516101c08101845281546001600160a01b031681526001820180548551818602810186019096528086529194929385810193929083018282801561255657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612538575b505050918352505060028201546001600160a01b039081166020808401919091526003840154604084015260048401546060840152600584015482166080840152600684015460a0840152600784015460c0840152600884015460e0840152600984015461010080850191909152600a850154610120850152600b9094015460ff8082161515610140860152948104909416151561016084015262010000909304166101809091015201519392505050565b600060026000541415612650576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b600260005561265d615ce3565b6000848152601c602090815260409182902082516101c08101845281546001600160a01b03168152600182018054855181860281018601909652808652919492938581019392908301828280156126dd57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116126bf575b505050918352505060028201546001600160a01b0390811660208301526003830154604083015260048301546060830152600583015481166080830152600683015460a0830152600783015460c0830152600883015460e0830152600983015461010080840191909152600a840154610120840152600b9093015460ff80821615156101408501529381049093161515610160830152620100009092048216610180909101528151919250166127975760019150506115fe565b60006127b28261012001518361014001518460000151614368565b9050806127c4576000925050506115fe565b6000858152601c6020526040812080546001600160a01b0319168155906127ee6001830182615d7a565b506002810180546001600160a01b03199081169091556000600383018190556004830181905560058301805490921690915560068201819055600782018190556008820181905560098201819055600a820155600b0180546001600160b01b03191690556101008201516128629085614073565b81600001516001600160a01b03167f87abfd78e844f28318363bdf3da99eab2f4a2da9ff7ae365484507f7b6c3f80583602001518460400151856060015186608001518761016001518860a001518960c001518a60e001518b61010001516128d88d61012001514361421b90919063ffffffff16565b6101408e01516128e990429061421b565b60405180806020018c6001600160a01b031681526020018b81526020018a81526020018915158152602001886001600160a01b0316815260200187815260200186815260200185815260200184815260200183815260200182810382528d818151815260200191508051906020019060200280838360005b83811015612979578181015183820152602001612961565b505050509050019c5050505050505050505050505060405180910390a2611a73826101a001518660008061425d565b6000828260405160200180836001600160a01b031660601b8152601401828152602001925050506040516020818303038152906040528051906020012090505b92915050565b60196020526000908152604090205481565b600e5481565b6004546001600160a01b031681565b60085481565b6001546001600160a01b03163314612a68576040805162461bcd60e51b81526020600482015260156024820152600080516020615ed9833981519152604482015290519081900360640190fd5b600280546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f5a272403b402d892977df56625f4164ccaf70ca3863991c43ecfe76a6905b0a19181900360200190a150565b600060026000541415612b04576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b6002600055600e54841015612b46576040805162461bcd60e51b815260206004820152600360248201526266656560e81b604482015290519081900360640190fd5b833414612b80576040805162461bcd60e51b81526020600482015260036024820152621d985b60ea1b604482015290519081900360640190fd5b8b5160011480612b9157508b516002145b612bc8576040805162461bcd60e51b81526020600482015260036024820152623632b760e91b604482015290519081900360640190fd5b8215612c3b576006548c516001600160a01b03909116908d906000198101908110612bef57fe5b60200260200101516001600160a01b031614612c3b576040805162461bcd60e51b815260206004808301919091526024820152630e0c2e8d60e31b604482015290519081900360640190fd5b612c458c8c614722565b612c4d61496f565b612c61338d8d8d8d8d8d8d8d8d8d8d614be6565b60016000559c9b505050505050505050505050565b6002546001600160a01b03163314612cc1576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b6012805482151560ff19909116811790915560408051918252517f4eb87a5935d402aa24c01b45bfb30adefcd2328b480f2d967864de4b64ea929f9181900360200190a150565b6002546001600160a01b03163314612d53576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b60178190556040805182815290517f22bd2c9f980325d046be74aaef5fc76df4a2bc3fbc7c5a1200fcc79fe80dab6c9181900360200190a150565b6060612d98615d98565b6000838152601a602090815260409182902082516101a08101845281546001600160a01b0316815260018201805485518186028101860190965280865291949293858101939290830182828015612e1857602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612dfa575b505050918352505060028201546001600160a01b03908116602080840191909152600384015460408401526004840154606084015260058401546080840152600684015460a0840152600784015460c0840152600884015460e0840152600984015461010080850191909152600a9094015460ff8082161515610120860152948104909416151561014084015262010000909304166101609091015201519392505050565b600d6020526000908152604090205481565b60095481565b3360009081526018602052604090205460ff16612f1f576040805162461bcd60e51b815260206004820152600360248201526234303360e81b604482015290519081900360640190fd5b601554601354808210612f33575050611b6a565b80841115612f3f578093505b838210156130a557600060138381548110612f5657fe5b90600052602060002001549050306001600160a01b03166327b42c0f82866040518363ffffffff1660e01b815260040180838152602001826001600160a01b0316815260200192505050602060405180830381600087803b158015612fba57600080fd5b505af1925050508015612fdf57506040513d6020811015612fda57600080fd5b505160015b613073576040805163225fc9fd60e01b8152600481018390526001600160a01b03861660248201529051309163225fc9fd9160448083019260209291908290030181600087803b15801561303257600080fd5b505af192505050801561305757506040513d602081101561305257600080fd5b505160015b6130605761306e565b8061306c5750506130a5565b505b613081565b8061307f5750506130a5565b505b6013838154811061308e57fe5b600091825260208220015550600190910190612f3f565b506015555050565b60155481565b6002546001600160a01b031633146130fe576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b600a80546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f828abcccea18192c21d645e575652c49e20b986dab777906fc473d056b01b6a89181900360200190a150565b60115481565b6001546001600160a01b031633146131a5576040805162461bcd60e51b81526020600482015260156024820152600080516020615ed9833981519152604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b03163314613214576040805162461bcd60e51b81526020600482015260156024820152600080516020615ed9833981519152604482015290519081900360640190fd5b826001600160a01b031663095ea7b383836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561326b57600080fd5b505af115801561327f573d6000803e3d6000fd5b505050506040513d602081101561329557600080fd5b5050505050565b6002546001600160a01b031633146132e7576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b60005b835181101561338257600084828151811061330157fe5b6020026020010151905083828151811061331757fe5b6020026020010151600c6000836001600160a01b03166001600160a01b031681526020019081526020016000208190555082828151811061335457fe5b6020908102919091018101516001600160a01b039092166000908152600d90915260409020556001016132ea565b507fae32d569b058895b9620d6552b09aaffedc9a6f396be4d595a224ad09f8b213983838360405180806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b838110156133ef5781810151838201526020016133d7565b50505050905001848103835286818151815260200191508051906020019060200280838360005b8381101561342e578181015183820152602001613416565b50505050905001848103825285818151815260200191508051906020019060200280838360005b8381101561346d578181015183820152602001613455565b50505050905001965050505050505060405180910390a1505050565b6002546001600160a01b031633146134d4576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b6001600160a01b0382166000908152600b6020526040902054806134f85750611b6a565b6001600160a01b0383166000818152600b602052604081205561351c908383613f91565b604080516001600160a01b0380861682528416602082015280820183905290517f4f1b51dd7a2fcb861aa2670f668be66835c4ee12b4bbbf037e4d0018f39819e49181900360600190a1505050565b6000600260005414156135b3576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b6002600055600e548410156135f5576040805162461bcd60e51b815260206004820152600360248201526266656560e81b604482015290519081900360640190fd5b83341461362f576040805162461bcd60e51b81526020600482015260036024820152621d985b60ea1b604482015290519081900360640190fd5b8a516001148061364057508a516002145b613677576040805162461bcd60e51b81526020600482015260036024820152623632b760e91b604482015290519081900360640190fd5b6136818b8b614722565b61368961496f565b613692836149db565b8815613744576005548b516001600160a01b0390911690631b827878908d906000906136ba57fe5b602002602001015133308d6040518563ffffffff1660e01b815260040180856001600160a01b03168152602001846001600160a01b03168152602001836001600160a01b03168152602001828152602001945050505050600060405180830381600087803b15801561372b57600080fd5b505af115801561373f573d6000803e3d6000fd5b505050505b6124b8338c8c8c8c8c8c8c8c60008c614a4f565b60155460135460165460145490919293565b3360009081526018602052604090205460ff166137b4576040805162461bcd60e51b815260206004820152600360248201526234303360e81b604482015290519081900360640190fd5b6016546014548082106137c8575050611b6a565b808411156137d4578093505b8382101561393a576000601483815481106137eb57fe5b90600052602060002001549050306001600160a01b0316630d4d003d82866040518363ffffffff1660e01b815260040180838152602001826001600160a01b0316815260200192505050602060405180830381600087803b15801561384f57600080fd5b505af192505050801561387457506040513d602081101561386f57600080fd5b505160015b6139085760408051633051b17160e11b8152600481018390526001600160a01b0386166024820152905130916360a362e29160448083019260209291908290030181600087803b1580156138c757600080fd5b505af19250505080156138ec57506040513d60208110156138e757600080fd5b505160015b6138f557613903565b8061390157505061393a565b505b613916565b8061391457505061393a565b505b6014838154811061392357fe5b6000918252602082200155506001909101906137d4565b506016555050565b6002546001600160a01b031681565b6005546001600160a01b031681565b601b6020526000908152604090205481565b601a602052600090815260409020805460028201546003830154600484015460058501546006860154600787015460088801546009890154600a909901546001600160a01b03988916999789169896979596949593949293919260ff8083169261010081049091169162010000909104168c565b6003546001600160a01b031681565b6002546001600160a01b03163314613a40576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b600e8190556040805182815290517f52a8358457e20bbb36e4086b83fb0749599f1893fe4c35a876c46dc4886d12db9181900360200190a150565b600042613a9360115485614dc090919063ffffffff16565b11613acf576040805162461bcd60e51b8152602060048201526007602482015266195e1c1a5c995960ca1b604482015290519081900360640190fd5b613ada848484614e18565b90505b9392505050565b6003546000906001600160a01b03168185613b7757816001600160a01b031663e124e6d28a6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613b4657600080fd5b505afa158015613b5a573d6000803e3d6000fd5b505050506040513d6020811015613b7057600080fd5b5051613bf1565b816001600160a01b03166381a612d68a6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613bc457600080fd5b505afa158015613bd8573d6000803e3d6000fd5b505050506040513d6020811015613bee57600080fd5b50515b90508515613c475783811015613c42576040805162461bcd60e51b81526020600482015260116024820152706d61726b5072696365203c20707269636560781b604482015290519081900360640190fd5b613c90565b83811115613c90576040805162461bcd60e51b81526020600482015260116024820152706d61726b5072696365203e20707269636560781b604482015290519081900360640190fd5b6000826001600160a01b03166312d43a516040518163ffffffff1660e01b815260040160206040518083038186803b158015613ccb57600080fd5b505afa158015613cdf573d6000803e3d6000fd5b505050506040513d6020811015613cf557600080fd5b81019080805190602001909291905050509050600460009054906101000a90046001600160a01b03166001600160a01b031663f3238cec8d8d8d8b8d8860006040518863ffffffff1660e01b815260040180886001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b0316815260200185151581526020018481526020018381526020018215158152602001975050505050505050600060405180830381600087803b158015613db357600080fd5b505af1158015613dc7573d6000803e3d6000fd5b50505050806001600160a01b0316636d63c1d0846040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015613e1a57600080fd5b505af1158015613e2e573d6000803e3d6000fd5b505050506000600560009054906101000a90046001600160a01b03166001600160a01b0316632662166b8e8e8e8e8e8e8e6040518863ffffffff1660e01b815260040180886001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b031681526020018581526020018481526020018315158152602001826001600160a01b03168152602001975050505050505050602060405180830381600087803b158015613ee557600080fd5b505af1158015613ef9573d6000803e3d6000fd5b505050506040513d6020811015613f0f57600080fd5b50516040805163d3c87bbb60e01b81526001600160a01b03878116600483015291519293509084169163d3c87bbb9160248082019260009290919082900301818387803b158015613f5f57600080fd5b505af1158015613f73573d6000803e3d6000fd5b50505050613f818d8a614f49565b9c9b505050505050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052613fe390849061513e565b505050565b600083516002141561402f576140288460008151811061400457fe5b60200260200101518560018151811061401957fe5b602002602001015185856151ef565b9050613add565b6040805162461bcd60e51b81526020600482015260146024820152730d2dcecc2d8d2c840bee0c2e8d05cd8cadccee8d60631b604482015290519081900360640190fd5b60065460408051632e1a7d4d60e01b81526004810185905290516001600160a01b03909216918291632e1a7d4d91602480830192600092919082900301818387803b1580156140c157600080fd5b505af11580156140d5573d6000803e3d6000fd5b5050600754604051600093506001600160a01b0386169250869084818181858888f193505050503d8060008114614128576040519150601f19603f3d011682016040523d82523d6000602084013e61412d565b606091505b50509050801561413e575050611b6a565b816001600160a01b031663d0e30db0856040518263ffffffff1660e01b81526004016000604051808303818588803b15801561417957600080fd5b505af115801561418d573d6000803e3d6000fd5b5050505050816001600160a01b031663a9059cbb84866040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156141e957600080fd5b505af11580156141fd573d6000803e3d6000fd5b505050506040513d602081101561421357600080fd5b505050505050565b6000613add83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506152d4565b6001600160a01b03841661427057614362565b614282846001600160a01b031661536b565b61428b57614362565b601754806142995750614362565b6000856001600160a01b031663a8a12308838787876040518563ffffffff1660e01b815260040180848152602001831515815260200182151581526020019350505050600060405180830381600088803b1580156142f657600080fd5b5087f193505050508015614308575060015b61431157614315565b5060015b604080516001600160a01b0388168152821515602082015280820184905290517fc9123a2a8e16684aa24686f2bf8a6d0eb0c601bdc109140c9729916865a58bc49181900360600190a150505b50505050565b6000613ada848484614e18565b804710156143ca576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114614415576040519150601f19603f3d011682016040523d82523d6000602084013e61441a565b606091505b5050905080613fe35760405162461bcd60e51b815260040180806020018281038252603a815260200180615ef9603a913960400191505060405180910390fd5b6000807311e3657fcde2053db4ec0e6327c3908aaf449c7b63e0cab550600360009054906101000a90046001600160a01b03168a8a8a8a8a8a6009546040518963ffffffff1660e01b815260040180896001600160a01b03168152602001886001600160a01b0316815260200180602001878152602001866001600160a01b031681526020018515158152602001848152602001838152602001828103825288818151815260200191508051906020019060200280838360005b8381101561452c578181015183820152602001614514565b50505050905001995050505050505050505060206040518083038186803b15801561455657600080fd5b505af415801561456a573d6000803e3d6000fd5b505050506040513d602081101561458057600080fd5b5051905080156146415760006145b96127106145b36145ac60085461271061421b90919063ffffffff16565b8a90615371565b906153ca565b905060006145c7888361421b565b905060008960018b5103815181106145db57fe5b6020026020010151905061461d82600b6000846001600160a01b03166001600160a01b0316815260200190815260200160002054614dc090919063ffffffff16565b6001600160a01b039091166000908152600b60205260409020555091506146469050565b859150505b9695505050505050565b61465b848385615409565b60035460055460048054604080516317c3cf0f60e31b81526001600160a01b03958616938101939093529284166024830152831660448201528883166064820152878316608482015291861660a483015260c4820185905283151560e48301526101048201839052517311e3657fcde2053db4ec0e6327c3908aaf449c7b9163be1e787891610124808301926000929190829003018186803b15801561470057600080fd5b505af4158015614714573d6000803e3d6000fd5b5050505061421386846155d2565b60035482516001600160a01b039091169063daf9c21090849060009061474457fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561478957600080fd5b505afa15801561479d573d6000803e3d6000fd5b505050506040513d60208110156147b357600080fd5b50516147eb576040805162461bcd60e51b81526020600482015260026024820152611ddb60f21b604482015290519081900360640190fd5b8151600214156148c05760035482516001600160a01b039091169063daf9c210908490600190811061481957fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561485e57600080fd5b505afa158015614872573d6000803e3d6000fd5b505050506040513d602081101561488857600080fd5b50516148c0576040805162461bcd60e51b81526020600482015260026024820152611ddb60f21b604482015290519081900360640190fd5b60035460408051630daf9c2160e41b81526001600160a01b0384811660048301529151919092169163daf9c210916024808301926020929190829003018186803b15801561490d57600080fd5b505afa158015614921573d6000803e3d6000fd5b505050506040513d602081101561493757600080fd5b5051611b6a576040805162461bcd60e51b81526020600482015260026024820152611ddb60f21b604482015290519081900360640190fd5b34156149d957600660009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156149c557600080fd5b505af1158015613295573d6000803e3d6000fd5b565b80158015906149f45750600a546001600160a01b031615155b15614a4c57600a54604080516356b4b2ad60e01b81523360048201526024810184905290516001600160a01b03909216916356b4b2ad9160448082019260009290919082900301818387803b1580156149c557600080fd5b50565b6000614a59615d98565b604051806101a001604052808e6001600160a01b031681526020018d81526020018c6001600160a01b031681526020018b81526020018a815260200189815260200187815260200186815260200143815260200142815260200188151581526020018515158152602001846001600160a01b03168152509050600080614ade83615759565b915091508e6001600160a01b03167f5265bc4952da402633b3fc35f67ab4245493a0ab94dd8ab123667c8d45a4485c8f8f8f8f8f8f8f8f8b60016013805490500343423a60405180806020018e6001600160a01b031681526020018d81526020018c81526020018b81526020018a1515815260200189815260200188815260200187815260200186815260200185815260200184815260200183815260200182810382528f818151815260200191508051906020019060200280838360005b83811015614bb5578181015183820152602001614b9d565b505050509050019e50505050505050505050505050505060405180910390a29e9d5050505050505050505050505050565b6000614bf0615ce3565b604051806101c001604052808f6001600160a01b031681526020018e81526020018d6001600160a01b031681526020018c81526020018b8152602001896001600160a01b031681526020018881526020018781526020018681526020014381526020014281526020018a151581526020018515158152602001846001600160a01b03168152509050600080614c84836158f7565b9150915082600001516001600160a01b03167f81ed0476a7e785a9e4728fffd679ea97176ca1ac85e1003462558bb5677da57b84602001518560400151866060015187608001518861016001518960a001518a60c001518b60e001518c61010001518c600160148054905003434260405180806020018e6001600160a01b031681526020018d81526020018c81526020018b151581526020018a6001600160a01b0316815260200189815260200188815260200187815260200186815260200185815260200184815260200183815260200182810382528f818151815260200191508051906020019060200280838360005b83811015614d8e578181015183820152602001614d76565b505050509050019e50505050505050505050505050505060405180910390a29f9e505050505050505050505050505050565b600082820183811015613add576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b60008033301480614e3857503360009081526018602052604090205460ff165b60125490915060ff16158015614e4c575080155b15614e84576040805162461bcd60e51b815260206004820152600360248201526234303360e81b604482015290519081900360640190fd5b8015614eaa5743614ea0600f5487614dc090919063ffffffff16565b1115915050613add565b336001600160a01b03841614614eed576040805162461bcd60e51b815260206004820152600360248201526234303360e81b604482015290519081900360640190fd5b42614f0360105486614dc090919063ffffffff16565b1115614f3e576040805162461bcd60e51b815260206004820152600560248201526464656c617960d81b604482015290519081900360640190fd5b506001949350505050565b600a546001600160a01b031680614f605750611b6a565b600080826001600160a01b031663534ef883866040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b158015614faf57600080fd5b505afa158015614fc3573d6000803e3d6000fd5b505050506040513d6040811015614fd957600080fd5b508051602090910151909250905081614ff457505050611b6a565b600354604080516312d43a5160e01b815290516000926001600160a01b0316916312d43a51916004808301926020929190829003018186803b15801561503957600080fd5b505afa15801561504d573d6000803e3d6000fd5b505050506040513d602081101561506357600080fd5b50516040805163318bc68960e01b815290519192507f474c763ff84bf2c2039a6d9fea955ecd0f724030e3c365b91169c6a16fe751b791889188916001600160a01b0386169163318bc6899160048083019260209291908290030181600087803b1580156150d057600080fd5b505af11580156150e4573d6000803e3d6000fd5b505050506040513d60208110156150fa57600080fd5b5051604080516001600160a01b03948516815260208101939093528281019190915260608201879052918516608082015290519081900360a00190a1505050505050565b6060615193826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316615aad9092919063ffffffff16565b805190915015613fe3578080602001905160208110156151b257600080fd5b5051613fe35760405162461bcd60e51b815260040180806020018281038252602a815260200180615f7a602a913960400191505060405180910390fd5b60035460408051634998b10960e11b81526001600160a01b03878116600483015286811660248301528481166044830152915160009384931691639331621291606480830192602092919082900301818787803b15801561524f57600080fd5b505af1158015615263573d6000803e3d6000fd5b505050506040513d602081101561527957600080fd5b50519050838110156152cb576040805162461bcd60e51b81526020600482015260166024820152751a5b9cdd59999a58da595b9d08185b5bdd5b9d13dd5d60521b604482015290519081900360640190fd5b95945050505050565b600081848411156153635760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015615328578181015183820152602001615310565b50505050905090810190601f1680156153555780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b3b151590565b600082615380575060006129e8565b8282028284828161538d57fe5b0414613add5760405162461bcd60e51b8152600401808060200182810382526021815260200180615f596021913960400191505060405180910390fd5b6000613add83836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b815250615abc565b8061541357613fe3565b8115615511576001600160a01b0383166000908152600c602052604090205480158015906154c457506003546040805163783a2b6760e11b81526001600160a01b038781166004830152915184936154c293879391169163f07456ce91602480820192602092909190829003018186803b15801561549057600080fd5b505afa1580156154a4573d6000803e3d6000fd5b505050506040513d60208110156154ba57600080fd5b505190614dc0565b115b1561550b576040805162461bcd60e51b81526020600482015260126024820152711b585e081b1bdb99dcc8195e18d95959195960721b604482015290519081900360640190fd5b50613fe3565b6001600160a01b0383166000908152600d6020526040902054801580159061558a57506003546040805163114f1b5560e31b81526001600160a01b03878116600483015291518493615588938793911691638a78daa891602480820192602092909190829003018186803b15801561549057600080fd5b115b15614362576040805162461bcd60e51b81526020600482015260136024820152721b585e081cda1bdc9d1cc8195e18d959591959606a1b604482015290519081900360640190fd5b600a546001600160a01b0316806155e95750611b6a565b600080826001600160a01b031663534ef883866040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b15801561563857600080fd5b505afa15801561564c573d6000803e3d6000fd5b505050506040513d604081101561566257600080fd5b50805160209091015190925090508161567d57505050611b6a565b600354604080516312d43a5160e01b815290516000926001600160a01b0316916312d43a51916004808301926020929190829003018186803b1580156156c257600080fd5b505afa1580156156d6573d6000803e3d6000fd5b505050506040513d60208110156156ec57600080fd5b50516040805163318bc68960e01b815290519192507fc2414023ce7002ee98557d1e7be21e5559073336f2217ee5f9b2e50fd85f71ee91889188916001600160a01b0386169163318bc6899160048083019260209291908290030181600087803b1580156150d057600080fd5b80516001600160a01b038116600090815260196020526040812054909182918290615785906001614dc0565b6001600160a01b03831660009081526019602052604081208290559091506157ad83836129a8565b6000818152601a60209081526040909120885181546001600160a01b0319166001600160a01b03909116178155888201518051939450899391926157f992600185019290910190615e1f565b5060408201516002820180546001600160a01b0319166001600160a01b03928316179055606083015160038301556080830151600483015560a0830151600583015560c0830151600683015560e083015160078301556101008084015160088401556101208401516009840155610140840151600a90930180546101608601516101809096015160ff199091169415159490941761ff0019169415159091029390931762010000600160b01b031916620100009290911691909102179055601380546001810182556000919091527f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a09001819055909590945092505050565b80516001600160a01b0381166000908152601b6020526040812054909182918290615923906001614dc0565b6001600160a01b0383166000908152601b6020526040812082905590915061594b83836129a8565b6000818152601c60209081526040909120885181546001600160a01b0319166001600160a01b039091161781558882015180519394508993919261599792600185019290910190615e1f565b5060408201516002820180546001600160a01b03199081166001600160a01b0393841617909155606084015160038401556080840151600484015560a084015160058401805490921690831617905560c0830151600683015560e083015160078301556101008084015160088401556101208401516009840155610140840151600a840155610160840151600b90930180546101808601516101a09096015160ff199091169415159490941761ff0019169415159091029390931762010000600160b01b031916620100009290911691909102179055601480546001810182556000919091527fce6d7b5282bd9a3661ae061feed1dbda4e52ab073b1f9285be6e155d9c38d4ec01819055909590945092505050565b6060613ada8484600085615b21565b60008183615b0b5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315615328578181015183820152602001615310565b506000838581615b1757fe5b0495945050505050565b606082471015615b625760405162461bcd60e51b8152600401808060200182810382526026815260200180615f336026913960400191505060405180910390fd5b615b6b8561536b565b615bbc576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310615bfb5780518252601f199092019160209182019101615bdc565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114615c5d576040519150601f19603f3d011682016040523d82523d6000602084013e615c62565b606091505b5091509150615c72828286615c7d565b979650505050505050565b60608315615c8c575081613add565b825115615c9c5782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315615328578181015183820152602001615310565b604051806101c0016040528060006001600160a01b031681526020016060815260200160006001600160a01b03168152602001600081526020016000815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160001515815260200160006001600160a01b031681525090565b5080546000825590600052602060002090810190614a4c9190615e84565b604051806101a0016040528060006001600160a01b031681526020016060815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160001515815260200160006001600160a01b031681525090565b828054828255906000526020600020908101928215615e74579160200282015b82811115615e7457825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190615e3f565b50615e80929150615e99565b5090565b5b80821115615e805760008155600101615e85565b5b80821115615e805780546001600160a01b0319168155600101615e9a56fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00476f7665726e61626c653a20666f7262696464656e0000000000000000000000416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c634300060c000a00000000000000000000000099b31498b0a1dae01fc3433e3cb60f095340935c0000000000000000000000001fe9fba5955af58c18057213f0151bbe893ab2c80000000000000000000000004f9a0e7fd2bf6067db6994cf12e4495df938e6e9000000000000000000000000e5041618b6de86a3ae68db2283b92295a7b5ae6a000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000011c37937e08000

Deployed Bytecode

0x6080604052600436106102945760003560e01c80626cc35e146102f057806304225954146103215780630d4d003d1461035d5780631045c74e146103aa578063126082cf146103dd57806312d43a51146103f25780631bca8cf0146104075780631ce9cb8f1461041c5780631f2851061461044f578063225fc9fd146104f3578063233bfe3b1461052c57806324a084df1461055657806324f746971461058f57806327b42c0f146105a45780632d79cf42146105dd578063308aa81f146105f25780633422ead11461062257806336eba48a1461065d5780633a2a80c7146106905780633a9b52ad146106a55780633e72a262146106cf5780633fc8cef3146106e45780634067b132146106f95780634278555f1461072f578063490ae210146107595780635841fcaa146107835780635b88e8c6146107985780635d5c22e81461087157806360a362e2146108eb57806362f8a3fe14610924578063633451de1461095d57806363ae210314610990578063657bc5d0146109a557806367a52793146109ba578063704b6c02146109cf5780637be7d14114610a025780637c2eb9f714610aed5780638a54942f14610b1957806395e9bbd714610b435780639698d25a14610b6d57806398d1e03a14610ba05780639a20810014610bb55780639b57862014610bee578063ae4d7f9a14610c03578063cb0269c914610c36578063cfad57a214610c4b578063e1f21c6714610c7e578063ef12c67e14610cc1578063f255527814610e73578063f2ae372f14610eae578063f2cea6a514610f8d578063f3883d8b14610fc8578063f851a44014611001578063f887ea4014611016578063fa4445771461102b578063faf990f31461105e578063fbfa77cf146110f9578063fc2cee621461110e576102eb565b366102eb576006546001600160a01b031633146102e9576040805162461bcd60e51b815260206004820152600e60248201526d34b73b30b634b21039b2b73232b960911b604482015290519081900360640190fd5b005b600080fd5b3480156102fc57600080fd5b50610305611138565b604080516001600160a01b039092168252519081900360200190f35b34801561032d57600080fd5b5061034b6004803603602081101561034457600080fd5b5035611147565b60408051918252519081900360200190f35b34801561036957600080fd5b506103966004803603604081101561038057600080fd5b50803590602001356001600160a01b0316611165565b604080519115158252519081900360200190f35b3480156103b657600080fd5b5061034b600480360360208110156103cd57600080fd5b50356001600160a01b0316611609565b3480156103e957600080fd5b5061034b61161b565b3480156103fe57600080fd5b50610305611621565b34801561041357600080fd5b5061034b611630565b34801561042857600080fd5b5061034b6004803603602081101561043f57600080fd5b50356001600160a01b0316611636565b34801561045b57600080fd5b506104796004803603602081101561047257600080fd5b5035611648565b604080516001600160a01b039e8f1681529c8e1660208e01528c81019b909b5260608c0199909952968b1660808b015260a08a019590955260c089019390935260e0880191909152610100870152610120860152151561014085015215156101608401529092166101808201529051908190036101a00190f35b3480156104ff57600080fd5b506103966004803603604081101561051657600080fd5b50803590602001356001600160a01b03166116c6565b34801561053857600080fd5b506102e96004803603602081101561054f57600080fd5b5035611a84565b34801561056257600080fd5b506102e96004803603604081101561057957600080fd5b506001600160a01b038135169060200135611b0a565b34801561059b57600080fd5b5061034b611b6e565b3480156105b057600080fd5b50610396600480360360408110156105c757600080fd5b50803590602001356001600160a01b0316611b74565b3480156105e957600080fd5b5061034b611fd0565b3480156105fe57600080fd5b506102e96004803603604081101561061557600080fd5b5080359060200135611fd6565b34801561062e57600080fd5b506102e96004803603604081101561064557600080fd5b506001600160a01b038135169060200135151561206a565b34801561066957600080fd5b506103966004803603602081101561068057600080fd5b50356001600160a01b0316612115565b34801561069c57600080fd5b5061034b61212a565b3480156106b157600080fd5b506102e9600480360360208110156106c857600080fd5b5035612130565b3480156106db57600080fd5b506103966121b6565b3480156106f057600080fd5b506103056121bf565b34801561070557600080fd5b506102e96004803603606081101561071c57600080fd5b50803590602081013590604001356121ce565b34801561073b57600080fd5b5061034b6004803603602081101561075257600080fd5b503561226d565b34801561076557600080fd5b506102e96004803603602081101561077c57600080fd5b503561227a565b34801561078f57600080fd5b5061034b612300565b61034b60048036036101208110156107af57600080fd5b810190602081018135600160201b8111156107c957600080fd5b8201836020820111156107db57600080fd5b803590602001918460208302840111600160201b831117156107fc57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550505081356001600160a01b03908116935060208301359260408101359250606081013515159160808201359160a08101359160c08201359160e0013516612306565b34801561087d57600080fd5b5061089b6004803603602081101561089457600080fd5b50356124cc565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156108d75781810151838201526020016108bf565b505050509050019250505060405180910390f35b3480156108f757600080fd5b506103966004803603604081101561090e57600080fd5b50803590602001356001600160a01b0316612608565b34801561093057600080fd5b5061034b6004803603604081101561094757600080fd5b506001600160a01b0381351690602001356129a8565b34801561096957600080fd5b5061034b6004803603602081101561098057600080fd5b50356001600160a01b03166129ee565b34801561099c57600080fd5b5061034b612a00565b3480156109b157600080fd5b50610305612a06565b3480156109c657600080fd5b5061034b612a15565b3480156109db57600080fd5b506102e9600480360360208110156109f257600080fd5b50356001600160a01b0316612a1b565b61034b6004803603610160811015610a1957600080fd5b810190602081018135600160201b811115610a3357600080fd5b820183602082011115610a4557600080fd5b803590602001918460208302840111600160201b83111715610a6657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550505081356001600160a01b039081169350602083013592604081013592506060810135151591608082013581169160a08101359160c08201359160e081013591610100820135151591610120013516612abc565b348015610af957600080fd5b506102e960048036036020811015610b1057600080fd5b50351515612c76565b348015610b2557600080fd5b506102e960048036036020811015610b3c57600080fd5b5035612d08565b348015610b4f57600080fd5b5061089b60048036036020811015610b6657600080fd5b5035612d8e565b348015610b7957600080fd5b5061034b60048036036020811015610b9057600080fd5b50356001600160a01b0316612ebd565b348015610bac57600080fd5b5061034b612ecf565b348015610bc157600080fd5b506102e960048036036040811015610bd857600080fd5b50803590602001356001600160a01b0316612ed5565b348015610bfa57600080fd5b5061034b6130ad565b348015610c0f57600080fd5b506102e960048036036020811015610c2657600080fd5b50356001600160a01b03166130b3565b348015610c4257600080fd5b5061034b613152565b348015610c5757600080fd5b506102e960048036036020811015610c6e57600080fd5b50356001600160a01b0316613158565b348015610c8a57600080fd5b506102e960048036036060811015610ca157600080fd5b506001600160a01b038135811691602081013590911690604001356131c7565b348015610ccd57600080fd5b506102e960048036036060811015610ce457600080fd5b810190602081018135600160201b811115610cfe57600080fd5b820183602082011115610d1057600080fd5b803590602001918460208302840111600160201b83111715610d3157600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610d8057600080fd5b820183602082011115610d9257600080fd5b803590602001918460208302840111600160201b83111715610db357600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610e0257600080fd5b820183602082011115610e1457600080fd5b803590602001918460208302840111600160201b83111715610e3557600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061329c945050505050565b348015610e7f57600080fd5b506102e960048036036040811015610e9657600080fd5b506001600160a01b0381358116916020013516613489565b61034b6004803603610140811015610ec557600080fd5b810190602081018135600160201b811115610edf57600080fd5b820183602082011115610ef157600080fd5b803590602001918460208302840111600160201b83111715610f1257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550506001600160a01b038335811694506020840135936040810135935060608101359250608081013515159160a08201359160c08101359160e08201359161010001351661356b565b348015610f9957600080fd5b50610fa2613758565b604080519485526020850193909352838301919091526060830152519081900360800190f35b348015610fd457600080fd5b506102e960048036036040811015610feb57600080fd5b50803590602001356001600160a01b031661376a565b34801561100d57600080fd5b50610305613942565b34801561102257600080fd5b50610305613951565b34801561103757600080fd5b5061034b6004803603602081101561104e57600080fd5b50356001600160a01b0316613960565b34801561106a57600080fd5b506110886004803603602081101561108157600080fd5b5035613972565b604080516001600160a01b039d8e1681529b8d1660208d01528b81019a909a5260608b019890985260808a019690965260a089019490945260c088019290925260e0870152610100860152151561012085015215156101408401529092166101608201529051908190036101800190f35b34801561110557600080fd5b506103056139e6565b34801561111a57600080fd5b506102e96004803603602081101561113157600080fd5b50356139f5565b600a546001600160a01b031681565b6013818154811061115457fe5b600091825260209091200154905081565b6000600260005414156111ad576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b60026000556111ba615ce3565b6000848152601c602090815260409182902082516101c08101845281546001600160a01b031681526001820180548551818602810186019096528086529194929385810193929083018282801561123a57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161121c575b505050918352505060028201546001600160a01b0390811660208301526003830154604083015260048301546060830152600583015481166080830152600683015460a0830152600783015460c0830152600883015460e0830152600983015461010080840191909152600a840154610120840152600b9093015460ff80821615156101408501529381049093161515610160830152620100009092048216610180909101528151919250166112f45760019150506115fe565b600061130f8261012001518361014001518460000151613a7b565b905080611321576000925050506115fe565b6000858152601c6020526040812080546001600160a01b03191681559061134b6001830182615d7a565b506002810180546001600160a01b03199081169091556000600383018190556004830181905560058301805490921690915560068201819055600782018190556008820181905560098201819055600a8201819055600b90910180546001600160b01b03191690558251602084015180516113f292919084906113ca57fe5b6020026020010151856040015186606001518760800151886101600151308a60c00151613ae4565b905080156114a05760018360200151511115611461576003546020840151805161144b926001600160a01b031691849160009061142b57fe5b60200260200101516001600160a01b0316613f919092919063ffffffff16565b61145e83602001518460e0015130613fe8565b90505b8261018001511561147f5761147a818460a00151614073565b6114a0565b6114a08360a001518285602001516001876020015151038151811061142b57fe5b6114af83610100015186614073565b82600001516001600160a01b03167f21435c5b618d77ff3657140cd3318e2cffaebc5e0e1b7318f56a9ba4044c3ed284602001518560400151866060015187608001518861016001518960a001518a60c001518b60e001518c61010001516115258e61012001514361421b90919063ffffffff16565b6101408f015161153690429061421b565b60405180806020018c6001600160a01b031681526020018b81526020018a81526020018915158152602001886001600160a01b0316815260200187815260200186815260200185815260200184815260200183815260200182810382528d818151815260200191508051906020019060200280838360005b838110156115c65781810151838201526020016115ae565b505050509050019c5050505050505050505050505060405180910390a26115f6836101a00151876001600061425d565b600193505050505b600160005592915050565b600c6020526000908152604090205481565b61271081565b6001546001600160a01b031681565b60165481565b600b6020526000908152604090205481565b601c602052600090815260409020805460028201546003830154600484015460058501546006860154600787015460088801546009890154600a8a0154600b909a01546001600160a01b03998a169a988a1699979896979586169694959394929391929160ff8083169261010081049091169162010000909104168d565b60006002600054141561170e576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b600260005561171b615d98565b6000848152601a602090815260409182902082516101a08101845281546001600160a01b031681526001820180548551818602810186019096528086529194929385810193929083018282801561179b57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161177d575b505050918352505060028201546001600160a01b039081166020830152600383015460408301526004830154606083015260058301546080830152600683015460a0830152600783015460c0830152600883015460e0830152600983015461010080840191909152600a9093015460ff80821615156101208501529381049093161515610140830152620100009092048216610160909101528151919250166118485760019150506115fe565b60006118638261010001518361012001518460000151614368565b905080611875576000925050506115fe565b6000858152601a6020526040812080546001600160a01b03191681559061189f6001830182615d7a565b506002810180546001600160a01b031916905560006003820181905560048201819055600582018190556006820181905560078201819055600882018190556009820155600a0180546001600160b01b0319169055610160820151156119165761191182606001518360000151614073565b611934565b61193482600001518360600151846020015160008151811061142b57fe5b6119428260e0015185614073565b81600001516001600160a01b03167f35b638e650e2328786fb405bd69d2083dbedc018d086662e74b775b4f1dae4bf83602001518460400151856060015186608001518760a001518861014001518960c001518a60e001516119b28c61010001514361421b90919063ffffffff16565b6101208d01516119c390429061421b565b60405180806020018b6001600160a01b031681526020018a8152602001898152602001888152602001871515815260200186815260200185815260200184815260200183815260200182810382528c818151815260200191508051906020019060200280838360005b83811015611a44578181015183820152602001611a2c565b505050509050019b50505050505050505050505060405180910390a2611a73826101800151866000600161425d565b600192505050600160005592915050565b6002546001600160a01b03163314611acf576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b60098190556040805182815290517f21167d0d4661af93817ebce920f18986eed3d75d5e1c03f2aed05efcbafbc4529181900360200190a150565b6001546001600160a01b03163314611b57576040805162461bcd60e51b81526020600482015260156024820152600080516020615ed9833981519152604482015290519081900360640190fd5b611b6a6001600160a01b03831682614375565b5050565b60175481565b600060026000541415611bbc576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b6002600055611bc9615d98565b6000848152601a602090815260409182902082516101a08101845281546001600160a01b0316815260018201805485518186028101860190965280865291949293858101939290830182828015611c4957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611c2b575b505050918352505060028201546001600160a01b039081166020830152600383015460408301526004830154606083015260058301546080830152600683015460a0830152600783015460c0830152600883015460e0830152600983015461010080840191909152600a9093015460ff8082161515610120850152938104909316151561014083015262010000909204821661016090910152815191925016611cf65760019150506115fe565b6000611d118261010001518361012001518460000151613a7b565b905080611d23576000925050506115fe565b6000858152601a6020526040812080546001600160a01b031916815590611d4d6001830182615d7a565b506002810180546001600160a01b031916905560006003820181905560048201819055600582018190556006820181905560078201819055600882018190556009820155600a0180546001600160b01b0319169055606082015115611e5357606082015160208301515160011015611dfd57600354606084015160208501518051611de7936001600160a01b031692919060009061142b57fe5b611dfa8360200151846080015130613fe8565b90505b6000611e22846000015185602001518487604001518861014001518960a0015161445a565b60035460208601518051929350611e50926001600160a01b0390921691849190600019810190811061142b57fe5b50505b815160208301518051611e929291906000198101908110611e7057fe5b602002602001015184604001518560a001518661014001518760c00151614650565b611ea08260e0015185614073565b81600001516001600160a01b03167f1be316b94d38c07bd41cdb4913772d0a0a82802786a2f8b657b6e85dbcdfc64183602001518460400151856060015186608001518760a001518861014001518960c001518a60e00151611f108c61010001514361421b90919063ffffffff16565b6101208d0151611f2190429061421b565b60405180806020018b6001600160a01b031681526020018a8152602001898152602001888152602001871515815260200186815260200185815260200184815260200183815260200182810382528c818151815260200191508051906020019060200280838360005b83811015611fa2578181015183820152602001611f8a565b505050509050019b50505050505050505050505060405180910390a2611a738261018001518660018061425d565b60075481565b6002546001600160a01b03163314612021576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b60158290556016819055604080518381526020810183905281517febb0f666150f4be5b60c45df8f3e49992510b0128027fe58eea6110f296493bc929181900390910190a15050565b6002546001600160a01b031633146120b5576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b6001600160a01b038216600081815260186020908152604091829020805460ff1916851515908117909155825190815291517ffbabc02389290a451c6e600d05bf9887b99bfad39d8e1237e4e3df042e4941fe9281900390910190a25050565b60186020526000908152604090205460ff1681565b60105481565b6002546001600160a01b0316331461217b576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b60078190556040805182815290517f4d371d598d3a13f99ce992a17975bbaf1e1c256e072ec7d2f93ce88e40d9ba1c9181900360200190a150565b60125460ff1681565b6006546001600160a01b031681565b6002546001600160a01b03163314612219576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b600f83905560108290556011819055604080518481526020810184905280820183905290517fb98e759701eaca2e60c25e91109003c1c7442ef731b5d569037063005da8254d9181900360600190a1505050565b6014818154811061115457fe5b6002546001600160a01b031633146122c5576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b60088190556040805182815290517f974fd3c1fcb4653dfc4fb740c4c692cd212d55c28f163f310128cb64d83006759181900360200190a150565b600f5481565b60006002600054141561234e576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b6002600055600e54841015612390576040805162461bcd60e51b815260206004820152600360248201526266656560e81b604482015290519081900360640190fd5b833410156123cb576040805162461bcd60e51b81526020600482015260036024820152621d985b60ea1b604482015290519081900360640190fd5b8951600114806123dc575089516002145b612413576040805162461bcd60e51b81526020600482015260036024820152623632b760e91b604482015290519081900360640190fd5b6006548a516001600160a01b03909116908b9060009061242f57fe5b60200260200101516001600160a01b03161461247b576040805162461bcd60e51b815260206004808301919091526024820152630e0c2e8d60e31b604482015290519081900360640190fd5b6124858a8a614722565b61248d61496f565b612496836149db565b60006124a2348661421b565b90506124b8338c8c848d8d8d8d8d60018d614a4f565b60016000559b9a5050505050505050505050565b60606124d6615ce3565b6000838152601c602090815260409182902082516101c08101845281546001600160a01b031681526001820180548551818602810186019096528086529194929385810193929083018282801561255657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612538575b505050918352505060028201546001600160a01b039081166020808401919091526003840154604084015260048401546060840152600584015482166080840152600684015460a0840152600784015460c0840152600884015460e0840152600984015461010080850191909152600a850154610120850152600b9094015460ff8082161515610140860152948104909416151561016084015262010000909304166101809091015201519392505050565b600060026000541415612650576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b600260005561265d615ce3565b6000848152601c602090815260409182902082516101c08101845281546001600160a01b03168152600182018054855181860281018601909652808652919492938581019392908301828280156126dd57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116126bf575b505050918352505060028201546001600160a01b0390811660208301526003830154604083015260048301546060830152600583015481166080830152600683015460a0830152600783015460c0830152600883015460e0830152600983015461010080840191909152600a840154610120840152600b9093015460ff80821615156101408501529381049093161515610160830152620100009092048216610180909101528151919250166127975760019150506115fe565b60006127b28261012001518361014001518460000151614368565b9050806127c4576000925050506115fe565b6000858152601c6020526040812080546001600160a01b0319168155906127ee6001830182615d7a565b506002810180546001600160a01b03199081169091556000600383018190556004830181905560058301805490921690915560068201819055600782018190556008820181905560098201819055600a820155600b0180546001600160b01b03191690556101008201516128629085614073565b81600001516001600160a01b03167f87abfd78e844f28318363bdf3da99eab2f4a2da9ff7ae365484507f7b6c3f80583602001518460400151856060015186608001518761016001518860a001518960c001518a60e001518b61010001516128d88d61012001514361421b90919063ffffffff16565b6101408e01516128e990429061421b565b60405180806020018c6001600160a01b031681526020018b81526020018a81526020018915158152602001886001600160a01b0316815260200187815260200186815260200185815260200184815260200183815260200182810382528d818151815260200191508051906020019060200280838360005b83811015612979578181015183820152602001612961565b505050509050019c5050505050505050505050505060405180910390a2611a73826101a001518660008061425d565b6000828260405160200180836001600160a01b031660601b8152601401828152602001925050506040516020818303038152906040528051906020012090505b92915050565b60196020526000908152604090205481565b600e5481565b6004546001600160a01b031681565b60085481565b6001546001600160a01b03163314612a68576040805162461bcd60e51b81526020600482015260156024820152600080516020615ed9833981519152604482015290519081900360640190fd5b600280546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f5a272403b402d892977df56625f4164ccaf70ca3863991c43ecfe76a6905b0a19181900360200190a150565b600060026000541415612b04576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b6002600055600e54841015612b46576040805162461bcd60e51b815260206004820152600360248201526266656560e81b604482015290519081900360640190fd5b833414612b80576040805162461bcd60e51b81526020600482015260036024820152621d985b60ea1b604482015290519081900360640190fd5b8b5160011480612b9157508b516002145b612bc8576040805162461bcd60e51b81526020600482015260036024820152623632b760e91b604482015290519081900360640190fd5b8215612c3b576006548c516001600160a01b03909116908d906000198101908110612bef57fe5b60200260200101516001600160a01b031614612c3b576040805162461bcd60e51b815260206004808301919091526024820152630e0c2e8d60e31b604482015290519081900360640190fd5b612c458c8c614722565b612c4d61496f565b612c61338d8d8d8d8d8d8d8d8d8d8d614be6565b60016000559c9b505050505050505050505050565b6002546001600160a01b03163314612cc1576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b6012805482151560ff19909116811790915560408051918252517f4eb87a5935d402aa24c01b45bfb30adefcd2328b480f2d967864de4b64ea929f9181900360200190a150565b6002546001600160a01b03163314612d53576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b60178190556040805182815290517f22bd2c9f980325d046be74aaef5fc76df4a2bc3fbc7c5a1200fcc79fe80dab6c9181900360200190a150565b6060612d98615d98565b6000838152601a602090815260409182902082516101a08101845281546001600160a01b0316815260018201805485518186028101860190965280865291949293858101939290830182828015612e1857602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612dfa575b505050918352505060028201546001600160a01b03908116602080840191909152600384015460408401526004840154606084015260058401546080840152600684015460a0840152600784015460c0840152600884015460e0840152600984015461010080850191909152600a9094015460ff8082161515610120860152948104909416151561014084015262010000909304166101609091015201519392505050565b600d6020526000908152604090205481565b60095481565b3360009081526018602052604090205460ff16612f1f576040805162461bcd60e51b815260206004820152600360248201526234303360e81b604482015290519081900360640190fd5b601554601354808210612f33575050611b6a565b80841115612f3f578093505b838210156130a557600060138381548110612f5657fe5b90600052602060002001549050306001600160a01b03166327b42c0f82866040518363ffffffff1660e01b815260040180838152602001826001600160a01b0316815260200192505050602060405180830381600087803b158015612fba57600080fd5b505af1925050508015612fdf57506040513d6020811015612fda57600080fd5b505160015b613073576040805163225fc9fd60e01b8152600481018390526001600160a01b03861660248201529051309163225fc9fd9160448083019260209291908290030181600087803b15801561303257600080fd5b505af192505050801561305757506040513d602081101561305257600080fd5b505160015b6130605761306e565b8061306c5750506130a5565b505b613081565b8061307f5750506130a5565b505b6013838154811061308e57fe5b600091825260208220015550600190910190612f3f565b506015555050565b60155481565b6002546001600160a01b031633146130fe576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b600a80546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f828abcccea18192c21d645e575652c49e20b986dab777906fc473d056b01b6a89181900360200190a150565b60115481565b6001546001600160a01b031633146131a5576040805162461bcd60e51b81526020600482015260156024820152600080516020615ed9833981519152604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b03163314613214576040805162461bcd60e51b81526020600482015260156024820152600080516020615ed9833981519152604482015290519081900360640190fd5b826001600160a01b031663095ea7b383836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561326b57600080fd5b505af115801561327f573d6000803e3d6000fd5b505050506040513d602081101561329557600080fd5b5050505050565b6002546001600160a01b031633146132e7576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b60005b835181101561338257600084828151811061330157fe5b6020026020010151905083828151811061331757fe5b6020026020010151600c6000836001600160a01b03166001600160a01b031681526020019081526020016000208190555082828151811061335457fe5b6020908102919091018101516001600160a01b039092166000908152600d90915260409020556001016132ea565b507fae32d569b058895b9620d6552b09aaffedc9a6f396be4d595a224ad09f8b213983838360405180806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b838110156133ef5781810151838201526020016133d7565b50505050905001848103835286818151815260200191508051906020019060200280838360005b8381101561342e578181015183820152602001613416565b50505050905001848103825285818151815260200191508051906020019060200280838360005b8381101561346d578181015183820152602001613455565b50505050905001965050505050505060405180910390a1505050565b6002546001600160a01b031633146134d4576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b6001600160a01b0382166000908152600b6020526040902054806134f85750611b6a565b6001600160a01b0383166000818152600b602052604081205561351c908383613f91565b604080516001600160a01b0380861682528416602082015280820183905290517f4f1b51dd7a2fcb861aa2670f668be66835c4ee12b4bbbf037e4d0018f39819e49181900360600190a1505050565b6000600260005414156135b3576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eb9833981519152604482015290519081900360640190fd5b6002600055600e548410156135f5576040805162461bcd60e51b815260206004820152600360248201526266656560e81b604482015290519081900360640190fd5b83341461362f576040805162461bcd60e51b81526020600482015260036024820152621d985b60ea1b604482015290519081900360640190fd5b8a516001148061364057508a516002145b613677576040805162461bcd60e51b81526020600482015260036024820152623632b760e91b604482015290519081900360640190fd5b6136818b8b614722565b61368961496f565b613692836149db565b8815613744576005548b516001600160a01b0390911690631b827878908d906000906136ba57fe5b602002602001015133308d6040518563ffffffff1660e01b815260040180856001600160a01b03168152602001846001600160a01b03168152602001836001600160a01b03168152602001828152602001945050505050600060405180830381600087803b15801561372b57600080fd5b505af115801561373f573d6000803e3d6000fd5b505050505b6124b8338c8c8c8c8c8c8c8c60008c614a4f565b60155460135460165460145490919293565b3360009081526018602052604090205460ff166137b4576040805162461bcd60e51b815260206004820152600360248201526234303360e81b604482015290519081900360640190fd5b6016546014548082106137c8575050611b6a565b808411156137d4578093505b8382101561393a576000601483815481106137eb57fe5b90600052602060002001549050306001600160a01b0316630d4d003d82866040518363ffffffff1660e01b815260040180838152602001826001600160a01b0316815260200192505050602060405180830381600087803b15801561384f57600080fd5b505af192505050801561387457506040513d602081101561386f57600080fd5b505160015b6139085760408051633051b17160e11b8152600481018390526001600160a01b0386166024820152905130916360a362e29160448083019260209291908290030181600087803b1580156138c757600080fd5b505af19250505080156138ec57506040513d60208110156138e757600080fd5b505160015b6138f557613903565b8061390157505061393a565b505b613916565b8061391457505061393a565b505b6014838154811061392357fe5b6000918252602082200155506001909101906137d4565b506016555050565b6002546001600160a01b031681565b6005546001600160a01b031681565b601b6020526000908152604090205481565b601a602052600090815260409020805460028201546003830154600484015460058501546006860154600787015460088801546009890154600a909901546001600160a01b03988916999789169896979596949593949293919260ff8083169261010081049091169162010000909104168c565b6003546001600160a01b031681565b6002546001600160a01b03163314613a40576040805162461bcd60e51b81526020600482015260096024820152683337b93134b23232b760b91b604482015290519081900360640190fd5b600e8190556040805182815290517f52a8358457e20bbb36e4086b83fb0749599f1893fe4c35a876c46dc4886d12db9181900360200190a150565b600042613a9360115485614dc090919063ffffffff16565b11613acf576040805162461bcd60e51b8152602060048201526007602482015266195e1c1a5c995960ca1b604482015290519081900360640190fd5b613ada848484614e18565b90505b9392505050565b6003546000906001600160a01b03168185613b7757816001600160a01b031663e124e6d28a6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613b4657600080fd5b505afa158015613b5a573d6000803e3d6000fd5b505050506040513d6020811015613b7057600080fd5b5051613bf1565b816001600160a01b03166381a612d68a6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613bc457600080fd5b505afa158015613bd8573d6000803e3d6000fd5b505050506040513d6020811015613bee57600080fd5b50515b90508515613c475783811015613c42576040805162461bcd60e51b81526020600482015260116024820152706d61726b5072696365203c20707269636560781b604482015290519081900360640190fd5b613c90565b83811115613c90576040805162461bcd60e51b81526020600482015260116024820152706d61726b5072696365203e20707269636560781b604482015290519081900360640190fd5b6000826001600160a01b03166312d43a516040518163ffffffff1660e01b815260040160206040518083038186803b158015613ccb57600080fd5b505afa158015613cdf573d6000803e3d6000fd5b505050506040513d6020811015613cf557600080fd5b81019080805190602001909291905050509050600460009054906101000a90046001600160a01b03166001600160a01b031663f3238cec8d8d8d8b8d8860006040518863ffffffff1660e01b815260040180886001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b0316815260200185151581526020018481526020018381526020018215158152602001975050505050505050600060405180830381600087803b158015613db357600080fd5b505af1158015613dc7573d6000803e3d6000fd5b50505050806001600160a01b0316636d63c1d0846040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015613e1a57600080fd5b505af1158015613e2e573d6000803e3d6000fd5b505050506000600560009054906101000a90046001600160a01b03166001600160a01b0316632662166b8e8e8e8e8e8e8e6040518863ffffffff1660e01b815260040180886001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b031681526020018581526020018481526020018315158152602001826001600160a01b03168152602001975050505050505050602060405180830381600087803b158015613ee557600080fd5b505af1158015613ef9573d6000803e3d6000fd5b505050506040513d6020811015613f0f57600080fd5b50516040805163d3c87bbb60e01b81526001600160a01b03878116600483015291519293509084169163d3c87bbb9160248082019260009290919082900301818387803b158015613f5f57600080fd5b505af1158015613f73573d6000803e3d6000fd5b50505050613f818d8a614f49565b9c9b505050505050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052613fe390849061513e565b505050565b600083516002141561402f576140288460008151811061400457fe5b60200260200101518560018151811061401957fe5b602002602001015185856151ef565b9050613add565b6040805162461bcd60e51b81526020600482015260146024820152730d2dcecc2d8d2c840bee0c2e8d05cd8cadccee8d60631b604482015290519081900360640190fd5b60065460408051632e1a7d4d60e01b81526004810185905290516001600160a01b03909216918291632e1a7d4d91602480830192600092919082900301818387803b1580156140c157600080fd5b505af11580156140d5573d6000803e3d6000fd5b5050600754604051600093506001600160a01b0386169250869084818181858888f193505050503d8060008114614128576040519150601f19603f3d011682016040523d82523d6000602084013e61412d565b606091505b50509050801561413e575050611b6a565b816001600160a01b031663d0e30db0856040518263ffffffff1660e01b81526004016000604051808303818588803b15801561417957600080fd5b505af115801561418d573d6000803e3d6000fd5b5050505050816001600160a01b031663a9059cbb84866040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156141e957600080fd5b505af11580156141fd573d6000803e3d6000fd5b505050506040513d602081101561421357600080fd5b505050505050565b6000613add83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506152d4565b6001600160a01b03841661427057614362565b614282846001600160a01b031661536b565b61428b57614362565b601754806142995750614362565b6000856001600160a01b031663a8a12308838787876040518563ffffffff1660e01b815260040180848152602001831515815260200182151581526020019350505050600060405180830381600088803b1580156142f657600080fd5b5087f193505050508015614308575060015b61431157614315565b5060015b604080516001600160a01b0388168152821515602082015280820184905290517fc9123a2a8e16684aa24686f2bf8a6d0eb0c601bdc109140c9729916865a58bc49181900360600190a150505b50505050565b6000613ada848484614e18565b804710156143ca576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114614415576040519150601f19603f3d011682016040523d82523d6000602084013e61441a565b606091505b5050905080613fe35760405162461bcd60e51b815260040180806020018281038252603a815260200180615ef9603a913960400191505060405180910390fd5b6000807311e3657fcde2053db4ec0e6327c3908aaf449c7b63e0cab550600360009054906101000a90046001600160a01b03168a8a8a8a8a8a6009546040518963ffffffff1660e01b815260040180896001600160a01b03168152602001886001600160a01b0316815260200180602001878152602001866001600160a01b031681526020018515158152602001848152602001838152602001828103825288818151815260200191508051906020019060200280838360005b8381101561452c578181015183820152602001614514565b50505050905001995050505050505050505060206040518083038186803b15801561455657600080fd5b505af415801561456a573d6000803e3d6000fd5b505050506040513d602081101561458057600080fd5b5051905080156146415760006145b96127106145b36145ac60085461271061421b90919063ffffffff16565b8a90615371565b906153ca565b905060006145c7888361421b565b905060008960018b5103815181106145db57fe5b6020026020010151905061461d82600b6000846001600160a01b03166001600160a01b0316815260200190815260200160002054614dc090919063ffffffff16565b6001600160a01b039091166000908152600b60205260409020555091506146469050565b859150505b9695505050505050565b61465b848385615409565b60035460055460048054604080516317c3cf0f60e31b81526001600160a01b03958616938101939093529284166024830152831660448201528883166064820152878316608482015291861660a483015260c4820185905283151560e48301526101048201839052517311e3657fcde2053db4ec0e6327c3908aaf449c7b9163be1e787891610124808301926000929190829003018186803b15801561470057600080fd5b505af4158015614714573d6000803e3d6000fd5b5050505061421386846155d2565b60035482516001600160a01b039091169063daf9c21090849060009061474457fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561478957600080fd5b505afa15801561479d573d6000803e3d6000fd5b505050506040513d60208110156147b357600080fd5b50516147eb576040805162461bcd60e51b81526020600482015260026024820152611ddb60f21b604482015290519081900360640190fd5b8151600214156148c05760035482516001600160a01b039091169063daf9c210908490600190811061481957fe5b60200260200101516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561485e57600080fd5b505afa158015614872573d6000803e3d6000fd5b505050506040513d602081101561488857600080fd5b50516148c0576040805162461bcd60e51b81526020600482015260026024820152611ddb60f21b604482015290519081900360640190fd5b60035460408051630daf9c2160e41b81526001600160a01b0384811660048301529151919092169163daf9c210916024808301926020929190829003018186803b15801561490d57600080fd5b505afa158015614921573d6000803e3d6000fd5b505050506040513d602081101561493757600080fd5b5051611b6a576040805162461bcd60e51b81526020600482015260026024820152611ddb60f21b604482015290519081900360640190fd5b34156149d957600660009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156149c557600080fd5b505af1158015613295573d6000803e3d6000fd5b565b80158015906149f45750600a546001600160a01b031615155b15614a4c57600a54604080516356b4b2ad60e01b81523360048201526024810184905290516001600160a01b03909216916356b4b2ad9160448082019260009290919082900301818387803b1580156149c557600080fd5b50565b6000614a59615d98565b604051806101a001604052808e6001600160a01b031681526020018d81526020018c6001600160a01b031681526020018b81526020018a815260200189815260200187815260200186815260200143815260200142815260200188151581526020018515158152602001846001600160a01b03168152509050600080614ade83615759565b915091508e6001600160a01b03167f5265bc4952da402633b3fc35f67ab4245493a0ab94dd8ab123667c8d45a4485c8f8f8f8f8f8f8f8f8b60016013805490500343423a60405180806020018e6001600160a01b031681526020018d81526020018c81526020018b81526020018a1515815260200189815260200188815260200187815260200186815260200185815260200184815260200183815260200182810382528f818151815260200191508051906020019060200280838360005b83811015614bb5578181015183820152602001614b9d565b505050509050019e50505050505050505050505050505060405180910390a29e9d5050505050505050505050505050565b6000614bf0615ce3565b604051806101c001604052808f6001600160a01b031681526020018e81526020018d6001600160a01b031681526020018c81526020018b8152602001896001600160a01b031681526020018881526020018781526020018681526020014381526020014281526020018a151581526020018515158152602001846001600160a01b03168152509050600080614c84836158f7565b9150915082600001516001600160a01b03167f81ed0476a7e785a9e4728fffd679ea97176ca1ac85e1003462558bb5677da57b84602001518560400151866060015187608001518861016001518960a001518a60c001518b60e001518c61010001518c600160148054905003434260405180806020018e6001600160a01b031681526020018d81526020018c81526020018b151581526020018a6001600160a01b0316815260200189815260200188815260200187815260200186815260200185815260200184815260200183815260200182810382528f818151815260200191508051906020019060200280838360005b83811015614d8e578181015183820152602001614d76565b505050509050019e50505050505050505050505050505060405180910390a29f9e505050505050505050505050505050565b600082820183811015613add576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b60008033301480614e3857503360009081526018602052604090205460ff165b60125490915060ff16158015614e4c575080155b15614e84576040805162461bcd60e51b815260206004820152600360248201526234303360e81b604482015290519081900360640190fd5b8015614eaa5743614ea0600f5487614dc090919063ffffffff16565b1115915050613add565b336001600160a01b03841614614eed576040805162461bcd60e51b815260206004820152600360248201526234303360e81b604482015290519081900360640190fd5b42614f0360105486614dc090919063ffffffff16565b1115614f3e576040805162461bcd60e51b815260206004820152600560248201526464656c617960d81b604482015290519081900360640190fd5b506001949350505050565b600a546001600160a01b031680614f605750611b6a565b600080826001600160a01b031663534ef883866040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b158015614faf57600080fd5b505afa158015614fc3573d6000803e3d6000fd5b505050506040513d6040811015614fd957600080fd5b508051602090910151909250905081614ff457505050611b6a565b600354604080516312d43a5160e01b815290516000926001600160a01b0316916312d43a51916004808301926020929190829003018186803b15801561503957600080fd5b505afa15801561504d573d6000803e3d6000fd5b505050506040513d602081101561506357600080fd5b50516040805163318bc68960e01b815290519192507f474c763ff84bf2c2039a6d9fea955ecd0f724030e3c365b91169c6a16fe751b791889188916001600160a01b0386169163318bc6899160048083019260209291908290030181600087803b1580156150d057600080fd5b505af11580156150e4573d6000803e3d6000fd5b505050506040513d60208110156150fa57600080fd5b5051604080516001600160a01b03948516815260208101939093528281019190915260608201879052918516608082015290519081900360a00190a1505050505050565b6060615193826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316615aad9092919063ffffffff16565b805190915015613fe3578080602001905160208110156151b257600080fd5b5051613fe35760405162461bcd60e51b815260040180806020018281038252602a815260200180615f7a602a913960400191505060405180910390fd5b60035460408051634998b10960e11b81526001600160a01b03878116600483015286811660248301528481166044830152915160009384931691639331621291606480830192602092919082900301818787803b15801561524f57600080fd5b505af1158015615263573d6000803e3d6000fd5b505050506040513d602081101561527957600080fd5b50519050838110156152cb576040805162461bcd60e51b81526020600482015260166024820152751a5b9cdd59999a58da595b9d08185b5bdd5b9d13dd5d60521b604482015290519081900360640190fd5b95945050505050565b600081848411156153635760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015615328578181015183820152602001615310565b50505050905090810190601f1680156153555780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b3b151590565b600082615380575060006129e8565b8282028284828161538d57fe5b0414613add5760405162461bcd60e51b8152600401808060200182810382526021815260200180615f596021913960400191505060405180910390fd5b6000613add83836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b815250615abc565b8061541357613fe3565b8115615511576001600160a01b0383166000908152600c602052604090205480158015906154c457506003546040805163783a2b6760e11b81526001600160a01b038781166004830152915184936154c293879391169163f07456ce91602480820192602092909190829003018186803b15801561549057600080fd5b505afa1580156154a4573d6000803e3d6000fd5b505050506040513d60208110156154ba57600080fd5b505190614dc0565b115b1561550b576040805162461bcd60e51b81526020600482015260126024820152711b585e081b1bdb99dcc8195e18d95959195960721b604482015290519081900360640190fd5b50613fe3565b6001600160a01b0383166000908152600d6020526040902054801580159061558a57506003546040805163114f1b5560e31b81526001600160a01b03878116600483015291518493615588938793911691638a78daa891602480820192602092909190829003018186803b15801561549057600080fd5b115b15614362576040805162461bcd60e51b81526020600482015260136024820152721b585e081cda1bdc9d1cc8195e18d959591959606a1b604482015290519081900360640190fd5b600a546001600160a01b0316806155e95750611b6a565b600080826001600160a01b031663534ef883866040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b15801561563857600080fd5b505afa15801561564c573d6000803e3d6000fd5b505050506040513d604081101561566257600080fd5b50805160209091015190925090508161567d57505050611b6a565b600354604080516312d43a5160e01b815290516000926001600160a01b0316916312d43a51916004808301926020929190829003018186803b1580156156c257600080fd5b505afa1580156156d6573d6000803e3d6000fd5b505050506040513d60208110156156ec57600080fd5b50516040805163318bc68960e01b815290519192507fc2414023ce7002ee98557d1e7be21e5559073336f2217ee5f9b2e50fd85f71ee91889188916001600160a01b0386169163318bc6899160048083019260209291908290030181600087803b1580156150d057600080fd5b80516001600160a01b038116600090815260196020526040812054909182918290615785906001614dc0565b6001600160a01b03831660009081526019602052604081208290559091506157ad83836129a8565b6000818152601a60209081526040909120885181546001600160a01b0319166001600160a01b03909116178155888201518051939450899391926157f992600185019290910190615e1f565b5060408201516002820180546001600160a01b0319166001600160a01b03928316179055606083015160038301556080830151600483015560a0830151600583015560c0830151600683015560e083015160078301556101008084015160088401556101208401516009840155610140840151600a90930180546101608601516101809096015160ff199091169415159490941761ff0019169415159091029390931762010000600160b01b031916620100009290911691909102179055601380546001810182556000919091527f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a09001819055909590945092505050565b80516001600160a01b0381166000908152601b6020526040812054909182918290615923906001614dc0565b6001600160a01b0383166000908152601b6020526040812082905590915061594b83836129a8565b6000818152601c60209081526040909120885181546001600160a01b0319166001600160a01b039091161781558882015180519394508993919261599792600185019290910190615e1f565b5060408201516002820180546001600160a01b03199081166001600160a01b0393841617909155606084015160038401556080840151600484015560a084015160058401805490921690831617905560c0830151600683015560e083015160078301556101008084015160088401556101208401516009840155610140840151600a840155610160840151600b90930180546101808601516101a09096015160ff199091169415159490941761ff0019169415159091029390931762010000600160b01b031916620100009290911691909102179055601480546001810182556000919091527fce6d7b5282bd9a3661ae061feed1dbda4e52ab073b1f9285be6e155d9c38d4ec01819055909590945092505050565b6060613ada8484600085615b21565b60008183615b0b5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315615328578181015183820152602001615310565b506000838581615b1757fe5b0495945050505050565b606082471015615b625760405162461bcd60e51b8152600401808060200182810382526026815260200180615f336026913960400191505060405180910390fd5b615b6b8561536b565b615bbc576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310615bfb5780518252601f199092019160209182019101615bdc565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114615c5d576040519150601f19603f3d011682016040523d82523d6000602084013e615c62565b606091505b5091509150615c72828286615c7d565b979650505050505050565b60608315615c8c575081613add565b825115615c9c5782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315615328578181015183820152602001615310565b604051806101c0016040528060006001600160a01b031681526020016060815260200160006001600160a01b03168152602001600081526020016000815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160001515815260200160006001600160a01b031681525090565b5080546000825590600052602060002090810190614a4c9190615e84565b604051806101a0016040528060006001600160a01b031681526020016060815260200160006001600160a01b031681526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815260200160001515815260200160006001600160a01b031681525090565b828054828255906000526020600020908101928215615e74579160200282015b82811115615e7457825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190615e3f565b50615e80929150615e99565b5090565b5b80821115615e805760008155600101615e85565b5b80821115615e805780546001600160a01b0319168155600101615e9a56fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00476f7665726e61626c653a20666f7262696464656e0000000000000000000000416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a164736f6c634300060c000a

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

00000000000000000000000099b31498b0a1dae01fc3433e3cb60f095340935c0000000000000000000000001fe9fba5955af58c18057213f0151bbe893ab2c80000000000000000000000004f9a0e7fd2bf6067db6994cf12e4495df938e6e9000000000000000000000000e5041618b6de86a3ae68db2283b92295a7b5ae6a000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000011c37937e08000

-----Decoded View---------------
Arg [0] : _vault (address): 0x99B31498B0a1Dae01fc3433e3Cb60F095340935C
Arg [1] : _router (address): 0x1FE9fBA5955Af58C18057213F0151BBE893aB2c8
Arg [2] : _weth (address): 0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9
Arg [3] : _shortsTracker (address): 0xE5041618b6de86A3AE68Db2283b92295a7B5aE6a
Arg [4] : _depositFee (uint256): 30
Arg [5] : _minExecutionFee (uint256): 5000000000000000

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 00000000000000000000000099b31498b0a1dae01fc3433e3cb60f095340935c
Arg [1] : 0000000000000000000000001fe9fba5955af58c18057213f0151bbe893ab2c8
Arg [2] : 0000000000000000000000004f9a0e7fd2bf6067db6994cf12e4495df938e6e9
Arg [3] : 000000000000000000000000e5041618b6de86a3ae68db2283b92295a7b5ae6a
Arg [4] : 000000000000000000000000000000000000000000000000000000000000001e
Arg [5] : 0000000000000000000000000000000000000000000000000011c37937e08000


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.