FTM Price: $0.67 (-8.41%)
Gas: 20 GWei

Contract

0x9eA320d5b987e859D841e7624E5e845928bA2ADc
 

Overview

FTM Balance

Fantom LogoFantom LogoFantom Logo0 FTM

FTM Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
Initialize478992552022-09-27 23:51:16566 days ago1664322676IN
0x9eA320d5...928bA2ADc
0 FTM0.2867883,000
0x60806040432324252022-07-21 10:23:51634 days ago1658399031IN
 Create: LiquidityManager
0 FTM0.023152815.19052673

Latest 1 internal transaction

Parent Txn Hash Block From To Value
432324252022-07-21 10:23:51634 days ago1658399031  Contract Creation0 FTM
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
LiquidityManager

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 19 : LiquidityManager.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.10;

import "../interfaces/ILiquidityPool.sol";
import "../libraries/LibUtils.sol";

import "./Types.sol";
import "./Storage.sol";
import "./AssetManager.sol";
import "./Admin.sol";
import "./ExtensionProxy.sol";

/**
 * @title LiquidityManager provides funds management and bridging services.
 */
contract LiquidityManager is Storage, AssetManager, DexWrapper, Admin, ExtensionProxy {
    receive() external payable {}

    /**
     * @notice Initialize the LiquidityManager.
     */
    function initialize(address vault_, address pool_) external initializer {
        __SafeOwnable_init();
        _vault = vault_;
        _pool = pool_;
        // 0 for placeHolder
        _dexSpotConfigs.push();
    }

    /**
     * @notice Return the address of LiquidityPool.
     */
    function getPool() public view returns (address) {
        return _pool;
    }

    /**
     * @notice Return the address of vault to which the profits of dex farming is transferred.
     */
    function getVault() public view returns (address) {
        return _vault;
    }

    function getMaintainer() public view returns (address) {
        return _maintainer;
    }

    /**
     * @notice Return true if an external contract is allowed to access authed methods.
     */
    function isHandler(address handler) public view returns (bool) {
        return _handlers[handler];
    }

    /**
     * @notice Return all the configs of current dexes.
     */
    function getAllDexSpotConfiguration() external returns (DexSpotConfiguration[] memory configs) {
        uint256 n = _dexSpotConfigs.length - 1;
        if (n == 0) {
            return configs;
        }
        configs = new DexSpotConfiguration[](n);
        for (uint8 dexId = 1; dexId <= n; dexId++) {
            configs[dexId - 1] = _getDexSpotConfiguration(dexId);
        }
        return configs;
    }

    /**
     * @notice Return the config of a given dex.
     */
    function getDexSpotConfiguration(uint8 dexId) external returns (DexSpotConfiguration memory config) {
        require(dexId != 0 && dexId < _dexSpotConfigs.length, "LST"); // the asset is not LiSTed
        config = _getDexSpotConfiguration(dexId);
    }

    /**
     * @notice Return the lp balance and calculated spot amounts of a given dex.
     */
    function getDexLiquidity(uint8 dexId) external returns (uint256[] memory liquidities, uint256 lpBalance) {
        lpBalance = getDexLpBalance(dexId);
        liquidities = getDexSpotAmounts(dexId, lpBalance);
    }

    /**
     * @notice Return adapter config of a given dex.
     */
    function getDexAdapterConfig(uint8 dexId) external view returns (bytes memory config) {
        config = _dexData[dexId].config;
    }

    /**
     * @notice Query the adapter state of a given dex by key. A state key can be obtain by `keccak(KEY_NAME)`
     */
    function getDexAdapterState(uint8 dexId, bytes32 key) external view returns (bytes32 state) {
        state = _dexData[dexId].states[key];
    }

    /**
     * @notice Return the address of adapter of a given dex.
     */
    function getDexAdapter(uint8 dexId) external view returns (DexRegistration memory registration) {
        registration = _dexAdapters[dexId];
    }

    function _getDexSpotConfiguration(uint8 dexId) internal returns (DexSpotConfiguration memory config) {
        config = _dexSpotConfigs[dexId];
        if (config.dexType == DEX_CURVE) {
            uint256[] memory amounts = getDexTotalSpotAmounts(dexId);
            config.totalSpotInDex = amounts;
        }
    }
}

File 2 of 19 : ILiquidityPool.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.10;

import "../core/Types.sol";

interface ILiquidityPool {
    /////////////////////////////////////////////////////////////////////////////////
    //                                 getters

    function getAssetInfo(uint8 assetId) external view returns (Asset memory);

    function getAllAssetInfo() external view returns (Asset[] memory);

    function getAssetAddress(uint8 assetId) external view returns (address);

    function getLiquidityPoolStorage()
        external
        view
        returns (
            // [0] shortFundingBaseRate8H
            // [1] shortFundingLimitRate8H
            // [2] lastFundingTime
            // [3] fundingInterval
            // [4] liquidityBaseFeeRate
            // [5] liquidityDynamicFeeRate
            // [6] sequence. note: will be 0 after 0xffffffff
            // [7] strictStableDeviation
            uint32[8] memory u32s,
            // [0] mlpPriceLowerBound
            // [1] mlpPriceUpperBound
            uint96[2] memory u96s
        );

    function getSubAccount(bytes32 subAccountId)
        external
        view
        returns (
            uint96 collateral,
            uint96 size,
            uint32 lastIncreasedTime,
            uint96 entryPrice,
            uint128 entryFunding
        );

    /////////////////////////////////////////////////////////////////////////////////
    //                             for Trader / Broker

    function withdrawAllCollateral(bytes32 subAccountId) external;

    /////////////////////////////////////////////////////////////////////////////////
    //                                 only Broker

    function depositCollateral(
        bytes32 subAccountId,
        uint256 rawAmount // NOTE: OrderBook SHOULD transfer rawAmount collateral to LiquidityPool
    ) external;

    function withdrawCollateral(
        bytes32 subAccountId,
        uint256 rawAmount,
        uint96 collateralPrice,
        uint96 assetPrice
    ) external;

    function withdrawProfit(
        bytes32 subAccountId,
        uint256 rawAmount,
        uint8 profitAssetId, // only used when !isLong
        uint96 collateralPrice,
        uint96 assetPrice,
        uint96 profitAssetPrice // only used when !isLong
    ) external;

    /**
     * @dev   Add liquidity
     *
     * @param trader            liquidity provider address
     * @param tokenId           asset.id that added
     * @param rawAmount         asset token amount. decimals = erc20.decimals
     * @param tokenPrice        token price
     * @param mlpPrice          mlp price
     * @param currentAssetValue liquidity USD value of a single asset in all chains (even if tokenId is a stable asset)
     * @param targetAssetValue  weight / Σ weight * total liquidity USD value in all chains
     */
    function addLiquidity(
        address trader,
        uint8 tokenId,
        uint256 rawAmount, // NOTE: OrderBook SHOULD transfer rawAmount collateral to LiquidityPool
        uint96 tokenPrice,
        uint96 mlpPrice,
        uint96 currentAssetValue,
        uint96 targetAssetValue
    ) external;

    /**
     * @dev   Remove liquidity
     *
     * @param trader            liquidity provider address
     * @param mlpAmount         mlp amount
     * @param tokenId           asset.id that removed to
     * @param tokenPrice        token price
     * @param mlpPrice          mlp price
     * @param currentAssetValue liquidity USD value of a single asset in all chains (even if tokenId is a stable asset)
     * @param targetAssetValue  weight / Σ weight * total liquidity USD value in all chains
     */
    function removeLiquidity(
        address trader,
        uint96 mlpAmount, // NOTE: OrderBook SHOULD transfer mlpAmount mlp to LiquidityPool
        uint8 tokenId,
        uint96 tokenPrice,
        uint96 mlpPrice,
        uint96 currentAssetValue,
        uint96 targetAssetValue
    ) external;

    function openPosition(
        bytes32 subAccountId,
        uint96 amount,
        uint96 collateralPrice,
        uint96 assetPrice
    ) external returns (uint96);

    /**
     * @notice Close a position
     *
     * @param  subAccountId     check LibSubAccount.decodeSubAccountId for detail.
     * @param  amount           position size.
     * @param  profitAssetId    for long position (unless asset.useStable is true), ignore this argument;
     *                          for short position, the profit asset should be one of the stable coin.
     * @param  collateralPrice  price of subAccount.collateral.
     * @param  assetPrice       price of subAccount.asset.
     * @param  profitAssetPrice price of profitAssetId. ignore this argument if profitAssetId is ignored.
     */
    function closePosition(
        bytes32 subAccountId,
        uint96 amount,
        uint8 profitAssetId, // only used when !isLong
        uint96 collateralPrice,
        uint96 assetPrice,
        uint96 profitAssetPrice // only used when !isLong
    ) external returns (uint96);

    /**
     * @notice Broker can update funding each [fundingInterval] seconds by specifying utilizations.
     *
     * @param  stableUtilization    Stable coin utilization in all chains
     * @param  unstableTokenIds     All unstable Asset id(s) MUST be passed in order. ex: 1, 2, 5, 6, ...
     * @param  unstableUtilizations Unstable Asset utilizations in all chains
     * @param  unstablePrices       Unstable Asset prices
     */
    function updateFundingState(
        uint32 stableUtilization, // 1e5
        uint8[] calldata unstableTokenIds,
        uint32[] calldata unstableUtilizations, // 1e5
        uint96[] calldata unstablePrices
    ) external;

    function liquidate(
        bytes32 subAccountId,
        uint8 profitAssetId, // only used when !isLong
        uint96 collateralPrice,
        uint96 assetPrice,
        uint96 profitAssetPrice // only used when !isLong
    ) external returns (uint96);

    function redeemMuxToken(
        address trader,
        uint8 tokenId,
        uint96 muxTokenAmount // NOTE: OrderBook SHOULD transfer muxTokenAmount to LiquidityPool
    ) external;

    function rebalance(
        address rebalancer,
        uint8 tokenId0,
        uint8 tokenId1,
        uint96 rawAmount0,
        uint96 maxRawAmount1,
        bytes32 userData,
        uint96 price0,
        uint96 price1
    ) external;

    /**
     * @dev Broker can withdraw brokerGasRebate
     */
    function claimBrokerGasRebate(address receiver) external returns (uint256 rawAmount);

    /////////////////////////////////////////////////////////////////////////////////
    //                            only LiquidityManager

    function transferLiquidityOut(uint8[] memory assetIds, uint256[] memory amounts) external;

    function transferLiquidityIn(uint8[] memory assetIds, uint256[] memory amounts) external;
}

File 2 of 19 : LibUtils.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.10;

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

library LibUtils {
    bytes4 constant SELECTOR_DECIMALS = 0x313ce567;

    function toBytes32(string memory source) internal pure returns (bytes32 result) {
        uint256 size = bytes(source).length;
        require(size > 0 && size <= 32, "RNG"); // out of range
        assembly {
            result := mload(add(source, 32))
        }
    }

    function norm(address[] memory tokens_, uint256[] memory amounts_)
        internal
        view
        returns (uint256[] memory normAmounts_)
    {
        require(tokens_.length == amounts_.length, "L!L");
        uint256 n = tokens_.length;
        normAmounts_ = new uint256[](n);
        for (uint256 i = 0; i < n; i++) {
            uint256 decimals;
            try IDecimals(tokens_[i]).decimals() returns (uint8 decimals_) {
                decimals = decimals_;
            } catch {
                decimals = 18;
            }
            normAmounts_[i] = amounts_[i] / (10**decimals);
        }
    }
}

File 2 of 19 : Types.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.10;

uint256 constant DEX_UNISWAP = 0;
uint256 constant DEX_CURVE = 1;

struct DexSpotConfiguration {
    uint8 dexId;
    uint8 dexType;
    uint32 dexWeight;
    uint8[] assetIds;
    uint32[] assetWeightInDex;
    uint256[] totalSpotInDex;
}

struct DexRegistration {
    address adapter;
    bool disabled;
    uint32 slippage;
}

struct DexData {
    bytes config; // read only
    mapping(bytes32 => bytes32) states; // mutable
}

struct PluginData {
    mapping(bytes32 => bytes32) states; // mutable
}

struct CallContext {
    uint8 dexId;
}

File 2 of 19 : Storage.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.10;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

import "./Types.sol";
import "../components/SafeOwnableUpgradeable.sol";

// prev storages:
// contract CrossStorage {
//     address internal _vault;
//     address internal _pool;
//     DexSpotConfiguration[] internal _dexSpotConfigs;
//     mapping(bytes32 => bytes32[]) internal _moduleData;
//     bytes32[50] private __moduleGaps;
// }

// contract Storage is CrossStorage {
//     mapping(bytes32 => ModuleInfo) internal _moduleInfos;
//     mapping(bytes32 => CallRegistration) internal _genericRoutes; // method -> call
//     mapping(uint8 => mapping(bytes32 => CallRegistration)) internal _dexRoutes; // dexId -> method -> call
//     mapping(address => bool) internal _externalAccessors;
//     bytes32[50] private __gaps;
// }

contract PlaceHolder {
    bytes32[200] private __deprecated;
}

contract Storage is PlaceHolder, Initializable, SafeOwnableUpgradeable {
    // base properties
    address internal _vault;
    address internal _pool;

    DexSpotConfiguration[] internal _dexSpotConfigs;
    // address => isAllowed
    mapping(address => bool) internal _handlers;
    CallContext internal _dexContext;
    // dexId => Context
    mapping(uint8 => DexData) internal _dexData;
    // assetId => address
    mapping(uint8 => address) internal _tokenCache;
    // dexId => dexRegistration
    mapping(uint8 => DexRegistration) internal _dexAdapters;
    // sig => callee
    mapping(bytes4 => address) internal _plugins;
    mapping(string => PluginData) internal _pluginData;

    address internal _maintainer;
    // reserves
    bytes32[49] private __gaps;
}

File 2 of 19 : AssetManager.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.10;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";

import "../interfaces/ILiquidityPool.sol";
import "./Types.sol";
import "./Storage.sol";

contract AssetManager is Storage {
    using AddressUpgradeable for address;
    using SafeERC20Upgradeable for IERC20Upgradeable;

    event FetchAssets(uint8[] assetIds, uint256[] amounts);
    event PushAssets(uint8[] assetIds, uint256[] amounts);
    event WithdrawToken(address token, address recipient, uint256 amount);

    modifier auth() {
        require(_handlers[msg.sender], "NHL"); // not handler
        _;
    }

    modifier onlyMaintainer() {
        require(msg.sender == _maintainer || msg.sender == owner(), "SND"); // invalid sender
        _;
    }

    function withdrawToken(address token, uint256 amount) external onlyOwner {
        if (token == address(0)) {
            AddressUpgradeable.sendValue(payable(msg.sender), amount);
        } else {
            IERC20Upgradeable(token).safeTransfer(msg.sender, amount);
        }
        emit WithdrawToken(token, msg.sender, amount);
    }

    function _fetchAssets(uint8[] memory assetIds, uint256[] memory amounts) internal {
        require(assetIds.length == amounts.length, "LEN"); // LENgth of 2 arguments does not match
        ILiquidityPool(_pool).transferLiquidityOut(assetIds, amounts);
        emit FetchAssets(assetIds, amounts);
    }

    function _pushAssets(uint8[] memory assetIds, uint256[] memory amounts) internal {
        if (_transferTo(_pool, assetIds, amounts)) {
            ILiquidityPool(_pool).transferLiquidityIn(assetIds, amounts);
            emit PushAssets(assetIds, amounts);
        }
    }

    function _getDexTokens(uint8 dexId) internal view returns (address[] memory tokens) {
        uint8[] memory assetIds = _dexSpotConfigs[dexId].assetIds;
        tokens = new address[](assetIds.length);
        for (uint256 i = 0; i < assetIds.length; i++) {
            tokens[i] = _getTokenAddress(assetIds[i]);
        }
    }

    function _repayAssets(
        uint8 dexId,
        uint256[] memory maxAmounts,
        uint256[] memory usedAmounts
    ) internal returns (uint256[] memory remainAmounts) {
        require(maxAmounts.length == usedAmounts.length, "LEN"); // LENgth of 2 arguments does not match
        uint256 n = maxAmounts.length;
        remainAmounts = new uint256[](n);
        bool hasRemain = false;
        for (uint256 i = 0; i < n; i++) {
            if (maxAmounts[i] > usedAmounts[i]) {
                remainAmounts[i] = maxAmounts[i] - usedAmounts[i];
                hasRemain = true;
            }
        }
        _pushAssets(_dexSpotConfigs[dexId].assetIds, remainAmounts);
    }

    function _getTokenAddress(uint8 assetId) internal view returns (address token) {
        token = _tokenCache[assetId];
        require(token != address(0), "NAD");
    }

    function _tryGetTokenAddress(uint8 assetId) internal returns (address token) {
        token = _tokenCache[assetId];
        if (token == address(0)) {
            token = ILiquidityPool(_pool).getAssetAddress(assetId);
            _tokenCache[assetId] = token;
        }
    }

    function _transferTo(
        address recipient,
        uint8[] memory assetIds,
        uint256[] memory amounts
    ) internal returns (bool transferred) {
        require(assetIds.length == amounts.length, "LEN"); // LENgth of 2 arguments does not match
        for (uint256 i = 0; i < assetIds.length; i++) {
            if (amounts[i] != 0) {
                IERC20Upgradeable(_tryGetTokenAddress(assetIds[i])).safeTransfer(recipient, amounts[i]);
                transferred = true;
            }
        }
    }
}

