Contract 0xa21b83e579f4315951ba658654c371520bdcb866 1

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x1220fcfd9de0190781c6b08cad31747df8c39e86ba67715aa4ef921806fdcf1fLiquidate Positi...228768682022-11-26 19:05:527 mins ago0x7858a4c42c619a68df6e95df7235a9ec6f0308b9 IN  GMX: Position Manager0 AVAX0.0115690255 26.5
0xa03466de717898cfb2a1bedf2b12489b57f24229c0f4cf44d103ddead1bcea20Liquidate Positi...228768372022-11-26 19:04:508 mins ago0x7858a4c42c619a68df6e95df7235a9ec6f0308b9 IN  GMX: Position Manager0 AVAX0.0130176215 26.5
0xfd8c857aa0be14b54835dd7d5f940b23ad50bc8502e5e65c4f8c6c8aae305a9cExecute Decrease...228768262022-11-26 19:04:258 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.015519937 26.5
0xbf0ab82cfb0a2c2f82695099bb56b5e84d50641b5c76051b51f278430ca9e57aExecute Increase...228768262022-11-26 19:04:258 mins ago0xf26f52d5985f6391e541a8d638e1edaa522ae56c IN  GMX: Position Manager0 AVAX0.0219170635 26.5
0xa38e1cd7466e3c4fe769872a895a207b81e7282fd31466840db0fb7a4771d017Liquidate Positi...228767762022-11-26 19:02:4910 mins ago0x7858a4c42c619a68df6e95df7235a9ec6f0308b9 IN  GMX: Position Manager0 AVAX0.011545944 26.5
0x0b7753b2e1efe0446f147a2786fe4b91930fc9f4be8f2ebf92761f5e2fddb338Liquidate Positi...228767682022-11-26 19:02:3310 mins ago0x7858a4c42c619a68df6e95df7235a9ec6f0308b9 IN  GMX: Position Manager0 AVAX0.012755669 26.5
0x10eb9215c1495d7f43f5c5038e2eb783916081b48da3b0a220d305109e3a6c97Execute Decrease...228767452022-11-26 19:01:4411 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.0154365945 26.5
0xe9ed3701685979e7588a3675a2ffd781fd5d59c60b31e5349ca4c2efe8901e0eExecute Decrease...228767392022-11-26 19:01:3511 mins ago0xf26f52d5985f6391e541a8d638e1edaa522ae56c IN  GMX: Position Manager0 AVAX0.017207616 26.5
0x0abff7264f86cae639752c74f5c8832bf46ce57e16c296454df076a1bbfb8447Execute Increase...228767382022-11-26 19:01:3311 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.0020877495 26.5
0xa42ab7a0d6b291dd47551b7ed067eb6d43af681ec163643b9f46cfbb13970e94Execute Increase...228767352022-11-26 19:01:2711 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.0223612565 26.5
0xb4695e93260c839ac598bf2d1b73d971b3dd8f9b44d816de92f65a8398c5ecbeLiquidate Positi...228766082022-11-26 18:57:1116 mins ago0x7858a4c42c619a68df6e95df7235a9ec6f0308b9 IN  GMX: Position Manager0 AVAX0.011551986 26.5
0x0760e0e31f39de53125e5f7c53f68f11e9d83ef37ca4dcfd805ecb746ce9baeaExecute Decrease...228765202022-11-26 18:54:1119 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.01559207 26.5
0x749d21031a82d914de897f5eef1986a14801eab3e36ddfcb92dc73fa8397111cExecute Increase...228765122022-11-26 18:53:5519 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.002117215272 26.87401181
0x4df1924e79944ff459f461371daba9c5e562b8fec2ae75582de48f9e3725fe7bExecute Increase...228765102022-11-26 18:53:4919 mins ago0xf26f52d5985f6391e541a8d638e1edaa522ae56c IN  GMX: Position Manager0 AVAX0.022818416326 27.596402213
0x670f9a22986b7f327ae4451ec50d110bb468b784318d00fdb244897539789338Execute Increase...228765102022-11-26 18:53:4919 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.025101439085 27.596402213
0xe378c6209a0e3c57c4fde54cdc49e188bdcf353433b7e8535bbb3c8fef0bfcfbExecute Decrease...228765092022-11-26 18:53:4719 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.015855025443 27.88437096
0xe5f4647bf15c83d0c595e627cbb4bae4e2b1b7a646b3f9624bd8acea58bb9768Execute Decrease...228765092022-11-26 18:53:4719 mins ago0xf26f52d5985f6391e541a8d638e1edaa522ae56c IN  GMX: Position Manager0 AVAX0.015854690831 27.88437096
0xc083b474ca9138d5e425c7ac3e54ef9a9561253132d65b1115798d0bc4618119Execute Increase...228759342022-11-26 18:34:2139 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.0241041615 26.5
0x7668b625e530b501b69640c5f80ae363fc84eaa3a376ebe2b52e05e195d10059Liquidate Positi...228749582022-11-26 18:00:311 hr 12 mins ago0x7858a4c42c619a68df6e95df7235a9ec6f0308b9 IN  GMX: Position Manager0 AVAX0.0134356325 26.5
0x6f690520a67270df3152f235939e7dc02f6d3ce5fa309eefb7f25c2c7684c1b5Execute Decrease...228732812022-11-26 17:03:012 hrs 10 mins ago0xf26f52d5985f6391e541a8d638e1edaa522ae56c IN  GMX: Position Manager0 AVAX0.0142398545 26.5
0xd75e370c1146c59013fbe6c7ae5b056aa2e99d30c82e5ce265f6f773fbf046c2Execute Decrease...228732712022-11-26 17:02:402 hrs 10 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.014322667 26.5
0xdfb458a8795b06e782cc9e83f73f939ae4b86bd1c2da5051bba643fcd202bc4aLiquidate Positi...228731852022-11-26 16:59:492 hrs 13 mins ago0x7858a4c42c619a68df6e95df7235a9ec6f0308b9 IN  GMX: Position Manager0 AVAX0.0131141875 26.5
0x1ce22ddabc9a9d3dcb5b29fcd853d56e503f36ee64cd2183ef2d3ee6d05273f3Execute Increase...228730552022-11-26 16:55:152 hrs 18 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.0162158535 26.5
0xbc34e760c86bf91e1a35b772d3505822a6bd84e184d94545a7b4c61caa0df869Execute Increase...228716212022-11-26 16:06:183 hrs 7 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.019488577 26.5
0xd52abc09c2ada645296ade1fe59d1bb64927645b6d15abc152a2cefbe8b131ebExecute Decrease...228705212022-11-26 15:28:183 hrs 45 mins ago0x06f34388a7cfdcc68ac9167c5f1c23dd39783179 IN  GMX: Position Manager0 AVAX0.017377269 26.5
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PositionManager

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 1 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 17 : PositionManager.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

import "../peripherals/interfaces/ITimelock.sol";
import "./BasePositionManager.sol";

