ETH Price: $3,500.24 (-0.43%)
Gas: 10 Gwei

Contract

0x28be1A970CBfB88d8CE438B439d818Dcae1a7D81
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
0x60806040181795202023-09-20 20:34:47266 days ago1695242087IN
 Create: ERC1155WhitelistUpgradeable
0 ETH0.0961676826.81372927

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ERC1155WhitelistUpgradeable

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
File 1 of 38 : ERC1155WhitelistUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "@gnus.ai/contracts-upgradeable-diamond/contracts/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/token/ERC1155/ERC1155Upgradeable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/security/PausableUpgradeable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/interfaces/IERC1155ReceiverUpgradeable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/utils/StringsUpgradeable.sol";

import "./ERC1155WhitelistStorage.sol";
import "./WaterCommonStorage.sol";
import "../utils/EIP2535Initializable.sol";
import "../utils/IrrigationAccessControl.sol";
import "../libraries/FullMath.sol";
import "../libraries/Constants.sol";
import "../interfaces/IPodsOracleUpgradeable.sol";
import "../interfaces/IERC1155WhitelistUpgradeable.sol";

/// @title ERC1155WhitelistUpgradeable Contract
/// @dev Users can hold this tranche tokens, and redeem underlying assets after maturity date.
///      We don't want our tranche tokens used out on random dex or other protocol,
///      so this tranche token can be available on markets in whitelist

contract ERC1155WhitelistUpgradeable is
    IERC1155WhitelistUpgradeable,
    IERC1155ReceiverUpgradeable,
    ERC1155SupplyUpgradeable,
    ERC1155BurnableUpgradeable,
    EIP2535Initializable,
    IrrigationAccessControl
{
    using StringsUpgradeable for uint256;
    using ERC1155WhitelistStorage for ERC1155WhitelistStorage.Layout;

    error NoWhitelist();
    error NoUserMint();
    error BlacklistedToken();

    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal override(ERC1155SupplyUpgradeable, ERC1155Upgradeable) {
        super._beforeTokenTransfer(operator, from, to, ids, amounts, data);

        /// @dev check whitelist and blacklist only for proxy contract call
        bool isProxyCall = from != operator;
        if (isProxyCall && ERC1155WhitelistStorage.layout().proxySpenders[operator].name == 0)
            revert NoWhitelist();
        uint256 length = ids.length;
        for (uint256 i = 0; i < length; ) {
            if (
                (isProxyCall &&
                    ERC1155WhitelistStorage.layout().proxySpenders[operator].blacklisted[i]) ||
                ERC1155WhitelistStorage.layout().blacklistForCompliance[i]
            ) revert BlacklistedToken();
            unchecked {
                i++;
            }
        }
    }

    // The following functions are overrides required by Solidity.
    function supportsInterface(
        bytes4 interfaceId
    )
        public
        view
        virtual
        override(AccessControlEnumerableUpgradeable, ERC1155Upgradeable, IERC165Upgradeable)
        returns (bool)
    {
        return (ERC1155Upgradeable.supportsInterface(interfaceId) ||
            AccessControlEnumerableUpgradeable.supportsInterface(interfaceId) ||
            (LibDiamond.diamondStorage().supportedInterfaces[interfaceId] == true));
    }

    function mint(address to, uint256 id, uint256 amount, bytes memory data) external {
        if (msg.sender != address(this)) revert NoUserMint();
        _mint(to, id, amount, data);
    }

    function mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) external {
        if (msg.sender != address(this)) revert NoUserMint();
        _mintBatch(to, ids, amounts, data);
    }

    function burnTotalAmount(address to, uint256 tokenId) external {
        uint256 balance = balanceOf(to, tokenId);
        burn(to, tokenId, balance);
    }

    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external pure override returns (bytes4) {
        (operator);
        (from);
        (id);
        (value);
        (data); // solidity, be quiet please
        // require(address(this) == proxy, "Direct call: onERC1155Received");
        return Constants.ERC1155_ACCEPTED;
    }

    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external pure override returns (bytes4) {
        (operator);
        (from);
        (ids);
        (values);
        (data); // solidity, be quiet please
        return Constants.ERC1155_BATCH_ACCEPTED;
    }

    /// @dev get functions
    /// @dev we will update token metadata uri into onchain image
    /// @param tokenId token ID
    function uri(uint256 tokenId) public view override returns (string memory) {
        return
            string(abi.encodePacked(ERC1155WhitelistStorage.layout().baseURI, tokenId.toString()));
    }

    function contractURI() public view returns (string memory) {
        return ERC1155WhitelistStorage.layout().contractURI;
    }

    function getProxyInfo(address proxySpender) external view returns (bytes32) {
        return ERC1155WhitelistStorage.layout().proxySpenders[proxySpender].name;
    }

    function isTradeableToken(address proxySpender, uint256 tokenId) external view returns (bool) {
        return
            ERC1155WhitelistStorage.layout().proxySpenders[proxySpender].name != 0 &&
            ERC1155WhitelistStorage.layout().proxySpenders[proxySpender].blacklisted[tokenId];
    }

    /// @dev Admin functions
    /// @notice Add proxy contract into whitelist
    /// @param contractAddress spender contract address
    /// @param name spender name
    function addProxySpender(address contractAddress, bytes32 name) external onlyAdminRole {
        ERC1155WhitelistStorage.layout().proxySpenders[contractAddress].name = name;
    }

    /// @notice Remove proxy contract into whitelist
    /// @param contractAddress spender contract addres
    function removeProxySpender(address contractAddress) external onlyAdminRole {
        ERC1155WhitelistStorage.layout().proxySpenders[contractAddress].name = 0;
    }

    /// @notice Manage blacklist
    /// @param proxyAddress proxy contract to update
    /// @param tokenIds token id array to update blacklist
    /// @param bBlacklisted true if want to include in blacklist, or not
    function updateTokenInBlacklist(
        address proxyAddress,
        uint256[] memory tokenIds,
        bool bBlacklisted
    ) external onlyAdminRole {
        uint256 length = tokenIds.length;
        for (uint256 i = 0; i < length; ) {
            ERC1155WhitelistStorage.layout().proxySpenders[proxyAddress].blacklisted[
                    i
                ] = bBlacklisted;
            unchecked {
                i++;
            }
        }
    }

    /// @notice Add token id list into blacklist for compliance with government regulations)
    function addTokenIntoBlacklist(uint256[] memory tokenIds) external onlyAdminRole {
        uint256 length = tokenIds.length;
        for (uint256 i = 0; i < length; ) {
            ERC1155WhitelistStorage.layout().blacklistForCompliance[i] = true;
            unchecked {
                i++;
            }
        }
    }

    function setTokenBaseURI(string calldata _uri) external onlyAdminRole {
        ERC1155WhitelistStorage.layout().baseURI = _uri;
    }

    function setContractURI(string calldata contractUri) external onlyAdminRole {
        ERC1155WhitelistStorage.layout().contractURI = contractUri;
    }
}

File 2 of 38 : AccessControlEnumerableStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;


import { AccessControlEnumerableUpgradeable } from "./AccessControlEnumerableUpgradeable.sol";
import { EnumerableSetUpgradeable } from "../utils/structs/EnumerableSetUpgradeable.sol";

library AccessControlEnumerableStorage {

  struct Layout {

    mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) _roleMembers;
  
  }
  
  bytes32 internal constant STORAGE_SLOT = keccak256('openzeppelin.contracts.storage.AccessControlEnumerable');

  function layout() internal pure returns (Layout storage l) {
    bytes32 slot = STORAGE_SLOT;
    assembly {
      l.slot := slot
    }
  }
}

File 3 of 38 : AccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlEnumerableUpgradeable.sol";
import "./AccessControlUpgradeable.sol";
import "../utils/structs/EnumerableSetUpgradeable.sol";
import { AccessControlEnumerableStorage } from "./AccessControlEnumerableStorage.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable {
    using AccessControlEnumerableStorage for AccessControlEnumerableStorage.Layout;
    function __AccessControlEnumerable_init() internal onlyInitializing {
    }

    function __AccessControlEnumerable_init_unchained() internal onlyInitializing {
    }
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
        return AccessControlEnumerableStorage.layout()._roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
        return AccessControlEnumerableStorage.layout()._roleMembers[role].length();
    }

    /**
     * @dev Overload {_grantRole} to track enumerable memberships
     */
    function _grantRole(bytes32 role, address account) internal virtual override {
        super._grantRole(role, account);
        AccessControlEnumerableStorage.layout()._roleMembers[role].add(account);
    }

    /**
     * @dev Overload {_revokeRole} to track enumerable memberships
     */
    function _revokeRole(bytes32 role, address account) internal virtual override {
        super._revokeRole(role, account);
        AccessControlEnumerableStorage.layout()._roleMembers[role].remove(account);
    }
}

File 4 of 38 : AccessControlStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;


import { AccessControlUpgradeable } from "./AccessControlUpgradeable.sol";

library AccessControlStorage {

  struct Layout {

    mapping(bytes32 => AccessControlUpgradeable.RoleData) _roles;
  
  }
  
  bytes32 internal constant STORAGE_SLOT = keccak256('openzeppelin.contracts.storage.AccessControl');

  function layout() internal pure returns (Layout storage l) {
    bytes32 slot = STORAGE_SLOT;
    assembly {
      l.slot := slot
    }
  }
}

File 5 of 38 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import { AccessControlStorage } from "./AccessControlStorage.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    using AccessControlStorage for AccessControlStorage.Layout;
    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return AccessControlStorage.layout()._roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(account),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return AccessControlStorage.layout()._roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        AccessControlStorage.layout()._roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            AccessControlStorage.layout()._roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            AccessControlStorage.layout()._roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 6 of 38 : IAccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

File 7 of 38 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 8 of 38 : IERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../token/ERC1155/IERC1155ReceiverUpgradeable.sol";

File 9 of 38 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";
import { InitializableStorage } from "./InitializableStorage.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !InitializableStorage.layout()._initializing;
        require(
            (isTopLevelCall && InitializableStorage.layout()._initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && InitializableStorage.layout()._initialized == 1),
            "Initializable: contract is already initialized"
        );
        InitializableStorage.layout()._initialized = 1;
        if (isTopLevelCall) {
            InitializableStorage.layout()._initializing = true;
        }
        _;
        if (isTopLevelCall) {
            InitializableStorage.layout()._initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!InitializableStorage.layout()._initializing && InitializableStorage.layout()._initialized < version, "Initializable: contract is already initialized");
        InitializableStorage.layout()._initialized = version;
        InitializableStorage.layout()._initializing = true;
        _;
        InitializableStorage.layout()._initializing = false;
        emit Initialized(version);
    }

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

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!InitializableStorage.layout()._initializing, "Initializable: contract is initializing");
        if (InitializableStorage.layout()._initialized < type(uint8).max) {
            InitializableStorage.layout()._initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return InitializableStorage.layout()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return InitializableStorage.layout()._initializing;
    }
}

File 10 of 38 : InitializableStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;


import { Initializable } from "./Initializable.sol";

