ETH Price: $2,605.32 (-0.35%)

Contract

0xb5b5f2FEC05c1E4639f0aeeb8D2B5D9b670CeF25

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
0x60806040975157412023-05-11 20:55:58523 days ago1683838558IN
 Create: PoolManagerLogic
0 ETH0.0388672143960.00104815

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
1075576322023-07-30 10:47:21443 days ago1690714041
0xb5b5f2FE...b670CeF25
0 ETH
1075576322023-07-30 10:47:21443 days ago1690714041
0xb5b5f2FE...b670CeF25
0 ETH
1075576322023-07-30 10:47:21443 days ago1690714041
0xb5b5f2FE...b670CeF25
0 ETH
1075576322023-07-30 10:47:21443 days ago1690714041
0xb5b5f2FE...b670CeF25
0 ETH
1075576322023-07-30 10:47:21443 days ago1690714041
0xb5b5f2FE...b670CeF25
0 ETH
1075576322023-07-30 10:47:21443 days ago1690714041
0xb5b5f2FE...b670CeF25
0 ETH
1075576322023-07-30 10:47:21443 days ago1690714041
0xb5b5f2FE...b670CeF25
0 ETH
1075576322023-07-30 10:47:21443 days ago1690714041
0xb5b5f2FE...b670CeF25
0 ETH
1075575792023-07-30 10:45:35443 days ago1690713935
0xb5b5f2FE...b670CeF25
0 ETH
1075575792023-07-30 10:45:35443 days ago1690713935
0xb5b5f2FE...b670CeF25
0 ETH
1075575792023-07-30 10:45:35443 days ago1690713935
0xb5b5f2FE...b670CeF25
0 ETH
1075575792023-07-30 10:45:35443 days ago1690713935
0xb5b5f2FE...b670CeF25
0 ETH
1075575792023-07-30 10:45:35443 days ago1690713935
0xb5b5f2FE...b670CeF25
0 ETH
1075575772023-07-30 10:45:31443 days ago1690713931
0xb5b5f2FE...b670CeF25
0 ETH
1075575772023-07-30 10:45:31443 days ago1690713931
0xb5b5f2FE...b670CeF25
0 ETH
1075575772023-07-30 10:45:31443 days ago1690713931
0xb5b5f2FE...b670CeF25
0 ETH
1075575772023-07-30 10:45:31443 days ago1690713931
0xb5b5f2FE...b670CeF25
0 ETH
1075575772023-07-30 10:45:31443 days ago1690713931
0xb5b5f2FE...b670CeF25
0 ETH
1075575772023-07-30 10:45:31443 days ago1690713931
0xb5b5f2FE...b670CeF25
0 ETH
1075575772023-07-30 10:45:31443 days ago1690713931
0xb5b5f2FE...b670CeF25
0 ETH
1075575772023-07-30 10:45:31443 days ago1690713931
0xb5b5f2FE...b670CeF25
0 ETH
1075575742023-07-30 10:45:25443 days ago1690713925
0xb5b5f2FE...b670CeF25
0 ETH
1075575742023-07-30 10:45:25443 days ago1690713925
0xb5b5f2FE...b670CeF25
0 ETH
1075575742023-07-30 10:45:25443 days ago1690713925
0xb5b5f2FE...b670CeF25
0 ETH
1075575742023-07-30 10:45:25443 days ago1690713925
0xb5b5f2FE...b670CeF25
0 ETH
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PoolManagerLogic

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 20 runs

Other Settings:
default evmVersion
File 1 of 29 : PoolManagerLogic.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.7.6;
pragma experimental ABIEncoderV2;

import "./interfaces/IPoolLogic.sol";
import "./interfaces/IPoolManagerLogic.sol";
import "./interfaces/IHasAssetInfo.sol";
import "./interfaces/IHasFeeInfo.sol";
import "./interfaces/IHasDaoInfo.sol";
import "./interfaces/IHasProtocolDaoInfo.sol";
import "./interfaces/IHasGuardInfo.sol";
import "./interfaces/IHasSupportedAsset.sol";
import "./interfaces/IHasOwnable.sol";
import "./interfaces/guards/IGuard.sol";
import "./interfaces/guards/IAssetGuard.sol";
import "./interfaces/IPoolFactory.sol";
import "./Managed.sol";

import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";

