ETH Price: $3,382.44 (+4.41%)

Contract

0x04d572734006788B646ce35b133Bdf7160f79995
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Safe Transfer Fr...181159522023-09-11 22:00:11492 days ago1694469611IN
0x04d57273...160f79995
0 ETH0.0017064213.89970743
Safe Transfer Fr...181159522023-09-11 22:00:11492 days ago1694469611IN
0x04d57273...160f79995
0 ETH0.0020803213.89970743
Set Approval For...165708102023-02-06 16:02:11709 days ago1675699331IN
0x04d57273...160f79995
0 ETH0.0027179355.26509658
Approve164715132023-01-23 19:11:35723 days ago1674501095IN
0x04d57273...160f79995
0 ETH0.0019305334.39766266
Approve164709972023-01-23 17:28:11723 days ago1674494891IN
0x04d57273...160f79995
0 ETH0.0015247327.16731887
Approve164709432023-01-23 17:17:23723 days ago1674494243IN
0x04d57273...160f79995
0 ETH0.0016071228.63528053
Create Proton Fo...164352812023-01-18 17:47:59728 days ago1674064079IN
0x04d57273...160f79995
0 ETH0.0088210336.24416477
Create Proton Fo...164352682023-01-18 17:45:23728 days ago1674063923IN
0x04d57273...160f79995
0 ETH0.0096811539.77827935
Create Proton Fo...164352562023-01-18 17:42:59728 days ago1674063779IN
0x04d57273...160f79995
0 ETH0.0100455741.27562259
Create Proton Fo...164346242023-01-18 15:35:47728 days ago1674056147IN
0x04d57273...160f79995
0 ETH0.0064531624.77432425
Create Proton Fo...163781332023-01-10 18:14:47736 days ago1673374487IN
0x04d57273...160f79995
0 ETH0.0068145828
Create Proton Fo...163730752023-01-10 1:19:47737 days ago1673313587IN
0x04d57273...160f79995
0 ETH0.0053969420.71940596
Create Proton Fo...163461092023-01-06 6:59:47740 days ago1672988387IN
0x04d57273...160f79995
0 ETH0.0053575416.07116872
Safe Transfer Fr...163423072023-01-05 18:13:59741 days ago1672942439IN
0x04d57273...160f79995
0 ETH0.0057859441.54391274
Create Proton Fo...162988312022-12-30 16:38:47747 days ago1672418327IN
0x04d57273...160f79995
0 ETH0.0049295718.92510941
Create Proton Fo...162671262022-12-26 6:26:23751 days ago1672035983IN
0x04d57273...160f79995
0 ETH0.00309511.88200835
Approve162421412022-12-22 18:49:35755 days ago1671734975IN
0x04d57273...160f79995
0 ETH0.0008916615.88737711
Create Proton Fo...162421172022-12-22 18:44:47755 days ago1671734687IN
0x04d57273...160f79995
0 ETH0.0037906315.57507781
Create Proton Fo...162396792022-12-22 10:34:47755 days ago1671705287IN
0x04d57273...160f79995
0 ETH0.0031653512.15209125
Create Proton Fo...162342912022-12-21 16:32:35756 days ago1671640355IN
0x04d57273...160f79995
0 ETH0.0053185821.85319505
Create Proton Fo...162307212022-12-21 4:35:35756 days ago1671597335IN
0x04d57273...160f79995
0 ETH0.0036466914
Set Approval For...162178232022-12-19 9:23:47758 days ago1671441827IN
0x04d57273...160f79995
0 ETH0.00063412.89147696
Create Proton Fo...162057912022-12-17 17:04:35760 days ago1671296675IN
0x04d57273...160f79995
0 ETH0.0036506715
Transfer From162028672022-12-17 7:16:59760 days ago1671261419IN
0x04d57273...160f79995
0 ETH0.0018724814.53620801
Create Proton Fo...162027902022-12-17 7:01:35760 days ago1671260495IN
0x04d57273...160f79995
0 ETH0.0044181113.96971611
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ProtonB

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 37 : ProtonB.sol
// SPDX-License-Identifier: MIT

// ProtonB.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

import "../interfaces/IUniverse.sol";
import "../interfaces/IChargedState.sol";
import "../interfaces/IChargedSettings.sol";
import "../interfaces/IChargedParticles.sol";
import "../interfaces/IProtonB.sol";

import "../lib/BaseProton.sol";
import "../lib/TokenInfo.sol";
import "../lib/BlackholePrevention.sol";
import "../lib/RelayRecipient.sol";


contract ProtonB is BaseProton, IProtonB {
  using SafeMath for uint256;
  using TokenInfo for address payable;
  using Counters for Counters.Counter;

  IUniverse internal _universe;
  IChargedState internal _chargedState;
  IChargedSettings internal _chargedSettings;
  IChargedParticles internal _chargedParticles;


  /***********************************|
  |          Initialization           |
  |__________________________________*/

  constructor() public BaseProton("Charged Particles - ProtonB", "PROTON.B") {}


  /***********************************|
  |              Public               |
  |__________________________________*/

  function createProtonForSale(
    address creator,
    address receiver,
    string memory tokenMetaUri,
    uint256 annuityPercent,
    uint256 royaltiesPercent,
    uint256 salePrice
  )
    external
    virtual
    override
    returns (uint256 newTokenId)
  {
    newTokenId = _createProton(
      creator,
      receiver,
      tokenMetaUri,
      royaltiesPercent,
      salePrice
    );

    if (annuityPercent > 0) {
      _chargedSettings.setCreatorAnnuities(
        address(this),
        newTokenId,
        creator,
        annuityPercent
      );
    }
  }

  function createChargedParticle(
    address creator,
    address receiver,
    address referrer,
    string memory tokenMetaUri,
    string memory walletManagerId,
    address assetToken,
    uint256 assetAmount,
    uint256 annuityPercent
  )
    external
    virtual
    override
    nonReentrant
    whenNotPaused
    returns (uint256 newTokenId)
  {
    newTokenId = _createChargedParticle(
      creator,
      receiver,
      referrer,
      tokenMetaUri,
      walletManagerId,
      assetToken,
      assetAmount,
      annuityPercent
    );
  }

  /// @dev for backwards compatibility with v1
  function createBasicProton(
    address creator,
    address receiver,
    string memory tokenMetaUri
  )
    external
    virtual
    whenNotPaused
    returns (uint256 newTokenId)
  {
    newTokenId = _createProton(
      creator,
      receiver,
      tokenMetaUri,
      0, // royaltiesPercent
      0  // salePrice
    );
  }


  /***********************************|
  |          Only Admin/DAO           |
  |__________________________________*/

  /**
    * @dev Setup the ChargedParticles Interface
    */
  function setUniverse(address universe) external virtual onlyOwner {
    _universe = IUniverse(universe);
    emit UniverseSet(universe);
  }

  /**
    * @dev Setup the ChargedParticles Interface
    */
  function setChargedParticles(address chargedParticles) external virtual onlyOwner {
    _chargedParticles = IChargedParticles(chargedParticles);
    emit ChargedParticlesSet(chargedParticles);
  }

  /// @dev Setup the Charged-State Controller
  function setChargedState(address stateController) external virtual onlyOwner {
    _chargedState = IChargedState(stateController);
    emit ChargedStateSet(stateController);
  }

  /// @dev Setup the Charged-Settings Controller
  function setChargedSettings(address settings) external virtual onlyOwner {
    _chargedSettings = IChargedSettings(settings);
    emit ChargedSettingsSet(settings);
  }


  /***********************************|
  |         Private Functions         |
  |__________________________________*/

  function _createChargedParticle(
    address creator,
    address receiver,
    address referrer,
    string memory tokenMetaUri,
    string memory walletManagerId,
    address assetToken,
    uint256 assetAmount,
    uint256 annuityPercent
  )
    internal
    virtual
    returns (uint256 newTokenId)
  {
    require(address(_chargedParticles) != address(0x0), "PRT:E-107");

    newTokenId = _createProton(creator, receiver, tokenMetaUri, 0, 0);

    if (annuityPercent > 0) {
      _chargedSettings.setCreatorAnnuities(
        address(this),
        newTokenId,
        creator,
        annuityPercent
      );
    }

    _chargeParticle(newTokenId, walletManagerId, assetToken, assetAmount, referrer);
  }

  function _chargeParticle(
    uint256 tokenId,
    string memory walletManagerId,
    address assetToken,
    uint256 assetAmount,
    address referrer
  )
    internal
    virtual
  {
    _collectAssetToken(_msgSender(), assetToken, assetAmount);

    IERC20(assetToken).approve(address(_chargedParticles), assetAmount);

    _chargedParticles.energizeParticle(
      address(this),
      tokenId,
      walletManagerId,
      assetToken,
      assetAmount,
      referrer
    );
  }


  /***********************************|
  |        Function Overrides         |
  |__________________________________*/

  function _setSalePrice(uint256 tokenId, uint256 salePrice) internal virtual override {
    super._setSalePrice(tokenId, salePrice);

    // Temp-Lock/Unlock NFT
    //  prevents front-running the sale and draining the value of the NFT just before sale
    _chargedState.setTemporaryLock(address(this), tokenId, (salePrice > 0));
  }


  function _buyProton(uint256 _tokenId, uint256 _gasLimit)
    internal
    virtual
    override
    returns (
      address contractAddress,
      uint256 tokenId,
      address oldOwner,
      address newOwner,
      uint256 salePrice,
      address royaltiesReceiver,
      uint256 creatorAmount
    )
  {
    (contractAddress, tokenId, oldOwner, newOwner, salePrice, royaltiesReceiver, creatorAmount) = super._buyProton(_tokenId, _gasLimit);

    // Signal to Universe Controller
    if (address(_universe) != address(0)) {
      _universe.onProtonSale(contractAddress, tokenId, oldOwner, newOwner, salePrice, royaltiesReceiver, creatorAmount);
    }
  }


  function _transfer(address from, address to, uint256 tokenId) internal virtual override {
    // Unlock NFT
    _chargedState.setTemporaryLock(address(this), tokenId, false);

    super._transfer(from, to, tokenId);
  }
}

File 2 of 37 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 3 of 37 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

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

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

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

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

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

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

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

File 4 of 37 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @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");
        return _functionCallWithValue(target, data, value, errorMessage);
    }

    function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
        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 5 of 37 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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].
 */
contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

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

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

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

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

        _;

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

File 6 of 37 : IUniverse.sol
// SPDX-License-Identifier: MIT

// IUniverse.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

/**
 * @title Universal Controller interface
 * @dev ...
 */
interface IUniverse {

  event ChargedParticlesSet(address indexed chargedParticles);
  event PhotonSet(address indexed photonToken, uint256 maxSupply);
  event ProtonTokenSet(address indexed protonToken);
  event LeptonTokenSet(address indexed leptonToken);
  event QuarkTokenSet(address indexed quarkToken);
  event BosonTokenSet(address indexed bosonToken);
  event EsaMultiplierSet(address indexed assetToken, uint256 multiplier);
  event ElectrostaticAttraction(address indexed account, address photonSource, uint256 energy, uint256 multiplier);
  event ElectrostaticDischarge(address indexed account, address photonSource, uint256 energy);

  function onEnergize(
    address sender,
    address referrer,
    address contractAddress,
    uint256 tokenId,
    string calldata managerId,
    address assetToken,
    uint256 assetEnergy
  ) external;

  function onDischarge(
    address contractAddress,
    uint256 tokenId,
    string calldata managerId,
    address assetToken,
    uint256 creatorEnergy,
    uint256 receiverEnergy
  ) external;

  function onDischargeForCreator(
    address contractAddress,
    uint256 tokenId,
    string calldata managerId,
    address creator,
    address assetToken,
    uint256 receiverEnergy
  ) external;

  function onRelease(
    address contractAddress,
    uint256 tokenId,
    string calldata managerId,
    address assetToken,
    uint256 principalEnergy,
    uint256 creatorEnergy,
    uint256 receiverEnergy
  ) external;

  function onCovalentBond(
    address contractAddress,
    uint256 tokenId,
    string calldata managerId,
    address nftTokenAddress,
    uint256 nftTokenId,
    uint256 nftTokenAmount
  ) external;

  function onCovalentBreak(
    address contractAddress,
    uint256 tokenId,
    string calldata managerId,
    address nftTokenAddress,
    uint256 nftTokenId,
    uint256 nftTokenAmount
  ) external;

  function onProtonSale(
    address contractAddress,
    uint256 tokenId,
    address oldOwner,
    address newOwner,
    uint256 salePrice,
    address creator,
    uint256 creatorRoyalties
  ) external;
}

File 7 of 37 : IChargedState.sol
// SPDX-License-Identifier: MIT

// IChargedSettings.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

import "./IChargedSettings.sol";

/**
 * @notice Interface for Charged State
 */
interface IChargedState {

  /***********************************|
  |             Public API            |
  |__________________________________*/

  function getDischargeTimelockExpiry(address contractAddress, uint256 tokenId) external view returns (uint256 lockExpiry);
  function getReleaseTimelockExpiry(address contractAddress, uint256 tokenId) external view returns (uint256 lockExpiry);
  function getBreakBondTimelockExpiry(address contractAddress, uint256 tokenId) external view returns (uint256 lockExpiry);

  function isApprovedForDischarge(address contractAddress, uint256 tokenId, address operator) external returns (bool);
  function isApprovedForRelease(address contractAddress, uint256 tokenId, address operator) external returns (bool);
  function isApprovedForBreakBond(address contractAddress, uint256 tokenId, address operator) external returns (bool);
  function isApprovedForTimelock(address contractAddress, uint256 tokenId, address operator) external returns (bool);

  function isEnergizeRestricted(address contractAddress, uint256 tokenId) external view returns (bool);
  function isCovalentBondRestricted(address contractAddress, uint256 tokenId) external view returns (bool);

  function getDischargeState(address contractAddress, uint256 tokenId, address sender) external
    returns (bool allowFromAll, bool isApproved, uint256 timelock, uint256 tempLockExpiry);
  function getReleaseState(address contractAddress, uint256 tokenId, address sender) external
    returns (bool allowFromAll, bool isApproved, uint256 timelock, uint256 tempLockExpiry);
  function getBreakBondState(address contractAddress, uint256 tokenId, address sender) external
    returns (bool allowFromAll, bool isApproved, uint256 timelock, uint256 tempLockExpiry);

  /***********************************|
  |      Only NFT Owner/Operator      |
  |__________________________________*/

  function setDischargeApproval(address contractAddress, uint256 tokenId, address operator) external;
  function setReleaseApproval(address contractAddress, uint256 tokenId, address operator) external;
  function setBreakBondApproval(address contractAddress, uint256 tokenId, address operator) external;
  function setTimelockApproval(address contractAddress, uint256 tokenId, address operator) external;
  function setApprovalForAll(address contractAddress, uint256 tokenId, address operator) external;

  function setPermsForRestrictCharge(address contractAddress, uint256 tokenId, bool state) external;
  function setPermsForAllowDischarge(address contractAddress, uint256 tokenId, bool state) external;
  function setPermsForAllowRelease(address contractAddress, uint256 tokenId, bool state) external;
  function setPermsForRestrictBond(address contractAddress, uint256 tokenId, bool state) external;
  function setPermsForAllowBreakBond(address contractAddress, uint256 tokenId, bool state) external;

  function setDischargeTimelock(
    address contractAddress,
    uint256 tokenId,
    uint256 unlockBlock
  ) external;

  function setReleaseTimelock(
    address contractAddress,
    uint256 tokenId,
    uint256 unlockBlock
  ) external;

  function setBreakBondTimelock(
    address contractAddress,
    uint256 tokenId,
    uint256 unlockBlock
  ) external;

  /***********************************|
  |         Only NFT Contract         |
  |__________________________________*/

  function setTemporaryLock(
    address contractAddress,
    uint256 tokenId,
    bool isLocked
  ) external;

  /***********************************|
  |          Particle Events          |
  |__________________________________*/

  event Initialized(address indexed initiator);
  event ControllerSet(address indexed controllerAddress, string controllerId);

  event DischargeApproval(address indexed contractAddress, uint256 indexed tokenId, address indexed owner, address operator);
  event ReleaseApproval(address indexed contractAddress, uint256 indexed tokenId, address indexed owner, address operator);
  event BreakBondApproval(address indexed contractAddress, uint256 indexed tokenId, address indexed owner, address operator);
  event TimelockApproval(address indexed contractAddress, uint256 indexed tokenId, address indexed owner, address operator);