library InitializableStorage {

  struct Layout {
    /*
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 _initialized;

    /*
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool _initializing;
  
  }
  
  bytes32 internal constant STORAGE_SLOT = keccak256('openzeppelin.contracts.storage.Initializable');

  function layout() internal pure returns (Layout storage l) {
    bytes32 slot = STORAGE_SLOT;
    assembly {
      l.slot := slot
    }
  }
}

File 11 of 38 : PausableStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;


import { PausableUpgradeable } from "./PausableUpgradeable.sol";

library PausableStorage {

  struct Layout {

    bool _paused;
  
  }
  
  bytes32 internal constant STORAGE_SLOT = keccak256('openzeppelin.contracts.storage.Pausable');

  function layout() internal pure returns (Layout storage l) {
    bytes32 slot = STORAGE_SLOT;
    assembly {
      l.slot := slot
    }
  }
}

File 12 of 38 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import { PausableStorage } from "./PausableStorage.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    using PausableStorage for PausableStorage.Layout;
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        PausableStorage.layout()._paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return PausableStorage.layout()._paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        PausableStorage.layout()._paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        PausableStorage.layout()._paused = false;
        emit Unpaused(_msgSender());
    }
}

File 13 of 38 : ERC1155Storage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;


import { ERC1155Upgradeable } from "./ERC1155Upgradeable.sol";

library ERC1155Storage {

  struct Layout {

    // Mapping from token ID to account balances
    mapping(uint256 => mapping(address => uint256)) _balances;

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

    // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
    string _uri;
  
  }
  
  bytes32 internal constant STORAGE_SLOT = keccak256('openzeppelin.contracts.storage.ERC1155');

  function layout() internal pure returns (Layout storage l) {
    bytes32 slot = STORAGE_SLOT;
    assembly {
      l.slot := slot
    }
  }
}

File 14 of 38 : ERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.0;

import "./IERC1155Upgradeable.sol";
import "./IERC1155ReceiverUpgradeable.sol";
import "./extensions/IERC1155MetadataURIUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import { ERC1155Storage } from "./ERC1155Storage.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the basic standard multi-token.
 * See https://eips.ethereum.org/EIPS/eip-1155
 * Originally based on code by Enjin: https://github.com/enjin/erc-1155
 *
 * _Available since v3.1._
 */
contract ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155Upgradeable, IERC1155MetadataURIUpgradeable {
    using ERC1155Storage for ERC1155Storage.Layout;
    using AddressUpgradeable for address;

    /**
     * @dev See {_setURI}.
     */
    function __ERC1155_init(string memory uri_) internal onlyInitializing {
        __ERC1155_init_unchained(uri_);
    }

    function __ERC1155_init_unchained(string memory uri_) internal onlyInitializing {
        _setURI(uri_);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
        return
            interfaceId == type(IERC1155Upgradeable).interfaceId ||
            interfaceId == type(IERC1155MetadataURIUpgradeable).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC1155MetadataURI-uri}.
     *
     * This implementation returns the same URI for *all* token types. It relies
     * on the token type ID substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * Clients calling this function must replace the `\{id\}` substring with the
     * actual token type ID.
     */
    function uri(uint256) public view virtual override returns (string memory) {
        return ERC1155Storage.layout()._uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
        require(account != address(0), "ERC1155: address zero is not a valid owner");
        return ERC1155Storage.layout()._balances[id][account];
    }

    /**
     * @dev See {IERC1155-balanceOfBatch}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
        public
        view
        virtual
        override
        returns (uint256[] memory)
    {
        require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }

    /**
     * @dev See {IERC1155-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

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

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner or approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner or approved"
        );
        _safeBatchTransferFrom(from, to, ids, amounts, data);
    }

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `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 memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        uint256 fromBalance = ERC1155Storage.layout()._balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            ERC1155Storage.layout()._balances[id][from] = fromBalance - amount;
        }
        ERC1155Storage.layout()._balances[id][to] += amount;

        emit TransferSingle(operator, from, to, id, amount);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - 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[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = ERC1155Storage.layout()._balances[id][from];
            require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
            unchecked {
                ERC1155Storage.layout()._balances[id][from] = fromBalance - amount;
            }
            ERC1155Storage.layout()._balances[id][to] += amount;
        }

        emit TransferBatch(operator, from, to, ids, amounts);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
    }

    /**
     * @dev Sets a new URI for all token types, by relying on the token type ID
     * substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * By this mechanism, any occurrence of the `\{id\}` substring in either the
     * URI or any of the amounts in the JSON file at said URI will be replaced by
     * clients with the token type ID.
     *
     * For example, the `https://token-cdn-domain/\{id\}.json` URI would be
     * interpreted by clients as
     * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
     * for token type ID 0x4cce0.
     *
     * See {uri}.
     *
     * Because these URIs cannot be meaningfully represented by the {URI} event,
     * this function emits no events.
     */
    function _setURI(string memory newuri) internal virtual {
        ERC1155Storage.layout()._uri = newuri;
    }

    /**
     * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        ERC1155Storage.layout()._balances[id][to] += amount;
        emit TransferSingle(operator, address(0), to, id, amount);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * 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 _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; i++) {
            ERC1155Storage.layout()._balances[ids[i]][to] += amounts[i];
        }

        emit TransferBatch(operator, address(0), to, ids, amounts);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
    }

    /**
     * @dev Destroys `amount` tokens of token type `id` from `from`
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `amount` tokens of token type `id`.
     */
    function _burn(
        address from,
        uint256 id,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        uint256 fromBalance = ERC1155Storage.layout()._balances[id][from];
        require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            ERC1155Storage.layout()._balances[id][from] = fromBalance - amount;
        }

        emit TransferSingle(operator, from, address(0), id, amount);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     */
    function _burnBatch(
        address from,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = ERC1155Storage.layout()._balances[id][from];
            require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                ERC1155Storage.layout()._balances[id][from] = fromBalance - amount;
            }
        }

        emit TransferBatch(operator, from, address(0), ids, amounts);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC1155: setting approval status for self");
        ERC1155Storage.layout()._operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `ids` and `amounts` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    /**
     * @dev Hook that is called after any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `id` and `amount` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155ReceiverUpgradeable(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155ReceiverUpgradeable.onERC1155Received.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non-ERC1155Receiver implementer");
            }
        }
    }

    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155ReceiverUpgradeable.onERC1155BatchReceived.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non-ERC1155Receiver implementer");
            }
        }
    }

    function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
        uint256[] memory array = new uint256[](1);
        array[0] = element;

        return array;
    }
}

File 15 of 38 : ERC1155BurnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/extensions/ERC1155Burnable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Extension of {ERC1155} that allows token holders to destroy both their
 * own tokens and those that they have been approved to use.
 *
 * _Available since v3.1._
 */
abstract contract ERC1155BurnableUpgradeable is Initializable, ERC1155Upgradeable {
    function __ERC1155Burnable_init() internal onlyInitializing {
    }

    function __ERC1155Burnable_init_unchained() internal onlyInitializing {
    }
    function burn(
        address account,
        uint256 id,
        uint256 value
    ) public virtual {
        require(
            account == _msgSender() || isApprovedForAll(account, _msgSender()),
            "ERC1155: caller is not token owner or approved"
        );

        _burn(account, id, value);
    }

    function burnBatch(
        address account,
        uint256[] memory ids,
        uint256[] memory values
    ) public virtual {
        require(
            account == _msgSender() || isApprovedForAll(account, _msgSender()),
            "ERC1155: caller is not token owner or approved"
        );

        _burnBatch(account, ids, values);
    }
}

File 16 of 38 : ERC1155SupplyStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;


import { ERC1155SupplyUpgradeable } from "./ERC1155SupplyUpgradeable.sol";

library ERC1155SupplyStorage {

  struct Layout {
    mapping(uint256 => uint256) _totalSupply;
  
  }
  
  bytes32 internal constant STORAGE_SLOT = keccak256('openzeppelin.contracts.storage.ERC1155Supply');

  function layout() internal pure returns (Layout storage l) {
    bytes32 slot = STORAGE_SLOT;
    assembly {
      l.slot := slot
    }
  }
}

File 17 of 38 : ERC1155SupplyUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/extensions/ERC1155Supply.sol)

pragma solidity ^0.8.0;

import "../ERC1155Upgradeable.sol";
import { ERC1155SupplyStorage } from "./ERC1155SupplyStorage.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev Extension of ERC1155 that adds tracking of total supply per id.
 *
 * Useful for scenarios where Fungible and Non-fungible tokens have to be
 * clearly identified. Note: While a totalSupply of 1 might mean the
 * corresponding is an NFT, there is no guarantees that no other token with the
 * same id are not going to be minted.
 */
abstract contract ERC1155SupplyUpgradeable is Initializable, ERC1155Upgradeable {
    using ERC1155SupplyStorage for ERC1155SupplyStorage.Layout;
    function __ERC1155Supply_init() internal onlyInitializing {
    }

    function __ERC1155Supply_init_unchained() internal onlyInitializing {
    }

    /**
     * @dev Total amount of tokens in with a given id.
     */
    function totalSupply(uint256 id) public view virtual returns (uint256) {
        return ERC1155SupplyStorage.layout()._totalSupply[id];
    }

    /**
     * @dev Indicates whether any token exist with a given id, or not.
     */
    function exists(uint256 id) public view virtual returns (bool) {
        return ERC1155SupplyUpgradeable.totalSupply(id) > 0;
    }

    /**
     * @dev See {ERC1155-_beforeTokenTransfer}.
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual override {
        super._beforeTokenTransfer(operator, from, to, ids, amounts, data);

        if (from == address(0)) {
            for (uint256 i = 0; i < ids.length; ++i) {
                ERC1155SupplyStorage.layout()._totalSupply[ids[i]] += amounts[i];
            }
        }

        if (to == address(0)) {
            for (uint256 i = 0; i < ids.length; ++i) {
                uint256 id = ids[i];
                uint256 amount = amounts[i];
                uint256 supply = ERC1155SupplyStorage.layout()._totalSupply[id];
                require(supply >= amount, "ERC1155: burn amount exceeds totalSupply");
                unchecked {
                    ERC1155SupplyStorage.layout()._totalSupply[id] = supply - amount;
                }
            }
        }
    }
}

File 18 of 38 : IERC1155MetadataURIUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.0;

import "../IERC1155Upgradeable.sol";

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable {
    /**
     * @dev Returns the URI for token type `id`.
     *
     * If the `\{id\}` substring is present in the URI, it must be replaced by
     * clients with the actual token type ID.
     */
    function uri(uint256 id) external view returns (string memory);
}

File 19 of 38 : IERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev _Available since v3.1._
 */
interface IERC1155ReceiverUpgradeable is IERC165Upgradeable {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

File 20 of 38 : IERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165Upgradeable.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 IERC1155Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred 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 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 21 of 38 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }


    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

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

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

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

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

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

File 23 of 38 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }
}

File 24 of 38 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^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);
}

File 25 of 38 : MathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 26 of 38 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = MathUpgradeable.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, MathUpgradeable.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 27 of 38 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

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

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

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

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

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

            if (lastIndex != toDeleteIndex) {
                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] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // 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) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // 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 in 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));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 28 of 38 : IBeanstalkUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

interface IBeanstalkUpgradeable {
    event SetFertilizer(uint128 id, uint128 bpf);

    function addFertilizerOwner(uint128 id, uint128 amount, uint256 minLP) external payable;

    function balanceOfBatchFertilizer(
        address[] memory accounts,
        uint256[] memory ids
    ) external view returns (IFertilizer.Balance[] memory);

    function balanceOfFertilized(
        address account,
        uint256[] memory ids
    ) external view returns (uint256 beans);

    function balanceOfFertilizer(
        address account,
        uint256 id
    ) external view returns (IFertilizer.Balance memory);

    function balanceOfUnfertilized(
        address account,
        uint256[] memory ids
    ) external view returns (uint256 beans);

    function beansPerFertilizer() external view returns (uint128 bpf);

    function claimFertilized(uint256[] memory ids, uint8 mode) external payable;

    function getActiveFertilizer() external view returns (uint256);

    function getCurrentHumidity() external view returns (uint128 humidity);

    function getEndBpf() external view returns (uint128 endBpf);

    function getFertilizer(uint128 id) external view returns (uint256);

    function getFertilizers() external view returns (FertilizerFacet.Supply[] memory fertilizers);

    function getFirst() external view returns (uint128);

    function getHumidity(uint128 _s) external pure returns (uint128 humidity);

    function getLast() external view returns (uint128);

    function getNext(uint128 id) external view returns (uint128);

    function isFertilizing() external view returns (bool);

    function mintFertilizer(uint128 amount, uint256 minLP, uint8 mode) external payable;

    function payFertilizer(address account, uint256 amount) external payable;

    function remainingRecapitalization() external view returns (uint256);

    function totalFertilizedBeans() external view returns (uint256 beans);

    function totalFertilizerBeans() external view returns (uint256 beans);

    function totalUnfertilizedBeans() external view returns (uint256 beans);

    event AddUnripeToken(
        address indexed unripeToken,
        address indexed underlyingToken,
        bytes32 merkleRoot
    );
    event ChangeUnderlying(address indexed token, int256 underlying);
    event Chop(address indexed account, address indexed token, uint256 amount, uint256 underlying);
    event Pick(address indexed account, address indexed token, uint256 amount);

    function _getPenalizedUnderlying(
        address unripeToken,
        uint256 amount,
        uint256 supply
    ) external view returns (uint256 redeem);

    function addUnripeToken(
        address unripeToken,
        address underlyingToken,
        bytes32 root
    ) external payable;

    function balanceOfPenalizedUnderlying(
        address unripeToken,
        address account
    ) external view returns (uint256 underlying);

    function balanceOfUnderlying(
        address unripeToken,
        address account
    ) external view returns (uint256 underlying);

    function chop(
        address unripeToken,
        uint256 amount,
        uint8 fromMode,
        uint8 toMode
    ) external payable returns (uint256 underlyingAmount);

    function getPenalizedUnderlying(
        address unripeToken,
        uint256 amount
    ) external view returns (uint256 redeem);

    function getPenalty(address unripeToken) external view returns (uint256 penalty);

    function getPercentPenalty(address unripeToken) external view returns (uint256 penalty);

    function getRecapFundedPercent(address unripeToken) external view returns (uint256 percent);

    function getRecapPaidPercent() external view returns (uint256 penalty);

    function getTotalUnderlying(address unripeToken) external view returns (uint256 underlying);

    function getUnderlying(
        address unripeToken,
        uint256 amount
    ) external view returns (uint256 redeem);

    function getUnderlyingPerUnripeToken(
        address unripeToken
    ) external view returns (uint256 underlyingPerToken);

    function getUnderlyingToken(
        address unripeToken
    ) external view returns (address underlyingToken);

    function isUnripe(address unripeToken) external view returns (bool unripe);

    function pick(
        address token,
        uint256 amount,
        bytes32[] memory proof,
        uint8 mode
    ) external payable;

    function picked(address account, address token) external view returns (bool);

