Contract 0x7EF6f8abAc00689e057C9ec14E34aC232255a2fb 8

 
Txn Hash Method
Block
From
To
Value
0x5ec499e09deebc2c631aea1acd6dc58094c077b86fd21885af417cea133c7b4aSet Gov1035524102023-06-01 11:42:27272 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001069505590.001
0x84d25efa2dabc4bfb39f9b0bf32bd10b29b145841daebda62c6ab4792f10c8b4Set Token Config1035512872023-06-01 11:37:40272 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001414034960.001
0xcad7185ca750cab24581f734b40200e0c59905325e96b27cd1100b7180dd8576Set Token Config1035512232023-06-01 11:37:25272 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001476374310.001
0xeb1c290988b2c5dc13bf7fba2e2885aca001954f870852e92e8352e1fe1d1192Set Token Config1035511562023-06-01 11:36:54272 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001469447470.001
0x474b3ae1bb7fbedb5991565c6edd98c91af34575453b69fc90490faea083cb19Set Token Config1035510822023-06-01 11:36:39272 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001476374310.001
0xc78c9faf8875f4ec9121f31af1be9501c0057d53506de9fee2e282e50c7cce32Set Token Config1035510102023-06-01 11:36:24272 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001414118960.001
0x0a0b6c9144c1fd064d6546a1695dd65a02e58362af9c969e32fdd1479d8ce8f5Set Token Config1035509252023-06-01 11:35:54272 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001476460530.001
0x140b99eb36e373bc4589d14f5441093237be667b8972fa301643057e22c11946Clear Token Conf...1035508952023-06-01 11:35:54272 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.000119870930.001
0x1262b23d8732c347b0dbc108785723d7c880385a1bbcf866ae5d854de88dbf79Set Token Config1028952102023-05-30 11:44:10274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001875353310.001
0xd01bcc2debed8e06e45276820905e4472cdf43839b4192c8a1d4c6366e511f35Set Token Config1028951372023-05-30 11:43:55274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001796325330.001
0x90a7587a53c55cf5cb3c678ee8f70e6224488eb6530e3e7690ba63ae99978cd2Set Token Config1028950552023-05-30 11:43:40274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.000187547060.001
0x704d07015c0f9666b091c10637ac7d2652027cb7f72d310fc838ea0ffbb76bfcSet Token Config1028949782023-05-30 11:43:25274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001866676380.001
0x35786eb6c1e5ca2c31f809cb79722939b67903dfe13172c7754e3376d4e25a95Set Token Config1028948992023-05-30 11:42:55274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001875470710.001
0x96f33a98d41dcc9ce8b38eaef170a25c474e74beed80d6712098b46a01e67eafSet Token Config1028948022023-05-30 11:42:40274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001791928220.001
0x8bd054621daa6059bf5ee26215e1bf957e33f51ae74707f510b5cb7cb920ef51Set Token Config1028947152023-05-30 11:42:25274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001871589170.001
0xb98ffe4d4f40357ca87f06f2b2ce9e0a7ef4fd8a29e3d28ad9666b88ee11d559Set Liquidator1028924552023-05-30 11:33:25274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001789414190.001
0x85e0a447690bd878b4ee925f2f044062c79d404c9258d462bc0a64b9651cb029Set Manager1028924222023-05-30 11:33:10274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001789216070.001
0x8b8e4fc65a2778ebdebed902dd6f3e873753058921647a5a205eb382253647e3Set Vault Utils1028923962023-05-30 11:33:10274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001724220170.001
0x157e762c515a585e6b44b64454a67af07ccf1574e6e146fa410e0fbcd1eab26fSet Error Contro...1028923662023-05-30 11:32:55274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001724390840.001
0x2d5a02e568db7b84cc03cd36f17bca63e7e4457df8e3053b9e6e4cbee91167d8Set Fees1028923312023-05-30 11:32:40274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0002178361790.001
0x2cad4cc8ce63527300de948a9c42bc12cbc49d18be834d7d9a6b2754c5e2ab1aSet Manager1028922962023-05-30 11:32:40274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001789415070.001
0x369ca3f3024c933e9ae27db2a91f5b436944932403bf0e71e337ae2e3343c593Set In Manager M...1028922582023-05-30 11:32:25274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.000162918560.001
0x54c9f215ceff6906b97b715a0d56f6315501a77fd7b15c7871decb2a296111b8Set Funding Rate1028922342023-05-30 11:32:25274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0001764280940.001
0xa7375fa7724b20a4530bb3e5ad32fa3ca05d43270ea2bdcbeae0499e4382f7cdInitialize1028922022023-05-30 11:32:10274 days 19 hrs agoMinerva Money: Deployer IN  Minerva Money: Vault0 ETH0.0002260746410.001
0x0e3f4876adcd327335ba7c4915a7e73404c0e81b475de67afdb1f0acd84bdd520x608060401007960742023-05-23 14:42:58281 days 16 hrs agoMinerva Money: Deployer IN  Create: Vault0 ETH0.0220505295190.001
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: VaultWrapped Ether0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: VaultWrapped Ether0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault Minerva Money: Vault Price Feed0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault 0x6cdc00a448fb093575f82279c85fc99db00a74a40 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault Utils Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault Utils Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault Utils Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault Utils Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault Utils Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault Minerva Money: Vault Utils0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault 0x6cdc00a448fb093575f82279c85fc99db00a74a40 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault 0x6cdc00a448fb093575f82279c85fc99db00a74a40 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault Minerva Money: Vault Price Feed0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault Minerva Money: Vault Utils0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault 0x6cdc00a448fb093575f82279c85fc99db00a74a40 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Mlp Manager Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Mlp Manager Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Mlp Manager Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Mlp Manager Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Mlp Manager Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Mlp Manager Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Mlp Manager Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Mlp Manager Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Mlp Manager Minerva Money: Vault0 ETH
0x168100c92ef18c091d1c368cb2fddbb6a696de51b9589e8a92d3ca8528a3bbac1069676072023-07-16 18:59:51227 days 11 hrs ago Minerva Money: Vault Minerva Money: Vault Price Feed0 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Vault

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 50 runs