contract PositionManager is BasePositionManager {

    address public orderBook;
    bool public inLegacyMode;

    bool public shouldValidateIncreaseOrder = true;

    mapping (address => bool) public isOrderKeeper;
    mapping (address => bool) public isPartner;
    mapping (address => bool) public isLiquidator;

    event SetOrderKeeper(address indexed account, bool isActive);
    event SetLiquidator(address indexed account, bool isActive);
    event SetPartner(address account, bool isActive);
    event SetInLegacyMode(bool inLegacyMode);
    event SetShouldValidateIncreaseOrder(bool shouldValidateIncreaseOrder);

    modifier onlyOrderKeeper() {
        require(isOrderKeeper[msg.sender], "PositionManager: forbidden");
        _;
    }

    modifier onlyLiquidator() {
        require(isLiquidator[msg.sender], "PositionManager: forbidden");
        _;
    }

    modifier onlyPartnersOrLegacyMode() {
        require(isPartner[msg.sender] || inLegacyMode, "PositionManager: forbidden");
        _;
    }

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

    function setOrderKeeper(address _account, bool _isActive) external onlyAdmin {
        isOrderKeeper[_account] = _isActive;
        emit SetOrderKeeper(_account, _isActive);
    }

    function setLiquidator(address _account, bool _isActive) external onlyAdmin {
        isLiquidator[_account] = _isActive;
        emit SetLiquidator(_account, _isActive);
    }

    function setPartner(address _account, bool _isActive) external onlyAdmin {
        isPartner[_account] = _isActive;
        emit SetPartner(_account, _isActive);
    }

    function setInLegacyMode(bool _inLegacyMode) external onlyAdmin {
        inLegacyMode = _inLegacyMode;
        emit SetInLegacyMode(_inLegacyMode);
    }

    function setShouldValidateIncreaseOrder(bool _shouldValidateIncreaseOrder) external onlyAdmin {
        shouldValidateIncreaseOrder = _shouldValidateIncreaseOrder;
        emit SetShouldValidateIncreaseOrder(_shouldValidateIncreaseOrder);
    }

    function increasePosition(
        address[] memory _path,
        address _indexToken,
        uint256 _amountIn,
        uint256 _minOut,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _price
    ) external nonReentrant onlyPartnersOrLegacyMode {
        require(_path.length == 1 || _path.length == 2, "PositionManager: invalid _path.length");

        if (_amountIn > 0) {
            if (_path.length == 1) {
                IRouter(router).pluginTransfer(_path[0], msg.sender, address(this), _amountIn);
            } else {
                IRouter(router).pluginTransfer(_path[0], msg.sender, vault, _amountIn);
                _amountIn = _swap(_path, _minOut, address(this));
            }

            uint256 afterFeeAmount = _collectFees(msg.sender, _path, _amountIn, _indexToken, _isLong, _sizeDelta);
            IERC20(_path[_path.length - 1]).safeTransfer(vault, afterFeeAmount);
        }

        _increasePosition(msg.sender, _path[_path.length - 1], _indexToken, _sizeDelta, _isLong, _price);
    }

    function increasePositionETH(
        address[] memory _path,
        address _indexToken,
        uint256 _minOut,
        uint256 _sizeDelta,
        bool _isLong,
        uint256 _price
    ) external payable nonReentrant onlyPartnersOrLegacyMode {
        require(_path.length == 1 || _path.length == 2, "PositionManager: invalid _path.length");
        require(_path[0] == weth, "PositionManager: invalid _path");

        if (msg.value > 0) {
            _transferInETH();
            uint256 _amountIn = msg.value;

            if (_path.length > 1) {
                IERC20(weth).safeTransfer(vault, msg.value);
                _amountIn = _swap(_path, _minOut, address(this));
            }

            uint256 afterFeeAmount = _collectFees(msg.sender, _path, _amountIn, _indexToken, _isLong, _sizeDelta);
            IERC20(_path[_path.length - 1]).safeTransfer(vault, afterFeeAmount);
        }

        _increasePosition(msg.sender, _path[_path.length - 1], _indexToken, _sizeDelta, _isLong, _price);
    }

    function decreasePosition(
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver,
        uint256 _price
    ) external nonReentrant onlyPartnersOrLegacyMode {
        _decreasePosition(msg.sender, _collateralToken, _indexToken, _collateralDelta, _sizeDelta, _isLong, _receiver, _price);
    }

    function decreasePositionETH(
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address payable _receiver,
        uint256 _price
    ) external nonReentrant onlyPartnersOrLegacyMode {
        require(_collateralToken == weth, "PositionManager: invalid _collateralToken");

        uint256 amountOut = _decreasePosition(msg.sender, _collateralToken, _indexToken, _collateralDelta, _sizeDelta, _isLong, address(this), _price);
        _transferOutETHWithGasLimitIgnoreFail(amountOut, _receiver);
    }

    function decreasePositionAndSwap(
        address[] memory _path,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver,
        uint256 _price,
        uint256 _minOut
    ) external nonReentrant onlyPartnersOrLegacyMode {
        require(_path.length == 2, "PositionManager: invalid _path.length");

        uint256 amount = _decreasePosition(msg.sender, _path[0], _indexToken, _collateralDelta, _sizeDelta, _isLong, address(this), _price);
        IERC20(_path[0]).safeTransfer(vault, amount);
        _swap(_path, _minOut, _receiver);
    }

    function decreasePositionAndSwapETH(
        address[] memory _path,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address payable _receiver,
        uint256 _price,
        uint256 _minOut
    ) external nonReentrant onlyPartnersOrLegacyMode {
        require(_path.length == 2, "PositionManager: invalid _path.length");
        require(_path[_path.length - 1] == weth, "PositionManager: invalid _path");

        uint256 amount = _decreasePosition(msg.sender, _path[0], _indexToken, _collateralDelta, _sizeDelta, _isLong, address(this), _price);
        IERC20(_path[0]).safeTransfer(vault, amount);
        uint256 amountOut = _swap(_path, _minOut, address(this));
        _transferOutETHWithGasLimitIgnoreFail(amountOut, _receiver);
    }

    function liquidatePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        address _feeReceiver
    ) external nonReentrant onlyLiquidator {
        address _vault = vault;
        address timelock = IVault(_vault).gov();
        (uint256 size, , , , , , , ) = IVault(vault).getPosition(_account, _collateralToken, _indexToken, _isLong);

        uint256 markPrice = _isLong ? IVault(_vault).getMinPrice(_indexToken) : IVault(_vault).getMaxPrice(_indexToken);
        // should be called strictly before position is updated in Vault
        IShortsTracker(shortsTracker).updateGlobalShortData(_account, _collateralToken, _indexToken, _isLong, size, markPrice, false);

        ITimelock(timelock).enableLeverage(_vault);
        IVault(_vault).liquidatePosition(_account, _collateralToken, _indexToken, _isLong, _feeReceiver);
        ITimelock(timelock).disableLeverage(_vault);
    }

    function executeSwapOrder(address _account, uint256 _orderIndex, address payable _feeReceiver) external onlyOrderKeeper {
        IOrderBook(orderBook).executeSwapOrder(_account, _orderIndex, _feeReceiver);
    }

    function executeIncreaseOrder(address _account, uint256 _orderIndex, address payable _feeReceiver) external onlyOrderKeeper {
        _validateIncreaseOrder(_account, _orderIndex);

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

        (
            /*address purchaseToken*/,
            /*uint256 purchaseTokenAmount*/,
            address collateralToken,
            address indexToken,
            uint256 sizeDelta,
            bool isLong,
            /*uint256 triggerPrice*/,
            /*bool triggerAboveThreshold*/,
            /*uint256 executionFee*/
        ) = IOrderBook(orderBook).getIncreaseOrder(_account, _orderIndex);

        uint256 markPrice = isLong ? IVault(_vault).getMaxPrice(indexToken) : IVault(_vault).getMinPrice(indexToken);
        // should be called strictly before position is updated in Vault
        IShortsTracker(shortsTracker).updateGlobalShortData(_account, collateralToken, indexToken, isLong, sizeDelta, markPrice, true);

        ITimelock(timelock).enableLeverage(_vault);
        IOrderBook(orderBook).executeIncreaseOrder(_account, _orderIndex, _feeReceiver);
        ITimelock(timelock).disableLeverage(_vault);

        _emitIncreasePositionReferral(_account, sizeDelta);
    }

    function executeDecreaseOrder(address _account, uint256 _orderIndex, address payable _feeReceiver) external onlyOrderKeeper {
        address _vault = vault;
        address timelock = IVault(_vault).gov();

        (
            address collateralToken,
            /*uint256 collateralDelta*/,
            address indexToken,
            uint256 sizeDelta,
            bool isLong,
            /*uint256 triggerPrice*/,
            /*bool triggerAboveThreshold*/,
            /*uint256 executionFee*/
        ) = IOrderBook(orderBook).getDecreaseOrder(_account, _orderIndex);

        uint256 markPrice = isLong ? IVault(_vault).getMinPrice(indexToken) : IVault(_vault).getMaxPrice(indexToken);
        // should be called strictly before position is updated in Vault
        IShortsTracker(shortsTracker).updateGlobalShortData(_account, collateralToken, indexToken, isLong, sizeDelta, markPrice, false);

        ITimelock(timelock).enableLeverage(_vault);
        IOrderBook(orderBook).executeDecreaseOrder(_account, _orderIndex, _feeReceiver);
        ITimelock(timelock).disableLeverage(_vault);

        _emitDecreasePositionReferral(_account, sizeDelta);
    }

    function _validateIncreaseOrder(address _account, uint256 _orderIndex) internal view {
        (
            address _purchaseToken,
            uint256 _purchaseTokenAmount,
            address _collateralToken,
            address _indexToken,
            uint256 _sizeDelta,
            bool _isLong,
            , // triggerPrice
            , // triggerAboveThreshold
            // executionFee
        ) = IOrderBook(orderBook).getIncreaseOrder(_account, _orderIndex);

        _validateMaxGlobalSize(_indexToken, _isLong, _sizeDelta);

        if (!shouldValidateIncreaseOrder) { return; }

        // shorts are okay
        if (!_isLong) { return; }

        // if the position size is not increasing, this is a collateral deposit
        require(_sizeDelta > 0, "PositionManager: long deposit");

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

        uint256 nextSize = size.add(_sizeDelta);
        uint256 collateralDelta = _vault.tokenToUsdMin(_purchaseToken, _purchaseTokenAmount);
        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 nextLeverageWithBuffer = nextSize.mul(BASIS_POINTS_DIVISOR + increasePositionBufferBps).div(nextCollateral);

        require(nextLeverageWithBuffer >= prevLeverage, "PositionManager: long leverage decrease");
    }
}