    function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_);

    function facetAddresses() external view returns (address[] memory facetAddresses_);

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

    function claimOwnership() external;

    function owner() external view returns (address owner_);

    function ownerCandidate() external view returns (address ownerCandidate_);

    function transferOwnership(address _newOwner) external;

    event Pause(uint256 timestamp);
    event Unpause(uint256 timestamp, uint256 timePassed);

    function pause() external payable;

    function unpause() external payable;

    function addLiquidity(
        address pool,
        address registry,
        uint256[] memory amounts,
        uint256 minAmountOut,
        uint8 fromMode,
        uint8 toMode
    ) external payable;

    function exchange(
        address pool,
        address registry,
        address fromToken,
        address toToken,
        uint256 amountIn,
        uint256 minAmountOut,
        uint8 fromMode,
        uint8 toMode
    ) external payable;

    function exchangeUnderlying(
        address pool,
        address fromToken,
        address toToken,
        uint256 amountIn,
        uint256 minAmountOut,
        uint8 fromMode,
        uint8 toMode
    ) external payable;

    function removeLiquidity(
        address pool,
        address registry,
        uint256 amountIn,
        uint256[] memory minAmountsOut,
        uint8 fromMode,
        uint8 toMode
    ) external payable;

    function removeLiquidityImbalance(
        address pool,
        address registry,
        uint256[] memory amountsOut,
        uint256 maxAmountIn,
        uint8 fromMode,
        uint8 toMode
    ) external payable;

    function removeLiquidityOneToken(
        address pool,
        address registry,
        address toToken,
        uint256 amountIn,
        uint256 minAmountOut,
        uint8 fromMode,
        uint8 toMode
    ) external payable;

    function advancedPipe(
        AdvancedPipeCall[] memory pipes,
        uint256 value
    ) external payable returns (bytes[] memory results);

    function etherPipe(
        PipeCall memory p,
        uint256 value
    ) external payable returns (bytes memory result);

    function multiPipe(PipeCall[] memory pipes) external payable returns (bytes[] memory results);

    function pipe(PipeCall memory p) external payable returns (bytes memory result);

    function readPipe(PipeCall memory p) external view returns (bytes memory result);

    function advancedFarm(
        AdvancedFarmCall[] memory data
    ) external payable returns (bytes[] memory results);

    function farm(bytes[] memory data) external payable returns (bytes[] memory results);

    event InternalBalanceChanged(address indexed user, address indexed token, int256 delta);
    event TokenApproval(
        address indexed owner,
        address indexed spender,
        address token,
        uint256 amount
    );

    function approveToken(address spender, address token, uint256 amount) external payable;

    function decreaseTokenAllowance(
        address spender,
        address token,
        uint256 subtractedValue
    ) external returns (bool);

    function getAllBalance(
        address account,
        address token
    ) external view returns (Storage.Rain memory b);

    function getAllBalances(
        address account,
        address[] memory tokens
    ) external view returns (Storage.Rain[] memory balances);

    function getBalance(address account, address token) external view returns (uint256 balance);

    function getBalances(
        address account,
        address[] memory tokens
    ) external view returns (uint256[] memory balances);

    function getExternalBalance(
        address account,
        address token
    ) external view returns (uint256 balance);

    function getExternalBalances(
        address account,
        address[] memory tokens
    ) external view returns (uint256[] memory balances);

    function getInternalBalance(
        address account,
        address token
    ) external view returns (uint256 balance);

    function getInternalBalances(
        address account,
        address[] memory tokens
    ) external view returns (uint256[] memory balances);

    function increaseTokenAllowance(
        address spender,
        address token,
        uint256 addedValue
    ) external returns (bool);

    function permitToken(
        address owner,
        address spender,
        address token,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external payable;

    function tokenAllowance(
        address account,
        address spender,
        address token
    ) external view returns (uint256);

    function tokenPermitDomainSeparator() external view returns (bytes32);

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

    function transferInternalTokenFrom(
        address token,
        address sender,
        address recipient,
        uint256 amount,
        uint8 toMode
    ) external payable;

    function transferToken(
        address token,
        address recipient,
        uint256 amount,
        uint8 fromMode,
        uint8 toMode
    ) external payable;

    function unwrapEth(uint256 amount, uint8 mode) external payable;

    function wrapEth(uint256 amount, uint8 mode) external payable;

    function batchTransferERC1155(
        address token,
        address to,
        uint256[] memory ids,
        uint256[] memory values
    ) external payable;

    function permitERC20(
        address token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external payable;

    function permitERC721(
        address token,
        address spender,
        uint256 tokenId,
        uint256 deadline,
        bytes memory sig
    ) external payable;

    function transferERC1155(address token, address to, uint256 id, uint256 value) external payable;

    function transferERC721(address token, address to, uint256 id) external payable;

    event Harvest(address indexed account, uint256[] plots, uint256 beans);
    event PodListingCancelled(address indexed account, uint256 index);
    event Sow(address indexed account, uint256 index, uint256 beans, uint256 pods);

    function harvest(uint256[] memory plots, uint8 mode) external payable;

    function harvestableIndex() external view returns (uint256);

    function maxTemperature() external view returns (uint256);

    function plot(address account, uint256 index) external view returns (uint256);

    function podIndex() external view returns (uint256);

    function remainingPods() external view returns (uint256);

    function sow(
        uint256 beans,
        uint256 minTemperature,
        uint8 mode
    ) external payable returns (uint256 pods);

    function sowWithMin(
        uint256 beans,
        uint256 minTemperature,
        uint256 minSoil,
        uint8 mode
    ) external payable returns (uint256 pods);

    function temperature() external view returns (uint256);

    function totalHarvestable() external view returns (uint256);

    function totalHarvested() external view returns (uint256);

    function totalPods() external view returns (uint256);

    function totalSoil() external view returns (uint256);

    function totalUnharvestable() external view returns (uint256);

    function yield() external view returns (uint32);

    event CompleteFundraiser(uint32 indexed id);
    event CreateFundraiser(uint32 indexed id, address payee, address token, uint256 amount);
    event FundFundraiser(address indexed account, uint32 indexed id, uint256 amount);

    function createFundraiser(address payee, address token, uint256 amount) external payable;

    function fund(uint32 id, uint256 amount, uint8 mode) external payable returns (uint256);

    function fundingToken(uint32 id) external view returns (address);

    function fundraiser(uint32 id) external view returns (Storage.Fundraiser memory);

    function numberOfFundraisers() external view returns (uint32);

    function remainingFunding(uint32 id) external view returns (uint256);

    function totalFunding(uint32 id) external view returns (uint256);

    event PlotTransfer(address indexed from, address indexed to, uint256 indexed id, uint256 pods);
    event PodApproval(address indexed owner, address indexed spender, uint256 pods);
    event PodListingCreated(
        address indexed account,
        uint256 index,
        uint256 start,
        uint256 amount,
        uint24 pricePerPod,
        uint256 maxHarvestableIndex,
        uint256 minFillAmount,
        bytes pricingFunction,
        uint8 mode,
        uint8 pricingType
    );
    event PodListingFilled(
        address indexed from,
        address indexed to,
        uint256 index,
        uint256 start,
        uint256 amount,
        uint256 costInBeans
    );
    event PodOrderCancelled(address indexed account, bytes32 id);
    event PodOrderCreated(
        address indexed account,
        bytes32 id,
        uint256 amount,
        uint24 pricePerPod,
        uint256 maxPlaceInLine,
        uint256 minFillAmount,
        bytes pricingFunction,
        uint8 priceType
    );
    event PodOrderFilled(
        address indexed from,
        address indexed to,
        bytes32 id,
        uint256 index,
        uint256 start,
        uint256 amount,
        uint256 costInBeans
    );

    function allowancePods(address owner, address spender) external view returns (uint256);

    function approvePods(address spender, uint256 amount) external payable;

    function cancelPodListing(uint256 index) external payable;

    function cancelPodOrder(
        uint24 pricePerPod,
        uint256 maxPlaceInLine,
        uint256 minFillAmount,
        uint8 mode
    ) external payable;

    function cancelPodOrderV2(
        uint256 maxPlaceInLine,
        uint256 minFillAmount,
        bytes memory pricingFunction,
        uint8 mode
    ) external payable;

    function createPodListing(
        uint256 index,
        uint256 start,
        uint256 amount,
        uint24 pricePerPod,
        uint256 maxHarvestableIndex,
        uint256 minFillAmount,
        uint8 mode
    ) external payable;

    function createPodListingV2(
        uint256 index,
        uint256 start,
        uint256 amount,
        uint256 maxHarvestableIndex,
        uint256 minFillAmount,
        bytes memory pricingFunction,
        uint8 mode
    ) external payable;

    function createPodOrder(
        uint256 beanAmount,
        uint24 pricePerPod,
        uint256 maxPlaceInLine,
        uint256 minFillAmount,
        uint8 mode
    ) external payable returns (bytes32 id);

    function createPodOrderV2(
        uint256 beanAmount,
        uint256 maxPlaceInLine,
        uint256 minFillAmount,
        bytes memory pricingFunction,
        uint8 mode
    ) external payable returns (bytes32 id);

    function fillPodListing(
        Listing.PodListing memory l,
        uint256 beanAmount,
        uint8 mode
    ) external payable;

    function fillPodListingV2(
        Listing.PodListing memory l,
        uint256 beanAmount,
        bytes memory pricingFunction,
        uint8 mode
    ) external payable;

    function fillPodOrder(
        Order.PodOrder memory o,
        uint256 index,
        uint256 start,
        uint256 amount,
        uint8 mode
    ) external payable;

    function fillPodOrderV2(
        Order.PodOrder memory o,
        uint256 index,
        uint256 start,
        uint256 amount,
        bytes memory pricingFunction,
        uint8 mode
    ) external payable;

    function getAmountBeansToFillOrderV2(
        uint256 placeInLine,
        uint256 amountPodsFromOrder,
        bytes memory pricingFunction
    ) external pure returns (uint256 beanAmount);

    function getAmountPodsFromFillListingV2(
        uint256 placeInLine,
        uint256 podListingAmount,
        uint256 fillBeanAmount,
        bytes memory pricingFunction
    ) external pure returns (uint256 amount);

    function podListing(uint256 index) external view returns (bytes32);

    function podOrder(
        address account,
        uint24 pricePerPod,
        uint256 maxPlaceInLine,
        uint256 minFillAmount
    ) external view returns (uint256);

    function podOrderById(bytes32 id) external view returns (uint256);

    function podOrderV2(
        address account,
        uint256 maxPlaceInLine,
        uint256 minFillAmount,
        bytes memory pricingFunction
    ) external view returns (uint256);

    function transferPlot(
        address sender,
        address recipient,
        uint256 id,
        uint256 start,
        uint256 end
    ) external payable;

    function bdv(address token, uint256 amount) external view returns (uint256);

    function beanToBDV(uint256 amount) external pure returns (uint256);

    function curveToBDV(uint256 amount) external view returns (uint256);

    function unripeBeanToBDV(uint256 amount) external view returns (uint256);

    function unripeLPToBDV(uint256 amount) external view returns (uint256);

    event Convert(
        address indexed account,
        address fromToken,
        address toToken,
        uint256 fromAmount,
        uint256 toAmount
    );
    event RemoveDeposits(
        address indexed account,
        address indexed token,
        uint32[] seasons,
        uint256[] amounts,
        uint256 amount
    );

    function convert(
        bytes memory convertData,
        uint32[] memory crates,
        uint256[] memory amounts
    )
        external
        payable
        returns (
            uint32 toSeason,
            uint256 fromAmount,
            uint256 toAmount,
            uint256 fromBdv,
            uint256 toBdv
        );

    function getAmountOut(
        address tokenIn,
        address tokenOut,
        uint256 amountIn
    ) external view returns (uint256 amountOut);

    function getMaxAmountIn(
        address tokenIn,
        address tokenOut
    ) external view returns (uint256 amountIn);

    event AddDeposit(
        address indexed account,
        address indexed token,
        uint32 season,
        uint256 amount,
        uint256 bdv
    );
    event AddWithdrawal(
        address indexed account,
        address indexed token,
        uint32 season,
        uint256 amount
    );
    event ClaimPlenty(address indexed account, uint256 plenty);
    event DepositApproval(
        address indexed owner,
        address indexed spender,
        address token,
        uint256 amount
    );
    event Plant(address indexed account, uint256 beans);
    event RemoveDeposit(
        address indexed account,
        address indexed token,
        uint32 season,
        uint256 amount
    );
    event RemoveWithdrawal(
        address indexed account,
        address indexed token,
        uint32 season,
        uint256 amount
    );
    event RemoveWithdrawals(
        address indexed account,
        address indexed token,
        uint32[] seasons,
        uint256 amount
    );
    event SeedsBalanceChanged(address indexed account, int256 delta);
    event StalkBalanceChanged(address indexed account, int256 delta, int256 deltaRoots);

    function approveDeposit(address spender, address token, uint256 amount) external payable;

    function balanceOfEarnedBeans(address account) external view returns (uint256 beans);

    function balanceOfEarnedSeeds(address account) external view returns (uint256);

    function balanceOfEarnedStalk(address account) external view returns (uint256);

    function balanceOfGrownStalk(address account) external view returns (uint256);

    function balanceOfPlenty(address account) external view returns (uint256 plenty);

    function balanceOfRainRoots(address account) external view returns (uint256);

    function balanceOfRoots(address account) external view returns (uint256);

    function balanceOfSeeds(address account) external view returns (uint256);

    function balanceOfSop(
        address account
    ) external view returns (SiloExit.AccountSeasonOfPlenty memory sop);

    function balanceOfStalk(address account) external view returns (uint256);

    function claimPlenty() external payable;

    function claimWithdrawal(address token, uint32 season, uint8 mode) external payable;

    function claimWithdrawals(address token, uint32[] memory seasons, uint8 mode) external payable;

    function decreaseDepositAllowance(
        address spender,
        address token,
        uint256 subtractedValue
    ) external returns (bool);

    function deposit(address token, uint256 amount, uint8 mode) external payable;

    function depositAllowance(
        address account,
        address spender,
        address token
    ) external view returns (uint256);

    function depositPermitDomainSeparator() external view returns (bytes32);

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

    function enrootDeposit(address token, uint32 _season, uint256 amount) external;

    function enrootDeposits(
        address token,
        uint32[] memory seasons,
        uint256[] memory amounts
    ) external;

    function getDeposit(
        address account,
        address token,
        uint32 season
    ) external view returns (uint256, uint256);

    function getTotalDeposited(address token) external view returns (uint256);

    function getTotalWithdrawn(address token) external view returns (uint256);

    function getWithdrawal(
        address account,
        address token,
        uint32 season
    ) external view returns (uint256);

    function increaseDepositAllowance(
        address spender,
        address token,
        uint256 addedValue
    ) external returns (bool);

    function lastSeasonOfPlenty() external view returns (uint32);

    function lastUpdate(address account) external view returns (uint32);

    function permitDeposit(
        address owner,
        address spender,
        address token,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external payable;

    function permitDeposits(
        address owner,
        address spender,
        address[] memory tokens,
        uint256[] memory values,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external payable;

    function plant() external payable returns (uint256 beans);

    function tokenSettings(address token) external view returns (Storage.SiloSettings memory);

    function totalEarnedBeans() external view returns (uint256);

    function totalRoots() external view returns (uint256);

    function totalSeeds() external view returns (uint256);

    function totalStalk() external view returns (uint256);

    function transferDeposit(
        address sender,
        address recipient,
        address token,
        uint32 season,
        uint256 amount
    ) external payable returns (uint256 bdv);

    function transferDeposits(
        address sender,
        address recipient,
        address token,
        uint32[] memory seasons,
        uint256[] memory amounts
    ) external payable returns (uint256[] memory bdvs);

    function update(address account) external payable;

    function withdrawDeposit(address token, uint32 season, uint256 amount) external payable;

    function withdrawDeposits(
        address token,
        uint32[] memory seasons,
        uint256[] memory amounts
    ) external payable;

    function withdrawFreeze() external view returns (uint8);

    event DewhitelistToken(address indexed token);
    event WhitelistToken(address indexed token, bytes4 selector, uint256 seeds, uint256 stalk);

    function dewhitelistToken(address token) external payable;

    function whitelistToken(
        address token,
        bytes4 selector,
        uint32 stalk,
        uint32 seeds
    ) external payable;

    event Incentivization(address indexed account, uint256 beans);
    event Reward(uint32 indexed season, uint256 toField, uint256 toSilo, uint256 toFertilizer);
    event SeasonOfPlenty(uint256 indexed season, uint256 amount, uint256 toField);
    event Soil(uint32 indexed season, uint256 soil);
    event Sunrise(uint256 indexed season);
    event WeatherChange(uint256 indexed season, uint256 caseId, int8 change);

    function abovePeg() external view returns (bool);

    function gm(address account, uint8 mode) external payable returns (uint256);

    function paused() external view returns (bool);

    function plentyPerRoot(uint32 season) external view returns (uint256);

    function poolDeltaB(address pool) external view returns (int256);

    function rain() external view returns (Storage.Rain memory);

    function season() external view returns (uint32);

    function seasonTime() external view returns (uint32);

    function sunrise() external payable returns (uint256);

    function sunriseBlock() external view returns (uint32);

    function time() external view returns (Storage.Season memory);

    function totalDeltaB() external view returns (int256 deltaB);

    function weather() external view returns (Storage.Weather memory);
}

struct AdvancedPipeCall {
    address target;
    bytes callData;
    bytes clipboard;
}

struct PipeCall {
    address target;
    bytes data;
}

struct AdvancedFarmCall {
    bytes callData;
    bytes clipboard;
}

interface IFertilizer {
    struct Balance {
        uint128 amount;
        uint128 lastBpf;
    }
}

interface FertilizerFacet {
    struct Supply {
        uint128 endBpf;
        uint256 supply;
    }
}

interface TokenFacet {
    struct Rain {
        uint256 deprecated;
        uint256 pods;
        uint256 roots;
    }
}

interface Storage {
    struct Rain {
        uint256 deprecated;
        uint256 pods;
        uint256 roots;
    }

    struct Fundraiser {
        address payee;
        address token;
        uint256 total;
        uint256 remaining;
        uint256 start;
    }

    struct SiloSettings {
        bytes4 selector;
        uint32 seeds;
        uint32 stalk;
    }

    struct Season {
        uint32 current;
        uint32 lastSop;
        uint8 withdrawSeasons;
        uint32 lastSopSeason;
        uint32 rainStart;
        bool raining;
        bool fertilizing;
        uint32 sunriseBlock;
        bool abovePeg;
        uint256 start;
        uint256 period;
        uint256 timestamp;
    }

    struct Weather {
        uint256[2] deprecated;
        uint128 lastDSoil;
        uint32 lastSowTime;
        uint32 thisSowTime;
        uint32 t;
    }
}

interface Listing {
    struct PodListing {
        address account;
        uint256 index;
        uint256 start;
        uint256 amount;
        uint24 pricePerPod;
        uint256 maxHarvestableIndex;
        uint256 minFillAmount;
        uint8 mode;
    }
}

interface Order {
    struct PodOrder {
        address account;
        uint24 pricePerPod;
        uint256 maxPlaceInLine;
        uint256 minFillAmount;
    }
}

interface SiloExit {
    struct AccountSeasonOfPlenty {
        uint32 lastRain;
        uint32 lastSop;
        uint256 roots;
        uint256 plentyPerRoot;
        uint256 plenty;
    }
}

File 29 of 38 : ERC1155WhitelistStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

struct ProxySpender {
    bytes32 name;
    mapping(uint256 => bool) blacklisted;
}

library ERC1155WhitelistStorage {
    struct Layout {
        mapping(uint256 => bool) blacklistForCompliance;
        mapping(address => ProxySpender) proxySpenders;
        string baseURI;
        string contractURI;
    }

    bytes32 internal constant STORAGE_SLOT =
        keccak256("irrigation.contracts.storage.ERC1155Whitelist");

    function layout() internal pure returns (Layout storage l) {
        bytes32 slot = STORAGE_SLOT;
        assembly {
            l.slot := slot
        }
    }
}

File 30 of 38 : WaterCommonStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

import {IBeanstalkUpgradeable} from "../beanstalk/IBeanstalkUpgradeable.sol";
import {IERC1155Upgradeable} from "@gnus.ai/contracts-upgradeable-diamond/contracts/token/ERC1155/IERC1155Upgradeable.sol";

library WaterCommonStorage {
    struct Layout {
        // Beanstalk protocol contract
        IBeanstalkUpgradeable beanstalk;
        // fertilizer token contract
        IERC1155Upgradeable fertilizer;
    }

    bytes32 internal constant STORAGE_SLOT = keccak256("irrigation.contracts.storage.WaterCommon");

    function layout() internal pure returns (Layout storage l) {
        bytes32 slot = STORAGE_SLOT;
        assembly {
            l.slot := slot
        }
    }
}

File 31 of 38 : IDiamondCut.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/

interface IDiamondCut {
    enum FacetCutAction {Add, Replace, Remove}
    // Add=0, Replace=1, Remove=2

    struct FacetCut {
        address facetAddress;
        FacetCutAction action;
        bytes4[] functionSelectors;
    }

    /// @notice Add/replace/remove any number of functions and optionally execute
    ///         a function with delegatecall
    /// @param _diamondCut Contains the facet addresses and function selectors
    /// @param _init The address of the contract or facet to execute _calldata
    /// @param _calldata A function call, including function selector and arguments
    ///                  _calldata is executed with delegatecall on _init
    function diamondCut(
        FacetCut[] calldata _diamondCut,
        address _init,
        bytes calldata _calldata
    ) external;

    event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
}

File 32 of 38 : IERC1155WhitelistUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

interface IERC1155WhitelistUpgradeable {
    function mint(address to, uint256 id, uint256 amount, bytes memory data) external;

    function mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) external;
    /// @dev burn total amount that user hold
    /// @param to user address
    /// @param tokenId token id
    function burnTotalAmount(address to, uint256 tokenId) external;
}

interface IERC1155BurnableUpgradeable{
    function burn(address account, uint256 id, uint256 value) external;
}

File 33 of 38 : IPodsOracleUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

interface IPodsOracleUpgradeable {
    ///@dev get virtual price of a plot with latest podIndex and harvestableIndex
    function latestPriceOfPods(uint256 placeInLine, uint256 pods) external returns (uint256);

    /// getter for price of a plot at any podIndex
    /**
     * @notice Get price for any pods to 1e18
     * @param placeInLine with 1e6 decimals
     * @param pods with 1e6 decimals
     * @return price pods price
     */
    function priceOfPods(
        uint256 placeInLine,
        uint256 pods,
        uint256 podIndex,
        uint256 harvestableIndex
    ) external returns (uint256);
}

File 34 of 38 : Constants.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

library Constants {
    /// Addresses
    address internal constant CURVE_ROUTER = 0x99a58482BD75cbab83b27EC03CA68fF489b5788f;
    address internal constant BEAN = 0xBEA0000029AD1c77D3d5D23Ba2D8893dB9d1Efab;
    address internal constant ETHER = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
    address internal constant TRI_CRYPTO_POOL = 0xD51a44d3FaE010294C616388b506AcdA1bfAAE46;
    address internal constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
    address internal constant CURVE_BEAN_METAPOOL = 0xc9C32cd16Bf7eFB85Ff14e0c8603cc90F6F2eE49;
    address internal constant BEANSTALK_PRICE = 0xF2C2b7eabcB353bF6f2128a7f8e1e32Eeb112530;
    address internal constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
    address internal constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
    address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
    address internal constant ZERO = 0x0000000000000000000000000000000000000000;
    address internal constant BEANSTALK = 0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5;
    address internal constant FERTILIZER = 0x402c84De2Ce49aF88f5e2eF3710ff89bFED36cB6;

    /// @notice time out to get price from chainlink
    /// @dev should update before deploying on mainnet
    uint256 internal constant GRACE_PERIOD_TIME = 72000000;

    /// underlying decimals
    uint256 internal constant D18 = 1e18;
    // tranche nft is fractionalized with decimals 6
    uint8 internal constant TRANCHE_DECIMALS = 6;
    uint8 internal constant WATER_DECIMALS = 18;    

    bytes internal constant EMPTY = "";

    /// function selectors
    bytes4 internal constant ERC1155_ACCEPTED = 0xf23a6e61; // bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))
    bytes4 internal constant ERC1155_BATCH_ACCEPTED = 0xbc197c81; // bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))
}

File 35 of 38 : FullMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/// @title Contains math functions
library FullMath {
    /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    function mulDivRoundingUp(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        result = (a * b) / denominator;
        if (mulmod(a, b, denominator) > 0) {
            require(result < type(uint256).max);
            result++;
        }
    }

    function mulDivRoundingUp128(
        uint128 a,
        uint128 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        result = (uint256(a) * uint256(b)) / denominator;
        if (mulmod(uint256(a), uint256(b), denominator) > 0) {
            // require(result < type(uint256).max); // no overflow for uint128
            result++;
        }
    }
}

File 36 of 38 : LibDiamond.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/
import { IDiamondCut } from "../interfaces/IDiamondCut.sol";

// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.
// The loupe functions are required by the EIP2535 Diamonds standard

library LibDiamond {
    bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage");

    struct DiamondStorage {
        // maps function selectors to the facets that execute the functions.
        // and maps the selectors to their position in the selectorSlots array.
        // func selector => address facet, selector position
        mapping(bytes4 => bytes32) facets;
        // array of slots of function selectors.
        // each slot holds 8 function selectors.
        mapping(uint256 => bytes32) selectorSlots;
        // The number of function selectors in selectorSlots
        uint16 selectorCount;
        // Used to query if a contract implements an interface.
        // Used to implement ERC-165.
        mapping(bytes4 => bool) supportedInterfaces;
        // owner of the contract
        address contractOwner;
    }

    function diamondStorage() internal pure returns (DiamondStorage storage ds) {
        bytes32 position = DIAMOND_STORAGE_POSITION;
        assembly {
            ds.slot := position
        }
    }

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

    function setContractOwner(address _newOwner) internal {
        DiamondStorage storage ds = diamondStorage();
        address previousOwner = ds.contractOwner;
        ds.contractOwner = _newOwner;
        emit OwnershipTransferred(previousOwner, _newOwner);
    }

    function contractOwner() internal view returns (address contractOwner_) {
        contractOwner_ = diamondStorage().contractOwner;
    }

    function enforceIsContractOwner() internal view {
        require(msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner");
    }

    event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);

    bytes32 constant CLEAR_ADDRESS_MASK = bytes32(uint256(0xffffffffffffffffffffffff));
    bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224));

    // Internal function version of diamondCut
    // This code is almost the same as the external diamondCut,
    // except it is using 'Facet[] memory _diamondCut' instead of
    // 'Facet[] calldata _diamondCut'.
    // The code is duplicated to prevent copying calldata to memory which
    // causes an error for a two dimensional array.
    function diamondCut(
        IDiamondCut.FacetCut[] memory _diamondCut,
        address _init,
        bytes memory _calldata
    ) internal {
        DiamondStorage storage ds = diamondStorage();
        uint256 originalSelectorCount = ds.selectorCount;
        uint256 selectorCount = originalSelectorCount;
        bytes32 selectorSlot;
        // Check if last selector slot is not full
        // "selectorCount & 7" is a gas efficient modulo by eight "selectorCount % 8"
        if (selectorCount & 7 > 0) {
            // get last selectorSlot
            // "selectorSlot >> 3" is a gas efficient division by 8 "selectorSlot / 8"
            selectorSlot = ds.selectorSlots[selectorCount >> 3];
        }
        // loop through diamond cut
        for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {
            (selectorCount, selectorSlot) = addReplaceRemoveFacetSelectors(
                selectorCount,
                selectorSlot,
                _diamondCut[facetIndex].facetAddress,
                _diamondCut[facetIndex].action,
                _diamondCut[facetIndex].functionSelectors
            );
        }
        if (selectorCount != originalSelectorCount) {
            ds.selectorCount = uint16(selectorCount);
        }
        // If last selector slot is not full
        // "selectorCount & 7" is a gas efficient modulo by eight "selectorCount % 8"
        if (selectorCount & 7 > 0) {
            // "selectorSlot >> 3" is a gas efficient division by 8 "selectorSlot / 8"
            ds.selectorSlots[selectorCount >> 3] = selectorSlot;
        }
        emit DiamondCut(_diamondCut, _init, _calldata);
        initializeDiamondCut(_init, _calldata);
    }

    function addReplaceRemoveFacetSelectors(
        uint256 _selectorCount,
        bytes32 _selectorSlot,
        address _newFacetAddress,
        IDiamondCut.FacetCutAction _action,
        bytes4[] memory _selectors
    ) internal returns (uint256, bytes32) {
        DiamondStorage storage ds = diamondStorage();
        require(_selectors.length > 0, "LibDiamondCut: No selectors in facet to cut");
        if (_action == IDiamondCut.FacetCutAction.Add) {
            enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Add facet has no code");
            for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
                bytes4 selector = _selectors[selectorIndex];
                bytes32 oldFacet = ds.facets[selector];
                require(address(bytes20(oldFacet)) == address(0), "LibDiamondCut: Can't add function that already exists");
                // add facet for selector
                ds.facets[selector] = bytes20(_newFacetAddress) | bytes32(_selectorCount);
                // "_selectorCount & 7" is a gas efficient modulo by eight "_selectorCount % 8"
                // " << 5 is the same as multiplying by 32 ( * 32)
                uint256 selectorInSlotPosition = (_selectorCount & 7) << 5;
                // clear selector position in slot and add selector
                _selectorSlot = (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) | (bytes32(selector) >> selectorInSlotPosition);
                // if slot is full then write it to storage
                if (selectorInSlotPosition == 224) {
                    // "_selectorSlot >> 3" is a gas efficient division by 8 "_selectorSlot / 8"
                    ds.selectorSlots[_selectorCount >> 3] = _selectorSlot;
                    _selectorSlot = 0;
                }
                _selectorCount++;
            }
        } else if (_action == IDiamondCut.FacetCutAction.Replace) {
            enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Replace facet has no code");
            for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
                bytes4 selector = _selectors[selectorIndex];
                bytes32 oldFacet = ds.facets[selector];
                address oldFacetAddress = address(bytes20(oldFacet));
                // only useful if immutable functions exist
                require(oldFacetAddress != address(this), "LibDiamondCut: Can't replace immutable function");
                require(oldFacetAddress != _newFacetAddress, "LibDiamondCut: Can't replace function with same function");
                require(oldFacetAddress != address(0), "LibDiamondCut: Can't replace function that doesn't exist");
                // replace old facet address
                ds.facets[selector] = (oldFacet & CLEAR_ADDRESS_MASK) | bytes20(_newFacetAddress);
            }
        } else if (_action == IDiamondCut.FacetCutAction.Remove) {
            require(_newFacetAddress == address(0), "LibDiamondCut: Remove facet address must be address(0)");
            // "_selectorCount >> 3" is a gas efficient division by 8 "_selectorCount / 8"
            uint256 selectorSlotCount = _selectorCount >> 3;
            // "_selectorCount & 7" is a gas efficient modulo by eight "_selectorCount % 8"
            uint256 selectorInSlotIndex = _selectorCount & 7;
            for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
                if (_selectorSlot == 0) {
                    // get last selectorSlot
                    selectorSlotCount--;
                    _selectorSlot = ds.selectorSlots[selectorSlotCount];
                    selectorInSlotIndex = 7;
                } else {
                    selectorInSlotIndex--;
                }
                bytes4 lastSelector;
                uint256 oldSelectorsSlotCount;
                uint256 oldSelectorInSlotPosition;
                // adding a block here prevents stack too deep error
                {
                    bytes4 selector = _selectors[selectorIndex];
                    bytes32 oldFacet = ds.facets[selector];
                    require(address(bytes20(oldFacet)) != address(0), "LibDiamondCut: Can't remove function that doesn't exist");
                    // only useful if immutable functions exist
                    require(address(bytes20(oldFacet)) != address(this), "LibDiamondCut: Can't remove immutable function");
                    // replace selector with last selector in ds.facets
                    // gets the last selector
                    // " << 5 is the same as multiplying by 32 ( * 32)
                    lastSelector = bytes4(_selectorSlot << (selectorInSlotIndex << 5));
                    if (lastSelector != selector) {
                        // update last selector slot position info
                        ds.facets[lastSelector] = (oldFacet & CLEAR_ADDRESS_MASK) | bytes20(ds.facets[lastSelector]);
                    }
                    delete ds.facets[selector];
                    uint256 oldSelectorCount = uint16(uint256(oldFacet));
                    // "oldSelectorCount >> 3" is a gas efficient division by 8 "oldSelectorCount / 8"
                    oldSelectorsSlotCount = oldSelectorCount >> 3;
                    // "oldSelectorCount & 7" is a gas efficient modulo by eight "oldSelectorCount % 8"
                    // " << 5 is the same as multiplying by 32 ( * 32)
                    oldSelectorInSlotPosition = (oldSelectorCount & 7) << 5;
                }
                if (oldSelectorsSlotCount != selectorSlotCount) {
                    bytes32 oldSelectorSlot = ds.selectorSlots[oldSelectorsSlotCount];
                    // clears the selector we are deleting and puts the last selector in its place.
                    oldSelectorSlot =
                        (oldSelectorSlot & ~(CLEAR_SELECTOR_MASK >> oldSelectorInSlotPosition)) |
                        (bytes32(lastSelector) >> oldSelectorInSlotPosition);
                    // update storage with the modified slot
                    ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;
                } else {
                    // clears the selector we are deleting and puts the last selector in its place.
                    _selectorSlot =
                        (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> oldSelectorInSlotPosition)) |
                        (bytes32(lastSelector) >> oldSelectorInSlotPosition);
                }
                if (selectorInSlotIndex == 0) {
                    delete ds.selectorSlots[selectorSlotCount];
                    _selectorSlot = 0;
                }
            }
            _selectorCount = selectorSlotCount * 8 + selectorInSlotIndex;
        } else {
            revert("LibDiamondCut: Incorrect FacetCutAction");
        }
        return (_selectorCount, _selectorSlot);
    }

    function initializeDiamondCut(address _init, bytes memory _calldata) internal {
        if (_init == address(0)) {
            return;
        }
        enforceHasContractCode(_init, "LibDiamondCut: _init address has no code");
        (bool success, bytes memory error) = _init.delegatecall(_calldata);
        if (!success) {
            if (error.length > 0) {
                // bubble up error
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(error)
                    revert(add(32, error), returndata_size)
                }
            } else {
                revert("InitializationFunctionReverted(address, bytes)");
            }
        }
    }

    function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {
        uint256 contractSize;
        assembly {
            contractSize := extcodesize(_contract)
        }
        require(contractSize > 0, _errorMessage);
    }
}