  event TokenDischargeTimelock(address indexed contractAddress, uint256 indexed tokenId, address indexed operator, uint256 unlockBlock);
  event TokenReleaseTimelock(address indexed contractAddress, uint256 indexed tokenId, address indexed operator, uint256 unlockBlock);
  event TokenBreakBondTimelock(address indexed contractAddress, uint256 indexed tokenId, address indexed operator, uint256 unlockBlock);
  event TokenTempLock(address indexed contractAddress, uint256 indexed tokenId, uint256 unlockBlock);

  event PermsSetForRestrictCharge(address indexed contractAddress, uint256 indexed tokenId, bool state);
  event PermsSetForAllowDischarge(address indexed contractAddress, uint256 indexed tokenId, bool state);
  event PermsSetForAllowRelease(address indexed contractAddress, uint256 indexed tokenId, bool state);
  event PermsSetForRestrictBond(address indexed contractAddress, uint256 indexed tokenId, bool state);
  event PermsSetForAllowBreakBond(address indexed contractAddress, uint256 indexed tokenId, bool state);
}

File 8 of 37 : IChargedSettings.sol
// SPDX-License-Identifier: MIT

// IChargedSettings.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

import "./IWalletManager.sol";
import "./IBasketManager.sol";

/**
 * @notice Interface for Charged Settings
 */
interface IChargedSettings {

  /***********************************|
  |             Public API            |
  |__________________________________*/

  // function isContractOwner(address contractAddress, address account) external view returns (bool);
  function getCreatorAnnuities(address contractAddress, uint256 tokenId) external returns (address creator, uint256 annuityPct);
  function getCreatorAnnuitiesRedirect(address contractAddress, uint256 tokenId) external view returns (address);
  function getTempLockExpiryBlocks() external view returns (uint256);
  function getTimelockApprovals(address operator) external view returns (bool timelockAny, bool timelockOwn);
  function getAssetRequirements(
    address contractAddress,
    address assetToken
  ) external view returns (
    string memory requiredWalletManager,
    bool energizeEnabled,
    bool restrictedAssets,
    bool validAsset,
    uint256 depositCap,
    uint256 depositMin,
    uint256 depositMax,
    bool invalidAsset
  );
  function getNftAssetRequirements(
    address contractAddress,
    address nftTokenAddress
  ) external view returns (
    string memory requiredBasketManager,
    bool basketEnabled,
    uint256 maxNfts
  );

  /***********************************|
  |         Only NFT Creator          |
  |__________________________________*/

  function setCreatorAnnuities(address contractAddress, uint256 tokenId, address creator, uint256 annuityPercent) external;
  function setCreatorAnnuitiesRedirect(address contractAddress, uint256 tokenId, address receiver) external;


  /***********************************|
  |      Only NFT Contract Owner      |
  |__________________________________*/

  function setRequiredWalletManager(address contractAddress, string calldata walletManager) external;
  function setRequiredBasketManager(address contractAddress, string calldata basketManager) external;
  function setAssetTokenRestrictions(address contractAddress, bool restrictionsEnabled) external;
  function setAllowedAssetToken(address contractAddress, address assetToken, bool isAllowed) external;
  function setAssetTokenLimits(address contractAddress, address assetToken, uint256 depositMin, uint256 depositMax) external;
  function setMaxNfts(address contractAddress, address nftTokenAddress, uint256 maxNfts) external;

  /***********************************|
  |          Only Admin/DAO           |
  |__________________________________*/

  function setAssetInvalidity(address assetToken, bool invalidity) external;
  function enableNftContracts(address[] calldata contracts) external;
  function setPermsForCharge(address contractAddress, bool state) external;
  function setPermsForBasket(address contractAddress, bool state) external;
  function setPermsForTimelockAny(address contractAddress, bool state) external;
  function setPermsForTimelockSelf(address contractAddress, bool state) external;

  /***********************************|
  |          Particle Events          |
  |__________________________________*/

  event Initialized(address indexed initiator);
  event ControllerSet(address indexed controllerAddress, string controllerId);
  event DepositCapSet(address assetToken, uint256 depositCap);
  event TempLockExpirySet(uint256 expiryBlocks);

  event RequiredWalletManagerSet(address indexed contractAddress, string walletManager);
  event RequiredBasketManagerSet(address indexed contractAddress, string basketManager);
  event AssetTokenRestrictionsSet(address indexed contractAddress, bool restrictionsEnabled);
  event AllowedAssetTokenSet(address indexed contractAddress, address assetToken, bool isAllowed);
  event AssetTokenLimitsSet(address indexed contractAddress, address assetToken, uint256 assetDepositMin, uint256 assetDepositMax);
  event MaxNftsSet(address indexed contractAddress, address indexed nftTokenAddress, uint256 maxNfts);
  event AssetInvaliditySet(address indexed assetToken, bool invalidity);

  event TokenCreatorConfigsSet(address indexed contractAddress, uint256 indexed tokenId, address indexed creatorAddress, uint256 annuityPercent);
  event TokenCreatorAnnuitiesRedirected(address indexed contractAddress, uint256 indexed tokenId, address indexed redirectAddress);

  event PermsSetForCharge(address indexed contractAddress, bool state);
  event PermsSetForBasket(address indexed contractAddress, bool state);
  event PermsSetForTimelockAny(address indexed contractAddress, bool state);
  event PermsSetForTimelockSelf(address indexed contractAddress, bool state);
}

File 9 of 37 : IChargedParticles.sol
// SPDX-License-Identifier: MIT

// IChargedParticles.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

/**
 * @notice Interface for Charged Particles
 */
interface IChargedParticles {

  /***********************************|
  |             Public API            |
  |__________________________________*/

  function getStateAddress() external view returns (address stateAddress);
  function getSettingsAddress() external view returns (address settingsAddress);
  function getManagersAddress() external view returns (address managersAddress);

  function getFeesForDeposit(uint256 assetAmount) external view returns (uint256 protocolFee);
  function baseParticleMass(address contractAddress, uint256 tokenId, string calldata walletManagerId, address assetToken) external returns (uint256);
  function currentParticleCharge(address contractAddress, uint256 tokenId, string calldata walletManagerId, address assetToken) external returns (uint256);
  function currentParticleKinetics(address contractAddress, uint256 tokenId, string calldata walletManagerId, address assetToken) external returns (uint256);
  function currentParticleCovalentBonds(address contractAddress, uint256 tokenId, string calldata basketManagerId) external view returns (uint256);

  /***********************************|
  |        Particle Mechanics         |
  |__________________________________*/

  function energizeParticle(
      address contractAddress,
      uint256 tokenId,
      string calldata walletManagerId,
      address assetToken,
      uint256 assetAmount,
      address referrer
  ) external returns (uint256 yieldTokensAmount);

  function dischargeParticle(
      address receiver,
      address contractAddress,
      uint256 tokenId,
      string calldata walletManagerId,
      address assetToken
  ) external returns (uint256 creatorAmount, uint256 receiverAmount);

  function dischargeParticleAmount(
      address receiver,
      address contractAddress,
      uint256 tokenId,
      string calldata walletManagerId,
      address assetToken,
      uint256 assetAmount
  ) external returns (uint256 creatorAmount, uint256 receiverAmount);

  function dischargeParticleForCreator(
      address receiver,
      address contractAddress,
      uint256 tokenId,
      string calldata walletManagerId,
      address assetToken,
      uint256 assetAmount
  ) external returns (uint256 receiverAmount);

  function releaseParticle(
      address receiver,
      address contractAddress,
      uint256 tokenId,
      string calldata walletManagerId,
      address assetToken
  ) external returns (uint256 creatorAmount, uint256 receiverAmount);

  function releaseParticleAmount(
    address receiver,
    address contractAddress,
    uint256 tokenId,
    string calldata walletManagerId,
    address assetToken,
    uint256 assetAmount
  ) external returns (uint256 creatorAmount, uint256 receiverAmount);

  function covalentBond(
    address contractAddress,
    uint256 tokenId,
    string calldata basketManagerId,
    address nftTokenAddress,
    uint256 nftTokenId,
    uint256 nftTokenAmount
  ) external returns (bool success);

  function breakCovalentBond(
    address receiver,
    address contractAddress,
    uint256 tokenId,
    string calldata basketManagerId,
    address nftTokenAddress,
    uint256 nftTokenId,
    uint256 nftTokenAmount
  ) external returns (bool success);

  /***********************************|
  |          Particle Events          |
  |__________________________________*/

  event Initialized(address indexed initiator);
  event ControllerSet(address indexed controllerAddress, string controllerId);
  event DepositFeeSet(uint256 depositFee);
  event ProtocolFeesCollected(address indexed assetToken, uint256 depositAmount, uint256 feesCollected);
}

File 10 of 37 : IProtonB.sol
// SPDX-License-Identifier: MIT

// Proton.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

import "../interfaces/IUniverse.sol";
import "../interfaces/IChargedState.sol";
import "../interfaces/IChargedSettings.sol";
import "../interfaces/IChargedParticles.sol";

import "../lib/BlackholePrevention.sol";
import "../lib/RelayRecipient.sol";


interface IProtonB is IERC721 {
  event UniverseSet(address indexed universe);
  event ChargedStateSet(address indexed chargedState);
  event ChargedSettingsSet(address indexed chargedSettings);
  event ChargedParticlesSet(address indexed chargedParticles);

  /***********************************|
  |              Public               |
  |__________________________________*/

  function createProtonForSale(
    address creator,
    address receiver,
    string memory tokenMetaUri,
    uint256 annuityPercent,
    uint256 royaltiesPercent,
    uint256 salePrice
  ) external returns (uint256 newTokenId);

  function createChargedParticle(
    address creator,
    address receiver,
    address referrer,
    string memory tokenMetaUri,
    string memory walletManagerId,
    address assetToken,
    uint256 assetAmount,
    uint256 annuityPercent
  ) external returns (uint256 newTokenId);
}

File 11 of 37 : BaseProton.sol
// SPDX-License-Identifier: MIT

// ProtonB.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "../lib/ERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

import "../interfaces/IBaseProton.sol";
import "../lib/TokenInfo.sol";
import "../lib/BlackholePrevention.sol";
import "../lib/RelayRecipient.sol";

