Token Camelot staking position NFT

 

Overview ERC-721

Total Supply:
183 spNFT

Holders:
80 addresses

Transfers:
-

Contract:
0x978e469e8242cd18af5926a1b60b8d93a550a3910x978E469E8242cd18af5926A1b60B8D93A550a391

Social Profiles:
Not Available, Update ?

Loading
[ Download CSV Export  ] 
Loading
[ Download CSV Export  ] 
Loading

Click here to update the token ICO / general information
# Exchange Pair Price  24H Volume % Volume

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x6BC938abA940fB828D39Daa23A94dfc522120C11
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
NFTPool

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 1500 runs

Other Settings:
default evmVersion
File 1 of 23 : NFTPool.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;

import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/EnumerableSet.sol";

import "./interfaces/INFTHandler.sol";
import "./interfaces/ICamelotMaster.sol";
import "./interfaces/INFTPool.sol";
import "./interfaces/IYieldBooster.sol";
import "./interfaces/tokens/IXGrailToken.sol";


/*
 * This contract wraps ERC20 assets into non-fungible staking positions called spNFTs
 * spNFTs add the possibility to create an additional layer on liquidity providing lock features
 * spNFTs are yield-generating positions when the NFTPool contract has allocations from the Camelot Master
 */
contract NFTPool is ReentrancyGuard, INFTPool, ERC721("Camelot staking position NFT", "spNFT") {
  using Address for address;
  using Counters for Counters.Counter;
  using EnumerableSet for EnumerableSet.AddressSet;
  using SafeMath for uint256;
  using SafeERC20 for IERC20;


  // Info of each NFT (staked position).
  struct StakingPosition {
    uint256 amount; // How many lp tokens the user has provided
    uint256 amountWithMultiplier; // Amount + lock bonus faked amount (amount + amount*multiplier)
    uint256 startLockTime; // The time at which the user made his deposit
    uint256 lockDuration; // The lock duration in seconds
    uint256 lockMultiplier; // Active lock multiplier (times 1e2)
    uint256 rewardDebt; // Reward debt
    uint256 boostPoints; // Allocated xGRAIL from yieldboost contract (optional)
    uint256 totalMultiplier; // lockMultiplier + allocated xGRAIL boostPoints multiplier
    uint256 pendingXGrailRewards; // Not harvested xGrail rewards
    uint256 pendingGrailRewards; // Not harvested Grail rewards
  }

  Counters.Counter private _tokenIds;

  EnumerableSet.AddressSet private _unlockOperators; // Addresses allowed to forcibly unlock locked spNFTs
  address public operator; // Used to delegate multiplier settings to project's owners
  ICamelotMaster public master; // Address of the master
  address public immutable factory; // NFTPoolFactory contract's address
  bool public initialized;

  IERC20 private _lpToken; // Deposit token contract's address
  IERC20 private _grailToken; // GrailToken contract's address
  IXGrailToken private _xGrailToken; // XGrailToken contract's address
  uint256 private _lpSupply; // Sum of deposit tokens on this pool
  uint256 private _lpSupplyWithMultiplier; // Sum of deposit token on this pool including the user's total multiplier (lockMultiplier + boostPoints)
  uint256 private _accRewardsPerShare; // Accumulated Rewards (staked token) per share, times 1e18. See below

  // readable via getMultiplierSettings
  uint256 public constant MAX_GLOBAL_MULTIPLIER_LIMIT = 25000; // 250%, high limit for maxGlobalMultiplier (100 = 1%)
  uint256 public constant MAX_LOCK_MULTIPLIER_LIMIT = 15000; // 150%, high limit for maxLockMultiplier (100 = 1%)
  uint256 public constant MAX_BOOST_MULTIPLIER_LIMIT = 15000; // 150%, high limit for maxBoostMultiplier (100 = 1%)
  uint256 private _maxGlobalMultiplier = 20000; // 200%
  uint256 private _maxLockDuration = 183 days; // 6 months, Capped lock duration to have the maximum bonus lockMultiplier
  uint256 private _maxLockMultiplier = 10000; // 100%, Max available lockMultiplier (100 = 1%)
  uint256 private _maxBoostMultiplier = 10000; // 100%, Max boost that can be earned from xGrail yieldBooster

  uint256 private constant _TOTAL_REWARDS_SHARES = 10000; // 100%, high limit for xGrailRewardsShare
  uint256 public xGrailRewardsShare = 8000; // 80%, directly defines grailShare with the remaining value to 100%

  bool public emergencyUnlock; // Release all locks in case of emergency

  // readable via getStakingPosition
  mapping(uint256 => StakingPosition) internal _stakingPositions; // Info of each NFT position that stakes LP tokens

  constructor() {
    factory = msg.sender;
  }

  function initialize(ICamelotMaster master_, IERC20 grailToken, IXGrailToken xGrailToken, IERC20 lpToken) external {
    require(msg.sender == factory && !initialized, "FORBIDDEN");
    _lpToken = lpToken;
    master = master_;
    _grailToken = grailToken;
    _xGrailToken = xGrailToken;
    initialized = true;

    // to convert GRAIL to xGRAIL
   _grailToken.approve(address(_xGrailToken), type(uint256).max);
  }


  /********************************************/
  /****************** EVENTS ******************/
  /********************************************/

  event AddToPosition(uint256 indexed tokenId, address user, uint256 amount);
  event CreatePosition(uint256 indexed tokenId, uint256 amount, uint256 lockDuration);
  event WithdrawFromPosition(uint256 indexed tokenId, uint256 amount);
  event EmergencyWithdraw(uint256 indexed tokenId, uint256 amount);
  event LockPosition(uint256 indexed tokenId, uint256 lockDuration);
  event SplitPosition(uint256 indexed tokenId, uint256 splitAmount, uint256 newTokenId);
  event MergePositions(address indexed user, uint256[] tokenIds);
  event HarvestPosition(uint256 indexed tokenId, address to, uint256 pending);
  event SetBoost(uint256 indexed tokenId, uint256 boostPoints);

  event PoolUpdated(uint256 lastRewardTime, uint256 accRewardsPerShare);

  event SetLockMultiplierSettings(uint256 maxLockDuration, uint256 maxLockMultiplier);
  event SetBoostMultiplierSettings(uint256 maxGlobalMultiplier, uint256 maxBoostMultiplier);
  event SetXGrailRewardsShare(uint256 xGrailRewardsShare);
  event SetUnlockOperator(address operator, bool isAdded);
  event SetEmergencyUnlock(bool emergencyUnlock);
  event SetOperator(address operator);


  /***********************************************/
  /****************** MODIFIERS ******************/
  /***********************************************/

  /**
   * @dev Check if caller has operator rights
   */
  function _requireOnlyOwner() internal view {
    require(msg.sender == owner(), "FORBIDDEN");
    // onlyOwner: caller is not the owner
  }

  /**
   * @dev Check if caller is a validated YieldBooster contract
   */
  function _requireOnlyYieldBooster() internal view {
    // onlyYieldBooster: caller has no yield boost rights
    require(msg.sender == yieldBooster(), "FORBIDDEN");
  }


  /**
   * @dev Check if a userAddress has privileged rights on a spNFT
   */
  function _requireOnlyOperatorOrOwnerOf(uint256 tokenId) internal view {
    // isApprovedOrOwner: caller has no rights on token
    require(ERC721._isApprovedOrOwner(msg.sender, tokenId), "FORBIDDEN");
  }


  /**
   * @dev Check if a userAddress has privileged rights on a spNFT
   */
  function _requireOnlyApprovedOrOwnerOf(uint256 tokenId) internal view {
    require(_exists(tokenId), "ERC721: operator query for nonexistent token");
    require(_isOwnerOf(msg.sender, tokenId) || getApproved(tokenId) == msg.sender, "FORBIDDEN");
  }

  /**
   * @dev Check if a msg.sender is owner of a spNFT
   */
  function _requireOnlyOwnerOf(uint256 tokenId) internal view {
    require(_exists(tokenId), "ERC721: operator query for nonexistent token");
    // onlyOwnerOf: caller has no rights on token
    require(_isOwnerOf(msg.sender, tokenId), "not owner");
  }


  /**************************************************/
  /****************** PUBLIC VIEWS ******************/
  /**************************************************/

  /**
   * @dev Returns this contract's owner (= master contract's owner)
   */
  function owner() public view returns (address) {
    return master.owner();
  }

  /**
   * @dev Returns the number of unlockOperators
   */
  function unlockOperatorsLength() external view returns (uint256) {
    return _unlockOperators.length();
  }

  /**
   * @dev Returns an unlockOperator from its "index"
   */
  function unlockOperator(uint256 index) external view returns (address) {
    if (_unlockOperators.length() <= index) return address(0);
    return _unlockOperators.at(index);
  }

  /**
   * @dev Returns true if "_operator" address is an unlockOperator
   */
  function isUnlockOperator(address _operator) external view returns (bool) {
    return _unlockOperators.contains(_operator);
  }

  /**
   * @dev Get master-defined yield booster contract address
   */
  function yieldBooster() public view returns (address) {
    return master.yieldBooster();
  }

  /**
   * @dev Returns true if "tokenId" is an existing spNFT id
   */
  function exists(uint256 tokenId) external view override returns (bool) {
    return ERC721._exists(tokenId);
  }

  /**
   * @dev Returns last minted NFT id
   */
  function lastTokenId() external view returns (uint256) {
    return _tokenIds.current();
  }

  /**
   * @dev Returns true if emergency unlocks are activated on this pool or on the master
   */
  function isUnlocked() public view returns (bool) {
    return emergencyUnlock || master.emergencyUnlock();
  }

  /**
   * @dev Returns true if this pool currently has deposits
   */
  function hasDeposits() external view override returns (bool) {
    return _lpSupplyWithMultiplier > 0;
  }

  /**
   * @dev Returns general "pool" info for this contract
   */
  function getPoolInfo() external view override returns (
    address lpToken, address grailToken, address xGrailToken, uint256 lastRewardTime, uint256 accRewardsPerShare,
    uint256 lpSupply, uint256 lpSupplyWithMultiplier, uint256 allocPoint
  ) {
    (, allocPoint, lastRewardTime,,) = master.getPoolInfo(address(this));
    return (
    address(_lpToken), address(_grailToken), address(_xGrailToken), lastRewardTime, _accRewardsPerShare,
    _lpSupply, _lpSupplyWithMultiplier, allocPoint
    );
  }

  /**
   * @dev Returns all multiplier settings for this contract
   */
  function getMultiplierSettings() external view returns (uint256 maxGlobalMultiplier, uint256 maxLockDuration, uint256 maxLockMultiplier, uint256 maxBoostMultiplier) {
    return (_maxGlobalMultiplier, _maxLockDuration, _maxLockMultiplier, _maxBoostMultiplier);
  }

  /**
   * @dev Returns bonus multiplier from YieldBooster contract for given "amount" (LP token staked) and "boostPoints" (result is *1e4)
   */
  function getMultiplierByBoostPoints(uint256 amount, uint256 boostPoints) public view returns (uint256) {
    if(boostPoints == 0 || amount == 0) return 0;

    address yieldBoosterAddress = yieldBooster();
    // only call yieldBooster contract if defined on master
    return yieldBoosterAddress != address(0) ? IYieldBooster(yieldBoosterAddress).getMultiplier(address(this), _maxBoostMultiplier, amount, _lpSupply, boostPoints) : 0;
  }

  /**
   * @dev Returns expected multiplier for a "lockDuration" duration lock (result is *1e4)
   */
  function getMultiplierByLockDuration(uint256 lockDuration) public view returns (uint256) {
    // in case of emergency unlock
    if (isUnlocked()) return 0;

    if (_maxLockDuration == 0 || lockDuration == 0) return 0;

    // capped to maxLockDuration
    if (lockDuration >= _maxLockDuration) return _maxLockMultiplier;

    return _maxLockMultiplier.mul(lockDuration).div(_maxLockDuration);
  }

  /**
   * @dev Returns a position info
   */
  function getStakingPosition(uint256 tokenId) external view override returns (
    uint256 amount, uint256 amountWithMultiplier, uint256 startLockTime,
    uint256 lockDuration, uint256 lockMultiplier, uint256 rewardDebt,
    uint256 boostPoints, uint256 totalMultiplier
  ) {
    StakingPosition storage position = _stakingPositions[tokenId];
    return (
    position.amount, position.amountWithMultiplier, position.startLockTime,
    position.lockDuration, position.lockMultiplier, position.rewardDebt,
    position.boostPoints, position.totalMultiplier
    );
  }

  /**
   * @dev Returns pending rewards for a position
   */
  function pendingRewards(uint256 tokenId) external view returns (uint256) {
    StakingPosition storage position = _stakingPositions[tokenId];

    uint256 accRewardsPerShare = _accRewardsPerShare;
    (,,uint256 lastRewardTime, uint256 reserve, uint256 poolEmissionRate) = master.getPoolInfo(address(this));

    // recompute accRewardsPerShare if not up to date
    if ((reserve > 0 || _currentBlockTimestamp() > lastRewardTime) && _lpSupplyWithMultiplier > 0) {
      uint256 duration = _currentBlockTimestamp().sub(lastRewardTime);
      // adding reserve here in case master has been synced but not the pool
      uint256 tokenRewards = duration.mul(poolEmissionRate).add(reserve);
      accRewardsPerShare = accRewardsPerShare.add(tokenRewards.mul(1e18).div(_lpSupplyWithMultiplier));
    }

    return position.amountWithMultiplier.mul(accRewardsPerShare).div(1e18).sub(position.rewardDebt)
      .add(position.pendingXGrailRewards).add(position.pendingGrailRewards);
  }


  /*******************************************************/
  /****************** OWNABLE FUNCTIONS ******************/
  /*******************************************************/

  /**
   * @dev Set lock multiplier settings
   *
   * maxLockMultiplier must be <= MAX_LOCK_MULTIPLIER_LIMIT
   * maxLockMultiplier must be <= _maxGlobalMultiplier - _maxBoostMultiplier
   *
   * Must only be called by the owner
   */
  function setLockMultiplierSettings(uint256 maxLockDuration, uint256 maxLockMultiplier) external {
    require(msg.sender == owner() || msg.sender == operator, "FORBIDDEN");
    // onlyOperatorOrOwner: caller has no operator rights
    require(maxLockMultiplier <= MAX_LOCK_MULTIPLIER_LIMIT && maxLockMultiplier.add(_maxBoostMultiplier) <= _maxGlobalMultiplier, "too high");
    // setLockSettings: maxGlobalMultiplier is too high
    _maxLockDuration = maxLockDuration;
    _maxLockMultiplier = maxLockMultiplier;

    emit SetLockMultiplierSettings(maxLockDuration, maxLockMultiplier);
  }

  /**
   * @dev Set global and boost multiplier settings
   *
   * maxGlobalMultiplier must be <= MAX_GLOBAL_MULTIPLIER_LIMIT
   * maxBoostMultiplier must be <= MAX_BOOST_MULTIPLIER_LIMIT
   * (maxBoostMultiplier + _maxLockMultiplier) must be <= _maxGlobalMultiplier
   *
   * Must only be called by the owner
   */
  function setBoostMultiplierSettings(uint256 maxGlobalMultiplier, uint256 maxBoostMultiplier) external {
    _requireOnlyOwner();
    require(maxGlobalMultiplier <= MAX_GLOBAL_MULTIPLIER_LIMIT, "too high");

    // setMultiplierSettings: maxGlobalMultiplier is too high
    require(maxBoostMultiplier <= MAX_BOOST_MULTIPLIER_LIMIT && maxBoostMultiplier.add(_maxLockMultiplier) <= maxGlobalMultiplier, "too high");
    // setLockSettings: maxGlobalMultiplier is too high
    _maxGlobalMultiplier = maxGlobalMultiplier;
    _maxBoostMultiplier = maxBoostMultiplier;

    emit SetBoostMultiplierSettings(maxGlobalMultiplier, maxBoostMultiplier);
  }

  /**
   * @dev Set the share of xGRAIL for the distributed rewards
   * The share of GRAIL will incidently be 100% - xGrailRewardsShare
   *
   * Must only be called by the owner
   */
  function setXGrailRewardsShare(uint256 xGrailRewardsShare_) external {
    _requireOnlyOwner();
    require(xGrailRewardsShare_ <= _TOTAL_REWARDS_SHARES, "too high");

    xGrailRewardsShare = xGrailRewardsShare_;
    emit SetXGrailRewardsShare(xGrailRewardsShare_);
  }

  /**
   * @dev Add or remove unlock operators
   *
   * Must only be called by the owner
   */
  function setUnlockOperator(address _operator, bool add) external {
    _requireOnlyOwner();

    if (add) {
      _unlockOperators.add(_operator);
    }
    else {
      _unlockOperators.remove(_operator);
    }
    emit SetUnlockOperator(_operator, add);
  }

  /**
   * @dev Set emergency unlock status
   *
   * Must only be called by the owner
   */
  function setEmergencyUnlock(bool emergencyUnlock_) external {
    _requireOnlyOwner();

    emergencyUnlock = emergencyUnlock_;
    emit SetEmergencyUnlock(emergencyUnlock);
  }

  /**
   * @dev Set operator (usually deposit token's project's owner) to adjust contract's settings
   *
   * Must only be called by the owner
   */
  function setOperator(address operator_) external {
    _requireOnlyOwner();

    operator = operator_;
    emit SetOperator(operator_);
  }


  /****************************************************************/
  /****************** EXTERNAL PUBLIC FUNCTIONS  ******************/
  /****************************************************************/

  /**
   * @dev Add nonReentrant to ERC721.transferFrom
   */
  function transferFrom(address from, address to, uint256 tokenId) public override(ERC721, IERC721) nonReentrant {
    ERC721.transferFrom(from, to, tokenId);
  }

  /**
   * @dev Add nonReentrant to ERC721.safeTransferFrom
   */
  function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public override(ERC721, IERC721) nonReentrant {
    ERC721.safeTransferFrom(from, to, tokenId, _data);
  }

  /**
   * @dev Updates rewards states of the given pool to be up-to-date
   */
  function updatePool() external nonReentrant {
    _updatePool();
  }

  /**
   * @dev Create a staking position (spNFT) with an optional lockDuration
   */
  function createPosition(uint256 amount, uint256 lockDuration) external nonReentrant {
    // no new lock can be set if the pool has been unlocked
    if (isUnlocked()) {
      require(lockDuration == 0, "locks disabled");
    }

    _updatePool();

    // handle tokens with transfer tax
    amount = _transferSupportingFeeOnTransfer(_lpToken, msg.sender, amount);
    require(amount != 0, "zero amount"); // createPosition: amount cannot be null

    // mint NFT position token
    uint256 currentTokenId = _mintNextTokenId(msg.sender);

    // calculate bonuses
    uint256 lockMultiplier = getMultiplierByLockDuration(lockDuration);
    uint256 amountWithMultiplier = amount.mul(lockMultiplier.add(1e4)).div(1e4);

    // create position
    _stakingPositions[currentTokenId] = StakingPosition({
      amount : amount,
      rewardDebt : amountWithMultiplier.mul(_accRewardsPerShare).div(1e18),
      lockDuration : lockDuration,
      startLockTime : _currentBlockTimestamp(),
      lockMultiplier : lockMultiplier,
      amountWithMultiplier : amountWithMultiplier,
      boostPoints : 0,
      totalMultiplier : lockMultiplier,
      pendingGrailRewards: 0,
      pendingXGrailRewards: 0
    });

    // update total lp supply
    _lpSupply = _lpSupply.add(amount);
    _lpSupplyWithMultiplier = _lpSupplyWithMultiplier.add(amountWithMultiplier);

    emit CreatePosition(currentTokenId, amount, lockDuration);
  }

  /**
   * @dev Add to an existing staking position
   *
   * Can only be called by spNFT's owner or operators
   */
  function addToPosition(uint256 tokenId, uint256 amountToAdd) external nonReentrant {
    _requireOnlyOperatorOrOwnerOf(tokenId);
    require(amountToAdd > 0, "0 amount"); // addToPosition: amount cannot be null

    _updatePool();
    address nftOwner = ERC721.ownerOf(tokenId);
    _harvestPosition(tokenId, nftOwner);

    StakingPosition storage position = _stakingPositions[tokenId];

    // if position is locked, renew the lock
    if (position.lockDuration > 0) {
      position.startLockTime = _currentBlockTimestamp();
      position.lockMultiplier = getMultiplierByLockDuration(position.lockDuration);
    }

    // handle tokens with transfer tax
    amountToAdd = _transferSupportingFeeOnTransfer(_lpToken, msg.sender, amountToAdd);

    // update position
    position.amount = position.amount.add(amountToAdd);
    _lpSupply = _lpSupply.add(amountToAdd);
    _updateBoostMultiplierInfoAndRewardDebt(position);

    _checkOnAddToPosition(nftOwner, tokenId, amountToAdd);
    emit AddToPosition(tokenId, msg.sender, amountToAdd);
  }

  /**
   * @dev Assign "amount" of boost points to a position
   *
   * Can only be called by the master-defined YieldBooster contract
   */
  function boost(uint256 tokenId, uint256 amount) external override nonReentrant {
    _requireOnlyYieldBooster();
    require(ERC721._exists(tokenId), "invalid tokenId");
    
    _updatePool();
    _harvestPosition(tokenId, address(0));

    StakingPosition storage position = _stakingPositions[tokenId];

    // update position
    uint256 boostPoints = position.boostPoints.add(amount);
    position.boostPoints = boostPoints;
    _updateBoostMultiplierInfoAndRewardDebt(position);
    emit SetBoost(tokenId, boostPoints);
  }

  /**
   * @dev Remove "amount" of boost points from a position
   *
   * Can only be called by the master-defined YieldBooster contract
   */
  function unboost(uint256 tokenId, uint256 amount) external override nonReentrant {
    _requireOnlyYieldBooster();
    
    _updatePool();
    _harvestPosition(tokenId, address(0));

    StakingPosition storage position = _stakingPositions[tokenId];

    // update position
    uint256 boostPoints = position.boostPoints.sub(amount);
    position.boostPoints = boostPoints;
    _updateBoostMultiplierInfoAndRewardDebt(position);
    emit SetBoost(tokenId, boostPoints);
  }

  /**
   * @dev Harvest from a staking position
   *
   * Can only be called by spNFT's owner or approved address
   */
  function harvestPosition(uint256 tokenId) external nonReentrant {
    _requireOnlyApprovedOrOwnerOf(tokenId);
    
    _updatePool();
    _harvestPosition(tokenId, ERC721.ownerOf(tokenId));
    _updateBoostMultiplierInfoAndRewardDebt(_stakingPositions[tokenId]);
  }

  /**
   * @dev Harvest from a staking position to "to" address
   *
   * Can only be called by spNFT's owner or approved address
   * spNFT's owner must be a contract
   */
  function harvestPositionTo(uint256 tokenId, address to) external nonReentrant {
    _requireOnlyApprovedOrOwnerOf(tokenId);
    require(ERC721.ownerOf(tokenId).isContract(), "FORBIDDEN");
    
    _updatePool();
    _harvestPosition(tokenId, to);
    _updateBoostMultiplierInfoAndRewardDebt(_stakingPositions[tokenId]);
  }

  /**
   * @dev Harvest from multiple staking positions to "to" address
   *
   * Can only be called by spNFT's owner or approved address
   */
  function harvestPositionsTo(uint256[] calldata tokenIds, address to) external nonReentrant {
    _updatePool();

    uint256 length = tokenIds.length;

    for (uint256 i = 0; i < length; ++i) {
      uint256 tokenId = tokenIds[i];
      _requireOnlyApprovedOrOwnerOf(tokenId);
      address tokenOwner = ERC721.ownerOf(tokenId);
      // if sender is the current owner, must also be the harvest dst address
      // if sender is approved, current owner must be a contract
      require((msg.sender == tokenOwner && msg.sender == to) || tokenOwner.isContract(), "FORBIDDEN");

      _harvestPosition(tokenId, to);
      _updateBoostMultiplierInfoAndRewardDebt(_stakingPositions[tokenId]);
    }
  }

  /**
   * @dev Withdraw from a staking position
   *
   * Can only be called by spNFT's owner or approved address
   */
  function withdrawFromPosition(uint256 tokenId, uint256 amountToWithdraw) external nonReentrant {
    _requireOnlyApprovedOrOwnerOf(tokenId);
    
    _updatePool();
    address nftOwner = ERC721.ownerOf(tokenId);
    _withdrawFromPosition(nftOwner, tokenId, amountToWithdraw);
    _checkOnWithdraw(nftOwner, tokenId, amountToWithdraw);
  }

  /**
   * @dev Renew lock from a staking position
   *
   * Can only be called by spNFT's owner or approved address
   */
  function renewLockPosition(uint256 tokenId) external nonReentrant {
    _requireOnlyApprovedOrOwnerOf(tokenId);
    
    _updatePool();
    _lockPosition(tokenId, _stakingPositions[tokenId].lockDuration);
  }

  /**
   * @dev Lock a staking position (can be used to extend a lock)
   *
   * Can only be called by spNFT's owner or approved address
   */
  function lockPosition(uint256 tokenId, uint256 lockDuration) external nonReentrant {
    _requireOnlyApprovedOrOwnerOf(tokenId);
    
    _updatePool();
    _lockPosition(tokenId, lockDuration);
  }

  /**
   * @dev Split a staking position into two
   *
   * Can only be called by nft's owner
   */
  function splitPosition(uint256 tokenId, uint256 splitAmount) external nonReentrant {
    _requireOnlyOwnerOf(tokenId);

    _updatePool();
    _harvestPosition(tokenId, ERC721.ownerOf(tokenId));

    StakingPosition storage position = _stakingPositions[tokenId];
    // can't have the original token completely emptied
    require(splitAmount < position.amount, "invalid splitAmount");

    // sub from existing position
    position.amount = position.amount.sub(splitAmount);
    _updateBoostMultiplierInfoAndRewardDebt(position);

    // create new position
    uint256 currentTokenId = _mintNextTokenId(msg.sender);
    uint256 lockDuration = position.lockDuration;
    uint256 lockMultiplier = position.lockMultiplier;
    uint256 amountWithMultiplier = splitAmount.mul(lockMultiplier.add(1e4)).div(1e4);
    _stakingPositions[currentTokenId] = StakingPosition({
      amount : splitAmount,
      rewardDebt : amountWithMultiplier.mul(_accRewardsPerShare).div(1e18),
      lockDuration : lockDuration,
      startLockTime : position.startLockTime,
      lockMultiplier : lockMultiplier,
      amountWithMultiplier : amountWithMultiplier,
      boostPoints : 0,
      totalMultiplier : lockMultiplier,
      pendingGrailRewards: 0,
      pendingXGrailRewards: 0
    });

    _lpSupplyWithMultiplier = _lpSupplyWithMultiplier.add(amountWithMultiplier);

    emit SplitPosition(tokenId, splitAmount, currentTokenId);
  }

  /**
   * @dev Merge an array of staking positions into a single one with "lockDuration"
   * Can't be used on positions with a higher lock duration than "lockDuration" param
   *
   * Can only be called by spNFT's owner
   */
  function mergePositions(uint256[] calldata tokenIds, uint256 lockDuration) external nonReentrant {
    _updatePool();

    uint256 length = tokenIds.length;
    require(length > 1, "invalid");
    // mergePositions: array must have at least two items

    // set the destination position into which the others will be merged (using first item of the list)
    uint256 dstTokenId = tokenIds[0];
    _requireOnlyOwnerOf(dstTokenId);

    StakingPosition storage dstPosition = _stakingPositions[dstTokenId];
    require(dstPosition.lockDuration <= lockDuration, "can't merge");
    _harvestPosition(dstTokenId, msg.sender);

    dstPosition.lockDuration = lockDuration;
    dstPosition.lockMultiplier = getMultiplierByLockDuration(lockDuration);

    // loop starts at 2nd element
    for (uint256 i = 1; i < length; ++i) {
      uint256 tokenId = tokenIds[i];
      _requireOnlyOwnerOf(tokenId);
      require(tokenId != dstTokenId, "invalid token id");

      _harvestPosition(tokenId, msg.sender);
      StakingPosition storage position = _stakingPositions[tokenId];

      // positions must have a lower lock duration than param
      require(position.lockDuration <= lockDuration, "can't merge");
      // mergePositions: positions cannot be merged

      // we want to use the latest startLockTime
      if (dstPosition.startLockTime < position.startLockTime) {
        dstPosition.startLockTime = position.startLockTime;
      }

      // aggregate amounts to the destination position
      dstPosition.amount = dstPosition.amount.add(position.amount);

      // destroy position
      _lpSupplyWithMultiplier = _lpSupplyWithMultiplier.sub(position.amountWithMultiplier);
      _destroyPosition(tokenId, position.boostPoints);
    }

    _updateBoostMultiplierInfoAndRewardDebt(dstPosition);
    emit MergePositions(msg.sender, tokenIds);
  }

  /**
   * Withdraw without caring about rewards, EMERGENCY ONLY
   *
   * Can only be called by spNFT's owner
   */
  function emergencyWithdraw(uint256 tokenId) external nonReentrant {
    _requireOnlyOwnerOf(tokenId);

    StakingPosition storage position = _stakingPositions[tokenId];

    // position should be unlocked
    require(
      _unlockOperators.contains(msg.sender) || position.startLockTime.add(position.lockDuration) <= _currentBlockTimestamp() || isUnlocked(), "locked");
    // emergencyWithdraw: locked

    uint256 amount = position.amount;

    // update total lp supply
    _lpSupply = _lpSupply.sub(amount);
    _lpSupplyWithMultiplier = _lpSupplyWithMultiplier.sub(position.amountWithMultiplier);

    // destroy position (ignore boost points)
    _destroyPosition(tokenId, 0);

    emit EmergencyWithdraw(tokenId, amount);
    _lpToken.safeTransfer(msg.sender, amount);
  }

  /********************************************************/
  /****************** INTERNAL FUNCTIONS ******************/
  /********************************************************/

  /**
   * @dev Returns whether "userAddress" is the owner of "tokenId" spNFT
   */
  function _isOwnerOf(address userAddress, uint256 tokenId) internal view returns (bool){
    return userAddress == ERC721.ownerOf(tokenId);
  }

  /**
   * @dev Updates rewards states of this pool to be up-to-date
   */
  function _updatePool() internal {
    // gets allocated rewards from Master and updates
    (uint256 rewards) = master.claimRewards();

    if (rewards > 0) {
      _accRewardsPerShare = _accRewardsPerShare.add(rewards.mul(1e18).div(_lpSupplyWithMultiplier));
    }

    emit PoolUpdated(_currentBlockTimestamp(), _accRewardsPerShare);
  }

  /**
   * @dev Destroys spNFT
   *
   * "boostPointsToDeallocate" is set to 0 to ignore boost points handling if called during an emergencyWithdraw
   * Users should still be able to deallocate xGRAIL from the YieldBooster contract
   */
  function _destroyPosition(uint256 tokenId, uint256 boostPoints) internal {
    // calls yieldBooster contract to deallocate the spNFT's owner boost points if any
    if (boostPoints > 0) {
      IYieldBooster(yieldBooster()).deallocateAllFromPool(msg.sender, tokenId);
    }

    // burn spNFT
    delete _stakingPositions[tokenId];
    ERC721._burn(tokenId);
  }

  /**
   * @dev Computes new tokenId and mint associated spNFT to "to" address
   */
  function _mintNextTokenId(address to) internal returns (uint256 tokenId) {
    _tokenIds.increment();
    tokenId = _tokenIds.current();
    _safeMint(to, tokenId);
  }

  /**
   * @dev Withdraw from a staking position and destroy it
   *
   * _updatePool() should be executed before calling this
   */
  function _withdrawFromPosition(address nftOwner, uint256 tokenId, uint256 amountToWithdraw) internal {
    require(amountToWithdraw > 0, "null");
    // withdrawFromPosition: amount cannot be null

    StakingPosition storage position = _stakingPositions[tokenId];
    require(_unlockOperators.contains(nftOwner) || position.startLockTime.add(position.lockDuration) <= _currentBlockTimestamp() || isUnlocked(), "locked");
    // withdrawFromPosition: invalid amount
    require(position.amount >= amountToWithdraw, "invalid");

    _harvestPosition(tokenId, nftOwner);

    // update position
    position.amount = position.amount.sub(amountToWithdraw);

    // update total lp supply
    _lpSupply = _lpSupply.sub(amountToWithdraw);

    if (position.amount == 0) {
      // destroy if now empty
      _lpSupplyWithMultiplier = _lpSupplyWithMultiplier.sub(position.amountWithMultiplier);
      _destroyPosition(tokenId, position.boostPoints);
    } else {
      _updateBoostMultiplierInfoAndRewardDebt(position);
    }

    emit WithdrawFromPosition(tokenId, amountToWithdraw);
    _lpToken.safeTransfer(nftOwner, amountToWithdraw);
  }

  /**
   * @dev updates position's boost multiplier, totalMultiplier, amountWithMultiplier (_lpSupplyWithMultiplier)
   * and rewardDebt without updating lockMultiplier
   */
  function _updateBoostMultiplierInfoAndRewardDebt(StakingPosition storage position) internal {
    // keep the original lock multiplier and recompute current boostPoints multiplier
    uint256 newTotalMultiplier = getMultiplierByBoostPoints(position.amount, position.boostPoints).add(position.lockMultiplier);
    if (newTotalMultiplier > _maxGlobalMultiplier) newTotalMultiplier = _maxGlobalMultiplier;

    position.totalMultiplier = newTotalMultiplier;
    uint256 amountWithMultiplier = position.amount.mul(newTotalMultiplier.add(1e4)).div(1e4);
    // update global supply
    _lpSupplyWithMultiplier = _lpSupplyWithMultiplier.sub(position.amountWithMultiplier).add(amountWithMultiplier);
    position.amountWithMultiplier = amountWithMultiplier;

    position.rewardDebt = amountWithMultiplier.mul(_accRewardsPerShare).div(1e18);
  }

  /**
   * @dev Harvest rewards from a position
   * Will also update the position's totalMultiplier
   */
  function _harvestPosition(uint256 tokenId, address to) internal {
    StakingPosition storage position = _stakingPositions[tokenId];

    // compute position's pending rewards
    uint256 pending = position.amountWithMultiplier.mul(_accRewardsPerShare).div(1e18).sub(
      position.rewardDebt
    );

    // unlock the position if pool has been unlocked or position is unlocked
    if (isUnlocked() || position.startLockTime.add(position.lockDuration) <= _currentBlockTimestamp()) {
      position.lockDuration = 0;
      position.lockMultiplier = 0;
    }

    // transfer rewards
    if (pending > 0 || position.pendingXGrailRewards > 0 || position.pendingGrailRewards > 0) {
      uint256 xGrailRewards = pending.mul(xGrailRewardsShare).div(_TOTAL_REWARDS_SHARES);
      uint256 grailAmount = pending.add(position.pendingGrailRewards).sub(xGrailRewards);

      xGrailRewards = xGrailRewards.add(position.pendingXGrailRewards);

      // Stack rewards in a buffer if to is equal to address(0)
      if (address(0) == to) {
        position.pendingXGrailRewards = xGrailRewards;
        position.pendingGrailRewards = grailAmount;
      }
      else {
        // convert and send xGRAIL + GRAIL rewards
        position.pendingXGrailRewards = 0;
        position.pendingGrailRewards = 0;

        if(xGrailRewards > 0) xGrailRewards = _safeConvertTo(to, xGrailRewards);
        // send share of GRAIL rewards
        grailAmount= _safeRewardsTransfer(to, grailAmount);

        // forbidden to harvest if contract has not explicitly confirmed it handle it
        _checkOnNFTHarvest(to, tokenId, grailAmount, xGrailRewards);
      }
    }
    emit HarvestPosition(tokenId, to, pending);
  }

  /**
   * @dev Renew lock from a staking position with "lockDuration"
   */
  function _lockPosition(uint256 tokenId, uint256 lockDuration) internal {
    require(!isUnlocked(), "locks disabled");

    StakingPosition storage position = _stakingPositions[tokenId];

    // for renew only, check if new lockDuration is at least = to the remaining active duration
    uint256 endTime = position.startLockTime.add(position.lockDuration);
    uint256 currentBlockTimestamp = _currentBlockTimestamp();
    if(endTime > currentBlockTimestamp){
      require(lockDuration >= endTime.sub(currentBlockTimestamp) && lockDuration > 0, "invalid");
    }

    _harvestPosition(tokenId, msg.sender);

    // update position and total lp supply
    position.lockDuration = lockDuration;
    position.lockMultiplier = getMultiplierByLockDuration(lockDuration);
    position.startLockTime = currentBlockTimestamp;
    _updateBoostMultiplierInfoAndRewardDebt(position);

    emit LockPosition(tokenId, lockDuration);
  }


  /**
  * @dev Handle deposits of tokens with transfer tax
  */
  function _transferSupportingFeeOnTransfer(IERC20 token, address user, uint256 amount) internal returns (uint256 receivedAmount) {
    uint256 previousBalance = token.balanceOf(address(this));
    token.safeTransferFrom(user, address(this), amount);
    return token.balanceOf(address(this)).sub(previousBalance);
  }

  /**
   * @dev Safe token transfer function, in case rounding error causes pool to not have enough tokens
   */
  function _safeRewardsTransfer(address to, uint256 amount) internal returns (uint256) {
    uint256 balance = _grailToken.balanceOf(address(this));
    // cap to available balance
    if (amount > balance) {
      amount = balance;
    }
    _grailToken.safeTransfer(to, amount);
    return amount;
  }

  /**
   * @dev Safe convert GRAIL to xGRAIL function, in case rounding error causes pool to not have enough tokens
   */
  function _safeConvertTo(address to, uint256 amount) internal returns (uint256) {
    uint256 balance = _grailToken.balanceOf(address(this));
    // cap to available balance
    if (amount > balance) {
      amount = balance;
    }
    if(amount > 0 ) _xGrailToken.convertTo(amount, to);
    return amount;
  }

  /**
   * @dev If NFT's owner is a contract, confirm whether it's able to handle rewards harvesting
   */
  function _checkOnNFTHarvest(address to, uint256 tokenId, uint256 grailAmount, uint256 xGrailAmount) internal {
    address nftOwner = ERC721.ownerOf(tokenId);
    if (nftOwner.isContract()) {
      bytes memory returndata = nftOwner.functionCall(abi.encodeWithSelector(
          INFTHandler(nftOwner).onNFTHarvest.selector, msg.sender, to, tokenId, grailAmount, xGrailAmount), "non implemented");
      require(abi.decode(returndata, (bool)), "FORBIDDEN");
    }
  }

  /**
   * @dev If NFT's owner is a contract, confirm whether it's able to handle addToPosition
   */
  function _checkOnAddToPosition(address nftOwner, uint256 tokenId, uint256 lpAmount) internal {
    if (nftOwner.isContract()) {
      bytes memory returndata = nftOwner.functionCall(abi.encodeWithSelector(
          INFTHandler(nftOwner).onNFTAddToPosition.selector, msg.sender, tokenId, lpAmount), "non implemented");
      require(abi.decode(returndata, (bool)), "FORBIDDEN");
    }
  }

  /**
   * @dev If NFT's owner is a contract, confirm whether it's able to handle withdrawals
   */
  function _checkOnWithdraw(address nftOwner, uint256 tokenId, uint256 lpAmount) internal {
    if (nftOwner.isContract()) {
      bytes memory returndata = nftOwner.functionCall(abi.encodeWithSelector(
          INFTHandler(nftOwner).onNFTWithdraw.selector, msg.sender, tokenId, lpAmount), "non implemented");
      require(abi.decode(returndata, (bool)), "FORBIDDEN");
    }
  }

  /**
  * @dev Forbid transfer when spNFT's owner is a contract and an operator is trying to transfer it
  * This is made to avoid unintended side effects
  *
  * Contract owner can still implement it by itself if needed
  */
  function _beforeTokenTransfer(address from, address /*to*/, uint256 /*tokenId*/) internal view override {
    require(!from.isContract() || msg.sender == from, "FORBIDDEN");
  }

  /**
   * @dev Utility function to get the current block timestamp
   */
  function _currentBlockTimestamp() internal view virtual returns (uint256) {
    /* solhint-disable not-rely-on-time */
    return block.timestamp;
  }

}