/// @notice Logic implmentation for pool manager
contract PoolManagerLogic is Initializable, IPoolManagerLogic, IHasSupportedAsset, Managed {
  using SafeMathUpgradeable for uint256;
  using AddressUpgradeable for address;

  event AssetAdded(address indexed fundAddress, address manager, address asset, bool isDeposit);
  event AssetRemoved(address fundAddress, address manager, address asset);

  event ManagerFeeSet(
    address fundAddress,
    address manager,
    uint256 performanceFeeNumerator,
    uint256 managerFeeNumerator,
    uint256 entryFeeNumerator,
    uint256 denominator
  );

  event ManagerFeeIncreaseAnnounced(
    uint256 performanceFeeNumerator,
    uint256 managerFeeNumerator,
    uint256 announcedFeeActivationTime
  );

  event ManagerFeeIncreaseRenounced();
  event PoolLogicSet(address poolLogic, address from);

  event MinDepositUpdated(uint256 minDepositUSD);

  address public override factory;
  address public override poolLogic;

  Asset[] public supportedAssets;
  mapping(address => uint256) public assetPosition; // maps the asset to its 1-based position

  // Fee increase announcement
  uint256 public announcedPerformanceFeeNumerator;
  uint256 public announcedFeeIncreaseTimestamp;
  uint256 public performanceFeeNumerator;
  uint256 public announcedManagerFeeNumerator;
  uint256 public managerFeeNumerator;

  // Should be in Managed.sol but not upgradable
  address public nftMembershipCollectionAddress;

  uint256 public override minDepositUSD;

  uint256 public announcedEntryFeeNumerator;
  uint256 public entryFeeNumerator;

  modifier onlyManagerOrTraderOrFactory() {
    require(msg.sender == manager || msg.sender == trader || msg.sender == factory, "only manager, trader or factory");
    _;
  }

  /// @notice initialize the pool manager
  /// @param _factory address of the factory
  /// @param _manager address of the manager
  /// @param _managerName name of the manager
  /// @param _poolLogic address of the pool logic
  /// @param _performanceFeeNumerator numerator of the manager fee
  /// @param _supportedAssets array of supported assets
  function initialize(
    address _factory,
    address _manager,
    string calldata _managerName,
    address _poolLogic,
    uint256 _performanceFeeNumerator,
    uint256 _managerFeeNumerator,
    Asset[] calldata _supportedAssets
  ) external initializer {
    require(_factory != address(0), "Invalid factory");
    require(_manager != address(0), "Invalid manager");
    require(_poolLogic != address(0), "Invalid poolLogic");
    initialize(_manager, _managerName);

    factory = _factory;
    poolLogic = _poolLogic;
    _setFeeNumerator(_performanceFeeNumerator, _managerFeeNumerator, 0); // By default entry fee will be set as 0%
    _changeAssets(_supportedAssets, new address[](0));
  }

  /// @notice Return true if it's supported asset, false otherwise
  /// @param asset address of the asset
  function isSupportedAsset(address asset) public view override returns (bool) {
    return assetPosition[asset] != 0;
  }

  /// @notice Return true if it's deposit asset, false otherwise
  /// @param asset address of the asset
  function isDepositAsset(address asset) public view override returns (bool) {
    uint256 index = assetPosition[asset];

    return index != 0 && supportedAssets[index.sub(1)].isDeposit;
  }

  /// @notice Return true if it's valid asset, false otherwise
  /// @param asset address of the asset
  function validateAsset(address asset) public view override returns (bool) {
    return IHasAssetInfo(factory).isValidAsset(asset);
  }

  /// @notice Change assets of the pool
  /// @param _addAssets array of assets to add
  /// @param _removeAssets array of asset addresses to remove
  function changeAssets(Asset[] calldata _addAssets, address[] calldata _removeAssets)
    external
    onlyManagerOrTraderOrFactory
  {
    _changeAssets(_addAssets, _removeAssets);
    emitFactoryEvent();
  }

  /// @notice Change assets of the pool internal call
  /// @param _addAssets array of assets to add
  /// @param _removeAssets array of asset addresses to remove
  function _changeAssets(Asset[] calldata _addAssets, address[] memory _removeAssets) internal {
    for (uint8 i = 0; i < _removeAssets.length; i++) {
      _removeAsset(_removeAssets[i]);
    }

    for (uint8 i = 0; i < _addAssets.length; i++) {
      _addAsset(_addAssets[i]);
    }

    require(supportedAssets.length <= IHasAssetInfo(factory).getMaximumSupportedAssetCount(), "maximum assets reached");

    require(getDepositAssets().length >= 1, "at least one deposit asset");
  }

  /// @notice Add an asset to the pool
  /// @param _asset an asset struct
  function _addAsset(Asset calldata _asset) internal {
    address asset = _asset.asset;
    bool isDeposit = _asset.isDeposit;

    require(validateAsset(asset), "invalid asset");
    // Pools with price aggregators cannot add other pools as assets
    require(!validateAsset(poolLogic) || !IPoolFactory(factory).isPool(asset), "cannot add pool asset");

    if (isSupportedAsset(asset)) {
      uint256 index = assetPosition[asset].sub(1);
      supportedAssets[index].isDeposit = isDeposit;
    } else {
      uint256 i = supportedAssets.length;
      supportedAssets.push(_asset);
      assetPosition[asset] = i.add(1); // adjusting the index because the map stores 1-based
      uint16 assetType = IHasAssetInfo(factory).getAssetType(asset);
      for (i; i > 0 && IHasAssetInfo(factory).getAssetType(supportedAssets[i.sub(1)].asset) < assetType; i--) {
        Asset memory temp = supportedAssets[i];
        supportedAssets[i] = supportedAssets[i.sub(1)];
        assetPosition[supportedAssets[i].asset] = i.add(1);
        supportedAssets[i.sub(1)] = temp;
        assetPosition[supportedAssets[i.sub(1)].asset] = i;
      }
    }

    emit AssetAdded(poolLogic, manager, asset, isDeposit);
  }

  /// @notice Remove asset from the pool
  /// @dev use asset address to remove from supportedAssets
  /// @param asset asset address
  function _removeAsset(address asset) internal {
    require(isSupportedAsset(asset), "asset not supported");

    address guard = IHasGuardInfo(factory).getAssetGuard(asset);
    if (guard != address(0)) {
      // should be able to remove any deprecated assets
      require(assetBalance(asset) == 0, "cannot remove non-empty asset");
      IAssetGuard(guard).removeAssetCheck(poolLogic, asset);
    }

    uint256 index = assetPosition[asset].sub(1); // adjusting the index because the map stores 1-based
    uint256 length = supportedAssets.length;
    for (uint256 i = index; i.add(1) < length; i++) {
      Asset memory temp = supportedAssets[i];
      supportedAssets[i] = supportedAssets[i.add(1)];
      assetPosition[supportedAssets[i].asset] = i.add(1);
      supportedAssets[i.add(1)] = temp;
      assetPosition[supportedAssets[i.add(1)].asset] = i.add(2);
    }

    assetPosition[supportedAssets[length.sub(1)].asset] = 0;
    supportedAssets.pop();

    emit AssetRemoved(poolLogic, manager, asset);
  }

  /// @notice Get all the supported assets
  /// @return Return array of supported assets
  function getSupportedAssets() external view override returns (Asset[] memory) {
    return supportedAssets;
  }

  /// @notice Get all the deposit assets
  /// @return Return array of deposit assets' addresses
  function getDepositAssets() public view returns (address[] memory) {
    uint256 assetCount = supportedAssets.length;
    address[] memory depositAssets = new address[](assetCount);
    uint8 index = 0;
    for (uint8 i = 0; i < assetCount; i++) {
      if (supportedAssets[i].isDeposit) {
        depositAssets[index] = supportedAssets[i].asset;
        index++;
      }
    }
    // Reduce length for withdrawnAssets to remove the empty items
    uint256 reduceLength = assetCount.sub(index);
    assembly {
      mstore(depositAssets, sub(mload(depositAssets), reduceLength))
    }
    return depositAssets;
  }

  /// @notice Get asset balance including any staked balance in external contracts
  /// @return balance of the asset
  function assetBalance(address asset) public view override returns (uint256 balance) {
    address guard = IHasGuardInfo(factory).getAssetGuard(asset);
    balance = IAssetGuard(guard).getBalance(poolLogic, asset);
  }

  /// @notice Get asset decimal
  /// @return decimal of the asset
  function assetDecimal(address asset) public view returns (uint256 decimal) {
    address guard = IHasGuardInfo(factory).getAssetGuard(asset);
    decimal = IAssetGuard(guard).getDecimals(asset);
  }

  /// @notice Get value of the asset
  /// @param asset address of the asset
  /// @param amount amount of the asset
  /// @return value of the asset
  function assetValue(address asset, uint256 amount) public view override returns (uint256 value) {
    uint256 price = IHasAssetInfo(factory).getAssetPrice(asset);
    uint256 decimals = assetDecimal(asset);

    value = price.mul(amount).div(10**decimals);
  }

  /// @notice Get value of the asset
  /// @param asset address of the asset
  /// @return value of the asset
  function assetValue(address asset) public view override returns (uint256 value) {
    value = assetValue(asset, assetBalance(asset));
  }

  /// @notice Return the fund composition of the pool
  /// @dev Return assets, balances of the asset and their prices
  /// @return assets array of supported assets
  /// @return balances balances of each asset
  /// @return rates price of each asset in USD
  function getFundComposition()
    public
    view
    returns (
      Asset[] memory assets,
      uint256[] memory balances,
      uint256[] memory rates
    )
  {
    uint256 assetCount = supportedAssets.length;
    assets = new Asset[](assetCount);
    balances = new uint256[](assetCount);
    rates = new uint256[](assetCount);

    for (uint8 i = 0; i < assetCount; i++) {
      address asset = supportedAssets[i].asset;
      balances[i] = assetBalance(asset);
      assets[i] = supportedAssets[i];
      rates[i] = IHasAssetInfo(factory).getAssetPrice(asset);
    }
  }

  /// @notice Return the total fund value of the pool
  /// @dev Calculate the total fund value from the supported assets
  /// @return value in USD
  function totalFundValue() external view override returns (uint256) {
    uint256 total = 0;
    uint256 assetCount = supportedAssets.length;

    for (uint256 i = 0; i < assetCount; i++) {
      total = total.add(assetValue(supportedAssets[i].asset));
    }
    return total;
  }

  /* ========== MANAGER FEES ========== */

  /// @notice Return the manager fees
  function getFee()
    external
    view
    override
    returns (
      uint256,
      uint256,
      uint256,
      uint256
    )
  {
    (, , , uint256 managerFeeDenominator) = IHasFeeInfo(factory).getMaximumFee();
    return (performanceFeeNumerator, managerFeeNumerator, entryFeeNumerator, managerFeeDenominator);
  }

  /// @notice Get maximum manager fee
  /// @return numerator numerator of the maximum manager fee
  /// @return entryFeeNumerator numerator of the maximum entry fee
  /// @return denominator denominator of the maximum manager fee
  function getMaximumFee()
    public
    view
    returns (
      uint256,
      uint256,
      uint256,
      uint256
    )
  {
    return IHasFeeInfo(factory).getMaximumFee();
  }

  /// @notice Get maximum manager fee change
  /// @return change change of the maximum manager fee
  function getMaximumPerformanceFeeChange() public view returns (uint256 change) {
    change = IHasFeeInfo(factory).maximumPerformanceFeeNumeratorChange();
  }

  // Manager fee decreases

  /// @notice Manager can decrease performance fee
  /// @param _performanceFeeNumerator The numerator of the maximum manager fee
  /// @param _managerFeeNumerator The numerator of the maximum streaming fee
  function setFeeNumerator(
    uint256 _performanceFeeNumerator,
    uint256 _managerFeeNumerator,
    uint256 _entryFeeNumerator
  ) external onlyManager {
    require(
      _performanceFeeNumerator <= performanceFeeNumerator &&
        _managerFeeNumerator <= managerFeeNumerator &&
        _entryFeeNumerator <= entryFeeNumerator,
      "manager fee too high"
    );
    _setFeeNumerator(_performanceFeeNumerator, _managerFeeNumerator, _entryFeeNumerator);
    emitFactoryEvent();
  }

  /// @notice Manager can decrease performance fee internal call
  /// @param _performanceFeeNumerator The numerator of the maximum manager fee
  /// @param _managerFeeNumerator The numerator of the maximum streaming fee
  function _setFeeNumerator(
    uint256 _performanceFeeNumerator,
    uint256 _managerFeeNumerator,
    uint256 _entryFeeNumerator
  ) internal {
    (
      uint256 maximumPerformanceFeeNumerator,
      uint256 maximumManagerFeeNumerator,
      uint256 maximumEntryFeeNumerator,
      uint256 denominator
    ) = getMaximumFee();
    require(
      _performanceFeeNumerator <= maximumPerformanceFeeNumerator &&
        _managerFeeNumerator <= maximumManagerFeeNumerator &&
        _entryFeeNumerator <= maximumEntryFeeNumerator,
      "invalid manager fee"
    );

    performanceFeeNumerator = _performanceFeeNumerator;
    managerFeeNumerator = _managerFeeNumerator;
    entryFeeNumerator = _entryFeeNumerator;

    emit ManagerFeeSet(
      poolLogic,
      manager,
      _performanceFeeNumerator,
      _managerFeeNumerator,
      _entryFeeNumerator,
      denominator
    );
  }

  // Manager fee increases

  /// @notice Manager can announce an increase to the performance fee
  /// @dev The commit to the new fee can happen after a time delay
  /// @param _performanceFeeNumerator The numerator of the maximum manager fee
  /// @param _managerFeeNumerator The numerator of the maximum streaming fee
  function announceFeeIncrease(
    uint256 _performanceFeeNumerator,
    uint256 _managerFeeNumerator,
    uint256 _entryFeeNumerator
  ) external onlyManager {
    (
      uint256 maximumPerformanceFeeNumerator,
      uint256 maximumManagerFeeNumerator,
      uint256 maximumEntryFeeNumerator,

    ) = getMaximumFee();
    uint256 maximumAllowedChange = getMaximumPerformanceFeeChange();

    require(
      _performanceFeeNumerator <= maximumPerformanceFeeNumerator &&
        _managerFeeNumerator <= maximumManagerFeeNumerator &&
        _entryFeeNumerator <= maximumEntryFeeNumerator &&
        _performanceFeeNumerator <= performanceFeeNumerator.add(maximumAllowedChange),
      "exceeded allowed increase"
    );

    uint256 feeChangeDelay = IHasFeeInfo(factory).performanceFeeNumeratorChangeDelay();

    announcedPerformanceFeeNumerator = _performanceFeeNumerator;
    announcedManagerFeeNumerator = _managerFeeNumerator;
    announcedEntryFeeNumerator = _entryFeeNumerator;
    announcedFeeIncreaseTimestamp = block.timestamp + feeChangeDelay;
    emit ManagerFeeIncreaseAnnounced(_performanceFeeNumerator, _managerFeeNumerator, announcedFeeIncreaseTimestamp);
    emitFactoryEvent();
  }

  /// @notice Manager can cancel the performance fee increase
  /// @dev Fee increase needs to be announced first
  function renounceFeeIncrease() external onlyManager {
    announcedPerformanceFeeNumerator = 0;
    announcedManagerFeeNumerator = 0;
    announcedEntryFeeNumerator = 0;
    announcedFeeIncreaseTimestamp = 0;
    emit ManagerFeeIncreaseRenounced();
    emitFactoryEvent();
  }

  /// @notice Manager can commit the performance fee increase
  /// @dev Fee increase needs to be announced first
  function commitFeeIncrease() external onlyManager {
    require(block.timestamp >= announcedFeeIncreaseTimestamp, "fee increase delay active");

    IPoolLogic(poolLogic).mintManagerFee();

    _setFeeNumerator(announcedPerformanceFeeNumerator, announcedManagerFeeNumerator, announcedEntryFeeNumerator);

    announcedPerformanceFeeNumerator = 0;
    announcedManagerFeeNumerator = 0;
    announcedEntryFeeNumerator = 0;
    announcedFeeIncreaseTimestamp = 0;
  }

  /// @notice Get manager fee increase information
  function getFeeIncreaseInfo()
    external
    view
    returns (
      uint256,
      uint256,
      uint256,
      uint256
    )
  {
    return (
      announcedPerformanceFeeNumerator,
      announcedManagerFeeNumerator,
      announcedEntryFeeNumerator,
      announcedFeeIncreaseTimestamp
    );
  }

  /// @notice Setter for poolLogic contract
  /// @dev Not required to be used under normal circumstances
  function setPoolLogic(address _poolLogic) external override returns (bool) {
    address owner = IHasOwnable(factory).owner();
    require(msg.sender == owner, "only owner address allowed");

    require(IPoolLogic(_poolLogic).poolManagerLogic() == address(this), "invalid pool logic");

    poolLogic = _poolLogic;
    emit PoolLogicSet(_poolLogic, msg.sender);
    emitFactoryEvent();
    return true;
  }

  /// @notice Set the address of the nftMembershipCollectionAddress
  /// @param newNftMembershipCollectionAddress The address of the new nftMembershipCollectionAddress
  function setNftMembershipCollectionAddress(address newNftMembershipCollectionAddress) external onlyManager {
    if (newNftMembershipCollectionAddress == address(0)) {
      nftMembershipCollectionAddress = newNftMembershipCollectionAddress;
      return;
    }
    try ERC721Upgradeable(newNftMembershipCollectionAddress).balanceOf(address(this)) returns (uint256) {
      nftMembershipCollectionAddress = newNftMembershipCollectionAddress;
    } catch {
      revert("Invalid collection");
    }
  }

  /// @notice Set minimum deposit amount in USD
  /// @param _minDepositUSD minimum deposit amount in USD
  function setMinDepositUSD(uint256 _minDepositUSD) external onlyManager {
    _setMinDepositUSD(_minDepositUSD);
    emitFactoryEvent();
  }

  /// @notice Set minimum deposit amount in USD internal call
  /// @param _minDepositUSD minimum deposit amount in USD
  function _setMinDepositUSD(uint256 _minDepositUSD) internal {
    minDepositUSD = _minDepositUSD;
    emit MinDepositUpdated(_minDepositUSD);
  }

  /// @notice Return boolean if the there is a nftMembership address set and the member owns one
  /// @param member The address of the member
  /// @return True if the address owns an nft
  function isNftMemberAllowed(address member) public view returns (bool) {
    return (nftMembershipCollectionAddress != address(0) &&
      ERC721Upgradeable(nftMembershipCollectionAddress).balanceOf(member) > 0);
  }

  /// @notice Return boolean if the address is a member of the list or owns an nft in the membership collection
  /// @param member The address of the member
  /// @return True if the address is a member of the list or owns nft in the membership collection, false otherwise
  function isMemberAllowed(address member) public view virtual override returns (bool) {
    return _isMemberAllowed(member) || isNftMemberAllowed(member);
  }

  /// @notice Emits an event through the factory, so we can just listen to the factory offchain
  function emitFactoryEvent() internal {
    IPoolFactory(factory).emitPoolManagerEvent();
  }

  uint256[45] private __gap;
}

File 2 of 29 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "./IERC165Upgradeable.sol";
import "../proxy/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts may inherit from this and call {_registerInterface} to declare
 * their support of an interface.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    /*
     * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
     */
    bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;

    /**
     * @dev Mapping of interface ids to whether or not it's supported.
     */
    mapping(bytes4 => bool) private _supportedInterfaces;

    function __ERC165_init() internal initializer {
        __ERC165_init_unchained();
    }

    function __ERC165_init_unchained() internal initializer {
        // Derived contracts need only register support for their own interfaces,
        // we register support for ERC165 itself here
        _registerInterface(_INTERFACE_ID_ERC165);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     *
     * Time complexity O(1), guaranteed to always use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return _supportedInterfaces[interfaceId];
    }

    /**
     * @dev Registers the contract as an implementer of the interface defined by
     * `interfaceId`. Support of the actual ERC165 interface is automatic and
     * registering its interface id is not required.
     *
     * See {IERC165-supportsInterface}.
     *
     * Requirements:
     *
     * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
     */
    function _registerInterface(bytes4 interfaceId) internal virtual {
        require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
        _supportedInterfaces[interfaceId] = true;
    }
    uint256[49] private __gap;
}