/// @title Base Proton Contract for Charged Particles compatible ERC721 NFTs
/// @dev MUST NOT be Upgradeable, as Upgradeable NFTs are incompatible with Charged Particles.
contract BaseProton is IBaseProton, ERC721, Ownable, RelayRecipient, ReentrancyGuard, BlackholePrevention {
  using SafeMath for uint256;
  using TokenInfo for address payable;
  using Counters for Counters.Counter;

  uint256 constant internal PERCENTAGE_SCALE = 1e4;   // 10000  (100%)

  /// @dev Sequential Token IDs storage
  Counters.Counter internal _tokenIds;

  /// @dev NFT Token Creator settings
  mapping (uint256 => address) internal _tokenCreator;
  mapping (uint256 => uint256) internal _tokenCreatorRoyaltiesPct;
  mapping (uint256 => address) internal _tokenCreatorRoyaltiesRedirect;
  mapping (address => uint256) internal _tokenCreatorClaimableRoyalties;

  /// @dev NFT Token Sale settings
  mapping (uint256 => uint256) internal _tokenSalePrice;
  mapping (uint256 => uint256) internal _tokenLastSellPrice;

  /// @dev Whether of not the Contract is Paused
  bool internal _paused;


  /***********************************|
  |          Initialization           |
  |__________________________________*/

  /// @dev Inherit from ERC721 standard
  constructor(string memory _name, string memory _symbol) public ERC721(_name, _symbol) {}


  /***********************************|
  |              Public               |
  |__________________________________*/

  /// Returns the Creator address of an NFT by Token ID
  /// @param tokenId The ID of the NFT Token to lookup
  /// @return The address of the Creator account
  function creatorOf(uint256 tokenId) external view virtual override returns (address) {
    return _tokenCreator[tokenId];
  }

  /// Returns the Sale Price of an NFT by Token ID
  /// @param tokenId The ID of the NFT Token to lookup
  /// @return The sale price of the NFT
  function getSalePrice(uint256 tokenId) external view virtual override returns (uint256) {
    return _tokenSalePrice[tokenId];
  }

  /// Returns the Last Sale Price of an NFT by Token ID
  /// @notice This is used to determine any increase in sale price used in royalties calculations
  /// @param tokenId The ID of the NFT Token to lookup
  /// @return The last sale price of the NFT
  function getLastSellPrice(uint256 tokenId) external view virtual override returns (uint256) {
    return _tokenLastSellPrice[tokenId];
  }

  /// Returns the Claimable Royalties for the NFT Creator
  /// @param account The address of the Creator account to lookup
  /// @return The amount of earned royalties for the creator account
  function getCreatorRoyalties(address account) external view virtual override returns (uint256) {
    return _tokenCreatorClaimableRoyalties[account];
  }

  /// Returns the Percentage of Royalties reserved for the NFT Creator
  /// @param tokenId The ID of the NFT Token to lookup
  /// @return The percentage of royalties reserved for the creator
  function getCreatorRoyaltiesPct(uint256 tokenId) external view virtual override returns (uint256) {
    return _tokenCreatorRoyaltiesPct[tokenId];
  }

  /// Returns the Receiving address of the Creator Royalties (or Creator if not set)
  /// @dev Returns the creator address if a receiving address has not been configured
  /// @param tokenId The ID of the NFT Token to lookup
  /// @return The Receiving address of the Creator Royalties
  function getCreatorRoyaltiesReceiver(uint256 tokenId) external view virtual override returns (address) {
    return _creatorRoyaltiesReceiver(tokenId);
  }

  /// Allows an NFT Creator to Claim any Royalties that have been earned from NFT sales
  /// @dev Must be called by the royalties receiver account (not neccessarily the creator)
  /// @return The amout of creator royalties claimed
  function claimCreatorRoyalties()
    external
    virtual
    override
    nonReentrant
    whenNotPaused
    returns (uint256)
  {
    return _claimCreatorRoyalties(_msgSender());
  }


  /***********************************|
  |       Create Single Protons       |
  |__________________________________*/

  /// Creates a Basic NFT with no Royalties and no initial Sale Price
  /// @dev Royalties and Sale Price can be configured later
  /// @param creator The address of the NFT Creator (can be different from the caller)
  /// @param receiver The receiving address of the NFT (can be different from the caller)
  /// @param tokenMetaUri The unique metadata URI for the NFT
  /// @return newTokenId The newly minted NFT Token ID
  function createProton(
    address creator,
    address receiver,
    string memory tokenMetaUri
  )
    external
    virtual
    override
    whenNotPaused
    returns (uint256 newTokenId)
  {
    newTokenId = _createProton(
      creator,
      receiver,
      tokenMetaUri,
      0, // royaltiesPercent
      0  // salePrice
    );
  }

  function createProtonForSale(
    address creator,
    address receiver,
    string memory tokenMetaUri,
    uint256 royaltiesPercent,
    uint256 salePrice
  )
    external
    virtual
    override
    whenNotPaused
    returns (uint256 newTokenId)
  {
    newTokenId = _createProton(
      creator,
      receiver,
      tokenMetaUri,
      royaltiesPercent,
      salePrice
    );
  }


  /***********************************|
  |      Create Multiple Protons      |
  |__________________________________*/

  function createProtons(
    address creator,
    address receiver,
    string[] calldata tokenMetaUris
  )
    external
    virtual
    override
    whenNotPaused
    returns (bool)
  {
    _createProtons(
      creator,
      receiver,
      0,  // royaltiesPercent
      tokenMetaUris
    );
    return true;
  }

  function createProtonsForSale(
    address creator,
    address receiver,
    uint256 royaltiesPercent,
    string[] calldata tokenMetaUris,
    uint256[] calldata salePrices
  )
    external
    virtual
    override
    whenNotPaused
    returns (bool)
  {
    _createProtonsForSale(
      creator,
      receiver,
      royaltiesPercent,
      tokenMetaUris,
      salePrices
    );
    return true;
  }


  /***********************************|
  |           Buy Protons             |
  |__________________________________*/

  function buyProton(uint256 tokenId, uint256 gasLimit)
    external
    payable
    virtual
    override
    nonReentrant
    whenNotPaused
    returns (bool)
  {
    _buyProton(tokenId, gasLimit);
    return true;
  }

  /***********************************|
  |     Only Token Creator/Owner      |
  |__________________________________*/

  function setSalePrice(uint256 tokenId, uint256 salePrice)
    external
    virtual
    override
    whenNotPaused
    onlyTokenOwnerOrApproved(tokenId)
  {
    _setSalePrice(tokenId, salePrice);
  }

  function setRoyaltiesPct(uint256 tokenId, uint256 royaltiesPct)
    external
    virtual
    override
    whenNotPaused
    onlyTokenCreator(tokenId)
    onlyTokenOwnerOrApproved(tokenId)
  {
    _setRoyaltiesPct(tokenId, royaltiesPct);
  }

  function setCreatorRoyaltiesReceiver(uint256 tokenId, address receiver)
    external
    virtual
    override
    whenNotPaused
    onlyTokenCreator(tokenId)
  {
    _tokenCreatorRoyaltiesRedirect[tokenId] = receiver;
  }


  /***********************************|
  |          Only Admin/DAO           |
  |__________________________________*/

  function setPausedState(bool state) external virtual onlyOwner {
    _paused = state;
    emit PausedStateSet(state);
  }

  function setTrustedForwarder(address _trustedForwarder) external virtual onlyOwner {
    trustedForwarder = _trustedForwarder;
  }


  /***********************************|
  |          Only Admin/DAO           |
  |      (blackhole prevention)       |
  |__________________________________*/

  function withdrawEther(address payable receiver, uint256 amount) external onlyOwner {
    _withdrawEther(receiver, amount);
  }

  function withdrawErc20(address payable receiver, address tokenAddress, uint256 amount) external onlyOwner {
    _withdrawERC20(receiver, tokenAddress, amount);
  }

  function withdrawERC721(address payable receiver, address tokenAddress, uint256 tokenId) external onlyOwner {
    _withdrawERC721(receiver, tokenAddress, tokenId);
  }


  /***********************************|
  |         Private Functions         |
  |__________________________________*/

  function _setSalePrice(uint256 tokenId, uint256 salePrice) internal virtual {
    _tokenSalePrice[tokenId] = salePrice;
    emit SalePriceSet(tokenId, salePrice);
  }

  function _setRoyaltiesPct(uint256 tokenId, uint256 royaltiesPct) internal virtual {
    require(royaltiesPct <= PERCENTAGE_SCALE, "PRT:E-421");
    _tokenCreatorRoyaltiesPct[tokenId] = royaltiesPct;
    emit CreatorRoyaltiesSet(tokenId, royaltiesPct);
  }

  function _creatorRoyaltiesReceiver(uint256 tokenId) internal view virtual returns (address) {
    address receiver = _tokenCreatorRoyaltiesRedirect[tokenId];
    if (receiver == address(0x0)) {
      receiver = _tokenCreator[tokenId];
    }
    return receiver;
  }

  function _createProton(
    address creator,
    address receiver,
    string memory tokenMetaUri,
    uint256 royaltiesPercent,
    uint256 salePrice
  )
    internal
    virtual
    returns (uint256 newTokenId)
  {
    _tokenIds.increment();

    newTokenId = _tokenIds.current();
    _safeMint(receiver, newTokenId, "");
    _tokenCreator[newTokenId] = creator;

    _setTokenURI(newTokenId, tokenMetaUri);

    if (royaltiesPercent > 0) {
      _setRoyaltiesPct(newTokenId, royaltiesPercent);
    }

    if (salePrice > 0) {
      _setSalePrice(newTokenId, salePrice);
    }
  }

  function _createProtons(
    address creator,
    address receiver,
    uint256 royaltiesPercent,
    string[] calldata tokenMetaUris
  )
    internal
    virtual
  {
    uint256 count = tokenMetaUris.length;
    for (uint256 i; i < count; i++) {
      _createProton(creator, receiver, tokenMetaUris[i], royaltiesPercent, 0);
    }
  }

  function _createProtonsForSale(
    address creator,
    address receiver,
    uint256 royaltiesPercent,
    string[] calldata tokenMetaUris,
    uint256[] calldata salePrices
  )
    internal
    virtual
  {
    require(tokenMetaUris.length == salePrices.length, "PRT:E-202");

    uint256 count = tokenMetaUris.length;
    for (uint256 i; i < count; i++) {
      _createProton(creator, receiver, tokenMetaUris[i], royaltiesPercent, salePrices[i]);
    }
  }

  function _buyProton(uint256 _tokenId, uint256 _gasLimit)
    internal
    virtual
    returns (
      address contractAddress,
      uint256 tokenId,
      address oldOwner,
      address newOwner,
      uint256 salePrice,
      address royaltiesReceiver,
      uint256 creatorAmount
    )
  {
    contractAddress = address(this);
    tokenId = _tokenId;
    salePrice = _tokenSalePrice[_tokenId];
    require(salePrice > 0, "PRT:E-416");
    require(msg.value >= salePrice, "PRT:E-414");

    uint256 ownerAmount = salePrice;
    creatorAmount;
    oldOwner = ownerOf(_tokenId);
    newOwner = _msgSender();

    // Creator Royalties
    royaltiesReceiver = _creatorRoyaltiesReceiver(_tokenId);
    uint256 royaltiesPct = _tokenCreatorRoyaltiesPct[_tokenId];
    uint256 lastSellPrice = _tokenLastSellPrice[_tokenId];
    if (royaltiesPct > 0 && lastSellPrice > 0 && salePrice > lastSellPrice) {
      creatorAmount = (salePrice - lastSellPrice).mul(royaltiesPct).div(PERCENTAGE_SCALE);
      ownerAmount = ownerAmount.sub(creatorAmount);
    }
    _tokenLastSellPrice[_tokenId] = salePrice;

    // Reserve Royalties for Creator
    if (creatorAmount > 0) {
      _tokenCreatorClaimableRoyalties[royaltiesReceiver] = _tokenCreatorClaimableRoyalties[royaltiesReceiver].add(creatorAmount);
    }

    // Transfer Token
    _transfer(oldOwner, newOwner, _tokenId);

    // Transfer Payment
    if (ownerAmount > 0) {
      payable(oldOwner).sendValue(ownerAmount, _gasLimit);
    }

    emit ProtonSold(_tokenId, oldOwner, newOwner, salePrice, royaltiesReceiver, creatorAmount);

    _refundOverpayment(salePrice, _gasLimit);
  }

  /**
    * @dev Pays out the Creator Royalties of the calling account
    * @param receiver  The receiver of the claimable royalties
    * @return          The amount of Creator Royalties claimed
    */
  function _claimCreatorRoyalties(address receiver) internal virtual returns (uint256) {
    uint256 claimableAmount = _tokenCreatorClaimableRoyalties[receiver];
    require(claimableAmount > 0, "PRT:E-411");

    delete _tokenCreatorClaimableRoyalties[receiver];
    payable(receiver).sendValue(claimableAmount, 0);

    emit RoyaltiesClaimed(receiver, claimableAmount);
  }

  /**
    * @dev Collects the Required Asset Token from the users wallet
    * @param from         The owner address to collect the Assets from
    * @param assetAmount  The Amount of Asset Tokens to Collect
    */
  function _collectAssetToken(address from, address assetToken, uint256 assetAmount) internal virtual {
    uint256 _userAssetBalance = IERC20(assetToken).balanceOf(from);
    require(assetAmount <= _userAssetBalance, "PRT:E-411");
    // Be sure to Approve this Contract to transfer your Asset Token
    require(IERC20(assetToken).transferFrom(from, address(this), assetAmount), "PRT:E-401");
  }

  function _refundOverpayment(uint256 threshold, uint256 gasLimit) internal virtual {
    uint256 overage = msg.value.sub(threshold);
    if (overage > 0) {
      payable(_msgSender()).sendValue(overage, gasLimit);
    }
  }

  function _transfer(address from, address to, uint256 tokenId) internal virtual override {
    _tokenSalePrice[tokenId] = 0;
    super._transfer(from, to, tokenId);
  }


  /***********************************|
  |          GSN/MetaTx Relay         |
  |__________________________________*/

  /// @dev See {BaseRelayRecipient-_msgSender}.
  function _msgSender()
    internal
    view
    virtual
    override(BaseRelayRecipient, Context)
    returns (address payable)
  {
    return BaseRelayRecipient._msgSender();
  }

  /// @dev See {BaseRelayRecipient-_msgData}.
  function _msgData()
    internal
    view
    virtual
    override(BaseRelayRecipient, Context)
    returns (bytes memory)
  {
    return BaseRelayRecipient._msgData();
  }


  /***********************************|
  |             Modifiers             |
  |__________________________________*/

  modifier whenNotPaused() {
      require(!_paused, "PRT:E-101");
      _;
  }

  modifier onlyTokenOwnerOrApproved(uint256 tokenId) {
    require(_isApprovedOrOwner(_msgSender(), tokenId), "PRT:E-105");
    _;
  }

  modifier onlyTokenCreator(uint256 tokenId) {
    require(_tokenCreator[tokenId] == _msgSender(), "PRT:E-104");
    _;
  }
}

File 12 of 37 : TokenInfo.sol
// SPDX-License-Identifier: MIT

// TokenInfo.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity 0.6.12;

import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "../interfaces/IERC721Chargeable.sol";

library TokenInfo {
  function getTokenUUID(address contractAddress, uint256 tokenId) internal pure virtual returns (uint256) {
    return uint256(keccak256(abi.encodePacked(contractAddress, tokenId)));
  }

  /// @dev DEPRECATED; Prefer TokenInfoProxy
  function getTokenOwner(address contractAddress, uint256 tokenId) internal view virtual returns (address) {
    IERC721Chargeable tokenInterface = IERC721Chargeable(contractAddress);
    return tokenInterface.ownerOf(tokenId);
  }

  /// @dev DEPRECATED; Prefer TokenInfoProxy
  function getTokenCreator(address contractAddress, uint256 tokenId) internal view virtual returns (address) {
    IERC721Chargeable tokenInterface = IERC721Chargeable(contractAddress);
    return tokenInterface.creatorOf(tokenId);
  }

  /// @dev DEPRECATED; Prefer TokenInfoProxy
  /// @dev Checks if an account is the Owner of an External NFT contract
  /// @param contractAddress  The Address to the Contract of the NFT to check
  /// @param account          The Address of the Account to check
  /// @return True if the account owns the contract
  function isContractOwner(address contractAddress, address account) internal view virtual returns (bool) {
    address contractOwner = IERC721Chargeable(contractAddress).owner();
    return contractOwner != address(0x0) && contractOwner == account;
  }

  /// @dev DEPRECATED; Prefer TokenInfoProxy
  /// @dev Checks if an account is the Creator of a Proton-based NFT
  /// @param contractAddress  The Address to the Contract of the Proton-based NFT to check
  /// @param tokenId          The Token ID of the Proton-based NFT to check
  /// @param sender           The Address of the Account to check
  /// @return True if the account is the creator of the Proton-based NFT
  function isTokenCreator(address contractAddress, uint256 tokenId, address sender) internal view virtual returns (bool) {
    IERC721Chargeable tokenInterface = IERC721Chargeable(contractAddress);
    address tokenCreator = tokenInterface.creatorOf(tokenId);
    return (sender == tokenCreator);
  }

  /// @dev DEPRECATED; Prefer TokenInfoProxy
  /// @dev Checks if an account is the Creator of a Proton-based NFT or the Contract itself
  /// @param contractAddress  The Address to the Contract of the Proton-based NFT to check
  /// @param tokenId          The Token ID of the Proton-based NFT to check
  /// @param sender           The Address of the Account to check
  /// @return True if the account is the creator of the Proton-based NFT or the Contract itself
  function isTokenContractOrCreator(address contractAddress, uint256 tokenId, address creator, address sender) internal view virtual returns (bool) {
    IERC721Chargeable tokenInterface = IERC721Chargeable(contractAddress);
    address tokenCreator = tokenInterface.creatorOf(tokenId);
    if (sender == contractAddress && creator == tokenCreator) { return true; }
    return (sender == tokenCreator);
  }

  /// @dev DEPRECATED; Prefer TokenInfoProxy
  /// @dev Checks if an account is the Owner or Operator of an External NFT
  /// @param contractAddress  The Address to the Contract of the External NFT to check
  /// @param tokenId          The Token ID of the External NFT to check
  /// @param sender           The Address of the Account to check
  /// @return True if the account is the Owner or Operator of the External NFT
  function isErc721OwnerOrOperator(address contractAddress, uint256 tokenId, address sender) internal view virtual returns (bool) {
    IERC721Chargeable tokenInterface = IERC721Chargeable(contractAddress);
    address tokenOwner = tokenInterface.ownerOf(tokenId);
    return (sender == tokenOwner || tokenInterface.isApprovedForAll(tokenOwner, sender));
  }

  /**
    * @dev Returns true if `account` is a contract.
    * @dev Taken from OpenZeppelin library
    *
    * [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) {
    // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
    // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
    // for accounts without code, i.e. `keccak256('')`
    bytes32 codehash;
    bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
    // solhint-disable-next-line no-inline-assembly
    assembly { codehash := extcodehash(account) }
    return (codehash != accountHash && codehash != 0x0);
  }

  /**
    * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
    * `recipient`, forwarding all available gas and reverting on errors.
    * @dev Taken from OpenZeppelin library
    *
    * 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, uint256 gasLimit) internal {
    require(address(this).balance >= amount, "TokenInfo: insufficient balance");

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

File 13 of 37 : BlackholePrevention.sol
// SPDX-License-Identifier: MIT

// BlackholePrevention.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

/**
 * @notice Prevents ETH or Tokens from getting stuck in a contract by allowing
 *  the Owner/DAO to pull them out on behalf of a user
 * This is only meant to contracts that are not expected to hold tokens, but do handle transferring them.
 */
contract BlackholePrevention {
  using Address for address payable;
  using SafeERC20 for IERC20;

  event WithdrawStuckEther(address indexed receiver, uint256 amount);
  event WithdrawStuckERC20(address indexed receiver, address indexed tokenAddress, uint256 amount);
  event WithdrawStuckERC721(address indexed receiver, address indexed tokenAddress, uint256 indexed tokenId);
  event WithdrawStuckERC1155(address indexed receiver, address indexed tokenAddress, uint256 indexed tokenId, uint256 amount);

  function _withdrawEther(address payable receiver, uint256 amount) internal virtual {
    require(receiver != address(0x0), "BHP:E-403");
    if (address(this).balance >= amount) {
      receiver.sendValue(amount);
      emit WithdrawStuckEther(receiver, amount);
    }
  }

  function _withdrawERC20(address payable receiver, address tokenAddress, uint256 amount) internal virtual {
    require(receiver != address(0x0), "BHP:E-403");
    if (IERC20(tokenAddress).balanceOf(address(this)) >= amount) {
      IERC20(tokenAddress).safeTransfer(receiver, amount);
      emit WithdrawStuckERC20(receiver, tokenAddress, amount);
    }
  }

  function _withdrawERC721(address payable receiver, address tokenAddress, uint256 tokenId) internal virtual {
    require(receiver != address(0x0), "BHP:E-403");
    if (IERC721(tokenAddress).ownerOf(tokenId) == address(this)) {
      IERC721(tokenAddress).transferFrom(address(this), receiver, tokenId);
      emit WithdrawStuckERC721(receiver, tokenAddress, tokenId);
    }
  }

  function _withdrawERC1155(address payable receiver, address tokenAddress, uint256 tokenId, uint256 amount) internal virtual {
    require(receiver != address(0x0), "BHP:E-403");
    if (IERC1155(tokenAddress).balanceOf(address(this), tokenId) >= amount) {
      IERC1155(tokenAddress).safeTransferFrom(address(this), receiver, tokenId, amount, "");
      emit WithdrawStuckERC1155(receiver, tokenAddress, tokenId, amount);
    }
  }
}

File 14 of 37 : RelayRecipient.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0;

import "@opengsn/gsn/contracts/BaseRelayRecipient.sol";

contract RelayRecipient is BaseRelayRecipient {
  function versionRecipient() external override view returns (string memory) {
    return "1.0.0-beta.1/charged-particles.relay.recipient";
  }
}

File 15 of 37 : IWalletManager.sol
// SPDX-License-Identifier: MIT

// IWalletManager.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

/**
 * @title Particle Wallet Manager interface
 * @dev The wallet-manager for underlying assets attached to Charged Particles
 * @dev Manages the link between NFTs and their respective Smart-Wallets
 */
interface IWalletManager {

  event ControllerSet(address indexed controller);
  event ExecutorSet(address indexed executor);
  event PausedStateSet(bool isPaused);
  event NewSmartWallet(address indexed contractAddress, uint256 indexed tokenId, address indexed smartWallet, address creator, uint256 annuityPct);
  event WalletEnergized(address indexed contractAddress, uint256 indexed tokenId, address indexed assetToken, uint256 assetAmount, uint256 yieldTokensAmount);
  event WalletDischarged(address indexed contractAddress, uint256 indexed tokenId, address indexed assetToken, uint256 creatorAmount, uint256 receiverAmount);
  event WalletDischargedForCreator(address indexed contractAddress, uint256 indexed tokenId, address indexed assetToken, address creator, uint256 receiverAmount);
  event WalletReleased(address indexed contractAddress, uint256 indexed tokenId, address indexed receiver, address assetToken, uint256 principalAmount, uint256 creatorAmount, uint256 receiverAmount);
  event WalletRewarded(address indexed contractAddress, uint256 indexed tokenId, address indexed receiver, address rewardsToken, uint256 rewardsAmount);

  function isPaused() external view returns (bool);

  function isReserveActive(address contractAddress, uint256 tokenId, address assetToken) external view returns (bool);
  function getReserveInterestToken(address contractAddress, uint256 tokenId, address assetToken) external view returns (address);

  function getTotal(address contractAddress, uint256 tokenId, address assetToken) external returns (uint256);
  function getPrincipal(address contractAddress, uint256 tokenId, address assetToken) external returns (uint256);
  function getInterest(address contractAddress, uint256 tokenId, address assetToken) external returns (uint256 creatorInterest, uint256 ownerInterest);
  function getRewards(address contractAddress, uint256 tokenId, address rewardToken) external returns (uint256);

  function energize(address contractAddress, uint256 tokenId, address assetToken, uint256 assetAmount) external returns (uint256 yieldTokensAmount);
  function discharge(address receiver, address contractAddress, uint256 tokenId, address assetToken, address creatorRedirect) external returns (uint256 creatorAmount, uint256 receiverAmount);
  function dischargeAmount(address receiver, address contractAddress, uint256 tokenId, address assetToken, uint256 assetAmount, address creatorRedirect) external returns (uint256 creatorAmount, uint256 receiverAmount);
  function dischargeAmountForCreator(address receiver, address contractAddress, uint256 tokenId, address creator, address assetToken, uint256 assetAmount) external returns (uint256 receiverAmount);
  function release(address receiver, address contractAddress, uint256 tokenId, address assetToken, address creatorRedirect) external returns (uint256 principalAmount, uint256 creatorAmount, uint256 receiverAmount);
  function releaseAmount(address receiver, address contractAddress, uint256 tokenId, address assetToken, uint256 assetAmount, address creatorRedirect) external returns (uint256 principalAmount, uint256 creatorAmount, uint256 receiverAmount);
  function withdrawRewards(address receiver, address contractAddress, uint256 tokenId, address rewardsToken, uint256 rewardsAmount) external returns (uint256 amount);
  function executeForAccount(address contractAddress, uint256 tokenId, address externalAddress, uint256 ethValue, bytes memory encodedParams) external returns (bytes memory);
  function refreshPrincipal(address contractAddress, uint256 tokenId, address assetToken) external;
  function getWalletAddressById(address contractAddress, uint256 tokenId, address creator, uint256 annuityPct) external returns (address);

  function withdrawEther(address contractAddress, uint256 tokenId, address payable receiver, uint256 amount) external;
  function withdrawERC20(address contractAddress, uint256 tokenId, address payable receiver, address tokenAddress, uint256 amount) external;
  function withdrawERC721(address contractAddress, uint256 tokenId, address payable receiver, address nftTokenAddress, uint256 nftTokenId) external;
}

File 16 of 37 : IBasketManager.sol
// SPDX-License-Identifier: MIT

// IBasketManager.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

/**
 * @title Particle Basket Manager interface
 * @dev The basket-manager for underlying assets attached to Charged Particles
 * @dev Manages the link between NFTs and their respective Smart-Baskets
 */
interface IBasketManager {

  event ControllerSet(address indexed controller);
  event ExecutorSet(address indexed executor);
  event PausedStateSet(bool isPaused);
  event NewSmartBasket(address indexed contractAddress, uint256 indexed tokenId, address indexed smartBasket);
  event BasketAdd(address indexed contractAddress, uint256 indexed tokenId, address basketTokenAddress, uint256 basketTokenId, uint256 basketTokenAmount);
  event BasketRemove(address indexed receiver, address indexed contractAddress, uint256 indexed tokenId, address basketTokenAddress, uint256 basketTokenId, uint256 basketTokenAmount);
  event BasketRewarded(address indexed contractAddress, uint256 indexed tokenId, address indexed receiver, address rewardsToken, uint256 rewardsAmount);

  function isPaused() external view returns (bool);

  function getTokenTotalCount(address contractAddress, uint256 tokenId) external view returns (uint256);
  function getTokenCountByType(address contractAddress, uint256 tokenId, address basketTokenAddress, uint256 basketTokenId) external returns (uint256);

  function prepareTransferAmount(uint256 nftTokenAmount) external;
  function addToBasket(address contractAddress, uint256 tokenId, address basketTokenAddress, uint256 basketTokenId) external returns (bool);
  function removeFromBasket(address receiver, address contractAddress, uint256 tokenId, address basketTokenAddress, uint256 basketTokenId) external returns (bool);
  function withdrawRewards(address receiver, address contractAddress, uint256 tokenId, address rewardsToken, uint256 rewardsAmount) external returns (uint256 amount);
  function executeForAccount(address contractAddress, uint256 tokenId, address externalAddress, uint256 ethValue, bytes memory encodedParams) external returns (bytes memory);
  function getBasketAddressById(address contractAddress, uint256 tokenId) external returns (address);

  function withdrawEther(address contractAddress, uint256 tokenId, address payable receiver, uint256 amount) external;
  function withdrawERC20(address contractAddress, uint256 tokenId, address payable receiver, address tokenAddress, uint256 amount) external;
  function withdrawERC721(address contractAddress, uint256 tokenId, address payable receiver, address nftTokenAddress, uint256 nftTokenId) external;
  function withdrawERC1155(address contractAddress, uint256 tokenId, address payable receiver, address nftTokenAddress, uint256 nftTokenId, uint256 amount) external;
}

File 17 of 37 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

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

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

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

File 18 of 37 : Counters.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 19 of 37 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 20 of 37 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 21 of 37 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transfered 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 22 of 37 : IERC1155.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transfered from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;
}