File 2 of 23 : IXGrailToken.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IXGrailToken is IERC20 {
  function usageAllocations(address userAddress, address usageAddress) external view returns (uint256 allocation);

  function allocateFromUsage(address userAddress, uint256 amount) external;
  function convertTo(uint256 amount, address to) external;
  function deallocateFromUsage(address userAddress, uint256 amount) external;

  function isTransferWhitelisted(address account) external view returns (bool);
}

File 3 of 23 : IYieldBooster.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;

interface IYieldBooster {
  function deallocateAllFromPool(address userAddress, uint256 tokenId) external;
  function getMultiplier(address poolAddress, uint256 maxBoostMultiplier, uint256 amount, uint256 totalPoolSupply, uint256 allocatedAmount) external view returns (uint256);
}

File 4 of 23 : INFTPool.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

interface INFTPool is IERC721 {
  function exists(uint256 tokenId) external view returns (bool);
  function hasDeposits() external view returns (bool);
  function getPoolInfo() external view returns (
    address lpToken, address grailToken, address sbtToken, uint256 lastRewardTime, uint256 accRewardsPerShare,
    uint256 lpSupply, uint256 lpSupplyWithMultiplier, uint256 allocPoint
  );
  function getStakingPosition(uint256 tokenId) external view returns (
    uint256 amount, uint256 amountWithMultiplier, uint256 startLockTime,
    uint256 lockDuration, uint256 lockMultiplier, uint256 rewardDebt,
    uint256 boostPoints, uint256 totalMultiplier
  );