File 3 of 29 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 4 of 29 : SafeMathUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMathUpgradeable {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

File 5 of 29 : Initializable.sol
// SPDX-License-Identifier: MIT

// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <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 a proxied contract can't have 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 {UpgradeableProxy-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.
 */
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() {
        require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");

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

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /// @dev Returns true if and only if the function is running in the constructor
    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 6 of 29 : ERC721Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../../utils/ContextUpgradeable.sol";
import "./IERC721Upgradeable.sol";
import "./IERC721MetadataUpgradeable.sol";
import "./IERC721EnumerableUpgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "../../introspection/ERC165Upgradeable.sol";
import "../../math/SafeMathUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/EnumerableSetUpgradeable.sol";
import "../../utils/EnumerableMapUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../proxy/Initializable.sol";

/**
 * @title ERC721 Non-Fungible Token Standard basic implementation
 * @dev see https://eips.ethereum.org/EIPS/eip-721
 */
contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable, IERC721EnumerableUpgradeable {
    using SafeMathUpgradeable for uint256;
    using AddressUpgradeable for address;
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet;
    using EnumerableMapUpgradeable for EnumerableMapUpgradeable.UintToAddressMap;
    using StringsUpgradeable for uint256;

    // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
    // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
    bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;

    // Mapping from holder address to their (enumerable) set of owned tokens
    mapping (address => EnumerableSetUpgradeable.UintSet) private _holderTokens;

    // Enumerable mapping from token ids to their owners
    EnumerableMapUpgradeable.UintToAddressMap private _tokenOwners;

    // Mapping from token ID to approved address
    mapping (uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping (address => mapping (address => bool)) private _operatorApprovals;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Optional mapping for token URIs
    mapping (uint256 => string) private _tokenURIs;

    // Base URI
    string private _baseURI;

    /*
     *     bytes4(keccak256('balanceOf(address)')) == 0x70a08231
     *     bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
     *     bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
     *     bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
     *     bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
     *     bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
     *     bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
     *
     *     => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
     *        0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
     */
    bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;

    /*
     *     bytes4(keccak256('name()')) == 0x06fdde03
     *     bytes4(keccak256('symbol()')) == 0x95d89b41
     *     bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
     *
     *     => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
     */
    bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;

    /*
     *     bytes4(keccak256('totalSupply()')) == 0x18160ddd
     *     bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
     *     bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
     *
     *     => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
     */
    bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    function __ERC721_init(string memory name_, string memory symbol_) internal initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __ERC721_init_unchained(name_, symbol_);
    }

    function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer {
        _name = name_;
        _symbol = symbol_;

        // register the supported interfaces to conform to ERC721 via ERC165
        _registerInterface(_INTERFACE_ID_ERC721);
        _registerInterface(_INTERFACE_ID_ERC721_METADATA);
        _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _holderTokens[owner].length();
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = baseURI();

        // If there is no base URI, return the token URI.
        if (bytes(base).length == 0) {
            return _tokenURI;
        }
        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
        if (bytes(_tokenURI).length > 0) {
            return string(abi.encodePacked(base, _tokenURI));
        }
        // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
        return string(abi.encodePacked(base, tokenId.toString()));
    }

    /**
    * @dev Returns the base URI set via {_setBaseURI}. This will be
    * automatically added as a prefix in {tokenURI} to each token's URI, or
    * to the token ID if no specific URI is set for that token ID.
    */
    function baseURI() public view virtual returns (string memory) {
        return _baseURI;
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        return _holderTokens[owner].at(index);
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
        return _tokenOwners.length();
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        (uint256 tokenId, ) = _tokenOwners.at(index);
        return tokenId;
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(_msgSender() == owner || ERC721Upgradeable.isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(address from, address to, uint256 tokenId) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _tokenOwners.contains(tokenId);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || ERC721Upgradeable.isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     d*
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {
        _mint(to, tokenId);
        require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

        emit Transfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721Upgradeable.ownerOf(tokenId); // internal owner

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        // Clear metadata (if any)
        if (bytes(_tokenURIs[tokenId]).length != 0) {
            delete _tokenURIs[tokenId];
        }

        _holderTokens[owner].remove(tokenId);

        _tokenOwners.remove(tokenId);

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(address from, address to, uint256 tokenId) internal virtual {
        require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal owner
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _holderTokens[from].remove(tokenId);
        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
        require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
        _tokenURIs[tokenId] = _tokenURI;
    }

    /**
     * @dev Internal function to set the base URI for all token IDs. It is
     * automatically added as a prefix to the value returned in {tokenURI},
     * or to the token ID if {tokenURI} is empty.
     */
    function _setBaseURI(string memory baseURI_) internal virtual {
        _baseURI = baseURI_;
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
        private returns (bool)
    {
        if (!to.isContract()) {
            return true;
        }
        bytes memory returndata = to.functionCall(abi.encodeWithSelector(
            IERC721ReceiverUpgradeable(to).onERC721Received.selector,
            _msgSender(),
            from,
            tokenId,
            _data
        ), "ERC721: transfer to non ERC721Receiver implementer");
        bytes4 retval = abi.decode(returndata, (bytes4));
        return (retval == _ERC721_RECEIVED);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits an {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); // internal owner
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
    uint256[41] private __gap;
}

File 7 of 29 : IERC721EnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "./IERC721Upgradeable.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721EnumerableUpgradeable is IERC721Upgradeable {

    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 8 of 29 : IERC721MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "./IERC721Upgradeable.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721MetadataUpgradeable is IERC721Upgradeable {

    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 9 of 29 : IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721ReceiverUpgradeable {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
}

File 10 of 29 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../../introspection/IERC165Upgradeable.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
      * @dev Safely transfers `tokenId` token from `from` to `to`.
      *
      * Requirements:
      *
      * - `from` cannot be the zero address.
      * - `to` cannot be the zero address.
      * - `tokenId` token must exist and be owned by `from`.
      * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
      * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
      *
      * Emits a {Transfer} event.
      */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}

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

pragma solidity ^0.7.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

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

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

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

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

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

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

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

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

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

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

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

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

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

File 12 of 29 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;
import "../proxy/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 GSN 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 initializer {
        __Context_init_unchained();
    }

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

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
    uint256[50] private __gap;
}

File 13 of 29 : EnumerableMapUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Library for managing an enumerable variant of Solidity's
 * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
 * type.
 *
 * Maps have the following properties:
 *
 * - Entries are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Entries are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableMap for EnumerableMap.UintToAddressMap;
 *
 *     // Declare a set state variable
 *     EnumerableMap.UintToAddressMap private myMap;
 * }
 * ```
 *
 * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
 * supported.
 */
library EnumerableMapUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Map type with
    // bytes32 keys and values.
    // The Map implementation uses private functions, and user-facing
    // implementations (such as Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct MapEntry {
        bytes32 _key;
        bytes32 _value;
    }

    struct Map {
        // Storage of map keys and values
        MapEntry[] _entries;

        // Position of the entry defined by a key in the `entries` array, plus 1
        // because index 0 means a key is not in the map.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex == 0) { // Equivalent to !contains(map, key)
            map._entries.push(MapEntry({ _key: key, _value: value }));
            // The entry is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            map._indexes[key] = map._entries.length;
            return true;
        } else {
            map._entries[keyIndex - 1]._value = value;
            return false;
        }
    }

    /**
     * @dev Removes a key-value pair from a map. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function _remove(Map storage map, bytes32 key) private returns (bool) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex != 0) { // Equivalent to contains(map, key)
            // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one
            // in the array, and then remove the last entry (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = keyIndex - 1;
            uint256 lastIndex = map._entries.length - 1;

            // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            MapEntry storage lastEntry = map._entries[lastIndex];

            // Move the last entry to the index where the entry to delete is
            map._entries[toDeleteIndex] = lastEntry;
            // Update the index for the moved entry
            map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved entry was stored
            map._entries.pop();

            // Delete the index for the deleted slot
            delete map._indexes[key];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function _contains(Map storage map, bytes32 key) private view returns (bool) {
        return map._indexes[key] != 0;
    }

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function _length(Map storage map) private view returns (uint256) {
        return map._entries.length;
    }

   /**
    * @dev Returns the key-value pair stored at position `index` in the map. O(1).
    *
    * Note that there are no guarantees on the ordering of entries inside the
    * array, and it may change when more entries are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {
        require(map._entries.length > index, "EnumerableMap: index out of bounds");

        MapEntry storage entry = map._entries[index];
        return (entry._key, entry._value);
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     */
    function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
        uint256 keyIndex = map._indexes[key];
        if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)
        return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function _get(Map storage map, bytes32 key) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {_tryGet}.
     */
    function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
        return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
        return _remove(map._inner, bytes32(key));
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
        return _contains(map._inner, bytes32(key));
    }

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToAddressMap storage map) internal view returns (uint256) {
        return _length(map._inner);
    }

   /**
    * @dev Returns the element stored at position `index` in the set. O(1).
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
        (bytes32 key, bytes32 value) = _at(map._inner, index);
        return (uint256(key), address(uint160(uint256(value))));
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     *
     * _Available since v3.4._
     */
    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
        (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
        return (success, address(uint160(uint256(value))));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
        return address(uint160(uint256(_get(map._inner, bytes32(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
        return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
    }
}

File 14 of 29 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }


    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}

File 15 of 29 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    /**
     * @dev Converts a `uint256` to its ASCII `string` representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        uint256 index = digits - 1;
        temp = value;
        while (temp != 0) {
            buffer[index--] = bytes1(uint8(48 + temp % 10));
            temp /= 10;
        }
        return string(buffer);
    }
}

File 16 of 29 : IAssetGuard.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;
pragma experimental ABIEncoderV2;

import "../IHasSupportedAsset.sol";

interface IAssetGuard {
  struct MultiTransaction {
    address to;
    bytes txData;
  }

  function withdrawProcessing(
    address pool,
    address asset,
    uint256 withdrawPortion,
    address to
  )
    external
    returns (
      address,
      uint256,
      MultiTransaction[] memory transactions
    );

  function getBalance(address pool, address asset) external view returns (uint256 balance);

  function getDecimals(address asset) external view returns (uint256 decimals);

  function removeAssetCheck(address poolLogic, address asset) external view;
}

File 17 of 29 : IGuard.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

interface IGuard {
  event ExchangeFrom(address fundAddress, address sourceAsset, uint256 sourceAmount, address dstAsset, uint256 time);
  event ExchangeTo(address fundAddress, address sourceAsset, address dstAsset, uint256 dstAmount, uint256 time);

  function txGuard(
    address poolManagerLogic,
    address to,
    bytes calldata data
  ) external returns (uint16 txType, bool isPublic); // TODO: eventually update `txType` to be of enum type as per ITransactionTypes
}

File 18 of 29 : IHasAssetInfo.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

interface IHasAssetInfo {
  function isValidAsset(address asset) external view returns (bool);

  function getAssetPrice(address asset) external view returns (uint256);

  function getAssetType(address asset) external view returns (uint16);

  function getMaximumSupportedAssetCount() external view returns (uint256);
}

File 19 of 29 : IHasDaoInfo.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

interface IHasDaoInfo {
  function getDaoFee() external view returns (uint256, uint256);

  function daoAddress() external view returns (address);
}

File 20 of 29 : IHasFeeInfo.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

interface IHasFeeInfo {
  // Manager fee
  function getMaximumFee()
    external
    view
    returns (
      uint256,
      uint256,
      uint256,
      uint256
    );

  function maximumPerformanceFeeNumeratorChange() external view returns (uint256);

  function performanceFeeNumeratorChangeDelay() external view returns (uint256);

  function getExitFee() external view returns (uint256, uint256);

  function getExitCooldown() external view returns (uint256);
}

File 21 of 29 : IHasGuardInfo.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

interface IHasGuardInfo {
  // Get guard
  function getContractGuard(address extContract) external view returns (address);

  // Get asset guard
  function getAssetGuard(address extContract) external view returns (address);

  // Get mapped addresses from Governance
  function getAddress(bytes32 name) external view returns (address);
}

File 22 of 29 : IHasOwnable.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

interface IHasOwnable {
  function owner() external view returns (address);
}

File 23 of 29 : IHasProtocolDaoInfo.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

interface IHasProtocolDaoInfo {
  function owner() external view returns (address);
}

File 24 of 29 : IHasSupportedAsset.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

pragma experimental ABIEncoderV2;

interface IHasSupportedAsset {
  struct Asset {
    address asset;
    bool isDeposit;
  }

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

  function isSupportedAsset(address asset) external view returns (bool);
}

File 25 of 29 : IManaged.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

interface IManaged {
  function manager() external view returns (address);

  function trader() external view returns (address);

  function managerName() external view returns (string memory);
}

File 26 of 29 : IPoolFactory.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

interface IPoolFactory {
  function governanceAddress() external view returns (address);

  function isPool(address pool) external view returns (bool);

  function customCooldownWhitelist(address from) external view returns (bool);

  function receiverWhitelist(address to) external view returns (bool);

  function emitPoolEvent() external;

  function emitPoolManagerEvent() external;
}

File 27 of 29 : IPoolLogic.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

interface IPoolLogic {
  function factory() external view returns (address);

  function poolManagerLogic() external view returns (address);

  function setPoolManagerLogic(address _poolManagerLogic) external returns (bool);

  function availableManagerFee() external view returns (uint256 fee);

  function tokenPrice() external view returns (uint256 price);

  function tokenPriceWithoutManagerFee() external view returns (uint256 price);

  function mintManagerFee() external;

  function deposit(address _asset, uint256 _amount) external returns (uint256 liquidityMinted);

  function depositFor(
    address _recipient,
    address _asset,
    uint256 _amount
  ) external returns (uint256 liquidityMinted);

  function depositForWithCustomCooldown(
    address _recipient,
    address _asset,
    uint256 _amount,
    uint256 _cooldown
  ) external returns (uint256 liquidityMinted);

  function withdraw(uint256 _fundTokenAmount) external;

  function transfer(address to, uint256 value) external returns (bool);

  function balanceOf(address owner) external view returns (uint256);

  function approve(address spender, uint256 amount) external returns (bool);

  function symbol() external view returns (string memory);

  function transferFrom(
    address from,
    address to,
    uint256 value
  ) external returns (bool);

  function getExitRemainingCooldown(address sender) external view returns (uint256 remaining);
}

File 28 of 29 : IPoolManagerLogic.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;

interface IPoolManagerLogic {
  function poolLogic() external view returns (address);

  function isDepositAsset(address asset) external view returns (bool);

  function validateAsset(address asset) external view returns (bool);

  function assetValue(address asset) external view returns (uint256);

  function assetValue(address asset, uint256 amount) external view returns (uint256);

  function assetBalance(address asset) external view returns (uint256 balance);

  function factory() external view returns (address);

  function setPoolLogic(address fundAddress) external returns (bool);

  function totalFundValue() external view returns (uint256);

  function isMemberAllowed(address member) external view returns (bool);

  function getFee()
    external
    view
    returns (
      uint256,
      uint256,
      uint256,
      uint256
    );

  function minDepositUSD() external view returns (uint256);
}

File 29 of 29 : Managed.sol
//
//        __  __    __  ________  _______    ______   ________
//       /  |/  |  /  |/        |/       \  /      \ /        |
//   ____$$ |$$ |  $$ |$$$$$$$$/ $$$$$$$  |/$$$$$$  |$$$$$$$$/
//  /    $$ |$$ |__$$ |$$ |__    $$ |  $$ |$$ | _$$/ $$ |__
// /$$$$$$$ |$$    $$ |$$    |   $$ |  $$ |$$ |/    |$$    |
// $$ |  $$ |$$$$$$$$ |$$$$$/    $$ |  $$ |$$ |$$$$ |$$$$$/
// $$ \__$$ |$$ |  $$ |$$ |_____ $$ |__$$ |$$ \__$$ |$$ |_____
// $$    $$ |$$ |  $$ |$$       |$$    $$/ $$    $$/ $$       |
//  $$$$$$$/ $$/   $$/ $$$$$$$$/ $$$$$$$/   $$$$$$/  $$$$$$$$/
//
// dHEDGE DAO - https://dhedge.org
//
// Copyright (c) 2021 dHEDGE DAO
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//
// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.7.6;

import "./interfaces/IManaged.sol";

import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";

/// @notice Role manage contract
contract Managed is IManaged {
  using SafeMathUpgradeable for uint256;

  event ManagerUpdated(address newManager, string newManagerName);

  address public override manager;
  string public override managerName;

  address[] private _memberList;
  mapping(address => uint256) private _memberPosition;

  address public override trader;

  /// @notice Initialize of the managed contract
  /// @param newManager The address of the new manager
  /// @param newManagerName The name of the new manager
  function initialize(address newManager, string memory newManagerName) internal {
    require(newManager != address(0), "Invalid manager");
    manager = newManager;
    managerName = newManagerName;
  }

  modifier onlyManager() {
    require(msg.sender == manager, "only manager");
    _;
  }

  modifier onlyManagerOrTrader() {
    require(msg.sender == manager || msg.sender == trader, "only manager or trader");
    _;
  }

  /// @notice Return boolean if the address is a member of the list
  /// @param member The address of the member
  /// @return True if the address is a member of the list, false otherwise
  function _isMemberAllowed(address member) internal view returns (bool) {
    return _memberPosition[member] != 0;
  }

  /// @notice Get a list of members
  /// @return members Array of member addresses
  function getMembers() external view returns (address[] memory members) {
    members = _memberList;
  }

  /// @notice change the manager address
  /// @param newManager The address of the new manager
  /// @param newManagerName The name of the new manager
  function changeManager(address newManager, string memory newManagerName) external onlyManager {
    require(newManager != address(0), "Invalid manager");
    manager = newManager;
    managerName = newManagerName;
    emit ManagerUpdated(newManager, newManagerName);
  }

  /// @notice add a list of members
  /// @param members Array of member addresses
  function addMembers(address[] memory members) external onlyManager {
    for (uint256 i = 0; i < members.length; i++) {
      if (_isMemberAllowed(members[i])) continue;

      _addMember(members[i]);
    }
  }

  /// @notice remove a list of members
  /// @param members Array of member addresses
  function removeMembers(address[] memory members) external onlyManager {
    for (uint256 i = 0; i < members.length; i++) {
      if (!_isMemberAllowed(members[i])) continue;

      _removeMember(members[i]);
    }
  }

  /// @notice add a member
  /// @param member The address of the member
  function addMember(address member) external onlyManager {
    if (_isMemberAllowed(member)) return;

    _addMember(member);
  }

  /// @notice remove a member
  /// @param member The address of the member
  function removeMember(address member) external onlyManager {
    if (!_isMemberAllowed(member)) return;

    _removeMember(member);
  }

  /// @notice Set the address of the trader
  /// @param newTrader The address of the new trader
  function setTrader(address newTrader) external onlyManager {
    require(newTrader != address(0), "Invalid trader");
    trader = newTrader;
  }

  /// @notice Remove the trader
  function removeTrader() external onlyManager {
    trader = address(0);
  }

  /// @notice Return the number of members
  /// @return _numberOfMembers The number of members
  function numberOfMembers() external view returns (uint256 _numberOfMembers) {
    _numberOfMembers = _memberList.length;
  }

  /// @notice Add member internal call
  /// @param member The address of the member
  function _addMember(address member) internal {
    _memberList.push(member);
    _memberPosition[member] = _memberList.length;
  }

  /// @notice Remove member internal call
  /// @param member The address of the member
  function _removeMember(address member) internal {
    uint256 length = _memberList.length;
    uint256 index = _memberPosition[member].sub(1);

    address lastMember = _memberList[length.sub(1)];

    _memberList[index] = lastMember;
    _memberPosition[lastMember] = index.add(1);
    _memberPosition[member] = 0;

    _memberList.pop();
  }
}

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

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"fundAddress","type":"address"},{"indexed":false,"internalType":"address","name":"manager","type":"address"},{"indexed":false,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"bool","name":"isDeposit","type":"bool"}],"name":"AssetAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"fundAddress","type":"address"},{"indexed":false,"internalType":"address","name":"manager","type":"address"},{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"AssetRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"performanceFeeNumerator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"managerFeeNumerator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"announcedFeeActivationTime","type":"uint256"}],"name":"ManagerFeeIncreaseAnnounced","type":"event"},{"anonymous":false,"inputs":[],"name":"ManagerFeeIncreaseRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"fundAddress","type":"address"},{"indexed":false,"internalType":"address","name":"manager","type":"address"},{"indexed":false,"internalType":"uint256","name":"performanceFeeNumerator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"managerFeeNumerator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"entryFeeNumerator","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"ManagerFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newManager","type":"address"},{"indexed":false,"internalType":"string","name":"newManagerName","type":"string"}],"name":"ManagerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minDepositUSD","type":"uint256"}],"name":"MinDepositUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"poolLogic","type":"address"},{"indexed":false,"internalType":"address","name":"from","type":"address"}],"name":"PoolLogicSet","type":"event"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"addMember","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"members","type":"address[]"}],"name":"addMembers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_performanceFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"_managerFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"_entryFeeNumerator","type":"uint256"}],"name":"announceFeeIncrease","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"announcedEntryFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"announcedFeeIncreaseTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"announcedManagerFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"announcedPerformanceFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"assetBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"assetDecimal","outputs":[{"internalType":"uint256","name":"decimal","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"assetPosition","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"assetValue","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"assetValue","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"bool","name":"isDeposit","type":"bool"}],"internalType":"struct IHasSupportedAsset.Asset[]","name":"_addAssets","type":"tuple[]"},{"internalType":"address[]","name":"_removeAssets","type":"address[]"}],"name":"changeAssets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newManager","type":"address"},{"internalType":"string","name":"newManagerName","type":"string"}],"name":"changeManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"commitFeeIncrease","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"entryFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDepositAssets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFeeIncreaseInfo","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFundComposition","outputs":[{"components":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"bool","name":"isDeposit","type":"bool"}],"internalType":"struct IHasSupportedAsset.Asset[]","name":"assets","type":"tuple[]"},{"internalType":"uint256[]","name":"balances","type":"uint256[]"},{"internalType":"uint256[]","name":"rates","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMaximumFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMaximumPerformanceFeeChange","outputs":[{"internalType":"uint256","name":"change","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMembers","outputs":[{"internalType":"address[]","name":"members","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSupportedAssets","outputs":[{"components":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"bool","name":"isDeposit","type":"bool"}],"internalType":"struct IHasSupportedAsset.Asset[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_manager","type":"address"},{"internalType":"string","name":"_managerName","type":"string"},{"internalType":"address","name":"_poolLogic","type":"address"},{"internalType":"uint256","name":"_performanceFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"_managerFeeNumerator","type":"uint256"},{"components":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"bool","name":"isDeposit","type":"bool"}],"internalType":"struct IHasSupportedAsset.Asset[]","name":"_supportedAssets","type":"tuple[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"isDepositAsset","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"isMemberAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"isNftMemberAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"isSupportedAsset","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"managerFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"managerName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minDepositUSD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftMembershipCollectionAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numberOfMembers","outputs":[{"internalType":"uint256","name":"_numberOfMembers","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"performanceFeeNumerator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolLogic","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"removeMember","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"members","type":"address[]"}],"name":"removeMembers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"removeTrader","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceFeeIncrease","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_performanceFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"_managerFeeNumerator","type":"uint256"},{"internalType":"uint256","name":"_entryFeeNumerator","type":"uint256"}],"name":"setFeeNumerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minDepositUSD","type":"uint256"}],"name":"setMinDepositUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newNftMembershipCollectionAddress","type":"address"}],"name":"setNftMembershipCollectionAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_poolLogic","type":"address"}],"name":"setPoolLogic","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTrader","type":"address"}],"name":"setTrader","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"supportedAssets","outputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"bool","name":"isDeposit","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalFundValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trader","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"validateAsset","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50613b24806100206000396000f3fe608060405234801561001057600080fd5b50600436106102615760003560e01c80639240d2991161014d5780639240d299146103ff57806397957825146104125780639be918e61461041a5780639eab52531461042d578063a30e3fa914610442578063a6bc18f91461044a578063ad60ffcc1461045d578063b34fa37c14610465578063b74a68d714610478578063bbbf725b14610480578063bdbef07d14610493578063bf0a9738146104a6578063bfd67ccb146104ae578063c45a0155146104b6578063c68dbb37146104be578063ca6d56dc146104df578063cd88e558146104f2578063ced72f8714610505578063d5110cfd1461050d578063d8af8ed414610515578063e5406dbf14610528578063eb7218fa1461053d578063ee5fd82514610550578063f09d14d714610558578063fc43863f1461056f578063fed4416a1461057757610261565b806308d7ce02146102665780630b1ca49a146102875780630b422ae31461029c5780630e6f9f79146102a45780631758078b146102b95780631aca138b146102ce57806329c07fba146102e157806339b81fd9146102f45780633c570d7d146102fc57806346ee84b01461030f578063481c6a751461032257806350b721a71461032a5780635221366314610332578063560a4a3d1461034557806360c44031146103585780636c262bfe146103785780636f452c931461038b5780636f4d469b1461039357806370999382146103a65780637b4d0c63146103b95780637c8afd51146103c157806389e0a081146103c95780638aafd945146103d15780638e10153d146103e45780639143b916146103f7575b600080fd5b61026e61058c565b60405161027e94939291906139ed565b60405180910390f35b61029a610295366004613063565b610626565b005b61029a610698565b6102ac6107a6565b60405161027e91906139ce565b6102c16107ac565b60405161027e91906134e8565b61029a6102dc366004613063565b6107bb565b6102ac6102ef366004613216565b6108ee565b6102c16109a3565b6102ac61030a366004613063565b6109b2565b61029a61031d366004613241565b6109c4565b6102c1610a71565b6102ac610a86565b61029a61034036600461317b565b610a8c565b61029a6103533660046132ed565b610c11565b61036b610366366004613063565b610cb7565b60405161027e9190613651565b61029a61038636600461309b565b610d5a565b6102ac610f0f565b61029a6103a1366004613241565b610f91565b6102ac6103b4366004613063565b61102e565b6102ac611139565b61029a61113f565b61026e6111a5565b61029a6103df366004613409565b6111b7565b61036b6103f2366004613063565b611261565b6102ac61141b565b61036b61040d366004613063565b611421565b6102ac6114a2565b61036b610428366004613063565b6114a8565b6104356114c5565b60405161027e91906135ae565b6102ac611527565b61029a610458366004613063565b61152d565b6102ac6115ef565b61029a610473366004613409565b611647565b6102ac6117ef565b61036b61048e366004613063565b6117f5565b61036b6104a1366004613063565b61180f565b6102ac611866565b6102c161186c565b6102c161187b565b6104d16104cc3660046133d9565b61188a565b60405161027e929190613593565b61029a6104ed366004613063565b6118bf565b6102ac610500366004613063565b61192f565b61026e6119e9565b61029a611a93565b6102ac610523366004613063565b611b2e565b610530611b3d565b60405161027e91906135fb565b61029a61054b3660046133d9565b611bb5565b6102ac611c1a565b610560611c20565b60405161027e9392919061360e565b610435611e6e565b61057f611f71565b60405161027e919061365c565b600080600080600560009054906101000a90046001600160a01b03166001600160a01b03166308d7ce026040518163ffffffff1660e01b815260040160806040518083038186803b1580156105e057600080fd5b505afa1580156105f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106189190613434565b935093509350935090919293565b6000546201000090046001600160a01b0316331461067a576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b61068381611ffe565b61068c57610695565b6106958161201b565b50565b6000546201000090046001600160a01b031633146106ec576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b600a544210156107175760405162461bcd60e51b815260040161070e90613821565b60405180910390fd5b600660009054906101000a90046001600160a01b03166001600160a01b031663cc3c6df66040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561076757600080fd5b505af115801561077b573d6000803e3d6000fd5b50505050610790600954600c54601054612114565b60006009819055600c8190556010819055600a55565b600d5481565b6004546001600160a01b031681565b6000546201000090046001600160a01b0316331461080f576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b6001600160a01b03811661083d57600e80546001600160a01b0319166001600160a01b038316179055610695565b6040516370a0823160e01b81526001600160a01b038216906370a08231906108699030906004016134e8565b60206040518083038186803b15801561088157600080fd5b505afa9250505080156108b1575060408051601f3d908101601f191682019092526108ae918101906133f1565b60015b6108cd5760405162461bcd60e51b815260040161070e906137f5565b50600e80546001600160a01b0383166001600160a01b031990911617905550565b60055460405163b3596f0760e01b815260009182916001600160a01b039091169063b3596f07906109239087906004016134e8565b60206040518083038186803b15801561093b57600080fd5b505afa15801561094f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097391906133f1565b905060006109808561102e565b905061099a600a82900a61099484876121d5565b90612237565b95945050505050565b6006546001600160a01b031681565b60086020526000908152604090205481565b6000546201000090046001600160a01b03163314610a18576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b60005b8151811015610a6d57610a40828281518110610a3357fe5b6020026020010151611ffe565b610a4957610a65565b610a65828281518110610a5857fe5b602002602001015161201b565b600101610a1b565b5050565b6000546201000090046001600160a01b031681565b600f5481565b6000546201000090046001600160a01b03163314610ae0576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b6001600160a01b038216610b2d576040805162461bcd60e51b815260206004820152600f60248201526e24b73b30b634b21036b0b730b3b2b960891b604482015290519081900360640190fd5b6000805462010000600160b01b031916620100006001600160a01b038516021790558051610b62906001906020840190612f57565b507f6ed15082ad038474841528b5badca105106d4463e44b5d434130dfb299aa3669828260405180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610bd2578181015183820152602001610bba565b50505050905090810190601f168015610bff5780820380516001836020036101000a031916815260200191505b50935050505060405180910390a15050565b6000546201000090046001600160a01b0316331480610c3a57506004546001600160a01b031633145b80610c4f57506005546001600160a01b031633145b610c6b5760405162461bcd60e51b815260040161070e90613854565b610ca9848484848080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061229b92505050565b610cb16123d6565b50505050565b600e546000906001600160a01b031615801590610d525750600e546040516370a0823160e01b81526000916001600160a01b0316906370a0823190610d009086906004016134e8565b60206040518083038186803b158015610d1857600080fd5b505afa158015610d2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5091906133f1565b115b90505b919050565b600054610100900460ff1680610d735750610d7361243a565b80610d81575060005460ff16155b610dbc5760405162461bcd60e51b815260040180806020018281038252602e815260200180613aa0602e913960400191505060405180910390fd5b600054610100900460ff16158015610de7576000805460ff1961ff0019909116610100171660011790555b6001600160a01b038a16610e0d5760405162461bcd60e51b815260040161070e90613915565b6001600160a01b038916610e335760405162461bcd60e51b815260040161070e906138ec565b6001600160a01b038616610e595760405162461bcd60e51b815260040161070e9061379c565b610e998989898080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061244b92505050565b600580546001600160a01b03808d166001600160a01b0319928316179092556006805492891692909116919091179055610ed585856000612114565b604080516000815260208101909152610ef1908490849061229b565b8015610f03576000805461ff00191690555b50505050505050505050565b60055460408051636bb9347360e11b815290516000926001600160a01b03169163d77268e6916004808301926020929190829003018186803b158015610f5457600080fd5b505afa158015610f68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8c91906133f1565b905090565b6000546201000090046001600160a01b03163314610fe5576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b60005b8151811015610a6d57611000828281518110610a3357fe5b1561100a57611026565b61102682828151811061101957fe5b60200260200101516124cd565b600101610fe8565b600554604051633f30232f60e21b815260009182916001600160a01b039091169063fcc08cbc906110639086906004016134e8565b60206040518083038186803b15801561107b57600080fd5b505afa15801561108f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b3919061307f565b60405163067aa55560e51b81529091506001600160a01b0382169063cf54aaa0906110e29086906004016134e8565b60206040518083038186803b1580156110fa57600080fd5b505afa15801561110e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113291906133f1565b9392505050565b600a5481565b6000546201000090046001600160a01b03163314611193576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b600480546001600160a01b0319169055565b600954600c54601054600a5490919293565b6000546201000090046001600160a01b0316331461120b576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b600b54831115801561121f5750600d548211155b801561122d57506011548111155b6112495760405162461bcd60e51b815260040161070e906137c7565b611254838383612114565b61125c6123d6565b505050565b600080600560009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156112b257600080fd5b505afa1580156112c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ea919061307f565b9050336001600160a01b038216146113145760405162461bcd60e51b815260040161070e90613705565b306001600160a01b0316836001600160a01b0316631e50a4a66040518163ffffffff1660e01b815260040160206040518083038186803b15801561135757600080fd5b505afa15801561136b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061138f919061307f565b6001600160a01b0316146113b55760405162461bcd60e51b815260040161070e90613770565b600680546001600160a01b0319166001600160a01b0385161790556040517f8c1446ebd2ac8c922b8c9716dfbdfcfef02c9fc167140d7cfd019565b423b2499061140290859033906134fc565b60405180910390a16114126123d6565b50600192915050565b60095481565b60055460405163cc435bf360e01b81526000916001600160a01b03169063cc435bf3906114529085906004016134e8565b60206040518083038186803b15801561146a57600080fd5b505afa15801561147e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d52919061339b565b60115481565b6001600160a01b0316600090815260086020526040902054151590565b6060600280548060200260200160405190810160405280929190818152602001828054801561151d57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116114ff575b5050505050905090565b60025490565b6000546201000090046001600160a01b03163314611581576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b6001600160a01b0381166115cd576040805162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b2103a3930b232b960911b604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6007546000908190815b8181101561163f5761163561162e6007838154811061161457fe5b6000918252602090912001546001600160a01b0316611b2e565b8490612529565b92506001016115f9565b509091505090565b6000546201000090046001600160a01b0316331461169b576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b60008060006116a861058c565b5092509250925060006116b9610f0f565b90508387111580156116cb5750828611155b80156116d75750818511155b80156116ef5750600b546116eb9082612529565b8711155b61170b5760405162461bcd60e51b815260040161070e9061393e565b600554604080516332dbceef60e21b815290516000926001600160a01b03169163cb6f3bbc916004808301926020929190829003018186803b15801561175057600080fd5b505afa158015611764573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178891906133f1565b6009899055600c8890556010879055428101600a8190556040519192507f85ebab1aaaca4ce6e4c14468cff4654ea8d9ec85d5f4a5a68f2ec2e49380c97d916117d5918b918b91906139d7565b60405180910390a16117e56123d6565b5050505050505050565b600b5481565b600061180082611ffe565b80610d525750610d5282610cb7565b6001600160a01b03811660009081526008602052604081205480158015906111325750600761183f826001612581565b8154811061184957fe5b600091825260209091200154600160a01b900460ff169392505050565b60105481565b600e546001600160a01b031681565b6005546001600160a01b031681565b6007818154811061189a57600080fd5b6000918252602090912001546001600160a01b0381169150600160a01b900460ff1682565b6000546201000090046001600160a01b03163314611913576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b61191c81611ffe565b1561192657610695565b610695816124cd565b600554604051633f30232f60e21b815260009182916001600160a01b039091169063fcc08cbc906119649086906004016134e8565b60206040518083038186803b15801561197c57600080fd5b505afa158015611990573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b4919061307f565b60065460405163d4fac45d60e01b81529192506001600160a01b038084169263d4fac45d926110e292169087906004016134fc565b6000806000806000600560009054906101000a90046001600160a01b03166001600160a01b03166308d7ce026040518163ffffffff1660e01b815260040160806040518083038186803b158015611a3f57600080fd5b505afa158015611a53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a779190613434565b600b54600d54601154919a509850965094505050505090919293565b6000546201000090046001600160a01b03163314611ae7576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b60006009819055600c8190556010819055600a8190556040517fc6f04bf43cbdf1ba5d51b4afa160bb3c7e13858b1409aa32868b239bb2f8d8499190a1611b2c6123d6565b565b6000610d52826102ef8461192f565b60606007805480602002602001604051908101604052809291908181526020016000905b82821015611bac57600084815260209081902060408051808201909152908401546001600160a01b0381168252600160a01b900460ff16151581830152825260019092019101611b61565b50505050905090565b6000546201000090046001600160a01b03163314611c09576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b611c12816125de565b6106956123d6565b600c5481565b60075460609081908190806001600160401b0381118015611c4057600080fd5b50604051908082528060200260200182016040528015611c7a57816020015b611c67612fe3565b815260200190600190039081611c5f5790505b509350806001600160401b0381118015611c9357600080fd5b50604051908082528060200260200182016040528015611cbd578160200160208202803683370190505b509250806001600160401b0381118015611cd657600080fd5b50604051908082528060200260200182016040528015611d00578160200160208202803683370190505b50915060005b818160ff161015611e6757600060078260ff1681548110611d2357fe5b6000918252602090912001546001600160a01b03169050611d438161192f565b858360ff1681518110611d5257fe5b60200260200101818152505060078260ff1681548110611d6e57fe5b6000918252602091829020604080518082019091529101546001600160a01b038116825260ff600160a01b9091048116151592820192909252875190918891908516908110611db957fe5b602090810291909101015260055460405163b3596f0760e01b81526001600160a01b039091169063b3596f0790611df49084906004016134e8565b60206040518083038186803b158015611e0c57600080fd5b505afa158015611e20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4491906133f1565b848360ff1681518110611e5357fe5b602090810291909101015250600101611d06565b5050909192565b6007546060906000816001600160401b0381118015611e8c57600080fd5b50604051908082528060200260200182016040528015611eb6578160200160208202803683370190505b5090506000805b838160ff161015611f535760078160ff1681548110611ed857fe5b600091825260209091200154600160a01b900460ff1615611f4b5760078160ff1681548110611f0357fe5b60009182526020909120015483516001600160a01b0390911690849060ff8516908110611f2c57fe5b6001600160a01b03909216602092830291909101909101526001909101905b600101611ebd565b506000611f638460ff8416612581565b835103835250909250505090565b60018054604080516020600284861615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015611ff65780601f10611fcb57610100808354040283529160200191611ff6565b820191906000526020600020905b815481529060010190602001808311611fd957829003601f168201915b505050505081565b6001600160a01b0316600090815260036020526040902054151590565b6002546001600160a01b038216600090815260036020526040812054612042906001612581565b905060006002612053846001612581565b8154811061205d57fe5b600091825260209091200154600280546001600160a01b03909216925082918490811061208657fe5b600091825260209091200180546001600160a01b0319166001600160a01b03929092169190911790556120ba826001612529565b6001600160a01b038083166000908152600360205260408082209390935590861681529081205560028054806120ec57fe5b600082815260209020810160001990810180546001600160a01b031916905501905550505050565b60008060008061212261058c565b935093509350935083871115801561213a5750828611155b80156121465750818511155b6121625760405162461bcd60e51b815260040161070e90613971565b600b879055600d86905560118590556006546000546040517f4ee6e02dcf04678ab842300dd9ea86277d98bd793cee41cecde1e1666ad94755926121c4926001600160a01b039182169262010000909104909116908b908b908b90889061355d565b60405180910390a150505050505050565b6000826121e457506000612231565b828202828482816121f157fe5b041461222e5760405162461bcd60e51b8152600401808060200182810382526021815260200180613ace6021913960400191505060405180910390fd5b90505b92915050565b600080821161228a576040805162461bcd60e51b815260206004820152601a602482015279536166654d6174683a206469766973696f6e206279207a65726f60301b604482015290519081900360640190fd5b81838161229357fe5b049392505050565b60005b81518160ff1610156122d1576122c9828260ff16815181106122bc57fe5b602002602001015161261e565b60010161229e565b5060005b60ff8116831115612305576122fd84848360ff168181106122f257fe5b905060400201612a1f565b6001016122d5565b50600560009054906101000a90046001600160a01b03166001600160a01b031663aa12ae4d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561235457600080fd5b505afa158015612368573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238c91906133f1565b60075411156123ad5760405162461bcd60e51b815260040161070e9061399e565b60016123b7611e6e565b51101561125c5760405162461bcd60e51b815260040161070e906138b8565b600560009054906101000a90046001600160a01b03166001600160a01b0316633f7f5c726040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561242657600080fd5b505af1158015610cb1573d6000803e3d6000fd5b600061244530612f51565b15905090565b6001600160a01b038216612498576040805162461bcd60e51b815260206004820152600f60248201526e24b73b30b634b21036b0b730b3b2b960891b604482015290519081900360640190fd5b6000805462010000600160b01b031916620100006001600160a01b03851602179055805161125c906001906020840190612f57565b600280546001810182557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b039093166001600160a01b0319909316831790555460009182526003602052604090912055565b60008282018381101561222e576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b6000828211156125d8576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600f8190556040517f96a008f96f1c0ab9fa3d9ddd43cdfc614848c4d054d51f43662ed900e9d094c8906126139083906139ce565b60405180910390a150565b612627816114a8565b6126435760405162461bcd60e51b815260040161070e9061388b565b600554604051633f30232f60e21b81526000916001600160a01b03169063fcc08cbc906126749085906004016134e8565b60206040518083038186803b15801561268c57600080fd5b505afa1580156126a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126c4919061307f565b90506001600160a01b03811615612760576126de8261192f565b156126fb5760405162461bcd60e51b815260040161070e90613739565b600654604051631b57eb9560e21b81526001600160a01b0383811692636d5fae549261272f929091169086906004016134fc565b60006040518083038186803b15801561274757600080fd5b505afa15801561275b573d6000803e3d6000fd5b505050505b6001600160a01b038216600090815260086020526040812054612784906001612581565b600754909150815b81612798826001612529565b1015612953576000600782815481106127ad57fe5b6000918252602091829020604080518082019091529101546001600160a01b0381168252600160a01b900460ff16151591810191909152905060076127f3836001612529565b815481106127fd57fe5b906000526020600020016007838154811061281457fe5b600091825260209091208254910180546001600160a01b0319166001600160a01b0390921691909117808255915460ff600160a01b918290041615150260ff60a01b1990921691909117905561286b826001612529565b600860006007858154811061287c57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020558060076128af846001612529565b815481106128b957fe5b600091825260209182902083519101805493909201511515600160a01b0260ff60a01b196001600160a01b039092166001600160a01b0319909416939093171691909117905561290a826002612529565b60086000600761291b866001612529565b8154811061292557fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020555060010161278c565b5060006008816007612966856001612581565b8154811061297057fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205560078054806129a057fe5b600082815260208120820160001990810180546001600160a81b031916905590910190915560065490546040517f9b4f55639e5e283319baee5bc4e69a5625a8e3a1cc004af968f4fee72502202792612a11926001600160a01b039182169262010000909104909116908890613516565b60405180910390a150505050565b6000612a2e6020830183613063565b90506000612a42604084016020850161337f565b9050612a4d82611421565b612a695760405162461bcd60e51b815260040161070e906136de565b600654612a7e906001600160a01b0316611421565b1580612b075750600554604051635b16ebb760e01b81526001600160a01b0390911690635b16ebb790612ab59085906004016134e8565b60206040518083038186803b158015612acd57600080fd5b505afa158015612ae1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b05919061339b565b155b612b235760405162461bcd60e51b815260040161070e906136af565b612b2c826114a8565b15612b90576001600160a01b038216600090815260086020526040812054612b55906001612581565b90508160078281548110612b6557fe5b60009182526020909120018054911515600160a01b0260ff60a01b1990921691909117905550612ef5565b60078054600181018255600091909152837fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6888201612bce8282613a2b565b50612bdc9050816001612529565b6001600160a01b0380851660009081526008602052604080822093909355600554925163032c49ed60e01b815290929091169063032c49ed90612c239087906004016134e8565b60206040518083038186803b158015612c3b57600080fd5b505afa158015612c4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c7391906133b7565b90505b600082118015612d3b575060055461ffff8216906001600160a01b031663032c49ed6007612ca5866001612581565b81548110612caf57fe5b6000918252602090912001546040516001600160e01b031960e084901b168152612ce5916001600160a01b0316906004016134e8565b60206040518083038186803b158015612cfd57600080fd5b505afa158015612d11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d3591906133b7565b61ffff16105b15612ef257600060078381548110612d4f57fe5b6000918252602091829020604080518082019091529101546001600160a01b0381168252600160a01b900460ff1615159181019190915290506007612d95846001612581565b81548110612d9f57fe5b9060005260206000200160078481548110612db657fe5b600091825260209091208254910180546001600160a01b0319166001600160a01b0390921691909117808255915460ff600160a01b918290041615150260ff60a01b19909216919091179055612e0d836001612529565b6008600060078681548110612e1e57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902055806007612e51856001612581565b81548110612e5b57fe5b6000918252602080832084519201805494909101511515600160a01b0260ff60a01b196001600160a01b039093166001600160a01b031990951694909417919091169290921790915583906008906007612eb6846001612581565b81548110612ec057fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020555060001990910190612c76565b50505b6006546000546040516001600160a01b03928316927fdb9319bd5f91884f639cec9a5e01b183bedb3e6a3ab459b6e72c0b1264e7742b92612f4492620100009091049091169086908690613539565b60405180910390a2505050565b3b151590565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282612f8d5760008555612fd3565b82601f10612fa657805160ff1916838001178555612fd3565b82800160010185558215612fd3579182015b82811115612fd3578251825591602001919060010190612fb8565b50612fdf929150612ffa565b5090565b604080518082019091526000808252602082015290565b5b80821115612fdf5760008155600101612ffb565b8035610d5581613a7c565b60008083601f84011261302b578182fd5b5081356001600160401b03811115613041578182fd5b60208301915083602060408302850101111561305c57600080fd5b9250929050565b600060208284031215613074578081fd5b813561222e81613a7c565b600060208284031215613090578081fd5b815161222e81613a7c565b600080600080600080600080600060e08a8c0312156130b8578485fd5b89356130c381613a7c565b985060208a01356130d381613a7c565b975060408a01356001600160401b03808211156130ee578687fd5b818c0191508c601f830112613101578687fd5b81358181111561310f578788fd5b8d6020828501011115613120578788fd5b602083019950975061313460608d0161300f565b965060808c0135955060a08c0135945060c08c0135915080821115613157578384fd5b506131648c828d0161301a565b915080935050809150509295985092959850929598565b6000806040838503121561318d578182fd5b823561319881613a7c565b91506020838101356001600160401b03808211156131b4578384fd5b818601915086601f8301126131c7578384fd5b8135818111156131d357fe5b6131e5601f8201601f19168501613a08565b915080825287848285010111156131fa578485fd5b8084840185840137810190920192909252919491935090915050565b60008060408385031215613228578182fd5b823561323381613a7c565b946020939093013593505050565b60006020808385031215613253578182fd5b82356001600160401b0380821115613269578384fd5b818501915085601f83011261327c578384fd5b81358181111561328857fe5b8381029150613298848301613a08565b8181528481019084860184860187018a10156132b2578788fd5b8795505b838610156132e057803594506132cb85613a7c565b848352600195909501949186019186016132b6565b5098975050505050505050565b60008060008060408587031215613302578384fd5b84356001600160401b0380821115613318578586fd5b6133248883890161301a565b9096509450602087013591508082111561333c578384fd5b818701915087601f83011261334f578384fd5b81358181111561335d578485fd5b8860208083028501011115613370578485fd5b95989497505060200194505050565b600060208284031215613390578081fd5b813561222e81613a91565b6000602082840312156133ac578081fd5b815161222e81613a91565b6000602082840312156133c8578081fd5b815161ffff8116811461222e578182fd5b6000602082840312156133ea578081fd5b5035919050565b600060208284031215613402578081fd5b5051919050565b60008060006060848603121561341d578081fd5b505081359360208301359350604090920135919050565b60008060008060808587031215613449578182fd5b505082516020840151604085015160609095015191969095509092509050565b6000815180845260208085019450808401835b838110156134ae57815180516001600160a01b031688528301511515838801526040909601959082019060010161347c565b509495945050505050565b6000815180845260208085019450808401835b838110156134ae578151875295820195908201906001016134cc565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b0393841681529183166020830152909116604082015260600190565b6001600160a01b039384168152919092166020820152901515604082015260600190565b6001600160a01b03968716815294909516602085015260408401929092526060830152608082015260a081019190915260c00190565b6001600160a01b039290921682521515602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156135ef5783516001600160a01b0316835292840192918401916001016135ca565b50909695505050505050565b6000602082526111326020830184613469565b6000606082526136216060830186613469565b828103602084015261363381866134b9565b9050828103604084015261364781856134b9565b9695505050505050565b901515815260200190565b6000602080835283518082850152825b818110156136885785810183015185820160400152820161366c565b818111156136995783604083870101525b50601f01601f1916929092016040019392505050565b60208082526015908201527418d85b9b9bdd08185919081c1bdbdb08185cdcd95d605a1b604082015260600190565b6020808252600d908201526c1a5b9d985b1a5908185cdcd95d609a1b604082015260600190565b6020808252601a90820152791bdb9b1e481bdddb995c881859191c995cdcc8185b1b1bddd95960321b604082015260600190565b6020808252601d908201527f63616e6e6f742072656d6f7665206e6f6e2d656d707479206173736574000000604082015260600190565b602080825260129082015271696e76616c696420706f6f6c206c6f67696360701b604082015260600190565b602080825260119082015270496e76616c696420706f6f6c4c6f67696360781b604082015260600190565b6020808252601490820152730dac2dcc2cecae440cccaca40e8dede40d0d2ced60631b604082015260600190565b60208082526012908201527124b73b30b634b21031b7b63632b1ba34b7b760711b604082015260600190565b60208082526019908201527866656520696e6372656173652064656c61792061637469766560381b604082015260600190565b6020808252601f908201527f6f6e6c79206d616e616765722c20747261646572206f7220666163746f727900604082015260600190565b602080825260139082015272185cdcd95d081b9bdd081cdd5c1c1bdc9d1959606a1b604082015260600190565b6020808252601a9082015279185d081b19585cdd081bdb994819195c1bdcda5d08185cdcd95d60321b604082015260600190565b6020808252600f908201526e24b73b30b634b21036b0b730b3b2b960891b604082015260600190565b6020808252600f908201526e496e76616c696420666163746f727960881b604082015260600190565b602080825260199082015278657863656564656420616c6c6f77656420696e63726561736560381b604082015260600190565b602080825260139082015272696e76616c6964206d616e616765722066656560681b604082015260600190565b6020808252601690820152751b585e1a5b5d5b48185cdcd95d1cc81c995858da195960521b604082015260600190565b90815260200190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b6040518181016001600160401b0381118282101715613a2357fe5b604052919050565b8135613a3681613a7c565b81546001600160a01b0319166001600160a01b0391909116178082556020830135613a6081613a91565b60ff60a01b199190911690151560a01b60ff60a01b1617905550565b6001600160a01b038116811461069557600080fd5b801515811461069557600080fdfe496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220a41116b962b2598edd27d1f17987a78514501a6223b47feb948fb49094b3643e64736f6c63430007060033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102615760003560e01c80639240d2991161014d5780639240d299146103ff57806397957825146104125780639be918e61461041a5780639eab52531461042d578063a30e3fa914610442578063a6bc18f91461044a578063ad60ffcc1461045d578063b34fa37c14610465578063b74a68d714610478578063bbbf725b14610480578063bdbef07d14610493578063bf0a9738146104a6578063bfd67ccb146104ae578063c45a0155146104b6578063c68dbb37146104be578063ca6d56dc146104df578063cd88e558146104f2578063ced72f8714610505578063d5110cfd1461050d578063d8af8ed414610515578063e5406dbf14610528578063eb7218fa1461053d578063ee5fd82514610550578063f09d14d714610558578063fc43863f1461056f578063fed4416a1461057757610261565b806308d7ce02146102665780630b1ca49a146102875780630b422ae31461029c5780630e6f9f79146102a45780631758078b146102b95780631aca138b146102ce57806329c07fba146102e157806339b81fd9146102f45780633c570d7d146102fc57806346ee84b01461030f578063481c6a751461032257806350b721a71461032a5780635221366314610332578063560a4a3d1461034557806360c44031146103585780636c262bfe146103785780636f452c931461038b5780636f4d469b1461039357806370999382146103a65780637b4d0c63146103b95780637c8afd51146103c157806389e0a081146103c95780638aafd945146103d15780638e10153d146103e45780639143b916146103f7575b600080fd5b61026e61058c565b60405161027e94939291906139ed565b60405180910390f35b61029a610295366004613063565b610626565b005b61029a610698565b6102ac6107a6565b60405161027e91906139ce565b6102c16107ac565b60405161027e91906134e8565b61029a6102dc366004613063565b6107bb565b6102ac6102ef366004613216565b6108ee565b6102c16109a3565b6102ac61030a366004613063565b6109b2565b61029a61031d366004613241565b6109c4565b6102c1610a71565b6102ac610a86565b61029a61034036600461317b565b610a8c565b61029a6103533660046132ed565b610c11565b61036b610366366004613063565b610cb7565b60405161027e9190613651565b61029a61038636600461309b565b610d5a565b6102ac610f0f565b61029a6103a1366004613241565b610f91565b6102ac6103b4366004613063565b61102e565b6102ac611139565b61029a61113f565b61026e6111a5565b61029a6103df366004613409565b6111b7565b61036b6103f2366004613063565b611261565b6102ac61141b565b61036b61040d366004613063565b611421565b6102ac6114a2565b61036b610428366004613063565b6114a8565b6104356114c5565b60405161027e91906135ae565b6102ac611527565b61029a610458366004613063565b61152d565b6102ac6115ef565b61029a610473366004613409565b611647565b6102ac6117ef565b61036b61048e366004613063565b6117f5565b61036b6104a1366004613063565b61180f565b6102ac611866565b6102c161186c565b6102c161187b565b6104d16104cc3660046133d9565b61188a565b60405161027e929190613593565b61029a6104ed366004613063565b6118bf565b6102ac610500366004613063565b61192f565b61026e6119e9565b61029a611a93565b6102ac610523366004613063565b611b2e565b610530611b3d565b60405161027e91906135fb565b61029a61054b3660046133d9565b611bb5565b6102ac611c1a565b610560611c20565b60405161027e9392919061360e565b610435611e6e565b61057f611f71565b60405161027e919061365c565b600080600080600560009054906101000a90046001600160a01b03166001600160a01b03166308d7ce026040518163ffffffff1660e01b815260040160806040518083038186803b1580156105e057600080fd5b505afa1580156105f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106189190613434565b935093509350935090919293565b6000546201000090046001600160a01b0316331461067a576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b61068381611ffe565b61068c57610695565b6106958161201b565b50565b6000546201000090046001600160a01b031633146106ec576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b600a544210156107175760405162461bcd60e51b815260040161070e90613821565b60405180910390fd5b600660009054906101000a90046001600160a01b03166001600160a01b031663cc3c6df66040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561076757600080fd5b505af115801561077b573d6000803e3d6000fd5b50505050610790600954600c54601054612114565b60006009819055600c8190556010819055600a55565b600d5481565b6004546001600160a01b031681565b6000546201000090046001600160a01b0316331461080f576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b6001600160a01b03811661083d57600e80546001600160a01b0319166001600160a01b038316179055610695565b6040516370a0823160e01b81526001600160a01b038216906370a08231906108699030906004016134e8565b60206040518083038186803b15801561088157600080fd5b505afa9250505080156108b1575060408051601f3d908101601f191682019092526108ae918101906133f1565b60015b6108cd5760405162461bcd60e51b815260040161070e906137f5565b50600e80546001600160a01b0383166001600160a01b031990911617905550565b60055460405163b3596f0760e01b815260009182916001600160a01b039091169063b3596f07906109239087906004016134e8565b60206040518083038186803b15801561093b57600080fd5b505afa15801561094f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097391906133f1565b905060006109808561102e565b905061099a600a82900a61099484876121d5565b90612237565b95945050505050565b6006546001600160a01b031681565b60086020526000908152604090205481565b6000546201000090046001600160a01b03163314610a18576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b60005b8151811015610a6d57610a40828281518110610a3357fe5b6020026020010151611ffe565b610a4957610a65565b610a65828281518110610a5857fe5b602002602001015161201b565b600101610a1b565b5050565b6000546201000090046001600160a01b031681565b600f5481565b6000546201000090046001600160a01b03163314610ae0576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b6001600160a01b038216610b2d576040805162461bcd60e51b815260206004820152600f60248201526e24b73b30b634b21036b0b730b3b2b960891b604482015290519081900360640190fd5b6000805462010000600160b01b031916620100006001600160a01b038516021790558051610b62906001906020840190612f57565b507f6ed15082ad038474841528b5badca105106d4463e44b5d434130dfb299aa3669828260405180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610bd2578181015183820152602001610bba565b50505050905090810190601f168015610bff5780820380516001836020036101000a031916815260200191505b50935050505060405180910390a15050565b6000546201000090046001600160a01b0316331480610c3a57506004546001600160a01b031633145b80610c4f57506005546001600160a01b031633145b610c6b5760405162461bcd60e51b815260040161070e90613854565b610ca9848484848080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061229b92505050565b610cb16123d6565b50505050565b600e546000906001600160a01b031615801590610d525750600e546040516370a0823160e01b81526000916001600160a01b0316906370a0823190610d009086906004016134e8565b60206040518083038186803b158015610d1857600080fd5b505afa158015610d2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d5091906133f1565b115b90505b919050565b600054610100900460ff1680610d735750610d7361243a565b80610d81575060005460ff16155b610dbc5760405162461bcd60e51b815260040180806020018281038252602e815260200180613aa0602e913960400191505060405180910390fd5b600054610100900460ff16158015610de7576000805460ff1961ff0019909116610100171660011790555b6001600160a01b038a16610e0d5760405162461bcd60e51b815260040161070e90613915565b6001600160a01b038916610e335760405162461bcd60e51b815260040161070e906138ec565b6001600160a01b038616610e595760405162461bcd60e51b815260040161070e9061379c565b610e998989898080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061244b92505050565b600580546001600160a01b03808d166001600160a01b0319928316179092556006805492891692909116919091179055610ed585856000612114565b604080516000815260208101909152610ef1908490849061229b565b8015610f03576000805461ff00191690555b50505050505050505050565b60055460408051636bb9347360e11b815290516000926001600160a01b03169163d77268e6916004808301926020929190829003018186803b158015610f5457600080fd5b505afa158015610f68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8c91906133f1565b905090565b6000546201000090046001600160a01b03163314610fe5576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b60005b8151811015610a6d57611000828281518110610a3357fe5b1561100a57611026565b61102682828151811061101957fe5b60200260200101516124cd565b600101610fe8565b600554604051633f30232f60e21b815260009182916001600160a01b039091169063fcc08cbc906110639086906004016134e8565b60206040518083038186803b15801561107b57600080fd5b505afa15801561108f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b3919061307f565b60405163067aa55560e51b81529091506001600160a01b0382169063cf54aaa0906110e29086906004016134e8565b60206040518083038186803b1580156110fa57600080fd5b505afa15801561110e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113291906133f1565b9392505050565b600a5481565b6000546201000090046001600160a01b03163314611193576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b600480546001600160a01b0319169055565b600954600c54601054600a5490919293565b6000546201000090046001600160a01b0316331461120b576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b600b54831115801561121f5750600d548211155b801561122d57506011548111155b6112495760405162461bcd60e51b815260040161070e906137c7565b611254838383612114565b61125c6123d6565b505050565b600080600560009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156112b257600080fd5b505afa1580156112c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ea919061307f565b9050336001600160a01b038216146113145760405162461bcd60e51b815260040161070e90613705565b306001600160a01b0316836001600160a01b0316631e50a4a66040518163ffffffff1660e01b815260040160206040518083038186803b15801561135757600080fd5b505afa15801561136b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061138f919061307f565b6001600160a01b0316146113b55760405162461bcd60e51b815260040161070e90613770565b600680546001600160a01b0319166001600160a01b0385161790556040517f8c1446ebd2ac8c922b8c9716dfbdfcfef02c9fc167140d7cfd019565b423b2499061140290859033906134fc565b60405180910390a16114126123d6565b50600192915050565b60095481565b60055460405163cc435bf360e01b81526000916001600160a01b03169063cc435bf3906114529085906004016134e8565b60206040518083038186803b15801561146a57600080fd5b505afa15801561147e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d52919061339b565b60115481565b6001600160a01b0316600090815260086020526040902054151590565b6060600280548060200260200160405190810160405280929190818152602001828054801561151d57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116114ff575b5050505050905090565b60025490565b6000546201000090046001600160a01b03163314611581576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b6001600160a01b0381166115cd576040805162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b2103a3930b232b960911b604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6007546000908190815b8181101561163f5761163561162e6007838154811061161457fe5b6000918252602090912001546001600160a01b0316611b2e565b8490612529565b92506001016115f9565b509091505090565b6000546201000090046001600160a01b0316331461169b576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b60008060006116a861058c565b5092509250925060006116b9610f0f565b90508387111580156116cb5750828611155b80156116d75750818511155b80156116ef5750600b546116eb9082612529565b8711155b61170b5760405162461bcd60e51b815260040161070e9061393e565b600554604080516332dbceef60e21b815290516000926001600160a01b03169163cb6f3bbc916004808301926020929190829003018186803b15801561175057600080fd5b505afa158015611764573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178891906133f1565b6009899055600c8890556010879055428101600a8190556040519192507f85ebab1aaaca4ce6e4c14468cff4654ea8d9ec85d5f4a5a68f2ec2e49380c97d916117d5918b918b91906139d7565b60405180910390a16117e56123d6565b5050505050505050565b600b5481565b600061180082611ffe565b80610d525750610d5282610cb7565b6001600160a01b03811660009081526008602052604081205480158015906111325750600761183f826001612581565b8154811061184957fe5b600091825260209091200154600160a01b900460ff169392505050565b60105481565b600e546001600160a01b031681565b6005546001600160a01b031681565b6007818154811061189a57600080fd5b6000918252602090912001546001600160a01b0381169150600160a01b900460ff1682565b6000546201000090046001600160a01b03163314611913576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b61191c81611ffe565b1561192657610695565b610695816124cd565b600554604051633f30232f60e21b815260009182916001600160a01b039091169063fcc08cbc906119649086906004016134e8565b60206040518083038186803b15801561197c57600080fd5b505afa158015611990573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119b4919061307f565b60065460405163d4fac45d60e01b81529192506001600160a01b038084169263d4fac45d926110e292169087906004016134fc565b6000806000806000600560009054906101000a90046001600160a01b03166001600160a01b03166308d7ce026040518163ffffffff1660e01b815260040160806040518083038186803b158015611a3f57600080fd5b505afa158015611a53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a779190613434565b600b54600d54601154919a509850965094505050505090919293565b6000546201000090046001600160a01b03163314611ae7576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b60006009819055600c8190556010819055600a8190556040517fc6f04bf43cbdf1ba5d51b4afa160bb3c7e13858b1409aa32868b239bb2f8d8499190a1611b2c6123d6565b565b6000610d52826102ef8461192f565b60606007805480602002602001604051908101604052809291908181526020016000905b82821015611bac57600084815260209081902060408051808201909152908401546001600160a01b0381168252600160a01b900460ff16151581830152825260019092019101611b61565b50505050905090565b6000546201000090046001600160a01b03163314611c09576040805162461bcd60e51b815260206004820152600c60248201526b37b7363c9036b0b730b3b2b960a11b604482015290519081900360640190fd5b611c12816125de565b6106956123d6565b600c5481565b60075460609081908190806001600160401b0381118015611c4057600080fd5b50604051908082528060200260200182016040528015611c7a57816020015b611c67612fe3565b815260200190600190039081611c5f5790505b509350806001600160401b0381118015611c9357600080fd5b50604051908082528060200260200182016040528015611cbd578160200160208202803683370190505b509250806001600160401b0381118015611cd657600080fd5b50604051908082528060200260200182016040528015611d00578160200160208202803683370190505b50915060005b818160ff161015611e6757600060078260ff1681548110611d2357fe5b6000918252602090912001546001600160a01b03169050611d438161192f565b858360ff1681518110611d5257fe5b60200260200101818152505060078260ff1681548110611d6e57fe5b6000918252602091829020604080518082019091529101546001600160a01b038116825260ff600160a01b9091048116151592820192909252875190918891908516908110611db957fe5b602090810291909101015260055460405163b3596f0760e01b81526001600160a01b039091169063b3596f0790611df49084906004016134e8565b60206040518083038186803b158015611e0c57600080fd5b505afa158015611e20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4491906133f1565b848360ff1681518110611e5357fe5b602090810291909101015250600101611d06565b5050909192565b6007546060906000816001600160401b0381118015611e8c57600080fd5b50604051908082528060200260200182016040528015611eb6578160200160208202803683370190505b5090506000805b838160ff161015611f535760078160ff1681548110611ed857fe5b600091825260209091200154600160a01b900460ff1615611f4b5760078160ff1681548110611f0357fe5b60009182526020909120015483516001600160a01b0390911690849060ff8516908110611f2c57fe5b6001600160a01b03909216602092830291909101909101526001909101905b600101611ebd565b506000611f638460ff8416612581565b835103835250909250505090565b60018054604080516020600284861615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015611ff65780601f10611fcb57610100808354040283529160200191611ff6565b820191906000526020600020905b815481529060010190602001808311611fd957829003601f168201915b505050505081565b6001600160a01b0316600090815260036020526040902054151590565b6002546001600160a01b038216600090815260036020526040812054612042906001612581565b905060006002612053846001612581565b8154811061205d57fe5b600091825260209091200154600280546001600160a01b03909216925082918490811061208657fe5b600091825260209091200180546001600160a01b0319166001600160a01b03929092169190911790556120ba826001612529565b6001600160a01b038083166000908152600360205260408082209390935590861681529081205560028054806120ec57fe5b600082815260209020810160001990810180546001600160a01b031916905501905550505050565b60008060008061212261058c565b935093509350935083871115801561213a5750828611155b80156121465750818511155b6121625760405162461bcd60e51b815260040161070e90613971565b600b879055600d86905560118590556006546000546040517f4ee6e02dcf04678ab842300dd9ea86277d98bd793cee41cecde1e1666ad94755926121c4926001600160a01b039182169262010000909104909116908b908b908b90889061355d565b60405180910390a150505050505050565b6000826121e457506000612231565b828202828482816121f157fe5b041461222e5760405162461bcd60e51b8152600401808060200182810382526021815260200180613ace6021913960400191505060405180910390fd5b90505b92915050565b600080821161228a576040805162461bcd60e51b815260206004820152601a602482015279536166654d6174683a206469766973696f6e206279207a65726f60301b604482015290519081900360640190fd5b81838161229357fe5b049392505050565b60005b81518160ff1610156122d1576122c9828260ff16815181106122bc57fe5b602002602001015161261e565b60010161229e565b5060005b60ff8116831115612305576122fd84848360ff168181106122f257fe5b905060400201612a1f565b6001016122d5565b50600560009054906101000a90046001600160a01b03166001600160a01b031663aa12ae4d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561235457600080fd5b505afa158015612368573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238c91906133f1565b60075411156123ad5760405162461bcd60e51b815260040161070e9061399e565b60016123b7611e6e565b51101561125c5760405162461bcd60e51b815260040161070e906138b8565b600560009054906101000a90046001600160a01b03166001600160a01b0316633f7f5c726040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561242657600080fd5b505af1158015610cb1573d6000803e3d6000fd5b600061244530612f51565b15905090565b6001600160a01b038216612498576040805162461bcd60e51b815260206004820152600f60248201526e24b73b30b634b21036b0b730b3b2b960891b604482015290519081900360640190fd5b6000805462010000600160b01b031916620100006001600160a01b03851602179055805161125c906001906020840190612f57565b600280546001810182557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b039093166001600160a01b0319909316831790555460009182526003602052604090912055565b60008282018381101561222e576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b6000828211156125d8576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600f8190556040517f96a008f96f1c0ab9fa3d9ddd43cdfc614848c4d054d51f43662ed900e9d094c8906126139083906139ce565b60405180910390a150565b612627816114a8565b6126435760405162461bcd60e51b815260040161070e9061388b565b600554604051633f30232f60e21b81526000916001600160a01b03169063fcc08cbc906126749085906004016134e8565b60206040518083038186803b15801561268c57600080fd5b505afa1580156126a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126c4919061307f565b90506001600160a01b03811615612760576126de8261192f565b156126fb5760405162461bcd60e51b815260040161070e90613739565b600654604051631b57eb9560e21b81526001600160a01b0383811692636d5fae549261272f929091169086906004016134fc565b60006040518083038186803b15801561274757600080fd5b505afa15801561275b573d6000803e3d6000fd5b505050505b6001600160a01b038216600090815260086020526040812054612784906001612581565b600754909150815b81612798826001612529565b1015612953576000600782815481106127ad57fe5b6000918252602091829020604080518082019091529101546001600160a01b0381168252600160a01b900460ff16151591810191909152905060076127f3836001612529565b815481106127fd57fe5b906000526020600020016007838154811061281457fe5b600091825260209091208254910180546001600160a01b0319166001600160a01b0390921691909117808255915460ff600160a01b918290041615150260ff60a01b1990921691909117905561286b826001612529565b600860006007858154811061287c57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020558060076128af846001612529565b815481106128b957fe5b600091825260209182902083519101805493909201511515600160a01b0260ff60a01b196001600160a01b039092166001600160a01b0319909416939093171691909117905561290a826002612529565b60086000600761291b866001612529565b8154811061292557fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020555060010161278c565b5060006008816007612966856001612581565b8154811061297057fe5b60009182526020808320909101546001600160a01b0316835282019290925260400190205560078054806129a057fe5b600082815260208120820160001990810180546001600160a81b031916905590910190915560065490546040517f9b4f55639e5e283319baee5bc4e69a5625a8e3a1cc004af968f4fee72502202792612a11926001600160a01b039182169262010000909104909116908890613516565b60405180910390a150505050565b6000612a2e6020830183613063565b90506000612a42604084016020850161337f565b9050612a4d82611421565b612a695760405162461bcd60e51b815260040161070e906136de565b600654612a7e906001600160a01b0316611421565b1580612b075750600554604051635b16ebb760e01b81526001600160a01b0390911690635b16ebb790612ab59085906004016134e8565b60206040518083038186803b158015612acd57600080fd5b505afa158015612ae1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b05919061339b565b155b612b235760405162461bcd60e51b815260040161070e906136af565b612b2c826114a8565b15612b90576001600160a01b038216600090815260086020526040812054612b55906001612581565b90508160078281548110612b6557fe5b60009182526020909120018054911515600160a01b0260ff60a01b1990921691909117905550612ef5565b60078054600181018255600091909152837fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6888201612bce8282613a2b565b50612bdc9050816001612529565b6001600160a01b0380851660009081526008602052604080822093909355600554925163032c49ed60e01b815290929091169063032c49ed90612c239087906004016134e8565b60206040518083038186803b158015612c3b57600080fd5b505afa158015612c4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c7391906133b7565b90505b600082118015612d3b575060055461ffff8216906001600160a01b031663032c49ed6007612ca5866001612581565b81548110612caf57fe5b6000918252602090912001546040516001600160e01b031960e084901b168152612ce5916001600160a01b0316906004016134e8565b60206040518083038186803b158015612cfd57600080fd5b505afa158015612d11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d3591906133b7565b61ffff16105b15612ef257600060078381548110612d4f57fe5b6000918252602091829020604080518082019091529101546001600160a01b0381168252600160a01b900460ff1615159181019190915290506007612d95846001612581565b81548110612d9f57fe5b9060005260206000200160078481548110612db657fe5b600091825260209091208254910180546001600160a01b0319166001600160a01b0390921691909117808255915460ff600160a01b918290041615150260ff60a01b19909216919091179055612e0d836001612529565b6008600060078681548110612e1e57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902055806007612e51856001612581565b81548110612e5b57fe5b6000918252602080832084519201805494909101511515600160a01b0260ff60a01b196001600160a01b039093166001600160a01b031990951694909417919091169290921790915583906008906007612eb6846001612581565b81548110612ec057fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020555060001990910190612c76565b50505b6006546000546040516001600160a01b03928316927fdb9319bd5f91884f639cec9a5e01b183bedb3e6a3ab459b6e72c0b1264e7742b92612f4492620100009091049091169086908690613539565b60405180910390a2505050565b3b151590565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282612f8d5760008555612fd3565b82601f10612fa657805160ff1916838001178555612fd3565b82800160010185558215612fd3579182015b82811115612fd3578251825591602001919060010190612fb8565b50612fdf929150612ffa565b5090565b604080518082019091526000808252602082015290565b5b80821115612fdf5760008155600101612ffb565b8035610d5581613a7c565b60008083601f84011261302b578182fd5b5081356001600160401b03811115613041578182fd5b60208301915083602060408302850101111561305c57600080fd5b9250929050565b600060208284031215613074578081fd5b813561222e81613a7c565b600060208284031215613090578081fd5b815161222e81613a7c565b600080600080600080600080600060e08a8c0312156130b8578485fd5b89356130c381613a7c565b985060208a01356130d381613a7c565b975060408a01356001600160401b03808211156130ee578687fd5b818c0191508c601f830112613101578687fd5b81358181111561310f578788fd5b8d6020828501011115613120578788fd5b602083019950975061313460608d0161300f565b965060808c0135955060a08c0135945060c08c0135915080821115613157578384fd5b506131648c828d0161301a565b915080935050809150509295985092959850929598565b6000806040838503121561318d578182fd5b823561319881613a7c565b91506020838101356001600160401b03808211156131b4578384fd5b818601915086601f8301126131c7578384fd5b8135818111156131d357fe5b6131e5601f8201601f19168501613a08565b915080825287848285010111156131fa578485fd5b8084840185840137810190920192909252919491935090915050565b60008060408385031215613228578182fd5b823561323381613a7c565b946020939093013593505050565b60006020808385031215613253578182fd5b82356001600160401b0380821115613269578384fd5b818501915085601f83011261327c578384fd5b81358181111561328857fe5b8381029150613298848301613a08565b8181528481019084860184860187018a10156132b2578788fd5b8795505b838610156132e057803594506132cb85613a7c565b848352600195909501949186019186016132b6565b5098975050505050505050565b60008060008060408587031215613302578384fd5b84356001600160401b0380821115613318578586fd5b6133248883890161301a565b9096509450602087013591508082111561333c578384fd5b818701915087601f83011261334f578384fd5b81358181111561335d578485fd5b8860208083028501011115613370578485fd5b95989497505060200194505050565b600060208284031215613390578081fd5b813561222e81613a91565b6000602082840312156133ac578081fd5b815161222e81613a91565b6000602082840312156133c8578081fd5b815161ffff8116811461222e578182fd5b6000602082840312156133ea578081fd5b5035919050565b600060208284031215613402578081fd5b5051919050565b60008060006060848603121561341d578081fd5b505081359360208301359350604090920135919050565b60008060008060808587031215613449578182fd5b505082516020840151604085015160609095015191969095509092509050565b6000815180845260208085019450808401835b838110156134ae57815180516001600160a01b031688528301511515838801526040909601959082019060010161347c565b509495945050505050565b6000815180845260208085019450808401835b838110156134ae578151875295820195908201906001016134cc565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b0393841681529183166020830152909116604082015260600190565b6001600160a01b039384168152919092166020820152901515604082015260600190565b6001600160a01b03968716815294909516602085015260408401929092526060830152608082015260a081019190915260c00190565b6001600160a01b039290921682521515602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156135ef5783516001600160a01b0316835292840192918401916001016135ca565b50909695505050505050565b6000602082526111326020830184613469565b6000606082526136216060830186613469565b828103602084015261363381866134b9565b9050828103604084015261364781856134b9565b9695505050505050565b901515815260200190565b6000602080835283518082850152825b818110156136885785810183015185820160400152820161366c565b818111156136995783604083870101525b50601f01601f1916929092016040019392505050565b60208082526015908201527418d85b9b9bdd08185919081c1bdbdb08185cdcd95d605a1b604082015260600190565b6020808252600d908201526c1a5b9d985b1a5908185cdcd95d609a1b604082015260600190565b6020808252601a90820152791bdb9b1e481bdddb995c881859191c995cdcc8185b1b1bddd95960321b604082015260600190565b6020808252601d908201527f63616e6e6f742072656d6f7665206e6f6e2d656d707479206173736574000000604082015260600190565b602080825260129082015271696e76616c696420706f6f6c206c6f67696360701b604082015260600190565b602080825260119082015270496e76616c696420706f6f6c4c6f67696360781b604082015260600190565b6020808252601490820152730dac2dcc2cecae440cccaca40e8dede40d0d2ced60631b604082015260600190565b60208082526012908201527124b73b30b634b21031b7b63632b1ba34b7b760711b604082015260600190565b60208082526019908201527866656520696e6372656173652064656c61792061637469766560381b604082015260600190565b6020808252601f908201527f6f6e6c79206d616e616765722c20747261646572206f7220666163746f727900604082015260600190565b602080825260139082015272185cdcd95d081b9bdd081cdd5c1c1bdc9d1959606a1b604082015260600190565b6020808252601a9082015279185d081b19585cdd081bdb994819195c1bdcda5d08185cdcd95d60321b604082015260600190565b6020808252600f908201526e24b73b30b634b21036b0b730b3b2b960891b604082015260600190565b6020808252600f908201526e496e76616c696420666163746f727960881b604082015260600190565b602080825260199082015278657863656564656420616c6c6f77656420696e63726561736560381b604082015260600190565b602080825260139082015272696e76616c6964206d616e616765722066656560681b604082015260600190565b6020808252601690820152751b585e1a5b5d5b48185cdcd95d1cc81c995858da195960521b604082015260600190565b90815260200190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b6040518181016001600160401b0381118282101715613a2357fe5b604052919050565b8135613a3681613a7c565b81546001600160a01b0319166001600160a01b0391909116178082556020830135613a6081613a91565b60ff60a01b199190911690151560a01b60ff60a01b1617905550565b6001600160a01b038116811461069557600080fd5b801515811461069557600080fdfe496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220a41116b962b2598edd27d1f17987a78514501a6223b47feb948fb49094b3643e64736f6c63430007060033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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