File 2 of 19 : Admin.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.10;

import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";

import "../interfaces/IPlugin.sol";
import "./AssetManager.sol";
import "./DexWrapper.sol";

contract Admin is AssetManager, DexWrapper {
    using AddressUpgradeable for address;

    uint32 constant DEFAULT_SLIPPAGE = 1000; // 1%

    event SetHandler(address handler, bool enable);
    event AddDex(uint8 dexId, uint8 dexType, uint32 dexWeight, uint8[] assetIds, uint32[] assetWeightInDex);
    event SetDexWeight(uint8 dexId, uint32 dexWeight, uint32[] assetWeightInDex);
    event SetAssetIds(uint8 dexId, uint8[] assetIds);
    event SetDexAdapter(uint8 dexId, address entrypoint, bytes initialData);
    event SetDexWrapperEnable(uint8 dexId, bool enable);
    event SetDexSlippage(uint8 dexId, uint32 slippage);
    event SetPlugin(address plugin, bool enable, bytes4[] selectors);
    event SetVault(address previousVault, address newVault);
    event SetPool(address previousVault, address newPool);
    event SetMaintainer(address previousMaintainer, address newMaintainer);

    function setVault(address newVault) external onlyOwner {
        require(newVault != address(0), "ZAD"); // zero address
        require(newVault != _vault, "DUP"); // duplicated
        emit SetVault(_vault, newVault);
        _vault = newVault;
    }

    function setPool(address newPool) external onlyOwner {
        require(newPool != address(0), "ZAD"); // zero address
        require(newPool != _pool, "DUP"); // duplicated
        emit SetPool(_pool, newPool);
        _pool = newPool;
    }

    function setMaintainer(address newMaintainer) external onlyOwner {
        require(newMaintainer != _maintainer, "DUP"); // duplicated
        emit SetMaintainer(_maintainer, newMaintainer);
        _maintainer = newMaintainer;
    }

    function setHandler(address handler, bool enable) external onlyOwner {
        require(_handlers[handler] != enable, "DUP");
        _handlers[handler] = enable;
        emit SetHandler(handler, enable);
    }

    /**
     * @notice Add a configuration for dex.
     *         Each configuration [dex, assets0, asset1, ...] represents a combination of dex pool address and assets categories.
     * @param dexId The name of dex for user to distinguish between the configurations.
     * @param dexType The name of dex for user to distinguish between the configurations.
     * @param dexWeight The name of dex for user to distinguish between the configurations.
     * @param assetIds The array represents the category of assets to add to the dex.
     * @param assetWeightInDex The array represents the weight of each asset added to the dex as liquidity.
     *
     */
    function addDexSpotConfiguration(
        uint8 dexId,
        uint8 dexType,
        uint32 dexWeight,
        uint8[] calldata assetIds,
        uint32[] calldata assetWeightInDex
    ) external onlyOwner {
        require(_dexSpotConfigs.length <= 256, "FLL"); // the array is FuLL
        require(assetIds.length > 0, "MTY"); // argument array is eMpTY
        require(assetIds.length == assetWeightInDex.length, "LEN"); // LENgth of 2 arguments does not match
        require(dexId == _dexSpotConfigs.length, "IDI"); // invalid dex id

        _dexSpotConfigs.push(
            DexSpotConfiguration({
                dexId: dexId,
                dexType: dexType,
                dexWeight: dexWeight,
                assetIds: assetIds,
                assetWeightInDex: assetWeightInDex,
                totalSpotInDex: _makeEmpty(assetIds.length)
            })
        );
        for (uint256 i = 0; i < assetIds.length; i++) {
            _tryGetTokenAddress(assetIds[i]);
        }
        emit AddDex(dexId, dexType, dexWeight, assetIds, assetWeightInDex);
    }

    /**
     * @notice Modify the weight of a dex configuration.
     * @param dexId The id of the dex.
     * @param dexWeight The new weight of the dex.
     */
    function setDexWeight(
        uint8 dexId,
        uint32 dexWeight,
        uint32[] memory assetWeightInDex
    ) external onlyOwner {
        require(dexId != 0 && dexId < _dexSpotConfigs.length, "LST"); // the asset is not LiSTed
        _dexSpotConfigs[dexId].dexWeight = dexWeight;
        _dexSpotConfigs[dexId].assetWeightInDex = assetWeightInDex;
        emit SetDexWeight(dexId, dexWeight, assetWeightInDex);
    }

    function refreshTokenCache(uint8[] memory assetIds) external {
        for (uint256 i = 0; i < assetIds.length; i++) {
            _tokenCache[assetIds[i]] = ILiquidityPool(_pool).getAssetAddress(assetIds[i]);
        }
    }

    /**
     * @notice Modify the weight of a dex configuration. Only can be modified when lp balance is zero or no module.
     * @param dexId The id of the dex.
     * @param assetIds The new ids of the dex.
     */
    function setAssetIds(uint8 dexId, uint8[] memory assetIds) external onlyOwner {
        require(dexId != 0 && dexId < _dexSpotConfigs.length, "LST"); // the asset is not LiSTed
        require(getDexLpBalance(dexId) == 0, "FBD"); // forbidden
        _dexSpotConfigs[dexId].assetIds = assetIds;
        emit SetAssetIds(dexId, assetIds);
    }

    function setDexWrapper(
        uint8 dexId,
        address adapter,
        bytes memory initialData
    ) external onlyOwner {
        require(dexId != 0 && dexId < _dexSpotConfigs.length, "LST"); // the asset is not LiSTed
        _dexAdapters[dexId].adapter = adapter;
        _dexAdapters[dexId].slippage = DEFAULT_SLIPPAGE;
        _initializeAdapter(dexId, initialData);
        emit SetDexAdapter(dexId, adapter, initialData);
    }

    function setDexSlippage(uint8 dexId, uint32 slippage) external onlyOwner {
        require(dexId != 0 && dexId < _dexSpotConfigs.length, "LST"); // the asset is not LiSTed
        require(slippage <= BASE_RATE, "OOR"); // out of range
        _dexAdapters[dexId].slippage = slippage;
        emit SetDexSlippage(dexId, slippage);
    }

    function freezeDexWrapper(uint8 dexId, bool enable) external onlyOwner {
        require(dexId != 0 && dexId < _dexSpotConfigs.length, "LST"); // the asset is not LiSTed
        _dexAdapters[dexId].disabled = !enable;
        emit SetDexWrapperEnable(dexId, enable);
    }

    function setPlugin(address plugin, bool enable) external onlyOwner {
        require(plugin != address(0), "ZPA"); // zero plugin address
        bytes4[] memory selectors;
        try IPlugin(plugin).exports() returns (bytes4[] memory _selectors) {
            selectors = _selectors;
        } catch Error(string memory reason) {
            revert(reason);
        } catch {
            revert("SushiFarm::CallUnStakeFail");
        }
        if (enable) {
            for (uint256 i = 0; i < selectors.length; i++) {
                require(_plugins[selectors[i]] == address(0), "PAE"); // plugin already exists
                _plugins[selectors[i]] = plugin;
            }
        } else {
            for (uint256 i = 0; i < selectors.length; i++) {
                require(_plugins[selectors[i]] != address(0), "PNE"); // plugin not exists
                delete _plugins[selectors[i]];
            }
        }
        emit SetPlugin(plugin, enable, selectors);
    }
}

File 2 of 19 : ExtensionProxy.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.10;

import "./Storage.sol";

interface IExports {
    function exports() external pure returns (bytes4[] memory selectors);
}

// functionCall chain:
// upgradeableProxy(admin) => liquidityManager => module => plugin
contract ExtensionProxy is Storage {
    event PluginCall(address sender, address target, bytes4 sig, bytes payload);

    fallback() external {
        _delegate();
    }

    function _delegate() internal {
        address target = _plugins[msg.sig];
        require(target != address(0), "NPG"); // no plugin
        emit PluginCall(msg.sender, target, msg.sig, msg.data);
        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())
            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), target, 0, calldatasize(), 0, 0)
            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())
            switch result
            // delegatecall returns 0 on error.
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }
}

File 2 of 19 : Types.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.10;

struct LiquidityPoolStorage {
    // slot
    address orderBook;
    // slot
    address mlp;
    // slot
    address liquidityManager;
    // slot
    address weth;
    // slot
    uint128 _reserved1;
    uint32 shortFundingBaseRate8H; // 1e5
    uint32 shortFundingLimitRate8H; // 1e5
    uint32 fundingInterval; // 1e0
    uint32 lastFundingTime; // 1e0
    // slot
    uint32 _reserved2;
    // slot
    Asset[] assets;
    // slot
    mapping(bytes32 => SubAccount) accounts;
    // slot
    mapping(address => bytes32) _reserved3;
    // slot
    address _reserved4;
    uint96 _reserved5;
    // slot
    uint96 mlpPriceLowerBound; // safeguard against mlp price attacks
    uint96 mlpPriceUpperBound; // safeguard against mlp price attacks
    uint32 liquidityBaseFeeRate; // 1e5
    uint32 liquidityDynamicFeeRate; // 1e5
    // slot
    address nativeUnwrapper;
    // a sequence number that changes when LiquidityPoolStorage updated. this helps to keep track the state of LiquidityPool.
    uint32 sequence; // 1e0. note: will be 0 after 0xffffffff
    uint32 strictStableDeviation; // 1e5. strictStable price is 1.0 if in this damping range
    uint32 brokerTransactions; // transaction count for broker gas rebates
    // slot
    address vault;
    uint96 brokerGasRebate; // the number of native tokens for broker gas rebates per transaction
    // slot
    address maintainer;
    bytes32[50] _gap;
}

struct Asset {
    // slot
    // assets with the same symbol in different chains are the same asset. they shares the same muxToken. so debts of the same symbol
    // can be accumulated across chains (see Reader.AssetState.deduct). ex: ERC20(fBNB).symbol should be "BNB", so that BNBs of
    // different chains are the same.
    // since muxToken of all stable coins is the same and is calculated separately (see Reader.ChainState.stableDeduct), stable coin
    // symbol can be different (ex: "USDT", "USDT.e" and "fUSDT").
    bytes32 symbol;
    // slot
    address tokenAddress; // erc20.address
    uint8 id;
    uint8 decimals; // erc20.decimals
    uint56 flags; // a bitset of ASSET_*
    uint24 _flagsPadding;
    // slot
    uint32 initialMarginRate; // 1e5
    uint32 maintenanceMarginRate; // 1e5
    uint32 minProfitRate; // 1e5
    uint32 minProfitTime; // 1e0
    uint32 positionFeeRate; // 1e5
    // note: 96 bits remaining
    // slot
    address referenceOracle;
    uint32 referenceDeviation; // 1e5
    uint8 referenceOracleType;
    uint32 halfSpread; // 1e5
    // note: 24 bits remaining
    // slot
    uint128 _reserved1;
    uint128 _reserved2;
    // slot
    uint96 collectedFee;
    uint32 _reserved3;
    uint96 spotLiquidity;
    // note: 32 bits remaining
    // slot
    uint96 maxLongPositionSize;
    uint96 totalLongPosition;
    // note: 64 bits remaining
    // slot
    uint96 averageLongPrice;
    uint96 maxShortPositionSize;
    // note: 64 bits remaining
    // slot
    uint96 totalShortPosition;
    uint96 averageShortPrice;
    // note: 64 bits remaining
    // slot, less used
    address muxTokenAddress; // muxToken.address. all stable coins share the same muxTokenAddress
    uint32 spotWeight; // 1e0
    uint32 longFundingBaseRate8H; // 1e5
    uint32 longFundingLimitRate8H; // 1e5
    // slot
    uint128 longCumulativeFundingRate; // Σ_t fundingRate_t
    uint128 shortCumulativeFunding; // Σ_t fundingRate_t * indexPrice_t
}

uint32 constant FUNDING_PERIOD = 3600 * 8;

uint56 constant ASSET_IS_STABLE = 0x00000000000001; // is a usdt, usdc, ...
uint56 constant ASSET_CAN_ADD_REMOVE_LIQUIDITY = 0x00000000000002; // can call addLiquidity and removeLiquidity with this token
uint56 constant ASSET_IS_TRADABLE = 0x00000000000100; // allowed to be assetId
uint56 constant ASSET_IS_OPENABLE = 0x00000000010000; // can open position
uint56 constant ASSET_IS_SHORTABLE = 0x00000001000000; // allow shorting this asset
uint56 constant ASSET_USE_STABLE_TOKEN_FOR_PROFIT = 0x00000100000000; // take profit will get stable coin
uint56 constant ASSET_IS_ENABLED = 0x00010000000000; // allowed to be assetId and collateralId
uint56 constant ASSET_IS_STRICT_STABLE = 0x01000000000000; // assetPrice is always 1 unless volatility exceeds strictStableDeviation

struct SubAccount {
    // slot
    uint96 collateral;
    uint96 size;
    uint32 lastIncreasedTime;
    // slot
    uint96 entryPrice;
    uint128 entryFunding; // entry longCumulativeFundingRate for long position. entry shortCumulativeFunding for short position
}

enum ReferenceOracleType {
    None,
    Chainlink
}

File 2 of 19 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 2 of 19 : SafeOwnableUpgradeable.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.10;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

contract SafeOwnableUpgradeable is OwnableUpgradeable {
    address internal _pendingOwner;

    event PrepareToTransferOwnership(address indexed pendingOwner);

    function __SafeOwnable_init() internal onlyInitializing {
        __Ownable_init();
    }

    function transferOwnership(address newOwner) public virtual override onlyOwner {
        require(newOwner != address(0), "O=0"); // Owner Is Zero
        require(newOwner != owner(), "O=O"); // Owner is the same as the old Owner
        _pendingOwner = newOwner;
        emit PrepareToTransferOwnership(_pendingOwner);
    }

    function takeOwnership() public virtual {
        require(_msgSender() == _pendingOwner, "SND"); // SeNDer is not authorized
        _transferOwnership(_pendingOwner);
        _pendingOwner = address(0);
    }

    function renounceOwnership() public virtual override onlyOwner {
        _pendingOwner = address(0);
        _transferOwnership(address(0));
    }
}