Other Settings:
default evmVersion
File 1 of 10 : 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 usdm() 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 getTargetUsdmAmount(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 setUsdmAmount(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 _maxUsdmAmount,
        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 buyUSDM(address _token, address _receiver) external returns (uint256);

    function sellUSDM(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 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 _usdmDelta,
        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 usdmAmounts(address _token) external view returns (uint256);

    function maxUsdmAmounts(address _token) external view returns (uint256);

    function getRedemptionAmount(address _token, uint256 _usdmAmount) 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 2 of 10 : IVaultPriceFeed.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IVaultPriceFeed {
    function adjustmentBasisPoints(address _token)
        external
        view
        returns (uint256);

    function isAdjustmentAdditive(address _token) external view returns (bool);

    function setAdjustment(
        address _token,
        bool _isAdditive,
        uint256 _adjustmentBps
    ) external;

    function setIsSecondaryPriceEnabled(bool _isEnabled) external;

    function setSpreadBasisPoints(address _token, uint256 _spreadBasisPoints)
        external;

    function setSpreadThresholdBasisPoints(uint256 _spreadThresholdBasisPoints)
        external;

    function setFavorPrimaryPrice(bool _favorPrimaryPrice) external;

    function setPriceSampleSpace(uint256 _priceSampleSpace) external;

    function setMaxStrictPriceDeviation(uint256 _maxStrictPriceDeviation)
        external;

    function getPrice(
        address _token,
        bool _maximise,
        bool _includeAmmPrice,
        bool _useSwapPricing
    ) external view returns (uint256);

    function getPrimaryPrice(address _token, bool _maximise)
        external
        view
        returns (uint256);

    function setTokenConfig(
        address _token,
        address _priceFeed,
        uint256 _priceDecimals,
        bool _isStrictStable
    ) external;

    function getLatestPrimaryPrice(address _token) external view returns (uint256);


}

File 3 of 10 : 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 getBuyUsdmFeeBasisPoints(address _token, uint256 _usdmAmount)
        external
        view
        returns (uint256);

    function getSellUsdmFeeBasisPoints(address _token, uint256 _usdmAmount)
        external
        view
        returns (uint256);

    function getSwapFeeBasisPoints(
        address _tokenIn,
        address _tokenOut,
        uint256 _usdmAmount
    ) external view returns (uint256);

    function getFeeBasisPoints(
        address _token,
        uint256 _usdmDelta,
        uint256 _feeBasisPoints,
        uint256 _taxBasisPoints,
        bool _increment
    ) external view returns (uint256);
}

File 4 of 10 : Vault.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "../libraries/math/SafeMath.sol";
import "../libraries/token/IERC20.sol";
import "../libraries/token/SafeERC20.sol";
import "../libraries/utils/ReentrancyGuard.sol";

import "../tokens/interfaces/IUSDM.sol";
import "./interfaces/IVault.sol";
import "./interfaces/IVaultUtils.sol";
import "./interfaces/IVaultPriceFeed.sol";

contract Vault is ReentrancyGuard, IVault {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    struct Position {
        uint256 size;
        uint256 collateral;
        uint256 averagePrice;
        uint256 entryFundingRate;
        uint256 reserveAmount;
        int256 realisedPnl;
        uint256 lastIncreasedTime;
    }

    uint256 public constant BASIS_POINTS_DIVISOR = 10000;
    uint256 public constant FUNDING_RATE_PRECISION = 1000000;
    uint256 public constant PRICE_PRECISION = 10**30;
    uint256 public constant MIN_LEVERAGE = 10000; // 1x
    uint256 public constant USDM_DECIMALS = 18;
    uint256 public constant MAX_FEE_BASIS_POINTS = 500; // 5%
    uint256 public constant MAX_LIQUIDATION_FEE_USD = 100 * PRICE_PRECISION; // 100 USD
    uint256 public constant MIN_FUNDING_RATE_INTERVAL = 1 hours;
    uint256 public constant MAX_FUNDING_RATE_FACTOR = 10000; // 1%

    bool public override isInitialized;
    bool public override isSwapEnabled = true;
    bool public override isLeverageEnabled = true;

    IVaultUtils public vaultUtils;

    address public errorController;

    address public override router;
    address public override priceFeed;

    address public override usdm;
    address public override gov;

    uint256 public override whitelistedTokenCount;

    uint256 public override maxLeverage = 50 * 10000; // 50x

    uint256 public override liquidationFeeUsd;
    uint256 public override taxBasisPoints = 50; // 0.5%
    uint256 public override stableTaxBasisPoints = 20; // 0.2%
    uint256 public override mintBurnFeeBasisPoints = 30; // 0.3%
    uint256 public override swapFeeBasisPoints = 30; // 0.3%
    uint256 public override stableSwapFeeBasisPoints = 4; // 0.04%
    uint256 public override marginFeeBasisPoints = 10; // 0.1%

    uint256 public override minProfitTime;
    bool public override hasDynamicFees = false;

    uint256 public override fundingInterval = 8 hours;
    uint256 public override fundingRateFactor;
    uint256 public override stableFundingRateFactor;
    uint256 public override totalTokenWeights;

    bool public includeAmmPrice = true;
    bool public useSwapPricing = false;

    bool public override inManagerMode = false;
    bool public override inPrivateLiquidationMode = false;

    uint256 public override maxGasPrice;

    mapping(address => mapping(address => bool)) public override approvedRouters;
    mapping(address => bool) public override isLiquidator;
    mapping(address => bool) public override isManager;

    address[] public override allWhitelistedTokens;

    mapping(address => bool) public override whitelistedTokens;
    mapping(address => uint256) public override tokenDecimals;
    mapping(address => uint256) public override minProfitBasisPoints;
    mapping(address => bool) public override stableTokens;
    mapping(address => bool) public override shortableTokens;

    // tokenBalances is used only to determine _transferIn values
    mapping(address => uint256) public override tokenBalances;

    // tokenWeights allows customisation of index composition
    mapping(address => uint256) public override tokenWeights;

    // usdmAmounts tracks the amount of USDM debt for each whitelisted token
    mapping(address => uint256) public override usdmAmounts;

    // maxUsdmAmounts allows setting a max amount of USDM debt for a token
    mapping(address => uint256) public override maxUsdmAmounts;

    // poolAmounts tracks the number of received tokens that can be used for leverage
    // this is tracked separately from tokenBalances to exclude funds that are deposited as margin collateral
    mapping(address => uint256) public override poolAmounts;

    // reservedAmounts tracks the number of tokens reserved for open leverage positions
    mapping(address => uint256) public override reservedAmounts;

    // bufferAmounts allows specification of an amount to exclude from swaps
    // this can be used to ensure a certain amount of liquidity is available for leverage positions
    mapping(address => uint256) public override bufferAmounts;

    // guaranteedUsd tracks the amount of USD that is "guaranteed" by opened leverage positions
    // this value is used to calculate the redemption values for selling of USDM
    // this is an estimated amount, it is possible for the actual guaranteed value to be lower
    // in the case of sudden price decreases, the guaranteed value should be corrected
    // after liquidations are carried out
    mapping(address => uint256) public override guaranteedUsd;

    // cumulativeFundingRates tracks the funding rates based on utilization
    mapping(address => uint256) public override cumulativeFundingRates;
    // lastFundingTimes tracks the last time funding was updated for a token
    mapping(address => uint256) public override lastFundingTimes;

    // positions tracks all open positions
    mapping(bytes32 => Position) public positions;

    // feeReserves tracks the amount of fees per token
    mapping(address => uint256) public override feeReserves;

    mapping(address => uint256) public override globalShortSizes;
    mapping(address => uint256) public override globalShortAveragePrices;
    mapping(address => uint256) public override maxGlobalShortSizes;

    mapping(uint256 => string) public errors;

    event BuyUSDM(address account, address token, uint256 tokenAmount, uint256 usdmAmount, uint256 feeBasisPoints);
    event SellUSDM(address account, address token, uint256 usdmAmount, uint256 tokenAmount, uint256 feeBasisPoints);
    event Swap(address account, address tokenIn, address tokenOut, uint256 amountIn, uint256 amountOut, uint256 amountOutAfterFees, uint256 feeBasisPoints);

    event IncreasePosition(
        bytes32 key,
        address account,
        address collateralToken,
        address indexToken,
        uint256 collateralDelta,
        uint256 sizeDelta,
        bool isLong,
        uint256 price,
        uint256 fee
    );
    event DecreasePosition(
        bytes32 key,
        address account,
        address collateralToken,
        address indexToken,
        uint256 collateralDelta,
        uint256 sizeDelta,
        bool isLong,
        uint256 price,
        uint256 fee
    );
    event LiquidatePosition(
        bytes32 key,
        address account,
        address collateralToken,
        address indexToken,
        bool isLong,
        uint256 size,
        uint256 collateral,
        uint256 reserveAmount,
        int256 realisedPnl,
        uint256 markPrice
    );
    event UpdatePosition(
        bytes32 key,
        uint256 size,
        uint256 collateral,
        uint256 averagePrice,
        uint256 entryFundingRate,
        uint256 reserveAmount,
        int256 realisedPnl,
        uint256 markPrice
    );
    event ClosePosition(bytes32 key, uint256 size, uint256 collateral, uint256 averagePrice, uint256 entryFundingRate, uint256 reserveAmount, int256 realisedPnl);

    event UpdateFundingRate(address token, uint256 fundingRate);
    event UpdatePnl(bytes32 key, bool hasProfit, uint256 delta);

    event CollectSwapFees(address token, uint256 feeUsd, uint256 feeTokens);
    event CollectMarginFees(address token, uint256 feeUsd, uint256 feeTokens);

    event DirectPoolDeposit(address token, uint256 amount);
    event IncreasePoolAmount(address token, uint256 amount);
    event DecreasePoolAmount(address token, uint256 amount);
    event IncreaseUsdmAmount(address token, uint256 amount);
    event DecreaseUsdmAmount(address token, uint256 amount);
    event IncreaseReservedAmount(address token, uint256 amount);
    event DecreaseReservedAmount(address token, uint256 amount);
    event IncreaseGuaranteedUsd(address token, uint256 amount);
    event DecreaseGuaranteedUsd(address token, uint256 amount);

    // once the parameters are verified to be working correctly,
    // gov should be set to a timelock contract or a governance contract
    constructor() public {
        gov = msg.sender;
    }

    function initialize(
        address _router,
        address _usdm,
        address _priceFeed,
        uint256 _liquidationFeeUsd,
        uint256 _fundingRateFactor,
        uint256 _stableFundingRateFactor
    ) external {
        _onlyGov();
        _validate(!isInitialized, 1);
        isInitialized = true;

        router = _router;
        usdm = _usdm;
        priceFeed = _priceFeed;
        liquidationFeeUsd = _liquidationFeeUsd;
        fundingRateFactor = _fundingRateFactor;
        stableFundingRateFactor = _stableFundingRateFactor;
    }

    function setVaultUtils(IVaultUtils _vaultUtils) external override {
        _onlyGov();
        vaultUtils = _vaultUtils;
    }

    function setErrorController(address _errorController) external {
        _onlyGov();
        errorController = _errorController;
    }

    function setError(uint256 _errorCode, string calldata _error) external override {
        require(msg.sender == errorController, "Vault: invalid errorController");
        errors[_errorCode] = _error;
    }

    function allWhitelistedTokensLength() external view override returns (uint256) {
        return allWhitelistedTokens.length;
    }

    function setInManagerMode(bool _inManagerMode) external override {
        _onlyGov();
        inManagerMode = _inManagerMode;
    }

    function setManager(address _manager, bool _isManager) external override {
        _onlyGov();
        isManager[_manager] = _isManager;
    }

    function setInPrivateLiquidationMode(bool _inPrivateLiquidationMode) external override {
        _onlyGov();
        inPrivateLiquidationMode = _inPrivateLiquidationMode;
    }

    function setLiquidator(address _liquidator, bool _isActive) external override {
        _onlyGov();
        isLiquidator[_liquidator] = _isActive;
    }

    function setIsSwapEnabled(bool _isSwapEnabled) external override {
        _onlyGov();
        isSwapEnabled = _isSwapEnabled;
    }

    function setIsLeverageEnabled(bool _isLeverageEnabled) external override {
        _onlyGov();
        isLeverageEnabled = _isLeverageEnabled;
    }

    function setMaxGasPrice(uint256 _maxGasPrice) external override {
        _onlyGov();
        maxGasPrice = _maxGasPrice;
    }

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

    function setPriceFeed(address _priceFeed) external override {
        _onlyGov();
        priceFeed = _priceFeed;
    }

    function setMaxLeverage(uint256 _maxLeverage) external override {
        _onlyGov();
        _validate(_maxLeverage > MIN_LEVERAGE, 2);
        maxLeverage = _maxLeverage;
    }

    function setBufferAmount(address _token, uint256 _amount) external override {
        _onlyGov();
        bufferAmounts[_token] = _amount;
    }

    function setMaxGlobalShortSize(address _token, uint256 _amount) external override {
        _onlyGov();
        maxGlobalShortSizes[_token] = _amount;
    }

    function setFees(
        uint256 _taxBasisPoints,
        uint256 _stableTaxBasisPoints,
        uint256 _mintBurnFeeBasisPoints,
        uint256 _swapFeeBasisPoints,
        uint256 _stableSwapFeeBasisPoints,
        uint256 _marginFeeBasisPoints,
        uint256 _liquidationFeeUsd,
        uint256 _minProfitTime,
        bool _hasDynamicFees
    ) external override {
        _onlyGov();
        _validate(_taxBasisPoints <= MAX_FEE_BASIS_POINTS, 3);
        _validate(_stableTaxBasisPoints <= MAX_FEE_BASIS_POINTS, 4);
        _validate(_mintBurnFeeBasisPoints <= MAX_FEE_BASIS_POINTS, 5);
        _validate(_swapFeeBasisPoints <= MAX_FEE_BASIS_POINTS, 6);
        _validate(_stableSwapFeeBasisPoints <= MAX_FEE_BASIS_POINTS, 7);
        _validate(_marginFeeBasisPoints <= MAX_FEE_BASIS_POINTS, 8);
        _validate(_liquidationFeeUsd <= MAX_LIQUIDATION_FEE_USD, 9);
        taxBasisPoints = _taxBasisPoints;
        stableTaxBasisPoints = _stableTaxBasisPoints;
        mintBurnFeeBasisPoints = _mintBurnFeeBasisPoints;
        swapFeeBasisPoints = _swapFeeBasisPoints;
        stableSwapFeeBasisPoints = _stableSwapFeeBasisPoints;
        marginFeeBasisPoints = _marginFeeBasisPoints;
        liquidationFeeUsd = _liquidationFeeUsd;
        minProfitTime = _minProfitTime;
        hasDynamicFees = _hasDynamicFees;
    }

    function setFundingRate(
        uint256 _fundingInterval,
        uint256 _fundingRateFactor,
        uint256 _stableFundingRateFactor
    ) external override {
        _onlyGov();
        _validate(_fundingInterval >= MIN_FUNDING_RATE_INTERVAL, 10);
        _validate(_fundingRateFactor <= MAX_FUNDING_RATE_FACTOR, 11);
        _validate(_stableFundingRateFactor <= MAX_FUNDING_RATE_FACTOR, 12);
        fundingInterval = _fundingInterval;
        fundingRateFactor = _fundingRateFactor;
        stableFundingRateFactor = _stableFundingRateFactor;
    }

    function setTokenConfig(
        address _token,
        uint256 _tokenDecimals,
        uint256 _tokenWeight,
        uint256 _minProfitBps,
        uint256 _maxUsdmAmount,
        bool _isStable,
        bool _isShortable
    ) external override {
        _onlyGov();
        // increment token count for the first time
        if (!whitelistedTokens[_token]) {
            whitelistedTokenCount = whitelistedTokenCount.add(1);
            allWhitelistedTokens.push(_token);
        }

        uint256 _totalTokenWeights = totalTokenWeights;
        _totalTokenWeights = _totalTokenWeights.sub(tokenWeights[_token]);

        whitelistedTokens[_token] = true;
        tokenDecimals[_token] = _tokenDecimals;
        tokenWeights[_token] = _tokenWeight;
        minProfitBasisPoints[_token] = _minProfitBps;
        maxUsdmAmounts[_token] = _maxUsdmAmount;
        stableTokens[_token] = _isStable;
        shortableTokens[_token] = _isShortable;

        totalTokenWeights = _totalTokenWeights.add(_tokenWeight);

        // validate price feed
        getMaxPrice(_token);
    }

    function clearTokenConfig(address _token) external {
        _onlyGov();
        _validate(whitelistedTokens[_token], 13);
        totalTokenWeights = totalTokenWeights.sub(tokenWeights[_token]);
        delete whitelistedTokens[_token];
        delete tokenDecimals[_token];
        delete tokenWeights[_token];
        delete minProfitBasisPoints[_token];
        delete maxUsdmAmounts[_token];
        delete stableTokens[_token];
        delete shortableTokens[_token];
        whitelistedTokenCount = whitelistedTokenCount.sub(1);
    }

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

    function addRouter(address _router) external {
        approvedRouters[msg.sender][_router] = true;
    }

    function removeRouter(address _router) external {
        approvedRouters[msg.sender][_router] = false;
    }

    function setUsdmAmount(address _token, uint256 _amount) external override {
        _onlyGov();

        uint256 usdmAmount = usdmAmounts[_token];
        if (_amount > usdmAmount) {
            _increaseUsdmAmount(_token, _amount.sub(usdmAmount));
            return;
        }

        _decreaseUsdmAmount(_token, usdmAmount.sub(_amount));
    }

    // the governance controlling this function should have a timelock
    function upgradeVault(
        address _newVault,
        address _token,
        uint256 _amount
    ) external {
        _onlyGov();
        IERC20(_token).safeTransfer(_newVault, _amount);
    }

    // deposit into the pool without minting USDM tokens
    // useful in allowing the pool to become over-collaterised
    function directPoolDeposit(address _token) external override nonReentrant {
        _validate(whitelistedTokens[_token], 14);
        uint256 tokenAmount = _transferIn(_token);
        _validate(tokenAmount > 0, 15);
        _increasePoolAmount(_token, tokenAmount);
        emit DirectPoolDeposit(_token, tokenAmount);
    }

    function buyUSDM(address _token, address _receiver) external override nonReentrant returns (uint256) {
        _validateManager();
        _validate(whitelistedTokens[_token], 16);
        useSwapPricing = true;

        uint256 tokenAmount = _transferIn(_token);
        _validate(tokenAmount > 0, 17);

        updateCumulativeFundingRate(_token, _token);

        uint256 price = getMinPrice(_token);

        uint256 usdmAmount = tokenAmount.mul(price).div(PRICE_PRECISION);
        usdmAmount = adjustForDecimals(usdmAmount, _token, usdm);
        _validate(usdmAmount > 0, 18);

        uint256 feeBasisPoints = vaultUtils.getBuyUsdmFeeBasisPoints(_token, usdmAmount);
        uint256 amountAfterFees = _collectSwapFees(_token, tokenAmount, feeBasisPoints);
        uint256 mintAmount = amountAfterFees.mul(price).div(PRICE_PRECISION);
        mintAmount = adjustForDecimals(mintAmount, _token, usdm);

        _increaseUsdmAmount(_token, mintAmount);
        _increasePoolAmount(_token, amountAfterFees);

        IUSDM(usdm).mint(_receiver, mintAmount);

        emit BuyUSDM(_receiver, _token, tokenAmount, mintAmount, feeBasisPoints);

        useSwapPricing = false;
        return mintAmount;
    }

    function sellUSDM(address _token, address _receiver) external override nonReentrant returns (uint256) {
        _validateManager();
        _validate(whitelistedTokens[_token], 19);
        useSwapPricing = true;

        uint256 usdmAmount = _transferIn(usdm);
        _validate(usdmAmount > 0, 20);

        updateCumulativeFundingRate(_token, _token);

        uint256 redemptionAmount = getRedemptionAmount(_token, usdmAmount);
        _validate(redemptionAmount > 0, 21);

        _decreaseUsdmAmount(_token, usdmAmount);
        _decreasePoolAmount(_token, redemptionAmount);

        IUSDM(usdm).burn(address(this), usdmAmount);

        // the _transferIn call increased the value of tokenBalances[usdm]
        // usually decreases in token balances are synced by calling _transferOut
        // however, for usdm, the tokens are burnt, so _updateTokenBalance should
        // be manually called to record the decrease in tokens
        _updateTokenBalance(usdm);

        uint256 feeBasisPoints = vaultUtils.getSellUsdmFeeBasisPoints(_token, usdmAmount);
        uint256 amountOut = _collectSwapFees(_token, redemptionAmount, feeBasisPoints);
        _validate(amountOut > 0, 22);

        _transferOut(_token, amountOut, _receiver);

        emit SellUSDM(_receiver, _token, usdmAmount, amountOut, feeBasisPoints);

        useSwapPricing = false;
        return amountOut;
    }

    function swap(
        address _tokenIn,
        address _tokenOut,
        address _receiver
    ) external override nonReentrant returns (uint256) {
        _validate(isSwapEnabled, 23);
        _validate(whitelistedTokens[_tokenIn], 24);
        _validate(whitelistedTokens[_tokenOut], 25);
        _validate(_tokenIn != _tokenOut, 26);

        useSwapPricing = true;

        updateCumulativeFundingRate(_tokenIn, _tokenIn);
        updateCumulativeFundingRate(_tokenOut, _tokenOut);

        uint256 amountIn = _transferIn(_tokenIn);
        _validate(amountIn > 0, 27);

        uint256 priceIn = getMinPrice(_tokenIn);
        uint256 priceOut = getMaxPrice(_tokenOut);

        uint256 amountOut = amountIn.mul(priceIn).div(priceOut);
        amountOut = adjustForDecimals(amountOut, _tokenIn, _tokenOut);

        // adjust usdmAmounts by the same usdmAmount as debt is shifted between the assets
        uint256 usdmAmount = amountIn.mul(priceIn).div(PRICE_PRECISION);
        usdmAmount = adjustForDecimals(usdmAmount, _tokenIn, usdm);

        uint256 feeBasisPoints = vaultUtils.getSwapFeeBasisPoints(_tokenIn, _tokenOut, usdmAmount);
        uint256 amountOutAfterFees = _collectSwapFees(_tokenOut, amountOut, feeBasisPoints);

        _increaseUsdmAmount(_tokenIn, usdmAmount);
        _decreaseUsdmAmount(_tokenOut, usdmAmount);

        _increasePoolAmount(_tokenIn, amountIn);
        _decreasePoolAmount(_tokenOut, amountOut);

        _validateBufferAmount(_tokenOut);

        _transferOut(_tokenOut, amountOutAfterFees, _receiver);

        emit Swap(_receiver, _tokenIn, _tokenOut, amountIn, amountOut, amountOutAfterFees, feeBasisPoints);

        useSwapPricing = false;
        return amountOutAfterFees;
    }

    function increasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _sizeDelta,
        bool _isLong
    ) external override nonReentrant {
        _validate(isLeverageEnabled, 28);
        _validateGasPrice();
        _validateRouter(_account);
        _validateTokens(_collateralToken, _indexToken, _isLong);
        vaultUtils.validateIncreasePosition(_account, _collateralToken, _indexToken, _sizeDelta, _isLong);

        updateCumulativeFundingRate(_collateralToken, _indexToken);

        bytes32 key = getPositionKey(_account, _collateralToken, _indexToken, _isLong);
        Position storage position = positions[key];

        uint256 price = _isLong ? getMaxPrice(_indexToken) : getMinPrice(_indexToken);

        if (position.size == 0) {
            position.averagePrice = price;
        }

        if (position.size > 0 && _sizeDelta > 0) {
            position.averagePrice = getNextAveragePrice(_indexToken, position.size, position.averagePrice, _isLong, price, _sizeDelta, position.lastIncreasedTime);
        }

        uint256 fee = _collectMarginFees(_account, _collateralToken, _indexToken, _isLong, _sizeDelta, position.size, position.entryFundingRate);
        uint256 collateralDelta = _transferIn(_collateralToken);
        uint256 collateralDeltaUsd = tokenToUsdMin(_collateralToken, collateralDelta);

        position.collateral = position.collateral.add(collateralDeltaUsd);
        _validate(position.collateral >= fee, 29);

        position.collateral = position.collateral.sub(fee);
        position.entryFundingRate = getEntryFundingRate(_collateralToken, _indexToken, _isLong);
        position.size = position.size.add(_sizeDelta);
        position.lastIncreasedTime = block.timestamp;

        _validate(position.size > 0, 30);
        _validatePosition(position.size, position.collateral);
        validateLiquidation(_account, _collateralToken, _indexToken, _isLong, true);

        // reserve tokens to pay profits on the position
        uint256 reserveDelta = usdToTokenMax(_collateralToken, _sizeDelta);
        position.reserveAmount = position.reserveAmount.add(reserveDelta);
        _increaseReservedAmount(_collateralToken, reserveDelta);

        if (_isLong) {
            // guaranteedUsd stores the sum of (position.size - position.collateral) for all positions
            // if a fee is charged on the collateral then guaranteedUsd should be increased by that fee amount
            // since (position.size - position.collateral) would have increased by `fee`
            _increaseGuaranteedUsd(_collateralToken, _sizeDelta.add(fee));
            _decreaseGuaranteedUsd(_collateralToken, collateralDeltaUsd);
            // treat the deposited collateral as part of the pool
            _increasePoolAmount(_collateralToken, collateralDelta);
            // fees need to be deducted from the pool since fees are deducted from position.collateral
            // and collateral is treated as part of the pool
            _decreasePoolAmount(_collateralToken, usdToTokenMin(_collateralToken, fee));
        } else {
            if (globalShortSizes[_indexToken] == 0) {
                globalShortAveragePrices[_indexToken] = price;
            } else {
                globalShortAveragePrices[_indexToken] = getNextGlobalShortAveragePrice(_indexToken, price, _sizeDelta);
            }

            _increaseGlobalShortSize(_indexToken, _sizeDelta);
        }

        emit IncreasePosition(key, _account, _collateralToken, _indexToken, collateralDeltaUsd, _sizeDelta, _isLong, price, fee);
        emit UpdatePosition(key, position.size, position.collateral, position.averagePrice, position.entryFundingRate, position.reserveAmount, position.realisedPnl, price);
    }

    function decreasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver
    ) external override nonReentrant returns (uint256) {
        _validateGasPrice();
        _validateRouter(_account);
        return _decreasePosition(_account, _collateralToken, _indexToken, _collateralDelta, _sizeDelta, _isLong, _receiver);
    }

    function _decreasePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong,
        address _receiver
    ) private returns (uint256) {
        vaultUtils.validateDecreasePosition(_account, _collateralToken, _indexToken, _collateralDelta, _sizeDelta, _isLong, _receiver);
        updateCumulativeFundingRate(_collateralToken, _indexToken);

        bytes32 key = getPositionKey(_account, _collateralToken, _indexToken, _isLong);
        Position storage position = positions[key];
        _validate(position.size > 0, 31);
        _validate(position.size >= _sizeDelta, 32);
        _validate(position.collateral >= _collateralDelta, 33);

        uint256 collateral = position.collateral;
        // scrop variables to avoid stack too deep errors
        {
            uint256 reserveDelta = position.reserveAmount.mul(_sizeDelta).div(position.size);
            position.reserveAmount = position.reserveAmount.sub(reserveDelta);
            _decreaseReservedAmount(_collateralToken, reserveDelta);
        }

        (uint256 usdOut, uint256 usdOutAfterFee) = _reduceCollateral(_account, _collateralToken, _indexToken, _collateralDelta, _sizeDelta, _isLong);

        if (position.size != _sizeDelta) {
            position.entryFundingRate = getEntryFundingRate(_collateralToken, _indexToken, _isLong);
            position.size = position.size.sub(_sizeDelta);

            _validatePosition(position.size, position.collateral);
            validateLiquidation(_account, _collateralToken, _indexToken, _isLong, true);

            if (_isLong) {
                _increaseGuaranteedUsd(_collateralToken, collateral.sub(position.collateral));
                _decreaseGuaranteedUsd(_collateralToken, _sizeDelta);
            }

            uint256 price = _isLong ? getMinPrice(_indexToken) : getMaxPrice(_indexToken);
            emit DecreasePosition(key, _account, _collateralToken, _indexToken, _collateralDelta, _sizeDelta, _isLong, price, usdOut.sub(usdOutAfterFee));
            emit UpdatePosition(key, position.size, position.collateral, position.averagePrice, position.entryFundingRate, position.reserveAmount, position.realisedPnl, price);
        } else {
            if (_isLong) {
                _increaseGuaranteedUsd(_collateralToken, collateral);
                _decreaseGuaranteedUsd(_collateralToken, _sizeDelta);
            }

            uint256 price = _isLong ? getMinPrice(_indexToken) : getMaxPrice(_indexToken);
            emit DecreasePosition(key, _account, _collateralToken, _indexToken, _collateralDelta, _sizeDelta, _isLong, price, usdOut.sub(usdOutAfterFee));
            emit ClosePosition(key, position.size, position.collateral, position.averagePrice, position.entryFundingRate, position.reserveAmount, position.realisedPnl);

            delete positions[key];
        }

        if (!_isLong) {
            _decreaseGlobalShortSize(_indexToken, _sizeDelta);
        }

        if (usdOut > 0) {
            if (_isLong) {
                _decreasePoolAmount(_collateralToken, usdToTokenMin(_collateralToken, usdOut));
            }
            uint256 amountOutAfterFees = usdToTokenMin(_collateralToken, usdOutAfterFee);
            _transferOut(_collateralToken, amountOutAfterFees, _receiver);
            return amountOutAfterFees;
        }

        return 0;
    }

    function liquidatePosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        address _feeReceiver
    ) external override nonReentrant {
        if (inPrivateLiquidationMode) {
            _validate(isLiquidator[msg.sender], 34);
        }

        // set includeAmmPrice to false to prevent manipulated liquidations
        includeAmmPrice = false;

        updateCumulativeFundingRate(_collateralToken, _indexToken);

        bytes32 key = getPositionKey(_account, _collateralToken, _indexToken, _isLong);
        Position memory position = positions[key];
        _validate(position.size > 0, 35);

        (uint256 liquidationState, uint256 marginFees) = validateLiquidation(_account, _collateralToken, _indexToken, _isLong, false);
        _validate(liquidationState != 0, 36);
        if (liquidationState == 2) {
            // max leverage exceeded but there is collateral remaining after deducting losses so decreasePosition instead
            _decreasePosition(_account, _collateralToken, _indexToken, 0, position.size, _isLong, _account);
            includeAmmPrice = true;
            return;
        }

        uint256 feeTokens = usdToTokenMin(_collateralToken, marginFees);
        feeReserves[_collateralToken] = feeReserves[_collateralToken].add(feeTokens);
        emit CollectMarginFees(_collateralToken, marginFees, feeTokens);

        _decreaseReservedAmount(_collateralToken, position.reserveAmount);
        if (_isLong) {
            _decreaseGuaranteedUsd(_collateralToken, position.size.sub(position.collateral));
            _decreasePoolAmount(_collateralToken, usdToTokenMin(_collateralToken, marginFees));
        }

        uint256 markPrice = _isLong ? getMinPrice(_indexToken) : getMaxPrice(_indexToken);
        emit LiquidatePosition(key, _account, _collateralToken, _indexToken, _isLong, position.size, position.collateral, position.reserveAmount, position.realisedPnl, markPrice);

        if (!_isLong && marginFees < position.collateral) {
            uint256 remainingCollateral = position.collateral.sub(marginFees);
            _increasePoolAmount(_collateralToken, usdToTokenMin(_collateralToken, remainingCollateral));
        }

        if (!_isLong) {
            _decreaseGlobalShortSize(_indexToken, position.size);
        }

        delete positions[key];

        // pay the fee receiver using the pool, we assume that in general the liquidated amount should be sufficient to cover
        // the liquidation fees
        _decreasePoolAmount(_collateralToken, usdToTokenMin(_collateralToken, liquidationFeeUsd));
        _transferOut(_collateralToken, usdToTokenMin(_collateralToken, liquidationFeeUsd), _feeReceiver);

        includeAmmPrice = true;
    }

    // validateLiquidation returns (state, fees)
    function validateLiquidation(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        bool _raise
    ) public view returns (uint256, uint256) {
        return vaultUtils.validateLiquidation(_account, _collateralToken, _indexToken, _isLong, _raise);
    }

    function getMaxPrice(address _token) public view override returns (uint256) {
        return IVaultPriceFeed(priceFeed).getPrice(_token, true, includeAmmPrice, useSwapPricing);
    }

    function getMinPrice(address _token) public view override returns (uint256) {
        return IVaultPriceFeed(priceFeed).getPrice(_token, false, includeAmmPrice, useSwapPricing);
    }

    function getRedemptionAmount(address _token, uint256 _usdmAmount) public view override returns (uint256) {
        uint256 price = getMaxPrice(_token);
        uint256 redemptionAmount = _usdmAmount.mul(PRICE_PRECISION).div(price);
        return adjustForDecimals(redemptionAmount, usdm, _token);
    }

    function getRedemptionCollateral(address _token) public view returns (uint256) {
        if (stableTokens[_token]) {
            return poolAmounts[_token];
        }
        uint256 collateral = usdToTokenMin(_token, guaranteedUsd[_token]);
        return collateral.add(poolAmounts[_token]).sub(reservedAmounts[_token]);
    }

    function getRedemptionCollateralUsd(address _token) public view returns (uint256) {
        return tokenToUsdMin(_token, getRedemptionCollateral(_token));
    }

    function adjustForDecimals(
        uint256 _amount,
        address _tokenDiv,
        address _tokenMul
    ) public view returns (uint256) {
        uint256 decimalsDiv = _tokenDiv == usdm ? USDM_DECIMALS : tokenDecimals[_tokenDiv];
        uint256 decimalsMul = _tokenMul == usdm ? USDM_DECIMALS : tokenDecimals[_tokenMul];
        return _amount.mul(10**decimalsMul).div(10**decimalsDiv);
    }

    function tokenToUsdMin(address _token, uint256 _tokenAmount) public view override returns (uint256) {
        if (_tokenAmount == 0) {
            return 0;
        }
        uint256 price = getMinPrice(_token);
        uint256 decimals = tokenDecimals[_token];
        return _tokenAmount.mul(price).div(10**decimals);
    }

    function usdToTokenMax(address _token, uint256 _usdAmount) public view returns (uint256) {
        if (_usdAmount == 0) {
            return 0;
        }
        return usdToToken(_token, _usdAmount, getMinPrice(_token));
    }

    function usdToTokenMin(address _token, uint256 _usdAmount) public view returns (uint256) {
        if (_usdAmount == 0) {
            return 0;
        }
        return usdToToken(_token, _usdAmount, getMaxPrice(_token));
    }

    function usdToToken(
        address _token,
        uint256 _usdAmount,
        uint256 _price
    ) public view returns (uint256) {
        if (_usdAmount == 0) {
            return 0;
        }
        uint256 decimals = tokenDecimals[_token];
        return _usdAmount.mul(10**decimals).div(_price);
    }

    function getPosition(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong
    )
        public
        view
        override
        returns (
            uint256,
            uint256,
            uint256,
            uint256,
            uint256,
            uint256,
            bool,
            uint256
        )
    {
        bytes32 key = getPositionKey(_account, _collateralToken, _indexToken, _isLong);
        Position memory position = positions[key];
        uint256 realisedPnl = position.realisedPnl > 0 ? uint256(position.realisedPnl) : uint256(-position.realisedPnl);
        return (
            position.size, // 0
            position.collateral, // 1
            position.averagePrice, // 2
            position.entryFundingRate, // 3
            position.reserveAmount, // 4
            realisedPnl, // 5
            position.realisedPnl >= 0, // 6
            position.lastIncreasedTime // 7
        );
    }

    function getPositionKey(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong
    ) public pure returns (bytes32) {
        return keccak256(abi.encodePacked(_account, _collateralToken, _indexToken, _isLong));
    }

    function updateCumulativeFundingRate(address _collateralToken, address _indexToken) public {
        bool shouldUpdate = vaultUtils.updateCumulativeFundingRate(_collateralToken, _indexToken);
        if (!shouldUpdate) {
            return;
        }

        if (lastFundingTimes[_collateralToken] == 0) {
            lastFundingTimes[_collateralToken] = block.timestamp.div(fundingInterval).mul(fundingInterval);
            return;
        }

        if (lastFundingTimes[_collateralToken].add(fundingInterval) > block.timestamp) {
            return;
        }

        uint256 fundingRate = getNextFundingRate(_collateralToken);
        cumulativeFundingRates[_collateralToken] = cumulativeFundingRates[_collateralToken].add(fundingRate);
        lastFundingTimes[_collateralToken] = block.timestamp.div(fundingInterval).mul(fundingInterval);

        emit UpdateFundingRate(_collateralToken, cumulativeFundingRates[_collateralToken]);
    }

    function getNextFundingRate(address _token) public view override returns (uint256) {
        if (lastFundingTimes[_token].add(fundingInterval) > block.timestamp) {
            return 0;
        }

        uint256 intervals = block.timestamp.sub(lastFundingTimes[_token]).div(fundingInterval);
        uint256 poolAmount = poolAmounts[_token];
        if (poolAmount == 0) {
            return 0;
        }

        uint256 _fundingRateFactor = stableTokens[_token] ? stableFundingRateFactor : fundingRateFactor;
        return _fundingRateFactor.mul(reservedAmounts[_token]).mul(intervals).div(poolAmount);
    }

    function getUtilisation(address _token) public view returns (uint256) {
        uint256 poolAmount = poolAmounts[_token];
        if (poolAmount == 0) {
            return 0;
        }

        return reservedAmounts[_token].mul(FUNDING_RATE_PRECISION).div(poolAmount);
    }

    function getPositionLeverage(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong
    ) public view returns (uint256) {
        bytes32 key = getPositionKey(_account, _collateralToken, _indexToken, _isLong);
        Position memory position = positions[key];
        _validate(position.collateral > 0, 37);
        return position.size.mul(BASIS_POINTS_DIVISOR).div(position.collateral);
    }

    // for longs: nextAveragePrice = (nextPrice * nextSize)/ (nextSize + delta)
    // for shorts: nextAveragePrice = (nextPrice * nextSize) / (nextSize - delta)
    function getNextAveragePrice(
        address _indexToken,
        uint256 _size,
        uint256 _averagePrice,
        bool _isLong,
        uint256 _nextPrice,
        uint256 _sizeDelta,
        uint256 _lastIncreasedTime
    ) public view returns (uint256) {
        (bool hasProfit, uint256 delta) = getDelta(_indexToken, _size, _averagePrice, _isLong, _lastIncreasedTime);
        uint256 nextSize = _size.add(_sizeDelta);
        uint256 divisor;
        if (_isLong) {
            divisor = hasProfit ? nextSize.add(delta) : nextSize.sub(delta);
        } else {
            divisor = hasProfit ? nextSize.sub(delta) : nextSize.add(delta);
        }
        return _nextPrice.mul(nextSize).div(divisor);
    }

    // for longs: nextAveragePrice = (nextPrice * nextSize)/ (nextSize + delta)
    // for shorts: nextAveragePrice = (nextPrice * nextSize) / (nextSize - delta)
    function getNextGlobalShortAveragePrice(
        address _indexToken,
        uint256 _nextPrice,
        uint256 _sizeDelta
    ) public view returns (uint256) {
        uint256 size = globalShortSizes[_indexToken];
        uint256 averagePrice = globalShortAveragePrices[_indexToken];
        uint256 priceDelta = averagePrice > _nextPrice ? averagePrice.sub(_nextPrice) : _nextPrice.sub(averagePrice);
        uint256 delta = size.mul(priceDelta).div(averagePrice);
        bool hasProfit = averagePrice > _nextPrice;

        uint256 nextSize = size.add(_sizeDelta);
        uint256 divisor = hasProfit ? nextSize.sub(delta) : nextSize.add(delta);

        return _nextPrice.mul(nextSize).div(divisor);
    }

    function getGlobalShortDelta(address _token) public view returns (bool, uint256) {
        uint256 size = globalShortSizes[_token];
        if (size == 0) {
            return (false, 0);
        }

        uint256 nextPrice = getMaxPrice(_token);
        uint256 averagePrice = globalShortAveragePrices[_token];
        uint256 priceDelta = averagePrice > nextPrice ? averagePrice.sub(nextPrice) : nextPrice.sub(averagePrice);
        uint256 delta = size.mul(priceDelta).div(averagePrice);
        bool hasProfit = averagePrice > nextPrice;

        return (hasProfit, delta);
    }

    function getPositionDelta(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong
    ) public view returns (bool, uint256) {
        bytes32 key = getPositionKey(_account, _collateralToken, _indexToken, _isLong);
        Position memory position = positions[key];
        return getDelta(_indexToken, position.size, position.averagePrice, _isLong, position.lastIncreasedTime);
    }

    function getDelta(
        address _indexToken,
        uint256 _size,
        uint256 _averagePrice,
        bool _isLong,
        uint256 _lastIncreasedTime
    ) public view override returns (bool, uint256) {
        _validate(_averagePrice > 0, 38);
        uint256 price = _isLong ? getMinPrice(_indexToken) : getMaxPrice(_indexToken);
        uint256 priceDelta = _averagePrice > price ? _averagePrice.sub(price) : price.sub(_averagePrice);
        uint256 delta = _size.mul(priceDelta).div(_averagePrice);

        bool hasProfit;

        if (_isLong) {
            hasProfit = price > _averagePrice;
        } else {
            hasProfit = _averagePrice > price;
        }

        // if the minProfitTime has passed then there will be no min profit threshold
        // the min profit threshold helps to prevent front-running issues
        uint256 minBps = block.timestamp > _lastIncreasedTime.add(minProfitTime) ? 0 : minProfitBasisPoints[_indexToken];
        if (hasProfit && delta.mul(BASIS_POINTS_DIVISOR) <= _size.mul(minBps)) {
            delta = 0;
        }

        return (hasProfit, delta);
    }

    function getEntryFundingRate(
        address _collateralToken,
        address _indexToken,
        bool _isLong
    ) public view returns (uint256) {
        return vaultUtils.getEntryFundingRate(_collateralToken, _indexToken, _isLong);
    }

    function getFundingFee(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        uint256 _size,
        uint256 _entryFundingRate
    ) public view returns (uint256) {
        return vaultUtils.getFundingFee(_account, _collateralToken, _indexToken, _isLong, _size, _entryFundingRate);
    }

    function getPositionFee(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        uint256 _sizeDelta
    ) public view returns (uint256) {
        return vaultUtils.getPositionFee(_account, _collateralToken, _indexToken, _isLong, _sizeDelta);
    }

    // cases to consider
    // 1. initialAmount is far from targetAmount, action increases balance slightly => high rebate
    // 2. initialAmount is far from targetAmount, action increases balance largely => high rebate
    // 3. initialAmount is close to targetAmount, action increases balance slightly => low rebate
    // 4. initialAmount is far from targetAmount, action reduces balance slightly => high tax
    // 5. initialAmount is far from targetAmount, action reduces balance largely => high tax
    // 6. initialAmount is close to targetAmount, action reduces balance largely => low tax
    // 7. initialAmount is above targetAmount, nextAmount is below targetAmount and vice versa
    // 8. a large swap should have similar fees as the same trade split into multiple smaller swaps
    function getFeeBasisPoints(
        address _token,
        uint256 _usdmDelta,
        uint256 _feeBasisPoints,
        uint256 _taxBasisPoints,
        bool _increment
    ) public view override returns (uint256) {
        return vaultUtils.getFeeBasisPoints(_token, _usdmDelta, _feeBasisPoints, _taxBasisPoints, _increment);
    }

    function getTargetUsdmAmount(address _token) public view override returns (uint256) {
        uint256 supply = IERC20(usdm).totalSupply();
        if (supply == 0) {
            return 0;
        }
        uint256 weight = tokenWeights[_token];
        return weight.mul(supply).div(totalTokenWeights);
    }

    function _reduceCollateral(
        address _account,
        address _collateralToken,
        address _indexToken,
        uint256 _collateralDelta,
        uint256 _sizeDelta,
        bool _isLong
    ) private returns (uint256, uint256) {
        bytes32 key = getPositionKey(_account, _collateralToken, _indexToken, _isLong);
        Position storage position = positions[key];

        uint256 fee = _collectMarginFees(_account, _collateralToken, _indexToken, _isLong, _sizeDelta, position.size, position.entryFundingRate);
        bool hasProfit;
        uint256 adjustedDelta;

        // scope variables to avoid stack too deep errors
        {
            (bool _hasProfit, uint256 delta) = getDelta(_indexToken, position.size, position.averagePrice, _isLong, position.lastIncreasedTime);
            hasProfit = _hasProfit;
            // get the proportional change in pnl
            adjustedDelta = _sizeDelta.mul(delta).div(position.size);
        }

        uint256 usdOut;
        // transfer profits out
        if (hasProfit && adjustedDelta > 0) {
            usdOut = adjustedDelta;
            position.realisedPnl = position.realisedPnl + int256(adjustedDelta);

            // pay out realised profits from the pool amount for short positions
            if (!_isLong) {
                uint256 tokenAmount = usdToTokenMin(_collateralToken, adjustedDelta);
                _decreasePoolAmount(_collateralToken, tokenAmount);
            }
        }

        if (!hasProfit && adjustedDelta > 0) {
            position.collateral = position.collateral.sub(adjustedDelta);

            // transfer realised losses to the pool for short positions
            // realised losses for long positions are not transferred here as
            // _increasePoolAmount was already called in increasePosition for longs
            if (!_isLong) {
                uint256 tokenAmount = usdToTokenMin(_collateralToken, adjustedDelta);
                _increasePoolAmount(_collateralToken, tokenAmount);
            }

            position.realisedPnl = position.realisedPnl - int256(adjustedDelta);
        }

        // reduce the position's collateral by _collateralDelta
        // transfer _collateralDelta out
        if (_collateralDelta > 0) {
            usdOut = usdOut.add(_collateralDelta);
            position.collateral = position.collateral.sub(_collateralDelta);
        }

        // if the position will be closed, then transfer the remaining collateral out
        if (position.size == _sizeDelta) {
            usdOut = usdOut.add(position.collateral);
            position.collateral = 0;
        }

        // if the usdOut is more than the fee then deduct the fee from the usdOut directly
        // else deduct the fee from the position's collateral
        uint256 usdOutAfterFee = usdOut;
        if (usdOut > fee) {
            usdOutAfterFee = usdOut.sub(fee);
        } else {
            position.collateral = position.collateral.sub(fee);
            if (_isLong) {
                uint256 feeTokens = usdToTokenMin(_collateralToken, fee);
                _decreasePoolAmount(_collateralToken, feeTokens);
            }
        }

        emit UpdatePnl(key, hasProfit, adjustedDelta);

        return (usdOut, usdOutAfterFee);
    }

    function _validatePosition(uint256 _size, uint256 _collateral) private view {
        if (_size == 0) {
            _validate(_collateral == 0, 39);
            return;
        }
        _validate(_size >= _collateral, 40);
    }

    function _validateRouter(address _account) private view {
        if (msg.sender == _account) {
            return;
        }
        if (msg.sender == router) {
            return;
        }
        _validate(approvedRouters[_account][msg.sender], 41);
    }

    function _validateTokens(
        address _collateralToken,
        address _indexToken,
        bool _isLong
    ) private view {
        if (_isLong) {
            _validate(_collateralToken == _indexToken, 42);
            _validate(whitelistedTokens[_collateralToken], 43);
            _validate(!stableTokens[_collateralToken], 44);
            return;
        }

        _validate(whitelistedTokens[_collateralToken], 45);
        _validate(stableTokens[_collateralToken], 46);
        _validate(!stableTokens[_indexToken], 47);
        _validate(shortableTokens[_indexToken], 48);
    }

    function _collectSwapFees(
        address _token,
        uint256 _amount,
        uint256 _feeBasisPoints
    ) private returns (uint256) {
        uint256 afterFeeAmount = _amount.mul(BASIS_POINTS_DIVISOR.sub(_feeBasisPoints)).div(BASIS_POINTS_DIVISOR);
        uint256 feeAmount = _amount.sub(afterFeeAmount);
        feeReserves[_token] = feeReserves[_token].add(feeAmount);
        emit CollectSwapFees(_token, tokenToUsdMin(_token, feeAmount), feeAmount);
        return afterFeeAmount;
    }

    function _collectMarginFees(
        address _account,
        address _collateralToken,
        address _indexToken,
        bool _isLong,
        uint256 _sizeDelta,
        uint256 _size,
        uint256 _entryFundingRate
    ) private returns (uint256) {
        uint256 feeUsd = getPositionFee(_account, _collateralToken, _indexToken, _isLong, _sizeDelta);

        uint256 fundingFee = getFundingFee(_account, _collateralToken, _indexToken, _isLong, _size, _entryFundingRate);
        feeUsd = feeUsd.add(fundingFee);

        uint256 feeTokens = usdToTokenMin(_collateralToken, feeUsd);
        feeReserves[_collateralToken] = feeReserves[_collateralToken].add(feeTokens);

        emit CollectMarginFees(_collateralToken, feeUsd, feeTokens);
        return feeUsd;
    }

    function _transferIn(address _token) private returns (uint256) {
        uint256 prevBalance = tokenBalances[_token];
        uint256 nextBalance = IERC20(_token).balanceOf(address(this));
        tokenBalances[_token] = nextBalance;

        return nextBalance.sub(prevBalance);
    }

    function _transferOut(
        address _token,
        uint256 _amount,
        address _receiver
    ) private {
        IERC20(_token).safeTransfer(_receiver, _amount);
        tokenBalances[_token] = IERC20(_token).balanceOf(address(this));
    }

    function _updateTokenBalance(address _token) private {
        uint256 nextBalance = IERC20(_token).balanceOf(address(this));
        tokenBalances[_token] = nextBalance;
    }

    function _increasePoolAmount(address _token, uint256 _amount) private {
        poolAmounts[_token] = poolAmounts[_token].add(_amount);
        uint256 balance = IERC20(_token).balanceOf(address(this));
        _validate(poolAmounts[_token] <= balance, 49);
        emit IncreasePoolAmount(_token, _amount);
    }

    function _decreasePoolAmount(address _token, uint256 _amount) private {
        poolAmounts[_token] = poolAmounts[_token].sub(_amount, "Vault: poolAmount exceeded");
        _validate(reservedAmounts[_token] <= poolAmounts[_token], 50);
        emit DecreasePoolAmount(_token, _amount);
    }

    function _validateBufferAmount(address _token) private view {
        if (poolAmounts[_token] < bufferAmounts[_token]) {
            revert("Vault: poolAmount < buffer");
        }
    }

    function _increaseUsdmAmount(address _token, uint256 _amount) private {
        usdmAmounts[_token] = usdmAmounts[_token].add(_amount);
        uint256 maxUsdmAmount = maxUsdmAmounts[_token];
        if (maxUsdmAmount != 0) {
            _validate(usdmAmounts[_token] <= maxUsdmAmount, 51);
        }
        emit IncreaseUsdmAmount(_token, _amount);
    }

    function _decreaseUsdmAmount(address _token, uint256 _amount) private {
        uint256 value = usdmAmounts[_token];
        // since USDM can be minted using multiple assets
        // it is possible for the USDM debt for a single asset to be less than zero
        // the USDM debt is capped to zero for this case
        if (value <= _amount) {
            usdmAmounts[_token] = 0;
            emit DecreaseUsdmAmount(_token, value);
            return;
        }
        usdmAmounts[_token] = value.sub(_amount);
        emit DecreaseUsdmAmount(_token, _amount);
    }

    function _increaseReservedAmount(address _token, uint256 _amount) private {
        reservedAmounts[_token] = reservedAmounts[_token].add(_amount);
        _validate(reservedAmounts[_token] <= poolAmounts[_token], 52);
        emit IncreaseReservedAmount(_token, _amount);
    }

    function _decreaseReservedAmount(address _token, uint256 _amount) private {
        reservedAmounts[_token] = reservedAmounts[_token].sub(_amount, "Vault: insufficient reserve");
        emit DecreaseReservedAmount(_token, _amount);
    }

    function _increaseGuaranteedUsd(address _token, uint256 _usdAmount) private {
        guaranteedUsd[_token] = guaranteedUsd[_token].add(_usdAmount);
        emit IncreaseGuaranteedUsd(_token, _usdAmount);
    }

    function _decreaseGuaranteedUsd(address _token, uint256 _usdAmount) private {
        guaranteedUsd[_token] = guaranteedUsd[_token].sub(_usdAmount);
        emit DecreaseGuaranteedUsd(_token, _usdAmount);
    }

    function _increaseGlobalShortSize(address _token, uint256 _amount) private {
        globalShortSizes[_token] = globalShortSizes[_token].add(_amount);

        uint256 maxSize = maxGlobalShortSizes[_token];
        if (maxSize != 0) {
            require(globalShortSizes[_token] <= maxSize, "Vault: max shorts exceeded");
        }
    }

    function _decreaseGlobalShortSize(address _token, uint256 _amount) private {
        uint256 size = globalShortSizes[_token];
        if (_amount > size) {
            globalShortSizes[_token] = 0;
            return;
        }

        globalShortSizes[_token] = size.sub(_amount);
    }

    // we have this validation as a function instead of a modifier to reduce contract size
    function _onlyGov() private view {
        _validate(msg.sender == gov, 53);
    }

    // we have this validation as a function instead of a modifier to reduce contract size
    function _validateManager() private view {
        if (inManagerMode) {
            _validate(isManager[msg.sender], 54);
        }
    }

    // we have this validation as a function instead of a modifier to reduce contract size
    function _validateGasPrice() private view {
        if (maxGasPrice == 0) {
            return;
        }
        _validate(tx.gasprice <= maxGasPrice, 55);
    }

    function _validate(bool _condition, uint256 _errorCode) private view {
        require(_condition, errors[_errorCode]);
    }
}

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