File 23 of 37 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 24 of 37 : BaseRelayRecipient.sol
// SPDX-License-Identifier:MIT
// solhint-disable no-inline-assembly
pragma solidity ^0.6.2;

import "./interfaces/IRelayRecipient.sol";

/**
 * A base contract to be inherited by any contract that want to receive relayed transactions
 * A subclass must use "_msgSender()" instead of "msg.sender"
 */
abstract contract BaseRelayRecipient is IRelayRecipient {

    /*
     * Forwarder singleton we accept calls from
     */
    address public trustedForwarder;

    function isTrustedForwarder(address forwarder) public override view returns(bool) {
        return forwarder == trustedForwarder;
    }

    /**
     * return the sender of this call.
     * if the call came through our trusted forwarder, return the original sender.
     * otherwise, return `msg.sender`.
     * should be used in the contract anywhere instead of msg.sender
     */
    function _msgSender() internal override virtual view returns (address payable ret) {
        if (msg.data.length >= 24 && isTrustedForwarder(msg.sender)) {
            // At this point we know that the sender is a trusted forwarder,
            // so we trust that the last bytes of msg.data are the verified sender address.
            // extract sender address from the end of msg.data
            assembly {
                ret := shr(96,calldataload(sub(calldatasize(),20)))
            }
        } else {
            return msg.sender;
        }
    }

    /**
     * return the msg.data of this call.
     * if the call came through our trusted forwarder, then the real sender was appended as the last 20 bytes
     * of the msg.data - so this method will strip those 20 bytes off.
     * otherwise, return `msg.data`
     * should be used in the contract instead of msg.data, where the difference matters (e.g. when explicitly
     * signing or hashing the
     */
    function _msgData() internal override virtual view returns (bytes memory ret) {
        if (msg.data.length >= 24 && isTrustedForwarder(msg.sender)) {
            // At this point we know that the sender is a trusted forwarder,
            // we copy the msg.data , except the last 20 bytes (and update the total length)
            assembly {
                let ptr := mload(0x40)
                // copy only size-20 bytes
                let size := sub(calldatasize(),20)
                // structure RLP data as <offset> <length> <bytes>
                mstore(ptr, 0x20)
                mstore(add(ptr,32), size)
                calldatacopy(add(ptr,64), 0, size)
                return(ptr, add(size,64))
            }
        } else {
            return msg.data;
        }
    }
}

File 25 of 37 : IRelayRecipient.sol
// SPDX-License-Identifier:MIT
pragma solidity ^0.6.2;

/**
 * a contract must implement this interface in order to support relayed transaction.
 * It is better to inherit the BaseRelayRecipient as its implementation.
 */
abstract contract IRelayRecipient {

    /**
     * return if the forwarder is trusted to forward relayed transactions to us.
     * the forwarder is required to verify the sender's signature, and verify
     * the call is not a replay.
     */
    function isTrustedForwarder(address forwarder) public virtual view returns(bool);

    /**
     * return the sender of this call.
     * if the call came through our trusted forwarder, then the real sender is appended as the last 20 bytes
     * of the msg.data.
     * otherwise, return `msg.sender`
     * should be used in the contract anywhere instead of msg.sender
     */
    function _msgSender() internal virtual view returns (address payable);

    /**
     * return the msg.data of this call.
     * if the call came through our trusted forwarder, then the real sender was appended as the last 20 bytes
     * of the msg.data - so this method will strip those 20 bytes off.
     * otherwise, return `msg.data`
     * should be used in the contract instead of msg.data, where the difference matters (e.g. when explicitly
     * signing or hashing the
     */
    function _msgData() internal virtual view returns (bytes memory);

    function versionRecipient() external virtual view returns (string memory);
}

File 26 of 37 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "@openzeppelin/contracts/GSN/Context.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/introspection/ERC165.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/EnumerableSet.sol";
import "@openzeppelin/contracts/utils/EnumerableMap.sol";
import "@openzeppelin/contracts/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;

    /**
     * @dev Emitted when `tokenId` token is transfered from `from` to `to`.
     */
    event TransferBatch(address indexed from, address indexed to, uint256 startTokenId, uint256 count);

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

    /*
     *     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 ^ 0xe985e9c ^ 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) public {
        _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 override returns (uint256) {
        require(owner != address(0), "ERC721:E-403");

        return _holderTokens[owner].length();
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view override returns (address) {
        return _tokenOwners.get(tokenId, "ERC721:E-405");
    }

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

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

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view override returns (string memory) {
        require(_exists(tokenId), "ERC721:E-405");
        return _tokenURIs[tokenId];
    }

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

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view 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 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 = ownerOf(tokenId);
        require(to != owner, "ERC721:E-111");

        require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721:E-105");

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view override returns (address) {
        require(_exists(tokenId), "ERC721:E-405");

        return _tokenApprovals[tokenId];
    }

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

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

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view 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:E-105");

        _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:E-105");
        _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 mecanisms 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:E-402");
    }

    /**
     * @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 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 returns (bool) {
        require(_exists(tokenId), "ERC721:E-405");
        address owner = ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
    }

    /**
     * @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:E-402");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMintBatch(address to, uint256 startTokenId, uint256 count, bytes memory _data) internal virtual {
        _mintBatch(to, startTokenId, count);
        require(_checkOnERC721Received(address(0), to, startTokenId, _data), "ERC721:E-402");
    }

    /**
     * @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:E-403");
        require(!_exists(tokenId), "ERC721:E-407");

        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

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

    /**
     * @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 _mintBatch(address to, uint256 startTokenId, uint256 count) internal virtual {
        require(to != address(0), "ERC721:E-403");
        require(!_exists(startTokenId), "ERC721:E-407");

        for (uint i = 0; i < count; i++) {
          uint256 tokenId = startTokenId.add(i);
          _holderTokens[to].add(tokenId);
          _tokenOwners.set(tokenId, to);
        }

        emit TransferBatch(address(0), to, startTokenId, count);
    }

    /**
     * @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(ownerOf(tokenId) == from, "ERC721:E-102");
        require(to != address(0), "ERC721:E-403");

        // 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), "ERC721:E-405");
        _tokenURIs[tokenId] = _tokenURI;
    }

    /**
     * @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:E-402");
        bytes4 retval = abi.decode(returndata, (bytes4));
        return (retval == _ERC721_RECEIVED);
    }

    function _approve(address to, uint256 tokenId) private {
        _tokenApprovals[tokenId] = to;
        emit Approval(ownerOf(tokenId), to, tokenId);
    }
}

File 27 of 37 : IBaseProton.sol
// SPDX-License-Identifier: MIT

// Proton.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

import "../lib/BlackholePrevention.sol";
import "../lib/RelayRecipient.sol";


interface IBaseProton is IERC721 {
  event PausedStateSet(bool isPaused);
  event SalePriceSet(uint256 indexed tokenId, uint256 salePrice);
  event CreatorRoyaltiesSet(uint256 indexed tokenId, uint256 royaltiesPct);
  event FeesWithdrawn(address indexed receiver, uint256 amount);
  event ProtonSold(uint256 indexed tokenId, address indexed oldOwner, address indexed newOwner, uint256 salePrice, address creator, uint256 creatorRoyalties);
  event RoyaltiesClaimed(address indexed receiver, uint256 amountClaimed);

  /***********************************|
  |              Public               |
  |__________________________________*/

  function creatorOf(uint256 tokenId) external view returns (address);
  function getSalePrice(uint256 tokenId) external view returns (uint256);
  function getLastSellPrice(uint256 tokenId) external view returns (uint256);
  function getCreatorRoyalties(address account) external view returns (uint256);
  function getCreatorRoyaltiesPct(uint256 tokenId) external view returns (uint256);
  function getCreatorRoyaltiesReceiver(uint256 tokenId) external view returns (address);

  function buyProton(uint256 tokenId, uint256 gasLimit) external payable returns (bool);
  function claimCreatorRoyalties() external returns (uint256);

  function createProton(
    address creator,
    address receiver,
    string memory tokenMetaUri
  ) external returns (uint256 newTokenId);

  function createProtonForSale(
    address creator,
    address receiver,
    string memory tokenMetaUri,
    uint256 royaltiesPercent,
    uint256 salePrice
  ) external returns (uint256 newTokenId);

  function createProtons(
    address creator,
    address receiver,
    string[] calldata tokenMetaUris
  ) external returns (bool);

  function createProtonsForSale(
    address creator,
    address receiver,
    uint256 royaltiesPercent,
    string[] calldata tokenMetaUris,
    uint256[] calldata salePrices
  ) external returns (bool);

  /***********************************|
  |     Only Token Creator/Owner      |
  |__________________________________*/

  function setSalePrice(uint256 tokenId, uint256 salePrice) external;
  function setRoyaltiesPct(uint256 tokenId, uint256 royaltiesPct) external;
  function setCreatorRoyaltiesReceiver(uint256 tokenId, address receiver) external;
}

File 28 of 37 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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 29 of 37 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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 30 of 37 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 31 of 37 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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.
 */
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 () internal {
        // 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 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;
    }
}

File 32 of 37 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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.0.0, only sets of type `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];
    }

    // 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(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(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(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(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 33 of 37 : EnumerableMap.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 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) {
        return _get(map, key, "EnumerableMap: nonexistent key");
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     */
    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(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(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(uint256(_get(map._inner, bytes32(key))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     */
    function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
        return address(uint256(_get(map._inner, bytes32(key), errorMessage)));
    }
}

File 34 of 37 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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--] = byte(uint8(48 + temp % 10));
            temp /= 10;
        }
        return string(buffer);
    }
}

File 35 of 37 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `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 36 of 37 : IERC721Chargeable.sol
// SPDX-License-Identifier: MIT

// IERC721Chargeable.sol -- Part of the Charged Particles Protocol
// Copyright (c) 2021 Firma Lux, Inc. <https://charged.fi>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

pragma solidity >=0.6.0;

import "@openzeppelin/contracts-upgradeable/introspection/IERC165Upgradeable.sol";

interface IERC721Chargeable is IERC165Upgradeable {
    function owner() external view returns (address);
    function creatorOf(uint256 tokenId) external view returns (address);
    function balanceOf(address tokenOwner) external view returns (uint256 balance);
    function ownerOf(uint256 tokenId) external view returns (address tokenOwner);
    function safeTransferFrom(address from, address to, uint256 tokenId) external;
    function transferFrom(address from, address to, uint256 tokenId) external;
    function approve(address to, uint256 tokenId) external;
    function getApproved(uint256 tokenId) external view returns (address operator);
    function setApprovalForAll(address operator, bool _approved) external;
    function isApprovedForAll(address tokenOwner, address operator) external view returns (bool);
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}

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