  function boost(uint256 userAddress, uint256 amount) external;
  function unboost(uint256 userAddress, uint256 amount) external;
}

File 5 of 23 : INFTHandler.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;

import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";

interface INFTHandler is IERC721Receiver {
  function onNFTHarvest(address operator, address to, uint256 tokenId, uint256 grailAmount, uint256 xGrailAmount) external returns (bool);
  function onNFTAddToPosition(address operator, uint256 tokenId, uint256 lpAmount) external returns (bool);
  function onNFTWithdraw(address operator, uint256 tokenId, uint256 lpAmount) external returns (bool);
}

File 6 of 23 : ICamelotMaster.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.7.6;

interface ICamelotMaster {

  function grailToken() external view returns (address);
  function yieldBooster() external view returns (address);
  function owner() external view returns (address);
  function emergencyUnlock() external view returns (bool);

  function getPoolInfo(address _poolAddress) external view returns (address poolAddress, uint256 allocPoint, uint256 lastRewardTime, uint256 reserve, uint256 poolEmissionRate);

  function claimRewards() external returns (uint256);
}

File 7 of 23 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev String operations.
 */
library Strings {
    /**
     * @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 8 of 23 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor () {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 9 of 23 : EnumerableSet.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 EnumerableSet {
    // 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 10 of 23 : EnumerableMap.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 EnumerableMap {
    // 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 11 of 23 : Counters.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../math/SafeMath.sol";

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}
 * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
 * directly accessed.
 */
library Counters {
    using SafeMath for uint256;

    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        // The {SafeMath} overflow check can be skipped here, see the comment at the top
        counter._value += 1;
    }

    function decrement(Counter storage counter) internal {
        counter._value = counter._value.sub(1);
    }
}