File 2 of 17 : 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 3 of 17 : 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 usdg() external view returns (address);
    function gov() external view returns (address);

    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 getTargetUsdgAmount(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 setUsdgAmount(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 _maxUsdgAmount,
        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 buyUSDG(address _token, address _receiver) external returns (uint256);
    function sellUSDG(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 _usdgDelta, 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 usdgAmounts(address _token) external view returns (uint256);
    function maxUsdgAmounts(address _token) external view returns (uint256);
    function getRedemptionAmount(address _token, uint256 _usdgAmount) 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 4 of 17 : 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 5 of 17 : ITimelock.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface ITimelock {
    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 6 of 17 : 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";

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;

    // 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 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, "BasePositionManager: 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, "BasePositionManager: invalid sender");
    }

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

    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("BasePositionManager: max global longs exceeded");
            }
        } else {
            uint256 maxGlobalShortSize = maxGlobalShortSizes[_indexToken];
            if (maxGlobalShortSize > 0 && IVault(vault).globalShortSizes(_indexToken).add(_sizeDelta) > maxGlobalShortSize) {
                revert("BasePositionManager: max global shorts exceeded");
            }
        }
    }

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

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

        _validateMaxGlobalSize(_indexToken, _isLong, _sizeDelta);

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

        _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, "BasePositionManager: mark price lower than limit");
        } else {
            require(markPrice <= _price, "BasePositionManager: mark price higher than limit");
        }

        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 _emitIncreasePositionReferral(address _account, uint256 _sizeDelta) internal {
        address _referralStorage = referralStorage;
        if (_referralStorage == address(0)) {
            return;
        }

        (bytes32 referralCode, address referrer) = IReferralStorage(_referralStorage).getTraderReferralInfo(_account);
        emit IncreasePositionReferral(
            _account,
            _sizeDelta,
            IVault(vault).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;
        }

        emit DecreasePositionReferral(
            _account,
            _sizeDelta,
            IVault(vault).marginFeeBasisPoints(),
            referralCode,
            referrer
        );
    }

    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("BasePositionManager: 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, "BasePositionManager: insufficient amountOut");
        return amountOut;
    }

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

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

        // use `send` instead of `transfer` to not revert whole transaction in case ETH transfer was failed
        // it has limit of 2300 gas
        // this is to avoid front-running
        _receiver.send(_amountOut);
    }

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

        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 _shouldDeductFee(
        address _account,
        address[] memory _path,
        uint256 _amountIn,
        address _indexToken,
        bool _isLong,
        uint256 _sizeDelta
    ) internal view 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);

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

File 7 of 17 : 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 getBuyUsdgFeeBasisPoints(address _token, uint256 _usdgAmount) external view returns (uint256);
    function getSellUsdgFeeBasisPoints(address _token, uint256 _usdgAmount) external view returns (uint256);
    function getSwapFeeBasisPoints(address _tokenIn, address _tokenOut, uint256 _usdgAmount) external view returns (uint256);
    function getFeeBasisPoints(address _token, uint256 _usdgDelta, uint256 _feeBasisPoints, uint256 _taxBasisPoints, bool _increment) external view returns (uint256);
}

File 8 of 17 : 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 9 of 17 : 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 10 of 17 : 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;
}

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

pragma solidity ^0.6.2;