pragma solidity >=0.6.0 <0.8.0;

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

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"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":"address","name":"chargedParticles","type":"address"}],"name":"ChargedParticlesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"chargedSettings","type":"address"}],"name":"ChargedSettingsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"chargedState","type":"address"}],"name":"ChargedStateSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"royaltiesPct","type":"uint256"}],"name":"CreatorRoyaltiesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeesWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PausedStateSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"},{"indexed":false,"internalType":"uint256","name":"salePrice","type":"uint256"},{"indexed":false,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"uint256","name":"creatorRoyalties","type":"uint256"}],"name":"ProtonSold","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountClaimed","type":"uint256"}],"name":"RoyaltiesClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"SalePriceSet","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":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"startTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"count","type":"uint256"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"universe","type":"address"}],"name":"UniverseSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawStuckERC1155","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawStuckERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"WithdrawStuckERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawStuckEther","type":"event"},{"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":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"buyProton","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"claimCreatorRoyalties","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"string","name":"tokenMetaUri","type":"string"}],"name":"createBasicProton","outputs":[{"internalType":"uint256","name":"newTokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"string","name":"tokenMetaUri","type":"string"},{"internalType":"string","name":"walletManagerId","type":"string"},{"internalType":"address","name":"assetToken","type":"address"},{"internalType":"uint256","name":"assetAmount","type":"uint256"},{"internalType":"uint256","name":"annuityPercent","type":"uint256"}],"name":"createChargedParticle","outputs":[{"internalType":"uint256","name":"newTokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"string","name":"tokenMetaUri","type":"string"}],"name":"createProton","outputs":[{"internalType":"uint256","name":"newTokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"string","name":"tokenMetaUri","type":"string"},{"internalType":"uint256","name":"annuityPercent","type":"uint256"},{"internalType":"uint256","name":"royaltiesPercent","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"createProtonForSale","outputs":[{"internalType":"uint256","name":"newTokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"string","name":"tokenMetaUri","type":"string"},{"internalType":"uint256","name":"royaltiesPercent","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"createProtonForSale","outputs":[{"internalType":"uint256","name":"newTokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"string[]","name":"tokenMetaUris","type":"string[]"}],"name":"createProtons","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"royaltiesPercent","type":"uint256"},{"internalType":"string[]","name":"tokenMetaUris","type":"string[]"},{"internalType":"uint256[]","name":"salePrices","type":"uint256[]"}],"name":"createProtonsForSale","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"creatorOf","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":"address","name":"account","type":"address"}],"name":"getCreatorRoyalties","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getCreatorRoyaltiesPct","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getCreatorRoyaltiesReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getLastSellPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getSalePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[],"name":"renounceOwnership","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":"address","name":"chargedParticles","type":"address"}],"name":"setChargedParticles","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"settings","type":"address"}],"name":"setChargedSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"stateController","type":"address"}],"name":"setChargedState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"setCreatorRoyaltiesReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"state","type":"bool"}],"name":"setPausedState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"royaltiesPct","type":"uint256"}],"name":"setRoyaltiesPct","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"setSalePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_trustedForwarder","type":"address"}],"name":"setTrustedForwarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"universe","type":"address"}],"name":"setUniverse","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":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"trustedForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"versionRecipient","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"receiver","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"withdrawERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"receiver","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawErc20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawEther","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b50604080518082018252601b81527f43686172676564205061727469636c6573202d2050726f746f6e42000000000060208083019190915282518084019093526008835267282927aa27a7172160c11b908301529081816200007a6301ffc9a760e01b62000146565b81516200008f9060069060208501906200020a565b508051620000a59060079060208401906200020a565b50620000b86380ac58cd60e01b62000146565b620000ca635b5e139f60e01b62000146565b620000dc63780e9d6360e01b62000146565b5060009050620000eb620001a1565b600980546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350506001600b5550620002dd565b6001600160e01b031980821614156200017c5760405162461bcd60e51b81526004016200017390620002a6565b60405180910390fd5b6001600160e01b0319166000908152602081905260409020805460ff19166001179055565b6000620001b8620001be60201b6200178c1760201c565b90505b90565b600060183610801590620001d85750620001d833620001f6565b15620001ee575060131936013560601c620001bb565b5033620001bb565b600a546001600160a01b0390811691161490565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200024d57805160ff19168380011785556200027d565b828001600101855582156200027d579182015b828111156200027d57825182559160200191906001019062000260565b506200028b9291506200028f565b5090565b5b808211156200028b576000815560010162000290565b6020808252601c908201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604082015260600190565b6140d980620002ed6000396000f3fe6080604052600436106102ae5760003560e01c80636e5559fd11610175578063ad82c42c116100dc578063c95d099811610095578063db9f60ff1161006f578063db9f60ff1461080d578063e985e9c51461082d578063f2fde38b1461084d578063f8eb5fc51461086d576102ae565b8063c95d0998146107ad578063d40e707b146107cd578063da742228146107ed576102ae565b8063ad82c42c146106ed578063ae9704cd1461070d578063b7683e931461072d578063b88d4fde1461074d578063c87b56dd1461076d578063c8c680d51461078d576102ae565b80638da5cb5b1161012e5780638da5cb5b146106435780639390afc71461065857806395d89b41146106785780639848bc761461068d578063a0092b55146106ad578063a22cb465146106cd576102ae565b80636e5559fd1461059957806370a08231146105b9578063715018a6146105d957806371e715f4146105ee5780637da0a8771461060e578063846ec08c14610623576102ae565b80632f745c5911610219578063522f6815116101d2578063522f6815146104e4578063572b6c0514610504578063589a17431461052457806362c51749146105445780636348af34146105645780636352211e14610579576102ae565b80632f745c591461042f5780632fc777971461044f5780634025feb21461046f57806342842e0e1461048f578063486ff0cd146104af5780634f6ccce7146104c4576102ae565b806318160ddd1161026b57806318160ddd1461039a5780631dcd79d4146103bc57806323b872dd146103cf578063250b2c80146103ef5780632b7e237c1461040f5780632c0cd5a31461040f576102ae565b806301ffc9a7146102b3578063053992c5146102e957806306fdde031461030b578063081812fc1461032d578063095ea7b31461035a5780631593dee11461037a575b600080fd5b3480156102bf57600080fd5b506102d36102ce366004613752565b61088d565b6040516102e091906139a0565b60405180910390f35b3480156102f557600080fd5b506103096103043660046137de565b6108ac565b005b34801561031757600080fd5b50610320610915565b6040516102e091906139ab565b34801561033957600080fd5b5061034d61034836600461378a565b6109ac565b6040516102e09190613847565b34801561036657600080fd5b50610309610375366004613300565b6109ef565b34801561038657600080fd5b506103096103953660046132c0565b610a82565b3480156103a657600080fd5b506103af610ac2565b6040516102e09190613fa0565b6102d36103ca3660046137de565b610ad3565b3480156103db57600080fd5b506103096103ea3660046135d3565b610b40565b3480156103fb57600080fd5b506103af61040a36600461378a565b610b72565b34801561041b57600080fd5b506103af61042a366004613485565b610b84565b34801561043b57600080fd5b506103af61044a366004613300565b610bc0565b34801561045b57600080fd5b5061030961046a3660046137ba565b610beb565b34801561047b57600080fd5b5061030961048a3660046132c0565b610c7f565b34801561049b57600080fd5b506103096104aa3660046135d3565b610cbf565b3480156104bb57600080fd5b50610320610cda565b3480156104d057600080fd5b506103af6104df36600461378a565b610cfa565b3480156104f057600080fd5b506103096104ff366004613300565b610d10565b34801561051057600080fd5b506102d361051f366004613288565b610d53565b34801561053057600080fd5b5061034d61053f36600461378a565b610d67565b34801561055057600080fd5b506103af61055f366004613363565b610d82565b34801561057057600080fd5b506103af610df1565b34801561058557600080fd5b5061034d61059436600461378a565b610e58565b3480156105a557600080fd5b506103096105b4366004613288565b610e94565b3480156105c557600080fd5b506103af6105d4366004613288565b610f13565b3480156105e557600080fd5b50610309610f5c565b3480156105fa57600080fd5b5061034d61060936600461378a565b610fdb565b34801561061a57600080fd5b5061034d610fe6565b34801561062f57600080fd5b506103af61063e366004613288565b610ff5565b34801561064f57600080fd5b5061034d611010565b34801561066457600080fd5b506103af610673366004613557565b61101f565b34801561068457600080fd5b506103206110a9565b34801561069957600080fd5b506103af6106a83660046134e5565b61110a565b3480156106b957600080fd5b506102d36106c83660046135e7565b61113d565b3480156106d957600080fd5b506103096106e83660046136ed565b611180565b3480156106f957600080fd5b506103af61070836600461378a565b61124e565b34801561071957600080fd5b50610309610728366004613288565b611260565b34801561073957600080fd5b50610309610748366004613288565b6112e7565b34801561075957600080fd5b50610309610768366004613683565b611366565b34801561077957600080fd5b5061032061078836600461378a565b6113a5565b34801561079957600080fd5b506103096107a83660046137de565b61146b565b3480156107b957600080fd5b506103096107c8366004613288565b611502565b3480156107d957600080fd5b506102d36107e8366004613422565b611581565b3480156107f957600080fd5b50610309610808366004613288565b6115c0565b34801561081957600080fd5b5061030961082836600461371a565b611617565b34801561083957600080fd5b506102d361084836600461332b565b611695565b34801561085957600080fd5b50610309610868366004613288565b6116c3565b34801561087957600080fd5b506103af61088836600461378a565b61177a565b6001600160e01b03191660009081526020819052604090205460ff1690565b60135460ff16156108d85760405162461bcd60e51b81526004016108cf90613e6a565b60405180910390fd5b816108ea6108e46117be565b826117c8565b6109065760405162461bcd60e51b81526004016108cf90613f57565b6109108383611845565b505050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109a15780601f10610976576101008083540402835291602001916109a1565b820191906000526020600020905b81548152906001019060200180831161098457829003601f168201915b505050505090505b90565b60006109b7826118bb565b6109d35760405162461bcd60e51b81526004016108cf90613efa565b506000908152600460205260409020546001600160a01b031690565b60006109fa82610e58565b9050806001600160a01b0316836001600160a01b03161415610a2e5760405162461bcd60e51b81526004016108cf90613f7a565b806001600160a01b0316610a406117be565b6001600160a01b03161480610a5c5750610a5c816108486117be565b610a785760405162461bcd60e51b81526004016108cf90613d7e565b61091083836118c8565b610a8a6117be565b6009546001600160a01b03908116911614610ab75760405162461bcd60e51b81526004016108cf90613cc6565b610910838383611936565b6000610ace6002611a43565b905090565b60006002600b541415610af85760405162461bcd60e51b81526004016108cf90613f20565b6002600b5560135460ff1615610b205760405162461bcd60e51b81526004016108cf90613e6a565b610b2a8383611a4e565b50505050505050600190506001600b5592915050565b610b4b6108e46117be565b610b675760405162461bcd60e51b81526004016108cf90613d7e565b610910838383611b0a565b60009081526012602052604090205490565b60135460009060ff1615610baa5760405162461bcd60e51b81526004016108cf90613e6a565b610bb8848484600080611b7c565b949350505050565b6001600160a01b0382166000908152600160205260408120610be29083611c08565b90505b92915050565b60135460ff1615610c0e5760405162461bcd60e51b81526004016108cf90613e6a565b81610c176117be565b6000828152600d60205260409020546001600160a01b03908116911614610c505760405162461bcd60e51b81526004016108cf90613da4565b506000918252600f602052604090912080546001600160a01b0319166001600160a01b03909216919091179055565b610c876117be565b6009546001600160a01b03908116911614610cb45760405162461bcd60e51b81526004016108cf90613cc6565b610910838383611c14565b61091083838360405180602001604052806000815250611366565b60606040518060600160405280602e8152602001614076602e9139905090565b600080610d08600284611d6f565b509392505050565b610d186117be565b6009546001600160a01b03908116911614610d455760405162461bcd60e51b81526004016108cf90613cc6565b610d4f8282611d8d565b5050565b600a546001600160a01b0390811691161490565b6000908152600d60205260409020546001600160a01b031690565b60006002600b541415610da75760405162461bcd60e51b81526004016108cf90613f20565b6002600b5560135460ff1615610dcf5760405162461bcd60e51b81526004016108cf90613e6a565b610ddf8989898989898989611e11565b6001600b559998505050505050505050565b60006002600b541415610e165760405162461bcd60e51b81526004016108cf90613f20565b6002600b5560135460ff1615610e3e5760405162461bcd60e51b81526004016108cf90613e6a565b610e4e610e496117be565b611ed4565b90506001600b5590565b6000610be5826040518060400160405280600c81526020016b4552433732313a452d34303560a01b8152506002611f789092919063ffffffff16565b610e9c6117be565b6009546001600160a01b03908116911614610ec95760405162461bcd60e51b81526004016108cf90613cc6565b601680546001600160a01b0319166001600160a01b0383169081179091556040517f5ce0e6b7fd36339ee97339831b6c72694ecee88c62aab49919d9cabe0a732e4190600090a250565b60006001600160a01b038216610f3b5760405162461bcd60e51b81526004016108cf90613a69565b6001600160a01b0382166000908152600160205260409020610be590611a43565b610f646117be565b6009546001600160a01b03908116911614610f915760405162461bcd60e51b81526004016108cf90613cc6565b6009546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600980546001600160a01b0319169055565b6000610be582611f8f565b600a546001600160a01b031681565b6001600160a01b031660009081526010602052604090205490565b6009546001600160a01b031690565b600061102e8787878686611b7c565b9050831561109f576015546040516315aea5d760e01b81526001600160a01b03909116906315aea5d79061106c90309085908c908a9060040161390b565b600060405180830381600087803b15801561108657600080fd5b505af115801561109a573d6000803e3d6000fd5b505050505b9695505050505050565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109a15780601f10610976576101008083540402835291602001916109a1565b60135460009060ff16156111305760405162461bcd60e51b81526004016108cf90613e6a565b61109f8686868686611b7c565b60135460009060ff16156111635760405162461bcd60e51b81526004016108cf90613e6a565b61117288888888888888611fc9565b506001979650505050505050565b6111886117be565b6001600160a01b0316826001600160a01b031614156111b95760405162461bcd60e51b81526004016108cf90613f7a565b80600560006111c66117be565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561120a6117be565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161124291906139a0565b60405180910390a35050565b6000908152600e602052604090205490565b6112686117be565b6009546001600160a01b039081169116146112955760405162461bcd60e51b81526004016108cf90613cc6565b60138054610100600160a81b0319166101006001600160a01b038416908102919091179091556040517ff28fa0fe2abe5dad2066ebce6edc9d403e4facb3603e47e6c0e7ea3e57dfe03290600090a250565b6112ef6117be565b6009546001600160a01b0390811691161461131c5760405162461bcd60e51b81526004016108cf90613cc6565b601480546001600160a01b0319166001600160a01b0383169081179091556040517f62ff39aed768a426c7582b6e1062ab2631df1869b2d574e36f8274d2e2b0ab8190600090a250565b6113776113716117be565b836117c8565b6113935760405162461bcd60e51b81526004016108cf90613d7e565b61139f8484848461207b565b50505050565b60606113b0826118bb565b6113cc5760405162461bcd60e51b81526004016108cf90613efa565b60008281526008602090815260409182902080548351601f60026000196101006001861615020190931692909204918201849004840281018401909452808452909183018282801561145f5780601f106114345761010080835404028352916020019161145f565b820191906000526020600020905b81548152906001019060200180831161144257829003601f168201915b50505050509050919050565b60135460ff161561148e5760405162461bcd60e51b81526004016108cf90613e6a565b816114976117be565b6000828152600d60205260409020546001600160a01b039081169116146114d05760405162461bcd60e51b81526004016108cf90613da4565b826114dc6108e46117be565b6114f85760405162461bcd60e51b81526004016108cf90613f57565b61139f84846120ae565b61150a6117be565b6009546001600160a01b039081169116146115375760405162461bcd60e51b81526004016108cf90613cc6565b601580546001600160a01b0319166001600160a01b0383169081179091556040517f7ad4c1bc3e874ec0bf47846feb5648b384e8511dc9e5f9803578c9d2b4ec9e6e90600090a250565b60135460009060ff16156115a75760405162461bcd60e51b81526004016108cf90613e6a565b6115b5858560008686612113565b506001949350505050565b6115c86117be565b6009546001600160a01b039081169116146115f55760405162461bcd60e51b81526004016108cf90613cc6565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b61161f6117be565b6009546001600160a01b0390811691161461164c5760405162461bcd60e51b81526004016108cf90613cc6565b6013805460ff19168215151790556040517fa9bfed3d98385b3777389e321dbde773cf7d335fa604fefbae3dca93564f55869061168a9083906139a0565b60405180910390a150565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6116cb6117be565b6009546001600160a01b039081169116146116f85760405162461bcd60e51b81526004016108cf90613cc6565b6001600160a01b03811661171e5760405162461bcd60e51b81526004016108cf90613a00565b6009546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600980546001600160a01b0319166001600160a01b0392909216919091179055565b60009081526011602052604090205490565b6000601836108015906117a357506117a333610d53565b156117b7575060131936013560601c6109a9565b50336109a9565b6000610ace61178c565b60006117d3826118bb565b6117ef5760405162461bcd60e51b81526004016108cf90613efa565b60006117fa83610e58565b9050806001600160a01b0316846001600160a01b031614806118355750836001600160a01b031661182a846109ac565b6001600160a01b0316145b80610bb85750610bb88185611695565b61184f8282612190565b601454604051636a5fcc8b60e11b81526001600160a01b039091169063d4bf991690611885903090869086151590600401613935565b600060405180830381600087803b15801561189f57600080fd5b505af11580156118b3573d6000803e3d6000fd5b505050505050565b6000610be56002836121d3565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906118fd82610e58565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6001600160a01b03831661195c5760405162461bcd60e51b81526004016108cf90613a46565b6040516370a0823160e01b815281906001600160a01b038416906370a082319061198a903090600401613847565b60206040518083038186803b1580156119a257600080fd5b505afa1580156119b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119da91906137a2565b10610910576119f36001600160a01b03831684836121df565b816001600160a01b0316836001600160a01b03167f6c9d637297625e945b296ff73a71fcfbd0a9e062652b6491a921c4c60194176b83604051611a369190613fa0565b60405180910390a3505050565b6000610be582612235565b6000806000806000806000611a638989612239565b601354969d50949b5092995090975095509350915061010090046001600160a01b031615611afe576013546040516345c984d960e11b81526101009091046001600160a01b031690638b9309b290611acb908a908a908a908a908a908a908a906004016138cb565b600060405180830381600087803b158015611ae557600080fd5b505af1158015611af9573d6000803e3d6000fd5b505050505b92959891949750929550565b601454604051636a5fcc8b60e11b81526001600160a01b039091169063d4bf991690611b3f9030908590600090600401613935565b600060405180830381600087803b158015611b5957600080fd5b505af1158015611b6d573d6000803e3d6000fd5b505050506109108383836123f3565b6000611b88600c61240d565b611b92600c612235565b9050611bae858260405180602001604052806000815250612416565b6000818152600d6020526040902080546001600160a01b0319166001600160a01b038816179055611bdf8185612449565b8215611bef57611bef81846120ae565b8115611bff57611bff8183611845565b95945050505050565b6000610be2838361248d565b6001600160a01b038316611c3a5760405162461bcd60e51b81526004016108cf90613a46565b6040516331a9108f60e11b815230906001600160a01b03841690636352211e90611c68908590600401613fa0565b60206040518083038186803b158015611c8057600080fd5b505afa158015611c94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cb891906132a4565b6001600160a01b03161415610910576040516323b872dd60e01b81526001600160a01b038316906323b872dd90611cf79030908790869060040161388e565b600060405180830381600087803b158015611d1157600080fd5b505af1158015611d25573d6000803e3d6000fd5b5050505080826001600160a01b0316846001600160a01b03167ffefe036cac4ee3a4aca074a81cbcc4376e1484693289078dbec149c890101d5b60405160405180910390a4505050565b6000808080611d7e86866124d2565b909450925050505b9250929050565b6001600160a01b038216611db35760405162461bcd60e51b81526004016108cf90613a46565b804710610d4f57611dcd6001600160a01b0383168261252e565b816001600160a01b03167eddb683bb45cd5d0ad8a200c6fae7152b1c236ee90a4a37db692407f5cc38bd82604051611e059190613fa0565b60405180910390a25050565b6016546000906001600160a01b0316611e3c5760405162461bcd60e51b81526004016108cf90613dfe565b611e4a898988600080611b7c565b90508115611ebb576015546040516315aea5d760e01b81526001600160a01b03909116906315aea5d790611e8890309085908e90889060040161390b565b600060405180830381600087803b158015611ea257600080fd5b505af1158015611eb6573d6000803e3d6000fd5b505050505b611ec8818686868b6125ca565b98975050505050505050565b6001600160a01b03811660009081526010602052604081205480611f0a5760405162461bcd60e51b81526004016108cf90613e47565b6001600160a01b0383166000818152601060205260408120819055611f31919083906126ef565b826001600160a01b03167f8fbbda19f4a70036f6f585dc4160142a8fa2a20ffb9393d23274f78de4e3988882604051611f6a9190613fa0565b60405180910390a250919050565b6000611f858484846127f5565b90505b9392505050565b6000818152600f60205260408120546001600160a01b031680610be55750506000908152600d60205260409020546001600160a01b031690565b828114611fe85760405162461bcd60e51b81526004016108cf90613ac6565b8260005b8181101561207057612067898988888581811061200557fe5b90506020028101906120179190613fc8565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508d92508a91508990508781811061205b57fe5b90506020020135611b7c565b50600101611fec565b505050505050505050565b612086848484611b0a565b61209284848484612854565b61139f5760405162461bcd60e51b81526004016108cf90613be6565b6127108111156120d05760405162461bcd60e51b81526004016108cf90613bc3565b6000828152600e6020526040908190208290555182907fd91bd92b973231f564eaa17c9bc62c86b96a8885f3cdcb990d5a3f0415580d9090611e05908490613fa0565b8060005b818110156121875761217e878786868581811061213057fe5b90506020028101906121429190613fc8565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052508c93509150611b7c9050565b50600101612117565b50505050505050565b600082815260116020526040908190208290555182907fe23ea816dce6d7f5c0b85cbd597e7c3b97b2453791152c0b94e5e5c5f314d2f090611e05908490613fa0565b6000610be2838361293c565b6109108363a9059cbb60e01b84846040516024016121fe9291906138b2565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612954565b5490565b60008281526011602052604081205430918491819081808261226d5760405162461bcd60e51b81526004016108cf90613ba0565b8234101561228d5760405162461bcd60e51b81526004016108cf90613b7d565b826122978a610e58565b95506122a16117be565b94506122ac8a611f8f565b60008b8152600e60209081526040808320546012909252909120549194509081158015906122da5750600081115b80156122e557508086115b15612311576123026127106122fc838903856129e3565b90612a1d565b935061230e8385612a5f565b92505b60008c81526012602052604090208690558315612365576001600160a01b03851660009081526010602052604090205461234b9085612aa1565b6001600160a01b0386166000908152601060205260409020555b61237088888e611b0a565b821561238a5761238a6001600160a01b038916848d6126ef565b866001600160a01b0316886001600160a01b03168d7f71a2ee63bc7695052e3a9837d5a45dd1cc0ce12717e39cef6eb6afb0d91697ed8989896040516123d293929190613fa9565b60405180910390a46123e4868c612ac6565b50505092959891949750929550565b600081815260116020526040812055610910838383612af7565b80546001019055565b6124208383612bfa565b61242d6000848484612854565b6109105760405162461bcd60e51b81526004016108cf90613be6565b612452826118bb565b61246e5760405162461bcd60e51b81526004016108cf90613efa565b6000828152600860209081526040909120825161091092840190613135565b815460009082106124b05760405162461bcd60e51b81526004016108cf906139be565b8260000182815481106124bf57fe5b9060005260206000200154905092915050565b8154600090819083106124f75760405162461bcd60e51b81526004016108cf90613c0c565b600084600001848154811061250857fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b8047101561254e5760405162461bcd60e51b81526004016108cf90613b46565b6000826001600160a01b031682604051612567906109a9565b60006040518083038185875af1925050503d80600081146125a4576040519150601f19603f3d011682016040523d82523d6000602084013e6125a9565b606091505b50509050806109105760405162461bcd60e51b81526004016108cf90613ae9565b6125dc6125d56117be565b8484612cb2565b60165460405163095ea7b360e01b81526001600160a01b038581169263095ea7b392612610929091169086906004016138b2565b602060405180830381600087803b15801561262a57600080fd5b505af115801561263e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126629190613736565b506016546040516305eef16560e11b81526001600160a01b0390911690630bdde2ca9061269d90309089908990899089908990600401613958565b602060405180830381600087803b1580156126b757600080fd5b505af11580156126cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b391906137a2565b8147101561270f5760405162461bcd60e51b81526004016108cf90613c4e565b600080821161277757836001600160a01b03168360405161272f906109a9565b60006040518083038185875af1925050503d806000811461276c576040519150601f19603f3d011682016040523d82523d6000602084013e612771565b606091505b506127d5565b836001600160a01b0316838390604051612790906109a9565b600060405180830381858888f193505050503d80600081146127ce576040519150601f19603f3d011682016040523d82523d6000602084013e6127d3565b606091505b505b5090508061139f5760405162461bcd60e51b81526004016108cf90613cfb565b600082815260018401602052604081205482816128255760405162461bcd60e51b81526004016108cf91906139ab565b5084600001600182038154811061283857fe5b9060005260206000209060020201600101549150509392505050565b6000612868846001600160a01b0316612df1565b61287457506001610bb8565b6060612905630a85bd0160e11b6128896117be565b88878760405160240161289f949392919061385b565b60408051601f19818403018152918152602080830180516001600160e01b03166001600160e01b0319909516949094179093528051808201909152600c81526b22a9219b99189d22969a181960a11b928101929092526001600160a01b03881691612e2a565b905060008180602001905181019061291d919061376e565b6001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b60606129a9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e2a9092919063ffffffff16565b80519091501561091057808060200190518101906129c79190613736565b6109105760405162461bcd60e51b81526004016108cf90613e8d565b6000826129f257506000610be5565b828202828482816129ff57fe5b0414610be25760405162461bcd60e51b81526004016108cf90613c85565b6000610be283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612e39565b6000610be283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612e70565b600082820183811015610be25760405162461bcd60e51b81526004016108cf90613a8f565b6000612ad23484612a5f565b90508015610910576109108183612ae76117be565b6001600160a01b031691906126ef565b826001600160a01b0316612b0a82610e58565b6001600160a01b031614612b305760405162461bcd60e51b81526004016108cf90613e21565b6001600160a01b038216612b565760405162461bcd60e51b81526004016108cf90613a69565b612b616000826118c8565b6001600160a01b0383166000908152600160205260409020612b839082612e9c565b506001600160a01b0382166000908152600160205260409020612ba69082612ea8565b50612bb360028284612eb4565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6001600160a01b038216612c205760405162461bcd60e51b81526004016108cf90613a69565b612c29816118bb565b15612c465760405162461bcd60e51b81526004016108cf90613d58565b6001600160a01b0382166000908152600160205260409020612c689082612ea8565b50612c7560028284612eb4565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6040516370a0823160e01b81526000906001600160a01b038416906370a0823190612ce1908790600401613847565b60206040518083038186803b158015612cf957600080fd5b505afa158015612d0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d3191906137a2565b905080821115612d535760405162461bcd60e51b81526004016108cf90613e47565b6040516323b872dd60e01b81526001600160a01b038416906323b872dd90612d839087903090879060040161388e565b602060405180830381600087803b158015612d9d57600080fd5b505af1158015612db1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dd59190613736565b61139f5760405162461bcd60e51b81526004016108cf90613ed7565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610bb8575050151592915050565b6060610bb88484600085612eca565b60008183612e5a5760405162461bcd60e51b81526004016108cf91906139ab565b506000838581612e6657fe5b0495945050505050565b60008184841115612e945760405162461bcd60e51b81526004016108cf91906139ab565b505050900390565b6000610be28383612f8e565b6000610be28383613054565b6000610bb884846001600160a01b03851661309e565b6060612ed585612df1565b612ef15760405162461bcd60e51b81526004016108cf90613dc7565b60006060866001600160a01b03168587604051612f0e919061382b565b60006040518083038185875af1925050503d8060008114612f4b576040519150601f19603f3d011682016040523d82523d6000602084013e612f50565b606091505b50915091508115612f64579150610bb89050565b805115612f745780518082602001fd5b8360405162461bcd60e51b81526004016108cf91906139ab565b6000818152600183016020526040812054801561304a5783546000198083019190810190600090879083908110612fc157fe5b9060005260206000200154905080876000018481548110612fde57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061300e57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610be5565b6000915050610be5565b6000613060838361293c565b61309657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610be5565b506000610be5565b600082815260018401602052604081205480613103575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055611f88565b8285600001600183038154811061311657fe5b9060005260206000209060020201600101819055506000915050611f88565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061317657805160ff19168380011785556131a3565b828001600101855582156131a3579182015b828111156131a3578251825591602001919060010190613188565b506131af9291506131b3565b5090565b5b808211156131af57600081556001016131b4565b60008083601f8401126131d9578182fd5b50813567ffffffffffffffff8111156131f0578182fd5b6020830191508360208083028501011115611d8657600080fd5b600082601f83011261321a578081fd5b813567ffffffffffffffff80821115613231578283fd5b604051601f8301601f191681016020018281118282101715613251578485fd5b60405282815292508284830160200186101561326c57600080fd5b8260208601602083013760006020848301015250505092915050565b600060208284031215613299578081fd5b8135610be281614039565b6000602082840312156132b5578081fd5b8151610be281614039565b6000806000606084860312156132d4578182fd5b83356132df81614039565b925060208401356132ef81614039565b929592945050506040919091013590565b60008060408385031215613312578182fd5b823561331d81614039565b946020939093013593505050565b6000806040838503121561333d578182fd5b823561334881614039565b9150602083013561335881614039565b809150509250929050565b600080600080600080600080610100898b03121561337f578384fd5b883561338a81614039565b9750602089013561339a81614039565b965060408901356133aa81614039565b9550606089013567ffffffffffffffff808211156133c6578586fd5b6133d28c838d0161320a565b965060808b01359150808211156133e7578586fd5b506133f48b828c0161320a565b94505060a089013561340581614039565b979a969950949793969295929450505060c08201359160e0013590565b60008060008060608587031215613437578384fd5b843561344281614039565b9350602085013561345281614039565b9250604085013567ffffffffffffffff81111561346d578283fd5b613479878288016131c8565b95989497509550505050565b600080600060608486031215613499578283fd5b83356134a481614039565b925060208401356134b481614039565b9150604084013567ffffffffffffffff8111156134cf578182fd5b6134db8682870161320a565b9150509250925092565b600080600080600060a086880312156134fc578081fd5b853561350781614039565b9450602086013561351781614039565b9350604086013567ffffffffffffffff811115613532578182fd5b61353e8882890161320a565b9598949750949560608101359550608001359392505050565b60008060008060008060c0878903121561356f578384fd5b863561357a81614039565b9550602087013561358a81614039565b9450604087013567ffffffffffffffff8111156135a5578485fd5b6135b189828a0161320a565b945050606087013592506080870135915060a087013590509295509295509295565b6000806000606084860312156132d4578081fd5b600080600080600080600060a0888a031215613601578081fd5b873561360c81614039565b9650602088013561361c81614039565b955060408801359450606088013567ffffffffffffffff8082111561363f578283fd5b61364b8b838c016131c8565b909650945060808a0135915080821115613663578283fd5b506136708a828b016131c8565b989b979a50959850939692959293505050565b60008060008060808587031215613698578182fd5b84356136a381614039565b935060208501356136b381614039565b925060408501359150606085013567ffffffffffffffff8111156136d5578182fd5b6136e18782880161320a565b91505092959194509250565b600080604083850312156136ff578182fd5b823561370a81614039565b9150602083013561335881614051565b60006020828403121561372b578081fd5b8135610be281614051565b600060208284031215613747578081fd5b8151610be281614051565b600060208284031215613763578081fd5b8135610be28161405f565b60006020828403121561377f578081fd5b8151610be28161405f565b60006020828403121561379b578081fd5b5035919050565b6000602082840312156137b3578081fd5b5051919050565b600080604083850312156137cc578182fd5b82359150602083013561335881614039565b600080604083850312156137f0578182fd5b50508035926020909101359150565b6000815180845261381781602086016020860161400d565b601f01601f19169290920160200192915050565b6000825161383d81846020870161400d565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061109f908301846137ff565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039788168152602081019690965293861660408601529185166060850152608084015290921660a082015260c081019190915260e00190565b6001600160a01b039485168152602081019390935292166040820152606081019190915260800190565b6001600160a01b0393909316835260208301919091521515604082015260600190565b600060018060a01b03808916835287602084015260c0604084015261398060c08401886137ff565b9581166060840152608083019490945250911660a0909101529392505050565b901515815260200190565b600060208252610be260208301846137ff565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252600990820152684248503a452d34303360b81b604082015260600190565b6020808252600c908201526b4552433732313a452d34303360a01b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526009908201526828292a1d229699181960b91b604082015260600190565b6020808252603a908201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260408201527f6563697069656e74206d61792068617665207265766572746564000000000000606082015260800190565b6020808252601d908201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604082015260600190565b6020808252600990820152681414950e914b4d0c4d60ba1b604082015260600190565b60208082526009908201526828292a1d22969a189b60b91b604082015260600190565b6020808252600990820152685052543a452d34323160b81b604082015260600190565b6020808252600c908201526b22a9219b99189d22969a181960a11b604082015260600190565b60208082526022908201527f456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252601f908201527f546f6b656e496e666f3a20696e73756666696369656e742062616c616e636500604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252603c908201527f546f6b656e496e666f3a20756e61626c6520746f2073656e642076616c75652c60408201527f20726563697069656e74206d6179206861766520726576657274656400000000606082015260800190565b6020808252600c908201526b4552433732313a452d34303760a01b604082015260600190565b6020808252600c908201526b4552433732313a452d31303560a01b604082015260600190565b6020808252600990820152681414950e914b4c4c0d60ba1b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600990820152685052543a452d31303760b81b604082015260600190565b6020808252600c908201526b22a9219b99189d229698981960a11b604082015260600190565b6020808252600990820152685052543a452d34313160b81b604082015260600190565b6020808252600990820152685052543a452d31303160b81b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600990820152685052543a452d34303160b81b604082015260600190565b6020808252600c908201526b4552433732313a452d34303560a01b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600990820152685052543a452d31303560b81b604082015260600190565b6020808252600c908201526b4552433732313a452d31313160a01b604082015260600190565b90815260200190565b9283526001600160a01b03919091166020830152604082015260600190565b6000808335601e19843603018112613fde578283fd5b83018035915067ffffffffffffffff821115613ff8578283fd5b602001915036819003821315611d8657600080fd5b60005b83811015614028578181015183820152602001614010565b8381111561139f5750506000910152565b6001600160a01b038116811461404e57600080fd5b50565b801515811461404e57600080fd5b6001600160e01b03198116811461404e57600080fdfe312e302e302d626574612e312f636861726765642d7061727469636c65732e72656c61792e726563697069656e74a2646970667358221220d9345c31ec72b22b72e5c554ae210d5a0e515a331f2a963067f198ffcdcf31b564736f6c634300060c0033