File 37 of 38 : EIP2535Initializable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "@gnus.ai/contracts-upgradeable-diamond/contracts/proxy/utils/Initializable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/proxy/utils/InitializableStorage.sol";
import "../libraries/LibDiamond.sol";

abstract contract EIP2535Initializable is Initializable {

    // override Initializable::initializer modifier
    modifier EIP2535Initializer() {
        require(!InitializableStorage.layout()._initializing && InitializableStorage.layout()._initialized < 1, "Initializable: contract is already initialized");
        InitializableStorage.layout()._initialized = 1;
        InitializableStorage.layout()._initializing = true;
        _;
        // multiple facet contracts needed initialization on deployment
        InitializableStorage.layout()._initialized = 0;
        InitializableStorage.layout()._initializing = false;
    }

    modifier EIP2535Reinitializer(uint8 version) {
        require(!InitializableStorage.layout()._initializing && InitializableStorage.layout()._initialized < version, "Initializable: contract is already initialized");
        InitializableStorage.layout()._initialized = version;
        InitializableStorage.layout()._initializing = true;
        _;
        // multiple facet contracts needed re-initialization on ugrades for instance
        InitializableStorage.layout()._initialized = 0;
        InitializableStorage.layout()._initializing = false;
        }

}

File 38 of 38 : IrrigationAccessControl.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "@gnus.ai/contracts-upgradeable-diamond/contracts/access/AccessControlEnumerableUpgradeable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/proxy/utils/Initializable.sol";
import "../libraries/LibDiamond.sol";