/**
 * @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 13 of 17 : 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 14 of 17 : 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;
}

File 15 of 17 : 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 16 of 17 : 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 17 of 17 : IReferralStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IReferralStorage {
    function codeOwners(bytes32 _code) external view returns (address);
    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;
}

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"_vault","type":"address"},{"internalType":"address","name":"_router","type":"address"},{"internalType":"address","name":"_shortsTracker","type":"address"},{"internalType":"address","name":"_weth","type":"address"},{"internalType":"uint256","name":"_depositFee","type":"uint256"},{"internalType":"address","name":"_orderBook","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"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":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":"depositFee","type":"uint256"}],"name":"SetDepositFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"inLegacyMode","type":"bool"}],"name":"SetInLegacyMode","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"increasePositionBufferBps","type":"uint256"}],"name":"SetIncreasePositionBufferBps","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isActive","type":"bool"}],"name":"SetLiquidator","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":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isActive","type":"bool"}],"name":"SetOrderKeeper","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isActive","type":"bool"}],"name":"SetPartner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"referralStorage","type":"address"}],"name":"SetReferralStorage","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"shouldValidateIncreaseOrder","type":"bool"}],"name":"SetShouldValidateIncreaseOrder","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":[{"internalType":"address","name":"_collateralToken","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":"_price","type":"uint256"}],"name":"decreasePosition","outputs":[],"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":"_price","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"}],"name":"decreasePositionAndSwap","outputs":[],"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 payable","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_minOut","type":"uint256"}],"name":"decreasePositionAndSwapETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","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 payable","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"decreasePositionETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"},{"internalType":"address payable","name":"_feeReceiver","type":"address"}],"name":"executeDecreaseOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"},{"internalType":"address payable","name":"_feeReceiver","type":"address"}],"name":"executeIncreaseOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_orderIndex","type":"uint256"},{"internalType":"address payable","name":"_feeReceiver","type":"address"}],"name":"executeSwapOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feeReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gov","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"inLegacyMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":"_price","type":"uint256"}],"name":"increasePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"increasePositionBufferBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":"_price","type":"uint256"}],"name":"increasePositionETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isLiquidator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isOrderKeeper","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isPartner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"address","name":"_feeReceiver","type":"address"}],"name":"liquidatePosition","outputs":[],"stateMutability":"nonpayable","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":"orderBook","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"_depositFee","type":"uint256"}],"name":"setDepositFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gov","type":"address"}],"name":"setGov","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_inLegacyMode","type":"bool"}],"name":"setInLegacyMode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_increasePositionBufferBps","type":"uint256"}],"name":"setIncreasePositionBufferBps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_isActive","type":"bool"}],"name":"setLiquidator","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":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_isActive","type":"bool"}],"name":"setOrderKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_isActive","type":"bool"}],"name":"setPartner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_referralStorage","type":"address"}],"name":"setReferralStorage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_shouldValidateIncreaseOrder","type":"bool"}],"name":"setShouldValidateIncreaseOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shortsTracker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"shouldValidateIncreaseOrder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"withdrawFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040526064600855600d805460ff60a81b1916600160a81b17905534801561002857600080fd5b506040516200512538038062005125833981810160405260c081101561004d57600080fd5b508051602082015160408301516060840151608085015160a0909501516001600081905580546001600160a01b031990811633908117909255600380546001600160a01b039889169083161790556005805496881696821696909617909555600680549387169386169390931790925560079590955560048054928516928416929092179091556002805483169091179055600d805492909316911617905561502980620000fc6000396000f3fe6080604052600436106101ef5760003560e01c80626cc35e1461024457806307c7edc3146102755780631045c74e146102b857806311d9444a146102fd578063126082cf1461034057806312d43a51146103555780631b9043591461036a5780631ce9cb8f146103965780631e261538146103c957806321acf65914610404578063233bfe3b1461043f57806324a084df146104695780633039e37f146104a25780633833f5f5146105825780633fc8cef3146105c9578063430ed37c146105de5780634453a3741461063d5780634584bd4b14610678578063490ae2101461068d578063529a356f146106b75780635fc8500e146106ea578063657bc5d0146107ca57806367a52793146107df578063704b6c02146107f4578063776af5ba146108275780638c0f9aac1461083c57806390205d8c1461086f5780639698d25a146108ce57806398d1e03a146109015780639c95332f14610916578063ae4d7f9a14610942578063b32755de14610975578063b7ddc99214610a38578063cfad57a214610b0e578063d38ab51914610b41578063d4ca83f914610b84578063de2ea94814610b99578063e1f21c6714610bee578063ef12c67e14610c31578063f255527814610de3578063f851a44014610e1e578063f887ea4014610e33578063fbfa77cf14610e485761023f565b3661023f576006546001600160a01b0316331461023d5760405162461bcd60e51b8152600401808060200182810382526023815260200180614f826023913960400191505060405180910390fd5b005b600080fd5b34801561025057600080fd5b50610259610e5d565b604080516001600160a01b039092168252519081900360200190f35b34801561028157600080fd5b5061023d6004803603606081101561029857600080fd5b506001600160a01b03813581169160208101359160409091013516610e6c565b3480156102c457600080fd5b506102eb600480360360208110156102db57600080fd5b50356001600160a01b0316610f38565b60408051918252519081900360200190f35b34801561030957600080fd5b5061023d6004803603606081101561032057600080fd5b506001600160a01b03813581169160208101359160409091013516610f4a565b34801561034c57600080fd5b506102eb6113aa565b34801561036157600080fd5b506102596113b0565b34801561037657600080fd5b5061023d6004803603602081101561038d57600080fd5b503515156113bf565b3480156103a257600080fd5b506102eb600480360360208110156103b957600080fd5b50356001600160a01b031661145f565b3480156103d557600080fd5b5061023d600480360360408110156103ec57600080fd5b506001600160a01b0381351690602001351515611471565b34801561041057600080fd5b5061023d6004803603604081101561042757600080fd5b506001600160a01b038135169060200135151561151e565b34801561044b57600080fd5b5061023d6004803603602081101561046257600080fd5b50356115cf565b34801561047557600080fd5b5061023d6004803603604081101561048c57600080fd5b506001600160a01b038135169060200135611657565b3480156104ae57600080fd5b5061023d60048036036101008110156104c657600080fd5b810190602081018135600160201b8111156104e057600080fd5b8201836020820111156104f257600080fd5b803590602001918460208302840111600160201b8311171561051357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550505081356001600160a01b0390811693506020830135926040810135925060608101351515916080820135169060a08101359060c001356116bb565b34801561058e57600080fd5b506105b5600480360360208110156105a557600080fd5b50356001600160a01b03166118b6565b604080519115158252519081900360200190f35b3480156105d557600080fd5b506102596118cb565b3480156105ea57600080fd5b5061023d600480360360e081101561060157600080fd5b506001600160a01b0381358116916020810135821691604082013591606081013591608082013515159160a08101359091169060c001356118da565b34801561064957600080fd5b5061023d6004803603604081101561066057600080fd5b506001600160a01b0381351690602001351515611a03565b34801561068457600080fd5b506105b5611ab0565b34801561069957600080fd5b5061023d600480360360208110156106b057600080fd5b5035611ac0565b3480156106c357600080fd5b506105b5600480360360208110156106da57600080fd5b50356001600160a01b0316611b48565b3480156106f657600080fd5b5061023d600480360361010081101561070e57600080fd5b810190602081018135600160201b81111561072857600080fd5b82018360208201111561073a57600080fd5b803590602001918460208302840111600160201b8311171561075b57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550505081356001600160a01b0390811693506020830135926040810135925060608101351515916080820135169060a08101359060c00135611b5d565b3480156107d657600080fd5b50610259611c94565b3480156107eb57600080fd5b506102eb611ca3565b34801561080057600080fd5b5061023d6004803603602081101561081757600080fd5b50356001600160a01b0316611ca9565b34801561083357600080fd5b50610259611d4a565b34801561084857600080fd5b506105b56004803603602081101561085f57600080fd5b50356001600160a01b0316611d59565b34801561087b57600080fd5b5061023d600480360360e081101561089257600080fd5b506001600160a01b0381358116916020810135821691604082013591606081013591608082013515159160a08101359091169060c00135611d6e565b3480156108da57600080fd5b506102eb600480360360208110156108f157600080fd5b50356001600160a01b0316611e2e565b34801561090d57600080fd5b506102eb611e40565b34801561092257600080fd5b5061023d6004803603602081101561093957600080fd5b50351515611e46565b34801561094e57600080fd5b5061023d6004803603602081101561096557600080fd5b50356001600160a01b0316611ee6565b61023d600480360360c081101561098b57600080fd5b810190602081018135600160201b8111156109a557600080fd5b8201836020820111156109b757600080fd5b803590602001918460208302840111600160201b831117156109d857600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550506001600160a01b0383351693505050602081013590604081013590606081013515159060800135611f87565b348015610a4457600080fd5b5061023d600480360360e0811015610a5b57600080fd5b810190602081018135600160201b811115610a7557600080fd5b820183602082011115610a8757600080fd5b803590602001918460208302840111600160201b83111715610aa857600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550506001600160a01b0383351693505050602081013590604081013590606081013590608081013515159060a001356121a6565b348015610b1a57600080fd5b5061023d60048036036020811015610b3157600080fd5b50356001600160a01b0316612485565b348015610b4d57600080fd5b5061023d60048036036060811015610b6457600080fd5b506001600160a01b038135811691602081013591604090910135166124f4565b348015610b9057600080fd5b506105b5612955565b348015610ba557600080fd5b5061023d600480360360a0811015610bbc57600080fd5b506001600160a01b03813581169160208101358216916040820135811691606081013515159160809091013516612965565b348015610bfa57600080fd5b5061023d60048036036060811015610c1157600080fd5b506001600160a01b03813581169160208101359091169060400135612e0a565b348015610c3d57600080fd5b5061023d60048036036060811015610c5457600080fd5b810190602081018135600160201b811115610c6e57600080fd5b820183602082011115610c8057600080fd5b803590602001918460208302840111600160201b83111715610ca157600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610cf057600080fd5b820183602082011115610d0257600080fd5b803590602001918460208302840111600160201b83111715610d2357600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610d7257600080fd5b820183602082011115610d8457600080fd5b803590602001918460208302840111600160201b83111715610da557600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550612edf945050505050565b348015610def57600080fd5b5061023d60048036036040811015610e0657600080fd5b506001600160a01b03813581169160200135166130ce565b348015610e2a57600080fd5b506102596131b2565b348015610e3f57600080fd5b506102596131c1565b348015610e5457600080fd5b506102596131d0565b6009546001600160a01b031681565b336000908152600e602052604090205460ff16610ebe576040805162461bcd60e51b815260206004820152601a6024820152600080516020614ee9833981519152604482015290519081900360640190fd5b600d54604080516307c7edc360e01b81526001600160a01b038681166004830152602482018690528481166044830152915191909216916307c7edc391606480830192600092919082900301818387803b158015610f1b57600080fd5b505af1158015610f2f573d6000803e3d6000fd5b50505050505050565b600b6020526000908152604090205481565b336000908152600e602052604090205460ff16610f9c576040805162461bcd60e51b815260206004820152601a6024820152600080516020614ee9833981519152604482015290519081900360640190fd5b600354604080516312d43a5160e01b815290516001600160a01b039092169160009183916312d43a5191600480820192602092909190829003018186803b158015610fe657600080fd5b505afa158015610ffa573d6000803e3d6000fd5b505050506040513d602081101561101057600080fd5b5051600d5460408051630130197760e11b81526001600160a01b03898116600483015260248201899052915193945060009384938493849391169163026032ee9160448082019261010092909190829003018186803b15801561107257600080fd5b505afa158015611086573d6000803e3d6000fd5b505050506040513d61010081101561109d57600080fd5b508051604082015160608301516080909301519196509450909250905060008161113f57866001600160a01b031663e124e6d2856040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b50516111b9565b866001600160a01b03166381a612d6856040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561118c57600080fd5b505afa1580156111a0573d6000803e3d6000fd5b505050506040513d60208110156111b657600080fd5b50515b6004805460408051633cc8e33b60e21b81526001600160a01b038f8116948201949094528984166024820152888416604482015286151560648201526084810188905260a48101859052600060c482018190529151949550929091169263f3238cec9260e480820193929182900301818387803b15801561123957600080fd5b505af115801561124d573d6000803e3d6000fd5b50505050856001600160a01b0316636d63c1d0886040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b1580156112a057600080fd5b505af11580156112b4573d6000803e3d6000fd5b5050600d54604080516308eca22560e11b81526001600160a01b038f81166004830152602482018f90528d8116604483015291519190921693506311d9444a9250606480830192600092919082900301818387803b15801561131557600080fd5b505af1158015611329573d6000803e3d6000fd5b50505050856001600160a01b031663d3c87bbb886040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b15801561137c57600080fd5b505af1158015611390573d6000803e3d6000fd5b5050505061139e8a846131df565b50505050505050505050565b61271081565b6001546001600160a01b031681565b6002546001600160a01b0316331461140c576040805162461bcd60e51b815260206004820152601e6024820152600080516020614e28833981519152604482015290519081900360640190fd5b600d8054821515600160a81b810260ff60a81b199092169190911790915560408051918252517fa956222e37fe025ff51e5440ac729a9bd417ff91e485e14dcffa2c0ba8894f409181900360200190a150565b600a6020526000908152604090205481565b6002546001600160a01b031633146114be576040805162461bcd60e51b815260206004820152601e6024820152600080516020614e28833981519152604482015290519081900360640190fd5b6001600160a01b0382166000818152600e6020908152604091829020805460ff1916851515908117909155825190815291517f1d5bc0255b943d6a5b5279e8a55d74d620baccbceecb25e87a3558f14c4c118e9281900390910190a25050565b6002546001600160a01b0316331461156b576040805162461bcd60e51b815260206004820152601e6024820152600080516020614e28833981519152604482015290519081900360640190fd5b6001600160a01b0382166000818152600f6020908152604091829020805460ff191685151590811790915582519384529083015280517fa4e46c70ff429a91de7d1716d736e877c7cca1c22ac850b23d242530dd95e4749281900390910190a15050565b6002546001600160a01b0316331461161c576040805162461bcd60e51b815260206004820152601e6024820152600080516020614e28833981519152604482015290519081900360640190fd5b60088190556040805182815290517f21167d0d4661af93817ebce920f18986eed3d75d5e1c03f2aed05efcbafbc4529181900360200190a150565b6001546001600160a01b031633146116a4576040805162461bcd60e51b81526020600482015260156024820152600080516020614d4d833981519152604482015290519081900360640190fd5b6116b76001600160a01b03831682613368565b5050565b60026000541415611701576040805162461bcd60e51b815260206004820152601f6024820152600080516020614d2d833981519152604482015290519081900360640190fd5b60026000908155338152600f602052604090205460ff168061172c5750600d54600160a01b900460ff165b61176b576040805162461bcd60e51b815260206004820152601a6024820152600080516020614ee9833981519152604482015290519081900360640190fd5b87516002146117ab5760405162461bcd60e51b8152600401808060200182810382526025815260200180614fcf6025913960400191505060405180910390fd5b60065488516001600160a01b0390911690899060001981019081106117cc57fe5b60200260200101516001600160a01b03161461181d576040805162461bcd60e51b815260206004820152601e6024820152600080516020614e48833981519152604482015290519081900360640190fd5b6000611843338a60008151811061183057fe5b60200260200101518a8a8a8a308a613452565b905061188c600360009054906101000a90046001600160a01b0316828b60008151811061186c57fe5b60200260200101516001600160a01b03166138eb9092919063ffffffff16565b60006118998a843061393d565b90506118a581866139c2565b505060016000555050505050505050565b600e6020526000908152604090205460ff1681565b6006546001600160a01b031681565b60026000541415611920576040805162461bcd60e51b815260206004820152601f6024820152600080516020614d2d833981519152604482015290519081900360640190fd5b60026000908155338152600f602052604090205460ff168061194b5750600d54600160a01b900460ff165b61198a576040805162461bcd60e51b815260206004820152601a6024820152600080516020614ee9833981519152604482015290519081900360640190fd5b6006546001600160a01b038881169116146119d65760405162461bcd60e51b8152600401808060200182810382526029815260200180614f596029913960400191505060405180910390fd5b60006119e83389898989893089613452565b90506119f481846139c2565b50506001600055505050505050565b6002546001600160a01b03163314611a50576040805162461bcd60e51b815260206004820152601e6024820152600080516020614e28833981519152604482015290519081900360640190fd5b6001600160a01b038216600081815260106020908152604091829020805460ff1916851515908117909155825190815291517f8c0d56805c3b43d441481229dc64bee168253ffe4305f37ab7cfe63b1c4268c69281900390910190a25050565b600d54600160a81b900460ff1681565b6002546001600160a01b03163314611b0d576040805162461bcd60e51b815260206004820152601e6024820152600080516020614e28833981519152604482015290519081900360640190fd5b60078190556040805182815290517f974fd3c1fcb4653dfc4fb740c4c692cd212d55c28f163f310128cb64d83006759181900360200190a150565b60106020526000908152604090205460ff1681565b60026000541415611ba3576040805162461bcd60e51b815260206004820152601f6024820152600080516020614d2d833981519152604482015290519081900360640190fd5b60026000908155338152600f602052604090205460ff1680611bce5750600d54600160a01b900460ff165b611c0d576040805162461bcd60e51b815260206004820152601a6024820152600080516020614ee9833981519152604482015290519081900360640190fd5b8751600214611c4d5760405162461bcd60e51b8152600401808060200182810382526025815260200180614fcf6025913960400191505060405180910390fd5b6000611c60338a60008151811061183057fe5b9050611c89600360009054906101000a90046001600160a01b0316828b60008151811061186c57fe5b6118a589838661393d565b6004546001600160a01b031681565b60075481565b6001546001600160a01b03163314611cf6576040805162461bcd60e51b81526020600482015260156024820152600080516020614d4d833981519152604482015290519081900360640190fd5b600280546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f5a272403b402d892977df56625f4164ccaf70ca3863991c43ecfe76a6905b0a19181900360200190a150565b600d546001600160a01b031681565b600f6020526000908152604090205460ff1681565b60026000541415611db4576040805162461bcd60e51b815260206004820152601f6024820152600080516020614d2d833981519152604482015290519081900360640190fd5b60026000908155338152600f602052604090205460ff1680611ddf5750600d54600160a01b900460ff165b611e1e576040805162461bcd60e51b815260206004820152601a6024820152600080516020614ee9833981519152604482015290519081900360640190fd5b6119f43388888888888888613452565b600c6020526000908152604090205481565b60085481565b6002546001600160a01b03163314611e93576040805162461bcd60e51b815260206004820152601e6024820152600080516020614e28833981519152604482015290519081900360640190fd5b600d8054821515600160a01b810260ff60a01b199092169190911790915560408051918252517feac6b3611e79ff0d8ea5daa8439f6b1ab7eea4ebf95f1dd360417f712c3fc3049181900360200190a150565b6002546001600160a01b03163314611f33576040805162461bcd60e51b815260206004820152601e6024820152600080516020614e28833981519152604482015290519081900360640190fd5b600980546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f828abcccea18192c21d645e575652c49e20b986dab777906fc473d056b01b6a89181900360200190a150565b60026000541415611fcd576040805162461bcd60e51b815260206004820152601f6024820152600080516020614d2d833981519152604482015290519081900360640190fd5b60026000908155338152600f602052604090205460ff1680611ff85750600d54600160a01b900460ff165b612037576040805162461bcd60e51b815260206004820152601a6024820152600080516020614ee9833981519152604482015290519081900360640190fd5b855160011480612048575085516002145b6120835760405162461bcd60e51b8152600401808060200182810382526025815260200180614fcf6025913960400191505060405180910390fd5b60065486516001600160a01b0390911690879060009061209f57fe5b60200260200101516001600160a01b0316146120f0576040805162461bcd60e51b815260206004820152601e6024820152600080516020614e48833981519152604482015290519081900360640190fd5b3415612174576120fe613a50565b855134906001101561213557600354600654612127916001600160a01b039182169116346138eb565b61213287863061393d565b90505b60006121453389848a888a613abc565b9050612171600360009054906101000a90046001600160a01b0316828a60018c51038151811061186c57fe5b50505b612199338760018951038151811061218857fe5b602002602001015187868686613b9b565b5050600160005550505050565b600260005414156121ec576040805162461bcd60e51b815260206004820152601f6024820152600080516020614d2d833981519152604482015290519081900360640190fd5b60026000908155338152600f602052604090205460ff16806122175750600d54600160a01b900460ff165b612256576040805162461bcd60e51b815260206004820152601a6024820152600080516020614ee9833981519152604482015290519081900360640190fd5b865160011480612267575086516002145b6122a25760405162461bcd60e51b8152600401808060200182810382526025815260200180614fcf6025913960400191505060405180910390fd5b8415612452578651600114156123625760055487516001600160a01b0390911690631b8278789089906000906122d457fe5b60200260200101513330896040518563ffffffff1660e01b815260040180856001600160a01b03168152602001846001600160a01b03168152602001836001600160a01b03168152602001828152602001945050505050600060405180830381600087803b15801561234557600080fd5b505af1158015612359573d6000803e3d6000fd5b50505050612414565b60055487516001600160a01b0390911690631b82787890899060009061238457fe5b6020908102919091010151600354604080516001600160e01b031960e086901b1681526001600160a01b0393841660048201523360248201529290911660448301526064820189905251608480830192600092919082900301818387803b1580156123ee57600080fd5b505af1158015612402573d6000803e3d6000fd5b5050505061241187853061393d565b94505b60006124243389888a8789613abc565b9050612450600360009054906101000a90046001600160a01b0316828a60018c51038151811061186c57fe5b505b612477338860018a51038151811061246657fe5b602002602001015188868686613b9b565b505060016000555050505050565b6001546001600160a01b031633146124d2576040805162461bcd60e51b81526020600482015260156024820152600080516020614d4d833981519152604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b336000908152600e602052604090205460ff16612546576040805162461bcd60e51b815260206004820152601a6024820152600080516020614ee9833981519152604482015290519081900360640190fd5b6125508383613fa3565b600354604080516312d43a5160e01b815290516001600160a01b039092169160009183916312d43a5191600480820192602092909190829003018186803b15801561259a57600080fd5b505afa1580156125ae573d6000803e3d6000fd5b505050506040513d60208110156125c457600080fd5b5051600d546040805163d3bab1d160e01b81526001600160a01b03898116600483015260248201899052915193945060009384938493849391169163d3bab1d19160448082019261012092909190829003018186803b15801561262657600080fd5b505afa15801561263a573d6000803e3d6000fd5b505050506040513d61012081101561265157600080fd5b5060408101516060820151608083015160a090930151919650945090925090506000816126f657866001600160a01b03166381a612d6856040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156126c557600080fd5b505afa1580156126d9573d6000803e3d6000fd5b505050506040513d60208110156126ef57600080fd5b5051612770565b866001600160a01b031663e124e6d2856040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561274357600080fd5b505afa158015612757573d6000803e3d6000fd5b505050506040513d602081101561276d57600080fd5b50515b6004805460408051633cc8e33b60e21b81526001600160a01b038f8116948201949094528984166024820152888416604482015286151560648201526084810188905260a48101859052600160c4820152905193945091169163f3238cec9160e48082019260009290919082900301818387803b1580156127f057600080fd5b505af1158015612804573d6000803e3d6000fd5b50505050856001600160a01b0316636d63c1d0886040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b15801561285757600080fd5b505af115801561286b573d6000803e3d6000fd5b5050600d546040805163d38ab51960e01b81526001600160a01b038f81166004830152602482018f90528d81166044830152915191909216935063d38ab5199250606480830192600092919082900301818387803b1580156128cc57600080fd5b505af11580156128e0573d6000803e3d6000fd5b50505050856001600160a01b031663d3c87bbb886040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b15801561293357600080fd5b505af1158015612947573d6000803e3d6000fd5b5050505061139e8a846142c6565b600d54600160a01b900460ff1681565b600260005414156129ab576040805162461bcd60e51b815260206004820152601f6024820152600080516020614d2d833981519152604482015290519081900360640190fd5b600260009081553381526010602052604090205460ff16612a01576040805162461bcd60e51b815260206004820152601a6024820152600080516020614ee9833981519152604482015290519081900360640190fd5b600354604080516312d43a5160e01b815290516001600160a01b039092169160009183916312d43a5191600480820192602092909190829003018186803b158015612a4b57600080fd5b505afa158015612a5f573d6000803e3d6000fd5b505050506040513d6020811015612a7557600080fd5b505160035460408051634a3f088d60e01b81526001600160a01b038b811660048301528a811660248301528981166044830152881515606483015291519394506000939190921691634a3f088d91608480830192610100929190829003018186803b158015612ae357600080fd5b505afa158015612af7573d6000803e3d6000fd5b505050506040513d610100811015612b0e57600080fd5b50519050600085612b9757836001600160a01b031663e124e6d2886040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612b6657600080fd5b505afa158015612b7a573d6000803e3d6000fd5b505050506040513d6020811015612b9057600080fd5b5051612c11565b836001600160a01b03166381a612d6886040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612be457600080fd5b505afa158015612bf8573d6000803e3d6000fd5b505050506040513d6020811015612c0e57600080fd5b50515b6004805460408051633cc8e33b60e21b81526001600160a01b038e8116948201949094528c841660248201528b841660448201528a151560648201526084810187905260a48101859052600060c482018190529151949550929091169263f3238cec9260e480820193929182900301818387803b158015612c9157600080fd5b505af1158015612ca5573d6000803e3d6000fd5b50505050826001600160a01b0316636d63c1d0856040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015612cf857600080fd5b505af1158015612d0c573d6000803e3d6000fd5b505060408051631bc5d52960e31b81526001600160a01b038d811660048301528c811660248301528b811660448301528a1515606483015289811660848301529151918816935063de2ea948925060a48082019260009290919082900301818387803b158015612d7b57600080fd5b505af1158015612d8f573d6000803e3d6000fd5b50505050826001600160a01b031663d3c87bbb856040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015612de257600080fd5b505af1158015612df6573d6000803e3d6000fd5b505060016000555050505050505050505050565b6001546001600160a01b03163314612e57576040805162461bcd60e51b81526020600482015260156024820152600080516020614d4d833981519152604482015290519081900360640190fd5b826001600160a01b031663095ea7b383836040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015612eae57600080fd5b505af1158015612ec2573d6000803e3d6000fd5b505050506040513d6020811015612ed857600080fd5b5050505050565b6002546001600160a01b03163314612f2c576040805162461bcd60e51b815260206004820152601e6024820152600080516020614e28833981519152604482015290519081900360640190fd5b60005b8351811015612fc7576000848281518110612f4657fe5b60200260200101519050838281518110612f5c57fe5b6020026020010151600b6000836001600160a01b03166001600160a01b0316815260200190815260200160002081905550828281518110612f9957fe5b6020908102919091018101516001600160a01b039092166000908152600c9091526040902055600101612f2f565b507fae32d569b058895b9620d6552b09aaffedc9a6f396be4d595a224ad09f8b213983838360405180806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b8381101561303457818101518382015260200161301c565b50505050905001848103835286818151815260200191508051906020019060200280838360005b8381101561307357818101518382015260200161305b565b50505050905001848103825285818151815260200191508051906020019060200280838360005b838110156130b257818101518382015260200161309a565b50505050905001965050505050505060405180910390a1505050565b6002546001600160a01b0316331461311b576040805162461bcd60e51b815260206004820152601e6024820152600080516020614e28833981519152604482015290519081900360640190fd5b6001600160a01b0382166000908152600a60205260409020548061313f57506116b7565b6001600160a01b0383166000818152600a60205260408120556131639083836138eb565b604080516001600160a01b0380861682528416602082015280820183905290517f4f1b51dd7a2fcb861aa2670f668be66835c4ee12b4bbbf037e4d0018f39819e49181900360600190a1505050565b6002546001600160a01b031681565b6005546001600160a01b031681565b6003546001600160a01b031681565b6009546001600160a01b0316806131f657506116b7565b600080826001600160a01b031663534ef883866040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b15801561324557600080fd5b505afa158015613259573d6000803e3d6000fd5b505050506040513d604081101561326f57600080fd5b50805160209091015190925090508161328a575050506116b7565b7f474c763ff84bf2c2039a6d9fea955ecd0f724030e3c365b91169c6a16fe751b78585600360009054906101000a90046001600160a01b03166001600160a01b031663318bc6896040518163ffffffff1660e01b815260040160206040518083038186803b1580156132fb57600080fd5b505afa15801561330f573d6000803e3d6000fd5b505050506040513d602081101561332557600080fd5b5051604080516001600160a01b03948516815260208101939093528281019190915260608201869052918416608082015290519081900360a00190a15050505050565b804710156133bd576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114613408576040519150601f19603f3d011682016040523d82523d6000602084013e61340d565b606091505b505090508061344d5760405162461bcd60e51b815260040180806020018281038252603a815260200180614d98603a913960400191505060405180910390fd5b505050565b6003546000906001600160a01b031681856134e557816001600160a01b031663e124e6d28a6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156134b457600080fd5b505afa1580156134c8573d6000803e3d6000fd5b505050506040513d60208110156134de57600080fd5b505161355f565b816001600160a01b03166381a612d68a6040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561353257600080fd5b505afa158015613546573d6000803e3d6000fd5b505050506040513d602081101561355c57600080fd5b50515b905085156135ab57838110156135a65760405162461bcd60e51b8152600401808060200182810382526030815260200180614df86030913960400191505060405180910390fd5b6135ea565b838111156135ea5760405162461bcd60e51b8152600401808060200182810382526031815260200180614eb86031913960400191505060405180910390fd5b6000826001600160a01b03166312d43a516040518163ffffffff1660e01b815260040160206040518083038186803b15801561362557600080fd5b505afa158015613639573d6000803e3d6000fd5b505050506040513d602081101561364f57600080fd5b81019080805190602001909291905050509050600460009054906101000a90046001600160a01b03166001600160a01b031663f3238cec8d8d8d8b8d8860006040518863ffffffff1660e01b815260040180886001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b0316815260200185151581526020018481526020018381526020018215158152602001975050505050505050600060405180830381600087803b15801561370d57600080fd5b505af1158015613721573d6000803e3d6000fd5b50505050806001600160a01b0316636d63c1d0846040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b15801561377457600080fd5b505af1158015613788573d6000803e3d6000fd5b505050506000600560009054906101000a90046001600160a01b03166001600160a01b0316632662166b8e8e8e8e8e8e8e6040518863ffffffff1660e01b815260040180886001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b031681526020018581526020018481526020018315158152602001826001600160a01b03168152602001975050505050505050602060405180830381600087803b15801561383f57600080fd5b505af1158015613853573d6000803e3d6000fd5b505050506040513d602081101561386957600080fd5b50516040805163d3c87bbb60e01b81526001600160a01b03878116600483015291519293509084169163d3c87bbb9160248082019260009290919082900301818387803b1580156138b957600080fd5b505af11580156138cd573d6000803e3d6000fd5b505050506138db8d8a6131df565b9c9b505050505050505050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261344d9084906143cc565b60008351600214156139845761397d8460008151811061395957fe5b60200260200101518560018151811061396e57fe5b6020026020010151858561447d565b90506139bb565b60405162461bcd60e51b8152600401808060200182810382526029815260200180614f306029913960400191505060405180910390fd5b9392505050565b60065460408051632e1a7d4d60e01b81526004810185905290516001600160a01b0390921691632e1a7d4d9160248082019260009290919082900301818387803b158015613a0f57600080fd5b505af1158015613a23573d6000803e3d6000fd5b50506040516001600160a01b038416925084156108fc02915084906000818181858888f150505050505050565b3415613aba57600660009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015613aa657600080fd5b505af1158015612ed8573d6000803e3d6000fd5b565b600080613acd888888888888614553565b90508015613b8c576000613b04612710613afe613af760075461271061473090919063ffffffff16565b8a9061477b565b906147d4565b90506000613b128883614730565b905060008960018b510381518110613b2657fe5b60200260200101519050613b6882600a6000846001600160a01b03166001600160a01b031681526020019081526020016000205461481390919063ffffffff16565b6001600160a01b039091166000908152600a6020526040902055509150613b919050565b859150505b9695505050505050565b6003546001600160a01b0316600083613c2c57816001600160a01b03166381a612d6876040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613bfb57600080fd5b505afa158015613c0f573d6000803e3d6000fd5b505050506040513d6020811015613c2557600080fd5b5051613ca6565b816001600160a01b031663e124e6d2876040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613c7957600080fd5b505afa158015613c8d573d6000803e3d6000fd5b505050506040513d6020811015613ca357600080fd5b50515b90508315613cf25782811115613ced5760405162461bcd60e51b8152600401808060200182810382526031815260200180614eb86031913960400191505060405180910390fd5b613d31565b82811015613d315760405162461bcd60e51b8152600401808060200182810382526030815260200180614df86030913960400191505060405180910390fd5b613d3c86858761486b565b6000826001600160a01b03166312d43a516040518163ffffffff1660e01b815260040160206040518083038186803b158015613d7757600080fd5b505afa158015613d8b573d6000803e3d6000fd5b505050506040513d6020811015613da157600080fd5b50516004805460408051633cc8e33b60e21b81526001600160a01b038e8116948201949094528c841660248201528b841660448201528915156064820152608481018b905260a48101879052600160c4820152905193945091169163f3238cec9160e48082019260009290919082900301818387803b158015613e2357600080fd5b505af1158015613e37573d6000803e3d6000fd5b50505050806001600160a01b0316636d63c1d0846040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015613e8a57600080fd5b505af1158015613e9e573d6000803e3d6000fd5b505060055460408051630f8ee8bb60e11b81526001600160a01b038e811660048301528d811660248301528c81166044830152606482018c90528a151560848301529151919092169350631f1dd176925060a480830192600092919082900301818387803b158015613f0f57600080fd5b505af1158015613f23573d6000803e3d6000fd5b50505050806001600160a01b031663d3c87bbb846040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b158015613f7657600080fd5b505af1158015613f8a573d6000803e3d6000fd5b50505050613f9889876142c6565b505050505050505050565b600d546040805163d3bab1d160e01b81526001600160a01b03858116600483015260248201859052915160009384938493849384938493169163d3bab1d191604480830192610120929190829003018186803b15801561400257600080fd5b505afa158015614016573d6000803e3d6000fd5b505050506040513d61012081101561402d57600080fd5b508051602082015160408301516060840151608085015160a090950151939a5091985096509450909250905061406483828461486b565b600d54600160a81b900460ff16614080575050505050506116b7565b80614090575050505050506116b7565b600082116140e5576040805162461bcd60e51b815260206004820152601d60248201527f506f736974696f6e4d616e616765723a206c6f6e67206465706f736974000000604482015290519081900360640190fd5b60035460408051634a3f088d60e01b81526001600160a01b038b811660048301528781166024830152868116604483015284151560648301529151919092169160009182918491634a3f088d9160848082019261010092909190829003018186803b15801561415357600080fd5b505afa158015614167573d6000803e3d6000fd5b505050506040513d61010081101561417e57600080fd5b50805160209091015190925090508161419f575050505050505050506116b7565b60006141ab8387614813565b90506000846001600160a01b0316630a48d5a98c8c6040518363ffffffff1660e01b815260040180836001600160a01b031681526020018281526020019250505060206040518083038186803b15801561420457600080fd5b505afa158015614218573d6000803e3d6000fd5b505050506040513d602081101561422e57600080fd5b50519050600061423e8483614813565b9050600061425285613afe8861271061477b565b9050600061427383613afe600854612710018861477b90919063ffffffff16565b9050818110156142b45760405162461bcd60e51b8152600401808060200182810382526027815260200180614f096027913960400191505060405180910390fd5b50505050505050505050505050505050565b6009546001600160a01b0316806142dd57506116b7565b600080826001600160a01b031663534ef883866040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050604080518083038186803b15801561432c57600080fd5b505afa158015614340573d6000803e3d6000fd5b505050506040513d604081101561435657600080fd5b5080516020918201516003546040805163318bc68960e01b815290519396509194507fc2414023ce7002ee98557d1e7be21e5559073336f2217ee5f9b2e50fd85f71ee93899389936001600160a01b039093169263318bc689926004808301939192829003018186803b1580156132fb57600080fd5b6060614421826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614a239092919063ffffffff16565b80519091501561344d5780806020019051602081101561444057600080fd5b505161344d5760405162461bcd60e51b815260040180806020018281038252602a815260200180614fa5602a913960400191505060405180910390fd5b60035460408051634998b10960e11b81526001600160a01b03878116600483015286811660248301528481166044830152915160009384931691639331621291606480830192602092919082900301818787803b1580156144dd57600080fd5b505af11580156144f1573d6000803e3d6000fd5b505050506040513d602081101561450757600080fd5b505190508381101561454a5760405162461bcd60e51b815260040180806020018281038252602b815260200180614d6d602b913960400191505060405180910390fd5b95945050505050565b60008261456257506000613b91565b8161456f57506001613b91565b60008660018851038151811061458157fe5b602090810291909101015160035460408051634a3f088d60e01b81526001600160a01b038c81166004830152808516602483015289811660448301528815156064830152915193945091169160009182918491634a3f088d91608480830192610100929190829003018186803b1580156145fa57600080fd5b505afa15801561460e573d6000803e3d6000fd5b505050506040513d61010081101561462557600080fd5b508051602090910151909250905081614645576000945050505050613b91565b60006146518388614813565b90506000846001600160a01b0316630a48d5a9878d6040518363ffffffff1660e01b815260040180836001600160a01b031681526020018281526020019250505060206040518083038186803b1580156146aa57600080fd5b505afa1580156146be573d6000803e3d6000fd5b505050506040513d60208110156146d457600080fd5b5051905060006146e48483614813565b905060006146f885613afe8861271061477b565b9050600061471983613afe600854612710018861477b90919063ffffffff16565b919091109f9e505050505050505050505050505050565b600061477283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614a3a565b90505b92915050565b60008261478a57506000614775565b8282028284828161479757fe5b04146147725760405162461bcd60e51b8152600401808060200182810382526021815260200180614e976021913960400191505060405180910390fd5b600061477283836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b815250614ad1565b600082820183811015614772576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b806148755761344d565b8115614968576001600160a01b0383166000908152600b6020526040902054801580159061492657506003546040805163783a2b6760e11b81526001600160a01b0387811660048301529151849361492493879391169163f07456ce91602480820192602092909190829003018186803b1580156148f257600080fd5b505afa158015614906573d6000803e3d6000fd5b505050506040513d602081101561491c57600080fd5b505190614813565b115b156149625760405162461bcd60e51b815260040180806020018281038252602e815260200180614cff602e913960400191505060405180910390fd5b5061344d565b6001600160a01b0383166000908152600c602052604090205480158015906149e157506003546040805163114f1b5560e31b81526001600160a01b038781166004830152915184936149df938793911691638a78daa891602480820192602092909190829003018186803b1580156148f257600080fd5b115b15614a1d5760405162461bcd60e51b815260040180806020018281038252602f815260200180614e68602f913960400191505060405180910390fd5b50505050565b6060614a328484600085614b36565b949350505050565b60008184841115614ac95760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614a8e578181015183820152602001614a76565b50505050905090810190601f168015614abb5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008183614b205760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315614a8e578181015183820152602001614a76565b506000838581614b2c57fe5b0495945050505050565b606082471015614b775760405162461bcd60e51b8152600401808060200182810382526026815260200180614dd26026913960400191505060405180910390fd5b614b8085614c92565b614bd1576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310614c105780518252601f199092019160209182019101614bf1565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614c72576040519150601f19603f3d011682016040523d82523d6000602084013e614c77565b606091505b5091509150614c87828286614c98565b979650505050505050565b3b151590565b60608315614ca75750816139bb565b825115614cb75782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315614a8e578181015183820152602001614a7656fe42617365506f736974696f6e4d616e616765723a206d617820676c6f62616c206c6f6e67732065786365656465645265656e7472616e637947756172643a207265656e7472616e742063616c6c00476f7665726e61626c653a20666f7262696464656e000000000000000000000042617365506f736974696f6e4d616e616765723a20696e73756666696369656e7420616d6f756e744f7574416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d61792068617665207265766572746564416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c42617365506f736974696f6e4d616e616765723a206d61726b207072696365206c6f776572207468616e206c696d697442617365506f736974696f6e4d616e616765723a20666f7262696464656e0000506f736974696f6e4d616e616765723a20696e76616c6964205f70617468000042617365506f736974696f6e4d616e616765723a206d617820676c6f62616c2073686f727473206578636565646564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7742617365506f736974696f6e4d616e616765723a206d61726b20707269636520686967686572207468616e206c696d6974506f736974696f6e4d616e616765723a20666f7262696464656e000000000000506f736974696f6e4d616e616765723a206c6f6e67206c6576657261676520646563726561736542617365506f736974696f6e4d616e616765723a20696e76616c6964205f706174682e6c656e677468506f736974696f6e4d616e616765723a20696e76616c6964205f636f6c6c61746572616c546f6b656e42617365506f736974696f6e4d616e616765723a20696e76616c69642073656e6465725361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564506f736974696f6e4d616e616765723a20696e76616c6964205f706174682e6c656e677468a2646970667358221220762deecbafb0f96a51aca7e6e6c7c69443acfea61ae143a9aa7ecf60aba396ac64736f6c634300060c00330000000000000000000000009ab2de34a33fb459b538c43f251eb825645e85950000000000000000000000005f719c2f1095f7b9fc68a68e35b51194f4b6abe80000000000000000000000009234252975484d75fd05f3e4f7bdbec61956d73a000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000004296e307f108b2f583ff2f7b7270ee7831574ae5

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

0000000000000000000000009ab2de34a33fb459b538c43f251eb825645e85950000000000000000000000005f719c2f1095f7b9fc68a68e35b51194f4b6abe80000000000000000000000009234252975484d75fd05f3e4f7bdbec61956d73a000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000004296e307f108b2f583ff2f7b7270ee7831574ae5

-----Decoded View---------------
Arg [0] : _vault (address): 0x9ab2de34a33fb459b538c43f251eb825645e8595
Arg [1] : _router (address): 0x5f719c2f1095f7b9fc68a68e35b51194f4b6abe8
Arg [2] : _shortsTracker (address): 0x9234252975484d75fd05f3e4f7bdbec61956d73a
Arg [3] : _weth (address): 0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7
Arg [4] : _depositFee (uint256): 30
Arg [5] : _orderBook (address): 0x4296e307f108b2f583ff2f7b7270ee7831574ae5

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000009ab2de34a33fb459b538c43f251eb825645e8595
Arg [1] : 0000000000000000000000005f719c2f1095f7b9fc68a68e35b51194f4b6abe8
Arg [2] : 0000000000000000000000009234252975484d75fd05f3e4f7bdbec61956d73a
Arg [3] : 000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c7
Arg [4] : 000000000000000000000000000000000000000000000000000000000000001e
Arg [5] : 0000000000000000000000004296e307f108b2f583ff2f7b7270ee7831574ae5


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.