File 2 of 19 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 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");

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

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

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 2 of 19 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

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

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

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

    /**
     * This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 2 of 19 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

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

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    /**
     * This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 2 of 19 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from,
        address to,
        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 2 of 19 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {
    using AddressUpgradeable for address;

    function safeTransfer(
        IERC20Upgradeable token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20Upgradeable 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(
        IERC20Upgradeable 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'
        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(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _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(IERC20Upgradeable 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
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 2 of 19 : IPlugin.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.10;

interface IPlugin {
    function name() external view returns (string memory);

    function exports() external view returns (bytes4[] memory);
}

File 2 of 19 : DexWrapper.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.10;

import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";

import "../interfaces/IDexAdapter.sol";
import "./AssetManager.sol";

contract DexWrapper is AssetManager {
    using AddressUpgradeable for address;

    uint256 constant BASE_RATE = 100000;

    event AddDexLiquidity(uint8 dexId, uint256[] maxAmounts, uint256[] addedAmounts, uint256 lpAmount, bytes extraData);
    event RemoveDexLiquidity(uint8 dexId, uint256 shareAmount, uint256[] minAmounts, uint256 deadline);
    event ClaimDexFees(uint8 dexId);

    modifier dexCall(uint8 dexId) {
        require(dexId != 0, "ZDI"); // zero dex id
        uint8 lastDexId = _dexContext.dexId;
        if (lastDexId == 0) {
            _dexContext.dexId = dexId;
        } else {
            require(lastDexId == dexId, "NDR"); // no dex-call reentrant
        }
        _;
        _dexContext.dexId = lastDexId;
    }

    // read methods
    function getDexLpBalance(uint8 dexId) public dexCall(dexId) returns (uint256 lpBalance) {
        DexRegistration storage registration = _dexAdapters[dexId];
        if (_dexAdapters[dexId].adapter != address(0)) {
            bytes memory returnData = _delegateCall(
                registration.adapter,
                abi.encodeWithSelector(IDexAdapter.getLpBalance.selector)
            );
            lpBalance = abi.decode(returnData, (uint256));
        } else {
            lpBalance = 0;
        }
    }

    function getDexFees(uint8 dexId)
        external
        dexCall(dexId)
        returns (
            address[] memory tokens,
            uint256[] memory claimedAmounts,
            uint256[] memory pendingAmounts
        )
    {
        DexRegistration storage registration = _dexAdapters[dexId];
        if (_dexAdapters[dexId].adapter != address(0)) {
            bytes memory returnData = _delegateCall(
                registration.adapter,
                abi.encodeWithSelector(IDexAdapter.getFees.selector)
            );
            (tokens, claimedAmounts, pendingAmounts) = abi.decode(returnData, (address[], uint256[], uint256[]));
        } else {
            uint256 n = _dexSpotConfigs[dexId].assetIds.length;
            tokens = new address[](n);
            claimedAmounts = _makeEmpty(n);
            pendingAmounts = _makeEmpty(n);
        }
    }

    function getDexSpotAmounts(uint8 dexId, uint256 shareAmount)
        public
        dexCall(dexId)
        returns (uint256[] memory amounts)
    {
        DexRegistration storage registration = _dexAdapters[dexId];
        if (_dexAdapters[dexId].adapter != address(0)) {
            bytes memory returnData = _delegateCall(
                registration.adapter,
                abi.encodeWithSelector(IDexAdapter.getSpotAmounts.selector, shareAmount)
            );
            amounts = abi.decode(returnData, (uint256[]));
        } else {
            uint256 n = _dexSpotConfigs[dexId].assetIds.length;
            amounts = _makeEmpty(n);
        }
    }

    function getDexTotalSpotAmounts(uint8 dexId) public dexCall(dexId) returns (uint256[] memory amounts) {
        DexRegistration storage registration = _dexAdapters[dexId];
        if (_dexAdapters[dexId].adapter != address(0)) {
            bytes memory returnData = _delegateCall(
                registration.adapter,
                abi.encodeWithSelector(IDexAdapter.getTotalSpotAmounts.selector)
            );
            amounts = abi.decode(returnData, (uint256[]));
        }
    }

    function getDexLiquidityData(uint8 dexId, uint256[] memory amounts)
        external
        dexCall(dexId)
        returns (bytes memory data)
    {
        DexRegistration storage registration = _dexAdapters[dexId];
        if (_dexAdapters[dexId].adapter != address(0)) {
            data = _delegateCall(registration.adapter, abi.encodeWithSignature("getLiquidityData(uint256[])", amounts));
        }
    }

    // write methods
    function addDexLiquidityUniSwapV2(
        uint8 dexId,
        uint256[] calldata amounts,
        uint256 deadline
    ) external dexCall(dexId) auth returns (uint256[] memory addedAmounts, uint256 liquidityAmount) {
        DexRegistration storage registration = _dexAdapters[dexId];
        require(!registration.disabled, "FRZ");
        require(registration.adapter != address(0), "ANS"); // adapter not set
        _fetchAssets(_dexSpotConfigs[dexId].assetIds, amounts);
        uint256[] memory minAmounts = new uint256[](amounts.length);
        uint256 rate = BASE_RATE - registration.slippage;
        minAmounts[0] = (amounts[0] * rate) / BASE_RATE;
        minAmounts[1] = (amounts[1] * rate) / BASE_RATE;
        bytes memory returnData = _delegateCall(
            registration.adapter,
            abi.encodeWithSelector(IDexAdapter.addLiquidityUniSwapV2.selector, amounts, minAmounts, deadline)
        );
        (addedAmounts, liquidityAmount) = abi.decode(returnData, (uint256[], uint256));
        _repayAssets(dexId, amounts, addedAmounts);

        emit AddDexLiquidity(dexId, amounts, addedAmounts, liquidityAmount, abi.encode(minAmounts, deadline));
    }

    // write methods
    function addDexLiquidityCurve(
        uint8 dexId,
        uint256[] calldata maxAmounts,
        uint256 desiredAmount
    ) external dexCall(dexId) auth returns (uint256[] memory addedAmounts, uint256 liquidityAmount) {
        DexRegistration storage registration = _dexAdapters[dexId];
        require(!registration.disabled, "FRZ");
        require(registration.adapter != address(0), "ANS"); // adapter not set
        _fetchAssets(_dexSpotConfigs[dexId].assetIds, maxAmounts);
        uint256 minLpAmount = (desiredAmount * (BASE_RATE - registration.slippage)) / BASE_RATE;
        bytes memory returnData = _delegateCall(
            registration.adapter,
            abi.encodeWithSelector(IDexAdapter.addLiquidityCurve.selector, maxAmounts, minLpAmount)
        );
        (addedAmounts, liquidityAmount) = abi.decode(returnData, (uint256[], uint256));

        emit AddDexLiquidity(dexId, maxAmounts, addedAmounts, liquidityAmount, abi.encode(desiredAmount, minLpAmount));
    }

    function removeDexLiquidity(
        uint8 dexId,
        uint256 shareAmount,
        uint256[] calldata minAmounts,
        uint256 deadline
    ) external dexCall(dexId) auth returns (uint256[] memory removedAmounts) {
        DexRegistration storage registration = _dexAdapters[dexId];
        require(!registration.disabled, "FRZ");
        require(registration.adapter != address(0), "ANS"); // adapter not set

        bytes memory returnData = _delegateCall(
            registration.adapter,
            abi.encodeWithSelector(IDexAdapter.removeLiquidity.selector, shareAmount, minAmounts, deadline)
        );
        removedAmounts = abi.decode(returnData, (uint256[]));
        if (removedAmounts.length != 0) {
            _pushAssets(_dexSpotConfigs[dexId].assetIds, removedAmounts);
        }
        emit RemoveDexLiquidity(dexId, shareAmount, minAmounts, deadline);
    }

    function claimDexFees(uint8 dexId) external dexCall(dexId) {
        DexRegistration storage registration = _dexAdapters[dexId];
        require(registration.adapter != address(0), "ANS"); // adapter not set
        _delegateCall(registration.adapter, abi.encodeWithSelector(IDexAdapter.claimFees.selector, dexId));
    }

    function _initializeAdapter(uint8 dexId, bytes memory initialData) internal dexCall(dexId) {
        DexRegistration storage registration = _dexAdapters[dexId];
        require(registration.adapter != address(0), "ANS"); // adapter not set
        _delegateCall(
            registration.adapter,
            abi.encodeWithSelector(IDexAdapter.initializeAdapter.selector, initialData)
        );
        emit ClaimDexFees(dexId);
    }

    // helpers
    function _makeEmpty(uint256 length) internal pure returns (uint256[] memory empty) {
        empty = new uint256[](length);
    }

    function _delegateCall(address target, bytes memory callData) internal returns (bytes memory) {
        (bool success, bytes memory returnData) = target.delegatecall(callData);
        return AddressUpgradeable.verifyCallResult(success, returnData, "!DC");
    }
}

File 2 of 19 : IDexAdapter.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.10;

interface IDexAdapter {
    function initializeAdapter(bytes memory initialData) external;

    function getLpBalance() external view returns (uint256);

    function getFees()
        external
        returns (
            address[] memory rewardTokens,
            uint256[] memory collectedFeeAmounts,
            uint256[] memory pendingFeeAmounts
        );

    function getTotalSpotAmounts() external view returns (uint256[] memory amounts);

    function getSpotAmounts(uint256 shareAmount) external view returns (uint256[] memory amounts);

    function addLiquidityUniSwapV2(
        uint256[] calldata maxAmounts,
        uint256[] calldata minAmounts,
        uint256 deadline
    ) external returns (uint256[] memory addedAmounts, uint256 liquidityAmount);

    function addLiquidityCurve(uint256[] calldata maxAmounts, uint256 minLpAmount)
        external
        returns (uint256[] memory addedAmounts, uint256 liquidityAmount);

    function removeLiquidity(
        uint256 shareAmount,
        uint256[] calldata minAmounts,
        uint256 deadline
    ) external returns (uint256[] memory removedAmounts);

    function claimFees() external;
}

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

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"dexId","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"dexType","type":"uint8"},{"indexed":false,"internalType":"uint32","name":"dexWeight","type":"uint32"},{"indexed":false,"internalType":"uint8[]","name":"assetIds","type":"uint8[]"},{"indexed":false,"internalType":"uint32[]","name":"assetWeightInDex","type":"uint32[]"}],"name":"AddDex","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"dexId","type":"uint8"},{"indexed":false,"internalType":"uint256[]","name":"maxAmounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"addedAmounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"lpAmount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"extraData","type":"bytes"}],"name":"AddDexLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"dexId","type":"uint8"}],"name":"ClaimDexFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8[]","name":"assetIds","type":"uint8[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"FetchAssets","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bytes4","name":"sig","type":"bytes4"},{"indexed":false,"internalType":"bytes","name":"payload","type":"bytes"}],"name":"PluginCall","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"PrepareToTransferOwnership","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8[]","name":"assetIds","type":"uint8[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"PushAssets","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"dexId","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"shareAmount","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"minAmounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"RemoveDexLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"dexId","type":"uint8"},{"indexed":false,"internalType":"uint8[]","name":"assetIds","type":"uint8[]"}],"name":"SetAssetIds","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"dexId","type":"uint8"},{"indexed":false,"internalType":"address","name":"entrypoint","type":"address"},{"indexed":false,"internalType":"bytes","name":"initialData","type":"bytes"}],"name":"SetDexAdapter","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"dexId","type":"uint8"},{"indexed":false,"internalType":"uint32","name":"slippage","type":"uint32"}],"name":"SetDexSlippage","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"dexId","type":"uint8"},{"indexed":false,"internalType":"uint32","name":"dexWeight","type":"uint32"},{"indexed":false,"internalType":"uint32[]","name":"assetWeightInDex","type":"uint32[]"}],"name":"SetDexWeight","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"dexId","type":"uint8"},{"indexed":false,"internalType":"bool","name":"enable","type":"bool"}],"name":"SetDexWrapperEnable","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"handler","type":"address"},{"indexed":false,"internalType":"bool","name":"enable","type":"bool"}],"name":"SetHandler","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousMaintainer","type":"address"},{"indexed":false,"internalType":"address","name":"newMaintainer","type":"address"}],"name":"SetMaintainer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"plugin","type":"address"},{"indexed":false,"internalType":"bool","name":"enable","type":"bool"},{"indexed":false,"internalType":"bytes4[]","name":"selectors","type":"bytes4[]"}],"name":"SetPlugin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousVault","type":"address"},{"indexed":false,"internalType":"address","name":"newPool","type":"address"}],"name":"SetPool","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousVault","type":"address"},{"indexed":false,"internalType":"address","name":"newVault","type":"address"}],"name":"SetVault","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawToken","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"uint256[]","name":"maxAmounts","type":"uint256[]"},{"internalType":"uint256","name":"desiredAmount","type":"uint256"}],"name":"addDexLiquidityCurve","outputs":[{"internalType":"uint256[]","name":"addedAmounts","type":"uint256[]"},{"internalType":"uint256","name":"liquidityAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"addDexLiquidityUniSwapV2","outputs":[{"internalType":"uint256[]","name":"addedAmounts","type":"uint256[]"},{"internalType":"uint256","name":"liquidityAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"uint8","name":"dexType","type":"uint8"},{"internalType":"uint32","name":"dexWeight","type":"uint32"},{"internalType":"uint8[]","name":"assetIds","type":"uint8[]"},{"internalType":"uint32[]","name":"assetWeightInDex","type":"uint32[]"}],"name":"addDexSpotConfiguration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"}],"name":"claimDexFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"freezeDexWrapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAllDexSpotConfiguration","outputs":[{"components":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"uint8","name":"dexType","type":"uint8"},{"internalType":"uint32","name":"dexWeight","type":"uint32"},{"internalType":"uint8[]","name":"assetIds","type":"uint8[]"},{"internalType":"uint32[]","name":"assetWeightInDex","type":"uint32[]"},{"internalType":"uint256[]","name":"totalSpotInDex","type":"uint256[]"}],"internalType":"struct DexSpotConfiguration[]","name":"configs","type":"tuple[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"}],"name":"getDexAdapter","outputs":[{"components":[{"internalType":"address","name":"adapter","type":"address"},{"internalType":"bool","name":"disabled","type":"bool"},{"internalType":"uint32","name":"slippage","type":"uint32"}],"internalType":"struct DexRegistration","name":"registration","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"}],"name":"getDexAdapterConfig","outputs":[{"internalType":"bytes","name":"config","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"bytes32","name":"key","type":"bytes32"}],"name":"getDexAdapterState","outputs":[{"internalType":"bytes32","name":"state","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"}],"name":"getDexFees","outputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"claimedAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"pendingAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"}],"name":"getDexLiquidity","outputs":[{"internalType":"uint256[]","name":"liquidities","type":"uint256[]"},{"internalType":"uint256","name":"lpBalance","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"getDexLiquidityData","outputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"}],"name":"getDexLpBalance","outputs":[{"internalType":"uint256","name":"lpBalance","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"uint256","name":"shareAmount","type":"uint256"}],"name":"getDexSpotAmounts","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"}],"name":"getDexSpotConfiguration","outputs":[{"components":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"uint8","name":"dexType","type":"uint8"},{"internalType":"uint32","name":"dexWeight","type":"uint32"},{"internalType":"uint8[]","name":"assetIds","type":"uint8[]"},{"internalType":"uint32[]","name":"assetWeightInDex","type":"uint32[]"},{"internalType":"uint256[]","name":"totalSpotInDex","type":"uint256[]"}],"internalType":"struct DexSpotConfiguration","name":"config","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"}],"name":"getDexTotalSpotAmounts","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getMaintainer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vault_","type":"address"},{"internalType":"address","name":"pool_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"handler","type":"address"}],"name":"isHandler","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8[]","name":"assetIds","type":"uint8[]"}],"name":"refreshTokenCache","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"uint256","name":"shareAmount","type":"uint256"},{"internalType":"uint256[]","name":"minAmounts","type":"uint256[]"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeDexLiquidity","outputs":[{"internalType":"uint256[]","name":"removedAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"uint8[]","name":"assetIds","type":"uint8[]"}],"name":"setAssetIds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"uint32","name":"slippage","type":"uint32"}],"name":"setDexSlippage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"uint32","name":"dexWeight","type":"uint32"},{"internalType":"uint32[]","name":"assetWeightInDex","type":"uint32[]"}],"name":"setDexWeight","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"dexId","type":"uint8"},{"internalType":"address","name":"adapter","type":"address"},{"internalType":"bytes","name":"initialData","type":"bytes"}],"name":"setDexWrapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"handler","type":"address"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"setHandler","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newMaintainer","type":"address"}],"name":"setMaintainer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"plugin","type":"address"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"setPlugin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newPool","type":"address"}],"name":"setPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newVault","type":"address"}],"name":"setVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"takeOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801561001057600080fd5b50614fb5806100206000396000f3fe60806040526004361061021e5760003560e01c806360536172116101235780639e281a98116100ab578063ea5a22501161006f578063ea5a22501461074f578063f0017eb21461076f578063f2fde38b1461078f578063f5f59bbc146107af578063fe14de64146107f057610225565b80639e281a9814610693578063a1384aa7146106b3578063d8ce54dd146106e2578063da8782cf1461070f578063df0762a81461072f57610225565b80638a3d3d09116100f25780638a3d3d09146105f65780638d928af8146106165780638da5cb5b146106355780638f468610146106535780639cb7de4b1461067357610225565b8063605361721461058c5780636817031b146105a1578063715018a6146105c157806375c8f2c9146105d657610225565b80633d598e58116101a6578063485cc95511610175578063485cc955146104ed5780634b0a72bc1461050d5780634cb37c291461052c5780634ed6c7761461054c57806356315c261461056c57610225565b80633d598e58146104285780634437152a14610455578063447d1ae11461047557806346ea87af146104a357610225565b80631bcb2995116101ed5780631bcb2995146102d457806324f75314146103025780632e0018ea146103b957806339270ede146103db5780633bb6d5e31461040857610225565b8063026b1d5f1461023c5780630c2254ef146102745780630f0282bd1461029457806313ea5d29146102b457610225565b3661022557005b34801561023157600080fd5b5061023a610810565b005b34801561024857600080fd5b5061012f546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b34801561028057600080fd5b5061023a61028f366004613cc6565b6108e1565b3480156102a057600080fd5b5061023a6102af366004613d67565b610bcd565b3480156102c057600080fd5b5061023a6102cf366004613d9a565b610ce9565b3480156102e057600080fd5b506102f46102ef366004613d67565b610dad565b60405190815260200161026b565b34801561030e57600080fd5b5061038661031d366004613d67565b60408051606080820183526000808352602080840182905292840181905260ff9485168152610135835283902083519182018452546001600160a01b0381168252600160a01b8104909416151591810191909152600160a81b90920463ffffffff169082015290565b6040805182516001600160a01b031681526020808401511515908201529181015163ffffffff169082015260600161026b565b3480156103c557600080fd5b506103ce610ebb565b60405161026b9190613ecd565b3480156103e757600080fd5b506103fb6103f6366004613f2f565b610f88565b60405161026b9190613f90565b34801561041457600080fd5b506103fb610423366004613fa3565b6111da565b34801561043457600080fd5b50610448610443366004613d67565b61130e565b60405161026b9190614029565b34801561046157600080fd5b5061023a610470366004613d9a565b6113b5565b34801561048157600080fd5b5061049561049036600461403c565b6114b5565b60405161026b929190614095565b3480156104af57600080fd5b506104dd6104be366004613d9a565b6001600160a01b03166000908152610131602052604090205460ff1690565b604051901515815260200161026b565b3480156104f957600080fd5b5061023a6105083660046140b7565b61179b565b34801561051957600080fd5b50610138546001600160a01b0316610257565b34801561053857600080fd5b5061049561054736600461403c565b61189c565b34801561055857600080fd5b50610448610567366004614155565b611be3565b34801561057857600080fd5b5061023a61058736600461427b565b611cde565b34801561059857600080fd5b5061023a611df1565b3480156105ad57600080fd5b5061023a6105bc366004613d9a565b611e64565b3480156105cd57600080fd5b5061023a611f64565b3480156105e257600080fd5b5061023a6105f13660046142d6565b611fab565b34801561060257600080fd5b5061023a610611366004614302565b61206a565b34801561062257600080fd5b5061012e546001600160a01b0316610257565b34801561064157600080fd5b5060fb546001600160a01b0316610257565b34801561065f57600080fd5b506103fb61066e366004613d67565b61217c565b34801561067f57600080fd5b5061023a61068e366004614336565b612281565b34801561069f57600080fd5b5061023a6106ae366004614354565b612348565b3480156106bf57600080fd5b506106d36106ce366004613d67565b6123e9565b60405161026b93929190614372565b3480156106ee57600080fd5b506107026106fd366004613d67565b612588565b60405161026b91906143e7565b34801561071b57600080fd5b5061023a61072a3660046143fa565b6125d2565b34801561073b57600080fd5b5061023a61074a366004614336565b6126f3565b34801561075b57600080fd5b5061023a61076a3660046144bf565b612a73565b34801561077b57600080fd5b5061023a61078a36600461457a565b612b45565b34801561079b57600080fd5b5061023a6107aa366004613d9a565b612c4b565b3480156107bb57600080fd5b506102f46107ca366004613fa3565b60ff90911660009081526101336020908152604080832093835260019093019052205490565b3480156107fc57600080fd5b5061049561080b366004613d67565b612d40565b600080356001600160e01b031916815261013660205260409020546001600160a01b03168061086c5760405162461bcd60e51b81526020600482015260036024820152624e504760e81b60448201526064015b60405180910390fd5b7fc4c7e4df8dcfb55b6be85f552942c3fed4de43d182818ef455cc76f3dcebcf1033826000356001600160e01b0319166000366040516108b09594939291906145ad565b60405180910390a13660008037600080366000845af43d6000803e8080156108d7573d6000f35b3d6000fd5b505050565b60fb546001600160a01b0316331461090b5760405162461bcd60e51b81526004016108639061460a565b6101305461010010156109465760405162461bcd60e51b815260206004820152600360248201526211931360ea1b6044820152606401610863565b826109795760405162461bcd60e51b81526020600482015260036024820152624d545960e81b6044820152606401610863565b8281146109985760405162461bcd60e51b81526004016108639061463f565b6101305460ff8816146109d35760405162461bcd60e51b815260206004820152600360248201526249444960e81b6044820152606401610863565b6101306040518060c001604052808960ff1681526020018860ff1681526020018763ffffffff1681526020018686808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506040805160208681028281018201909352868252928301929091879187918291850190849080828437600092019190915250505090825250602001610a7986612d60565b905281546001818101845560009384526020938490208351600490930201805485850151604086015163ffffffff16620100000265ffffffff00001960ff9283166101000261ffff19909416929096169190911791909117939093169290921782556060830151805193949293610af893928501929190910190613a8f565b5060808201518051610b14916002840191602090910190613b35565b5060a08201518051610b30916003840191602090910190613bd2565b50505060005b83811015610b8057610b6d858583818110610b5357610b5361465c565b9050602002016020810190610b689190613d67565b612daa565b5080610b7881614688565b915050610b36565b507f9083feb96be9e0d24fc4efabe3d93583fe8da6522667e53e6a7799c30e4efaf387878787878787604051610bbc97969594939291906146a3565b60405180910390a150505050505050565b8060ff8116610bee5760405162461bcd60e51b81526004016108639061474f565b6101325460ff1680610c0f57610132805460ff191660ff8416179055610c34565b8160ff168160ff1614610c345760405162461bcd60e51b81526004016108639061476c565b60ff831660009081526101356020526040902080546001600160a01b0316610c6e5760405162461bcd60e51b815260040161086390614789565b805460405160ff86166024820152610cce916001600160a01b03169063d294f09360e01b906044015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612e70565b5050610132805460ff191660ff929092169190911790555050565b60fb546001600160a01b03163314610d135760405162461bcd60e51b81526004016108639061460a565b610138546001600160a01b0382811691161415610d425760405162461bcd60e51b8152600401610863906147a6565b61013854604080516001600160a01b03928316815291831660208301527f4a0b4f56d51e80b4326f54a5c49a82dd619e7f6f936f3f381de080d05dcbab1b910160405180910390a161013880546001600160a01b0319166001600160a01b0392909216919091179055565b60008160ff8116610dd05760405162461bcd60e51b81526004016108639061474f565b6101325460ff1680610df157610132805460ff191660ff8416179055610e16565b8160ff168160ff1614610e165760405162461bcd60e51b81526004016108639061476c565b60ff841660009081526101356020526040902080546001600160a01b031615610e9a5780546040805160048152602481019091526020810180516001600160e01b0316638421403d60e01b179052600091610e7c916001600160a01b0390911690612e70565b905080806020019051810190610e9291906147c3565b945050610e9f565b600093505b50610132805460ff191660ff9290921691909117905550919050565b61013054606090600090610ed1906001906147dc565b905080610edc575090565b806001600160401b03811115610ef457610ef46140f0565b604051908082528060200260200182016040528015610f2d57816020015b610f1a613c0d565b815260200190600190039081610f125790505b50915060015b818160ff1611610f8357610f4681612f01565b83610f526001846147f3565b60ff1681518110610f6557610f6561465c565b60200260200101819052508080610f7b90614816565b915050610f33565b505090565b60608560ff8116610fab5760405162461bcd60e51b81526004016108639061474f565b6101325460ff1680610fcc57610132805460ff191660ff8416179055610ff1565b8160ff168160ff1614610ff15760405162461bcd60e51b81526004016108639061476c565b336000908152610131602052604090205460ff166110215760405162461bcd60e51b815260040161086390614836565b60ff80891660009081526101356020526040902080549091600160a01b909104161561105f5760405162461bcd60e51b815260040161086390614853565b80546001600160a01b03166110865760405162461bcd60e51b815260040161086390614789565b80546040516000916110bb916001600160a01b039091169063031cd52b60e41b90610c97908d908d908d908d906024016148a6565b9050808060200190518101906110d19190614937565b9450845160001461117a5761117a6101308b60ff16815481106110f6576110f661465c565b906000526020600020906004020160010180548060200260200160405190810160405280929190818152602001828054801561116f57602002820191906000526020600020906000905b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116111405790505b5050505050866130da565b7fde4c0c5c30ef58217b2e9b0fd3783365142b2e2645b741e3bd3f72b57c7de02d8a8a8a8a8a6040516111b195949392919061496b565b60405180910390a15050610132805460ff191660ff929092169190911790555095945050505050565b60608260ff81166111fd5760405162461bcd60e51b81526004016108639061474f565b6101325460ff168061121e57610132805460ff191660ff8416179055611243565b8160ff168160ff16146112435760405162461bcd60e51b81526004016108639061476c565b60ff851660009081526101356020526040902080546001600160a01b0316156112b457805460405160248101879052600091611296916001600160a01b0390911690632ca7bbbd60e11b90604401610c97565b9050808060200190518101906112ac9190614937565b9450506112f1565b60006101308760ff16815481106112cd576112cd61465c565b90600052602060002090600402016001018054905090506112ed81612d60565b9450505b50610132805460ff191660ff929092169190911790555092915050565b60ff8116600090815261013360205260409020805460609190611330906149a0565b80601f016020809104026020016040519081016040528092919081815260200182805461135c906149a0565b80156113a95780601f1061137e576101008083540402835291602001916113a9565b820191906000526020600020905b81548152906001019060200180831161138c57829003601f168201915b50505050509050919050565b60fb546001600160a01b031633146113df5760405162461bcd60e51b81526004016108639061460a565b6001600160a01b03811661141b5760405162461bcd60e51b815260206004820152600360248201526216905160ea1b6044820152606401610863565b61012f546001600160a01b038281169116141561144a5760405162461bcd60e51b8152600401610863906147a6565b61012f54604080516001600160a01b03928316815291831660208301527f390ace337562623e4cf938891cfa7e80b7b2e6ff395963aba93e537ce67e842c910160405180910390a161012f80546001600160a01b0319166001600160a01b0392909216919091179055565b606060008560ff81166114da5760405162461bcd60e51b81526004016108639061474f565b6101325460ff16806114fb57610132805460ff191660ff8416179055611520565b8160ff168160ff16146115205760405162461bcd60e51b81526004016108639061476c565b336000908152610131602052604090205460ff166115505760405162461bcd60e51b815260040161086390614836565b60ff80891660009081526101356020526040902080549091600160a01b909104161561158e5760405162461bcd60e51b815260040161086390614853565b80546001600160a01b03166115b55760405162461bcd60e51b815260040161086390614789565b6116866101308a60ff16815481106115cf576115cf61465c565b906000526020600020906004020160010180548060200260200160405190810160405280929190818152602001828054801561164857602002820191906000526020600020906000905b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116116195790505b505050505089898080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061318d92505050565b8054600090620186a0906116a790600160a81b900463ffffffff16826147dc565b6116b190896149db565b6116bb91906149fa565b82546040519192506000916116ef916001600160a01b031690635e7d818b60e01b90610c97908e908e908890602401614a1c565b9050808060200190518101906117059190614a40565b80975081985050507f6aac9ce382c7a82b4ce0881b4a26b12ea0074236797b66ba59a23e8f611393048b8b8b8a8a8d8860405160200161174f929190918252602082015260400190565b60408051601f198184030181529082905261176e969594939291614a86565b60405180910390a15050610132805460ff191660ff93909316929092179091555091969095509350505050565b60c854610100900460ff166117b65760c85460ff16156117ba565b303b155b61181d5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610863565b60c854610100900460ff1615801561183f5760c8805461ffff19166101011790555b611847613244565b61012e80546001600160a01b038086166001600160a01b03199283161790925561012f8054928516929091169190911790556101308054600101815560005280156108dc5760c8805461ff0019169055505050565b606060008560ff81166118c15760405162461bcd60e51b81526004016108639061474f565b6101325460ff16806118e257610132805460ff191660ff8416179055611907565b8160ff168160ff16146119075760405162461bcd60e51b81526004016108639061476c565b336000908152610131602052604090205460ff166119375760405162461bcd60e51b815260040161086390614836565b60ff80891660009081526101356020526040902080549091600160a01b90910416156119755760405162461bcd60e51b815260040161086390614853565b80546001600160a01b031661199c5760405162461bcd60e51b815260040161086390614789565b6119b66101308a60ff16815481106115cf576115cf61465c565b6000876001600160401b038111156119d0576119d06140f0565b6040519080825280602002602001820160405280156119f9578160200160208202803683370190505b508254909150600090611a1c90600160a81b900463ffffffff16620186a06147dc565b9050620186a0818b8b6000818110611a3657611a3661465c565b90506020020135611a4791906149db565b611a5191906149fa565b82600081518110611a6457611a6461465c565b602002602001018181525050620186a0818b8b6001818110611a8857611a8861465c565b90506020020135611a9991906149db565b611aa391906149fa565b82600181518110611ab657611ab661465c565b6020026020010181815250506000611afe8460000160009054906101000a90046001600160a01b031663a9b5397d60e01b8d8d878e604051602401610c979493929190614adc565b905080806020019051810190611b149190614a40565b8098508199505050611b5b8c8c8c808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508d9250613273915050565b507f6aac9ce382c7a82b4ce0881b4a26b12ea0074236797b66ba59a23e8f611393048c8c8c8b8b888f604051602001611b95929190614095565b60408051601f1981840301815290829052611bb4969594939291614a86565b60405180910390a15050610132805460ff191660ff949094169390931790925550929791965090945050505050565b60608260ff8116611c065760405162461bcd60e51b81526004016108639061474f565b6101325460ff1680611c2757610132805460ff191660ff8416179055611c4c565b8160ff168160ff1614611c4c5760405162461bcd60e51b81526004016108639061476c565b60ff851660009081526101356020526040902080546001600160a01b0316156112f1578054604051611cbf916001600160a01b031690611c90908890602401613f90565b60408051601f198184030181529190526020810180516001600160e01b0316630592f8a560e11b179052612e70565b610132805460ff191660ff949094169390931790925550949350505050565b60fb546001600160a01b03163314611d085760405162461bcd60e51b81526004016108639061460a565b60ff821615801590611d1f57506101305460ff8316105b611d3b5760405162461bcd60e51b815260040161086390614b14565b611d4482610dad565b15611d775760405162461bcd60e51b815260206004820152600360248201526211909160ea1b6044820152606401610863565b806101308360ff1681548110611d8f57611d8f61465c565b90600052602060002090600402016001019080519060200190611db3929190613a8f565b507fe6fdb15f9a5f25ba22d841fea695803791dc5ac2a4efb3cc452b567b0b3ba1108282604051611de5929190614b64565b60405180910390a15050565b61012d546001600160a01b0316336001600160a01b031614611e3b5760405162461bcd60e51b815260206004820152600360248201526214d39160ea1b6044820152606401610863565b61012d54611e51906001600160a01b031661343d565b61012d80546001600160a01b0319169055565b60fb546001600160a01b03163314611e8e5760405162461bcd60e51b81526004016108639061460a565b6001600160a01b038116611eca5760405162461bcd60e51b815260206004820152600360248201526216905160ea1b6044820152606401610863565b61012e546001600160a01b0382811691161415611ef95760405162461bcd60e51b8152600401610863906147a6565b61012e54604080516001600160a01b03928316815291831660208301527f22a9f7c8a21e91a43518238948d4ed67511ad8492ca0e13fdbc93c134701a72a910160405180910390a161012e80546001600160a01b0319166001600160a01b0392909216919091179055565b60fb546001600160a01b03163314611f8e5760405162461bcd60e51b81526004016108639061460a565b61012d80546001600160a01b0319169055611fa9600061343d565b565b60fb546001600160a01b03163314611fd55760405162461bcd60e51b81526004016108639061460a565b60ff821615801590611fec57506101305460ff8316105b6120085760405162461bcd60e51b815260040161086390614b14565b60ff821660008181526101356020908152604091829020805460ff60a01b19168515600160a01b810291909117909155825193845215908301527fde8039381db35105e31bfa44584c4a61db5b390f751d0842f11476e24c7bda899101611de5565b60005b81518110156121785761012f5482516001600160a01b0390911690632d46c6c2908490849081106120a0576120a061465c565b60200260200101516040518263ffffffff1660e01b81526004016120cd919060ff91909116815260200190565b602060405180830381865afa1580156120ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210e9190614b80565b61013460008484815181106121255761212561465c565b602002602001015160ff1660ff16815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550808061217090614688565b91505061206d565b5050565b60608160ff811661219f5760405162461bcd60e51b81526004016108639061474f565b6101325460ff16806121c057610132805460ff191660ff84161790556121e5565b8160ff168160ff16146121e55760405162461bcd60e51b81526004016108639061476c565b60ff841660009081526101356020526040902080546001600160a01b031615610e9f5780546040805160048152602481019091526020810180516001600160e01b0316631005c7c760e31b17905260009161224b916001600160a01b0390911690612e70565b9050808060200190518101906122619190614937565b94505050610132805460ff90921660ff1990921691909117905550919050565b60fb546001600160a01b031633146122ab5760405162461bcd60e51b81526004016108639061460a565b6001600160a01b0382166000908152610131602052604090205460ff16151581151514156122eb5760405162461bcd60e51b8152600401610863906147a6565b6001600160a01b03821660008181526101316020908152604091829020805460ff19168515159081179091558251938452908301527fd373464a39404e5f98fdb4b152b8ba9a094561e97e5c4b4ea11eb18cd9e6695e9101611de5565b60fb546001600160a01b031633146123725760405162461bcd60e51b81526004016108639061460a565b6001600160a01b03821661238f5761238a338261348f565b6123a3565b6123a36001600160a01b03831633836135a8565b604080516001600160a01b03841681523360208201529081018290527f037238854fe57fbf51f09946f854fc3916fe83938d6521f09bd05463839f130490606001611de5565b606080808360ff811661240e5760405162461bcd60e51b81526004016108639061474f565b6101325460ff168061242f57610132805460ff191660ff8416179055612454565b8160ff168160ff16146124545760405162461bcd60e51b81526004016108639061476c565b60ff861660009081526101356020526040902080546001600160a01b0316156124de5780546040805160048152602481019091526020810180516001600160e01b031663db8d55f160e01b1790526000916124ba916001600160a01b0390911690612e70565b9050808060200190518101906124d09190614b9d565b9198509650945061256a9050565b60006101308860ff16815481106124f7576124f761465c565b9060005260206000209060040201600101805490509050806001600160401b03811115612526576125266140f0565b60405190808252806020026020018201604052801561254f578160200160208202803683370190505b50965061255b81612d60565b955061256681612d60565b9450505b50610132805460ff191660ff92909216919091179055509193909250565b612590613c0d565b60ff8216158015906125a757506101305460ff8316105b6125c35760405162461bcd60e51b815260040161086390614b14565b6125cc82612f01565b92915050565b60fb546001600160a01b031633146125fc5760405162461bcd60e51b81526004016108639061460a565b60ff83161580159061261357506101305460ff8416105b61262f5760405162461bcd60e51b815260040161086390614b14565b816101308460ff16815481106126475761264761465c565b906000526020600020906004020160000160026101000a81548163ffffffff021916908363ffffffff160217905550806101308460ff168154811061268e5761268e61465c565b906000526020600020906004020160020190805190602001906126b2929190613b35565b507f8a8f5fda8dffa25fc4847ab1e94503a97749d80d9f496d4964506ce7bbd9c06e8383836040516126e693929190614c90565b60405180910390a1505050565b60fb546001600160a01b0316331461271d5760405162461bcd60e51b81526004016108639061460a565b6001600160a01b0382166127595760405162461bcd60e51b81526020600482015260036024820152625a504160e81b6044820152606401610863565b6060826001600160a01b031663f274290b6040518163ffffffff1660e01b8152600401600060405180830381865afa9250505080156127ba57506040513d6000823e601f3d908101601f191682016040526127b79190810190614cf2565b60015b61284a576127c6614d99565b806308c379a0141561280057506127db614db5565b806127e65750612802565b8060405162461bcd60e51b81526004016108639190614029565b505b60405162461bcd60e51b815260206004820152601a60248201527f53757368694661726d3a3a43616c6c556e5374616b654661696c0000000000006044820152606401610863565b905081156129535760005b815181101561294d5760006001600160a01b031661013660008484815181106128805761288061465c565b6020908102919091018101516001600160e01b0319168252810191909152604001600020546001600160a01b0316146128e15760405162461bcd60e51b815260206004820152600360248201526250414560e81b6044820152606401610863565b8361013660008484815181106128f9576128f961465c565b6020908102919091018101516001600160e01b031916825281019190915260400160002080546001600160a01b0319166001600160a01b03929092169190911790558061294581614688565b915050612855565b50612a40565b60005b8151811015612a3e5760006001600160a01b031661013660008484815181106129815761298161465c565b6020908102919091018101516001600160e01b0319168252810191909152604001600020546001600160a01b031614156129e35760405162461bcd60e51b8152602060048201526003602482015262504e4560e81b6044820152606401610863565b61013660008383815181106129fa576129fa61465c565b6020908102919091018101516001600160e01b031916825281019190915260400160002080546001600160a01b031916905580612a3681614688565b915050612956565b505b7fe8bc441e42b94e4a57eed11e89ceca79d3a6efdff2832d1e48f86f2f45ca2d308383836040516126e693929190614e3e565b60fb546001600160a01b03163314612a9d5760405162461bcd60e51b81526004016108639061460a565b60ff831615801590612ab457506101305460ff8416105b612ad05760405162461bcd60e51b815260040161086390614b14565b60ff83166000908152610135602052604090208054607d60ab1b600164ffffffff0160a01b03199091166001600160a01b03851617179055612b1283826135fa565b7f0868d98f95ab8813a03cffd533e2822fab9479efe0ac15237d98f0180928a82f8383836040516126e693929190614ea9565b60fb546001600160a01b03163314612b6f5760405162461bcd60e51b81526004016108639061460a565b60ff821615801590612b8657506101305460ff8316105b612ba25760405162461bcd60e51b815260040161086390614b14565b620186a08163ffffffff161115612be15760405162461bcd60e51b815260206004820152600360248201526227a7a960e91b6044820152606401610863565b60ff821660008181526101356020908152604091829020805463ffffffff60a81b1916600160a81b63ffffffff8716908102919091179091558251938452908301527f38fb1a592d4049a40c14b94a27cb0459dab828dc87fb387e8bdbda776706f1d29101611de5565b60fb546001600160a01b03163314612c755760405162461bcd60e51b81526004016108639061460a565b6001600160a01b038116612cb15760405162461bcd60e51b815260206004820152600360248201526204f3d360ec1b6044820152606401610863565b60fb546001600160a01b0382811691161415612cf55760405162461bcd60e51b81526020600482015260036024820152624f3d4f60e81b6044820152606401610863565b61012d80546001600160a01b0319166001600160a01b0383169081179091556040517fb501f5dc3610d10a179d924f686fc89ddcdd3abb05afd7a1baeead166b2f122c90600090a250565b60606000612d4d83610dad565b9050612d5983826111da565b9150915091565b6060816001600160401b03811115612d7a57612d7a6140f0565b604051908082528060200260200182016040528015612da3578160200160208202803683370190505b5092915050565b60ff8116600090815261013460205260409020546001600160a01b031680612e6b5761012f546040516316a3636160e11b815260ff841660048201526001600160a01b0390911690632d46c6c290602401602060405180830381865afa158015612e18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e3c9190614b80565b60ff831660009081526101346020526040902080546001600160a01b0319166001600160a01b03831617905590505b919050565b6060600080846001600160a01b031684604051612e8d9190614ed6565b600060405180830381855af49150503d8060008114612ec8576040519150601f19603f3d011682016040523d82523d6000602084013e612ecd565b606091505b5091509150612ef882826040518060400160405280600381526020016221444360e81b815250613717565b95945050505050565b612f09613c0d565b6101308260ff1681548110612f2057612f2061465c565b60009182526020918290206040805160c0810182526004909302909101805460ff80821685526101008204168486015263ffffffff62010000909104168383015260018101805483518187028101870190945280845293949193606086019392830182828015612fcd57602002820191906000526020600020906000905b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411612f9e5790505b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561305157602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff16815260200190600401906020826003010492830192600103820291508084116130145790505b50505050508152602001600382018054806020026020016040519081016040528092919081815260200182805480156130a957602002820191906000526020600020905b815481526020019060010190808311613095575b50505050508152505090506001816020015160ff161415612e6b5760006130cf8361217c565b60a083015250919050565b61012f546130f2906001600160a01b03168383613757565b156121785761012f546040516302116fe560e11b81526001600160a01b0390911690630422dfca9061312a9085908590600401614ef2565b600060405180830381600087803b15801561314457600080fd5b505af1158015613158573d6000803e3d6000fd5b505050507faf0fc5e4cc697636cf17fe46d3aef6a04610a71ce1a9de8842d5408b12eca0b18282604051611de5929190614ef2565b80518251146131ae5760405162461bcd60e51b81526004016108639061463f565b61012f54604051634ff2c3d360e11b81526001600160a01b0390911690639fe587a6906131e19085908590600401614ef2565b600060405180830381600087803b1580156131fb57600080fd5b505af115801561320f573d6000803e3d6000fd5b505050507fd49617575cc0aa00922a48e5a6c4a8118756750d44fe3e12ea0669a236b907c08282604051611de5929190614ef2565b60c854610100900460ff1661326b5760405162461bcd60e51b815260040161086390614f17565b611fa9613816565b606081518351146132965760405162461bcd60e51b81526004016108639061463f565b8251806001600160401b038111156132b0576132b06140f0565b6040519080825280602002602001820160405280156132d9578160200160208202803683370190505b5091506000805b82811015613395578481815181106132fa576132fa61465c565b60200260200101518682815181106133145761331461465c565b60200260200101511115613383578481815181106133345761333461465c565b602002602001015186828151811061334e5761334e61465c565b602002602001015161336091906147dc565b8482815181106133725761337261465c565b602002602001018181525050600191505b8061338d81614688565b9150506132e0565b506134346101308760ff16815481106133b0576133b061465c565b906000526020600020906004020160010180548060200260200160405190810160405280929190818152602001828054801561342957602002820191906000526020600020906000905b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116133fa5790505b5050505050846130da565b50509392505050565b60fb80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b804710156134df5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610863565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461352c576040519150601f19603f3d011682016040523d82523d6000602084013e613531565b606091505b50509050806108dc5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610863565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526108dc908490613845565b8160ff811661361b5760405162461bcd60e51b81526004016108639061474f565b6101325460ff168061363c57610132805460ff191660ff8416179055613661565b8160ff168160ff16146136615760405162461bcd60e51b81526004016108639061476c565b60ff841660009081526101356020526040902080546001600160a01b031661369b5760405162461bcd60e51b815260040161086390614789565b80546040516136c5916001600160a01b031690630e1a7d1760e41b90610c97908890602401614029565b5060405160ff861681527f9aa77a2a0eb93487c4aaa91485120e31edaa4f8aff2455e4208986f5851958d69060200160405180910390a150610132805460ff191660ff92909216919091179055505050565b60608315613726575081613750565b8251156137365782518084602001fd5b8160405162461bcd60e51b81526004016108639190614029565b9392505050565b6000815183511461377a5760405162461bcd60e51b81526004016108639061463f565b60005b835181101561380e578281815181106137985761379861465c565b60200260200101516000146137fc576137f7858483815181106137bd576137bd61465c565b60200260200101516137e78785815181106137da576137da61465c565b6020026020010151612daa565b6001600160a01b031691906135a8565b600191505b8061380681614688565b91505061377d565b509392505050565b60c854610100900460ff1661383d5760405162461bcd60e51b815260040161086390614f17565b611fa9613917565b600061389a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166139479092919063ffffffff16565b8051909150156108dc57808060200190518101906138b89190614f62565b6108dc5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610863565b60c854610100900460ff1661393e5760405162461bcd60e51b815260040161086390614f17565b611fa93361343d565b6060613956848460008561395e565b949350505050565b6060824710156139bf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610863565b6001600160a01b0385163b613a165760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610863565b600080866001600160a01b03168587604051613a329190614ed6565b60006040518083038185875af1925050503d8060008114613a6f576040519150601f19603f3d011682016040523d82523d6000602084013e613a74565b606091505b5091509150613a84828286613717565b979650505050505050565b82805482825590600052602060002090601f01602090048101928215613b255791602002820160005b83821115613af657835183826101000a81548160ff021916908360ff1602179055509260200192600101602081600001049283019260010302613ab8565b8015613b235782816101000a81549060ff0219169055600101602081600001049283019260010302613af6565b505b50613b31929150613c41565b5090565b82805482825590600052602060002090600701600890048101928215613b255791602002820160005b83821115613ba257835183826101000a81548163ffffffff021916908363ffffffff1602179055509260200192600401602081600301049283019260010302613b5e565b8015613b235782816101000a81549063ffffffff0219169055600401602081600301049283019260010302613ba2565b828054828255906000526020600020908101928215613b25579160200282015b82811115613b25578251825591602001919060010190613bf2565b6040805160c0810182526000808252602082018190529181019190915260608082018190526080820181905260a082015290565b5b80821115613b315760008155600101613c42565b803560ff81168114612e6b57600080fd5b803563ffffffff81168114612e6b57600080fd5b60008083601f840112613c8d57600080fd5b5081356001600160401b03811115613ca457600080fd5b6020830191508360208260051b8501011115613cbf57600080fd5b9250929050565b600080600080600080600060a0888a031215613ce157600080fd5b613cea88613c56565b9650613cf860208901613c56565b9550613d0660408901613c67565b945060608801356001600160401b0380821115613d2257600080fd5b613d2e8b838c01613c7b565b909650945060808a0135915080821115613d4757600080fd5b50613d548a828b01613c7b565b989b979a50959850939692959293505050565b600060208284031215613d7957600080fd5b61375082613c56565b6001600160a01b0381168114613d9757600080fd5b50565b600060208284031215613dac57600080fd5b813561375081613d82565b600081518084526020808501945080840160005b83811015613ded57815163ffffffff1687529582019590820190600101613dcb565b509495945050505050565b600081518084526020808501945080840160005b83811015613ded57815187529582019590820190600101613e0c565b600060c0830160ff80845116855260208181860151168187015263ffffffff6040860151166040870152606085015160c0606088015283815180865260e0890191508383019550600092505b80831015613e9657855185168252948301946001929092019190830190613e74565b50608087015194508781036080890152613eb08186613db7565b94505050505060a083015184820360a0860152612ef88282613df8565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015613f2257603f19888603018452613f10858351613e28565b94509285019290850190600101613ef4565b5092979650505050505050565b600080600080600060808688031215613f4757600080fd5b613f5086613c56565b94506020860135935060408601356001600160401b03811115613f7257600080fd5b613f7e88828901613c7b565b96999598509660600135949350505050565b6020815260006137506020830184613df8565b60008060408385031215613fb657600080fd5b613fbf83613c56565b946020939093013593505050565b60005b83811015613fe8578181015183820152602001613fd0565b83811115613ff7576000848401525b50505050565b60008151808452614015816020860160208601613fcd565b601f01601f19169290920160200192915050565b6020815260006137506020830184613ffd565b6000806000806060858703121561405257600080fd5b61405b85613c56565b935060208501356001600160401b0381111561407657600080fd5b61408287828801613c7b565b9598909750949560400135949350505050565b6040815260006140a86040830185613df8565b90508260208301529392505050565b600080604083850312156140ca57600080fd5b82356140d581613d82565b915060208301356140e581613d82565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b038111828210171561412b5761412b6140f0565b6040525050565b60006001600160401b0382111561414b5761414b6140f0565b5060051b60200190565b6000806040838503121561416857600080fd5b61417183613c56565b91506020808401356001600160401b0381111561418d57600080fd5b8401601f8101861361419e57600080fd5b80356141a981614132565b6040516141b68282614106565b82815260059290921b83018401918481019150888311156141d657600080fd5b928401925b828410156141f4578335825292840192908401906141db565b80955050505050509250929050565b600082601f83011261421457600080fd5b8135602061422182614132565b60405161422e8282614106565b83815260059390931b850182019282810191508684111561424e57600080fd5b8286015b848110156142705761426381613c56565b8352918301918301614252565b509695505050505050565b6000806040838503121561428e57600080fd5b61429783613c56565b915060208301356001600160401b038111156142b257600080fd5b6142be85828601614203565b9150509250929050565b8015158114613d9757600080fd5b600080604083850312156142e957600080fd5b6142f283613c56565b915060208301356140e5816142c8565b60006020828403121561431457600080fd5b81356001600160401b0381111561432a57600080fd5b61395684828501614203565b6000806040838503121561434957600080fd5b82356142f281613d82565b6000806040838503121561436757600080fd5b8235613fbf81613d82565b606080825284519082018190526000906020906080840190828801845b828110156143b45781516001600160a01b03168452928401929084019060010161438f565b505050838103828501526143c88187613df8565b91505082810360408401526143dd8185613df8565b9695505050505050565b6020815260006137506020830184613e28565b60008060006060848603121561440f57600080fd5b61441884613c56565b92506020614427818601613c67565b925060408501356001600160401b0381111561444257600080fd5b8501601f8101871361445357600080fd5b803561445e81614132565b60405161446b8282614106565b82815260059290921b830184019184810191508983111561448b57600080fd5b928401925b828410156144b0576144a184613c67565b82529284019290840190614490565b80955050505050509250925092565b6000806000606084860312156144d457600080fd5b6144dd84613c56565b92506020808501356144ee81613d82565b925060408501356001600160401b038082111561450a57600080fd5b818701915087601f83011261451e57600080fd5b813581811115614530576145306140f0565b6040519150614548601f8201601f1916850183614106565b808252888482850101111561455c57600080fd5b80848401858401376000848284010152508093505050509250925092565b6000806040838503121561458d57600080fd5b61459683613c56565b91506145a460208401613c67565b90509250929050565b6001600160a01b038681168252851660208201526001600160e01b03198416604082015260806060820181905281018290526000828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600390820152622622a760e91b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561469c5761469c614672565b5060010190565b600060a0820160ff808b1684526020818b168186015263ffffffff808b16604087015260a060608701528389855260c0870190508a945060005b8a81101561470257846146ef87613c56565b16825294830194908301906001016146dd565b5086810360808801528781528201935087925060005b8781101561473d578161472a85613c67565b1685529382019392820192600101614718565b50929c9b505050505050505050505050565b6020808252600390820152625a444960e81b604082015260600190565b60208082526003908201526227222960e91b604082015260600190565b602080825260039082015262414e5360e81b604082015260600190565b60208082526003908201526204455560ec1b604082015260600190565b6000602082840312156147d557600080fd5b5051919050565b6000828210156147ee576147ee614672565b500390565b600060ff821660ff84168082101561480d5761480d614672565b90039392505050565b600060ff821660ff81141561482d5761482d614672565b60010192915050565b60208082526003908201526213921360ea1b604082015260600190565b60208082526003908201526223292d60e91b604082015260600190565b81835260006001600160fb1b0383111561488957600080fd5b8260051b8083602087013760009401602001938452509192915050565b8481526060602082015260006148c0606083018587614870565b905082604083015295945050505050565b600082601f8301126148e257600080fd5b815160206148ef82614132565b6040516148fc8282614106565b83815260059390931b850182019282810191508684111561491c57600080fd5b8286015b848110156142705780518352918301918301614920565b60006020828403121561494957600080fd5b81516001600160401b0381111561495f57600080fd5b613956848285016148d1565b60ff8616815284602082015260806040820152600061498e608083018587614870565b90508260608301529695505050505050565b600181811c908216806149b457607f821691505b602082108114156149d557634e487b7160e01b600052602260045260246000fd5b50919050565b60008160001904831182151516156149f5576149f5614672565b500290565b600082614a1757634e487b7160e01b600052601260045260246000fd5b500490565b604081526000614a30604083018587614870565b9050826020830152949350505050565b60008060408385031215614a5357600080fd5b82516001600160401b03811115614a6957600080fd5b614a75858286016148d1565b925050602083015190509250929050565b60ff8716815260a060208201526000614aa360a083018789614870565b8281036040840152614ab58187613df8565b90508460608401528281036080840152614acf8185613ffd565b9998505050505050505050565b606081526000614af0606083018688614870565b8281036020840152614b028186613df8565b91505082604083015295945050505050565b6020808252600390820152621314d560ea1b604082015260600190565b600081518084526020808501945080840160005b83811015613ded57815160ff1687529582019590820190600101614b45565b60ff831681526040602082015260006139566040830184614b31565b600060208284031215614b9257600080fd5b815161375081613d82565b600080600060608486031215614bb257600080fd5b83516001600160401b0380821115614bc957600080fd5b818601915086601f830112614bdd57600080fd5b81516020614bea82614132565b604051614bf78282614106565b83815260059390931b850182019282810191508a841115614c1757600080fd5b948201945b83861015614c3e578551614c2f81613d82565b82529482019490820190614c1c565b91890151919750909350505080821115614c5757600080fd5b614c63878388016148d1565b93506040860151915080821115614c7957600080fd5b50614c86868287016148d1565b9150509250925092565b60006060820160ff86168352602063ffffffff8087168286015260606040860152828651808552608087019150838801945060005b81811015614ce3578551841683529484019491840191600101614cc5565b50909998505050505050505050565b60006020808385031215614d0557600080fd5b82516001600160401b03811115614d1b57600080fd5b8301601f81018513614d2c57600080fd5b8051614d3781614132565b604051614d448282614106565b82815260059290921b8301840191848101915087831115614d6457600080fd5b928401925b82841015613a845783516001600160e01b031981168114614d8a5760008081fd5b82529284019290840190614d69565b600060033d1115614db25760046000803e5060005160e01c5b90565b600060443d1015614dc35790565b6040516003193d81016004833e81513d6001600160401b038160248401118184111715614df257505050505090565b8285019150815181811115614e0a5750505050505090565b843d8701016020828501011115614e245750505050505090565b614e3360208286010187614106565b509095945050505050565b6001600160a01b03841681528215156020808301919091526060604083018190528351908301819052600091848101916080850190845b81811015614e9b5784516001600160e01b03191683529383019391830191600101614e75565b509098975050505050505050565b60ff841681526001600160a01b0383166020820152606060408201819052600090612ef890830184613ffd565b60008251614ee8818460208701613fcd565b9190910192915050565b604081526000614f056040830185614b31565b8281036020840152612ef88185613df8565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600060208284031215614f7457600080fd5b8151613750816142c856fea264697066735822122023b8e147971a448e0a219ac6301929ada51823e74a2d02d4efee959ad0a77b0b64736f6c634300080a0033

Deployed Bytecode

0x60806040526004361061021e5760003560e01c806360536172116101235780639e281a98116100ab578063ea5a22501161006f578063ea5a22501461074f578063f0017eb21461076f578063f2fde38b1461078f578063f5f59bbc146107af578063fe14de64146107f057610225565b80639e281a9814610693578063a1384aa7146106b3578063d8ce54dd146106e2578063da8782cf1461070f578063df0762a81461072f57610225565b80638a3d3d09116100f25780638a3d3d09146105f65780638d928af8146106165780638da5cb5b146106355780638f468610146106535780639cb7de4b1461067357610225565b8063605361721461058c5780636817031b146105a1578063715018a6146105c157806375c8f2c9146105d657610225565b80633d598e58116101a6578063485cc95511610175578063485cc955146104ed5780634b0a72bc1461050d5780634cb37c291461052c5780634ed6c7761461054c57806356315c261461056c57610225565b80633d598e58146104285780634437152a14610455578063447d1ae11461047557806346ea87af146104a357610225565b80631bcb2995116101ed5780631bcb2995146102d457806324f75314146103025780632e0018ea146103b957806339270ede146103db5780633bb6d5e31461040857610225565b8063026b1d5f1461023c5780630c2254ef146102745780630f0282bd1461029457806313ea5d29146102b457610225565b3661022557005b34801561023157600080fd5b5061023a610810565b005b34801561024857600080fd5b5061012f546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b34801561028057600080fd5b5061023a61028f366004613cc6565b6108e1565b3480156102a057600080fd5b5061023a6102af366004613d67565b610bcd565b3480156102c057600080fd5b5061023a6102cf366004613d9a565b610ce9565b3480156102e057600080fd5b506102f46102ef366004613d67565b610dad565b60405190815260200161026b565b34801561030e57600080fd5b5061038661031d366004613d67565b60408051606080820183526000808352602080840182905292840181905260ff9485168152610135835283902083519182018452546001600160a01b0381168252600160a01b8104909416151591810191909152600160a81b90920463ffffffff169082015290565b6040805182516001600160a01b031681526020808401511515908201529181015163ffffffff169082015260600161026b565b3480156103c557600080fd5b506103ce610ebb565b60405161026b9190613ecd565b3480156103e757600080fd5b506103fb6103f6366004613f2f565b610f88565b60405161026b9190613f90565b34801561041457600080fd5b506103fb610423366004613fa3565b6111da565b34801561043457600080fd5b50610448610443366004613d67565b61130e565b60405161026b9190614029565b34801561046157600080fd5b5061023a610470366004613d9a565b6113b5565b34801561048157600080fd5b5061049561049036600461403c565b6114b5565b60405161026b929190614095565b3480156104af57600080fd5b506104dd6104be366004613d9a565b6001600160a01b03166000908152610131602052604090205460ff1690565b604051901515815260200161026b565b3480156104f957600080fd5b5061023a6105083660046140b7565b61179b565b34801561051957600080fd5b50610138546001600160a01b0316610257565b34801561053857600080fd5b5061049561054736600461403c565b61189c565b34801561055857600080fd5b50610448610567366004614155565b611be3565b34801561057857600080fd5b5061023a61058736600461427b565b611cde565b34801561059857600080fd5b5061023a611df1565b3480156105ad57600080fd5b5061023a6105bc366004613d9a565b611e64565b3480156105cd57600080fd5b5061023a611f64565b3480156105e257600080fd5b5061023a6105f13660046142d6565b611fab565b34801561060257600080fd5b5061023a610611366004614302565b61206a565b34801561062257600080fd5b5061012e546001600160a01b0316610257565b34801561064157600080fd5b5060fb546001600160a01b0316610257565b34801561065f57600080fd5b506103fb61066e366004613d67565b61217c565b34801561067f57600080fd5b5061023a61068e366004614336565b612281565b34801561069f57600080fd5b5061023a6106ae366004614354565b612348565b3480156106bf57600080fd5b506106d36106ce366004613d67565b6123e9565b60405161026b93929190614372565b3480156106ee57600080fd5b506107026106fd366004613d67565b612588565b60405161026b91906143e7565b34801561071b57600080fd5b5061023a61072a3660046143fa565b6125d2565b34801561073b57600080fd5b5061023a61074a366004614336565b6126f3565b34801561075b57600080fd5b5061023a61076a3660046144bf565b612a73565b34801561077b57600080fd5b5061023a61078a36600461457a565b612b45565b34801561079b57600080fd5b5061023a6107aa366004613d9a565b612c4b565b3480156107bb57600080fd5b506102f46107ca366004613fa3565b60ff90911660009081526101336020908152604080832093835260019093019052205490565b3480156107fc57600080fd5b5061049561080b366004613d67565b612d40565b600080356001600160e01b031916815261013660205260409020546001600160a01b03168061086c5760405162461bcd60e51b81526020600482015260036024820152624e504760e81b60448201526064015b60405180910390fd5b7fc4c7e4df8dcfb55b6be85f552942c3fed4de43d182818ef455cc76f3dcebcf1033826000356001600160e01b0319166000366040516108b09594939291906145ad565b60405180910390a13660008037600080366000845af43d6000803e8080156108d7573d6000f35b3d6000fd5b505050565b60fb546001600160a01b0316331461090b5760405162461bcd60e51b81526004016108639061460a565b6101305461010010156109465760405162461bcd60e51b815260206004820152600360248201526211931360ea1b6044820152606401610863565b826109795760405162461bcd60e51b81526020600482015260036024820152624d545960e81b6044820152606401610863565b8281146109985760405162461bcd60e51b81526004016108639061463f565b6101305460ff8816146109d35760405162461bcd60e51b815260206004820152600360248201526249444960e81b6044820152606401610863565b6101306040518060c001604052808960ff1681526020018860ff1681526020018763ffffffff1681526020018686808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506040805160208681028281018201909352868252928301929091879187918291850190849080828437600092019190915250505090825250602001610a7986612d60565b905281546001818101845560009384526020938490208351600490930201805485850151604086015163ffffffff16620100000265ffffffff00001960ff9283166101000261ffff19909416929096169190911791909117939093169290921782556060830151805193949293610af893928501929190910190613a8f565b5060808201518051610b14916002840191602090910190613b35565b5060a08201518051610b30916003840191602090910190613bd2565b50505060005b83811015610b8057610b6d858583818110610b5357610b5361465c565b9050602002016020810190610b689190613d67565b612daa565b5080610b7881614688565b915050610b36565b507f9083feb96be9e0d24fc4efabe3d93583fe8da6522667e53e6a7799c30e4efaf387878787878787604051610bbc97969594939291906146a3565b60405180910390a150505050505050565b8060ff8116610bee5760405162461bcd60e51b81526004016108639061474f565b6101325460ff1680610c0f57610132805460ff191660ff8416179055610c34565b8160ff168160ff1614610c345760405162461bcd60e51b81526004016108639061476c565b60ff831660009081526101356020526040902080546001600160a01b0316610c6e5760405162461bcd60e51b815260040161086390614789565b805460405160ff86166024820152610cce916001600160a01b03169063d294f09360e01b906044015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612e70565b5050610132805460ff191660ff929092169190911790555050565b60fb546001600160a01b03163314610d135760405162461bcd60e51b81526004016108639061460a565b610138546001600160a01b0382811691161415610d425760405162461bcd60e51b8152600401610863906147a6565b61013854604080516001600160a01b03928316815291831660208301527f4a0b4f56d51e80b4326f54a5c49a82dd619e7f6f936f3f381de080d05dcbab1b910160405180910390a161013880546001600160a01b0319166001600160a01b0392909216919091179055565b60008160ff8116610dd05760405162461bcd60e51b81526004016108639061474f565b6101325460ff1680610df157610132805460ff191660ff8416179055610e16565b8160ff168160ff1614610e165760405162461bcd60e51b81526004016108639061476c565b60ff841660009081526101356020526040902080546001600160a01b031615610e9a5780546040805160048152602481019091526020810180516001600160e01b0316638421403d60e01b179052600091610e7c916001600160a01b0390911690612e70565b905080806020019051810190610e9291906147c3565b945050610e9f565b600093505b50610132805460ff191660ff9290921691909117905550919050565b61013054606090600090610ed1906001906147dc565b905080610edc575090565b806001600160401b03811115610ef457610ef46140f0565b604051908082528060200260200182016040528015610f2d57816020015b610f1a613c0d565b815260200190600190039081610f125790505b50915060015b818160ff1611610f8357610f4681612f01565b83610f526001846147f3565b60ff1681518110610f6557610f6561465c565b60200260200101819052508080610f7b90614816565b915050610f33565b505090565b60608560ff8116610fab5760405162461bcd60e51b81526004016108639061474f565b6101325460ff1680610fcc57610132805460ff191660ff8416179055610ff1565b8160ff168160ff1614610ff15760405162461bcd60e51b81526004016108639061476c565b336000908152610131602052604090205460ff166110215760405162461bcd60e51b815260040161086390614836565b60ff80891660009081526101356020526040902080549091600160a01b909104161561105f5760405162461bcd60e51b815260040161086390614853565b80546001600160a01b03166110865760405162461bcd60e51b815260040161086390614789565b80546040516000916110bb916001600160a01b039091169063031cd52b60e41b90610c97908d908d908d908d906024016148a6565b9050808060200190518101906110d19190614937565b9450845160001461117a5761117a6101308b60ff16815481106110f6576110f661465c565b906000526020600020906004020160010180548060200260200160405190810160405280929190818152602001828054801561116f57602002820191906000526020600020906000905b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116111405790505b5050505050866130da565b7fde4c0c5c30ef58217b2e9b0fd3783365142b2e2645b741e3bd3f72b57c7de02d8a8a8a8a8a6040516111b195949392919061496b565b60405180910390a15050610132805460ff191660ff929092169190911790555095945050505050565b60608260ff81166111fd5760405162461bcd60e51b81526004016108639061474f565b6101325460ff168061121e57610132805460ff191660ff8416179055611243565b8160ff168160ff16146112435760405162461bcd60e51b81526004016108639061476c565b60ff851660009081526101356020526040902080546001600160a01b0316156112b457805460405160248101879052600091611296916001600160a01b0390911690632ca7bbbd60e11b90604401610c97565b9050808060200190518101906112ac9190614937565b9450506112f1565b60006101308760ff16815481106112cd576112cd61465c565b90600052602060002090600402016001018054905090506112ed81612d60565b9450505b50610132805460ff191660ff929092169190911790555092915050565b60ff8116600090815261013360205260409020805460609190611330906149a0565b80601f016020809104026020016040519081016040528092919081815260200182805461135c906149a0565b80156113a95780601f1061137e576101008083540402835291602001916113a9565b820191906000526020600020905b81548152906001019060200180831161138c57829003601f168201915b50505050509050919050565b60fb546001600160a01b031633146113df5760405162461bcd60e51b81526004016108639061460a565b6001600160a01b03811661141b5760405162461bcd60e51b815260206004820152600360248201526216905160ea1b6044820152606401610863565b61012f546001600160a01b038281169116141561144a5760405162461bcd60e51b8152600401610863906147a6565b61012f54604080516001600160a01b03928316815291831660208301527f390ace337562623e4cf938891cfa7e80b7b2e6ff395963aba93e537ce67e842c910160405180910390a161012f80546001600160a01b0319166001600160a01b0392909216919091179055565b606060008560ff81166114da5760405162461bcd60e51b81526004016108639061474f565b6101325460ff16806114fb57610132805460ff191660ff8416179055611520565b8160ff168160ff16146115205760405162461bcd60e51b81526004016108639061476c565b336000908152610131602052604090205460ff166115505760405162461bcd60e51b815260040161086390614836565b60ff80891660009081526101356020526040902080549091600160a01b909104161561158e5760405162461bcd60e51b815260040161086390614853565b80546001600160a01b03166115b55760405162461bcd60e51b815260040161086390614789565b6116866101308a60ff16815481106115cf576115cf61465c565b906000526020600020906004020160010180548060200260200160405190810160405280929190818152602001828054801561164857602002820191906000526020600020906000905b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116116195790505b505050505089898080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061318d92505050565b8054600090620186a0906116a790600160a81b900463ffffffff16826147dc565b6116b190896149db565b6116bb91906149fa565b82546040519192506000916116ef916001600160a01b031690635e7d818b60e01b90610c97908e908e908890602401614a1c565b9050808060200190518101906117059190614a40565b80975081985050507f6aac9ce382c7a82b4ce0881b4a26b12ea0074236797b66ba59a23e8f611393048b8b8b8a8a8d8860405160200161174f929190918252602082015260400190565b60408051601f198184030181529082905261176e969594939291614a86565b60405180910390a15050610132805460ff191660ff93909316929092179091555091969095509350505050565b60c854610100900460ff166117b65760c85460ff16156117ba565b303b155b61181d5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610863565b60c854610100900460ff1615801561183f5760c8805461ffff19166101011790555b611847613244565b61012e80546001600160a01b038086166001600160a01b03199283161790925561012f8054928516929091169190911790556101308054600101815560005280156108dc5760c8805461ff0019169055505050565b606060008560ff81166118c15760405162461bcd60e51b81526004016108639061474f565b6101325460ff16806118e257610132805460ff191660ff8416179055611907565b8160ff168160ff16146119075760405162461bcd60e51b81526004016108639061476c565b336000908152610131602052604090205460ff166119375760405162461bcd60e51b815260040161086390614836565b60ff80891660009081526101356020526040902080549091600160a01b90910416156119755760405162461bcd60e51b815260040161086390614853565b80546001600160a01b031661199c5760405162461bcd60e51b815260040161086390614789565b6119b66101308a60ff16815481106115cf576115cf61465c565b6000876001600160401b038111156119d0576119d06140f0565b6040519080825280602002602001820160405280156119f9578160200160208202803683370190505b508254909150600090611a1c90600160a81b900463ffffffff16620186a06147dc565b9050620186a0818b8b6000818110611a3657611a3661465c565b90506020020135611a4791906149db565b611a5191906149fa565b82600081518110611a6457611a6461465c565b602002602001018181525050620186a0818b8b6001818110611a8857611a8861465c565b90506020020135611a9991906149db565b611aa391906149fa565b82600181518110611ab657611ab661465c565b6020026020010181815250506000611afe8460000160009054906101000a90046001600160a01b031663a9b5397d60e01b8d8d878e604051602401610c979493929190614adc565b905080806020019051810190611b149190614a40565b8098508199505050611b5b8c8c8c808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508d9250613273915050565b507f6aac9ce382c7a82b4ce0881b4a26b12ea0074236797b66ba59a23e8f611393048c8c8c8b8b888f604051602001611b95929190614095565b60408051601f1981840301815290829052611bb4969594939291614a86565b60405180910390a15050610132805460ff191660ff949094169390931790925550929791965090945050505050565b60608260ff8116611c065760405162461bcd60e51b81526004016108639061474f565b6101325460ff1680611c2757610132805460ff191660ff8416179055611c4c565b8160ff168160ff1614611c4c5760405162461bcd60e51b81526004016108639061476c565b60ff851660009081526101356020526040902080546001600160a01b0316156112f1578054604051611cbf916001600160a01b031690611c90908890602401613f90565b60408051601f198184030181529190526020810180516001600160e01b0316630592f8a560e11b179052612e70565b610132805460ff191660ff949094169390931790925550949350505050565b60fb546001600160a01b03163314611d085760405162461bcd60e51b81526004016108639061460a565b60ff821615801590611d1f57506101305460ff8316105b611d3b5760405162461bcd60e51b815260040161086390614b14565b611d4482610dad565b15611d775760405162461bcd60e51b815260206004820152600360248201526211909160ea1b6044820152606401610863565b806101308360ff1681548110611d8f57611d8f61465c565b90600052602060002090600402016001019080519060200190611db3929190613a8f565b507fe6fdb15f9a5f25ba22d841fea695803791dc5ac2a4efb3cc452b567b0b3ba1108282604051611de5929190614b64565b60405180910390a15050565b61012d546001600160a01b0316336001600160a01b031614611e3b5760405162461bcd60e51b815260206004820152600360248201526214d39160ea1b6044820152606401610863565b61012d54611e51906001600160a01b031661343d565b61012d80546001600160a01b0319169055565b60fb546001600160a01b03163314611e8e5760405162461bcd60e51b81526004016108639061460a565b6001600160a01b038116611eca5760405162461bcd60e51b815260206004820152600360248201526216905160ea1b6044820152606401610863565b61012e546001600160a01b0382811691161415611ef95760405162461bcd60e51b8152600401610863906147a6565b61012e54604080516001600160a01b03928316815291831660208301527f22a9f7c8a21e91a43518238948d4ed67511ad8492ca0e13fdbc93c134701a72a910160405180910390a161012e80546001600160a01b0319166001600160a01b0392909216919091179055565b60fb546001600160a01b03163314611f8e5760405162461bcd60e51b81526004016108639061460a565b61012d80546001600160a01b0319169055611fa9600061343d565b565b60fb546001600160a01b03163314611fd55760405162461bcd60e51b81526004016108639061460a565b60ff821615801590611fec57506101305460ff8316105b6120085760405162461bcd60e51b815260040161086390614b14565b60ff821660008181526101356020908152604091829020805460ff60a01b19168515600160a01b810291909117909155825193845215908301527fde8039381db35105e31bfa44584c4a61db5b390f751d0842f11476e24c7bda899101611de5565b60005b81518110156121785761012f5482516001600160a01b0390911690632d46c6c2908490849081106120a0576120a061465c565b60200260200101516040518263ffffffff1660e01b81526004016120cd919060ff91909116815260200190565b602060405180830381865afa1580156120ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210e9190614b80565b61013460008484815181106121255761212561465c565b602002602001015160ff1660ff16815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550808061217090614688565b91505061206d565b5050565b60608160ff811661219f5760405162461bcd60e51b81526004016108639061474f565b6101325460ff16806121c057610132805460ff191660ff84161790556121e5565b8160ff168160ff16146121e55760405162461bcd60e51b81526004016108639061476c565b60ff841660009081526101356020526040902080546001600160a01b031615610e9f5780546040805160048152602481019091526020810180516001600160e01b0316631005c7c760e31b17905260009161224b916001600160a01b0390911690612e70565b9050808060200190518101906122619190614937565b94505050610132805460ff90921660ff1990921691909117905550919050565b60fb546001600160a01b031633146122ab5760405162461bcd60e51b81526004016108639061460a565b6001600160a01b0382166000908152610131602052604090205460ff16151581151514156122eb5760405162461bcd60e51b8152600401610863906147a6565b6001600160a01b03821660008181526101316020908152604091829020805460ff19168515159081179091558251938452908301527fd373464a39404e5f98fdb4b152b8ba9a094561e97e5c4b4ea11eb18cd9e6695e9101611de5565b60fb546001600160a01b031633146123725760405162461bcd60e51b81526004016108639061460a565b6001600160a01b03821661238f5761238a338261348f565b6123a3565b6123a36001600160a01b03831633836135a8565b604080516001600160a01b03841681523360208201529081018290527f037238854fe57fbf51f09946f854fc3916fe83938d6521f09bd05463839f130490606001611de5565b606080808360ff811661240e5760405162461bcd60e51b81526004016108639061474f565b6101325460ff168061242f57610132805460ff191660ff8416179055612454565b8160ff168160ff16146124545760405162461bcd60e51b81526004016108639061476c565b60ff861660009081526101356020526040902080546001600160a01b0316156124de5780546040805160048152602481019091526020810180516001600160e01b031663db8d55f160e01b1790526000916124ba916001600160a01b0390911690612e70565b9050808060200190518101906124d09190614b9d565b9198509650945061256a9050565b60006101308860ff16815481106124f7576124f761465c565b9060005260206000209060040201600101805490509050806001600160401b03811115612526576125266140f0565b60405190808252806020026020018201604052801561254f578160200160208202803683370190505b50965061255b81612d60565b955061256681612d60565b9450505b50610132805460ff191660ff92909216919091179055509193909250565b612590613c0d565b60ff8216158015906125a757506101305460ff8316105b6125c35760405162461bcd60e51b815260040161086390614b14565b6125cc82612f01565b92915050565b60fb546001600160a01b031633146125fc5760405162461bcd60e51b81526004016108639061460a565b60ff83161580159061261357506101305460ff8416105b61262f5760405162461bcd60e51b815260040161086390614b14565b816101308460ff16815481106126475761264761465c565b906000526020600020906004020160000160026101000a81548163ffffffff021916908363ffffffff160217905550806101308460ff168154811061268e5761268e61465c565b906000526020600020906004020160020190805190602001906126b2929190613b35565b507f8a8f5fda8dffa25fc4847ab1e94503a97749d80d9f496d4964506ce7bbd9c06e8383836040516126e693929190614c90565b60405180910390a1505050565b60fb546001600160a01b0316331461271d5760405162461bcd60e51b81526004016108639061460a565b6001600160a01b0382166127595760405162461bcd60e51b81526020600482015260036024820152625a504160e81b6044820152606401610863565b6060826001600160a01b031663f274290b6040518163ffffffff1660e01b8152600401600060405180830381865afa9250505080156127ba57506040513d6000823e601f3d908101601f191682016040526127b79190810190614cf2565b60015b61284a576127c6614d99565b806308c379a0141561280057506127db614db5565b806127e65750612802565b8060405162461bcd60e51b81526004016108639190614029565b505b60405162461bcd60e51b815260206004820152601a60248201527f53757368694661726d3a3a43616c6c556e5374616b654661696c0000000000006044820152606401610863565b905081156129535760005b815181101561294d5760006001600160a01b031661013660008484815181106128805761288061465c565b6020908102919091018101516001600160e01b0319168252810191909152604001600020546001600160a01b0316146128e15760405162461bcd60e51b815260206004820152600360248201526250414560e81b6044820152606401610863565b8361013660008484815181106128f9576128f961465c565b6020908102919091018101516001600160e01b031916825281019190915260400160002080546001600160a01b0319166001600160a01b03929092169190911790558061294581614688565b915050612855565b50612a40565b60005b8151811015612a3e5760006001600160a01b031661013660008484815181106129815761298161465c565b6020908102919091018101516001600160e01b0319168252810191909152604001600020546001600160a01b031614156129e35760405162461bcd60e51b8152602060048201526003602482015262504e4560e81b6044820152606401610863565b61013660008383815181106129fa576129fa61465c565b6020908102919091018101516001600160e01b031916825281019190915260400160002080546001600160a01b031916905580612a3681614688565b915050612956565b505b7fe8bc441e42b94e4a57eed11e89ceca79d3a6efdff2832d1e48f86f2f45ca2d308383836040516126e693929190614e3e565b60fb546001600160a01b03163314612a9d5760405162461bcd60e51b81526004016108639061460a565b60ff831615801590612ab457506101305460ff8416105b612ad05760405162461bcd60e51b815260040161086390614b14565b60ff83166000908152610135602052604090208054607d60ab1b600164ffffffff0160a01b03199091166001600160a01b03851617179055612b1283826135fa565b7f0868d98f95ab8813a03cffd533e2822fab9479efe0ac15237d98f0180928a82f8383836040516126e693929190614ea9565b60fb546001600160a01b03163314612b6f5760405162461bcd60e51b81526004016108639061460a565b60ff821615801590612b8657506101305460ff8316105b612ba25760405162461bcd60e51b815260040161086390614b14565b620186a08163ffffffff161115612be15760405162461bcd60e51b815260206004820152600360248201526227a7a960e91b6044820152606401610863565b60ff821660008181526101356020908152604091829020805463ffffffff60a81b1916600160a81b63ffffffff8716908102919091179091558251938452908301527f38fb1a592d4049a40c14b94a27cb0459dab828dc87fb387e8bdbda776706f1d29101611de5565b60fb546001600160a01b03163314612c755760405162461bcd60e51b81526004016108639061460a565b6001600160a01b038116612cb15760405162461bcd60e51b815260206004820152600360248201526204f3d360ec1b6044820152606401610863565b60fb546001600160a01b0382811691161415612cf55760405162461bcd60e51b81526020600482015260036024820152624f3d4f60e81b6044820152606401610863565b61012d80546001600160a01b0319166001600160a01b0383169081179091556040517fb501f5dc3610d10a179d924f686fc89ddcdd3abb05afd7a1baeead166b2f122c90600090a250565b60606000612d4d83610dad565b9050612d5983826111da565b9150915091565b6060816001600160401b03811115612d7a57612d7a6140f0565b604051908082528060200260200182016040528015612da3578160200160208202803683370190505b5092915050565b60ff8116600090815261013460205260409020546001600160a01b031680612e6b5761012f546040516316a3636160e11b815260ff841660048201526001600160a01b0390911690632d46c6c290602401602060405180830381865afa158015612e18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e3c9190614b80565b60ff831660009081526101346020526040902080546001600160a01b0319166001600160a01b03831617905590505b919050565b6060600080846001600160a01b031684604051612e8d9190614ed6565b600060405180830381855af49150503d8060008114612ec8576040519150601f19603f3d011682016040523d82523d6000602084013e612ecd565b606091505b5091509150612ef882826040518060400160405280600381526020016221444360e81b815250613717565b95945050505050565b612f09613c0d565b6101308260ff1681548110612f2057612f2061465c565b60009182526020918290206040805160c0810182526004909302909101805460ff80821685526101008204168486015263ffffffff62010000909104168383015260018101805483518187028101870190945280845293949193606086019392830182828015612fcd57602002820191906000526020600020906000905b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411612f9e5790505b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561305157602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff16815260200190600401906020826003010492830192600103820291508084116130145790505b50505050508152602001600382018054806020026020016040519081016040528092919081815260200182805480156130a957602002820191906000526020600020905b815481526020019060010190808311613095575b50505050508152505090506001816020015160ff161415612e6b5760006130cf8361217c565b60a083015250919050565b61012f546130f2906001600160a01b03168383613757565b156121785761012f546040516302116fe560e11b81526001600160a01b0390911690630422dfca9061312a9085908590600401614ef2565b600060405180830381600087803b15801561314457600080fd5b505af1158015613158573d6000803e3d6000fd5b505050507faf0fc5e4cc697636cf17fe46d3aef6a04610a71ce1a9de8842d5408b12eca0b18282604051611de5929190614ef2565b80518251146131ae5760405162461bcd60e51b81526004016108639061463f565b61012f54604051634ff2c3d360e11b81526001600160a01b0390911690639fe587a6906131e19085908590600401614ef2565b600060405180830381600087803b1580156131fb57600080fd5b505af115801561320f573d6000803e3d6000fd5b505050507fd49617575cc0aa00922a48e5a6c4a8118756750d44fe3e12ea0669a236b907c08282604051611de5929190614ef2565b60c854610100900460ff1661326b5760405162461bcd60e51b815260040161086390614f17565b611fa9613816565b606081518351146132965760405162461bcd60e51b81526004016108639061463f565b8251806001600160401b038111156132b0576132b06140f0565b6040519080825280602002602001820160405280156132d9578160200160208202803683370190505b5091506000805b82811015613395578481815181106132fa576132fa61465c565b60200260200101518682815181106133145761331461465c565b60200260200101511115613383578481815181106133345761333461465c565b602002602001015186828151811061334e5761334e61465c565b602002602001015161336091906147dc565b8482815181106133725761337261465c565b602002602001018181525050600191505b8061338d81614688565b9150506132e0565b506134346101308760ff16815481106133b0576133b061465c565b906000526020600020906004020160010180548060200260200160405190810160405280929190818152602001828054801561342957602002820191906000526020600020906000905b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116133fa5790505b5050505050846130da565b50509392505050565b60fb80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b804710156134df5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610863565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461352c576040519150601f19603f3d011682016040523d82523d6000602084013e613531565b606091505b50509050806108dc5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610863565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526108dc908490613845565b8160ff811661361b5760405162461bcd60e51b81526004016108639061474f565b6101325460ff168061363c57610132805460ff191660ff8416179055613661565b8160ff168160ff16146136615760405162461bcd60e51b81526004016108639061476c565b60ff841660009081526101356020526040902080546001600160a01b031661369b5760405162461bcd60e51b815260040161086390614789565b80546040516136c5916001600160a01b031690630e1a7d1760e41b90610c97908890602401614029565b5060405160ff861681527f9aa77a2a0eb93487c4aaa91485120e31edaa4f8aff2455e4208986f5851958d69060200160405180910390a150610132805460ff191660ff92909216919091179055505050565b60608315613726575081613750565b8251156137365782518084602001fd5b8160405162461bcd60e51b81526004016108639190614029565b9392505050565b6000815183511461377a5760405162461bcd60e51b81526004016108639061463f565b60005b835181101561380e578281815181106137985761379861465c565b60200260200101516000146137fc576137f7858483815181106137bd576137bd61465c565b60200260200101516137e78785815181106137da576137da61465c565b6020026020010151612daa565b6001600160a01b031691906135a8565b600191505b8061380681614688565b91505061377d565b509392505050565b60c854610100900460ff1661383d5760405162461bcd60e51b815260040161086390614f17565b611fa9613917565b600061389a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166139479092919063ffffffff16565b8051909150156108dc57808060200190518101906138b89190614f62565b6108dc5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610863565b60c854610100900460ff1661393e5760405162461bcd60e51b815260040161086390614f17565b611fa93361343d565b6060613956848460008561395e565b949350505050565b6060824710156139bf5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610863565b6001600160a01b0385163b613a165760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610863565b600080866001600160a01b03168587604051613a329190614ed6565b60006040518083038185875af1925050503d8060008114613a6f576040519150601f19603f3d011682016040523d82523d6000602084013e613a74565b606091505b5091509150613a84828286613717565b979650505050505050565b82805482825590600052602060002090601f01602090048101928215613b255791602002820160005b83821115613af657835183826101000a81548160ff021916908360ff1602179055509260200192600101602081600001049283019260010302613ab8565b8015613b235782816101000a81549060ff0219169055600101602081600001049283019260010302613af6565b505b50613b31929150613c41565b5090565b82805482825590600052602060002090600701600890048101928215613b255791602002820160005b83821115613ba257835183826101000a81548163ffffffff021916908363ffffffff1602179055509260200192600401602081600301049283019260010302613b5e565b8015613b235782816101000a81549063ffffffff0219169055600401602081600301049283019260010302613ba2565b828054828255906000526020600020908101928215613b25579160200282015b82811115613b25578251825591602001919060010190613bf2565b6040805160c0810182526000808252602082018190529181019190915260608082018190526080820181905260a082015290565b5b80821115613b315760008155600101613c42565b803560ff81168114612e6b57600080fd5b803563ffffffff81168114612e6b57600080fd5b60008083601f840112613c8d57600080fd5b5081356001600160401b03811115613ca457600080fd5b6020830191508360208260051b8501011115613cbf57600080fd5b9250929050565b600080600080600080600060a0888a031215613ce157600080fd5b613cea88613c56565b9650613cf860208901613c56565b9550613d0660408901613c67565b945060608801356001600160401b0380821115613d2257600080fd5b613d2e8b838c01613c7b565b909650945060808a0135915080821115613d4757600080fd5b50613d548a828b01613c7b565b989b979a50959850939692959293505050565b600060208284031215613d7957600080fd5b61375082613c56565b6001600160a01b0381168114613d9757600080fd5b50565b600060208284031215613dac57600080fd5b813561375081613d82565b600081518084526020808501945080840160005b83811015613ded57815163ffffffff1687529582019590820190600101613dcb565b509495945050505050565b600081518084526020808501945080840160005b83811015613ded57815187529582019590820190600101613e0c565b600060c0830160ff80845116855260208181860151168187015263ffffffff6040860151166040870152606085015160c0606088015283815180865260e0890191508383019550600092505b80831015613e9657855185168252948301946001929092019190830190613e74565b50608087015194508781036080890152613eb08186613db7565b94505050505060a083015184820360a0860152612ef88282613df8565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015613f2257603f19888603018452613f10858351613e28565b94509285019290850190600101613ef4565b5092979650505050505050565b600080600080600060808688031215613f4757600080fd5b613f5086613c56565b94506020860135935060408601356001600160401b03811115613f7257600080fd5b613f7e88828901613c7b565b96999598509660600135949350505050565b6020815260006137506020830184613df8565b60008060408385031215613fb657600080fd5b613fbf83613c56565b946020939093013593505050565b60005b83811015613fe8578181015183820152602001613fd0565b83811115613ff7576000848401525b50505050565b60008151808452614015816020860160208601613fcd565b601f01601f19169290920160200192915050565b6020815260006137506020830184613ffd565b6000806000806060858703121561405257600080fd5b61405b85613c56565b935060208501356001600160401b0381111561407657600080fd5b61408287828801613c7b565b9598909750949560400135949350505050565b6040815260006140a86040830185613df8565b90508260208301529392505050565b600080604083850312156140ca57600080fd5b82356140d581613d82565b915060208301356140e581613d82565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b038111828210171561412b5761412b6140f0565b6040525050565b60006001600160401b0382111561414b5761414b6140f0565b5060051b60200190565b6000806040838503121561416857600080fd5b61417183613c56565b91506020808401356001600160401b0381111561418d57600080fd5b8401601f8101861361419e57600080fd5b80356141a981614132565b6040516141b68282614106565b82815260059290921b83018401918481019150888311156141d657600080fd5b928401925b828410156141f4578335825292840192908401906141db565b80955050505050509250929050565b600082601f83011261421457600080fd5b8135602061422182614132565b60405161422e8282614106565b83815260059390931b850182019282810191508684111561424e57600080fd5b8286015b848110156142705761426381613c56565b8352918301918301614252565b509695505050505050565b6000806040838503121561428e57600080fd5b61429783613c56565b915060208301356001600160401b038111156142b257600080fd5b6142be85828601614203565b9150509250929050565b8015158114613d9757600080fd5b600080604083850312156142e957600080fd5b6142f283613c56565b915060208301356140e5816142c8565b60006020828403121561431457600080fd5b81356001600160401b0381111561432a57600080fd5b61395684828501614203565b6000806040838503121561434957600080fd5b82356142f281613d82565b6000806040838503121561436757600080fd5b8235613fbf81613d82565b606080825284519082018190526000906020906080840190828801845b828110156143b45781516001600160a01b03168452928401929084019060010161438f565b505050838103828501526143c88187613df8565b91505082810360408401526143dd8185613df8565b9695505050505050565b6020815260006137506020830184613e28565b60008060006060848603121561440f57600080fd5b61441884613c56565b92506020614427818601613c67565b925060408501356001600160401b0381111561444257600080fd5b8501601f8101871361445357600080fd5b803561445e81614132565b60405161446b8282614106565b82815260059290921b830184019184810191508983111561448b57600080fd5b928401925b828410156144b0576144a184613c67565b82529284019290840190614490565b80955050505050509250925092565b6000806000606084860312156144d457600080fd5b6144dd84613c56565b92506020808501356144ee81613d82565b925060408501356001600160401b038082111561450a57600080fd5b818701915087601f83011261451e57600080fd5b813581811115614530576145306140f0565b6040519150614548601f8201601f1916850183614106565b808252888482850101111561455c57600080fd5b80848401858401376000848284010152508093505050509250925092565b6000806040838503121561458d57600080fd5b61459683613c56565b91506145a460208401613c67565b90509250929050565b6001600160a01b038681168252851660208201526001600160e01b03198416604082015260806060820181905281018290526000828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600390820152622622a760e91b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561469c5761469c614672565b5060010190565b600060a0820160ff808b1684526020818b168186015263ffffffff808b16604087015260a060608701528389855260c0870190508a945060005b8a81101561470257846146ef87613c56565b16825294830194908301906001016146dd565b5086810360808801528781528201935087925060005b8781101561473d578161472a85613c67565b1685529382019392820192600101614718565b50929c9b505050505050505050505050565b6020808252600390820152625a444960e81b604082015260600190565b60208082526003908201526227222960e91b604082015260600190565b602080825260039082015262414e5360e81b604082015260600190565b60208082526003908201526204455560ec1b604082015260600190565b6000602082840312156147d557600080fd5b5051919050565b6000828210156147ee576147ee614672565b500390565b600060ff821660ff84168082101561480d5761480d614672565b90039392505050565b600060ff821660ff81141561482d5761482d614672565b60010192915050565b60208082526003908201526213921360ea1b604082015260600190565b60208082526003908201526223292d60e91b604082015260600190565b81835260006001600160fb1b0383111561488957600080fd5b8260051b8083602087013760009401602001938452509192915050565b8481526060602082015260006148c0606083018587614870565b905082604083015295945050505050565b600082601f8301126148e257600080fd5b815160206148ef82614132565b6040516148fc8282614106565b83815260059390931b850182019282810191508684111561491c57600080fd5b8286015b848110156142705780518352918301918301614920565b60006020828403121561494957600080fd5b81516001600160401b0381111561495f57600080fd5b613956848285016148d1565b60ff8616815284602082015260806040820152600061498e608083018587614870565b90508260608301529695505050505050565b600181811c908216806149b457607f821691505b602082108114156149d557634e487b7160e01b600052602260045260246000fd5b50919050565b60008160001904831182151516156149f5576149f5614672565b500290565b600082614a1757634e487b7160e01b600052601260045260246000fd5b500490565b604081526000614a30604083018587614870565b9050826020830152949350505050565b60008060408385031215614a5357600080fd5b82516001600160401b03811115614a6957600080fd5b614a75858286016148d1565b925050602083015190509250929050565b60ff8716815260a060208201526000614aa360a083018789614870565b8281036040840152614ab58187613df8565b90508460608401528281036080840152614acf8185613ffd565b9998505050505050505050565b606081526000614af0606083018688614870565b8281036020840152614b028186613df8565b91505082604083015295945050505050565b6020808252600390820152621314d560ea1b604082015260600190565b600081518084526020808501945080840160005b83811015613ded57815160ff1687529582019590820190600101614b45565b60ff831681526040602082015260006139566040830184614b31565b600060208284031215614b9257600080fd5b815161375081613d82565b600080600060608486031215614bb257600080fd5b83516001600160401b0380821115614bc957600080fd5b818601915086601f830112614bdd57600080fd5b81516020614bea82614132565b604051614bf78282614106565b83815260059390931b850182019282810191508a841115614c1757600080fd5b948201945b83861015614c3e578551614c2f81613d82565b82529482019490820190614c1c565b91890151919750909350505080821115614c5757600080fd5b614c63878388016148d1565b93506040860151915080821115614c7957600080fd5b50614c86868287016148d1565b9150509250925092565b60006060820160ff86168352602063ffffffff8087168286015260606040860152828651808552608087019150838801945060005b81811015614ce3578551841683529484019491840191600101614cc5565b50909998505050505050505050565b60006020808385031215614d0557600080fd5b82516001600160401b03811115614d1b57600080fd5b8301601f81018513614d2c57600080fd5b8051614d3781614132565b604051614d448282614106565b82815260059290921b8301840191848101915087831115614d6457600080fd5b928401925b82841015613a845783516001600160e01b031981168114614d8a5760008081fd5b82529284019290840190614d69565b600060033d1115614db25760046000803e5060005160e01c5b90565b600060443d1015614dc35790565b6040516003193d81016004833e81513d6001600160401b038160248401118184111715614df257505050505090565b8285019150815181811115614e0a5750505050505090565b843d8701016020828501011115614e245750505050505090565b614e3360208286010187614106565b509095945050505050565b6001600160a01b03841681528215156020808301919091526060604083018190528351908301819052600091848101916080850190845b81811015614e9b5784516001600160e01b03191683529383019391830191600101614e75565b509098975050505050505050565b60ff841681526001600160a01b0383166020820152606060408201819052600090612ef890830184613ffd565b60008251614ee8818460208701613fcd565b9190910192915050565b604081526000614f056040830185614b31565b8281036020840152612ef88185613df8565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600060208284031215614f7457600080fd5b8151613750816142c856fea264697066735822122023b8e147971a448e0a219ac6301929ada51823e74a2d02d4efee959ad0a77b0b64736f6c634300080a0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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