Deployed Bytecode

0x6080604052600436106102ae5760003560e01c80636e5559fd11610175578063ad82c42c116100dc578063c95d099811610095578063db9f60ff1161006f578063db9f60ff1461080d578063e985e9c51461082d578063f2fde38b1461084d578063f8eb5fc51461086d576102ae565b8063c95d0998146107ad578063d40e707b146107cd578063da742228146107ed576102ae565b8063ad82c42c146106ed578063ae9704cd1461070d578063b7683e931461072d578063b88d4fde1461074d578063c87b56dd1461076d578063c8c680d51461078d576102ae565b80638da5cb5b1161012e5780638da5cb5b146106435780639390afc71461065857806395d89b41146106785780639848bc761461068d578063a0092b55146106ad578063a22cb465146106cd576102ae565b80636e5559fd1461059957806370a08231146105b9578063715018a6146105d957806371e715f4146105ee5780637da0a8771461060e578063846ec08c14610623576102ae565b80632f745c5911610219578063522f6815116101d2578063522f6815146104e4578063572b6c0514610504578063589a17431461052457806362c51749146105445780636348af34146105645780636352211e14610579576102ae565b80632f745c591461042f5780632fc777971461044f5780634025feb21461046f57806342842e0e1461048f578063486ff0cd146104af5780634f6ccce7146104c4576102ae565b806318160ddd1161026b57806318160ddd1461039a5780631dcd79d4146103bc57806323b872dd146103cf578063250b2c80146103ef5780632b7e237c1461040f5780632c0cd5a31461040f576102ae565b806301ffc9a7146102b3578063053992c5146102e957806306fdde031461030b578063081812fc1461032d578063095ea7b31461035a5780631593dee11461037a575b600080fd5b3480156102bf57600080fd5b506102d36102ce366004613752565b61088d565b6040516102e091906139a0565b60405180910390f35b3480156102f557600080fd5b506103096103043660046137de565b6108ac565b005b34801561031757600080fd5b50610320610915565b6040516102e091906139ab565b34801561033957600080fd5b5061034d61034836600461378a565b6109ac565b6040516102e09190613847565b34801561036657600080fd5b50610309610375366004613300565b6109ef565b34801561038657600080fd5b506103096103953660046132c0565b610a82565b3480156103a657600080fd5b506103af610ac2565b6040516102e09190613fa0565b6102d36103ca3660046137de565b610ad3565b3480156103db57600080fd5b506103096103ea3660046135d3565b610b40565b3480156103fb57600080fd5b506103af61040a36600461378a565b610b72565b34801561041b57600080fd5b506103af61042a366004613485565b610b84565b34801561043b57600080fd5b506103af61044a366004613300565b610bc0565b34801561045b57600080fd5b5061030961046a3660046137ba565b610beb565b34801561047b57600080fd5b5061030961048a3660046132c0565b610c7f565b34801561049b57600080fd5b506103096104aa3660046135d3565b610cbf565b3480156104bb57600080fd5b50610320610cda565b3480156104d057600080fd5b506103af6104df36600461378a565b610cfa565b3480156104f057600080fd5b506103096104ff366004613300565b610d10565b34801561051057600080fd5b506102d361051f366004613288565b610d53565b34801561053057600080fd5b5061034d61053f36600461378a565b610d67565b34801561055057600080fd5b506103af61055f366004613363565b610d82565b34801561057057600080fd5b506103af610df1565b34801561058557600080fd5b5061034d61059436600461378a565b610e58565b3480156105a557600080fd5b506103096105b4366004613288565b610e94565b3480156105c557600080fd5b506103af6105d4366004613288565b610f13565b3480156105e557600080fd5b50610309610f5c565b3480156105fa57600080fd5b5061034d61060936600461378a565b610fdb565b34801561061a57600080fd5b5061034d610fe6565b34801561062f57600080fd5b506103af61063e366004613288565b610ff5565b34801561064f57600080fd5b5061034d611010565b34801561066457600080fd5b506103af610673366004613557565b61101f565b34801561068457600080fd5b506103206110a9565b34801561069957600080fd5b506103af6106a83660046134e5565b61110a565b3480156106b957600080fd5b506102d36106c83660046135e7565b61113d565b3480156106d957600080fd5b506103096106e83660046136ed565b611180565b3480156106f957600080fd5b506103af61070836600461378a565b61124e565b34801561071957600080fd5b50610309610728366004613288565b611260565b34801561073957600080fd5b50610309610748366004613288565b6112e7565b34801561075957600080fd5b50610309610768366004613683565b611366565b34801561077957600080fd5b5061032061078836600461378a565b6113a5565b34801561079957600080fd5b506103096107a83660046137de565b61146b565b3480156107b957600080fd5b506103096107c8366004613288565b611502565b3480156107d957600080fd5b506102d36107e8366004613422565b611581565b3480156107f957600080fd5b50610309610808366004613288565b6115c0565b34801561081957600080fd5b5061030961082836600461371a565b611617565b34801561083957600080fd5b506102d361084836600461332b565b611695565b34801561085957600080fd5b50610309610868366004613288565b6116c3565b34801561087957600080fd5b506103af61088836600461378a565b61177a565b6001600160e01b03191660009081526020819052604090205460ff1690565b60135460ff16156108d85760405162461bcd60e51b81526004016108cf90613e6a565b60405180910390fd5b816108ea6108e46117be565b826117c8565b6109065760405162461bcd60e51b81526004016108cf90613f57565b6109108383611845565b505050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109a15780601f10610976576101008083540402835291602001916109a1565b820191906000526020600020905b81548152906001019060200180831161098457829003601f168201915b505050505090505b90565b60006109b7826118bb565b6109d35760405162461bcd60e51b81526004016108cf90613efa565b506000908152600460205260409020546001600160a01b031690565b60006109fa82610e58565b9050806001600160a01b0316836001600160a01b03161415610a2e5760405162461bcd60e51b81526004016108cf90613f7a565b806001600160a01b0316610a406117be565b6001600160a01b03161480610a5c5750610a5c816108486117be565b610a785760405162461bcd60e51b81526004016108cf90613d7e565b61091083836118c8565b610a8a6117be565b6009546001600160a01b03908116911614610ab75760405162461bcd60e51b81526004016108cf90613cc6565b610910838383611936565b6000610ace6002611a43565b905090565b60006002600b541415610af85760405162461bcd60e51b81526004016108cf90613f20565b6002600b5560135460ff1615610b205760405162461bcd60e51b81526004016108cf90613e6a565b610b2a8383611a4e565b50505050505050600190506001600b5592915050565b610b4b6108e46117be565b610b675760405162461bcd60e51b81526004016108cf90613d7e565b610910838383611b0a565b60009081526012602052604090205490565b60135460009060ff1615610baa5760405162461bcd60e51b81526004016108cf90613e6a565b610bb8848484600080611b7c565b949350505050565b6001600160a01b0382166000908152600160205260408120610be29083611c08565b90505b92915050565b60135460ff1615610c0e5760405162461bcd60e51b81526004016108cf90613e6a565b81610c176117be565b6000828152600d60205260409020546001600160a01b03908116911614610c505760405162461bcd60e51b81526004016108cf90613da4565b506000918252600f602052604090912080546001600160a01b0319166001600160a01b03909216919091179055565b610c876117be565b6009546001600160a01b03908116911614610cb45760405162461bcd60e51b81526004016108cf90613cc6565b610910838383611c14565b61091083838360405180602001604052806000815250611366565b60606040518060600160405280602e8152602001614076602e9139905090565b600080610d08600284611d6f565b509392505050565b610d186117be565b6009546001600160a01b03908116911614610d455760405162461bcd60e51b81526004016108cf90613cc6565b610d4f8282611d8d565b5050565b600a546001600160a01b0390811691161490565b6000908152600d60205260409020546001600160a01b031690565b60006002600b541415610da75760405162461bcd60e51b81526004016108cf90613f20565b6002600b5560135460ff1615610dcf5760405162461bcd60e51b81526004016108cf90613e6a565b610ddf8989898989898989611e11565b6001600b559998505050505050505050565b60006002600b541415610e165760405162461bcd60e51b81526004016108cf90613f20565b6002600b5560135460ff1615610e3e5760405162461bcd60e51b81526004016108cf90613e6a565b610e4e610e496117be565b611ed4565b90506001600b5590565b6000610be5826040518060400160405280600c81526020016b4552433732313a452d34303560a01b8152506002611f789092919063ffffffff16565b610e9c6117be565b6009546001600160a01b03908116911614610ec95760405162461bcd60e51b81526004016108cf90613cc6565b601680546001600160a01b0319166001600160a01b0383169081179091556040517f5ce0e6b7fd36339ee97339831b6c72694ecee88c62aab49919d9cabe0a732e4190600090a250565b60006001600160a01b038216610f3b5760405162461bcd60e51b81526004016108cf90613a69565b6001600160a01b0382166000908152600160205260409020610be590611a43565b610f646117be565b6009546001600160a01b03908116911614610f915760405162461bcd60e51b81526004016108cf90613cc6565b6009546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600980546001600160a01b0319169055565b6000610be582611f8f565b600a546001600160a01b031681565b6001600160a01b031660009081526010602052604090205490565b6009546001600160a01b031690565b600061102e8787878686611b7c565b9050831561109f576015546040516315aea5d760e01b81526001600160a01b03909116906315aea5d79061106c90309085908c908a9060040161390b565b600060405180830381600087803b15801561108657600080fd5b505af115801561109a573d6000803e3d6000fd5b505050505b9695505050505050565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156109a15780601f10610976576101008083540402835291602001916109a1565b60135460009060ff16156111305760405162461bcd60e51b81526004016108cf90613e6a565b61109f8686868686611b7c565b60135460009060ff16156111635760405162461bcd60e51b81526004016108cf90613e6a565b61117288888888888888611fc9565b506001979650505050505050565b6111886117be565b6001600160a01b0316826001600160a01b031614156111b95760405162461bcd60e51b81526004016108cf90613f7a565b80600560006111c66117be565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561120a6117be565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161124291906139a0565b60405180910390a35050565b6000908152600e602052604090205490565b6112686117be565b6009546001600160a01b039081169116146112955760405162461bcd60e51b81526004016108cf90613cc6565b60138054610100600160a81b0319166101006001600160a01b038416908102919091179091556040517ff28fa0fe2abe5dad2066ebce6edc9d403e4facb3603e47e6c0e7ea3e57dfe03290600090a250565b6112ef6117be565b6009546001600160a01b0390811691161461131c5760405162461bcd60e51b81526004016108cf90613cc6565b601480546001600160a01b0319166001600160a01b0383169081179091556040517f62ff39aed768a426c7582b6e1062ab2631df1869b2d574e36f8274d2e2b0ab8190600090a250565b6113776113716117be565b836117c8565b6113935760405162461bcd60e51b81526004016108cf90613d7e565b61139f8484848461207b565b50505050565b60606113b0826118bb565b6113cc5760405162461bcd60e51b81526004016108cf90613efa565b60008281526008602090815260409182902080548351601f60026000196101006001861615020190931692909204918201849004840281018401909452808452909183018282801561145f5780601f106114345761010080835404028352916020019161145f565b820191906000526020600020905b81548152906001019060200180831161144257829003601f168201915b50505050509050919050565b60135460ff161561148e5760405162461bcd60e51b81526004016108cf90613e6a565b816114976117be565b6000828152600d60205260409020546001600160a01b039081169116146114d05760405162461bcd60e51b81526004016108cf90613da4565b826114dc6108e46117be565b6114f85760405162461bcd60e51b81526004016108cf90613f57565b61139f84846120ae565b61150a6117be565b6009546001600160a01b039081169116146115375760405162461bcd60e51b81526004016108cf90613cc6565b601580546001600160a01b0319166001600160a01b0383169081179091556040517f7ad4c1bc3e874ec0bf47846feb5648b384e8511dc9e5f9803578c9d2b4ec9e6e90600090a250565b60135460009060ff16156115a75760405162461bcd60e51b81526004016108cf90613e6a565b6115b5858560008686612113565b506001949350505050565b6115c86117be565b6009546001600160a01b039081169116146115f55760405162461bcd60e51b81526004016108cf90613cc6565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b61161f6117be565b6009546001600160a01b0390811691161461164c5760405162461bcd60e51b81526004016108cf90613cc6565b6013805460ff19168215151790556040517fa9bfed3d98385b3777389e321dbde773cf7d335fa604fefbae3dca93564f55869061168a9083906139a0565b60405180910390a150565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6116cb6117be565b6009546001600160a01b039081169116146116f85760405162461bcd60e51b81526004016108cf90613cc6565b6001600160a01b03811661171e5760405162461bcd60e51b81526004016108cf90613a00565b6009546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600980546001600160a01b0319166001600160a01b0392909216919091179055565b60009081526011602052604090205490565b6000601836108015906117a357506117a333610d53565b156117b7575060131936013560601c6109a9565b50336109a9565b6000610ace61178c565b60006117d3826118bb565b6117ef5760405162461bcd60e51b81526004016108cf90613efa565b60006117fa83610e58565b9050806001600160a01b0316846001600160a01b031614806118355750836001600160a01b031661182a846109ac565b6001600160a01b0316145b80610bb85750610bb88185611695565b61184f8282612190565b601454604051636a5fcc8b60e11b81526001600160a01b039091169063d4bf991690611885903090869086151590600401613935565b600060405180830381600087803b15801561189f57600080fd5b505af11580156118b3573d6000803e3d6000fd5b505050505050565b6000610be56002836121d3565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906118fd82610e58565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6001600160a01b03831661195c5760405162461bcd60e51b81526004016108cf90613a46565b6040516370a0823160e01b815281906001600160a01b038416906370a082319061198a903090600401613847565b60206040518083038186803b1580156119a257600080fd5b505afa1580156119b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119da91906137a2565b10610910576119f36001600160a01b03831684836121df565b816001600160a01b0316836001600160a01b03167f6c9d637297625e945b296ff73a71fcfbd0a9e062652b6491a921c4c60194176b83604051611a369190613fa0565b60405180910390a3505050565b6000610be582612235565b6000806000806000806000611a638989612239565b601354969d50949b5092995090975095509350915061010090046001600160a01b031615611afe576013546040516345c984d960e11b81526101009091046001600160a01b031690638b9309b290611acb908a908a908a908a908a908a908a906004016138cb565b600060405180830381600087803b158015611ae557600080fd5b505af1158015611af9573d6000803e3d6000fd5b505050505b92959891949750929550565b601454604051636a5fcc8b60e11b81526001600160a01b039091169063d4bf991690611b3f9030908590600090600401613935565b600060405180830381600087803b158015611b5957600080fd5b505af1158015611b6d573d6000803e3d6000fd5b505050506109108383836123f3565b6000611b88600c61240d565b611b92600c612235565b9050611bae858260405180602001604052806000815250612416565b6000818152600d6020526040902080546001600160a01b0319166001600160a01b038816179055611bdf8185612449565b8215611bef57611bef81846120ae565b8115611bff57611bff8183611845565b95945050505050565b6000610be2838361248d565b6001600160a01b038316611c3a5760405162461bcd60e51b81526004016108cf90613a46565b6040516331a9108f60e11b815230906001600160a01b03841690636352211e90611c68908590600401613fa0565b60206040518083038186803b158015611c8057600080fd5b505afa158015611c94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cb891906132a4565b6001600160a01b03161415610910576040516323b872dd60e01b81526001600160a01b038316906323b872dd90611cf79030908790869060040161388e565b600060405180830381600087803b158015611d1157600080fd5b505af1158015611d25573d6000803e3d6000fd5b5050505080826001600160a01b0316846001600160a01b03167ffefe036cac4ee3a4aca074a81cbcc4376e1484693289078dbec149c890101d5b60405160405180910390a4505050565b6000808080611d7e86866124d2565b909450925050505b9250929050565b6001600160a01b038216611db35760405162461bcd60e51b81526004016108cf90613a46565b804710610d4f57611dcd6001600160a01b0383168261252e565b816001600160a01b03167eddb683bb45cd5d0ad8a200c6fae7152b1c236ee90a4a37db692407f5cc38bd82604051611e059190613fa0565b60405180910390a25050565b6016546000906001600160a01b0316611e3c5760405162461bcd60e51b81526004016108cf90613dfe565b611e4a898988600080611b7c565b90508115611ebb576015546040516315aea5d760e01b81526001600160a01b03909116906315aea5d790611e8890309085908e90889060040161390b565b600060405180830381600087803b158015611ea257600080fd5b505af1158015611eb6573d6000803e3d6000fd5b505050505b611ec8818686868b6125ca565b98975050505050505050565b6001600160a01b03811660009081526010602052604081205480611f0a5760405162461bcd60e51b81526004016108cf90613e47565b6001600160a01b0383166000818152601060205260408120819055611f31919083906126ef565b826001600160a01b03167f8fbbda19f4a70036f6f585dc4160142a8fa2a20ffb9393d23274f78de4e3988882604051611f6a9190613fa0565b60405180910390a250919050565b6000611f858484846127f5565b90505b9392505050565b6000818152600f60205260408120546001600160a01b031680610be55750506000908152600d60205260409020546001600160a01b031690565b828114611fe85760405162461bcd60e51b81526004016108cf90613ac6565b8260005b8181101561207057612067898988888581811061200557fe5b90506020028101906120179190613fc8565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508d92508a91508990508781811061205b57fe5b90506020020135611b7c565b50600101611fec565b505050505050505050565b612086848484611b0a565b61209284848484612854565b61139f5760405162461bcd60e51b81526004016108cf90613be6565b6127108111156120d05760405162461bcd60e51b81526004016108cf90613bc3565b6000828152600e6020526040908190208290555182907fd91bd92b973231f564eaa17c9bc62c86b96a8885f3cdcb990d5a3f0415580d9090611e05908490613fa0565b8060005b818110156121875761217e878786868581811061213057fe5b90506020028101906121429190613fc8565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052508c93509150611b7c9050565b50600101612117565b50505050505050565b600082815260116020526040908190208290555182907fe23ea816dce6d7f5c0b85cbd597e7c3b97b2453791152c0b94e5e5c5f314d2f090611e05908490613fa0565b6000610be2838361293c565b6109108363a9059cbb60e01b84846040516024016121fe9291906138b2565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612954565b5490565b60008281526011602052604081205430918491819081808261226d5760405162461bcd60e51b81526004016108cf90613ba0565b8234101561228d5760405162461bcd60e51b81526004016108cf90613b7d565b826122978a610e58565b95506122a16117be565b94506122ac8a611f8f565b60008b8152600e60209081526040808320546012909252909120549194509081158015906122da5750600081115b80156122e557508086115b15612311576123026127106122fc838903856129e3565b90612a1d565b935061230e8385612a5f565b92505b60008c81526012602052604090208690558315612365576001600160a01b03851660009081526010602052604090205461234b9085612aa1565b6001600160a01b0386166000908152601060205260409020555b61237088888e611b0a565b821561238a5761238a6001600160a01b038916848d6126ef565b866001600160a01b0316886001600160a01b03168d7f71a2ee63bc7695052e3a9837d5a45dd1cc0ce12717e39cef6eb6afb0d91697ed8989896040516123d293929190613fa9565b60405180910390a46123e4868c612ac6565b50505092959891949750929550565b600081815260116020526040812055610910838383612af7565b80546001019055565b6124208383612bfa565b61242d6000848484612854565b6109105760405162461bcd60e51b81526004016108cf90613be6565b612452826118bb565b61246e5760405162461bcd60e51b81526004016108cf90613efa565b6000828152600860209081526040909120825161091092840190613135565b815460009082106124b05760405162461bcd60e51b81526004016108cf906139be565b8260000182815481106124bf57fe5b9060005260206000200154905092915050565b8154600090819083106124f75760405162461bcd60e51b81526004016108cf90613c0c565b600084600001848154811061250857fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b8047101561254e5760405162461bcd60e51b81526004016108cf90613b46565b6000826001600160a01b031682604051612567906109a9565b60006040518083038185875af1925050503d80600081146125a4576040519150601f19603f3d011682016040523d82523d6000602084013e6125a9565b606091505b50509050806109105760405162461bcd60e51b81526004016108cf90613ae9565b6125dc6125d56117be565b8484612cb2565b60165460405163095ea7b360e01b81526001600160a01b038581169263095ea7b392612610929091169086906004016138b2565b602060405180830381600087803b15801561262a57600080fd5b505af115801561263e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126629190613736565b506016546040516305eef16560e11b81526001600160a01b0390911690630bdde2ca9061269d90309089908990899089908990600401613958565b602060405180830381600087803b1580156126b757600080fd5b505af11580156126cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b391906137a2565b8147101561270f5760405162461bcd60e51b81526004016108cf90613c4e565b600080821161277757836001600160a01b03168360405161272f906109a9565b60006040518083038185875af1925050503d806000811461276c576040519150601f19603f3d011682016040523d82523d6000602084013e612771565b606091505b506127d5565b836001600160a01b0316838390604051612790906109a9565b600060405180830381858888f193505050503d80600081146127ce576040519150601f19603f3d011682016040523d82523d6000602084013e6127d3565b606091505b505b5090508061139f5760405162461bcd60e51b81526004016108cf90613cfb565b600082815260018401602052604081205482816128255760405162461bcd60e51b81526004016108cf91906139ab565b5084600001600182038154811061283857fe5b9060005260206000209060020201600101549150509392505050565b6000612868846001600160a01b0316612df1565b61287457506001610bb8565b6060612905630a85bd0160e11b6128896117be565b88878760405160240161289f949392919061385b565b60408051601f19818403018152918152602080830180516001600160e01b03166001600160e01b0319909516949094179093528051808201909152600c81526b22a9219b99189d22969a181960a11b928101929092526001600160a01b03881691612e2a565b905060008180602001905181019061291d919061376e565b6001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b60606129a9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e2a9092919063ffffffff16565b80519091501561091057808060200190518101906129c79190613736565b6109105760405162461bcd60e51b81526004016108cf90613e8d565b6000826129f257506000610be5565b828202828482816129ff57fe5b0414610be25760405162461bcd60e51b81526004016108cf90613c85565b6000610be283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612e39565b6000610be283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612e70565b600082820183811015610be25760405162461bcd60e51b81526004016108cf90613a8f565b6000612ad23484612a5f565b90508015610910576109108183612ae76117be565b6001600160a01b031691906126ef565b826001600160a01b0316612b0a82610e58565b6001600160a01b031614612b305760405162461bcd60e51b81526004016108cf90613e21565b6001600160a01b038216612b565760405162461bcd60e51b81526004016108cf90613a69565b612b616000826118c8565b6001600160a01b0383166000908152600160205260409020612b839082612e9c565b506001600160a01b0382166000908152600160205260409020612ba69082612ea8565b50612bb360028284612eb4565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6001600160a01b038216612c205760405162461bcd60e51b81526004016108cf90613a69565b612c29816118bb565b15612c465760405162461bcd60e51b81526004016108cf90613d58565b6001600160a01b0382166000908152600160205260409020612c689082612ea8565b50612c7560028284612eb4565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6040516370a0823160e01b81526000906001600160a01b038416906370a0823190612ce1908790600401613847565b60206040518083038186803b158015612cf957600080fd5b505afa158015612d0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d3191906137a2565b905080821115612d535760405162461bcd60e51b81526004016108cf90613e47565b6040516323b872dd60e01b81526001600160a01b038416906323b872dd90612d839087903090879060040161388e565b602060405180830381600087803b158015612d9d57600080fd5b505af1158015612db1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dd59190613736565b61139f5760405162461bcd60e51b81526004016108cf90613ed7565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590610bb8575050151592915050565b6060610bb88484600085612eca565b60008183612e5a5760405162461bcd60e51b81526004016108cf91906139ab565b506000838581612e6657fe5b0495945050505050565b60008184841115612e945760405162461bcd60e51b81526004016108cf91906139ab565b505050900390565b6000610be28383612f8e565b6000610be28383613054565b6000610bb884846001600160a01b03851661309e565b6060612ed585612df1565b612ef15760405162461bcd60e51b81526004016108cf90613dc7565b60006060866001600160a01b03168587604051612f0e919061382b565b60006040518083038185875af1925050503d8060008114612f4b576040519150601f19603f3d011682016040523d82523d6000602084013e612f50565b606091505b50915091508115612f64579150610bb89050565b805115612f745780518082602001fd5b8360405162461bcd60e51b81526004016108cf91906139ab565b6000818152600183016020526040812054801561304a5783546000198083019190810190600090879083908110612fc157fe5b9060005260206000200154905080876000018481548110612fde57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061300e57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610be5565b6000915050610be5565b6000613060838361293c565b61309657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610be5565b506000610be5565b600082815260018401602052604081205480613103575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055611f88565b8285600001600183038154811061311657fe5b9060005260206000209060020201600101819055506000915050611f88565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061317657805160ff19168380011785556131a3565b828001600101855582156131a3579182015b828111156131a3578251825591602001919060010190613188565b506131af9291506131b3565b5090565b5b808211156131af57600081556001016131b4565b60008083601f8401126131d9578182fd5b50813567ffffffffffffffff8111156131f0578182fd5b6020830191508360208083028501011115611d8657600080fd5b600082601f83011261321a578081fd5b813567ffffffffffffffff80821115613231578283fd5b604051601f8301601f191681016020018281118282101715613251578485fd5b60405282815292508284830160200186101561326c57600080fd5b8260208601602083013760006020848301015250505092915050565b600060208284031215613299578081fd5b8135610be281614039565b6000602082840312156132b5578081fd5b8151610be281614039565b6000806000606084860312156132d4578182fd5b83356132df81614039565b925060208401356132ef81614039565b929592945050506040919091013590565b60008060408385031215613312578182fd5b823561331d81614039565b946020939093013593505050565b6000806040838503121561333d578182fd5b823561334881614039565b9150602083013561335881614039565b809150509250929050565b600080600080600080600080610100898b03121561337f578384fd5b883561338a81614039565b9750602089013561339a81614039565b965060408901356133aa81614039565b9550606089013567ffffffffffffffff808211156133c6578586fd5b6133d28c838d0161320a565b965060808b01359150808211156133e7578586fd5b506133f48b828c0161320a565b94505060a089013561340581614039565b979a969950949793969295929450505060c08201359160e0013590565b60008060008060608587031215613437578384fd5b843561344281614039565b9350602085013561345281614039565b9250604085013567ffffffffffffffff81111561346d578283fd5b613479878288016131c8565b95989497509550505050565b600080600060608486031215613499578283fd5b83356134a481614039565b925060208401356134b481614039565b9150604084013567ffffffffffffffff8111156134cf578182fd5b6134db8682870161320a565b9150509250925092565b600080600080600060a086880312156134fc578081fd5b853561350781614039565b9450602086013561351781614039565b9350604086013567ffffffffffffffff811115613532578182fd5b61353e8882890161320a565b9598949750949560608101359550608001359392505050565b60008060008060008060c0878903121561356f578384fd5b863561357a81614039565b9550602087013561358a81614039565b9450604087013567ffffffffffffffff8111156135a5578485fd5b6135b189828a0161320a565b945050606087013592506080870135915060a087013590509295509295509295565b6000806000606084860312156132d4578081fd5b600080600080600080600060a0888a031215613601578081fd5b873561360c81614039565b9650602088013561361c81614039565b955060408801359450606088013567ffffffffffffffff8082111561363f578283fd5b61364b8b838c016131c8565b909650945060808a0135915080821115613663578283fd5b506136708a828b016131c8565b989b979a50959850939692959293505050565b60008060008060808587031215613698578182fd5b84356136a381614039565b935060208501356136b381614039565b925060408501359150606085013567ffffffffffffffff8111156136d5578182fd5b6136e18782880161320a565b91505092959194509250565b600080604083850312156136ff578182fd5b823561370a81614039565b9150602083013561335881614051565b60006020828403121561372b578081fd5b8135610be281614051565b600060208284031215613747578081fd5b8151610be281614051565b600060208284031215613763578081fd5b8135610be28161405f565b60006020828403121561377f578081fd5b8151610be28161405f565b60006020828403121561379b578081fd5b5035919050565b6000602082840312156137b3578081fd5b5051919050565b600080604083850312156137cc578182fd5b82359150602083013561335881614039565b600080604083850312156137f0578182fd5b50508035926020909101359150565b6000815180845261381781602086016020860161400d565b601f01601f19169290920160200192915050565b6000825161383d81846020870161400d565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061109f908301846137ff565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039788168152602081019690965293861660408601529185166060850152608084015290921660a082015260c081019190915260e00190565b6001600160a01b039485168152602081019390935292166040820152606081019190915260800190565b6001600160a01b0393909316835260208301919091521515604082015260600190565b600060018060a01b03808916835287602084015260c0604084015261398060c08401886137ff565b9581166060840152608083019490945250911660a0909101529392505050565b901515815260200190565b600060208252610be260208301846137ff565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252600990820152684248503a452d34303360b81b604082015260600190565b6020808252600c908201526b4552433732313a452d34303360a01b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526009908201526828292a1d229699181960b91b604082015260600190565b6020808252603a908201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260408201527f6563697069656e74206d61792068617665207265766572746564000000000000606082015260800190565b6020808252601d908201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604082015260600190565b6020808252600990820152681414950e914b4d0c4d60ba1b604082015260600190565b60208082526009908201526828292a1d22969a189b60b91b604082015260600190565b6020808252600990820152685052543a452d34323160b81b604082015260600190565b6020808252600c908201526b22a9219b99189d22969a181960a11b604082015260600190565b60208082526022908201527f456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252601f908201527f546f6b656e496e666f3a20696e73756666696369656e742062616c616e636500604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252603c908201527f546f6b656e496e666f3a20756e61626c6520746f2073656e642076616c75652c60408201527f20726563697069656e74206d6179206861766520726576657274656400000000606082015260800190565b6020808252600c908201526b4552433732313a452d34303760a01b604082015260600190565b6020808252600c908201526b4552433732313a452d31303560a01b604082015260600190565b6020808252600990820152681414950e914b4c4c0d60ba1b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600990820152685052543a452d31303760b81b604082015260600190565b6020808252600c908201526b22a9219b99189d229698981960a11b604082015260600190565b6020808252600990820152685052543a452d34313160b81b604082015260600190565b6020808252600990820152685052543a452d31303160b81b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600990820152685052543a452d34303160b81b604082015260600190565b6020808252600c908201526b4552433732313a452d34303560a01b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600990820152685052543a452d31303560b81b604082015260600190565b6020808252600c908201526b4552433732313a452d31313160a01b604082015260600190565b90815260200190565b9283526001600160a01b03919091166020830152604082015260600190565b6000808335601e19843603018112613fde578283fd5b83018035915067ffffffffffffffff821115613ff8578283fd5b602001915036819003821315611d8657600080fd5b60005b83811015614028578181015183820152602001614010565b8381111561139f5750506000910152565b6001600160a01b038116811461404e57600080fd5b50565b801515811461404e57600080fd5b6001600160e01b03198116811461404e57600080fdfe312e302e302d626574612e312f636861726765642d7061727469636c65732e72656c61792e726563697069656e74a2646970667358221220d9345c31ec72b22b72e5c554ae210d5a0e515a331f2a963067f198ffcdcf31b564736f6c634300060c0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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