pragma solidity ^0.6.12;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.3._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.3._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

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

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

File 9 of 10 : 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 10 of 10 : IUSDM.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

interface IUSDM {
    function addVault(address _vault) external;

    function removeVault(address _vault) external;

    function mint(address _account, uint256 _amount) external;

    function burn(address _account, uint256 _amount) external;
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"usdmAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeBasisPoints","type":"uint256"}],"name":"BuyUSDM","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"key","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"size","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateral","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"averagePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"entryFundingRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserveAmount","type":"uint256"},{"indexed":false,"internalType":"int256","name":"realisedPnl","type":"int256"}],"name":"ClosePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"feeUsd","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeTokens","type":"uint256"}],"name":"CollectMarginFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"feeUsd","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeTokens","type":"uint256"}],"name":"CollectSwapFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DecreaseGuaranteedUsd","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DecreasePoolAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"key","type":"bytes32"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"DecreasePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DecreaseReservedAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DecreaseUsdmAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DirectPoolDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"IncreaseGuaranteedUsd","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"IncreasePoolAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"key","type":"bytes32"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sizeDelta","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"IncreasePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"IncreaseReservedAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"IncreaseUsdmAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"key","type":"bytes32"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"address","name":"indexToken","type":"address"},{"indexed":false,"internalType":"bool","name":"isLong","type":"bool"},{"indexed":false,"internalType":"uint256","name":"size","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateral","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserveAmount","type":"uint256"},{"indexed":false,"internalType":"int256","name":"realisedPnl","type":"int256"},{"indexed":false,"internalType":"uint256","name":"markPrice","type":"uint256"}],"name":"LiquidatePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"usdmAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeBasisPoints","type":"uint256"}],"name":"SellUSDM","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":false,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOutAfterFees","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeBasisPoints","type":"uint256"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"fundingRate","type":"uint256"}],"name":"UpdateFundingRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"key","type":"bytes32"},{"indexed":false,"internalType":"bool","name":"hasProfit","type":"bool"},{"indexed":false,"internalType":"uint256","name":"delta","type":"uint256"}],"name":"UpdatePnl","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"key","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"size","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"collateral","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"averagePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"entryFundingRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reserveAmount","type":"uint256"},{"indexed":false,"internalType":"int256","name":"realisedPnl","type":"int256"},{"indexed":false,"internalType":"uint256","name":"markPrice","type":"uint256"}],"name":"UpdatePosition","type":"event"},{"inputs":[],"name":"BASIS_POINTS_DIVISOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FUNDING_RATE_PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FEE_BASIS_POINTS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FUNDING_RATE_FACTOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_LIQUIDATION_FEE_USD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_FUNDING_RATE_INTERVAL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_LEVERAGE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRICE_PRECISION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDM_DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"name":"addRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_tokenDiv","type":"address"},{"internalType":"address","name":"_tokenMul","type":"address"}],"name":"adjustForDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allWhitelistedTokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allWhitelistedTokensLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"approvedRouters","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"bufferAmounts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"buyUSDM","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"clearTokenConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"cumulativeFundingRates","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"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"}],"name":"decreasePosition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"directPoolDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"errorController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"errors","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feeReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fundingInterval","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fundingRateFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_size","type":"uint256"},{"internalType":"uint256","name":"_averagePrice","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_lastIncreasedTime","type":"uint256"}],"name":"getDelta","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"bool","name":"_isLong","type":"bool"}],"name":"getEntryFundingRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_usdmDelta","type":"uint256"},{"internalType":"uint256","name":"_feeBasisPoints","type":"uint256"},{"internalType":"uint256","name":"_taxBasisPoints","type":"uint256"},{"internalType":"bool","name":"_increment","type":"bool"}],"name":"getFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"_size","type":"uint256"},{"internalType":"uint256","name":"_entryFundingRate","type":"uint256"}],"name":"getFundingFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getGlobalShortDelta","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getMaxPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getMinPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_size","type":"uint256"},{"internalType":"uint256","name":"_averagePrice","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"},{"internalType":"uint256","name":"_nextPrice","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"uint256","name":"_lastIncreasedTime","type":"uint256"}],"name":"getNextAveragePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getNextFundingRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_indexToken","type":"address"},{"internalType":"uint256","name":"_nextPrice","type":"uint256"},{"internalType":"uint256","name":"_sizeDelta","type":"uint256"}],"name":"getNextGlobalShortAveragePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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"}],"name":"getPosition","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"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"}],"name":"getPositionDelta","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"_sizeDelta","type":"uint256"}],"name":"getPositionFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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"}],"name":"getPositionKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","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"}],"name":"getPositionLeverage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_usdmAmount","type":"uint256"}],"name":"getRedemptionAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getRedemptionCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getRedemptionCollateralUsd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getTargetUsdmAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getUtilisation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"globalShortAveragePrices","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"globalShortSizes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gov","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"guaranteedUsd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hasDynamicFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"inManagerMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"inPrivateLiquidationMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"includeAmmPrice","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":"uint256","name":"_sizeDelta","type":"uint256"},{"internalType":"bool","name":"_isLong","type":"bool"}],"name":"increasePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"},{"internalType":"address","name":"_usdm","type":"address"},{"internalType":"address","name":"_priceFeed","type":"address"},{"internalType":"uint256","name":"_liquidationFeeUsd","type":"uint256"},{"internalType":"uint256","name":"_fundingRateFactor","type":"uint256"},{"internalType":"uint256","name":"_stableFundingRateFactor","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isLeverageEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":"isManager","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isSwapEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastFundingTimes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[],"name":"liquidationFeeUsd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marginFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxGasPrice","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":"maxLeverage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxUsdmAmounts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minProfitBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minProfitTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintBurnFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"poolAmounts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"positions","outputs":[{"internalType":"uint256","name":"size","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint256","name":"averagePrice","type":"uint256"},{"internalType":"uint256","name":"entryFundingRate","type":"uint256"},{"internalType":"uint256","name":"reserveAmount","type":"uint256"},{"internalType":"int256","name":"realisedPnl","type":"int256"},{"internalType":"uint256","name":"lastIncreasedTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeed","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"name":"removeRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"reservedAmounts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"sellUSDM","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"setBufferAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_errorCode","type":"uint256"},{"internalType":"string","name":"_error","type":"string"}],"name":"setError","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_errorController","type":"address"}],"name":"setErrorController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_taxBasisPoints","type":"uint256"},{"internalType":"uint256","name":"_stableTaxBasisPoints","type":"uint256"},{"internalType":"uint256","name":"_mintBurnFeeBasisPoints","type":"uint256"},{"internalType":"uint256","name":"_swapFeeBasisPoints","type":"uint256"},{"internalType":"uint256","name":"_stableSwapFeeBasisPoints","type":"uint256"},{"internalType":"uint256","name":"_marginFeeBasisPoints","type":"uint256"},{"internalType":"uint256","name":"_liquidationFeeUsd","type":"uint256"},{"internalType":"uint256","name":"_minProfitTime","type":"uint256"},{"internalType":"bool","name":"_hasDynamicFees","type":"bool"}],"name":"setFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fundingInterval","type":"uint256"},{"internalType":"uint256","name":"_fundingRateFactor","type":"uint256"},{"internalType":"uint256","name":"_stableFundingRateFactor","type":"uint256"}],"name":"setFundingRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gov","type":"address"}],"name":"setGov","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_inManagerMode","type":"bool"}],"name":"setInManagerMode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_inPrivateLiquidationMode","type":"bool"}],"name":"setInPrivateLiquidationMode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isLeverageEnabled","type":"bool"}],"name":"setIsLeverageEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isSwapEnabled","type":"bool"}],"name":"setIsSwapEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_liquidator","type":"address"},{"internalType":"bool","name":"_isActive","type":"bool"}],"name":"setLiquidator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_manager","type":"address"},{"internalType":"bool","name":"_isManager","type":"bool"}],"name":"setManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxGasPrice","type":"uint256"}],"name":"setMaxGasPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"setMaxGlobalShortSize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxLeverage","type":"uint256"}],"name":"setMaxLeverage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_priceFeed","type":"address"}],"name":"setPriceFeed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_tokenDecimals","type":"uint256"},{"internalType":"uint256","name":"_tokenWeight","type":"uint256"},{"internalType":"uint256","name":"_minProfitBps","type":"uint256"},{"internalType":"uint256","name":"_maxUsdmAmount","type":"uint256"},{"internalType":"bool","name":"_isStable","type":"bool"},{"internalType":"bool","name":"_isShortable","type":"bool"}],"name":"setTokenConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"setUsdmAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IVaultUtils","name":"_vaultUtils","type":"address"}],"name":"setVaultUtils","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"shortableTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stableFundingRateFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stableSwapFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stableTaxBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stableTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenIn","type":"address"},{"internalType":"address","name":"_tokenOut","type":"address"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"swap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"taxBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_tokenAmount","type":"uint256"}],"name":"tokenToUsdMin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenWeights","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalTokenWeights","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collateralToken","type":"address"},{"internalType":"address","name":"_indexToken","type":"address"}],"name":"updateCumulativeFundingRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newVault","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"upgradeVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_usdAmount","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"usdToToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_usdAmount","type":"uint256"}],"name":"usdToTokenMax","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_usdAmount","type":"uint256"}],"name":"usdToTokenMin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usdm","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"usdmAmounts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"useSwapPricing","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":"bool","name":"_raise","type":"bool"}],"name":"validateLiquidation","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultUtils","outputs":[{"internalType":"contract IVaultUtils","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"whitelistedTokenCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistedTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"withdrawFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

60806040526001805462ff00001961ff00199091166101001716620100001781556207a1206008556032600a9081556014600b55601e600c819055600d556004600e55600f556011805460ff199081169091556170806012556016805463ffffff0019921690921716905534801561007657600080fd5b506001600055600680546001600160a01b03191633179055615f8d806200009e6000396000f3fe608060405234801561001057600080fd5b50600436106106095760003560e01c80638585f4d211610329578063c7e074c3116101af578063df73a26711610105578063f2555278116100a8578063f255527814611640578063f3ae24151461166e578063f887ea4014611694578063fa12dbc01461169c578063fbfded6d146116ce578063fce28c10146116fc578063fdaf6ac314611704578063fed1a6061461174857610609565b8063df73a26714611556578063e124e6d21461155e578063e468baf014611584578063e67f59a7146115a1578063ee138d0f146115c7578063efa10a6e146115cf578063f07456ce146115fb578063f07bbf771461162157610609565b8063c7e074c314611295578063cea0c328146112d5578063cfad57a21461130b578063d2fa635e14611331578063d3127e631461134e578063d45200d11461136b578063d54d5a9f14611397578063d8f897c3146113f6578063d9ac42251461141c578063da76524c14611424578063daf9c2101461146e578063db3555fb14611494578063db97495f146114ba578063dc8f5fac14611506578063de2ea9481461150e57610609565b80639d7432ca1161027f578063ae3302c211610222578063ae3302c2146111ad578063b06423f3146111b5578063b136ca49146111bd578063b1cc53ab146111e3578063b364accb1461121b578063c3c7b9e914611241578063c4f718bf14611267578063c65bc7b11461126f57610609565b80639d7432ca146110bd5780639f392eb3146110ef578063a22f2392146110f7578063a42ab3d2146110ff578063a5e90eee1461112b578063a93acac214611159578063ab08c1c61461117f578063ab2f3ad41461118757610609565b80638585f4d214610eda57806386284f5f14610f0657806388b1fbdf14610f345780638a27d46814610f5a5780638a39735a146106b85780638a78daa814610f835780638ee573ac14610fa95780638f7b840414610fcf5780639060b1ca14610ff55780639331621214610ffd57806395082d25146110355780639698d25a1461103d5780639849e412146110635780639899cd021461106b5780639acc6b331461109757610609565b806342b60b03116104ae5780635f7bc11911610404578063724e78da116103a7578063724e78da14610d9d578063728cdbca14610dc3578063741bef1a14610e0b5780637a210a2b14610e135780637c2eb9f714610e1b57806381a612d614610e3a57806382a0849014610e6057806383867b2d14610eb457610609565b80635f7bc11914610cbf5780636092219914610ce557806362287a3214610d135780636274980314610d1b5780636abbe0c814610d415780636ae0b15414610d495780636be6026b14610d6f57806371089f4d14610d7757610609565b806342b60b03146109ca5780634453a374146109f057806345a6f37014610a1e57806348d91abf14610a7757806348f35cbb14610abb5780634a3f088d14610ac35780634a993ee914610b445780634befe2ca14610b6a5780634d47b30414610b72578063514ea4bf14610b7a57806351723e8214610bcf578063523fba7f14610c0d578063529a356f14610c3357806352f55eed14610c595780635c07eaab14610c7f57610609565b806329ff96151161056357806329ff9615146107f25780632c668ec1146108185780632d4b057614610844578063302a81411461088257806330455ede1461088a578063318bc689146108a957806334c1557d146106b8578063351a964d146108b157806337af6e7e146108b9578063392e53cd146108df5780633c5a6e35146108e75780633de39c11146109355780633e72a2621461093d57806340eb380214610945578063421528731461099657610609565b806304fef1db1461060e57806307c58752146106465780630842b0761461064e5780630928a4f8146106565780630a48d5a91461068457806310eb56c2146106b0578063126082cf146106b857806312d43a51146106c0578063134ca63b146106e4578063174d2694146106ec578063181e210e146106f45780631ce9cb8f1461071057806324b0c04d1461073657806324ca984e1461075757806328e67be51461077d575b600080fd5b6106346004803603602081101561062457600080fd5b50356001600160a01b03166117da565b60408051918252519081900360200190f35b61063461183d565b61063461184e565b6106346004803603604081101561066c57600080fd5b506001600160a01b0381358116916020013516611854565b6106346004803603604081101561069a57600080fd5b506001600160a01b038135169060200135611ae8565b610634611b3b565b610634611b41565b6106c8611b47565b604080516001600160a01b039092168252519081900360200190f35b610634611b56565b610634611b5c565b6106fc611b62565b604080519115158252519081900360200190f35b6106346004803603602081101561072657600080fd5b50356001600160a01b0316611b72565b6107556004803603602081101561074c57600080fd5b50351515611b84565b005b6107556004803603602081101561076d57600080fd5b50356001600160a01b0316611ba8565b6107556004803603604081101561079357600080fd5b81359190810190604081016020820135600160201b8111156107b457600080fd5b8201836020820111156107c657600080fd5b803590602001918460018302840111600160201b831117156107e757600080fd5b509092509050611bd9565b6106346004803603602081101561080857600080fd5b50356001600160a01b0316611c57565b6106346004803603604081101561082e57600080fd5b506001600160a01b038135169060200135611c6b565b6106346004803603608081101561085a57600080fd5b506001600160a01b038135811691602081013582169160408201351690606001351515611cb0565b610634611d06565b610755600480360360208110156108a057600080fd5b50351515611d0b565b610634611d2d565b6106fc611d33565b610634600480360360208110156108cf57600080fd5b50356001600160a01b0316611d41565b6106fc611e01565b610755600480360360e08110156108fd57600080fd5b506001600160a01b038135169060208101359060408101359060608101359060808101359060a081013515159060c001351515611e0a565b610634611f4c565b6106fc611f52565b610755600480360361012081101561095c57600080fd5b5080359060208101359060408101359060608101359060808101359060a08101359060c08101359060e08101359061010001351515611f61565b610634600480360360608110156109ac57600080fd5b508035906001600160a01b036020820135811691604001351661201b565b6106fc600480360360208110156109e057600080fd5b50356001600160a01b03166120bd565b61075560048036036040811015610a0657600080fd5b506001600160a01b03813516906020013515156120d2565b610a5c60048036036080811015610a3457600080fd5b506001600160a01b038135811691602081013582169160408201351690606001351515612105565b60408051921515835260208301919091528051918290030190f35b610755600480360360a0811015610a8d57600080fd5b506001600160a01b0381358116916020810135821691604082013516906060810135906080013515156121a3565b6106c86125e2565b610b0160048036036080811015610ad957600080fd5b506001600160a01b0381358116916020810135821691604082013516906060013515156125f1565b604080519889526020890197909752878701959095526060870193909352608086019190915260a0850152151560c084015260e083015251908190036101000190f35b61063460048036036020811015610b5a57600080fd5b50356001600160a01b03166126e7565b6106346126f9565b6106346126ff565b610b9760048036036020811015610b9057600080fd5b5035612705565b604080519788526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b61063460048036036080811015610be557600080fd5b506001600160a01b038135811691602081013582169160408201351690606001351515612742565b61063460048036036020811015610c2357600080fd5b50356001600160a01b03166127e8565b6106fc60048036036020811015610c4957600080fd5b50356001600160a01b03166127fa565b61063460048036036020811015610c6f57600080fd5b50356001600160a01b031661280f565b610a5c600480360360a0811015610c9557600080fd5b506001600160a01b0381351690602081013590604081013590606081013515159060800135612821565b61075560048036036020811015610cd557600080fd5b50356001600160a01b0316612919565b6106fc60048036036040811015610cfb57600080fd5b506001600160a01b03813581169160200135166129fc565b610634612a1c565b61063460048036036020811015610d3157600080fd5b50356001600160a01b0316612a22565b6106c8612a34565b61075560048036036020811015610d5f57600080fd5b50356001600160a01b0316612a4a565b610634612a78565b61075560048036036020811015610d8d57600080fd5b50356001600160a01b0316612a7f565b61075560048036036020811015610db357600080fd5b50356001600160a01b0316612ab3565b610755600480360360c0811015610dd957600080fd5b506001600160a01b03813581169160208101358216916040820135169060608101359060808101359060a00135612add565b6106c8612b54565b610634612b63565b61075560048036036020811015610e3157600080fd5b50351515612b69565b61063460048036036020811015610e5057600080fd5b50356001600160a01b0316612b8d565b610634600480360360e0811015610e7657600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359160808201359160a081013515159160c09091013516612c38565b61063460048036036020811015610eca57600080fd5b50356001600160a01b0316612cb6565b61075560048036036040811015610ef057600080fd5b506001600160a01b038135169060200135612cc8565b61063460048036036040811015610f1c57600080fd5b506001600160a01b0381358116916020013516612cec565b61063460048036036020811015610f4a57600080fd5b50356001600160a01b0316612fbc565b61075560048036036060811015610f7057600080fd5b5080359060208101359060400135612fce565b61063460048036036020811015610f9957600080fd5b50356001600160a01b0316613014565b61063460048036036020811015610fbf57600080fd5b50356001600160a01b0316613026565b61075560048036036020811015610fe557600080fd5b50356001600160a01b0316613038565b6106fc613062565b6106346004803603606081101561101357600080fd5b506001600160a01b038135811691602081013582169160409091013516613071565b610634613359565b6106346004803603602081101561105357600080fd5b50356001600160a01b0316613369565b61063461337b565b6106346004803603604081101561108157600080fd5b506001600160a01b038135169060200135613381565b610634600480360360208110156110ad57600080fd5b50356001600160a01b03166133a3565b610634600480360360608110156110d357600080fd5b506001600160a01b0381351690602081013590604001356133b5565b6106fc61345e565b610634613467565b6106346004803603604081101561111557600080fd5b506001600160a01b03813516906020013561346d565b6107556004803603604081101561114157600080fd5b506001600160a01b038135169060200135151561348a565b6106346004803603602081101561116f57600080fd5b50356001600160a01b03166134bd565b6106fc6135bb565b6106346004803603602081101561119d57600080fd5b50356001600160a01b03166135c4565b6106346135d6565b6106fc6135dc565b610634600480360360208110156111d357600080fd5b50356001600160a01b03166135ea565b610634600480360360608110156111f957600080fd5b506001600160a01b03813581169160208101359091169060400135151561368b565b610a5c6004803603602081101561123157600080fd5b50356001600160a01b0316613726565b6106346004803603602081101561125757600080fd5b50356001600160a01b03166137be565b6106346137d0565b6106346004803603602081101561128557600080fd5b50356001600160a01b03166137d6565b610634600480360360a08110156112ab57600080fd5b506001600160a01b03813516906020810135906040810135906060810135906080013515156137e8565b610755600480360360608110156112eb57600080fd5b506001600160a01b03813581169160208101359091169060400135613892565b6107556004803603602081101561132157600080fd5b50356001600160a01b03166138b3565b6107556004803603602081101561134757600080fd5b50356138dd565b6107556004803603602081101561136457600080fd5b50356138ea565b6107556004803603604081101561138157600080fd5b506001600160a01b038135169060200135613906565b6113dd600480360360a08110156113ad57600080fd5b506001600160a01b038135811691602081013582169160408201351690606081013515159060800135151561395f565b6040805192835260208301919091528051918290030190f35b6106346004803603602081101561140c57600080fd5b50356001600160a01b0316613a16565b610634613a28565b610634600480360360c081101561143a57600080fd5b506001600160a01b038135811691602081013582169160408201351690606081013515159060808101359060a00135613a2e565b6106fc6004803603602081101561148457600080fd5b50356001600160a01b0316613ae2565b6106fc600480360360208110156114aa57600080fd5b50356001600160a01b0316613af7565b610634600480360360e08110156114d057600080fd5b506001600160a01b0381351690602081013590604081013590606081013515159060808101359060a08101359060c00135613b0b565b610634613b9c565b610755600480360360a081101561152457600080fd5b506001600160a01b03813581169160208101358216916040820135811691606081013515159160809091013516613ba2565b610634613f7a565b6106346004803603602081101561157457600080fd5b50356001600160a01b0316613f80565b6106c86004803603602081101561159a57600080fd5b5035613ff8565b610755600480360360208110156115b757600080fd5b50356001600160a01b031661401f565b6106c86140f2565b610755600480360360408110156115e557600080fd5b506001600160a01b038135169060200135614101565b6106346004803603602081101561161157600080fd5b50356001600160a01b0316614125565b6107556004803603602081101561163757600080fd5b50351515614137565b6106346004803603604081101561165657600080fd5b506001600160a01b038135811691602001351661415d565b6106fc6004803603602081101561168457600080fd5b50356001600160a01b03166141b3565b6106c86141c8565b610634600480360360608110156116b257600080fd5b506001600160a01b0381351690602081013590604001356141d7565b610755600480360360408110156116e457600080fd5b506001600160a01b0381358116916020013516614211565b6106346143ea565b610634600480360360a081101561171a57600080fd5b506001600160a01b0381358116916020810135821691604082013516906060810135151590608001356143f0565b6117656004803603602081101561175e57600080fd5b5035614466565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561179f578181015183820152602001611787565b50505050905090810190601f1680156117cc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6001600160a01b03811660009081526025602052604081205480611802576000915050611838565b6001600160a01b03831660009081526026602052604090205461183490829061182e90620f4240614501565b9061455a565b9150505b919050565b6904ee2d6d415b85acef8160201b81565b601b5490565b60006002600054141561189c576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b60026000556118a9614599565b6001600160a01b0383166000908152601c60205260409020546118d09060ff1660136145ca565b6016805461ff0019166101001790556005546000906118f7906001600160a01b0316614676565b90506119076000821160146145ca565b6119118485614211565b600061191d8583611c6b565b905061192d6000821160156145ca565b6119378583614723565b6119418582614805565b60055460408051632770a7eb60e21b81523060048201526024810185905290516001600160a01b0390921691639dc29fac9160448082019260009290919082900301818387803b15801561199457600080fd5b505af11580156119a8573d6000803e3d6000fd5b50506005546119c292506001600160a01b031690506148d8565b600154604080516310d5486360e21b81526001600160a01b0388811660048301526024820186905291516000936301000000900490921691634355218c91604480820192602092909190829003018186803b158015611a2057600080fd5b505afa158015611a34573d6000803e3d6000fd5b505050506040513d6020811015611a4a57600080fd5b505190506000611a5b878484614973565b9050611a6b6000821160166145ca565b611a76878288614a3b565b604080516001600160a01b03808916825289166020820152808201869052606081018390526080810184905290517f52eb5f5cb9a498f7cf35a2e264fbe42a9401185a0fd345d5d2c8932a2a45b1ae9181900360a00190a16016805461ff001916905560016000559695505050505050565b600081611af757506000611b35565b6000611b0284612b8d565b6001600160a01b0385166000908152601d6020526040902054909150611b30600a82900a61182e8685614501565b925050505b92915050565b600b5481565b61271081565b6006546001600160a01b031681565b60145481565b60095481565b6016546301000000900460ff1681565b602c6020526000908152604090205481565b611b8c614ae2565b60168054911515620100000262ff000019909216919091179055565b3360009081526018602090815260408083206001600160a01b0394909416835292905220805460ff19166001179055565b6002546001600160a01b03163314611c38576040805162461bcd60e51b815260206004820152601e60248201527f5661756c743a20696e76616c6964206572726f72436f6e74726f6c6c65720000604482015290519081900360640190fd5b6000838152603060205260409020611c51908383615e1c565b50505050565b6000611b3582611c66846135ea565b611ae8565b600080611c7784613f80565b90506000611c958261182e8668327cb2734119d3b7a9601e1b614501565b600554909150611b309082906001600160a01b03168761201b565b604080516001600160601b0319606096871b811660208084019190915295871b811660348301529390951b9092166048850152151560f81b605c8401528051603d818503018152605d9093019052815191012090565b601281565b611d13614ae2565b600180549115156101000261ff0019909216919091179055565b600f5481565b600154610100900460ff1681565b600080600560009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611d9257600080fd5b505afa158015611da6573d6000803e3d6000fd5b505050506040513d6020811015611dbc57600080fd5b5051905080611dcf576000915050611838565b6001600160a01b038316600090815260226020526040902054601554611df99061182e8385614501565b949350505050565b60015460ff1681565b611e12614ae2565b6001600160a01b0387166000908152601c602052604090205460ff16611e8f57600754611e40906001614afb565b600755601b80546001810182556000919091527f3ad8aa4f87544323a9d1e5dd902f40c356527a7955687113db5f9a85ad579dc10180546001600160a01b0319166001600160a01b0389161790555b6015546001600160a01b038816600090815260226020526040902054611eb6908290614b53565b6001600160a01b0389166000908152601c602090815260408083208054600160ff1991821617909155601d83528184208c9055602283528184208b9055601e83528184208a905560248352818420899055601f83528184208054821689151517905591805290912080549091168415151790559050611f358187614afb565b601555611f4188613f80565b505050505050505050565b60175481565b60015462010000900460ff1681565b611f69614ae2565b611f796101f48a111560036145ca565b611f896101f489111560046145ca565b611f996101f488111560056145ca565b611fa96101f487111560066145ca565b611fb96101f486111560076145ca565b611fc96101f485111560086145ca565b611fe46904ee2d6d415b85acef8160201b84111560096145ca565b600a98909855600b96909655600c94909455600d92909255600e55600f556009556010556011805460ff1916911515919091179055565b60055460009081906001600160a01b03858116911614612053576001600160a01b0384166000908152601d6020526040902054612056565b60125b6005549091506000906001600160a01b0385811691161461208f576001600160a01b0384166000908152601d6020526040902054612092565b60125b90506120b182600a0a61182e83600a0a8961450190919063ffffffff16565b925050505b9392505050565b601f6020526000908152604090205460ff1681565b6120da614ae2565b6001600160a01b03919091166000908152601960205260409020805460ff1916911515919091179055565b600080600061211687878787611cb0565b9050612120615e9a565b506000818152602b6020908152604091829020825160e081018452815480825260018301549382019390935260028201549381018490526003820154606082015260048201546080820152600582015460a082015260069091015460c0820181905290926121949289929091908990612821565b93509350505094509492505050565b600260005414156121e9576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b60026000556001546122059062010000900460ff16601c6145ca565b61220d614b95565b61221685614bb1565b612221848483614c14565b60015460408051634eae147d60e11b81526001600160a01b038881166004830152878116602483015286811660448301526064820186905284151560848301529151630100000090930490911691639d5c28fa9160a480820192600092909190829003018186803b15801561229557600080fd5b505afa1580156122a9573d6000803e3d6000fd5b505050506122b78484614211565b60006122c586868685611cb0565b6000818152602b60205260408120919250836122e9576122e486612b8d565b6122f2565b6122f286613f80565b825490915061230357600282018190555b8154158015906123135750600085115b1561233957612333868360000154846002015487858a8860060154613b0b565b60028301555b6000612352898989888a88600001548960030154614d29565b9050600061235f89614676565b9050600061236d8a83611ae8565b600186015490915061237f9082614afb565b6001860181905561239490841115601d6145ca565b60018501546123a39084614b53565b60018601556123b38a8a8961368b565b600386015584546123c49089614afb565b8086554260068701556123da901515601e6145ca565b6123ec85600001548660010154614df7565b6123fa8b8b8b8a600161395f565b505060006124088b8a61346d565b600487015490915061241a9082614afb565b60048701556124298b82614e1b565b871561246e576124428b61243d8b87614afb565b614ebb565b61244c8b83614f3a565b6124568b84614fb9565b6124698b6124648d87613381565b614805565b6124da565b6001600160a01b038a166000908152602d60205260409020546124ab576001600160a01b038a166000908152602e602052604090208590556124d0565b6124b68a868b6133b5565b6001600160a01b038b166000908152602e60205260409020555b6124da8a8a6150d1565b604080518881526001600160a01b03808f166020830152808e16828401528c1660608201526080810184905260a081018b905289151560c082015260e08101879052610100810186905290517f2fe68525253654c21998f35787a8d0f361905ef647c854092430ab65f2f15022918190036101200190a1855460018701546002880154600389015460048a015460058b0154604080518e81526020810197909752868101959095526060860193909352608085019190915260a084015260c083015260e08201879052517f20853733b590dce729d9f4628682ebd9a34d2354e72679e66f43a008fc03b773918190036101000190a15050600160005550505050505050505050565b6002546001600160a01b031681565b600080600080600080600080600061260b8d8d8d8d611cb0565b9050612615615e9a565b602b60008381526020019081526020016000206040518060e001604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482015481526020016005820154815260200160068201548152505090506000808260a0015113612695578160a0015160000361269b565b8160a001515b9050816000015182602001518360400151846060015185608001518560008860a0015112158860c001519a509a509a509a509a509a509a509a5050505094995094995094999196509450565b60276020526000908152604090205481565b6101f481565b600c5481565b602b602052600090815260409020805460018201546002830154600384015460048501546005860154600690960154949593949293919290919087565b60008061275186868686611cb0565b905061275b615e9a565b506000818152602b6020908152604091829020825160e0810184528154815260018201549281018390526002820154938101939093526003810154606084015260048101546080840152600581015460a08401526006015460c08301526127c590151560256145ca565b602081015181516127dd919061182e90612710614501565b979650505050505050565b60216020526000908152604090205481565b60196020526000908152604090205460ff1681565b60256020526000908152604090205481565b6000806128326000861160266145ca565b6000846128475761284288613f80565b612850565b61285088612b8d565b9050600081871161286a576128658288614b53565b612874565b6128748783614b53565b905060006128868861182e8b85614501565b905060008715612899575087831161289e565b508288115b60006128b560105489614afb90919063ffffffff16565b42116128d9576001600160a01b038c166000908152601e60205260409020546128dc565b60005b90508180156128ff57506128f08b82614501565b6128fc84612710614501565b11155b1561290957600092505b509a909950975050505050505050565b6002600054141561295f576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b600260009081556001600160a01b0382168152601c602052604090205461298a9060ff16600e6145ca565b600061299582614676565b90506129a560008211600f6145ca565b6129af8282614fb9565b604080516001600160a01b03841681526020810183905281517fa5a389190ebf6170a133bda5c769b77f4d6715b8aa172ec0ddf8473d0b4944bd929181900390910190a150506001600055565b601860209081526000928352604080842090915290825290205460ff1681565b60075481565b602e6020526000908152604090205481565b600154630100000090046001600160a01b031681565b3360009081526018602090815260408083206001600160a01b0394909416835292905220805460ff19169055565b620f424081565b612a87614ae2565b600180546001600160a01b039092166301000000026301000000600160b81b0319909216919091179055565b612abb614ae2565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b612ae5614ae2565b60018054612af99160ff90911615906145ca565b6001805460ff191681179055600380546001600160a01b03199081166001600160a01b039889161790915560058054821696881696909617909555600480549095169390951692909217909255600991909155601355601455565b6004546001600160a01b031681565b600a5481565b612b71614ae2565b60018054911515620100000262ff000019909216919091179055565b60048054601654604080516317e1d38560e11b81526001600160a01b038681169582019590955260006024820181905260ff80851615156044840152610100909404909316151560648201529051919390921691632fc3a70a916084808301926020929190829003018186803b158015612c0657600080fd5b505afa158015612c1a573d6000803e3d6000fd5b505050506040513d6020811015612c3057600080fd5b505192915050565b600060026000541415612c80576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b6002600055612c8d614b95565b612c9688614bb1565b612ca588888888888888615189565b600160005598975050505050505050565b60236020526000908152604090205481565b612cd0614ae2565b6001600160a01b03909116600090815260276020526040902055565b600060026000541415612d34576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b6002600055612d41614599565b6001600160a01b0383166000908152601c6020526040902054612d689060ff1660106145ca565b6016805461ff0019166101001790556000612d8284614676565b9050612d926000821160116145ca565b612d9c8485614211565b6000612da785612b8d565b90506000612dc568327cb2734119d3b7a9601e1b61182e8585614501565b600554909150612de190829088906001600160a01b031661201b565b9050612df16000821160126145ca565b60015460408051630f1e2bb760e31b81526001600160a01b03898116600483015260248201859052915160009363010000009004909216916378f15db891604480820192602092909190829003018186803b158015612e4f57600080fd5b505afa158015612e63573d6000803e3d6000fd5b505050506040513d6020811015612e7957600080fd5b505190506000612e8a888684614973565b90506000612ea868327cb2734119d3b7a9601e1b61182e8488614501565b600554909150612ec49082908b906001600160a01b031661201b565b9050612ed0898261564c565b612eda8983614fb9565b600554604080516340c10f1960e01b81526001600160a01b038b8116600483015260248201859052915191909216916340c10f1991604480830192600092919082900301818387803b158015612f2f57600080fd5b505af1158015612f43573d6000803e3d6000fd5b5050604080516001600160a01b03808d1682528d1660208201528082018a9052606081018590526080810187905290517f2de7e0046c51567d81afaeb29981b87a4470ca1496850cdae633a300d1f9be5193509081900360a0019150a16016805461ff0019169055600160005598975050505050505050565b601e6020526000908152604090205481565b612fd6614ae2565b612fe6610e10841015600a6145ca565b612ff6612710831115600b6145ca565b613006612710821115600c6145ca565b601292909255601355601455565b602d6020526000908152604090205481565b601d6020526000908152604090205481565b613040614ae2565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b60165462010000900460ff1681565b6000600260005414156130b9576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b60026000556001546130d490610100900460ff1660176145ca565b6001600160a01b0384166000908152601c60205260409020546130fb9060ff1660186145ca565b6001600160a01b0383166000908152601c60205260409020546131229060ff1660196145ca565b613142836001600160a01b0316856001600160a01b03161415601a6145ca565b6016805461ff00191661010017905561315b8480614211565b6131658384614211565b600061317085614676565b905061318060008211601b6145ca565b600061318b86612b8d565b9050600061319886613f80565b905060006131aa8261182e8686614501565b90506131b781898961201b565b905060006131d568327cb2734119d3b7a9601e1b61182e8787614501565b6005549091506131f19082908b906001600160a01b031661201b565b60015460408051636d099c0b60e11b81526001600160a01b038d811660048301528c8116602483015260448201859052915193945060009363010000009093049091169163da13381691606480820192602092909190829003018186803b15801561325b57600080fd5b505afa15801561326f573d6000803e3d6000fd5b505050506040513d602081101561328557600080fd5b5051905060006132968a8584614973565b90506132a28b8461564c565b6132ac8a84614723565b6132b68b88614fb9565b6132c08a85614805565b6132c98a61570a565b6132d48a828b614a3b565b604080516001600160a01b03808c168252808e1660208301528c1681830152606081018990526080810186905260a0810183905260c0810184905290517f0874b2d545cb271cdbda4e093020c452328b24af12382ed62c4d00f5c26709db9181900360e00190a16016805461ff001916905560016000559a9950505050505050505050565b68327cb2734119d3b7a9601e1b81565b602f6020526000908152604090205481565b60125481565b60008161339057506000611b35565b6120b6838361339e86613f80565b6141d7565b60246020526000908152604090205481565b6001600160a01b0383166000908152602d6020908152604080832054602e909252822054828582116133f0576133eb8683614b53565b6133fa565b6133fa8287614b53565b9050600061340c8361182e8685614501565b9050868311600061341d8689614afb565b9050600082613435576134308285614afb565b61343f565b61343f8285614b53565b905061344f8161182e8c85614501565b9b9a5050505050505050505050565b60115460ff1681565b600d5481565b60008161347c57506000611b35565b6120b6838361339e86612b8d565b613492614ae2565b6001600160a01b03919091166000908152601a60205260409020805460ff1916911515919091179055565b6012546001600160a01b0382166000908152602a6020526040812054909142916134e691614afb565b11156134f457506000611838565b6012546001600160a01b0383166000908152602a602052604081205490916135219161182e904290614b53565b6001600160a01b0384166000908152602560205260409020549091508061354d57600092505050611838565b6001600160a01b0384166000908152601f602052604081205460ff1661357557601354613579565b6014545b6001600160a01b0386166000908152602660205260409020549091506135b290839061182e9086906135ac908690614501565b90614501565b95945050505050565b60165460ff1681565b60226020526000908152604090205481565b60085481565b601654610100900460ff1681565b6001600160a01b0381166000908152601f602052604081205460ff161561362a57506001600160a01b038116600090815260256020526040902054611838565b6001600160a01b03821660009081526028602052604081205461364e908490613381565b6001600160a01b03841660009081526026602090815260408083205460259092529091205491925061183491613685908490614afb565b90614b53565b6001546040805163b1cc53ab60e01b81526001600160a01b038681166004830152858116602483015284151560448301529151600093630100000090049092169163b1cc53ab91606480820192602092909190829003018186803b1580156136f257600080fd5b505afa158015613706573d6000803e3d6000fd5b505050506040513d602081101561371c57600080fd5b5051949350505050565b6001600160a01b0381166000908152602d60205260408120548190806137535760008092509250506137b9565b600061375e85613f80565b6001600160a01b0386166000908152602e60205260408120549192508282116137905761378b8383614b53565b61379a565b61379a8284614b53565b905060006137ac8361182e8785614501565b9390921195509193505050505b915091565b60266020526000908152604090205481565b60135481565b60296020526000908152604090205481565b6001546040805163c7e074c360e01b81526001600160a01b03888116600483015260248201889052604482018790526064820186905284151560848301529151600093630100000090049092169163c7e074c39160a480820192602092909190829003018186803b15801561385c57600080fd5b505afa158015613870573d6000803e3d6000fd5b505050506040513d602081101561388657600080fd5b50519695505050505050565b61389a614ae2565b6138ae6001600160a01b038316848361577f565b505050565b6138bb614ae2565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6138e5614ae2565b601755565b6138f2614ae2565b613901612710821160026145ca565b600855565b61390e614ae2565b6001600160a01b03821660009081526023602052604090205480821115613948576139428361393d8484614b53565b61564c565b5061395b565b6138ae836139568385614b53565b614723565b5050565b6001546040805163d54d5a9f60e01b81526001600160a01b03888116600483015287811660248301528681166044830152851515606483015284151560848301528251600094859463010000009091049092169263d54d5a9f9260a4808301939192829003018186803b1580156139d557600080fd5b505afa1580156139e9573d6000803e3d6000fd5b505050506040513d60408110156139ff57600080fd5b508051602090910151909890975095505050505050565b602a6020526000908152604090205481565b60105481565b6001546040805163369d949360e21b81526001600160a01b0389811660048301528881166024830152878116604483015286151560648301526084820186905260a482018590529151600093630100000090049092169163da76524c9160c480820192602092909190829003018186803b158015613aab57600080fd5b505afa158015613abf573d6000803e3d6000fd5b505050506040513d6020811015613ad557600080fd5b5051979650505050505050565b601c6020526000908152604090205460ff1681565b602080526000908152604090205460ff1681565b6000806000613b1d8a8a8a8a88612821565b90925090506000613b2e8a87614afb565b905060008815613b5d5783613b4c57613b478284614b53565b613b56565b613b568284614afb565b9050613b7e565b83613b7157613b6c8284614afb565b613b7b565b613b7b8284614b53565b90505b613b8c8161182e8a85614501565b9c9b505050505050505050505050565b60155481565b60026000541415613be8576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b60026000556016546301000000900460ff1615613c1d5733600090815260196020526040902054613c1d9060ff1660226145ca565b6016805460ff19169055613c318484614211565b6000613c3f86868686611cb0565b9050613c49615e9a565b506000818152602b6020908152604091829020825160e08101845281548082526001830154938201939093526002820154938101939093526003810154606084015260048101546080840152600581015460a08401526006015460c0830152613cb590151560236145ca565b600080613cc689898989600061395f565b91509150613cd9826000141560246145ca565b8160021415613d0e57613cf6898989600087600001518b8f615189565b50506016805460ff1916600117905550613f6e915050565b6000613d1a8983613381565b6001600160a01b038a166000908152602c6020526040902054909150613d409082614afb565b6001600160a01b038a166000818152602c602090815260409182902093909355805191825291810184905280820183905290517f5d0c0019d3d45fadeb74eff9d2c9924d146d000ac6bcf3c28bf0ac3c9baa011a9181900360600190a1613dab8985608001516157d1565b8615613dda5760208401518451613dcc918b91613dc791614b53565b614f3a565b613dda896124648b85613381565b600087613def57613dea89613f80565b613df8565b613df889612b8d565b90507f2e1f85a64a2f22cf2f0c42584e7c919ed4abe8d53675cff0f62bf1e95a1c676f868c8c8c8c8a600001518b602001518c608001518d60a001518a604051808b81526020018a6001600160a01b03168152602001896001600160a01b03168152602001886001600160a01b0316815260200187151581526020018681526020018581526020018481526020018381526020018281526020019a505050505050505050505060405180910390a187158015613eb75750846020015183105b15613ee5576020850151600090613ece9085614b53565b9050613ee38b613ede8d84613381565b614fb9565b505b87613ef857613ef8898660000151615886565b6000868152602b60205260408120818155600181018290556002810182905560038101829055600481018290556005810182905560060155600954613f44908b90612464908290613381565b613f5a8a613f548c600954613381565b89614a3b565b50506016805460ff19166001179055505050505b50506001600055505050565b600e5481565b60048054601654604080516317e1d38560e11b81526001600160a01b03868116958201959095526001602482015260ff80841615156044830152610100909304909216151560648301525160009390921691632fc3a70a91608480820192602092909190829003018186803b158015612c0657600080fd5b601b818154811061400557fe5b6000918252602090912001546001600160a01b0316905081565b614027614ae2565b6001600160a01b0381166000908152601c602052604090205461404e9060ff16600d6145ca565b6001600160a01b03811660009081526022602052604090205460155461407391614b53565b6015556001600160a01b0381166000908152601c60209081526040808320805460ff19908116909155601d835281842084905560228352818420849055601e835281842084905560248352818420849055601f8352818420805482169055918052909120805490911690556007546140ec906001614b53565b60075550565b6005546001600160a01b031681565b614109614ae2565b6001600160a01b039091166000908152602f6020526040902055565b60286020526000908152604090205481565b61413f614ae2565b6016805491151563010000000263ff00000019909216919091179055565b6000614167614ae2565b6001600160a01b0383166000908152602c60205260409020548061418f576000915050611b35565b6001600160a01b0384166000908152602c60205260408120556120b6848285614a3b565b601a6020526000908152604090205460ff1681565b6003546001600160a01b031681565b6000826141e6575060006120b6565b6001600160a01b0384166000908152601d60205260409020546135b28361182e86600a85900a614501565b6001546040805163fbfded6d60e01b81526001600160a01b03858116600483015284811660248301529151600093630100000090049092169163fbfded6d9160448082019260209290919082900301818787803b15801561427157600080fd5b505af1158015614285573d6000803e3d6000fd5b505050506040513d602081101561429b57600080fd5b50519050806142aa575061395b565b6001600160a01b0383166000908152602a60205260409020546142f7576012546142d8906135ac428261455a565b6001600160a01b0384166000908152602a60205260409020555061395b565b6012546001600160a01b0384166000908152602a6020526040902054429161431f9190614afb565b111561432b575061395b565b6000614336846134bd565b6001600160a01b03851660009081526029602052604090205490915061435c9082614afb565b6001600160a01b038516600090815260296020526040902055601254614386906135ac428261455a565b6001600160a01b0385166000818152602a602090815260408083209490945560298152908390205483519283529082015281517fa146fc154e1913322e9817d49f0d5c37466c24326e15de10e739a948be815eab929181900390910190a150505050565b610e1081565b6001546040805163fdaf6ac360e01b81526001600160a01b038881166004830152878116602483015286811660448301528515156064830152608482018590529151600093630100000090049092169163fdaf6ac39160a480820192602092909190829003018186803b15801561385c57600080fd5b60306020908152600091825260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156144f95780601f106144ce576101008083540402835291602001916144f9565b820191906000526020600020905b8154815290600101906020018083116144dc57829003601f168201915b505050505081565b60008261451057506000611b35565b8282028284828161451d57fe5b04146120b65760405162461bcd60e51b8152600401808060200182810382526021815260200180615f0d6021913960400191505060405180910390fd5b60006120b683836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b8152506158ee565b60165462010000900460ff16156145c857336000908152601a60205260409020546145c89060ff1660366145ca565b565b6000818152603060205260409020826138ae5760405162461bcd60e51b81526020600482019081528254600260001961010060018416150201909116046024830181905290918291604490910190849080156146675780601f1061463c57610100808354040283529160200191614667565b820191906000526020600020905b81548152906001019060200180831161464a57829003601f168201915b50509250505060405180910390fd5b6001600160a01b03811660008181526021602090815260408083205481516370a0823160e01b8152306004820152915193949093859391926370a08231926024808301939192829003018186803b1580156146d057600080fd5b505afa1580156146e4573d6000803e3d6000fd5b505050506040513d60208110156146fa57600080fd5b50516001600160a01b03851660009081526021602052604090208190559050611df98183614b53565b6001600160a01b03821660009081526023602052604090205481811161479e576001600160a01b0383166000818152602360209081526040808320929092558151928352820183905280517f4cd0095bd565d45488212267145f37c5a223186512b169e04f24bc12a4f6b3079281900390910190a15061395b565b6147a88183614b53565b6001600160a01b03841660008181526023602090815260409182902093909355805191825291810184905281517f4cd0095bd565d45488212267145f37c5a223186512b169e04f24bc12a4f6b307929181900390910190a1505050565b604080518082018252601a81527915985d5b1d0e881c1bdbdb105b5bdd5b9d08195e18d95959195960321b6020808301919091526001600160a01b03851660009081526025909152919091205461485d918390615990565b6001600160a01b0383166000908152602560209081526040808320849055602690915290205461489091101560326145ca565b604080516001600160a01b03841681526020810183905281517f112726233fbeaeed0f5b1dba5cb0b2b81883dee49fb35ff99fd98ed9f6d31eb0929181900390910190a15050565b6000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561492757600080fd5b505afa15801561493b573d6000803e3d6000fd5b505050506040513d602081101561495157600080fd5b50516001600160a01b0390921660009081526021602052604090209190915550565b60008061499061271061182e6149898287614b53565b8790614501565b9050600061499e8583614b53565b6001600160a01b0387166000908152602c60205260409020549091506149c49082614afb565b6001600160a01b0387166000908152602c60205260409020557f47cd9dda0e50ce30bcaaacd0488452b596221c07ac402a581cfae4d3933cac2b86614a098184611ae8565b604080516001600160a01b0390931683526020830191909152818101849052519081900360600190a150949350505050565b614a4f6001600160a01b038416828461577f565b604080516370a0823160e01b815230600482015290516001600160a01b038516916370a08231916024808301926020929190829003018186803b158015614a9557600080fd5b505afa158015614aa9573d6000803e3d6000fd5b505050506040513d6020811015614abf57600080fd5b50516001600160a01b039093166000908152602160205260409020929092555050565b6006546145c8906001600160a01b0316331460356145ca565b6000828201838110156120b6576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b60006120b683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250615990565b601754614ba1576145c8565b6145c86017543a111560376145ca565b336001600160a01b0382161415614bc757614c11565b6003546001600160a01b0316331415614bdf57614c11565b6001600160a01b0381166000908152601860209081526040808320338452909152902054614c119060ff1660296145ca565b50565b8015614c8d57614c39826001600160a01b0316846001600160a01b031614602a6145ca565b6001600160a01b0383166000908152601c6020526040902054614c609060ff16602b6145ca565b6001600160a01b0383166000908152601f6020526040902054614c889060ff1615602c6145ca565b6138ae565b6001600160a01b0383166000908152601c6020526040902054614cb49060ff16602d6145ca565b6001600160a01b0383166000908152601f6020526040902054614cdb9060ff16602e6145ca565b6001600160a01b0382166000908152601f6020526040902054614d039060ff1615602f6145ca565b6001600160a01b03821660009081526020805260409020546138ae9060ff1660306145ca565b600080614d3989898989896143f0565b90506000614d4b8a8a8a8a8989613a2e565b9050614d578282614afb565b91506000614d658a84613381565b6001600160a01b038b166000908152602c6020526040902054909150614d8b9082614afb565b6001600160a01b038b166000818152602c602090815260409182902093909355805191825291810185905280820183905290517f5d0c0019d3d45fadeb74eff9d2c9924d146d000ac6bcf3c28bf0ac3c9baa011a9181900360600190a150909998505050505050505050565b81614e0d57614e08811560276145ca565b61395b565b61395b8183101560286145ca565b6001600160a01b038216600090815260266020526040902054614e3e9082614afb565b6001600160a01b038316600090815260266020818152604080842085905560258252909220549152614e7391111560346145ca565b604080516001600160a01b03841681526020810183905281517faa5649d82f5462be9d19b0f2b31a59b2259950a6076550bac9f3a1c07db9f66d929181900390910190a15050565b6001600160a01b038216600090815260286020526040902054614ede9082614afb565b6001600160a01b03831660008181526028602090815260409182902093909355805191825291810183905281517fd9d4761f75e0d0103b5cbeab941eeb443d7a56a35b5baf2a0787c03f03f4e474929181900390910190a15050565b6001600160a01b038216600090815260286020526040902054614f5d9082614b53565b6001600160a01b03831660008181526028602090815260409182902093909355805191825291810183905281517f34e07158b9db50df5613e591c44ea2ebc82834eff4a4dc3a46e000e608261d68929181900390910190a15050565b6001600160a01b038216600090815260256020526040902054614fdc9082614afb565b6001600160a01b03831660008181526025602090815260408083209490945583516370a0823160e01b8152306004820152935191936370a082319260248083019392829003018186803b15801561503257600080fd5b505afa158015615046573d6000803e3d6000fd5b505050506040513d602081101561505c57600080fd5b50516001600160a01b0384166000908152602560205260409020549091506150889082101560316145ca565b604080516001600160a01b03851681526020810184905281517f976177fbe09a15e5e43f848844963a42b41ef919ef17ff21a17a5421de8f4737929181900390910190a1505050565b6001600160a01b0382166000908152602d60205260409020546150f49082614afb565b6001600160a01b0383166000908152602d6020908152604080832093909355602f9052205480156138ae576001600160a01b0383166000908152602d60205260409020548110156138ae576040805162461bcd60e51b815260206004820152601a60248201527915985d5b1d0e881b585e081cda1bdc9d1cc8195e18d95959195960321b604482015290519081900360640190fd5b600154604080516381d11a2360e01b81526001600160a01b038a8116600483015289811660248301528881166044830152606482018890526084820187905285151560a483015284811660c4830152915160009363010000009004909216916381d11a239160e4808201928692909190829003018186803b15801561520d57600080fd5b505afa158015615221573d6000803e3d6000fd5b5050505061522f8787614211565b600061523d89898987611cb0565b6000818152602b6020526040902080549192509061525e901515601f6145ca565b615270868260000154101560206145ca565b615282878260010154101560216145ca565b60018101548154600483015460009161529f9161182e908b614501565b60048401549091506152b19082614b53565b60048401556152c08b826157d1565b506000806152d28d8d8d8d8d8d6159ea565b855491935091508914615476576152ea8c8c8a61368b565b600385015583546152fb908a614b53565b808555600185015461530d9190614df7565b61531b8d8d8d8b600161395f565b505087156153485761533e8c61243d866001015486614b5390919063ffffffff16565b6153488c8a614f3a565b60008861535d576153588c613f80565b615366565b6153668c612b8d565b90507f93d75d64d1f84fc6f430a64fc578bdd4c1e090e90ea2d51773e626d19de56d30868f8f8f8f8f8f8861539b8c8c614b53565b60408051998a526001600160a01b0398891660208b015296881689880152949096166060880152608087019290925260a0860152151560c085015260e084019290925261010083019190915251908190036101200190a18454600186015460028701546003880154600489015460058a0154604080518d81526020810197909752868101959095526060860193909352608085019190915260a084015260c083015260e08201839052517f20853733b590dce729d9f4628682ebd9a34d2354e72679e66f43a008fc03b773918190036101000190a1506155ea565b8715615490576154868c84614ebb565b6154908c8a614f3a565b6000886154a5576154a08c613f80565b6154ae565b6154ae8c612b8d565b90507f93d75d64d1f84fc6f430a64fc578bdd4c1e090e90ea2d51773e626d19de56d30868f8f8f8f8f8f886154e38c8c614b53565b60408051998a526001600160a01b0398891660208b015296881689880152949096166060880152608087019290925260a0860152151560c085015260e084019290925261010083019190915251908190036101200190a18454600186015460028701546003880154600489015460058a0154604080518d81526020810197909752868101959095526060860193909352608085019190915260a084015260c0830152517f73af1d417d82c240fdb6d319b34ad884487c6bf2845d98980cc52ad9171cb4559181900360e00190a1506000858152602b602052604081208181556001810182905560028101829055600381018290556004810182905560058101829055600601555b876155f9576155f98b8a615886565b8115615639578715615613576156138c6124648e85613381565b600061561f8d83613381565b905061562c8d828a614a3b565b95506127dd945050505050565b5060009c9b505050505050505050505050565b6001600160a01b03821660009081526023602052604090205461566f9082614afb565b6001600160a01b03831660009081526023602090815260408083209390935560249052205480156156c1576001600160a01b0383166000908152602360205260409020546156c19082101560336145ca565b604080516001600160a01b03851681526020810184905281517f8734a535d62699174c322d74d291c6053308a8caf79759684f44851562dc5cce929181900390910190a1505050565b6001600160a01b0381166000908152602760209081526040808320546025909252909120541015614c11576040805162461bcd60e51b815260206004820152601a6024820152792b30bab63a1d103837b7b620b6b7bab73a101e10313ab33332b960311b604482015290519081900360640190fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526138ae908490615be4565b604080518082018252601b81527a5661756c743a20696e73756666696369656e74207265736572766560281b6020808301919091526001600160a01b03851660009081526026909152919091205461582a918390615990565b6001600160a01b03831660008181526026602090815260409182902093909355805191825291810183905281517f533cb5ed32be6a90284e96b5747a1bfc2d38fdb5768a6b5f67ff7d62144ed67b929181900390910190a15050565b6001600160a01b0382166000908152602d6020526040902054808211156158c657506001600160a01b0382166000908152602d602052604081205561395b565b6158d08183614b53565b6001600160a01b0384166000908152602d6020526040902055505050565b6000818361597a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561593f578181015183820152602001615927565b50505050905090810190601f16801561596c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161598657fe5b0495945050505050565b600081848411156159e25760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561593f578181015183820152602001615927565b505050900390565b60008060006159fb89898987611cb0565b6000818152602b60205260408120805460038201549394509092615a28918d918d918d918b918d91614d29565b9050600080600080615a498d876000015488600201548d8a60060154612821565b87549195508593509150615a619061182e8d84614501565b925050506000828015615a745750600082115b15615aa45750600584018054820190558088615aa4576000615a968e84613381565b9050615aa28e82614805565b505b82158015615ab25750600082115b15615af6576001850154615ac69083614b53565b600186015588615aea576000615adc8e84613381565b9050615ae88e82614fb9565b505b60058501805483900390555b8a15615b1e57615b06818c614afb565b6001860154909150615b18908c614b53565b60018601555b84548a1415615b41576001850154615b37908290614afb565b6000600187015590505b8084811115615b5b57615b548286614b53565b9050615b8f565b6001860154615b6a9086614b53565b60018701558915615b8f576000615b818f87613381565b9050615b8d8f82614805565b505b60408051888152851515602082015280820185905290517f3ff41bdde87755b687ae83d0221a232b6be51a803330ed9661c1b5d0105e0d8a9181900360600190a1909e909d509b505050505050505050505050565b6060615c39826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316615c959092919063ffffffff16565b8051909150156138ae57808060200190516020811015615c5857600080fd5b50516138ae5760405162461bcd60e51b815260040180806020018281038252602a815260200180615f2e602a913960400191505060405180910390fd5b6060611df9848460008585615ca985615db0565b615cfa576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310615d395780518252601f199092019160209182019101615d1a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114615d9b576040519150601f19603f3d011682016040523d82523d6000602084013e615da0565b606091505b50915091506127dd828286615db6565b3b151590565b60608315615dc55750816120b6565b825115615dd55782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561593f578181015183820152602001615927565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10615e5d5782800160ff19823516178555615e8a565b82800160010185558215615e8a579182015b82811115615e8a578235825591602001919060010190615e6f565b50615e96929150615ed7565b5090565b6040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b5b80821115615e965760008155600101615ed856fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220ce3a288a0fdbcd3422bb45d1fa6e1c11dab973f76592c664c7bac534653edb5764736f6c634300060c0033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106106095760003560e01c80638585f4d211610329578063c7e074c3116101af578063df73a26711610105578063f2555278116100a8578063f255527814611640578063f3ae24151461166e578063f887ea4014611694578063fa12dbc01461169c578063fbfded6d146116ce578063fce28c10146116fc578063fdaf6ac314611704578063fed1a6061461174857610609565b8063df73a26714611556578063e124e6d21461155e578063e468baf014611584578063e67f59a7146115a1578063ee138d0f146115c7578063efa10a6e146115cf578063f07456ce146115fb578063f07bbf771461162157610609565b8063c7e074c314611295578063cea0c328146112d5578063cfad57a21461130b578063d2fa635e14611331578063d3127e631461134e578063d45200d11461136b578063d54d5a9f14611397578063d8f897c3146113f6578063d9ac42251461141c578063da76524c14611424578063daf9c2101461146e578063db3555fb14611494578063db97495f146114ba578063dc8f5fac14611506578063de2ea9481461150e57610609565b80639d7432ca1161027f578063ae3302c211610222578063ae3302c2146111ad578063b06423f3146111b5578063b136ca49146111bd578063b1cc53ab146111e3578063b364accb1461121b578063c3c7b9e914611241578063c4f718bf14611267578063c65bc7b11461126f57610609565b80639d7432ca146110bd5780639f392eb3146110ef578063a22f2392146110f7578063a42ab3d2146110ff578063a5e90eee1461112b578063a93acac214611159578063ab08c1c61461117f578063ab2f3ad41461118757610609565b80638585f4d214610eda57806386284f5f14610f0657806388b1fbdf14610f345780638a27d46814610f5a5780638a39735a146106b85780638a78daa814610f835780638ee573ac14610fa95780638f7b840414610fcf5780639060b1ca14610ff55780639331621214610ffd57806395082d25146110355780639698d25a1461103d5780639849e412146110635780639899cd021461106b5780639acc6b331461109757610609565b806342b60b03116104ae5780635f7bc11911610404578063724e78da116103a7578063724e78da14610d9d578063728cdbca14610dc3578063741bef1a14610e0b5780637a210a2b14610e135780637c2eb9f714610e1b57806381a612d614610e3a57806382a0849014610e6057806383867b2d14610eb457610609565b80635f7bc11914610cbf5780636092219914610ce557806362287a3214610d135780636274980314610d1b5780636abbe0c814610d415780636ae0b15414610d495780636be6026b14610d6f57806371089f4d14610d7757610609565b806342b60b03146109ca5780634453a374146109f057806345a6f37014610a1e57806348d91abf14610a7757806348f35cbb14610abb5780634a3f088d14610ac35780634a993ee914610b445780634befe2ca14610b6a5780634d47b30414610b72578063514ea4bf14610b7a57806351723e8214610bcf578063523fba7f14610c0d578063529a356f14610c3357806352f55eed14610c595780635c07eaab14610c7f57610609565b806329ff96151161056357806329ff9615146107f25780632c668ec1146108185780632d4b057614610844578063302a81411461088257806330455ede1461088a578063318bc689146108a957806334c1557d146106b8578063351a964d146108b157806337af6e7e146108b9578063392e53cd146108df5780633c5a6e35146108e75780633de39c11146109355780633e72a2621461093d57806340eb380214610945578063421528731461099657610609565b806304fef1db1461060e57806307c58752146106465780630842b0761461064e5780630928a4f8146106565780630a48d5a91461068457806310eb56c2146106b0578063126082cf146106b857806312d43a51146106c0578063134ca63b146106e4578063174d2694146106ec578063181e210e146106f45780631ce9cb8f1461071057806324b0c04d1461073657806324ca984e1461075757806328e67be51461077d575b600080fd5b6106346004803603602081101561062457600080fd5b50356001600160a01b03166117da565b60408051918252519081900360200190f35b61063461183d565b61063461184e565b6106346004803603604081101561066c57600080fd5b506001600160a01b0381358116916020013516611854565b6106346004803603604081101561069a57600080fd5b506001600160a01b038135169060200135611ae8565b610634611b3b565b610634611b41565b6106c8611b47565b604080516001600160a01b039092168252519081900360200190f35b610634611b56565b610634611b5c565b6106fc611b62565b604080519115158252519081900360200190f35b6106346004803603602081101561072657600080fd5b50356001600160a01b0316611b72565b6107556004803603602081101561074c57600080fd5b50351515611b84565b005b6107556004803603602081101561076d57600080fd5b50356001600160a01b0316611ba8565b6107556004803603604081101561079357600080fd5b81359190810190604081016020820135600160201b8111156107b457600080fd5b8201836020820111156107c657600080fd5b803590602001918460018302840111600160201b831117156107e757600080fd5b509092509050611bd9565b6106346004803603602081101561080857600080fd5b50356001600160a01b0316611c57565b6106346004803603604081101561082e57600080fd5b506001600160a01b038135169060200135611c6b565b6106346004803603608081101561085a57600080fd5b506001600160a01b038135811691602081013582169160408201351690606001351515611cb0565b610634611d06565b610755600480360360208110156108a057600080fd5b50351515611d0b565b610634611d2d565b6106fc611d33565b610634600480360360208110156108cf57600080fd5b50356001600160a01b0316611d41565b6106fc611e01565b610755600480360360e08110156108fd57600080fd5b506001600160a01b038135169060208101359060408101359060608101359060808101359060a081013515159060c001351515611e0a565b610634611f4c565b6106fc611f52565b610755600480360361012081101561095c57600080fd5b5080359060208101359060408101359060608101359060808101359060a08101359060c08101359060e08101359061010001351515611f61565b610634600480360360608110156109ac57600080fd5b508035906001600160a01b036020820135811691604001351661201b565b6106fc600480360360208110156109e057600080fd5b50356001600160a01b03166120bd565b61075560048036036040811015610a0657600080fd5b506001600160a01b03813516906020013515156120d2565b610a5c60048036036080811015610a3457600080fd5b506001600160a01b038135811691602081013582169160408201351690606001351515612105565b60408051921515835260208301919091528051918290030190f35b610755600480360360a0811015610a8d57600080fd5b506001600160a01b0381358116916020810135821691604082013516906060810135906080013515156121a3565b6106c86125e2565b610b0160048036036080811015610ad957600080fd5b506001600160a01b0381358116916020810135821691604082013516906060013515156125f1565b604080519889526020890197909752878701959095526060870193909352608086019190915260a0850152151560c084015260e083015251908190036101000190f35b61063460048036036020811015610b5a57600080fd5b50356001600160a01b03166126e7565b6106346126f9565b6106346126ff565b610b9760048036036020811015610b9057600080fd5b5035612705565b604080519788526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b61063460048036036080811015610be557600080fd5b506001600160a01b038135811691602081013582169160408201351690606001351515612742565b61063460048036036020811015610c2357600080fd5b50356001600160a01b03166127e8565b6106fc60048036036020811015610c4957600080fd5b50356001600160a01b03166127fa565b61063460048036036020811015610c6f57600080fd5b50356001600160a01b031661280f565b610a5c600480360360a0811015610c9557600080fd5b506001600160a01b0381351690602081013590604081013590606081013515159060800135612821565b61075560048036036020811015610cd557600080fd5b50356001600160a01b0316612919565b6106fc60048036036040811015610cfb57600080fd5b506001600160a01b03813581169160200135166129fc565b610634612a1c565b61063460048036036020811015610d3157600080fd5b50356001600160a01b0316612a22565b6106c8612a34565b61075560048036036020811015610d5f57600080fd5b50356001600160a01b0316612a4a565b610634612a78565b61075560048036036020811015610d8d57600080fd5b50356001600160a01b0316612a7f565b61075560048036036020811015610db357600080fd5b50356001600160a01b0316612ab3565b610755600480360360c0811015610dd957600080fd5b506001600160a01b03813581169160208101358216916040820135169060608101359060808101359060a00135612add565b6106c8612b54565b610634612b63565b61075560048036036020811015610e3157600080fd5b50351515612b69565b61063460048036036020811015610e5057600080fd5b50356001600160a01b0316612b8d565b610634600480360360e0811015610e7657600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101359160808201359160a081013515159160c09091013516612c38565b61063460048036036020811015610eca57600080fd5b50356001600160a01b0316612cb6565b61075560048036036040811015610ef057600080fd5b506001600160a01b038135169060200135612cc8565b61063460048036036040811015610f1c57600080fd5b506001600160a01b0381358116916020013516612cec565b61063460048036036020811015610f4a57600080fd5b50356001600160a01b0316612fbc565b61075560048036036060811015610f7057600080fd5b5080359060208101359060400135612fce565b61063460048036036020811015610f9957600080fd5b50356001600160a01b0316613014565b61063460048036036020811015610fbf57600080fd5b50356001600160a01b0316613026565b61075560048036036020811015610fe557600080fd5b50356001600160a01b0316613038565b6106fc613062565b6106346004803603606081101561101357600080fd5b506001600160a01b038135811691602081013582169160409091013516613071565b610634613359565b6106346004803603602081101561105357600080fd5b50356001600160a01b0316613369565b61063461337b565b6106346004803603604081101561108157600080fd5b506001600160a01b038135169060200135613381565b610634600480360360208110156110ad57600080fd5b50356001600160a01b03166133a3565b610634600480360360608110156110d357600080fd5b506001600160a01b0381351690602081013590604001356133b5565b6106fc61345e565b610634613467565b6106346004803603604081101561111557600080fd5b506001600160a01b03813516906020013561346d565b6107556004803603604081101561114157600080fd5b506001600160a01b038135169060200135151561348a565b6106346004803603602081101561116f57600080fd5b50356001600160a01b03166134bd565b6106fc6135bb565b6106346004803603602081101561119d57600080fd5b50356001600160a01b03166135c4565b6106346135d6565b6106fc6135dc565b610634600480360360208110156111d357600080fd5b50356001600160a01b03166135ea565b610634600480360360608110156111f957600080fd5b506001600160a01b03813581169160208101359091169060400135151561368b565b610a5c6004803603602081101561123157600080fd5b50356001600160a01b0316613726565b6106346004803603602081101561125757600080fd5b50356001600160a01b03166137be565b6106346137d0565b6106346004803603602081101561128557600080fd5b50356001600160a01b03166137d6565b610634600480360360a08110156112ab57600080fd5b506001600160a01b03813516906020810135906040810135906060810135906080013515156137e8565b610755600480360360608110156112eb57600080fd5b506001600160a01b03813581169160208101359091169060400135613892565b6107556004803603602081101561132157600080fd5b50356001600160a01b03166138b3565b6107556004803603602081101561134757600080fd5b50356138dd565b6107556004803603602081101561136457600080fd5b50356138ea565b6107556004803603604081101561138157600080fd5b506001600160a01b038135169060200135613906565b6113dd600480360360a08110156113ad57600080fd5b506001600160a01b038135811691602081013582169160408201351690606081013515159060800135151561395f565b6040805192835260208301919091528051918290030190f35b6106346004803603602081101561140c57600080fd5b50356001600160a01b0316613a16565b610634613a28565b610634600480360360c081101561143a57600080fd5b506001600160a01b038135811691602081013582169160408201351690606081013515159060808101359060a00135613a2e565b6106fc6004803603602081101561148457600080fd5b50356001600160a01b0316613ae2565b6106fc600480360360208110156114aa57600080fd5b50356001600160a01b0316613af7565b610634600480360360e08110156114d057600080fd5b506001600160a01b0381351690602081013590604081013590606081013515159060808101359060a08101359060c00135613b0b565b610634613b9c565b610755600480360360a081101561152457600080fd5b506001600160a01b03813581169160208101358216916040820135811691606081013515159160809091013516613ba2565b610634613f7a565b6106346004803603602081101561157457600080fd5b50356001600160a01b0316613f80565b6106c86004803603602081101561159a57600080fd5b5035613ff8565b610755600480360360208110156115b757600080fd5b50356001600160a01b031661401f565b6106c86140f2565b610755600480360360408110156115e557600080fd5b506001600160a01b038135169060200135614101565b6106346004803603602081101561161157600080fd5b50356001600160a01b0316614125565b6107556004803603602081101561163757600080fd5b50351515614137565b6106346004803603604081101561165657600080fd5b506001600160a01b038135811691602001351661415d565b6106fc6004803603602081101561168457600080fd5b50356001600160a01b03166141b3565b6106c86141c8565b610634600480360360608110156116b257600080fd5b506001600160a01b0381351690602081013590604001356141d7565b610755600480360360408110156116e457600080fd5b506001600160a01b0381358116916020013516614211565b6106346143ea565b610634600480360360a081101561171a57600080fd5b506001600160a01b0381358116916020810135821691604082013516906060810135151590608001356143f0565b6117656004803603602081101561175e57600080fd5b5035614466565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561179f578181015183820152602001611787565b50505050905090810190601f1680156117cc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6001600160a01b03811660009081526025602052604081205480611802576000915050611838565b6001600160a01b03831660009081526026602052604090205461183490829061182e90620f4240614501565b9061455a565b9150505b919050565b6904ee2d6d415b85acef8160201b81565b601b5490565b60006002600054141561189c576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b60026000556118a9614599565b6001600160a01b0383166000908152601c60205260409020546118d09060ff1660136145ca565b6016805461ff0019166101001790556005546000906118f7906001600160a01b0316614676565b90506119076000821160146145ca565b6119118485614211565b600061191d8583611c6b565b905061192d6000821160156145ca565b6119378583614723565b6119418582614805565b60055460408051632770a7eb60e21b81523060048201526024810185905290516001600160a01b0390921691639dc29fac9160448082019260009290919082900301818387803b15801561199457600080fd5b505af11580156119a8573d6000803e3d6000fd5b50506005546119c292506001600160a01b031690506148d8565b600154604080516310d5486360e21b81526001600160a01b0388811660048301526024820186905291516000936301000000900490921691634355218c91604480820192602092909190829003018186803b158015611a2057600080fd5b505afa158015611a34573d6000803e3d6000fd5b505050506040513d6020811015611a4a57600080fd5b505190506000611a5b878484614973565b9050611a6b6000821160166145ca565b611a76878288614a3b565b604080516001600160a01b03808916825289166020820152808201869052606081018390526080810184905290517f52eb5f5cb9a498f7cf35a2e264fbe42a9401185a0fd345d5d2c8932a2a45b1ae9181900360a00190a16016805461ff001916905560016000559695505050505050565b600081611af757506000611b35565b6000611b0284612b8d565b6001600160a01b0385166000908152601d6020526040902054909150611b30600a82900a61182e8685614501565b925050505b92915050565b600b5481565b61271081565b6006546001600160a01b031681565b60145481565b60095481565b6016546301000000900460ff1681565b602c6020526000908152604090205481565b611b8c614ae2565b60168054911515620100000262ff000019909216919091179055565b3360009081526018602090815260408083206001600160a01b0394909416835292905220805460ff19166001179055565b6002546001600160a01b03163314611c38576040805162461bcd60e51b815260206004820152601e60248201527f5661756c743a20696e76616c6964206572726f72436f6e74726f6c6c65720000604482015290519081900360640190fd5b6000838152603060205260409020611c51908383615e1c565b50505050565b6000611b3582611c66846135ea565b611ae8565b600080611c7784613f80565b90506000611c958261182e8668327cb2734119d3b7a9601e1b614501565b600554909150611b309082906001600160a01b03168761201b565b604080516001600160601b0319606096871b811660208084019190915295871b811660348301529390951b9092166048850152151560f81b605c8401528051603d818503018152605d9093019052815191012090565b601281565b611d13614ae2565b600180549115156101000261ff0019909216919091179055565b600f5481565b600154610100900460ff1681565b600080600560009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611d9257600080fd5b505afa158015611da6573d6000803e3d6000fd5b505050506040513d6020811015611dbc57600080fd5b5051905080611dcf576000915050611838565b6001600160a01b038316600090815260226020526040902054601554611df99061182e8385614501565b949350505050565b60015460ff1681565b611e12614ae2565b6001600160a01b0387166000908152601c602052604090205460ff16611e8f57600754611e40906001614afb565b600755601b80546001810182556000919091527f3ad8aa4f87544323a9d1e5dd902f40c356527a7955687113db5f9a85ad579dc10180546001600160a01b0319166001600160a01b0389161790555b6015546001600160a01b038816600090815260226020526040902054611eb6908290614b53565b6001600160a01b0389166000908152601c602090815260408083208054600160ff1991821617909155601d83528184208c9055602283528184208b9055601e83528184208a905560248352818420899055601f83528184208054821689151517905591805290912080549091168415151790559050611f358187614afb565b601555611f4188613f80565b505050505050505050565b60175481565b60015462010000900460ff1681565b611f69614ae2565b611f796101f48a111560036145ca565b611f896101f489111560046145ca565b611f996101f488111560056145ca565b611fa96101f487111560066145ca565b611fb96101f486111560076145ca565b611fc96101f485111560086145ca565b611fe46904ee2d6d415b85acef8160201b84111560096145ca565b600a98909855600b96909655600c94909455600d92909255600e55600f556009556010556011805460ff1916911515919091179055565b60055460009081906001600160a01b03858116911614612053576001600160a01b0384166000908152601d6020526040902054612056565b60125b6005549091506000906001600160a01b0385811691161461208f576001600160a01b0384166000908152601d6020526040902054612092565b60125b90506120b182600a0a61182e83600a0a8961450190919063ffffffff16565b925050505b9392505050565b601f6020526000908152604090205460ff1681565b6120da614ae2565b6001600160a01b03919091166000908152601960205260409020805460ff1916911515919091179055565b600080600061211687878787611cb0565b9050612120615e9a565b506000818152602b6020908152604091829020825160e081018452815480825260018301549382019390935260028201549381018490526003820154606082015260048201546080820152600582015460a082015260069091015460c0820181905290926121949289929091908990612821565b93509350505094509492505050565b600260005414156121e9576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b60026000556001546122059062010000900460ff16601c6145ca565b61220d614b95565b61221685614bb1565b612221848483614c14565b60015460408051634eae147d60e11b81526001600160a01b038881166004830152878116602483015286811660448301526064820186905284151560848301529151630100000090930490911691639d5c28fa9160a480820192600092909190829003018186803b15801561229557600080fd5b505afa1580156122a9573d6000803e3d6000fd5b505050506122b78484614211565b60006122c586868685611cb0565b6000818152602b60205260408120919250836122e9576122e486612b8d565b6122f2565b6122f286613f80565b825490915061230357600282018190555b8154158015906123135750600085115b1561233957612333868360000154846002015487858a8860060154613b0b565b60028301555b6000612352898989888a88600001548960030154614d29565b9050600061235f89614676565b9050600061236d8a83611ae8565b600186015490915061237f9082614afb565b6001860181905561239490841115601d6145ca565b60018501546123a39084614b53565b60018601556123b38a8a8961368b565b600386015584546123c49089614afb565b8086554260068701556123da901515601e6145ca565b6123ec85600001548660010154614df7565b6123fa8b8b8b8a600161395f565b505060006124088b8a61346d565b600487015490915061241a9082614afb565b60048701556124298b82614e1b565b871561246e576124428b61243d8b87614afb565b614ebb565b61244c8b83614f3a565b6124568b84614fb9565b6124698b6124648d87613381565b614805565b6124da565b6001600160a01b038a166000908152602d60205260409020546124ab576001600160a01b038a166000908152602e602052604090208590556124d0565b6124b68a868b6133b5565b6001600160a01b038b166000908152602e60205260409020555b6124da8a8a6150d1565b604080518881526001600160a01b03808f166020830152808e16828401528c1660608201526080810184905260a081018b905289151560c082015260e08101879052610100810186905290517f2fe68525253654c21998f35787a8d0f361905ef647c854092430ab65f2f15022918190036101200190a1855460018701546002880154600389015460048a015460058b0154604080518e81526020810197909752868101959095526060860193909352608085019190915260a084015260c083015260e08201879052517f20853733b590dce729d9f4628682ebd9a34d2354e72679e66f43a008fc03b773918190036101000190a15050600160005550505050505050505050565b6002546001600160a01b031681565b600080600080600080600080600061260b8d8d8d8d611cb0565b9050612615615e9a565b602b60008381526020019081526020016000206040518060e001604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482015481526020016005820154815260200160068201548152505090506000808260a0015113612695578160a0015160000361269b565b8160a001515b9050816000015182602001518360400151846060015185608001518560008860a0015112158860c001519a509a509a509a509a509a509a509a5050505094995094995094999196509450565b60276020526000908152604090205481565b6101f481565b600c5481565b602b602052600090815260409020805460018201546002830154600384015460048501546005860154600690960154949593949293919290919087565b60008061275186868686611cb0565b905061275b615e9a565b506000818152602b6020908152604091829020825160e0810184528154815260018201549281018390526002820154938101939093526003810154606084015260048101546080840152600581015460a08401526006015460c08301526127c590151560256145ca565b602081015181516127dd919061182e90612710614501565b979650505050505050565b60216020526000908152604090205481565b60196020526000908152604090205460ff1681565b60256020526000908152604090205481565b6000806128326000861160266145ca565b6000846128475761284288613f80565b612850565b61285088612b8d565b9050600081871161286a576128658288614b53565b612874565b6128748783614b53565b905060006128868861182e8b85614501565b905060008715612899575087831161289e565b508288115b60006128b560105489614afb90919063ffffffff16565b42116128d9576001600160a01b038c166000908152601e60205260409020546128dc565b60005b90508180156128ff57506128f08b82614501565b6128fc84612710614501565b11155b1561290957600092505b509a909950975050505050505050565b6002600054141561295f576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b600260009081556001600160a01b0382168152601c602052604090205461298a9060ff16600e6145ca565b600061299582614676565b90506129a560008211600f6145ca565b6129af8282614fb9565b604080516001600160a01b03841681526020810183905281517fa5a389190ebf6170a133bda5c769b77f4d6715b8aa172ec0ddf8473d0b4944bd929181900390910190a150506001600055565b601860209081526000928352604080842090915290825290205460ff1681565b60075481565b602e6020526000908152604090205481565b600154630100000090046001600160a01b031681565b3360009081526018602090815260408083206001600160a01b0394909416835292905220805460ff19169055565b620f424081565b612a87614ae2565b600180546001600160a01b039092166301000000026301000000600160b81b0319909216919091179055565b612abb614ae2565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b612ae5614ae2565b60018054612af99160ff90911615906145ca565b6001805460ff191681179055600380546001600160a01b03199081166001600160a01b039889161790915560058054821696881696909617909555600480549095169390951692909217909255600991909155601355601455565b6004546001600160a01b031681565b600a5481565b612b71614ae2565b60018054911515620100000262ff000019909216919091179055565b60048054601654604080516317e1d38560e11b81526001600160a01b038681169582019590955260006024820181905260ff80851615156044840152610100909404909316151560648201529051919390921691632fc3a70a916084808301926020929190829003018186803b158015612c0657600080fd5b505afa158015612c1a573d6000803e3d6000fd5b505050506040513d6020811015612c3057600080fd5b505192915050565b600060026000541415612c80576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b6002600055612c8d614b95565b612c9688614bb1565b612ca588888888888888615189565b600160005598975050505050505050565b60236020526000908152604090205481565b612cd0614ae2565b6001600160a01b03909116600090815260276020526040902055565b600060026000541415612d34576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b6002600055612d41614599565b6001600160a01b0383166000908152601c6020526040902054612d689060ff1660106145ca565b6016805461ff0019166101001790556000612d8284614676565b9050612d926000821160116145ca565b612d9c8485614211565b6000612da785612b8d565b90506000612dc568327cb2734119d3b7a9601e1b61182e8585614501565b600554909150612de190829088906001600160a01b031661201b565b9050612df16000821160126145ca565b60015460408051630f1e2bb760e31b81526001600160a01b03898116600483015260248201859052915160009363010000009004909216916378f15db891604480820192602092909190829003018186803b158015612e4f57600080fd5b505afa158015612e63573d6000803e3d6000fd5b505050506040513d6020811015612e7957600080fd5b505190506000612e8a888684614973565b90506000612ea868327cb2734119d3b7a9601e1b61182e8488614501565b600554909150612ec49082908b906001600160a01b031661201b565b9050612ed0898261564c565b612eda8983614fb9565b600554604080516340c10f1960e01b81526001600160a01b038b8116600483015260248201859052915191909216916340c10f1991604480830192600092919082900301818387803b158015612f2f57600080fd5b505af1158015612f43573d6000803e3d6000fd5b5050604080516001600160a01b03808d1682528d1660208201528082018a9052606081018590526080810187905290517f2de7e0046c51567d81afaeb29981b87a4470ca1496850cdae633a300d1f9be5193509081900360a0019150a16016805461ff0019169055600160005598975050505050505050565b601e6020526000908152604090205481565b612fd6614ae2565b612fe6610e10841015600a6145ca565b612ff6612710831115600b6145ca565b613006612710821115600c6145ca565b601292909255601355601455565b602d6020526000908152604090205481565b601d6020526000908152604090205481565b613040614ae2565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b60165462010000900460ff1681565b6000600260005414156130b9576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b60026000556001546130d490610100900460ff1660176145ca565b6001600160a01b0384166000908152601c60205260409020546130fb9060ff1660186145ca565b6001600160a01b0383166000908152601c60205260409020546131229060ff1660196145ca565b613142836001600160a01b0316856001600160a01b03161415601a6145ca565b6016805461ff00191661010017905561315b8480614211565b6131658384614211565b600061317085614676565b905061318060008211601b6145ca565b600061318b86612b8d565b9050600061319886613f80565b905060006131aa8261182e8686614501565b90506131b781898961201b565b905060006131d568327cb2734119d3b7a9601e1b61182e8787614501565b6005549091506131f19082908b906001600160a01b031661201b565b60015460408051636d099c0b60e11b81526001600160a01b038d811660048301528c8116602483015260448201859052915193945060009363010000009093049091169163da13381691606480820192602092909190829003018186803b15801561325b57600080fd5b505afa15801561326f573d6000803e3d6000fd5b505050506040513d602081101561328557600080fd5b5051905060006132968a8584614973565b90506132a28b8461564c565b6132ac8a84614723565b6132b68b88614fb9565b6132c08a85614805565b6132c98a61570a565b6132d48a828b614a3b565b604080516001600160a01b03808c168252808e1660208301528c1681830152606081018990526080810186905260a0810183905260c0810184905290517f0874b2d545cb271cdbda4e093020c452328b24af12382ed62c4d00f5c26709db9181900360e00190a16016805461ff001916905560016000559a9950505050505050505050565b68327cb2734119d3b7a9601e1b81565b602f6020526000908152604090205481565b60125481565b60008161339057506000611b35565b6120b6838361339e86613f80565b6141d7565b60246020526000908152604090205481565b6001600160a01b0383166000908152602d6020908152604080832054602e909252822054828582116133f0576133eb8683614b53565b6133fa565b6133fa8287614b53565b9050600061340c8361182e8685614501565b9050868311600061341d8689614afb565b9050600082613435576134308285614afb565b61343f565b61343f8285614b53565b905061344f8161182e8c85614501565b9b9a5050505050505050505050565b60115460ff1681565b600d5481565b60008161347c57506000611b35565b6120b6838361339e86612b8d565b613492614ae2565b6001600160a01b03919091166000908152601a60205260409020805460ff1916911515919091179055565b6012546001600160a01b0382166000908152602a6020526040812054909142916134e691614afb565b11156134f457506000611838565b6012546001600160a01b0383166000908152602a602052604081205490916135219161182e904290614b53565b6001600160a01b0384166000908152602560205260409020549091508061354d57600092505050611838565b6001600160a01b0384166000908152601f602052604081205460ff1661357557601354613579565b6014545b6001600160a01b0386166000908152602660205260409020549091506135b290839061182e9086906135ac908690614501565b90614501565b95945050505050565b60165460ff1681565b60226020526000908152604090205481565b60085481565b601654610100900460ff1681565b6001600160a01b0381166000908152601f602052604081205460ff161561362a57506001600160a01b038116600090815260256020526040902054611838565b6001600160a01b03821660009081526028602052604081205461364e908490613381565b6001600160a01b03841660009081526026602090815260408083205460259092529091205491925061183491613685908490614afb565b90614b53565b6001546040805163b1cc53ab60e01b81526001600160a01b038681166004830152858116602483015284151560448301529151600093630100000090049092169163b1cc53ab91606480820192602092909190829003018186803b1580156136f257600080fd5b505afa158015613706573d6000803e3d6000fd5b505050506040513d602081101561371c57600080fd5b5051949350505050565b6001600160a01b0381166000908152602d60205260408120548190806137535760008092509250506137b9565b600061375e85613f80565b6001600160a01b0386166000908152602e60205260408120549192508282116137905761378b8383614b53565b61379a565b61379a8284614b53565b905060006137ac8361182e8785614501565b9390921195509193505050505b915091565b60266020526000908152604090205481565b60135481565b60296020526000908152604090205481565b6001546040805163c7e074c360e01b81526001600160a01b03888116600483015260248201889052604482018790526064820186905284151560848301529151600093630100000090049092169163c7e074c39160a480820192602092909190829003018186803b15801561385c57600080fd5b505afa158015613870573d6000803e3d6000fd5b505050506040513d602081101561388657600080fd5b50519695505050505050565b61389a614ae2565b6138ae6001600160a01b038316848361577f565b505050565b6138bb614ae2565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b6138e5614ae2565b601755565b6138f2614ae2565b613901612710821160026145ca565b600855565b61390e614ae2565b6001600160a01b03821660009081526023602052604090205480821115613948576139428361393d8484614b53565b61564c565b5061395b565b6138ae836139568385614b53565b614723565b5050565b6001546040805163d54d5a9f60e01b81526001600160a01b03888116600483015287811660248301528681166044830152851515606483015284151560848301528251600094859463010000009091049092169263d54d5a9f9260a4808301939192829003018186803b1580156139d557600080fd5b505afa1580156139e9573d6000803e3d6000fd5b505050506040513d60408110156139ff57600080fd5b508051602090910151909890975095505050505050565b602a6020526000908152604090205481565b60105481565b6001546040805163369d949360e21b81526001600160a01b0389811660048301528881166024830152878116604483015286151560648301526084820186905260a482018590529151600093630100000090049092169163da76524c9160c480820192602092909190829003018186803b158015613aab57600080fd5b505afa158015613abf573d6000803e3d6000fd5b505050506040513d6020811015613ad557600080fd5b5051979650505050505050565b601c6020526000908152604090205460ff1681565b602080526000908152604090205460ff1681565b6000806000613b1d8a8a8a8a88612821565b90925090506000613b2e8a87614afb565b905060008815613b5d5783613b4c57613b478284614b53565b613b56565b613b568284614afb565b9050613b7e565b83613b7157613b6c8284614afb565b613b7b565b613b7b8284614b53565b90505b613b8c8161182e8a85614501565b9c9b505050505050505050505050565b60155481565b60026000541415613be8576040805162461bcd60e51b815260206004820152601f6024820152600080516020615eed833981519152604482015290519081900360640190fd5b60026000556016546301000000900460ff1615613c1d5733600090815260196020526040902054613c1d9060ff1660226145ca565b6016805460ff19169055613c318484614211565b6000613c3f86868686611cb0565b9050613c49615e9a565b506000818152602b6020908152604091829020825160e08101845281548082526001830154938201939093526002820154938101939093526003810154606084015260048101546080840152600581015460a08401526006015460c0830152613cb590151560236145ca565b600080613cc689898989600061395f565b91509150613cd9826000141560246145ca565b8160021415613d0e57613cf6898989600087600001518b8f615189565b50506016805460ff1916600117905550613f6e915050565b6000613d1a8983613381565b6001600160a01b038a166000908152602c6020526040902054909150613d409082614afb565b6001600160a01b038a166000818152602c602090815260409182902093909355805191825291810184905280820183905290517f5d0c0019d3d45fadeb74eff9d2c9924d146d000ac6bcf3c28bf0ac3c9baa011a9181900360600190a1613dab8985608001516157d1565b8615613dda5760208401518451613dcc918b91613dc791614b53565b614f3a565b613dda896124648b85613381565b600087613def57613dea89613f80565b613df8565b613df889612b8d565b90507f2e1f85a64a2f22cf2f0c42584e7c919ed4abe8d53675cff0f62bf1e95a1c676f868c8c8c8c8a600001518b602001518c608001518d60a001518a604051808b81526020018a6001600160a01b03168152602001896001600160a01b03168152602001886001600160a01b0316815260200187151581526020018681526020018581526020018481526020018381526020018281526020019a505050505050505050505060405180910390a187158015613eb75750846020015183105b15613ee5576020850151600090613ece9085614b53565b9050613ee38b613ede8d84613381565b614fb9565b505b87613ef857613ef8898660000151615886565b6000868152602b60205260408120818155600181018290556002810182905560038101829055600481018290556005810182905560060155600954613f44908b90612464908290613381565b613f5a8a613f548c600954613381565b89614a3b565b50506016805460ff19166001179055505050505b50506001600055505050565b600e5481565b60048054601654604080516317e1d38560e11b81526001600160a01b03868116958201959095526001602482015260ff80841615156044830152610100909304909216151560648301525160009390921691632fc3a70a91608480820192602092909190829003018186803b158015612c0657600080fd5b601b818154811061400557fe5b6000918252602090912001546001600160a01b0316905081565b614027614ae2565b6001600160a01b0381166000908152601c602052604090205461404e9060ff16600d6145ca565b6001600160a01b03811660009081526022602052604090205460155461407391614b53565b6015556001600160a01b0381166000908152601c60209081526040808320805460ff19908116909155601d835281842084905560228352818420849055601e835281842084905560248352818420849055601f8352818420805482169055918052909120805490911690556007546140ec906001614b53565b60075550565b6005546001600160a01b031681565b614109614ae2565b6001600160a01b039091166000908152602f6020526040902055565b60286020526000908152604090205481565b61413f614ae2565b6016805491151563010000000263ff00000019909216919091179055565b6000614167614ae2565b6001600160a01b0383166000908152602c60205260409020548061418f576000915050611b35565b6001600160a01b0384166000908152602c60205260408120556120b6848285614a3b565b601a6020526000908152604090205460ff1681565b6003546001600160a01b031681565b6000826141e6575060006120b6565b6001600160a01b0384166000908152601d60205260409020546135b28361182e86600a85900a614501565b6001546040805163fbfded6d60e01b81526001600160a01b03858116600483015284811660248301529151600093630100000090049092169163fbfded6d9160448082019260209290919082900301818787803b15801561427157600080fd5b505af1158015614285573d6000803e3d6000fd5b505050506040513d602081101561429b57600080fd5b50519050806142aa575061395b565b6001600160a01b0383166000908152602a60205260409020546142f7576012546142d8906135ac428261455a565b6001600160a01b0384166000908152602a60205260409020555061395b565b6012546001600160a01b0384166000908152602a6020526040902054429161431f9190614afb565b111561432b575061395b565b6000614336846134bd565b6001600160a01b03851660009081526029602052604090205490915061435c9082614afb565b6001600160a01b038516600090815260296020526040902055601254614386906135ac428261455a565b6001600160a01b0385166000818152602a602090815260408083209490945560298152908390205483519283529082015281517fa146fc154e1913322e9817d49f0d5c37466c24326e15de10e739a948be815eab929181900390910190a150505050565b610e1081565b6001546040805163fdaf6ac360e01b81526001600160a01b038881166004830152878116602483015286811660448301528515156064830152608482018590529151600093630100000090049092169163fdaf6ac39160a480820192602092909190829003018186803b15801561385c57600080fd5b60306020908152600091825260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156144f95780601f106144ce576101008083540402835291602001916144f9565b820191906000526020600020905b8154815290600101906020018083116144dc57829003601f168201915b505050505081565b60008261451057506000611b35565b8282028284828161451d57fe5b04146120b65760405162461bcd60e51b8152600401808060200182810382526021815260200180615f0d6021913960400191505060405180910390fd5b60006120b683836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b8152506158ee565b60165462010000900460ff16156145c857336000908152601a60205260409020546145c89060ff1660366145ca565b565b6000818152603060205260409020826138ae5760405162461bcd60e51b81526020600482019081528254600260001961010060018416150201909116046024830181905290918291604490910190849080156146675780601f1061463c57610100808354040283529160200191614667565b820191906000526020600020905b81548152906001019060200180831161464a57829003601f168201915b50509250505060405180910390fd5b6001600160a01b03811660008181526021602090815260408083205481516370a0823160e01b8152306004820152915193949093859391926370a08231926024808301939192829003018186803b1580156146d057600080fd5b505afa1580156146e4573d6000803e3d6000fd5b505050506040513d60208110156146fa57600080fd5b50516001600160a01b03851660009081526021602052604090208190559050611df98183614b53565b6001600160a01b03821660009081526023602052604090205481811161479e576001600160a01b0383166000818152602360209081526040808320929092558151928352820183905280517f4cd0095bd565d45488212267145f37c5a223186512b169e04f24bc12a4f6b3079281900390910190a15061395b565b6147a88183614b53565b6001600160a01b03841660008181526023602090815260409182902093909355805191825291810184905281517f4cd0095bd565d45488212267145f37c5a223186512b169e04f24bc12a4f6b307929181900390910190a1505050565b604080518082018252601a81527915985d5b1d0e881c1bdbdb105b5bdd5b9d08195e18d95959195960321b6020808301919091526001600160a01b03851660009081526025909152919091205461485d918390615990565b6001600160a01b0383166000908152602560209081526040808320849055602690915290205461489091101560326145ca565b604080516001600160a01b03841681526020810183905281517f112726233fbeaeed0f5b1dba5cb0b2b81883dee49fb35ff99fd98ed9f6d31eb0929181900390910190a15050565b6000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561492757600080fd5b505afa15801561493b573d6000803e3d6000fd5b505050506040513d602081101561495157600080fd5b50516001600160a01b0390921660009081526021602052604090209190915550565b60008061499061271061182e6149898287614b53565b8790614501565b9050600061499e8583614b53565b6001600160a01b0387166000908152602c60205260409020549091506149c49082614afb565b6001600160a01b0387166000908152602c60205260409020557f47cd9dda0e50ce30bcaaacd0488452b596221c07ac402a581cfae4d3933cac2b86614a098184611ae8565b604080516001600160a01b0390931683526020830191909152818101849052519081900360600190a150949350505050565b614a4f6001600160a01b038416828461577f565b604080516370a0823160e01b815230600482015290516001600160a01b038516916370a08231916024808301926020929190829003018186803b158015614a9557600080fd5b505afa158015614aa9573d6000803e3d6000fd5b505050506040513d6020811015614abf57600080fd5b50516001600160a01b039093166000908152602160205260409020929092555050565b6006546145c8906001600160a01b0316331460356145ca565b6000828201838110156120b6576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b60006120b683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250615990565b601754614ba1576145c8565b6145c86017543a111560376145ca565b336001600160a01b0382161415614bc757614c11565b6003546001600160a01b0316331415614bdf57614c11565b6001600160a01b0381166000908152601860209081526040808320338452909152902054614c119060ff1660296145ca565b50565b8015614c8d57614c39826001600160a01b0316846001600160a01b031614602a6145ca565b6001600160a01b0383166000908152601c6020526040902054614c609060ff16602b6145ca565b6001600160a01b0383166000908152601f6020526040902054614c889060ff1615602c6145ca565b6138ae565b6001600160a01b0383166000908152601c6020526040902054614cb49060ff16602d6145ca565b6001600160a01b0383166000908152601f6020526040902054614cdb9060ff16602e6145ca565b6001600160a01b0382166000908152601f6020526040902054614d039060ff1615602f6145ca565b6001600160a01b03821660009081526020805260409020546138ae9060ff1660306145ca565b600080614d3989898989896143f0565b90506000614d4b8a8a8a8a8989613a2e565b9050614d578282614afb565b91506000614d658a84613381565b6001600160a01b038b166000908152602c6020526040902054909150614d8b9082614afb565b6001600160a01b038b166000818152602c602090815260409182902093909355805191825291810185905280820183905290517f5d0c0019d3d45fadeb74eff9d2c9924d146d000ac6bcf3c28bf0ac3c9baa011a9181900360600190a150909998505050505050505050565b81614e0d57614e08811560276145ca565b61395b565b61395b8183101560286145ca565b6001600160a01b038216600090815260266020526040902054614e3e9082614afb565b6001600160a01b038316600090815260266020818152604080842085905560258252909220549152614e7391111560346145ca565b604080516001600160a01b03841681526020810183905281517faa5649d82f5462be9d19b0f2b31a59b2259950a6076550bac9f3a1c07db9f66d929181900390910190a15050565b6001600160a01b038216600090815260286020526040902054614ede9082614afb565b6001600160a01b03831660008181526028602090815260409182902093909355805191825291810183905281517fd9d4761f75e0d0103b5cbeab941eeb443d7a56a35b5baf2a0787c03f03f4e474929181900390910190a15050565b6001600160a01b038216600090815260286020526040902054614f5d9082614b53565b6001600160a01b03831660008181526028602090815260409182902093909355805191825291810183905281517f34e07158b9db50df5613e591c44ea2ebc82834eff4a4dc3a46e000e608261d68929181900390910190a15050565b6001600160a01b038216600090815260256020526040902054614fdc9082614afb565b6001600160a01b03831660008181526025602090815260408083209490945583516370a0823160e01b8152306004820152935191936370a082319260248083019392829003018186803b15801561503257600080fd5b505afa158015615046573d6000803e3d6000fd5b505050506040513d602081101561505c57600080fd5b50516001600160a01b0384166000908152602560205260409020549091506150889082101560316145ca565b604080516001600160a01b03851681526020810184905281517f976177fbe09a15e5e43f848844963a42b41ef919ef17ff21a17a5421de8f4737929181900390910190a1505050565b6001600160a01b0382166000908152602d60205260409020546150f49082614afb565b6001600160a01b0383166000908152602d6020908152604080832093909355602f9052205480156138ae576001600160a01b0383166000908152602d60205260409020548110156138ae576040805162461bcd60e51b815260206004820152601a60248201527915985d5b1d0e881b585e081cda1bdc9d1cc8195e18d95959195960321b604482015290519081900360640190fd5b600154604080516381d11a2360e01b81526001600160a01b038a8116600483015289811660248301528881166044830152606482018890526084820187905285151560a483015284811660c4830152915160009363010000009004909216916381d11a239160e4808201928692909190829003018186803b15801561520d57600080fd5b505afa158015615221573d6000803e3d6000fd5b5050505061522f8787614211565b600061523d89898987611cb0565b6000818152602b6020526040902080549192509061525e901515601f6145ca565b615270868260000154101560206145ca565b615282878260010154101560216145ca565b60018101548154600483015460009161529f9161182e908b614501565b60048401549091506152b19082614b53565b60048401556152c08b826157d1565b506000806152d28d8d8d8d8d8d6159ea565b855491935091508914615476576152ea8c8c8a61368b565b600385015583546152fb908a614b53565b808555600185015461530d9190614df7565b61531b8d8d8d8b600161395f565b505087156153485761533e8c61243d866001015486614b5390919063ffffffff16565b6153488c8a614f3a565b60008861535d576153588c613f80565b615366565b6153668c612b8d565b90507f93d75d64d1f84fc6f430a64fc578bdd4c1e090e90ea2d51773e626d19de56d30868f8f8f8f8f8f8861539b8c8c614b53565b60408051998a526001600160a01b0398891660208b015296881689880152949096166060880152608087019290925260a0860152151560c085015260e084019290925261010083019190915251908190036101200190a18454600186015460028701546003880154600489015460058a0154604080518d81526020810197909752868101959095526060860193909352608085019190915260a084015260c083015260e08201839052517f20853733b590dce729d9f4628682ebd9a34d2354e72679e66f43a008fc03b773918190036101000190a1506155ea565b8715615490576154868c84614ebb565b6154908c8a614f3a565b6000886154a5576154a08c613f80565b6154ae565b6154ae8c612b8d565b90507f93d75d64d1f84fc6f430a64fc578bdd4c1e090e90ea2d51773e626d19de56d30868f8f8f8f8f8f886154e38c8c614b53565b60408051998a526001600160a01b0398891660208b015296881689880152949096166060880152608087019290925260a0860152151560c085015260e084019290925261010083019190915251908190036101200190a18454600186015460028701546003880154600489015460058a0154604080518d81526020810197909752868101959095526060860193909352608085019190915260a084015260c0830152517f73af1d417d82c240fdb6d319b34ad884487c6bf2845d98980cc52ad9171cb4559181900360e00190a1506000858152602b602052604081208181556001810182905560028101829055600381018290556004810182905560058101829055600601555b876155f9576155f98b8a615886565b8115615639578715615613576156138c6124648e85613381565b600061561f8d83613381565b905061562c8d828a614a3b565b95506127dd945050505050565b5060009c9b505050505050505050505050565b6001600160a01b03821660009081526023602052604090205461566f9082614afb565b6001600160a01b03831660009081526023602090815260408083209390935560249052205480156156c1576001600160a01b0383166000908152602360205260409020546156c19082101560336145ca565b604080516001600160a01b03851681526020810184905281517f8734a535d62699174c322d74d291c6053308a8caf79759684f44851562dc5cce929181900390910190a1505050565b6001600160a01b0381166000908152602760209081526040808320546025909252909120541015614c11576040805162461bcd60e51b815260206004820152601a6024820152792b30bab63a1d103837b7b620b6b7bab73a101e10313ab33332b960311b604482015290519081900360640190fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526138ae908490615be4565b604080518082018252601b81527a5661756c743a20696e73756666696369656e74207265736572766560281b6020808301919091526001600160a01b03851660009081526026909152919091205461582a918390615990565b6001600160a01b03831660008181526026602090815260409182902093909355805191825291810183905281517f533cb5ed32be6a90284e96b5747a1bfc2d38fdb5768a6b5f67ff7d62144ed67b929181900390910190a15050565b6001600160a01b0382166000908152602d6020526040902054808211156158c657506001600160a01b0382166000908152602d602052604081205561395b565b6158d08183614b53565b6001600160a01b0384166000908152602d6020526040902055505050565b6000818361597a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561593f578181015183820152602001615927565b50505050905090810190601f16801561596c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161598657fe5b0495945050505050565b600081848411156159e25760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561593f578181015183820152602001615927565b505050900390565b60008060006159fb89898987611cb0565b6000818152602b60205260408120805460038201549394509092615a28918d918d918d918b918d91614d29565b9050600080600080615a498d876000015488600201548d8a60060154612821565b87549195508593509150615a619061182e8d84614501565b925050506000828015615a745750600082115b15615aa45750600584018054820190558088615aa4576000615a968e84613381565b9050615aa28e82614805565b505b82158015615ab25750600082115b15615af6576001850154615ac69083614b53565b600186015588615aea576000615adc8e84613381565b9050615ae88e82614fb9565b505b60058501805483900390555b8a15615b1e57615b06818c614afb565b6001860154909150615b18908c614b53565b60018601555b84548a1415615b41576001850154615b37908290614afb565b6000600187015590505b8084811115615b5b57615b548286614b53565b9050615b8f565b6001860154615b6a9086614b53565b60018701558915615b8f576000615b818f87613381565b9050615b8d8f82614805565b505b60408051888152851515602082015280820185905290517f3ff41bdde87755b687ae83d0221a232b6be51a803330ed9661c1b5d0105e0d8a9181900360600190a1909e909d509b505050505050505050505050565b6060615c39826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316615c959092919063ffffffff16565b8051909150156138ae57808060200190516020811015615c5857600080fd5b50516138ae5760405162461bcd60e51b815260040180806020018281038252602a815260200180615f2e602a913960400191505060405180910390fd5b6060611df9848460008585615ca985615db0565b615cfa576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310615d395780518252601f199092019160209182019101615d1a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114615d9b576040519150601f19603f3d011682016040523d82523d6000602084013e615da0565b606091505b50915091506127dd828286615db6565b3b151590565b60608315615dc55750816120b6565b825115615dd55782518084602001fd5b60405162461bcd60e51b815260206004820181815284516024840152845185939192839260440191908501908083836000831561593f578181015183820152602001615927565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10615e5d5782800160ff19823516178555615e8a565b82800160010185558215615e8a579182015b82811115615e8a578235825591602001919060010190615e6f565b50615e96929150615ed7565b5090565b6040518060e00160405280600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b5b80821115615e965760008155600101615ed856fe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220ce3a288a0fdbcd3422bb45d1fa6e1c11dab973f76592c664c7bac534653edb5764736f6c634300060c0033

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.