abstract contract IrrigationAccessControl is Initializable, AccessControlEnumerableUpgradeable {
    bytes32 public constant AUTO_IRRIGATE_ADMIN_ROLE = keccak256("AUTO_IRRIGATE_ADMIN_ROLE");
    bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");

    function __IrrigationAccessControl_init() internal onlyInitializing onlySuperAdminRole {
        __AccessControlEnumerable_init_unchained();
        __IrrigationAccessControl_init_unchained();
    }

    function __IrrigationAccessControl_init_unchained() internal onlyInitializing {
        address superAdmin = _msgSender();
        // this sets the default admin for every ROLE created
        _grantRole(DEFAULT_ADMIN_ROLE, superAdmin);
        // set SuperAdmin as ADMIN_ROLE also, no need to setRoleAdmin() as it will use DEFAULT_ADMIN_ROLE
        _grantRole(ADMIN_ROLE, superAdmin);
        // all non-superAdmin can also grant/revoke roles of IRRIGATION_ADMIN_ROLE
        _setRoleAdmin(AUTO_IRRIGATE_ADMIN_ROLE, ADMIN_ROLE);
        // make superAdmin have the IRRIGATION_ADMIN_ROLE too.
        _grantRole(AUTO_IRRIGATE_ADMIN_ROLE, superAdmin);
    }

    function grantRole(
        bytes32 role,
        address account
    ) public override(IAccessControlUpgradeable, AccessControlUpgradeable) {
        // this checks the admin role that can do this.
        super.grantRole(role, account);
    }

    // renounce role is only for yourself, so no modifier should have been added to this
    function renounceRole(
        bytes32 role,
        address account
    ) public override(IAccessControlUpgradeable, AccessControlUpgradeable) {
        require(
            LibDiamond.diamondStorage().contractOwner != account,
            "Cannot renounce superAdmin from any Roles"
        );
        super.renounceRole(role, account);
    }

    function revokeRole(
        bytes32 role,
        address account
    ) public override(IAccessControlUpgradeable, AccessControlUpgradeable) {
        require(
            LibDiamond.diamondStorage().contractOwner != account,
            "Cannot revoke superAdmin from any Roles"
        );
        // this checks that only the admin(s) of the Role can revoke a Role
        super.revokeRole(role, account);
    }

    modifier onlySuperAdminRole() {
        require(LibDiamond.diamondStorage().contractOwner == msg.sender, "Only SuperAdmin allowed");
        _;
    }

    modifier onlyAdminRole() {
        require(hasRole(ADMIN_ROLE, msg.sender), "Account doesn't have admin role");
        _;
    }

    modifier onlyAutoIrrigateAdminRole() {
        require(
            hasRole(AUTO_IRRIGATE_ADMIN_ROLE, msg.sender),
            "Account doesn't have auto irrigate admin role"
        );
        _;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"BlacklistedToken","type":"error"},{"inputs":[],"name":"NoUserMint","type":"error"},{"inputs":[],"name":"NoWhitelist","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","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":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"AUTO_IRRIGATE_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"bytes32","name":"name","type":"bytes32"}],"name":"addProxySpender","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"addTokenIntoBlacklist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"burnBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burnTotalAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"proxySpender","type":"address"}],"name":"getProxyInfo","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"proxySpender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isTradeableToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"mintBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"removeProxySpender","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","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":"string","name":"contractUri","type":"string"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_uri","type":"string"}],"name":"setTokenBaseURI","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":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"bool","name":"bBlacklisted","type":"bool"}],"name":"updateTokenInBlacklist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50613ffe806100206000396000f3fe608060405234801561001057600080fd5b506004361061025b5760003560e01c80639010d07c11610145578063bd85b039116100bd578063e8a3d4851161008c578063f23a6e6111610071578063f23a6e61146106af578063f242432a146106cf578063f5298aca146106e257600080fd5b8063e8a3d4851461064c578063e985e9c51461065457600080fd5b8063bd85b039146105d4578063ca15c87314610613578063d547741f14610626578063d679ecf51461063957600080fd5b80639762b15011610114578063a22cb465116100f9578063a22cb46514610573578063a3d7118014610586578063bc197c811461059957600080fd5b80639762b15014610558578063a217fddf1461056b57600080fd5b80639010d07c146104af57806391d14854146104da578063938e3d7b1461053257806396dd33971461054557600080fd5b80633aebb682116101d85780635effdd20116101a7578063731133e91161018c578063731133e91461046257806375b238fc146104755780638ef79e911461049c57600080fd5b80635effdd20146104285780636b20c4541461044f57600080fd5b80633aebb6821461036c5780633c1c30c5146103b45780634e1273f4146103c75780634f558e79146103e757600080fd5b80631f7fdffa1161022f5780632eb2c2d6116102145780632eb2c2d6146103335780632f2ff15d1461034657806336568abe1461035957600080fd5b80631f7fdffa146102de578063248a9ca3146102f157600080fd5b8062fdd58e1461026057806301ffc9a7146102865780630e89341c146102a957806315213188146102c9575b600080fd5b61027361026e3660046131fb565b6106f5565b6040519081526020015b60405180910390f35b61029961029436600461323b565b6107b0565b604051901515815260200161027d565b6102bc6102b7366004613258565b610814565b60405161027d91906132c1565b6102dc6102d73660046132d4565b610867565b005b6102dc6102ec36600461343b565b61091e565b6102736102ff366004613258565b60009081527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602052604090206001015490565b6102dc6103413660046134d4565b610950565b6102dc61035436600461357e565b610a20565b6102dc61036736600461357e565b610a2e565b61027361037a3660046132d4565b6001600160a01b031660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d602052604090205490565b6102996103c23660046131fb565b610ada565b6103da6103d53660046135aa565b610b6c565b60405161027d91906136b0565b6102996103f5366004613258565b60009081527f76dd8cdb4832d68b5d1c960a26cfc39d747ad996ccfa98abdfa423082e3a74d46020526040902054151590565b6102737f985f43f95034558adeb696c121176bc5c84ee4c38c3b6363ba22cb8d4e7abb5181565b6102dc61045d3660046136c3565b610caa565b6102dc610470366004613737565b610d76565b6102737fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b6102dc6104aa3660046137d5565b610da2565b6104c26104bd366004613817565b610e4c565b6040516001600160a01b03909116815260200161027d565b6102996104e836600461357e565b60009182527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6102dc6105403660046137d5565b610e83565b6102dc610553366004613839565b610f2d565b6102dc6105663660046131fb565b610ff9565b610273600081565b6102dc610581366004613886565b611012565b6102dc6105943660046138b0565b61101d565b6105bb6105a7366004613953565b63bc197c8160e01b98975050505050505050565b6040516001600160e01b0319909116815260200161027d565b6102736105e2366004613258565b60009081527f76dd8cdb4832d68b5d1c960a26cfc39d747ad996ccfa98abdfa423082e3a74d4602052604090205490565b610273610621366004613258565b611102565b6102dc61063436600461357e565b611138565b6102dc6106473660046131fb565b6111e4565b6102bc61129e565b610299610662366004613a0e565b6001600160a01b0391821660009081527f82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e576020908152604080832093909416825291909152205460ff1690565b6105bb6106bd366004613a38565b63f23a6e6160e01b9695505050505050565b6102dc6106dd366004613ab0565b611352565b6102dc6106f0366004613b15565b61141b565b60006001600160a01b0383166107785760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201527f616c6964206f776e65720000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b600080516020613fd28339815191526000838152602091825260408082206001600160a01b0387168352909252205490505b92915050565b60006107bb826114e2565b806107ca57506107ca8261157d565b806107aa5750506001600160e01b03191660009081527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f602052604090205460ff16151560011490565b60607f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35e610840836115bb565b604051602001610851929190613b82565b6040516020818303038152906040529050919050565b3360009081527fb977ac7bfb64a9f32cc48ea82b91232f336bcd9f92134cd335a842f2528a472b602052604090205460ff166108e55760405162461bcd60e51b815260206004820152601f60248201527f4163636f756e7420646f65736e277420686176652061646d696e20726f6c6500604482015260640161076f565b6001600160a01b031660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d6020526040812055565b33301461093e5760405163141949cb60e31b815260040160405180910390fd5b61094a8484848461165b565b50505050565b6001600160a01b0385163314806109a957506001600160a01b03851660009081527f82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e576020908152604080832033845290915290205460ff165b610a0c5760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201526d195c881bdc88185c1c1c9bdd995960921b606482015260840161076f565b610a198585858585611847565b5050505050565b610a2a8282611ad5565b5050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b03828116911603610ad05760405162461bcd60e51b815260206004820152602960248201527f43616e6e6f742072656e6f756e636520737570657241646d696e2066726f6d2060448201527f616e7920526f6c65730000000000000000000000000000000000000000000000606482015260840161076f565b610a2a8282611b19565b6001600160a01b03821660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d602052604081205415801590610b6557506001600160a01b03831660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d6020908152604080832085845260010190915290205460ff165b9392505050565b60608151835114610be55760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e67746860448201527f206d69736d617463680000000000000000000000000000000000000000000000606482015260840161076f565b6000835167ffffffffffffffff811115610c0157610c016132ef565b604051908082528060200260200182016040528015610c2a578160200160208202803683370190505b50905060005b8451811015610ca257610c75858281518110610c4e57610c4e613c09565b6020026020010151858381518110610c6857610c68613c09565b60200260200101516106f5565b828281518110610c8757610c87613c09565b6020908102919091010152610c9b81613c35565b9050610c30565b509392505050565b6001600160a01b038316331480610d0357506001600160a01b03831660009081527f82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e576020908152604080832033845290915290205460ff165b610d665760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201526d195c881bdc88185c1c1c9bdd995960921b606482015260840161076f565b610d71838383611ba1565b505050565b333014610d965760405163141949cb60e31b815260040160405180910390fd5b61094a84848484611e18565b3360009081527fb977ac7bfb64a9f32cc48ea82b91232f336bcd9f92134cd335a842f2528a472b602052604090205460ff16610e205760405162461bcd60e51b815260206004820152601f60248201527f4163636f756e7420646f65736e277420686176652061646d696e20726f6c6500604482015260640161076f565b7f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35e610d71828483613c94565b60008281527fac45f8eb145dd54e906393bc996fcbbaa6f04b5294c6c4a500bf5679d0edd09860205260408120610b659083611f4a565b3360009081527fb977ac7bfb64a9f32cc48ea82b91232f336bcd9f92134cd335a842f2528a472b602052604090205460ff16610f015760405162461bcd60e51b815260206004820152601f60248201527f4163636f756e7420646f65736e277420686176652061646d696e20726f6c6500604482015260640161076f565b7f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35f610d71828483613c94565b3360009081527fb977ac7bfb64a9f32cc48ea82b91232f336bcd9f92134cd335a842f2528a472b602052604090205460ff16610fab5760405162461bcd60e51b815260206004820152601f60248201527f4163636f756e7420646f65736e277420686176652061646d696e20726f6c6500604482015260640161076f565b805160005b81811015610d715760008181527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35c60205260409020805460ff1916600190811790915501610fb0565b600061100583836106f5565b9050610d7183838361141b565b610a2a338383611f56565b3360009081527fb977ac7bfb64a9f32cc48ea82b91232f336bcd9f92134cd335a842f2528a472b602052604090205460ff1661109b5760405162461bcd60e51b815260206004820152601f60248201527f4163636f756e7420646f65736e277420686176652061646d696e20726f6c6500604482015260640161076f565b815160005b81811015610a19576001600160a01b03851660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d602090815260408083208484526001908101909252909120805460ff1916851515179055016110a0565b60008181527fac45f8eb145dd54e906393bc996fcbbaa6f04b5294c6c4a500bf5679d0edd098602052604081206107aa9061206a565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b038281169116036111da5760405162461bcd60e51b815260206004820152602760248201527f43616e6e6f74207265766f6b6520737570657241646d696e2066726f6d20616e60448201527f7920526f6c657300000000000000000000000000000000000000000000000000606482015260840161076f565b610a2a8282612074565b3360009081527fb977ac7bfb64a9f32cc48ea82b91232f336bcd9f92134cd335a842f2528a472b602052604090205460ff166112625760405162461bcd60e51b815260206004820152601f60248201527f4163636f756e7420646f65736e277420686176652061646d696e20726f6c6500604482015260640161076f565b6001600160a01b039190911660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d6020526040902055565b60607f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35c60030180546112cf90613b48565b80601f01602080910402602001604051908101604052809291908181526020018280546112fb90613b48565b80156113485780601f1061131d57610100808354040283529160200191611348565b820191906000526020600020905b81548152906001019060200180831161132b57829003601f168201915b5050505050905090565b6001600160a01b0385163314806113ab57506001600160a01b03851660009081527f82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e576020908152604080832033845290915290205460ff165b61140e5760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201526d195c881bdc88185c1c1c9bdd995960921b606482015260840161076f565b610a1985858585856120b8565b6001600160a01b03831633148061147457506001600160a01b03831660009081527f82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e576020908152604080832033845290915290205460ff165b6114d75760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201526d195c881bdc88185c1c1c9bdd995960921b606482015260840161076f565b610d7183838361228f565b60006001600160e01b031982167fd9b67a2600000000000000000000000000000000000000000000000000000000148061154557506001600160e01b031982167f0e89341c00000000000000000000000000000000000000000000000000000000145b806107aa57507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316146107aa565b60006001600160e01b031982167f5a05180f0000000000000000000000000000000000000000000000000000000014806107aa57506107aa8261243d565b606060006115c88361247b565b600101905060008167ffffffffffffffff8111156115e8576115e86132ef565b6040519080825280601f01601f191660200182016040528015611612576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461161c57509392505050565b6001600160a01b0384166116bb5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b606482015260840161076f565b815183511461171d5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b606482015260840161076f565b3361172d8160008787878761255d565b60005b84518110156117df5783818151811061174b5761174b613c09565b6020026020010151611768600080516020613fd283398151915290565b600001600087848151811061177f5761177f613c09565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b0316815260200190815260200160002060008282546117c79190613d54565b909155508190506117d781613c35565b915050611730565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611830929190613d67565b60405180910390a4610a19816000878787876126cb565b81518351146118a95760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b606482015260840161076f565b6001600160a01b03841661190d5760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161076f565b3361191c81878787878761255d565b60005b8451811015611a6757600085828151811061193c5761193c613c09565b60200260200101519050600085838151811061195a5761195a613c09565b60200260200101519050600061197b600080516020613fd283398151915290565b6000848152602091825260408082206001600160a01b038e1683529092522054905081811015611a005760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b606482015260840161076f565b6000838152600080516020613fd2833981519152602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290611a4c908490613d54565b9250508190555050505080611a6090613c35565b905061191f565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611ab7929190613d67565b60405180910390a4611acd8187878787876126cb565b505050505050565b60008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da626020526040902060010154611b0f81612870565b610d71838361287d565b6001600160a01b0381163314611b975760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c660000000000000000000000000000000000606482015260840161076f565b610a2a82826128be565b6001600160a01b038316611c035760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b606482015260840161076f565b8051825114611c655760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b606482015260840161076f565b6000339050611c888185600086866040518060200160405280600081525061255d565b60005b8351811015611dab576000848281518110611ca857611ca8613c09565b602002602001015190506000848381518110611cc657611cc6613c09565b602002602001015190506000611ce7600080516020613fd283398151915290565b6000848152602091825260408082206001600160a01b038c1683529092522054905081811015611d655760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b606482015260840161076f565b6000928352600080516020613fd2833981519152602090815260408085206001600160a01b038b1686529091529092209103905580611da381613c35565b915050611c8b565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051611dfc929190613d67565b60405180910390a460408051602081019091526000905261094a565b6001600160a01b038416611e785760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b606482015260840161076f565b336000611e84856128ff565b90506000611e91856128ff565b9050611ea28360008985858961255d565b6000868152600080516020613fd2833981519152602090815260408083206001600160a01b038b16845290915281208054879290611ee1908490613d54565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611f418360008989898961294a565b50505050505050565b6000610b658383612a46565b816001600160a01b0316836001600160a01b031603611fdd5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c2073746174757360448201527f20666f722073656c660000000000000000000000000000000000000000000000606482015260840161076f565b6001600160a01b0383811660008181527f82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e576020908152604080832094871680845294825291829020805460ff1916861515908117909155825190815291517f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319281900390910190a3505050565b60006107aa825490565b60008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da6260205260409020600101546120ae81612870565b610d7183836128be565b6001600160a01b03841661211c5760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161076f565b336000612128856128ff565b90506000612135856128ff565b905061214583898985858961255d565b6000868152600080516020613fd2833981519152602090815260408083206001600160a01b038c168452909152902054858110156121d85760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b606482015260840161076f565b6000878152600080516020613fd2833981519152602090815260408083206001600160a01b038d8116855292528083208985039055908a16825281208054889290612224908490613d54565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4612284848a8a8a8a8a61294a565b505050505050505050565b6001600160a01b0383166122f15760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b606482015260840161076f565b3360006122fd846128ff565b9050600061230a846128ff565b905061232a8387600085856040518060200160405280600081525061255d565b6000858152600080516020613fd2833981519152602090815260408083206001600160a01b038a168452909152902054848110156123b65760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b606482015260840161076f565b6000868152600080516020613fd2833981519152602090815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a905282519193908916927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292918290030190a4604080516020810190915260009052611f41565b60006001600160e01b031982167f7965db0b0000000000000000000000000000000000000000000000000000000014806107aa57506107aa826114e2565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106124c4577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef810000000083106124f0576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061250e57662386f26fc10000830492506010015b6305f5e1008310612526576305f5e100830492506008015b612710831061253a57612710830492506004015b6064831061254c576064830492506002015b600a83106107aa5760010192915050565b61256b868686868686612a70565b6001600160a01b038581169087161480159081906125be57506001600160a01b03871660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d6020526040902054155b156125f5576040517fe3bcfeb700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b835160005b818110156122845782801561265457506001600160a01b03891660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d6020908152604080832084845260010190915290205460ff165b8061268c575060008181527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35c602052604090205460ff165b156126c3576040517f1230cf7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001016125fa565b6001600160a01b0384163b15611acd5760405163bc197c8160e01b81526001600160a01b0385169063bc197c819061270f9089908990889088908890600401613d95565b6020604051808303816000875af192505050801561274a575060408051601f3d908101601f1916820190925261274791810190613df3565b60015b6127ff57612756613e10565b806308c379a00361278f575061276a613e2c565b806127755750612791565b8060405162461bcd60e51b815260040161076f91906132c1565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d4552433131353560448201527f526563656976657220696d706c656d656e746572000000000000000000000000606482015260840161076f565b6001600160e01b0319811663bc197c8160e01b14611f415760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b606482015260840161076f565b61287a8133612c68565b50565b6128878282612cfc565b60008281527fac45f8eb145dd54e906393bc996fcbbaa6f04b5294c6c4a500bf5679d0edd09860205260409020610d719082612dbf565b6128c88282612dd4565b60008281527fac45f8eb145dd54e906393bc996fcbbaa6f04b5294c6c4a500bf5679d0edd09860205260409020610d719082612e95565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061293957612939613c09565b602090810291909101015292915050565b6001600160a01b0384163b15611acd5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e619061298e9089908990889088908890600401613eb6565b6020604051808303816000875af19250505080156129c9575060408051601f3d908101601f191682019092526129c691810190613df3565b60015b6129d557612756613e10565b6001600160e01b0319811663f23a6e6160e01b14611f415760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b606482015260840161076f565b6000826000018281548110612a5d57612a5d613c09565b9060005260206000200154905092915050565b6001600160a01b038516612b1f5760005b8351811015612b1d57828181518110612a9c57612a9c613c09565b6020026020010151612acb7f76dd8cdb4832d68b5d1c960a26cfc39d747ad996ccfa98abdfa423082e3a74d490565b6000016000868481518110612ae257612ae2613c09565b602002602001015181526020019081526020016000206000828254612b079190613d54565b90915550612b16905081613c35565b9050612a81565b505b6001600160a01b038416611acd5760005b8351811015611f41576000848281518110612b4d57612b4d613c09565b602002602001015190506000848381518110612b6b57612b6b613c09565b602002602001015190506000612b9e7f76dd8cdb4832d68b5d1c960a26cfc39d747ad996ccfa98abdfa423082e3a74d490565b60008481526020919091526040902054905081811015612c265760405162461bcd60e51b815260206004820152602860248201527f455243313135353a206275726e20616d6f756e74206578636565647320746f7460448201527f616c537570706c79000000000000000000000000000000000000000000000000606482015260840161076f565b60009283527f76dd8cdb4832d68b5d1c960a26cfc39d747ad996ccfa98abdfa423082e3a74d4602052604090922091039055612c6181613c35565b9050612b30565b60008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602090815260408083206001600160a01b038516845290915290205460ff16610a2a57612cba81612eaa565b612cc5836020612ebc565b604051602001612cd6929190613ef9565b60408051601f198184030181529082905262461bcd60e51b825261076f916004016132c1565b60008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602090815260408083206001600160a01b038516845290915290205460ff16610a2a5760008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6000610b65836001600160a01b03841661309d565b60008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602090815260408083206001600160a01b038516845290915290205460ff1615610a2a5760008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610b65836001600160a01b0384166130ec565b60606107aa6001600160a01b03831660145b60606000612ecb836002613f7a565b612ed6906002613d54565b67ffffffffffffffff811115612eee57612eee6132ef565b6040519080825280601f01601f191660200182016040528015612f18576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110612f4f57612f4f613c09565b60200101906001600160f81b031916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110612f9a57612f9a613c09565b60200101906001600160f81b031916908160001a9053506000612fbe846002613f7a565b612fc9906001613d54565b90505b600181111561304e577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061300a5761300a613c09565b1a60f81b82828151811061302057613020613c09565b60200101906001600160f81b031916908160001a90535060049490941c9361304781613f91565b9050612fcc565b508315610b655760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161076f565b60008181526001830160205260408120546130e4575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556107aa565b5060006107aa565b600081815260018301602052604081205480156131d5576000613110600183613fa8565b855490915060009061312490600190613fa8565b905081811461318957600086600001828154811061314457613144613c09565b906000526020600020015490508087600001848154811061316757613167613c09565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061319a5761319a613fbb565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506107aa565b60009150506107aa565b80356001600160a01b03811681146131f657600080fd5b919050565b6000806040838503121561320e57600080fd5b613217836131df565b946020939093013593505050565b6001600160e01b03198116811461287a57600080fd5b60006020828403121561324d57600080fd5b8135610b6581613225565b60006020828403121561326a57600080fd5b5035919050565b60005b8381101561328c578181015183820152602001613274565b50506000910152565b600081518084526132ad816020860160208601613271565b601f01601f19169290920160200192915050565b602081526000610b656020830184613295565b6000602082840312156132e657600080fd5b610b65826131df565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff8111828210171561332b5761332b6132ef565b6040525050565b600067ffffffffffffffff82111561334c5761334c6132ef565b5060051b60200190565b600082601f83011261336757600080fd5b8135602061337482613332565b6040516133818282613305565b83815260059390931b85018201928281019150868411156133a157600080fd5b8286015b848110156133bc57803583529183019183016133a5565b509695505050505050565b600082601f8301126133d857600080fd5b813567ffffffffffffffff8111156133f2576133f26132ef565b604051613409601f8301601f191660200182613305565b81815284602083860101111561341e57600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000806080858703121561345157600080fd5b61345a856131df565b9350602085013567ffffffffffffffff8082111561347757600080fd5b61348388838901613356565b9450604087013591508082111561349957600080fd5b6134a588838901613356565b935060608701359150808211156134bb57600080fd5b506134c8878288016133c7565b91505092959194509250565b600080600080600060a086880312156134ec57600080fd5b6134f5866131df565b9450613503602087016131df565b9350604086013567ffffffffffffffff8082111561352057600080fd5b61352c89838a01613356565b9450606088013591508082111561354257600080fd5b61354e89838a01613356565b9350608088013591508082111561356457600080fd5b50613571888289016133c7565b9150509295509295909350565b6000806040838503121561359157600080fd5b823591506135a1602084016131df565b90509250929050565b600080604083850312156135bd57600080fd5b823567ffffffffffffffff808211156135d557600080fd5b818501915085601f8301126135e957600080fd5b813560206135f682613332565b6040516136038282613305565b83815260059390931b850182019282810191508984111561362357600080fd5b948201945b8386101561364857613639866131df565b82529482019490820190613628565b9650508601359250508082111561365e57600080fd5b5061366b85828601613356565b9150509250929050565b600081518084526020808501945080840160005b838110156136a557815187529582019590820190600101613689565b509495945050505050565b602081526000610b656020830184613675565b6000806000606084860312156136d857600080fd5b6136e1846131df565b9250602084013567ffffffffffffffff808211156136fe57600080fd5b61370a87838801613356565b9350604086013591508082111561372057600080fd5b5061372d86828701613356565b9150509250925092565b6000806000806080858703121561374d57600080fd5b613756856131df565b93506020850135925060408501359150606085013567ffffffffffffffff81111561378057600080fd5b6134c8878288016133c7565b60008083601f84011261379e57600080fd5b50813567ffffffffffffffff8111156137b657600080fd5b6020830191508360208285010111156137ce57600080fd5b9250929050565b600080602083850312156137e857600080fd5b823567ffffffffffffffff8111156137ff57600080fd5b61380b8582860161378c565b90969095509350505050565b6000806040838503121561382a57600080fd5b50508035926020909101359150565b60006020828403121561384b57600080fd5b813567ffffffffffffffff81111561386257600080fd5b61386e84828501613356565b949350505050565b803580151581146131f657600080fd5b6000806040838503121561389957600080fd5b6138a2836131df565b91506135a160208401613876565b6000806000606084860312156138c557600080fd5b6138ce846131df565b9250602084013567ffffffffffffffff8111156138ea57600080fd5b6138f686828701613356565b92505061390560408501613876565b90509250925092565b60008083601f84011261392057600080fd5b50813567ffffffffffffffff81111561393857600080fd5b6020830191508360208260051b85010111156137ce57600080fd5b60008060008060008060008060a0898b03121561396f57600080fd5b613978896131df565b975061398660208a016131df565b9650604089013567ffffffffffffffff808211156139a357600080fd5b6139af8c838d0161390e565b909850965060608b01359150808211156139c857600080fd5b6139d48c838d0161390e565b909650945060808b01359150808211156139ed57600080fd5b506139fa8b828c0161378c565b999c989b5096995094979396929594505050565b60008060408385031215613a2157600080fd5b613a2a836131df565b91506135a1602084016131df565b60008060008060008060a08789031215613a5157600080fd5b613a5a876131df565b9550613a68602088016131df565b94506040870135935060608701359250608087013567ffffffffffffffff811115613a9257600080fd5b613a9e89828a0161378c565b979a9699509497509295939492505050565b600080600080600060a08688031215613ac857600080fd5b613ad1866131df565b9450613adf602087016131df565b93506040860135925060608601359150608086013567ffffffffffffffff811115613b0957600080fd5b613571888289016133c7565b600080600060608486031215613b2a57600080fd5b613b33846131df565b95602085013595506040909401359392505050565b600181811c90821680613b5c57607f821691505b602082108103613b7c57634e487b7160e01b600052602260045260246000fd5b50919050565b6000808454613b9081613b48565b60018281168015613ba85760018114613bbd57613bec565b60ff1984168752821515830287019450613bec565b8860005260208060002060005b85811015613be35781548a820152908401908201613bca565b50505082870194505b505050508351613c00818360208801613271565b01949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613c4757613c47613c1f565b5060010190565b601f821115610d7157600081815260208120601f850160051c81016020861015613c755750805b601f850160051c820191505b81811015611acd57828155600101613c81565b67ffffffffffffffff831115613cac57613cac6132ef565b613cc083613cba8354613b48565b83613c4e565b6000601f841160018114613cf45760008515613cdc5750838201355b600019600387901b1c1916600186901b178355610a19565b600083815260209020601f19861690835b82811015613d255786850135825560209485019460019092019101613d05565b5086821015613d425760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b808201808211156107aa576107aa613c1f565b604081526000613d7a6040830185613675565b8281036020840152613d8c8185613675565b95945050505050565b60006001600160a01b03808816835280871660208401525060a06040830152613dc160a0830186613675565b8281036060840152613dd38186613675565b90508281036080840152613de78185613295565b98975050505050505050565b600060208284031215613e0557600080fd5b8151610b6581613225565b600060033d1115613e295760046000803e5060005160e01c5b90565b600060443d1015613e3a5790565b6040516003193d81016004833e81513d67ffffffffffffffff8160248401118184111715613e6a57505050505090565b8285019150815181811115613e825750505050505090565b843d8701016020828501011115613e9c5750505050505090565b613eab60208286010187613305565b509095945050505050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a06080830152613eee60a0830184613295565b979650505050505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613f31816017850160208801613271565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613f6e816028840160208801613271565b01602801949350505050565b80820281158282048414176107aa576107aa613c1f565b600081613fa057613fa0613c1f565b506000190190565b818103818111156107aa576107aa613c1f565b634e487b7160e01b600052603160045260246000fdfe82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e56a164736f6c6343000811000a

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061025b5760003560e01c80639010d07c11610145578063bd85b039116100bd578063e8a3d4851161008c578063f23a6e6111610071578063f23a6e61146106af578063f242432a146106cf578063f5298aca146106e257600080fd5b8063e8a3d4851461064c578063e985e9c51461065457600080fd5b8063bd85b039146105d4578063ca15c87314610613578063d547741f14610626578063d679ecf51461063957600080fd5b80639762b15011610114578063a22cb465116100f9578063a22cb46514610573578063a3d7118014610586578063bc197c811461059957600080fd5b80639762b15014610558578063a217fddf1461056b57600080fd5b80639010d07c146104af57806391d14854146104da578063938e3d7b1461053257806396dd33971461054557600080fd5b80633aebb682116101d85780635effdd20116101a7578063731133e91161018c578063731133e91461046257806375b238fc146104755780638ef79e911461049c57600080fd5b80635effdd20146104285780636b20c4541461044f57600080fd5b80633aebb6821461036c5780633c1c30c5146103b45780634e1273f4146103c75780634f558e79146103e757600080fd5b80631f7fdffa1161022f5780632eb2c2d6116102145780632eb2c2d6146103335780632f2ff15d1461034657806336568abe1461035957600080fd5b80631f7fdffa146102de578063248a9ca3146102f157600080fd5b8062fdd58e1461026057806301ffc9a7146102865780630e89341c146102a957806315213188146102c9575b600080fd5b61027361026e3660046131fb565b6106f5565b6040519081526020015b60405180910390f35b61029961029436600461323b565b6107b0565b604051901515815260200161027d565b6102bc6102b7366004613258565b610814565b60405161027d91906132c1565b6102dc6102d73660046132d4565b610867565b005b6102dc6102ec36600461343b565b61091e565b6102736102ff366004613258565b60009081527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602052604090206001015490565b6102dc6103413660046134d4565b610950565b6102dc61035436600461357e565b610a20565b6102dc61036736600461357e565b610a2e565b61027361037a3660046132d4565b6001600160a01b031660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d602052604090205490565b6102996103c23660046131fb565b610ada565b6103da6103d53660046135aa565b610b6c565b60405161027d91906136b0565b6102996103f5366004613258565b60009081527f76dd8cdb4832d68b5d1c960a26cfc39d747ad996ccfa98abdfa423082e3a74d46020526040902054151590565b6102737f985f43f95034558adeb696c121176bc5c84ee4c38c3b6363ba22cb8d4e7abb5181565b6102dc61045d3660046136c3565b610caa565b6102dc610470366004613737565b610d76565b6102737fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b6102dc6104aa3660046137d5565b610da2565b6104c26104bd366004613817565b610e4c565b6040516001600160a01b03909116815260200161027d565b6102996104e836600461357e565b60009182527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6102dc6105403660046137d5565b610e83565b6102dc610553366004613839565b610f2d565b6102dc6105663660046131fb565b610ff9565b610273600081565b6102dc610581366004613886565b611012565b6102dc6105943660046138b0565b61101d565b6105bb6105a7366004613953565b63bc197c8160e01b98975050505050505050565b6040516001600160e01b0319909116815260200161027d565b6102736105e2366004613258565b60009081527f76dd8cdb4832d68b5d1c960a26cfc39d747ad996ccfa98abdfa423082e3a74d4602052604090205490565b610273610621366004613258565b611102565b6102dc61063436600461357e565b611138565b6102dc6106473660046131fb565b6111e4565b6102bc61129e565b610299610662366004613a0e565b6001600160a01b0391821660009081527f82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e576020908152604080832093909416825291909152205460ff1690565b6105bb6106bd366004613a38565b63f23a6e6160e01b9695505050505050565b6102dc6106dd366004613ab0565b611352565b6102dc6106f0366004613b15565b61141b565b60006001600160a01b0383166107785760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201527f616c6964206f776e65720000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b600080516020613fd28339815191526000838152602091825260408082206001600160a01b0387168352909252205490505b92915050565b60006107bb826114e2565b806107ca57506107ca8261157d565b806107aa5750506001600160e01b03191660009081527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f602052604090205460ff16151560011490565b60607f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35e610840836115bb565b604051602001610851929190613b82565b6040516020818303038152906040529050919050565b3360009081527fb977ac7bfb64a9f32cc48ea82b91232f336bcd9f92134cd335a842f2528a472b602052604090205460ff166108e55760405162461bcd60e51b815260206004820152601f60248201527f4163636f756e7420646f65736e277420686176652061646d696e20726f6c6500604482015260640161076f565b6001600160a01b031660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d6020526040812055565b33301461093e5760405163141949cb60e31b815260040160405180910390fd5b61094a8484848461165b565b50505050565b6001600160a01b0385163314806109a957506001600160a01b03851660009081527f82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e576020908152604080832033845290915290205460ff165b610a0c5760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201526d195c881bdc88185c1c1c9bdd995960921b606482015260840161076f565b610a198585858585611847565b5050505050565b610a2a8282611ad5565b5050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b03828116911603610ad05760405162461bcd60e51b815260206004820152602960248201527f43616e6e6f742072656e6f756e636520737570657241646d696e2066726f6d2060448201527f616e7920526f6c65730000000000000000000000000000000000000000000000606482015260840161076f565b610a2a8282611b19565b6001600160a01b03821660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d602052604081205415801590610b6557506001600160a01b03831660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d6020908152604080832085845260010190915290205460ff165b9392505050565b60608151835114610be55760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e67746860448201527f206d69736d617463680000000000000000000000000000000000000000000000606482015260840161076f565b6000835167ffffffffffffffff811115610c0157610c016132ef565b604051908082528060200260200182016040528015610c2a578160200160208202803683370190505b50905060005b8451811015610ca257610c75858281518110610c4e57610c4e613c09565b6020026020010151858381518110610c6857610c68613c09565b60200260200101516106f5565b828281518110610c8757610c87613c09565b6020908102919091010152610c9b81613c35565b9050610c30565b509392505050565b6001600160a01b038316331480610d0357506001600160a01b03831660009081527f82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e576020908152604080832033845290915290205460ff165b610d665760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201526d195c881bdc88185c1c1c9bdd995960921b606482015260840161076f565b610d71838383611ba1565b505050565b333014610d965760405163141949cb60e31b815260040160405180910390fd5b61094a84848484611e18565b3360009081527fb977ac7bfb64a9f32cc48ea82b91232f336bcd9f92134cd335a842f2528a472b602052604090205460ff16610e205760405162461bcd60e51b815260206004820152601f60248201527f4163636f756e7420646f65736e277420686176652061646d696e20726f6c6500604482015260640161076f565b7f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35e610d71828483613c94565b60008281527fac45f8eb145dd54e906393bc996fcbbaa6f04b5294c6c4a500bf5679d0edd09860205260408120610b659083611f4a565b3360009081527fb977ac7bfb64a9f32cc48ea82b91232f336bcd9f92134cd335a842f2528a472b602052604090205460ff16610f015760405162461bcd60e51b815260206004820152601f60248201527f4163636f756e7420646f65736e277420686176652061646d696e20726f6c6500604482015260640161076f565b7f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35f610d71828483613c94565b3360009081527fb977ac7bfb64a9f32cc48ea82b91232f336bcd9f92134cd335a842f2528a472b602052604090205460ff16610fab5760405162461bcd60e51b815260206004820152601f60248201527f4163636f756e7420646f65736e277420686176652061646d696e20726f6c6500604482015260640161076f565b805160005b81811015610d715760008181527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35c60205260409020805460ff1916600190811790915501610fb0565b600061100583836106f5565b9050610d7183838361141b565b610a2a338383611f56565b3360009081527fb977ac7bfb64a9f32cc48ea82b91232f336bcd9f92134cd335a842f2528a472b602052604090205460ff1661109b5760405162461bcd60e51b815260206004820152601f60248201527f4163636f756e7420646f65736e277420686176652061646d696e20726f6c6500604482015260640161076f565b815160005b81811015610a19576001600160a01b03851660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d602090815260408083208484526001908101909252909120805460ff1916851515179055016110a0565b60008181527fac45f8eb145dd54e906393bc996fcbbaa6f04b5294c6c4a500bf5679d0edd098602052604081206107aa9061206a565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b038281169116036111da5760405162461bcd60e51b815260206004820152602760248201527f43616e6e6f74207265766f6b6520737570657241646d696e2066726f6d20616e60448201527f7920526f6c657300000000000000000000000000000000000000000000000000606482015260840161076f565b610a2a8282612074565b3360009081527fb977ac7bfb64a9f32cc48ea82b91232f336bcd9f92134cd335a842f2528a472b602052604090205460ff166112625760405162461bcd60e51b815260206004820152601f60248201527f4163636f756e7420646f65736e277420686176652061646d696e20726f6c6500604482015260640161076f565b6001600160a01b039190911660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d6020526040902055565b60607f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35c60030180546112cf90613b48565b80601f01602080910402602001604051908101604052809291908181526020018280546112fb90613b48565b80156113485780601f1061131d57610100808354040283529160200191611348565b820191906000526020600020905b81548152906001019060200180831161132b57829003601f168201915b5050505050905090565b6001600160a01b0385163314806113ab57506001600160a01b03851660009081527f82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e576020908152604080832033845290915290205460ff165b61140e5760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201526d195c881bdc88185c1c1c9bdd995960921b606482015260840161076f565b610a1985858585856120b8565b6001600160a01b03831633148061147457506001600160a01b03831660009081527f82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e576020908152604080832033845290915290205460ff165b6114d75760405162461bcd60e51b815260206004820152602e60248201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60448201526d195c881bdc88185c1c1c9bdd995960921b606482015260840161076f565b610d7183838361228f565b60006001600160e01b031982167fd9b67a2600000000000000000000000000000000000000000000000000000000148061154557506001600160e01b031982167f0e89341c00000000000000000000000000000000000000000000000000000000145b806107aa57507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316146107aa565b60006001600160e01b031982167f5a05180f0000000000000000000000000000000000000000000000000000000014806107aa57506107aa8261243d565b606060006115c88361247b565b600101905060008167ffffffffffffffff8111156115e8576115e86132ef565b6040519080825280601f01601f191660200182016040528015611612576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461161c57509392505050565b6001600160a01b0384166116bb5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b606482015260840161076f565b815183511461171d5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b606482015260840161076f565b3361172d8160008787878761255d565b60005b84518110156117df5783818151811061174b5761174b613c09565b6020026020010151611768600080516020613fd283398151915290565b600001600087848151811061177f5761177f613c09565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b0316815260200190815260200160002060008282546117c79190613d54565b909155508190506117d781613c35565b915050611730565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611830929190613d67565b60405180910390a4610a19816000878787876126cb565b81518351146118a95760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b606482015260840161076f565b6001600160a01b03841661190d5760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161076f565b3361191c81878787878761255d565b60005b8451811015611a6757600085828151811061193c5761193c613c09565b60200260200101519050600085838151811061195a5761195a613c09565b60200260200101519050600061197b600080516020613fd283398151915290565b6000848152602091825260408082206001600160a01b038e1683529092522054905081811015611a005760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b606482015260840161076f565b6000838152600080516020613fd2833981519152602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290611a4c908490613d54565b9250508190555050505080611a6090613c35565b905061191f565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051611ab7929190613d67565b60405180910390a4611acd8187878787876126cb565b505050505050565b60008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da626020526040902060010154611b0f81612870565b610d71838361287d565b6001600160a01b0381163314611b975760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c660000000000000000000000000000000000606482015260840161076f565b610a2a82826128be565b6001600160a01b038316611c035760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b606482015260840161076f565b8051825114611c655760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b606482015260840161076f565b6000339050611c888185600086866040518060200160405280600081525061255d565b60005b8351811015611dab576000848281518110611ca857611ca8613c09565b602002602001015190506000848381518110611cc657611cc6613c09565b602002602001015190506000611ce7600080516020613fd283398151915290565b6000848152602091825260408082206001600160a01b038c1683529092522054905081811015611d655760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b606482015260840161076f565b6000928352600080516020613fd2833981519152602090815260408085206001600160a01b038b1686529091529092209103905580611da381613c35565b915050611c8b565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051611dfc929190613d67565b60405180910390a460408051602081019091526000905261094a565b6001600160a01b038416611e785760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b606482015260840161076f565b336000611e84856128ff565b90506000611e91856128ff565b9050611ea28360008985858961255d565b6000868152600080516020613fd2833981519152602090815260408083206001600160a01b038b16845290915281208054879290611ee1908490613d54565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611f418360008989898961294a565b50505050505050565b6000610b658383612a46565b816001600160a01b0316836001600160a01b031603611fdd5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c2073746174757360448201527f20666f722073656c660000000000000000000000000000000000000000000000606482015260840161076f565b6001600160a01b0383811660008181527f82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e576020908152604080832094871680845294825291829020805460ff1916861515908117909155825190815291517f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319281900390910190a3505050565b60006107aa825490565b60008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da6260205260409020600101546120ae81612870565b610d7183836128be565b6001600160a01b03841661211c5760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161076f565b336000612128856128ff565b90506000612135856128ff565b905061214583898985858961255d565b6000868152600080516020613fd2833981519152602090815260408083206001600160a01b038c168452909152902054858110156121d85760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201526939103a3930b739b332b960b11b606482015260840161076f565b6000878152600080516020613fd2833981519152602090815260408083206001600160a01b038d8116855292528083208985039055908a16825281208054889290612224908490613d54565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4612284848a8a8a8a8a61294a565b505050505050505050565b6001600160a01b0383166122f15760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b606482015260840161076f565b3360006122fd846128ff565b9050600061230a846128ff565b905061232a8387600085856040518060200160405280600081525061255d565b6000858152600080516020613fd2833981519152602090815260408083206001600160a01b038a168452909152902054848110156123b65760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b606482015260840161076f565b6000868152600080516020613fd2833981519152602090815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a905282519193908916927fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6292918290030190a4604080516020810190915260009052611f41565b60006001600160e01b031982167f7965db0b0000000000000000000000000000000000000000000000000000000014806107aa57506107aa826114e2565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106124c4577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef810000000083106124f0576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061250e57662386f26fc10000830492506010015b6305f5e1008310612526576305f5e100830492506008015b612710831061253a57612710830492506004015b6064831061254c576064830492506002015b600a83106107aa5760010192915050565b61256b868686868686612a70565b6001600160a01b038581169087161480159081906125be57506001600160a01b03871660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d6020526040902054155b156125f5576040517fe3bcfeb700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b835160005b818110156122845782801561265457506001600160a01b03891660009081527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35d6020908152604080832084845260010190915290205460ff165b8061268c575060008181527f5838f82ec6b44a178024a276092618ea201557826a4f49ef84e816d378fdc35c602052604090205460ff165b156126c3576040517f1230cf7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001016125fa565b6001600160a01b0384163b15611acd5760405163bc197c8160e01b81526001600160a01b0385169063bc197c819061270f9089908990889088908890600401613d95565b6020604051808303816000875af192505050801561274a575060408051601f3d908101601f1916820190925261274791810190613df3565b60015b6127ff57612756613e10565b806308c379a00361278f575061276a613e2c565b806127755750612791565b8060405162461bcd60e51b815260040161076f91906132c1565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d4552433131353560448201527f526563656976657220696d706c656d656e746572000000000000000000000000606482015260840161076f565b6001600160e01b0319811663bc197c8160e01b14611f415760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b606482015260840161076f565b61287a8133612c68565b50565b6128878282612cfc565b60008281527fac45f8eb145dd54e906393bc996fcbbaa6f04b5294c6c4a500bf5679d0edd09860205260409020610d719082612dbf565b6128c88282612dd4565b60008281527fac45f8eb145dd54e906393bc996fcbbaa6f04b5294c6c4a500bf5679d0edd09860205260409020610d719082612e95565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061293957612939613c09565b602090810291909101015292915050565b6001600160a01b0384163b15611acd5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e619061298e9089908990889088908890600401613eb6565b6020604051808303816000875af19250505080156129c9575060408051601f3d908101601f191682019092526129c691810190613df3565b60015b6129d557612756613e10565b6001600160e01b0319811663f23a6e6160e01b14611f415760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b606482015260840161076f565b6000826000018281548110612a5d57612a5d613c09565b9060005260206000200154905092915050565b6001600160a01b038516612b1f5760005b8351811015612b1d57828181518110612a9c57612a9c613c09565b6020026020010151612acb7f76dd8cdb4832d68b5d1c960a26cfc39d747ad996ccfa98abdfa423082e3a74d490565b6000016000868481518110612ae257612ae2613c09565b602002602001015181526020019081526020016000206000828254612b079190613d54565b90915550612b16905081613c35565b9050612a81565b505b6001600160a01b038416611acd5760005b8351811015611f41576000848281518110612b4d57612b4d613c09565b602002602001015190506000848381518110612b6b57612b6b613c09565b602002602001015190506000612b9e7f76dd8cdb4832d68b5d1c960a26cfc39d747ad996ccfa98abdfa423082e3a74d490565b60008481526020919091526040902054905081811015612c265760405162461bcd60e51b815260206004820152602860248201527f455243313135353a206275726e20616d6f756e74206578636565647320746f7460448201527f616c537570706c79000000000000000000000000000000000000000000000000606482015260840161076f565b60009283527f76dd8cdb4832d68b5d1c960a26cfc39d747ad996ccfa98abdfa423082e3a74d4602052604090922091039055612c6181613c35565b9050612b30565b60008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602090815260408083206001600160a01b038516845290915290205460ff16610a2a57612cba81612eaa565b612cc5836020612ebc565b604051602001612cd6929190613ef9565b60408051601f198184030181529082905262461bcd60e51b825261076f916004016132c1565b60008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602090815260408083206001600160a01b038516845290915290205460ff16610a2a5760008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6000610b65836001600160a01b03841661309d565b60008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602090815260408083206001600160a01b038516845290915290205460ff1615610a2a5760008281527f2e59e4c2e927cdddbb64e181e0668d9a0fa70dd88f94d999cd87d5496a20da62602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610b65836001600160a01b0384166130ec565b60606107aa6001600160a01b03831660145b60606000612ecb836002613f7a565b612ed6906002613d54565b67ffffffffffffffff811115612eee57612eee6132ef565b6040519080825280601f01601f191660200182016040528015612f18576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110612f4f57612f4f613c09565b60200101906001600160f81b031916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110612f9a57612f9a613c09565b60200101906001600160f81b031916908160001a9053506000612fbe846002613f7a565b612fc9906001613d54565b90505b600181111561304e577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061300a5761300a613c09565b1a60f81b82828151811061302057613020613c09565b60200101906001600160f81b031916908160001a90535060049490941c9361304781613f91565b9050612fcc565b508315610b655760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161076f565b60008181526001830160205260408120546130e4575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556107aa565b5060006107aa565b600081815260018301602052604081205480156131d5576000613110600183613fa8565b855490915060009061312490600190613fa8565b905081811461318957600086600001828154811061314457613144613c09565b906000526020600020015490508087600001848154811061316757613167613c09565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061319a5761319a613fbb565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506107aa565b60009150506107aa565b80356001600160a01b03811681146131f657600080fd5b919050565b6000806040838503121561320e57600080fd5b613217836131df565b946020939093013593505050565b6001600160e01b03198116811461287a57600080fd5b60006020828403121561324d57600080fd5b8135610b6581613225565b60006020828403121561326a57600080fd5b5035919050565b60005b8381101561328c578181015183820152602001613274565b50506000910152565b600081518084526132ad816020860160208601613271565b601f01601f19169290920160200192915050565b602081526000610b656020830184613295565b6000602082840312156132e657600080fd5b610b65826131df565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff8111828210171561332b5761332b6132ef565b6040525050565b600067ffffffffffffffff82111561334c5761334c6132ef565b5060051b60200190565b600082601f83011261336757600080fd5b8135602061337482613332565b6040516133818282613305565b83815260059390931b85018201928281019150868411156133a157600080fd5b8286015b848110156133bc57803583529183019183016133a5565b509695505050505050565b600082601f8301126133d857600080fd5b813567ffffffffffffffff8111156133f2576133f26132ef565b604051613409601f8301601f191660200182613305565b81815284602083860101111561341e57600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000806080858703121561345157600080fd5b61345a856131df565b9350602085013567ffffffffffffffff8082111561347757600080fd5b61348388838901613356565b9450604087013591508082111561349957600080fd5b6134a588838901613356565b935060608701359150808211156134bb57600080fd5b506134c8878288016133c7565b91505092959194509250565b600080600080600060a086880312156134ec57600080fd5b6134f5866131df565b9450613503602087016131df565b9350604086013567ffffffffffffffff8082111561352057600080fd5b61352c89838a01613356565b9450606088013591508082111561354257600080fd5b61354e89838a01613356565b9350608088013591508082111561356457600080fd5b50613571888289016133c7565b9150509295509295909350565b6000806040838503121561359157600080fd5b823591506135a1602084016131df565b90509250929050565b600080604083850312156135bd57600080fd5b823567ffffffffffffffff808211156135d557600080fd5b818501915085601f8301126135e957600080fd5b813560206135f682613332565b6040516136038282613305565b83815260059390931b850182019282810191508984111561362357600080fd5b948201945b8386101561364857613639866131df565b82529482019490820190613628565b9650508601359250508082111561365e57600080fd5b5061366b85828601613356565b9150509250929050565b600081518084526020808501945080840160005b838110156136a557815187529582019590820190600101613689565b509495945050505050565b602081526000610b656020830184613675565b6000806000606084860312156136d857600080fd5b6136e1846131df565b9250602084013567ffffffffffffffff808211156136fe57600080fd5b61370a87838801613356565b9350604086013591508082111561372057600080fd5b5061372d86828701613356565b9150509250925092565b6000806000806080858703121561374d57600080fd5b613756856131df565b93506020850135925060408501359150606085013567ffffffffffffffff81111561378057600080fd5b6134c8878288016133c7565b60008083601f84011261379e57600080fd5b50813567ffffffffffffffff8111156137b657600080fd5b6020830191508360208285010111156137ce57600080fd5b9250929050565b600080602083850312156137e857600080fd5b823567ffffffffffffffff8111156137ff57600080fd5b61380b8582860161378c565b90969095509350505050565b6000806040838503121561382a57600080fd5b50508035926020909101359150565b60006020828403121561384b57600080fd5b813567ffffffffffffffff81111561386257600080fd5b61386e84828501613356565b949350505050565b803580151581146131f657600080fd5b6000806040838503121561389957600080fd5b6138a2836131df565b91506135a160208401613876565b6000806000606084860312156138c557600080fd5b6138ce846131df565b9250602084013567ffffffffffffffff8111156138ea57600080fd5b6138f686828701613356565b92505061390560408501613876565b90509250925092565b60008083601f84011261392057600080fd5b50813567ffffffffffffffff81111561393857600080fd5b6020830191508360208260051b85010111156137ce57600080fd5b60008060008060008060008060a0898b03121561396f57600080fd5b613978896131df565b975061398660208a016131df565b9650604089013567ffffffffffffffff808211156139a357600080fd5b6139af8c838d0161390e565b909850965060608b01359150808211156139c857600080fd5b6139d48c838d0161390e565b909650945060808b01359150808211156139ed57600080fd5b506139fa8b828c0161378c565b999c989b5096995094979396929594505050565b60008060408385031215613a2157600080fd5b613a2a836131df565b91506135a1602084016131df565b60008060008060008060a08789031215613a5157600080fd5b613a5a876131df565b9550613a68602088016131df565b94506040870135935060608701359250608087013567ffffffffffffffff811115613a9257600080fd5b613a9e89828a0161378c565b979a9699509497509295939492505050565b600080600080600060a08688031215613ac857600080fd5b613ad1866131df565b9450613adf602087016131df565b93506040860135925060608601359150608086013567ffffffffffffffff811115613b0957600080fd5b613571888289016133c7565b600080600060608486031215613b2a57600080fd5b613b33846131df565b95602085013595506040909401359392505050565b600181811c90821680613b5c57607f821691505b602082108103613b7c57634e487b7160e01b600052602260045260246000fd5b50919050565b6000808454613b9081613b48565b60018281168015613ba85760018114613bbd57613bec565b60ff1984168752821515830287019450613bec565b8860005260208060002060005b85811015613be35781548a820152908401908201613bca565b50505082870194505b505050508351613c00818360208801613271565b01949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613c4757613c47613c1f565b5060010190565b601f821115610d7157600081815260208120601f850160051c81016020861015613c755750805b601f850160051c820191505b81811015611acd57828155600101613c81565b67ffffffffffffffff831115613cac57613cac6132ef565b613cc083613cba8354613b48565b83613c4e565b6000601f841160018114613cf45760008515613cdc5750838201355b600019600387901b1c1916600186901b178355610a19565b600083815260209020601f19861690835b82811015613d255786850135825560209485019460019092019101613d05565b5086821015613d425760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b808201808211156107aa576107aa613c1f565b604081526000613d7a6040830185613675565b8281036020840152613d8c8185613675565b95945050505050565b60006001600160a01b03808816835280871660208401525060a06040830152613dc160a0830186613675565b8281036060840152613dd38186613675565b90508281036080840152613de78185613295565b98975050505050505050565b600060208284031215613e0557600080fd5b8151610b6581613225565b600060033d1115613e295760046000803e5060005160e01c5b90565b600060443d1015613e3a5790565b6040516003193d81016004833e81513d67ffffffffffffffff8160248401118184111715613e6a57505050505090565b8285019150815181811115613e825750505050505090565b843d8701016020828501011115613e9c5750505050505090565b613eab60208286010187613305565b509095945050505050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a06080830152613eee60a0830184613295565b979650505050505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613f31816017850160208801613271565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613f6e816028840160208801613271565b01602801949350505050565b80820281158282048414176107aa576107aa613c1f565b600081613fa057613fa0613c1f565b506000190190565b818103818111156107aa576107aa613c1f565b634e487b7160e01b600052603160045260246000fdfe82ba9ca949c870287cb5c3fcd447862dd035b20f08094ed205a06fea6bba9e56a164736f6c6343000811000a

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.