File 12 of 23 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/*
 * @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 Context {
    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;
    }
}

File 13 of 23 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 14 of 23 : IERC721Receiver.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 IERC721Receiver {
    /**
     * @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 15 of 23 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "./IERC721.sol";

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

    /**
     * @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 16 of 23 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "./IERC721.sol";

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

    /**
     * @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 17 of 23 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../../introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @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 18 of 23 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../../utils/Context.sol";
import "./IERC721.sol";
import "./IERC721Metadata.sol";
import "./IERC721Enumerable.sol";
import "./IERC721Receiver.sol";
import "../../introspection/ERC165.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
import "../../utils/EnumerableSet.sol";
import "../../utils/EnumerableMap.sol";
import "../../utils/Strings.sol";

/**
 * @title ERC721 Non-Fungible Token Standard basic implementation
 * @dev see https://eips.ethereum.org/EIPS/eip-721
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
    using SafeMath for uint256;
    using Address for address;
    using EnumerableSet for EnumerableSet.UintSet;
    using EnumerableMap for EnumerableMap.UintToAddressMap;
    using Strings 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 => EnumerableSet.UintSet) private _holderTokens;

    // Enumerable mapping from token ids to their owners
    EnumerableMap.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.
     */
    constructor (string memory name_, string memory symbol_) {
        _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 = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(_msgSender() == owner || ERC721.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 = ERC721.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || ERC721.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 = ERC721.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(ERC721.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(
            IERC721Receiver(to).onERC721Received.selector,
            _msgSender(),
            from,
            tokenId,
            _data
        ), "ERC721: transfer to non ERC721Receiver implementer");
        bytes4 retval = abi.decode(returndata, (bytes4));
        return (retval == _ERC721_RECEIVED);
    }

    function _approve(address to, uint256 tokenId) private {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.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 { }
}

File 19 of 23 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

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

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 20 of 23 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 21 of 23 : SafeMath.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 SafeMath {
    /**
     * @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 22 of 23 : IERC165.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 IERC165 {
    /**
     * @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 23 of 23 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts may inherit from this and call {_registerInterface} to declare
 * their support of an interface.
 */
abstract contract ERC165 is IERC165 {
    /*
     * 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;

    constructor () {
        // 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;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AddToPosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lockDuration","type":"uint256"}],"name":"CreatePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"pending","type":"uint256"}],"name":"HarvestPosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lockDuration","type":"uint256"}],"name":"LockPosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"MergePositions","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lastRewardTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accRewardsPerShare","type":"uint256"}],"name":"PoolUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"boostPoints","type":"uint256"}],"name":"SetBoost","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxGlobalMultiplier","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxBoostMultiplier","type":"uint256"}],"name":"SetBoostMultiplierSettings","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"emergencyUnlock","type":"bool"}],"name":"SetEmergencyUnlock","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxLockDuration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxLockMultiplier","type":"uint256"}],"name":"SetLockMultiplierSettings","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"}],"name":"SetOperator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"isAdded","type":"bool"}],"name":"SetUnlockOperator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"xGrailRewardsShare","type":"uint256"}],"name":"SetXGrailRewardsShare","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"splitAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTokenId","type":"uint256"}],"name":"SplitPosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawFromPosition","type":"event"},{"inputs":[],"name":"MAX_BOOST_MULTIPLIER_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_GLOBAL_MULTIPLIER_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_LOCK_MULTIPLIER_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amountToAdd","type":"uint256"}],"name":"addToPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"boost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"lockDuration","type":"uint256"}],"name":"createPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyUnlock","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"boostPoints","type":"uint256"}],"name":"getMultiplierByBoostPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"lockDuration","type":"uint256"}],"name":"getMultiplierByLockDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMultiplierSettings","outputs":[{"internalType":"uint256","name":"maxGlobalMultiplier","type":"uint256"},{"internalType":"uint256","name":"maxLockDuration","type":"uint256"},{"internalType":"uint256","name":"maxLockMultiplier","type":"uint256"},{"internalType":"uint256","name":"maxBoostMultiplier","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPoolInfo","outputs":[{"internalType":"address","name":"lpToken","type":"address"},{"internalType":"address","name":"grailToken","type":"address"},{"internalType":"address","name":"xGrailToken","type":"address"},{"internalType":"uint256","name":"lastRewardTime","type":"uint256"},{"internalType":"uint256","name":"accRewardsPerShare","type":"uint256"},{"internalType":"uint256","name":"lpSupply","type":"uint256"},{"internalType":"uint256","name":"lpSupplyWithMultiplier","type":"uint256"},{"internalType":"uint256","name":"allocPoint","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getStakingPosition","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"amountWithMultiplier","type":"uint256"},{"internalType":"uint256","name":"startLockTime","type":"uint256"},{"internalType":"uint256","name":"lockDuration","type":"uint256"},{"internalType":"uint256","name":"lockMultiplier","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"},{"internalType":"uint256","name":"boostPoints","type":"uint256"},{"internalType":"uint256","name":"totalMultiplier","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"harvestPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"harvestPositionTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"address","name":"to","type":"address"}],"name":"harvestPositionsTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"hasDeposits","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ICamelotMaster","name":"master_","type":"address"},{"internalType":"contract IERC20","name":"grailToken","type":"address"},{"internalType":"contract IXGrailToken","name":"xGrailToken","type":"address"},{"internalType":"contract IERC20","name":"lpToken","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"}],"name":"isUnlockOperator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isUnlocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"lockDuration","type":"uint256"}],"name":"lockPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"master","outputs":[{"internalType":"contract ICamelotMaster","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256","name":"lockDuration","type":"uint256"}],"name":"mergePositions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"pendingRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"renewLockPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxGlobalMultiplier","type":"uint256"},{"internalType":"uint256","name":"maxBoostMultiplier","type":"uint256"}],"name":"setBoostMultiplierSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"emergencyUnlock_","type":"bool"}],"name":"setEmergencyUnlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxLockDuration","type":"uint256"},{"internalType":"uint256","name":"maxLockMultiplier","type":"uint256"}],"name":"setLockMultiplierSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator_","type":"address"}],"name":"setOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"bool","name":"add","type":"bool"}],"name":"setUnlockOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"xGrailRewardsShare_","type":"uint256"}],"name":"setXGrailRewardsShare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"splitAmount","type":"uint256"}],"name":"splitPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unboost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"unlockOperator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unlockOperatorsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"updatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amountToWithdraw","type":"uint256"}],"name":"withdrawFromPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"xGrailRewardsShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"yieldBooster","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106103ba5760003560e01c80636c0360eb116101f4578063b88d4fde1161011a578063e61f927d116100ad578063f2e16b3c1161007c578063f2e16b3c14610c5f578063f84ddf0b14610c82578063f8c8765e14610c8a578063fdc5f93014610cc8576103ba565b8063e61f927d14610c19578063e985e9c514610c21578063ee97f7f314610c4f578063f2c3999214610c57576103ba565b8063d4e32de6116100e9578063d4e32de614610412578063d5232dee14610be6578063dc6e15bd14610c09578063e3161ddd14610c11576103ba565b8063b88d4fde14610ad8578063c45a015514610b9e578063c87b56dd14610ba6578063d1aaef0514610bc3576103ba565b80638380edb71161019257806395d89b411161016157806395d89b4114610a59578063a22cb46514610a61578063a6b0b2a814610a8f578063b3ab15fb14610ab2576103ba565b80638380edb714610a09578063842072af14610a115780638da5cb5b14610a2e5780639016f82214610a36576103ba565b806370a08231116101ce57806370a082311461097b5780637a004bac146109a15780637dcb2abf146109be578063832c51f6146109db576103ba565b80636c0360eb1461092a5780636e00e2da146109325780636f8297af14610955576103ba565b80632f745c59116102e45780634f558e7911610277578063570ca73511610246578063570ca735146108a557806360246c88146108ad5780636352211e1461090557806368e5dab514610922576103ba565b80634f558e79146107de5780634f6ccce7146107fb5780635312ea8e1461081857806356dd590b14610835576103ba565b80634a256786116102b35780634a2567861461070c5780634a81add41461072f5780634cd5520b146107375780634d05c318146107b0576103ba565b80632f745c591461065b5780633e9b453e1461068757806340be7bec146106b357806342842e0e146106d6576103ba565b806313e46e841161035c57806320f8e94e1161032b57806320f8e94e146105c657806323b872dd146105e35780632c542ede146106195780632f38e0421461063c576103ba565b806313e46e8414610591578063158ef93e1461059957806318160ddd146105a15780631dc60207146105a9576103ba565b806306fdde031161039857806306fdde0314610451578063081812fc146104ce57806308521f7914610507578063095ea7b314610565576103ba565b806301ffc9a7146103bf5780630332f1141461041257806304d5b62d1461042c575b600080fd5b6103fe600480360360208110156103d557600080fd5b50357fffffffff0000000000000000000000000000000000000000000000000000000016610ce5565b604080519115158252519081900360200190f35b61041a610d20565b60408051918252519081900360200190f35b61044f6004803603604081101561044257600080fd5b5080359060200135610d26565b005b610459610f7e565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561049357818101518382015260200161047b565b50505050905090810190601f1680156104c05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104eb600480360360208110156104e457600080fd5b5035611014565b604080516001600160a01b039092168252519081900360200190f35b6105246004803603602081101561051d57600080fd5b5035611076565b604080519889526020890197909752878701959095526060870193909352608086019190915260a085015260c084015260e083015251908190036101000190f35b61044f6004803603604081101561057b57600080fd5b506001600160a01b0381351690602001356110ba565b61041a611195565b6103fe61119b565b61041a6111ab565b6104eb600480360360208110156105bf57600080fd5b50356111bc565b61044f600480360360208110156105dc57600080fd5b50356111e7565b61044f600480360360608110156105f957600080fd5b506001600160a01b0381358116916020810135909116906040013561126f565b61044f6004803603604081101561062f57600080fd5b50803590602001356112cf565b61044f6004803603602081101561065257600080fd5b50351515611461565b61041a6004803603604081101561067157600080fd5b506001600160a01b0381351690602001356114b5565b61044f6004803603604081101561069d57600080fd5b50803590602001356001600160a01b03166114de565b61044f600480360360408110156106c957600080fd5b50803590602001356115bb565b61044f600480360360608110156106ec57600080fd5b506001600160a01b038135811691602081013590911690604001356116ee565b61044f6004803603604081101561072257600080fd5b5080359060200135611709565b61041a6117fe565b61044f6004803603604081101561074d57600080fd5b81019060208101813564010000000081111561076857600080fd5b82018360208201111561077a57600080fd5b8035906020019184602083028401116401000000008311171561079c57600080fd5b9193509150356001600160a01b0316611804565b61044f600480360360408110156107c657600080fd5b506001600160a01b038135169060200135151561193c565b6103fe600480360360208110156107f457600080fd5b50356119b1565b61041a6004803603602081101561081157600080fd5b50356119bc565b61044f6004803603602081101561082e57600080fd5b50356119d2565b61044f6004803603604081101561084b57600080fd5b81019060208101813564010000000081111561086657600080fd5b82018360208201111561087857600080fd5b8035906020019184602083028401116401000000008311171561089a57600080fd5b919350915035611b29565b6104eb611e30565b6108b5611e3f565b604080516001600160a01b03998a168152978916602089015295909716868601526060860193909352608085019190915260a084015260c083015260e08201929092529051908190036101000190f35b6104eb6004803603602081101561091b57600080fd5b5035611f24565b6104eb611f4c565b610459611fdb565b61041a6004803603604081101561094857600080fd5b508035906020013561203c565b6103fe6004803603602081101561096b57600080fd5b50356001600160a01b031661212e565b61041a6004803603602081101561099157600080fd5b50356001600160a01b031661213b565b61044f600480360360208110156109b757600080fd5b50356121a3565b61041a600480360360208110156109d457600080fd5b5035612228565b6109e36123b3565b604080519485526020850193909352838301919091526060830152519081900360800190f35b6103fe6123c5565b61041a60048036036020811015610a2757600080fd5b5035612422565b6104eb612480565b61044f60048036036040811015610a4c57600080fd5b50803590602001356124de565b610459612564565b61044f60048036036040811015610a7757600080fd5b506001600160a01b03813516906020013515156125c5565b61044f60048036036040811015610aa557600080fd5b50803590602001356126ca565b61044f60048036036020811015610ac857600080fd5b50356001600160a01b03166127de565b61044f60048036036080811015610aee57600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135640100000000811115610b2957600080fd5b820183602082011115610b3b57600080fd5b80359060200191846001830284011164010000000083111715610b5d57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612847945050505050565b6104eb6128a9565b61045960048036036020811015610bbc57600080fd5b50356128cd565b61044f60048036036040811015610bd957600080fd5b5080359060200135612b4e565b61044f60048036036040811015610bfc57600080fd5b5080359060200135612de8565b61041a612e4e565b61044f612e5a565b6103fe612eb4565b6103fe60048036036040811015610c3757600080fd5b506001600160a01b0381358116916020013516612ebc565b6104eb612eea565b6103fe612ef9565b61044f60048036036040811015610c7557600080fd5b5080359060200135612f02565b61041a612f81565b61044f60048036036080811015610ca057600080fd5b506001600160a01b038135811691602081013582169160408201358116916060013516612f8d565b61044f60048036036020811015610cde57600080fd5b5035613126565b7fffffffff00000000000000000000000000000000000000000000000000000000811660009081526001602052604090205460ff165b919050565b613a9881565b60026000541415610d6c576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b6002600055610d7a8261319f565b610d82613241565b610d9482610d8f84611f24565b613345565b6000828152601c6020526040902080548210610df7576040805162461bcd60e51b815260206004820152601360248201527f696e76616c69642073706c6974416d6f756e7400000000000000000000000000604482015290519081900360640190fd5b8054610e0390836134e6565b8155610e0e81613543565b6000610e19336135e6565b60038301546004840154919250906000610e49612710610e43610e3c8583613608565b8990613662565b906136bb565b905060405180610140016040528087815260200182815260200186600201548152602001848152602001838152602001610e9a670de0b6b3a7640000610e436015548661366290919063ffffffff16565b815260006020808301829052604080840187905260608085018490526080948501849052898452601c83529281902085518155918501516001830155840151600282015590830151600382015590820151600482015560a0820151600582015560c0820151600682015560e08201516007820155610100820151600882015561012090910151600990910155601454610f339082613608565b6014556040805187815260208101869052815189927f83ad7662a93cf58f10a379c6370e942debc7c8cb1cffb157f519b12973264a4c928290030190a2505060016000555050505050565b60078054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561100a5780601f10610fdf5761010080835404028352916020019161100a565b820191906000526020600020905b815481529060010190602001808311610fed57829003601f168201915b5050505050905090565b600061101f82613722565b61105a5760405162461bcd60e51b815260040180806020018281038252602c815260200180615588602c913960400191505060405180910390fd5b506000908152600560205260409020546001600160a01b031690565b6000908152601c6020526040902080546001820154600283015460038401546004850154600586015460068701546007909701549597949693959294919390929091565b60006110c582611f24565b9050806001600160a01b0316836001600160a01b031614156111185760405162461bcd60e51b815260040180806020018281038252602181526020018061560c6021913960400191505060405180910390fd5b806001600160a01b031661112a61372f565b6001600160a01b0316148061114b575061114b8161114661372f565b612ebc565b6111865760405162461bcd60e51b81526004018080602001828103825260388152602001806154ba6038913960400191505060405180910390fd5b6111908383613733565b505050565b6161a881565b600f54600160a01b900460ff1681565b60006111b760036137ae565b905090565b6000816111c9600c6137ae565b116111d657506000610d1b565b6111e1600c836137b9565b92915050565b6002600054141561122d576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b600260005561123b816137c5565b611243613241565b61125081610d8f83611f24565b6000818152601c6020526040902061126790613543565b506001600055565b600260005414156112b5576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b60026000556112c583838361386b565b5050600160005550565b60026000541415611315576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b6002600055611323826138c2565b60008111611378576040805162461bcd60e51b815260206004820152600860248201527f3020616d6f756e74000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611380613241565b600061138b83611f24565b90506113978382613345565b6000838152601c602052604090206003810154156113d0576113b76138cc565b600282015560038101546113ca90612422565b60048201555b6010546113e7906001600160a01b031633856138d0565b81549093506113f69084613608565b81556013546114059084613608565b60135561141181613543565b61141c8285856139ef565b6040805133815260208101859052815186927f2bc3f231118d71058e11ae6ae9f199b789d86a7012a9d45f4c2ed7d7016478c2928290030190a2505060016000555050565b611469613b08565b601b805460ff191682151517908190556040805160ff90921615158252517f1545be19b3ba6f2e76454d1b8b59529cbbbdf7af9046fd49bd86c17314a5509d916020908290030190a150565b6001600160a01b03821660009081526002602052604081206114d790836137b9565b9392505050565b60026000541415611524576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b6002600055611532826137c5565b61154c61153e83611f24565b6001600160a01b0316613b63565b611589576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b611591613241565b61159b8282613345565b6000828152601c602052604090206115b290613543565b50506001600055565b60026000541415611601576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b600260005561160e613b69565b61161782613722565b611668576040805162461bcd60e51b815260206004820152600f60248201527f696e76616c696420746f6b656e49640000000000000000000000000000000000604482015290519081900360640190fd5b611670613241565b61167b826000613345565b6000828152601c60205260408120600681015490919061169b9084613608565b6006830181905590506116ad82613543565b60408051828152905185917fe96d35ce795c2d6a754b1bf60d2ea30785c5a460b6d4bf0e5b48190e5084860d919081900360200190a2505060016000555050565b61119083838360405180602001604052806000815250612847565b611711613b08565b6161a8821115611753576040805162461bcd60e51b81526020600482015260086024820152670e8dede40d0d2ced60c31b604482015290519081900360640190fd5b613a9881111580156117795750816117766018548361360890919063ffffffff16565b11155b6117b5576040805162461bcd60e51b81526020600482015260086024820152670e8dede40d0d2ced60c31b604482015290519081900360640190fd5b60168290556019819055604080518381526020810183905281517fde0bddf440a694ffa55b73c57fcb0c32fc9794b258c4e71ca2c867f6d7137f05929181900390910190a15050565b601a5481565b6002600054141561184a576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b6002600055611857613241565b8160005b8181101561193057600085858381811061187157fe5b905060200201359050611883816137c5565b600061188e82611f24565b9050336001600160a01b0382161480156118b05750336001600160a01b038616145b806118c857506118c8816001600160a01b0316613b63565b611905576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b61190f8286613345565b6000828152601c6020526040902061192690613543565b505060010161185b565b50506001600055505050565b611944613b08565b801561195b57611955600c83613b71565b50611968565b611966600c83613b86565b505b604080516001600160a01b0384168152821515602082015281517f28d57a4483d2172573741520aa0af0c5ac1e83cb2523c0d1a37c07b90a2e9395929181900390910190a15050565b60006111e182613722565b6000806119ca600384613b9b565b509392505050565b60026000541415611a18576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b6002600055611a268161319f565b6000818152601c60205260409020611a3f600c33613bb7565b80611a635750611a4d6138cc565b60038201546002830154611a6091613608565b11155b80611a715750611a716123c5565b611aab576040805162461bcd60e51b81526020600482015260066024820152651b1bd8dad95960d21b604482015290519081900360640190fd5b8054601354611aba90826134e6565b6013556001820154601454611ace916134e6565b601455611adc836000613bcc565b60408051828152905184917fb073e6fbd06d7557d2c82f414fee57de28e7fb517ecc0afdd6b1fc57034a9cb8919081900360200190a26010546112c5906001600160a01b03163383613ca3565b60026000541415611b6f576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b6002600055611b7c613241565b8160018111611bbc576040805162461bcd60e51b81526020600482015260076024820152661a5b9d985b1a5960ca1b604482015290519081900360640190fd5b600084846000818110611bcb57fe5b905060200201359050611bdd8161319f565b6000818152601c602052604090206003810154841015611c44576040805162461bcd60e51b815260206004820152600b60248201527f63616e2774206d65726765000000000000000000000000000000000000000000604482015290519081900360640190fd5b611c4e8233613345565b60038101849055611c5e84612422565b600482015560015b83811015611dac576000878783818110611c7c57fe5b905060200201359050611c8e8161319f565b83811415611ce3576040805162461bcd60e51b815260206004820152601060248201527f696e76616c696420746f6b656e20696400000000000000000000000000000000604482015290519081900360640190fd5b611ced8133613345565b6000818152601c602052604090206003810154871015611d54576040805162461bcd60e51b815260206004820152600b60248201527f63616e2774206d65726765000000000000000000000000000000000000000000604482015290519081900360640190fd5b806002015484600201541015611d6f57600280820154908501555b80548454611d7c91613608565b84556001810154601454611d8f916134e6565b6014556006810154611da2908390613bcc565b5050600101611c66565b50611db681613543565b336001600160a01b03167f1b6a7445053b0df83054e159a97edc3f3aad4284adaece07bef2fca11928a930878760405180806020018281038252848482818152602001925060200280828437600083820152604051601f909101601f19169092018290039550909350505050a25050600160005550505050565b600e546001600160a01b031681565b600080600080600080600080600f60009054906101000a90046001600160a01b03166001600160a01b03166306bfa938306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060a06040518083038186803b158015611ead57600080fd5b505afa158015611ec1573d6000803e3d6000fd5b505050506040513d60a0811015611ed757600080fd5b5060208101516040909101516010546011546012546015546013546014546001600160a01b039586169f509385169d50919093169a50929850909650909450925090509091929394959697565b60006111e18260405180606001604052806029815260200161551c6029913960039190613d0e565b600f54604080517f68e5dab500000000000000000000000000000000000000000000000000000000815290516000926001600160a01b0316916368e5dab5916004808301926020929190829003018186803b158015611faa57600080fd5b505afa158015611fbe573d6000803e3d6000fd5b505050506040513d6020811015611fd457600080fd5b5051905090565b600a8054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561100a5780601f10610fdf5761010080835404028352916020019161100a565b6000811580612049575082155b15612056575060006111e1565b6000612060611f4c565b90506001600160a01b038116612077576000612126565b601954601354604080517fd2eec6ff000000000000000000000000000000000000000000000000000000008152306004820152602481019390935260448301879052606483019190915260848201859052516001600160a01b0383169163d2eec6ff9160a4808301926020929190829003018186803b1580156120f957600080fd5b505afa15801561210d573d6000803e3d6000fd5b505050506040513d602081101561212357600080fd5b50515b949350505050565b60006111e1600c83613bb7565b60006001600160a01b0382166121825760405162461bcd60e51b815260040180806020018281038252602a8152602001806154f2602a913960400191505060405180910390fd5b6001600160a01b03821660009081526002602052604090206111e1906137ae565b6121ab613b08565b6127108111156121ed576040805162461bcd60e51b81526020600482015260086024820152670e8dede40d0d2ced60c31b604482015290519081900360640190fd5b601a8190556040805182815290517f3b2d8bc8f2837b38877b1e141263e80865f61ed9a257c4be608abe237d5f158e9181900360200190a150565b6000818152601c6020526040808220601554600f5483517f06bfa9380000000000000000000000000000000000000000000000000000000081523060048201529351929391928592839283926001600160a01b03909116916306bfa9389160248083019260a0929190829003018186803b1580156122a557600080fd5b505afa1580156122b9573d6000803e3d6000fd5b505050506040513d60a08110156122cf57600080fd5b50604081015160608201516080909201519094509092509050811515806122fc5750826122fa6138cc565b115b801561230a57506000601454115b1561236d5760006123238461231d6138cc565b906134e6565b9050600061233b846123358486613662565b90613608565b9050612368612361601454610e43670de0b6b3a76400008561366290919063ffffffff16565b8790613608565b955050505b6123a885600901546123358760080154612335896005015461231d670de0b6b3a7640000610e438c8e6001015461366290919063ffffffff16565b979650505050505050565b60165460175460185460195490919293565b601b5460009060ff16806111b75750600f60009054906101000a90046001600160a01b03166001600160a01b031663f2c399926040518163ffffffff1660e01b815260040160206040518083038186803b158015611faa57600080fd5b600061242c6123c5565b1561243957506000610d1b565b6017541580612446575081155b1561245357506000610d1b565b60175482106124655750601854610d1b565b6111e1601754610e438460185461366290919063ffffffff16565b600f54604080517f8da5cb5b00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b031691638da5cb5b916004808301926020929190829003018186803b158015611faa57600080fd5b60026000541415612524576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b6002600055612531613b69565b612539613241565b612544826000613345565b6000828152601c60205260408120600681015490919061169b90846134e6565b60088054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561100a5780601f10610fdf5761010080835404028352916020019161100a565b6125cd61372f565b6001600160a01b0316826001600160a01b03161415612633576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b806006600061264061372f565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561268461372f565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b6126d2612480565b6001600160a01b0316336001600160a01b031614806126fb5750600e546001600160a01b031633145b612738576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b613a9881111580156127595750601654601954612756908390613608565b11155b612795576040805162461bcd60e51b81526020600482015260086024820152670e8dede40d0d2ced60c31b604482015290519081900360640190fd5b60178290556018819055604080518381526020810183905281517f46cf6b9b4ec75e8786b2e93d4beb426d70d56d9b0eb9bfd40e975f9dc59d7703929181900390910190a15050565b6127e6613b08565b600e80546001600160a01b03831673ffffffffffffffffffffffffffffffffffffffff19909116811790915560408051918252517fdbebfba65bd6398fb722063efc10c99f624f9cd8ba657201056af918a676d5ee9181900360200190a150565b6002600054141561288d576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b600260005561289e84848484613d1b565b505060016000555050565b7f0000000000000000000000006db1ef0df42e30acf139a70c1ed0b7e6c51dbf6d81565b60606128d882613722565b6129135760405162461bcd60e51b815260040180806020018281038252602f8152602001806155dd602f913960400191505060405180910390fd5b60008281526009602090815260408083208054825160026001831615610100026000190190921691909104601f8101859004850282018501909352828152929091908301828280156129a65780601f1061297b576101008083540402835291602001916129a6565b820191906000526020600020905b81548152906001019060200180831161298957829003601f168201915b5050505050905060006129b7611fdb565b90508051600014156129cb57509050610d1b565b815115612a8c5780826040516020018083805190602001908083835b60208310612a065780518252601f1990920191602091820191016129e7565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310612a4e5780518252601f199092019160209182019101612a2f565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050610d1b565b80612a9685613d73565b6040516020018083805190602001908083835b60208310612ac85780518252601f199092019160209182019101612aa9565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b60208310612b105780518252601f199092019160209182019101612af1565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050919050565b60026000541415612b94576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b6002600055612ba16123c5565b15612bf9578015612bf9576040805162461bcd60e51b815260206004820152600e60248201527f6c6f636b732064697361626c6564000000000000000000000000000000000000604482015290519081900360640190fd5b612c01613241565b601054612c18906001600160a01b031633846138d0565b915081612c6c576040805162461bcd60e51b815260206004820152600b60248201527f7a65726f20616d6f756e74000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000612c77336135e6565b90506000612c8483612422565b90506000612ca2612710610e43612c9b8583613608565b8890613662565b9050604051806101400160405280868152602001828152602001612cc46138cc565b8152602001858152602001838152602001612cf6670de0b6b3a7640000610e436015548661366290919063ffffffff16565b815260006020808301829052604080840187905260608085018490526080948501849052888452601c83529281902085518155918501516001830155840151600282015590830151600382015590820151600482015560a0820151600582015560c0820151600682015560e08201516007820155610100820151600882015561012090910151600990910155601354612d8f9086613608565b601355601454612d9f9082613608565b6014556040805186815260208101869052815185927fc75220a9dbab7c65d9cc87d8534accb348d3f151ee2afccfb42e6ccf75556f23928290030190a250506001600055505050565b60026000541415612e2e576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b6002600055612e3c826137c5565b612e44613241565b6115b28282613e82565b60006111b7600c6137ae565b60026000541415612ea0576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b6002600055612ead613241565b6001600055565b601454151590565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b600f546001600160a01b031681565b601b5460ff1681565b60026000541415612f48576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b6002600055612f56826137c5565b612f5e613241565b6000612f6983611f24565b9050612f76818484613fd6565b6112c581848461419f565b60006111b7600b61425c565b336001600160a01b037f0000000000000000000000006db1ef0df42e30acf139a70c1ed0b7e6c51dbf6d16148015612fcf5750600f54600160a01b900460ff16155b61300c576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b6010805473ffffffffffffffffffffffffffffffffffffffff199081166001600160a01b0384811691909117909255600f805460118054841688861617908190556012805485168887161790819055600160a01b92909416898616177fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1691909117909155604080517f095ea7b3000000000000000000000000000000000000000000000000000000008152928416600484015260001960248401525192169163095ea7b3916044808201926020929091908290030181600087803b1580156130f457600080fd5b505af1158015613108573d6000803e3d6000fd5b505050506040513d602081101561311e57600080fd5b505050505050565b6002600054141561316c576040805162461bcd60e51b815260206004820152601f60248201526000805160206153f2833981519152604482015290519081900360640190fd5b600260005561317a816137c5565b613182613241565b6000818152601c6020526040902060030154611267908290613e82565b6131a881613722565b6131e35760405162461bcd60e51b815260040180806020018281038252602c81526020018061548e602c913960400191505060405180910390fd5b6131ed3382614260565b61323e576040805162461bcd60e51b815260206004820152600960248201527f6e6f74206f776e65720000000000000000000000000000000000000000000000604482015290519081900360640190fd5b50565b600f54604080517f372500ab00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b03169163372500ab91600480830192602092919082900301818787803b1580156132a057600080fd5b505af11580156132b4573d6000803e3d6000fd5b505050506040513d60208110156132ca57600080fd5b5051905080156132fe576014546132fa906132f190610e4384670de0b6b3a7640000613662565b60155490613608565b6015555b7f7fa9647ec1cc14e3822b46d05a2b9d4e019bde8875c0088c46b6503d71bf17226133276138cc565b6015546040805192835260208301919091528051918290030190a150565b6000828152601c6020526040812060058101546015546001830154929392613380929161231d91670de0b6b3a764000091610e439190613662565b905061338a6123c5565b806133ae57506133986138cc565b600383015460028401546133ab91613608565b11155b156133c25760006003830181905560048301555b60008111806133d5575060008260080154115b806133e4575060008260090154115b1561349d576000613406612710610e43601a548561366290919063ffffffff16565b905060006134258261231d86600901548661360890919063ffffffff16565b905061343e84600801548361360890919063ffffffff16565b91506001600160a01b03851661346157600884018290556009840181905561349a565b600060088501819055600985015581156134825761347f8583614287565b91505b61348c85826143a6565b905061349a85878385614447565b50505b604080516001600160a01b038516815260208101839052815186927fcc70d7e29d5f6e6a993743a891f22f70aee482bafb25b00b8909ee1bf9028ae2928290030190a250505050565b60008282111561353d576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600061355f82600401546123358460000154856006015461203c565b905060165481111561357057506016545b600782018190556000613594612710610e4361358c8583613608565b865490613662565b90506135b38161233585600101546014546134e690919063ffffffff16565b601455600183018190556015546135d990670de0b6b3a764000090610e43908490613662565b8360050181905550505050565b60006135f2600b61457f565b6135fc600b61425c565b9050610d1b8282614588565b6000828201838110156114d7576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600082613671575060006111e1565b8282028284828161367e57fe5b04146114d75760405162461bcd60e51b81526004018080602001828103825260218152602001806155676021913960400191505060405180910390fd5b6000808211613711576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161371a57fe5b049392505050565b60006111e16003836145a2565b3390565b6000818152600560205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038416908117909155819061377582611f24565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006111e18261425c565b60006114d783836145ae565b6137ce81613722565b6138095760405162461bcd60e51b815260040180806020018281038252602c81526020018061548e602c913960400191505060405180910390fd5b6138133382614260565b8061382e57503361382382611014565b6001600160a01b0316145b61323e576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b61387c61387661372f565b82614612565b6138b75760405162461bcd60e51b815260040180806020018281038252603181526020018061562d6031913960400191505060405180910390fd5b6111908383836146ae565b61382e3382614612565b4290565b600080846001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561392057600080fd5b505afa158015613934573d6000803e3d6000fd5b505050506040513d602081101561394a57600080fd5b505190506139636001600160a01b0386168530866147fa565b6139e681866001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156139b457600080fd5b505afa1580156139c8573d6000803e3d6000fd5b505050506040513d60208110156139de57600080fd5b5051906134e6565b95945050505050565b613a01836001600160a01b0316613b63565b1561119057604080513360248201526044810184905260648082018490528251808303909101815260849091018252602081810180516001600160e01b03167fe2b36dc3000000000000000000000000000000000000000000000000000000001790528251808401909352600f83527f6e6f6e20696d706c656d656e746564000000000000000000000000000000000090830152600091613aac916001600160a01b0387169161486d565b9050808060200190516020811015613ac357600080fd5b5051613b02576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b50505050565b613b10612480565b6001600160a01b0316336001600160a01b031614613b61576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b565b3b151590565b613b10611f4c565b60006114d7836001600160a01b03841661487c565b60006114d7836001600160a01b0384166148c6565b6000808080613baa868661498c565b9097909650945050505050565b60006114d7836001600160a01b038416614a07565b8015613c4957613bda611f4c565b6001600160a01b0316635485435433846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050600060405180830381600087803b158015613c3057600080fd5b505af1158015613c44573d6000803e3d6000fd5b505050505b6000828152601c60205260408120818155600181018290556002810182905560038101829055600481018290556005810182905560068101829055600781018290556008810182905560090155613c9f82614a1f565b5050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b03167fa9059cbb00000000000000000000000000000000000000000000000000000000179052611190908490614aec565b6000612126848484614b9d565b613d2c613d2661372f565b83614612565b613d675760405162461bcd60e51b815260040180806020018281038252603181526020018061562d6031913960400191505060405180910390fd5b613b0284848484614c67565b606081613db4575060408051808201909152600181527f30000000000000000000000000000000000000000000000000000000000000006020820152610d1b565b8160005b8115613dcc57600101600a82049150613db8565b60008167ffffffffffffffff81118015613de557600080fd5b506040519080825280601f01601f191660200182016040528015613e10576020820181803683370190505b50859350905060001982015b8315613e7957600a840660300160f81b82828060019003935081518110613e3f57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a84049350613e1c565b50949350505050565b613e8a6123c5565b15613edc576040805162461bcd60e51b815260206004820152600e60248201527f6c6f636b732064697361626c6564000000000000000000000000000000000000604482015290519081900360640190fd5b6000828152601c6020526040812060038101546002820154919291613f0091613608565b90506000613f0c6138cc565b905080821115613f6a57613f2082826134e6565b8410158015613f2f5750600084115b613f6a576040805162461bcd60e51b81526020600482015260076024820152661a5b9d985b1a5960ca1b604482015290519081900360640190fd5b613f748533613345565b60038301849055613f8484612422565b600484015560028301819055613f9983613543565b60408051858152905186917f817ea9dab606b88f1d3b71d35f23e301a95c27058f35c39acf502f471feb03b8919081900360200190a25050505050565b6000811161402d576040805162461bcd60e51b8152602060048083019190915260248201527f6e756c6c00000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000828152601c60205260409020614046600c85613bb7565b8061406a57506140546138cc565b6003820154600283015461406791613608565b11155b8061407857506140786123c5565b6140b2576040805162461bcd60e51b81526020600482015260066024820152651b1bd8dad95960d21b604482015290519081900360640190fd5b80548211156140f2576040805162461bcd60e51b81526020600482015260076024820152661a5b9d985b1a5960ca1b604482015290519081900360640190fd5b6140fc8385613345565b805461410890836134e6565b815560135461411790836134e6565b6013558054614149576001810154601454614131916134e6565b6014556006810154614144908490613bcc565b614152565b61415281613543565b60408051838152905184917f10b3873e32aa5edce774b02db517f3bde3429d0e97b57b74cb569ba85ce69a58919081900360200190a2601054613b02906001600160a01b03168584613ca3565b6141b1836001600160a01b0316613b63565b1561119057604080513360248201526044810184905260648082018490528251808303909101815260849091018252602081810180516001600160e01b03167f34677c7a000000000000000000000000000000000000000000000000000000001790528251808401909352600f83527f6e6f6e20696d706c656d656e746564000000000000000000000000000000000090830152600091613aac916001600160a01b0387169161486d565b5490565b600061426b82611f24565b6001600160a01b0316836001600160a01b031614905092915050565b601154604080516370a0823160e01b8152306004820152905160009283926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b1580156142d757600080fd5b505afa1580156142eb573d6000803e3d6000fd5b505050506040513d602081101561430157600080fd5b5051905080831115614311578092505b821561439e57601254604080517f5a1d34dc000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b03878116602483015291519190921691635a1d34dc91604480830192600092919082900301818387803b15801561438557600080fd5b505af1158015614399573d6000803e3d6000fd5b505050505b509092915050565b601154604080516370a0823160e01b8152306004820152905160009283926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b1580156143f657600080fd5b505afa15801561440a573d6000803e3d6000fd5b505050506040513d602081101561442057600080fd5b5051905080831115614430578092505b60115461439e906001600160a01b03168585613ca3565b600061445284611f24565b9050614466816001600160a01b0316613b63565b1561457857604080513360248201526001600160a01b038088166044830152606482018790526084820186905260a48083018690528351808403909101815260c49092018352602082810180516001600160e01b03167ffe4ee967000000000000000000000000000000000000000000000000000000001790528351808501909452600f84527f6e6f6e20696d706c656d656e74656400000000000000000000000000000000009084015260009261452292918516919061486d565b905080806020019051602081101561453957600080fd5b505161311e576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b5050505050565b80546001019055565b613c9f828260405180602001604052806000815250614cb9565b60006114d78383614a07565b815460009082106145f05760405162461bcd60e51b81526004018080602001828103825260228152602001806153d06022913960400191505060405180910390fd5b8260000182815481106145ff57fe5b9060005260206000200154905092915050565b600061461d82613722565b6146585760405162461bcd60e51b815260040180806020018281038252602c81526020018061548e602c913960400191505060405180910390fd5b600061466383611f24565b9050806001600160a01b0316846001600160a01b0316148061469e5750836001600160a01b031661469384611014565b6001600160a01b0316145b8061212657506121268185612ebc565b826001600160a01b03166146c182611f24565b6001600160a01b0316146147065760405162461bcd60e51b81526004018080602001828103825260298152602001806155b46029913960400191505060405180910390fd5b6001600160a01b03821661474b5760405162461bcd60e51b81526004018080602001828103825260248152602001806154446024913960400191505060405180910390fd5b614756838383614d0b565b614761600082613733565b6001600160a01b03831660009081526002602052604090206147839082614d6e565b506001600160a01b03821660009081526002602052604090206147a69082614d7a565b506147b360038284614d86565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03167f23b872dd00000000000000000000000000000000000000000000000000000000179052613b02908590614aec565b60606121268484600085614d9c565b60006148888383614a07565b6148be575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556111e1565b5060006111e1565b6000818152600183016020526040812054801561498257835460001980830191908101906000908790839081106148f957fe5b906000526020600020015490508087600001848154811061491657fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061494657fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506111e1565b60009150506111e1565b8154600090819083106149d05760405162461bcd60e51b81526004018080602001828103825260228152602001806155456022913960400191505060405180910390fd5b60008460000184815481106149e157fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60009081526001919091016020526040902054151590565b6000614a2a82611f24565b9050614a3881600084614d0b565b614a43600083613733565b6000828152600960205260409020546002600019610100600184161502019091160415614a81576000828152600960205260408120614a8191615377565b6001600160a01b0381166000908152600260205260409020614aa39083614d6e565b50614aaf600383614eec565b5060405182906000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6000614b41826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661486d9092919063ffffffff16565b80519091501561119057808060200190516020811015614b6057600080fd5b50516111905760405162461bcd60e51b815260040180806020018281038252602a81526020018061565e602a913960400191505060405180910390fd5b60008281526001840160205260408120548281614c385760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614bfd578181015183820152602001614be5565b50505050905090810190601f168015614c2a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50846000016001820381548110614c4b57fe5b9060005260206000209060020201600101549150509392505050565b614c728484846146ae565b614c7e84848484614ef8565b613b025760405162461bcd60e51b81526004018080602001828103825260328152602001806154126032913960400191505060405180910390fd5b614cc38383615078565b614cd06000848484614ef8565b6111905760405162461bcd60e51b81526004018080602001828103825260328152602001806154126032913960400191505060405180910390fd5b614d1d836001600160a01b0316613b63565b1580614d315750336001600160a01b038416145b611190576040805162461bcd60e51b81526020600482015260096024820152682327a92124a22222a760b91b604482015290519081900360640190fd5b60006114d783836148c6565b60006114d7838361487c565b600061212684846001600160a01b0385166151a6565b606082471015614ddd5760405162461bcd60e51b81526004018080602001828103825260268152602001806154686026913960400191505060405180910390fd5b614de685613b63565b614e37576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310614e755780518252601f199092019160209182019101614e56565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614ed7576040519150601f19603f3d011682016040523d82523d6000602084013e614edc565b606091505b50915091506123a882828661523d565b60006114d783836152a3565b6000614f0c846001600160a01b0316613b63565b614f1857506001612126565b6000615026630a85bd0160e11b614f2d61372f565b88878760405160240180856001600160a01b03168152602001846001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015614f94578181015183820152602001614f7c565b50505050905090810190601f168015614fc15780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001615412603291396001600160a01b038816919061486d565b9050600081806020019051602081101561503f57600080fd5b50517fffffffff0000000000000000000000000000000000000000000000000000000016630a85bd0160e11b1492505050949350505050565b6001600160a01b0382166150d3576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b6150dc81613722565b1561512e576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b61513a60008383614d0b565b6001600160a01b038216600090815260026020526040902061515c9082614d7a565b5061516960038284614d86565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60008281526001840160205260408120548061520b5750506040805180820182528381526020808201848152865460018181018955600089815284812095516002909302909501918255915190820155865486845281880190925292909120556114d7565b8285600001600183038154811061521e57fe5b90600052602060002090600202016001018190555060009150506114d7565b6060831561524c5750816114d7565b82511561525c5782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315614bfd578181015183820152602001614be5565b6000818152600183016020526040812054801561498257835460001980830191908101906000908790839081106152d657fe5b90600052602060002090600202019050808760000184815481106152f657fe5b60009182526020808320845460029093020191825560019384015491840191909155835482528983019052604090209084019055865487908061533557fe5b60008281526020808220600260001990940193840201828155600190810183905592909355888152898201909252604082209190915594506111e19350505050565b50805460018160011615610100020316600290046000825580601f1061539d575061323e565b601f01602090049060005260206000209081019061323e91905b808211156153cb57600081556001016153b7565b509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64735265656e7472616e637947756172643a207265656e7472616e742063616c6c004552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e6473536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f7665645361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a264697066735822122026eeb298c9d2e348d59d7daa454c89b23e4b8cd017e58515643dae12fa05443f64736f6c63430007060033

Loading