Contract 0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d 1

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x12eed30077a542f28002e35011559deefe947f8b81ec75d681d1acaef971a707Pause1848228692024-02-27 0:01:0756 days 1 hr agoRealm: Deployer IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.00004965 0.1
0xb07d6646aed6bdf374babac963d6a07d77c68e9c086b7c996a525922e019e037Craft1848158222024-02-26 23:29:2056 days 1 hr ago0xe7357cf2e07f55fb2f5ca79716f65e890221d8ad IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.000718260.1
0x1c98e5517737148be2cec1e48150b5141f0f61002fc31e8efeeef0503db7ed6eCraft1848112112024-02-26 23:08:5156 days 2 hrs ago0x70a9c497536e98f2dbb7c66911700fe2b2550900 IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.00137633 0.1
0x0bef01c20a14c9e7be6db51da8a9cbab00d69b28c869842ee37bd1c1ab651269Craft1848088722024-02-26 22:58:1256 days 2 hrs ago0x64345edd54d89a61780606be201ac0535f069fdc IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.000724780.1
0x3bf71a4d369a6309b0c5e6723d41080d90fa5fe94eea760b1deec26057be0ed9Craft1848082012024-02-26 22:55:1056 days 2 hrs ago0xebac1fb92a07e78b8861dbc2b3b0c55c493b8e6b IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.000918690.1
0x4bba2688059e64a8a1314643bf1a97a1e571b65739a83ab3cae86e270dc709c8Craft1848073592024-02-26 22:51:3256 days 2 hrs ago0x6a55064197d5104dcad517a3980a5bc997bc4886 IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.000866740.1
0x09ca95b38fc5c83244733ed90aca44ee1795d3ed588b307777bcb1bd59cae8daCraft1848065482024-02-26 22:47:5756 days 2 hrs ago0x5d0fed7f6a211e503e5b6adcdd0e8f4ce49dc374 IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.001294170.1
0x1411e49ea767917e2caa0f080102fceff7ebd67cdcb1b103cf01303976214ac3Craft1848055332024-02-26 22:43:2656 days 2 hrs ago0xcdfe3d78680fe4b4810db0db2e8d6a2da9b59abf IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.001277290.1
0xb4887d11c00fb32edc0c18d4b42ff9f92ace3c834e69af2a8c8454df9942f20dCraft1848042102024-02-26 22:37:4156 days 2 hrs ago0xa7d742590bd8320de664e00861b71eea2e52707f IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.001292910.1
0x96fb7e6f011c30031a4c048d1684db7af642d71ca1950c1c890b6d11e15b4480Craft1848035262024-02-26 22:34:4356 days 2 hrs ago0xf4a8b052afbd2584d0a12c1711887ef8b2f4b44a IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.00037247 0.1
0xe6b839a6c89a9416012000751075d11fa4bc73773781626bece98cb606912a6aCraft1848032532024-02-26 22:33:2956 days 2 hrs ago0x85fafd0daab176ab5023b5d0ba0288da886d0450 IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.001302680.1
0xf346caf9e82e2fb1d1bb948810e543f29b03a1cb081fa6529a8640f6adbdc83dCraft1848020622024-02-26 22:28:2156 days 2 hrs ago0x1abad6afd7c00530e022ec0d1bdd252660bfc0fd IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.000954670.1
0xff9fc7847c61033ce9b48e0a181a6f51c35d22cf5f6cc094f512d133b13ac3ffCraft1847998132024-02-26 22:18:3756 days 2 hrs ago0x8b66372d5ccf4f961e5757443ae88861350d0c40 IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.001504450.1
0xbca856151d85183dfd1b8fe871ea96eec8f19c513885263f44fd27e087743693Craft1847979322024-02-26 22:10:1756 days 3 hrs ago0xed17f2e71eae4336ca9f435a36137d924c8ff3ad IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.001436480.1
0xc6e223ef3896e559dad2eeb99bbd0385605fbe155e6a9dc87b5b07444329ef36Craft1847971562024-02-26 22:06:5556 days 3 hrs ago0xec97aeae755d0f3c2c52368d19be3bbae947ba3b IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.001025040.1
0xf9c720fbfdd7e65c36aa0b4cbc391126d8b6d5b34380e70d8214d8ad0e845987Craft1847969892024-02-26 22:06:1056 days 3 hrs ago0x2c5650f9ebe5e584a525e425125fd02a64c88285 IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.001533730.1
0x4e59c86461c35c6bd0c7c93edb1041a26ddf9abe17664e8d79d14dc0a5178eddCraft1847969192024-02-26 22:05:5256 days 3 hrs ago0xb2b7e7aa3ad5450165c44882da521a0de7927e72 IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.001102810.1
0xee5a4674557280baf68440e05209e82cce0fec251c13788e75d83ebacba5c7dcCraft1847962672024-02-26 22:03:0256 days 3 hrs ago0x3ef5fa43284ce2109fac46c62aada9904ad18a3f IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.000746040.1
0x45fe676fd1d376bf1456b987df4a8a63fcc2063da8847f3154f0b009def9cb83Craft1847961032024-02-26 22:02:1756 days 3 hrs ago0x2233b04da84900a7fa1508a1cac39df124721bbe IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.00034729 0.1
0xdf88f8e719145da1064b40fb5053c2e2e61e5c192445665acc1c7b75318992c6Craft1847950542024-02-26 21:57:4756 days 3 hrs ago0x14a3d78794b60aa6adc0409c63b98407a0a61250 IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.001213720.1
0xe978eac145bded828ac9b3d45cb6fcb2ac108c8ca39446734c0c411507c2bd96Craft1847925782024-02-26 21:46:5856 days 3 hrs ago0x2e0bd89b0ea081115eb2c330f4c6eda61f3829ce IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.001411050.1
0x807cfa5cfc5c954b0c6aeeca7f1cf80725a2d3089ed3bcae5b0ab55bc7eb6536Craft1847923932024-02-26 21:46:1056 days 3 hrs ago0x7e528b571c78832db13c12bff73c2a15df709334 IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.00130590.1
0x6e45f18cec63daf1ab29cc2215e4bbe1607c8ed2be3e653625eb3c43881e1421Craft1847910172024-02-26 21:40:0556 days 3 hrs ago0x4d8f12386561667cfcc600ce2cc161a0d337da8b IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.00059661 0.1
0x4754e4043f8dbf2c30052b94467384b5e111dbf5c2a3bb5a94ba40c98a941ff6Craft1847865052024-02-26 21:19:5756 days 3 hrs ago0x92cdba52de347d47d045518077f7a4d07be304b5 IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.00056428 0.1
0xa56be4e488ffd06b78cb356e9a2fc675a77efc129e6355dd45c7993f55fe6390Craft1847825092024-02-26 21:02:0756 days 4 hrs ago0xb03be385f4da2b881f0215dc780b26a6e65fc0bd IN  0xeab86f39ac26dce7cac0e3cb4ee15eca8b01b49d0 ETH0.00202495 0.1
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Crafting

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 63 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

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

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

pragma solidity ^0.8.0;

import "../utils/Context.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 Pausable is Context {
    /**
     * @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);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _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 _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 {
        _paused = true;
        emit Paused(_msgSender());
    }

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

File 3 of 63 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

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

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

pragma solidity ^0.8.0;

import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.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 ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
    using Address for address;

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

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

    // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
    string private _uri;

    /**
     * @dev See {_setURI}.
     */
    constructor(string memory uri_) {
        _setURI(uri_);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC1155).interfaceId ||
            interfaceId == type(IERC1155MetadataURI).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 _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 _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 _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 = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }
        _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 = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
            _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 {
        _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);

        _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++) {
            _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 = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            _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 = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                _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");
        _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 IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155Receiver.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 IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155Receiver.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 5 of 63 : IERC1155MetadataURI.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.0;

import "../IERC1155.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 IERC1155MetadataURI is IERC1155 {
    /**
     * @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 6 of 63 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are 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 7 of 63 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @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 8 of 63 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

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

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

File 9 of 63 : ERC20Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)

pragma solidity ^0.8.0;

import "../ERC20.sol";
import "../../../utils/Context.sol";

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        _spendAllowance(account, _msgSender(), amount);
        _burn(account, amount);
    }
}

File 10 of 63 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 11 of 63 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

File 12 of 63 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

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

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

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: address zero is not a valid owner");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _ownerOf(tokenId);
        require(owner != address(0), "ERC721: invalid token ID");
        return owner;
    }

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

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

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

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

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

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        _requireMinted(tokenId);

        return _tokenApprovals[tokenId];
    }

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

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

    /**
     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
     */
    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
        return _owners[tokenId];
    }

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

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

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

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

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

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

        // Check that tokenId was not minted by `_beforeTokenTransfer` hook
        require(!_exists(tokenId), "ERC721: token already minted");

        unchecked {
            // Will not overflow unless all 2**256 token ids are minted to the same owner.
            // Given that tokens are minted one by one, it is impossible in practice that
            // this ever happens. Might change if we allow batch minting.
            // The ERC fails to describe this case.
            _balances[to] += 1;
        }

        _owners[tokenId] = to;

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

        _afterTokenTransfer(address(0), to, tokenId, 1);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     * This is an internal function that does not check if the sender is authorized to operate on the token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

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

        // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
        owner = ERC721.ownerOf(tokenId);

        // Clear approvals
        delete _tokenApprovals[tokenId];

        unchecked {
            // Cannot overflow, as that would require more tokens to be burned/transferred
            // out than the owner initially received through minting and transferring in.
            _balances[owner] -= 1;
        }
        delete _owners[tokenId];

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

        _afterTokenTransfer(owner, address(0), tokenId, 1);
    }

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

        _beforeTokenTransfer(from, to, tokenId, 1);

        // Check that tokenId was not transferred by `_beforeTokenTransfer` hook
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");

        // Clear approvals from the previous owner
        delete _tokenApprovals[tokenId];

        unchecked {
            // `_balances[from]` cannot overflow for the same reason as described in `_burn`:
            // `from`'s balance is the number of token held, which is at least one before the current
            // transfer.
            // `_balances[to]` could overflow in the conditions described in `_mint`. That would require
            // all 2**256 token ids to be minted, which in practice is impossible.
            _balances[from] -= 1;
            _balances[to] += 1;
        }
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId, 1);
    }

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

    /**
     * @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, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` has not been minted yet.
     */
    function _requireMinted(uint256 tokenId) internal view virtual {
        require(_exists(tokenId), "ERC721: invalid token ID");
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is
     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
     * - When `from` is zero, the tokens will be minted for `to`.
     * - When `to` is zero, ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     * - `batchSize` is non-zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256, /* firstTokenId */
        uint256 batchSize
    ) internal virtual {
        if (batchSize > 1) {
            if (from != address(0)) {
                _balances[from] -= batchSize;
            }
            if (to != address(0)) {
                _balances[to] += batchSize;
            }
        }
    }

    /**
     * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
     * - When `from` is zero, the tokens were minted for `to`.
     * - When `to` is zero, ``from``'s tokens were burned.
     * - `from` and `to` are never both zero.
     * - `batchSize` is non-zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 firstTokenId,
        uint256 batchSize
    ) internal virtual {}
}

File 13 of 63 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

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

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @dev See {ERC721-_beforeTokenTransfer}.
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 firstTokenId,
        uint256 batchSize
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, firstTokenId, batchSize);

        if (batchSize > 1) {
            // Will only trigger during construction. Batch transferring (minting) is not available afterwards.
            revert("ERC721Enumerable: consecutive transfers not supported");
        }

        uint256 tokenId = firstTokenId;

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}

File 14 of 63 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

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

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

File 15 of 63 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

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

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

File 16 of 63 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

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

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

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

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

File 17 of 63 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

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

File 18 of 63 : Address.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 Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(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 19 of 63 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

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

pragma solidity ^0.8.0;

import "./IERC165.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 ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 21 of 63 : IERC165.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 IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 22 of 63 : Math.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 Math {
    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 23 of 63 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    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 = Math.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, Math.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 24 of 63 : Actions.sol
// SPDX-License-Identifier: Unlicensed

pragma solidity ^0.8.17;

uint64 constant DAILY_EPOCH_DURATION = 1 days;
uint64 constant DAILY_EPOCH_OFFSET = 0 hours;

uint64 constant HOURLY_EPOCH_DURATION = 1 hours;
uint64 constant NO_OFFSET = 0 hours;

uint256 constant ACTION_LOCK = 101;

uint256 constant ACTION_ADVENTURER_HOMAGE = 1001;
uint256 constant ACTION_ADVENTURER_BATTLE_V3 = 1002;
uint256 constant ACTION_ADVENTURER_COLLECT_EPOCH_REWARDS = 1003;
uint256 constant ACTION_ADVENTURER_VOID_CRAFTING = 1004;
uint256 constant ACTION_ADVENTURER_REALM_CRAFTING = 1005;
uint256 constant ACTION_ADVENTURER_ANIMA_REGENERATION = 1006;
uint256 constant ACTION_ADVENTURER_BATTLE_V3_OPPONENT = 1007;
uint256 constant ACTION_ADVENTURER_TRAINING = 1008;
uint256 constant ACTION_ADVENTURER_TRANSCENDENCE = 1009;

uint256 constant ACTION_ARMORY_STAKE_RARITY_ITEM = 2001;
uint256 constant ACTION_ARMORY_UNSTAKE_RARITY_ITEM = 2002;

uint256 constant ACTION_ARMORY_STAKE_RARITY_ITEM_SHARD = 2011;
uint256 constant ACTION_ARMORY_UNSTAKE_RARITY_ITEM_SHARD = 2012;

uint256 constant ACTION_ARMORY_STAKE_MATERIAL_SHARD = 2021;
uint256 constant ACTION_ARMORY_UNSTAKE_MATERIAL_SHARD = 2022;

uint256 constant ACTION_ARMORY_STAKE_LAB = 2031;
uint256 constant ACTION_ARMORY_UNSTAKE_LAB = 2032;

uint256 constant ACTION_ARMORY_STAKE_COLLECTIBLE = 2041;
uint256 constant ACTION_ARMORY_UNSTAKE_COLLECTIBLE = 2042;

uint256 constant ACTION_ARMORY_STAKE_MATERIAL = 2051;
uint256 constant ACTION_ARMORY_UNSTAKE_MATERIAL = 2052;

uint256 constant ACTION_ARMORY_STAKE_CITY = 2061;
uint256 constant ACTION_ARMORY_UNSTAKE_CITY = 2062;

uint256 constant ACTION_ARMORY_STAKE_MONUMENT = 2061;
uint256 constant ACTION_ARMORY_UNSTAKE_MONUMENT = 2062;

uint256 constant ACTION_REALM_COLLECT_COLLECTIBLES = 4001;
uint256 constant ACTION_REALM_BUILD_LAB = 4011;

File 25 of 63 : IActionDemandAverageStorage.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.17;

interface IActionDemandAverageStorage {
  function getDemandBatch(
    uint _action,
    uint[] calldata _subGroups
  ) external returns (uint256[] memory results);

  function getDemandViewBatch(
    uint _action,
    uint[] calldata _subGroups
  ) external view returns (uint256[] memory results);

  function getDemandPredictionBatch(
    uint _action,
    uint[] calldata _subGroups
  ) external view returns (uint256[] memory results);

  function increaseDemandBatch(
    uint _action,
    uint[] calldata _subGroups,
    uint[] calldata _deltas
  ) external;
}

File 26 of 63 : IActionPermit.sol
// SPDX-License-Identifier: Unlicensed

pragma solidity ^0.8.17;

error Unauthorized(address _tokenAddr, uint256 _tokenId);
error EntityLocked(address _tokenAddr, uint256 _tokenId, uint _lockedUntil);
error MinEpochsTooLow(uint256 _minEpochs);
error InsufficientEpochSpan(
  uint256 _minEpochs,
  uint256 _epochs,
  address _tokenAddr,
  uint256 _tokenId
);
error DuplicateActionAttempt(address _tokenAddr, uint256 _tokenId);

interface IActionPermit {
  // Reverts if no permissions or action was already taken in the last _minEpochs
  function checkAndMarkActionComplete(
    address _sender,
    address _tokenAddr,
    uint256 _tokenId,
    bytes32[] calldata _proof,
    uint256 _action,
    uint256 _minEpochs,
    uint128 _epochConfig
  ) external;

  function checkAndMarkActionCompleteMany(
    address _sender,
    address[] calldata _tokenAddrs,
    uint256[] calldata _tokenIds,
    bytes32[][] calldata _proofs,
    uint256 _action,
    uint256 _minEpochs,
    uint128 _epochConfig
  ) external;

  function checkAndMarkActionCompleteMany(
    address _sender,
    address[] calldata _tokenAddrs,
    uint256[] calldata _tokenIds,
    bytes32[][] calldata _proofs,
    uint256 _action,
    uint256[] calldata _minEpochs,
    uint128 _epochConfig
  ) external;

  // Marks action complete even if already completed
  function forceMarkActionComplete(address _tokenAddr, uint256 _tokenId, uint256 _action) external;

  // Reverts if no permissions
  function checkPermissions(
    address _sender,
    address _tokenAddr,
    uint256 _tokenId,
    bytes32[] calldata _proof,
    uint256 _action
  ) external view;

  function checkOwner(
    address _tokenAddr,
    uint256 _tokenId,
    bytes32[] calldata _proof
  ) external view returns (address);

  function checkPermissionsMany(
    address _sender,
    address[] calldata _tokenAddr,
    uint256[] calldata _tokenId,
    bytes32[][] calldata _proofs,
    uint256 _action
  ) external view;

  function checkPermissionsMany(
    address _sender,
    address _tokenAddr,
    uint256[] calldata _tokenId,
    bytes32[][] calldata _proofs,
    uint256 _action
  ) external view;

  function checkOwnerBatch(
    address[] calldata _tokenAddrs,
    uint256[] calldata _tokenIds,
    bytes32[][] calldata _proofs
  ) external view returns (address[] memory);

  // Reverts if action already taken this epoch
  function checkIfEnoughEpochsElapsed(
    address _tokenAddr,
    uint256 _tokenId,
    uint256 _action,
    uint256 _minEpochs,
    uint128 _epochConfig
  ) external view;

  function checkIfEnoughEpochsElapsedBatch(
    address[] calldata _tokenAddrs,
    uint256[] calldata _tokenIds,
    uint256 _action,
    uint256 _minEpochs,
    uint128 _epochConfig
  ) external view;

  function checkIfEnoughEpochsElapsedBatch(
    address[] calldata _tokenAddrs,
    uint256[] calldata _tokenIds,
    uint256 _action,
    uint256[] calldata _minEpochs,
    uint128 _epochConfig
  ) external view;

  function getElapsedEpochs(
    address[] calldata _tokenAddrs,
    uint256[] calldata _tokenIds,
    uint256 _action,
    uint128 _epochConfig
  ) external view returns (uint[] memory result);
}

File 27 of 63 : IGlobalActionIdStorage.sol
// SPDX-License-Identifier: Unlicensed

pragma solidity ^0.8.17;

interface IGlobalActionIdStorage {
  function getAndIncrementNextId(uint256 action, uint increment) external returns (uint256);

  function getNextId(uint256 action) external view returns (uint256);
}

File 28 of 63 : ILastActionMarkerStorage.sol
// SPDX-License-Identifier: Unlicensed

pragma solidity ^0.8.17;

import "../Manager/ManagerModifier.sol";

interface ILastActionMarkerStorage {
  function setActionMarker(
    address _tokenAddress,
    uint256 _tokenId,
    uint256 _action,
    uint256 _marker
  ) external;

  function getActionMarker(
    address _tokenAddress,
    uint256 _tokenId,
    uint256 _action
  ) external view returns (uint256);
}

File 29 of 63 : IAdventurerData.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

interface IAdventurerData {
  function initData(
    address[] calldata _addresses,
    uint256[] calldata _ids,
    bytes32[][] calldata _proofs,
    uint256[] calldata _professions,
    uint256[][] calldata _points
  ) external;

  function baseProperties(
    address _addr,
    uint256 _id,
    uint256 _start,
    uint256 _end
  ) external view returns (uint256[] memory);

  function aovProperties(
    address _addr,
    uint256 _id,
    uint256 _start,
    uint256 _end
  ) external view returns (uint256[] memory);

  function extensionProperties(
    address _addr,
    uint256 _id,
    uint256 _start,
    uint256 _end
  ) external view returns (uint256[] memory);

  function createFor(
    address _addr,
    uint256 _id,
    uint256[] calldata _points
  ) external;

  function createFor(address _addr, uint256 _id, uint256 _archetype) external;

  function addToBase(
    address _addr,
    uint256 _id,
    uint256 _prop,
    uint256 _val
  ) external;

  function updateBase(
    address _addr,
    uint256 _id,
    uint256 _prop,
    uint256 _val
  ) external;

  function removeFromBase(
    address _addr,
    uint256 _id,
    uint256 _prop,
    uint256 _val
  ) external;

  function addToAov(
    address _addr,
    uint256 _id,
    uint256 _prop,
    uint256 _val
  ) external;

  function updateAov(
    address _addr,
    uint256 _id,
    uint256 _prop,
    uint256 _val
  ) external;

  function removeFromAov(
    address _addr,
    uint256 _id,
    uint256 _prop,
    uint256 _val
  ) external;

  function addToExtension(
    address _addr,
    uint256 _id,
    uint256 _prop,
    uint256 _val
  ) external;

  function updateExtension(
    address _addr,
    uint256 _id,
    uint256 _prop,
    uint256 _val
  ) external;

  function removeFromExtension(
    address _addr,
    uint256 _id,
    uint256 _prop,
    uint256 _val
  ) external;

  function base(
    address _addr,
    uint256 _id,
    uint256 _prop
  ) external view returns (uint256);

  function aov(
    address _addr,
    uint256 _id,
    uint256 _prop
  ) external view returns (uint256);

  function extension(
    address _addr,
    uint256 _id,
    uint256 _prop
  ) external view returns (uint256);
}

File 30 of 63 : IBatchAdventurerData.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

uint constant ADVENTURER_DATA_BASE = 0;
uint constant ADVENTURER_DATA_AOV = 1;
uint constant ADVENTURER_DATA_EXTENSION = 2;

interface IBatchAdventurerData {
  function add(address _addr, uint256 _id, uint256 _type, uint256 _prop, uint256 _val) external;

  function addBatch(
    address[] calldata _addr,
    uint256[] calldata _id,
    uint256 _type,
    uint256[][] calldata _prop,
    uint256[][] calldata _val
  ) external;

  function addBatch(
    address[] calldata _addr,
    uint256[] calldata _id,
    uint256 _type,
    uint256 _prop,
    uint256 _val
  ) external;

  function addBatch(
    address[] calldata _addr,
    uint256[] calldata _id,
    uint256 _type,
    uint256 _prop,
    uint256[] calldata _val
  ) external;

  function update(address _addr, uint256 _id, uint256 _type, uint256 _prop, uint256 _val) external;

  function updateRaw(address _addr, uint256 _id, uint256 _type, uint24[10] calldata _val) external;

  function updateBatch(
    address[] calldata _addr,
    uint256[] calldata _id,
    uint256 _type,
    uint256 _prop,
    uint256[] calldata _val
  ) external;

  function updateBatchRaw(
    address[] calldata _addr,
    uint256[] calldata _id,
    uint256 _type,
    uint24[10][] calldata _val
  ) external;

  function remove(address _addr, uint256 _id, uint256 _type, uint256 _prop, uint256 _val) external;

  function removeBatch(
    address[] calldata _addr,
    uint256[] calldata _id,
    uint256 _type,
    uint256[][] calldata _prop,
    uint256[][] calldata _val
  ) external;

  function get(address _addr, uint256 _id, uint256 _type, uint256 _prop) external returns (uint256);

  function getRaw(address _addr, uint256 _id, uint256 _type) external returns (uint24[10] memory);

  function getMulti(
    address _addr,
    uint256 _id,
    uint256 _type,
    uint256[] calldata _prop
  ) external returns (uint256[] memory result);

  function getBatch(
    address[] calldata _addr,
    uint256[] calldata _id,
    uint256 _type,
    uint256 _prop
  ) external returns (uint256[] memory);

  function getBatchMulti(
    address[] calldata _addrs,
    uint256[] calldata _ids,
    uint256 _type,
    uint256[] calldata _props
  ) external returns (uint256[][] memory);

  function getRawBatch(
    address[] calldata _addrs,
    uint256[] calldata _ids,
    uint256 _type
  ) external returns (uint24[10][] memory result);
}

File 31 of 63 : IBatchAdventurerGateway.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

interface IBatchAdventurerGateway {
  function checkAddress(address _addr, bytes32[] calldata _proof) external view;

  function checkAddressBatch(address[] calldata _addr, bytes32[][] calldata _proof) external view;
}

File 32 of 63 : TraitConstants.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.17;

library traits {
  uint256 public constant ADV_TRAIT_GROUP_BASE = 0;

  // Base, _type = 0
  uint256 public constant ADV_TRAIT_BASE_LEVEL = 0;
  uint256 public constant ADV_TRAIT_BASE_XP = 1;
  uint256 public constant ADV_TRAIT_BASE_STRENGTH = 2;
  uint256 public constant ADV_TRAIT_BASE_DEXTERITY = 3;
  uint256 public constant ADV_TRAIT_BASE_CONSTITUTION = 4;
  uint256 public constant ADV_TRAIT_BASE_INTELLIGENCE = 5;
  uint256 public constant ADV_TRAIT_BASE_WISDOM = 6;
  uint256 public constant ADV_TRAIT_BASE_CHARISMA = 7;
  uint256 public constant ADV_TRAIT_BASE_CLASS = 8;

  uint256 public constant ADV_TRAIT_GROUP_ADVANCED = 1;
  // Advanced, _type = 1
  uint256 public constant ADV_TRAIT_ADVANCED_ARCHETYPE = 0;
  uint256 public constant ADV_TRAIT_ADVANCED_PROFESSION = 1;
  uint256 public constant ADV_TRAIT_ADVANCED_TRAINING_POINTS = 2;

  // Base Ttraits
  // See AdventurerData.sol for details
  uint256 public constant LEGACY_ADV_BASE_TRAIT_XP = 0;
  uint256 public constant LEGACY_ADV_BASE_TRAIT_XP_BROKEN = 1;
  uint256 public constant LEGACY_ADV_BASE_TRAIT_STRENGTH = 2;
  uint256 public constant LEGACY_ADV_BASE_TRAIT_DEXTERITY = 3;
  uint256 public constant LEGACY_ADV_BASE_TRAIT_CONSTITUTION = 4;
  uint256 public constant LEGACY_ADV_BASE_TRAIT_INTELLIGENCE = 5;
  uint256 public constant LEGACY_ADV_BASE_TRAIT_WISDOM = 6;
  uint256 public constant LEGACY_ADV_BASE_TRAIT_CHARISMA = 7;
  uint256 public constant LEGACY_ADV_BASE_TRAIT_HP = 8;
  uint256 public constant LEGACY_ADV_BASE_TRAIT_HP_USED = 9;

  // AoV Traits
  // See AdventurerData.sol for details
  uint256 public constant LEGACY_ADV_AOV_TRAIT_LEVEL = 0;
  uint256 public constant LEGACY_ADV_AOV_TRAIT_ARCHETYPE = 1;
  uint256 public constant LEGACY_ADV_AOV_TRAIT_CLASS = 2;
  uint256 public constant LEGACY_ADV_AOV_TRAIT_PROFESSION = 3;

  function baseTraitNames() public pure returns (string[10] memory) {
    return [
      "Level",
      "XP",
      "Strength",
      "Dexterity",
      "Constitution",
      "Intelligence",
      "Wisdom",
      "Charisma",
      "Class",
      ""
    ];
  }

  function advancedTraitNames() public pure returns (string[2] memory) {
    return ["Archetype", "Profession"];
  }

  function baseTraitName(uint256 traitId) public pure returns (string memory) {
    return baseTraitNames()[traitId];
  }

  function advancedTraitName(uint256 traitId) public pure returns (string memory) {
    return advancedTraitNames()[traitId];
  }
}

File 33 of 63 : Anima.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

import "../Bound/IERC20Bound.sol";
import "./IAnima.sol";

import "../Manager/ManagerModifier.sol";

contract Anima is IAnima, ERC20, ERC20Burnable, ManagerModifier, ReentrancyGuard, Pausable {
  //=======================================
  // Immutables
  //=======================================
  IERC20Bound public immutable BOUND;
  uint256 public immutable CAP;

  //=======================================
  // Constructor
  //=======================================
  constructor(
    address _manager,
    address _bound,
    uint256 _cap
  ) ERC20("Anima", "ANIMA") ManagerModifier(_manager) {
    BOUND = IERC20Bound(_bound);
    CAP = _cap;
  }

  //=======================================
  // External
  //=======================================
  function mintFor(address _for, uint256 _amount) external override onlyTokenMinter {
    // Check amount doesn't exceed cap
    require(ERC20.totalSupply() + _amount <= CAP, "Anima: Cap exceeded");

    // Mint
    _mint(_for, _amount);
  }

  function burnFrom(address account, uint256 amount) public override(IAnima, ERC20Burnable) {
    super.burnFrom(account, amount);
  }

  //=======================================
  // Admin
  //=======================================
  function pause() external onlyAdmin {
    _pause();
  }

  function unpause() external onlyAdmin {
    _unpause();
  }

  //=======================================
  // Internal
  //=======================================
  function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
    // Call super
    super._beforeTokenTransfer(from, to, amount);

    // Check if sender is manager
    if (!MANAGER.isManager(msg.sender, 0)) {
      // Check if minting or burning
      if (from != address(0) && to != address(0)) {
        // Check if token is unbound
        require(BOUND.isUnbound(address(this)), "Anima: Token not unbound");
      }
    }

    // Check if contract is paused
    require(!paused(), "Anima: Paused");
  }
}

File 34 of 63 : IAnima.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

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

interface IAnima is IERC20 {
  function mintFor(address _for, uint256 _amount) external;

  function burnFrom(address account, uint256 amount) external;
}

File 35 of 63 : IArmory.sol
// SPDX-License-Identifier: Unlicensed

pragma solidity ^0.8.17;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

import "../Manager/ManagerModifier.sol";
import "./IArmoryEntityStorageAdapter.sol";

struct MultiStakeRequest {
  address _staker;
  address[] _ownerAddresses;
  uint256[] _ownerTokenIds;
  bytes32[][] _proofs;
  address[] _entityAddresses;
  uint256[][][] _entityIds;
  uint256[][][] _entityAmounts;
}

interface IArmory {
  function stake(
    address _staker,
    address _ownerAddress,
    uint256 _ownerTokenId,
    address _entityAddress,
    bytes32[] calldata _proof,
    uint256 _entityId,
    uint256 _entityAmount
  ) external;

  function stakeBatch(
    address _staker,
    address _ownerAddress,
    uint256 _ownerTokenId,
    bytes32[] calldata _proof,
    address _entityAddress,
    uint256[] calldata _entityIds,
    uint256[] calldata _entityAmounts
  ) external;

  function stakeBatch(
    address _staker,
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerTokenIds,
    bytes32[][] calldata _proofs,
    address _entityAddress,
    uint256[][] calldata _entityIds,
    uint256[][] calldata _entityAmounts
  ) external;

  function stakeBatchMulti(MultiStakeRequest calldata _request) external;

  function unstakeBatch(
    address _staker,
    address _ownerAddress,
    uint256 _ownerTokenId,
    bytes32[] calldata _proof,
    address _entityAddress,
    uint256[] calldata _entityIds,
    uint256[] calldata _entityAmounts
  ) external;

  function unstakeBatch(
    address _staker,
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerTokenIds,
    bytes32[][] calldata _proofs,
    address _entityAddress,
    uint256[][] calldata _entityIds,
    uint256[][] calldata _entityAmounts
  ) external;

  function unstakeBatchMulti(MultiStakeRequest calldata _request) external;

  function burn(
    address _ownerAddress,
    uint256 _ownerTokenId,
    address _entityAddress,
    uint256 _entityId,
    uint256 _entityAmount
  ) external;

  function burnBatch(
    address _ownerAddress,
    uint256 _ownerTokenId,
    address _entityAddress,
    uint256[] calldata _entityIds,
    uint256[] calldata _entityAmounts
  ) external;

  function burnBatch(
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerTokenIds,
    address _entityAddress,
    uint256[][] calldata _entityIds,
    uint256[][] calldata _entityAmounts
  ) external;

  function burnBatchMulti(
    address _ownerAddress,
    uint256 _ownerTokenId,
    address[] calldata _entityAddresses,
    uint256[][] calldata _entityIds,
    uint256[][] calldata _entityAmounts
  ) external;

  function burnBatchMulti(
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerTokenIds,
    address[] calldata _entityAddresses,
    uint256[][][] calldata _entityIds,
    uint256[][][] calldata _entityAmounts
  ) external;

  function mint(
    address _ownerAddress,
    uint256 _ownerTokenId,
    address _entityAddress,
    uint256 _entityId,
    uint256 _entityAmount
  ) external;

  function mintBatch(
    address _ownerAddresses,
    uint256 _ownerTokenIds,
    address _entityAddress,
    uint256[] calldata _entityIds,
    uint256[] calldata _entityAmounts
  ) external;

  function mintBatch(
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerTokenIds,
    address _entityAddress,
    uint256[][] calldata _entityIds,
    uint256[][] calldata _entityAmounts
  ) external;

  function mintBatchMulti(
    address _ownerAddress,
    uint256 _ownerTokenId,
    address[] calldata _entityAddresses,
    uint256[][] calldata _entityIds,
    uint256[][] calldata _entityAmounts
  ) external;

  function mintBatchMulti(
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerTokenIds,
    address[] calldata _entityAddresses,
    uint256[][][] calldata _entityIds,
    uint256[][][] calldata _entityAmounts
  ) external;

  function checkMinimumAmounts(
    address _ownerAddresses,
    uint256 _ownerTokenIds,
    address _entityAddress,
    uint256[] calldata _entityIds,
    uint256[] calldata _entityAmounts
  ) external view;

  function checkMinimumAmounts(
    address _ownerAddresses,
    uint256 _ownerTokenIds,
    address _entityAddress,
    uint256[] calldata _entityIds,
    uint256 _entityAmounts
  ) external view;

  function checkMinimumAmountsBatch(
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerTokenIds,
    address _entityAddress,
    uint256[][] calldata _entityIds,
    uint256[][] calldata _entityAmounts
  ) external view;

  function checkMinimumAmountsBatch(
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerTokenIds,
    address _entityAddress,
    uint256[][] calldata _entityIds,
    uint256 _entityAmount
  ) external view;

  function balanceOf(
    address _ownerAddress,
    uint _ownerId,
    address _entityAddress,
    uint _entityTokenId
  ) external view returns (uint);

  function balanceOfBatch(
    address _ownerAddress,
    uint _ownerId,
    address _entityAddress,
    uint[] memory _entityTokenIds
  ) external view returns (uint[] memory);
}

File 36 of 63 : IArmoryEntityStorageAdapter.sol
// SPDX-License-Identifier: Unlicensed

pragma solidity ^0.8.17;

interface IArmoryEntityStorageAdapter {
  error Unauthorized(address _staker, address _ownerAddress, uint _ownerId);
  error UnsupportedOperation(address _entityAddress, string operation);
  error UnsupportedEntity(address _entityAddress);
  error InsufficientAmountStaked(
    address _ownerAddress,
    uint _ownerId,
    address _entityAddress,
    uint _tokenIds,
    uint _tokenAmounts
  );

  function entityType() external pure returns (uint);

  function stake(
    address _staker,
    address _ownerAddress,
    uint256 _ownerId,
    bytes32[] calldata _proof,
    address _entityAddress,
    uint256 _entityTokenId,
    uint256 _entityAmount
  ) external;

  function stakeBatch(
    address _staker,
    address _ownerAddresses,
    uint256 _ownerIds,
    bytes32[] calldata _proof,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256[] calldata _entityTokenIds, // only used for ERC-721, ERC-1155
    uint256[] calldata _entityAmounts // only used for ERC-20, ERC-1155
  ) external;

  function stakeBatch(
    address _staker,
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerIds,
    bytes32[][] calldata _proofs,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256[][] calldata _entityTokenIds, // only used for ERC-721, ERC-1155
    uint256[][] calldata _entityAmounts // only used for ERC-20, ERC-1155
  ) external;

  function unstake(
    address _staker,
    address _ownerAddress,
    uint256 _ownerId,
    bytes32[] calldata _proof,
    address _entityAddress,
    uint256 _entityTokenId,
    uint256 _entityAmount
  ) external;

  function unstakeBatch(
    address _staker,
    address _ownerAddresses,
    uint256 _ownerIds,
    bytes32[] calldata _proof,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256[] calldata _entityTokenIds, // only used for ERC-721, ERC-1155
    uint256[] calldata _entityAmounts // only used for ERC-20, ERC-1155
  ) external;

  function unstakeBatch(
    address _staker,
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerIds,
    bytes32[][] calldata _proofs,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256[][] calldata _entityTokenIds, // only used for ERC-721, ERC-1155
    uint256[][] calldata _entityAmounts // only used for ERC-20, ERC-1155
  ) external;

  function burn(
    address _ownerAddress,
    uint256 _ownerId,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256 _entityTokenId, // only used for ERC-721, ERC-1155
    uint256 _entityAmount // only used for ERC-20, ERC-1155
  ) external;

  function burnBatch(
    address _ownerAddress,
    uint256 _ownerId,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256[] calldata _entityTokenIds, // only used for ERC-721, ERC-1155
    uint256[] calldata _entityAmounts // only used for ERC-20, ERC-1155
  ) external;

  function burnBatch(
    address[] calldata _ownerAddress,
    uint256[] calldata _ownerId,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256[][] calldata _entityTokenIds, // only used for ERC-721, ERC-1155
    uint256[][] calldata _entityAmounts // only used for ERC-20, ERC-1155
  ) external;

  function mint(
    address _ownerAddresses,
    uint256 _ownerIds,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256 _entityTokenId, // only used for ERC-721, ERC-1155
    uint256 _entityAmount // only used for ERC-20, ERC-1155
  ) external;

  function mintBatch(
    address _ownerAddresses,
    uint256 _ownerIds,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256[] calldata _entityTokenIds, // only used for ERC-721, ERC-1155
    uint256[] calldata _entityAmounts // only used for ERC-20, ERC-1155
  ) external;

  function mintBatch(
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerIds,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256[][] calldata _entityTokenIds, // only used for ERC-721, ERC-1155
    uint256[][] calldata _entityAmounts // only used for ERC-20, ERC-1155
  ) external;

  // Reverts if not enough tokens
  function batchCheckAmounts(
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerIds,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256[][] calldata _entityTokenIds, // only used for ERC-721, ERC-1155
    uint256[][] calldata _entityAmounts // only used for ERC-20, ERC-1155
  ) external view;

  // Reverts if not enough tokens
  function batchCheckAmounts(
    address _ownerAddresses,
    uint256 _ownerIds,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256[] calldata _entityTokenIds, // only used for ERC-721, ERC-1155
    uint256[] calldata _entityAmounts // only used for ERC-20, ERC-1155
  ) external view;

  // Reverts if not enough tokens
  function batchCheckAmounts(
    address _ownerAddresses,
    uint256 _ownerIds,
    address _entityAddress, // only used for ERC-20, ERC-721, ERC-1155
    uint256[] calldata _entityTokenIds, // only used for ERC-721, ERC-1155
    uint256 _entityAmounts // only used for ERC-20, ERC-1155
  ) external view;

  function balanceOf(
    address _ownerAddress,
    uint _ownerIds,
    address _entityAddress,
    uint _entityTokenId
  ) external view returns (uint);

  function balanceOfBatch(
    address _ownerAddress,
    uint _ownerIds,
    address _entityAddress,
    uint[] calldata _entityTokenIds
  ) external view returns (uint[] memory);
}

File 37 of 63 : IDurabilityEnabledArmory.sol
// SPDX-License-Identifier: Unlicensed

pragma solidity ^0.8.17;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

import "../Manager/ManagerModifier.sol";
import "./IArmoryEntityStorageAdapter.sol";

interface IDurabilityEnabledArmory {
  function currentDurability(
    address _ownerAddress,
    uint256 _ownerId,
    address _entityAddress,
    uint256 _entityId
  ) external view returns (uint);

  function currentDurabilityBatch(
    address _ownerAddress,
    uint256 _ownerId,
    address _entityAddress,
    uint256[] calldata _entityId
  ) external view returns (uint[] memory);

  function currentDurabilityBatch(
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerIds,
    address _entityAddress,
    uint256[][] calldata _entityIds
  ) external view returns (uint[][] memory);

  function currentDurabilityBatchMulti(
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerIds,
    address[] calldata _entityAddress,
    uint256[][][] calldata _entityIds
  ) external view returns (uint[][][] memory);

  function currentDurabilityPercentage(
    address _ownerAddress,
    uint256 _ownerId,
    address _entityAddress,
    uint256 _entityId
  ) external view returns (uint);

  function currentDurabilityPercentageBatch(
    address _ownerAddress,
    uint256 _ownerId,
    address _entityAddress,
    uint256[] calldata _entityId
  ) external view returns (uint[] memory);

  function currentDurabilityPercentageBatch(
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerIds,
    address _entityAddress,
    uint256[][] calldata _entityIds
  ) external view returns (uint[][] memory);

  function currentDurabilityPercentageBatchMulti(
    address[] calldata _ownerAddresses,
    uint256[] calldata _ownerIds,
    address[] calldata _entityAddress,
    uint256[][][] calldata _entityIds
  ) external view returns (uint[][][] memory);

  function reduceDurability(
    address _ownerAddress,
    uint _ownerTokenId,
    address _ownedTokenAddress,
    uint _ownedTokenId,
    uint _durabilityLoss,
    bool _startNewTokenIfNeeded,
    bool _ignoreAvailability
  ) external;

  function reduceDurabilityBatch(
    address[] calldata _ownerAddresses,
    uint[] calldata _ownerTokenIds,
    address _ownedTokenAddress,
    uint[][] calldata _ownedTokenIds,
    uint durabilityLoss,
    bool _startNewTokenIfNeeded,
    bool _ignoreAvailability
  ) external;

  function reduceDurabilityMultiBatch(
    address[] calldata _ownerAddresses,
    uint[] calldata _ownerTokenIds,
    address[] calldata _ownedTokenAddresses,
    uint[][][] calldata _ownedTokenIds,
    uint _durabilityLoss,
    bool _startNewTokenIfNeeded,
    bool _ignoreAvailability
  ) external;

  function reduceDurabilityMultiBatch(
    address[] calldata _ownerAddresses,
    uint[] calldata _ownerTokenIds,
    address[] calldata _entityAddresses,
    uint[][][] calldata _entityTokenIds,
    uint[][][] calldata _durabilityLosses,
    bool _startNewTokenIfNeeded,
    bool _ignoreAvailability
  ) external;
}

File 38 of 63 : IBatchBurnableStructure.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

interface IBatchBurnableStructure {
  function burnBatchFor(
    address _from,
    uint256[] calldata ids,
    uint256[] calldata amounts
  ) external;
}

File 39 of 63 : IERC20Bound.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

interface IERC20Bound {
  function unbind(address _addresses) external;

  function isUnbound(address _addr) external view returns (bool);
}

File 40 of 63 : Crafting.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

import "../Adventurer/TraitConstants.sol";
import "../Resource/ResourceConstants.sol";

import "../Action/ILastActionMarkerStorage.sol";
import "../Action/Actions.sol";
import "../Action/IActionDemandAverageStorage.sol";
import "../Lab/ILab.sol";
import "../Adventurer/IAdventurerData.sol";
import "../Resource/IResource.sol";
import "../Utils/Epoch.sol";
import "../Utils/Random.sol";
import "../lib/FloatingPointConstants.sol";

import "../Particle/Particle.sol";
import "../Manager/ManagerModifier.sol";
import "./ICrafting.sol";
import "../Action/IActionPermit.sol";
import "../Armory/IArmory.sol";
import "./IOwnerSpecificRewardsPool.sol";
import "../Anima/Anima.sol";
import "../Realm/Realm.sol";
import "../Action/IGlobalActionIdStorage.sol";
import "./ICraftingDynamicConfigProvider.sol";
import "../RandomPicker/RandomPicker.sol";
import "../Armory/IDurabilityEnabledArmory.sol";
import "../Utils/ArrayUtils.sol";
import "../Productivity/IProductivity.sol";
import "../Adventurer/IBatchAdventurerData.sol";
import "../Adventurer/IBatchAdventurerGateway.sol";
import "../Renown/IFocus.sol";

struct CraftingContractCreationRequest {
  address MANAGER;
  address FOCUS;
  address GATEWAY;
  address ACTION_PERMIT;
  address ACTION_ID_STORAGE;
  address ACTION_DEMAND_STORAGE;
  address ADVENTURER_DATA;
  address RESOURCE;
  address ADVENTURER_ARMORY;
  address REALM_ARMORY;
  address ANIMA;
  address REALM_ADDRESS;
  address LAB_ADDRESS;
  address CRAFTING_CONFIG_PROVIDER;
  address PRODUCTIVITY_STORAGE;
  address RANDOM_PICKER;
  address AOV;
}

enum RecipeRequirementType {
  MATERIAL_GROUP,
  EXACT_TOKEN
}

struct RecipeRequirement {
  address requirementAddress;
  RecipeRequirementType requirementType;
  bool enabled;
  uint32 tokenAmount;
  uint256 requirementArgument; // rarity value or the token id
}

struct LabCraftingConfig {
  bool enabled;
  uint64 minimumLevel;
  uint256 baseAnimaCost;
  uint256 animaCapacity;
  uint256 labIndex;
}

struct Recipe {
  bool enabled;
  RecipeRequirement[4] requirements;
  IOwnerSpecificRewardsPool rewardsPool;
  uint64 subPoolId;
  uint256 labId;
}

struct CraftingCost {
  uint realm;
  uint void;
}

contract Crafting is ICrafting, ManagerModifier, ReentrancyGuard, Pausable {
  error AdventurerLevelTooLow(uint64 minimumLevel, uint currentLevel);

  error InsufficientLabs(uint labId);
  error InvalidLabId(uint labId);
  error InvalidMaterialTotal(
    uint materialAddressIndex,
    uint adventurerIndex,
    uint materialIdIndex,
    uint expectedAmount,
    uint actualAmount
  );
  error InvalidTotalRequestsCount();
  error InvalidRecipe(uint recipeId);
  error InvalidRecipeAmount(uint recipeId);
  error InvalidMaterial(uint recipeId, address materialAddress, uint materialId);
  error InvalidRequirementConfig(uint recipeId);
  error InsufficientMaterials(uint recipeId);
  error GasTooLow(uint gasAmount, uint gasRequired);

  //=======================================
  // Immutables
  //=======================================
  IFocus public immutable FOCUS;
  IBatchAdventurerGateway public GATEWAY;
  IActionPermit public ACTION_PERMIT;
  IGlobalActionIdStorage public immutable ACTION_ID_STORAGE;
  IActionDemandAverageStorage public immutable ACTION_DEMAND_STORAGE;
  IBatchAdventurerData public immutable ADVENTURER_DATA;
  IResource public immutable RESOURCE;
  IArmory public immutable ADVENTURER_ARMORY;
  IDurabilityEnabledArmory public immutable REALM_ARMORY;
  IProductivity public immutable PRODUCTIVITY_STORAGE;
  Anima public immutable ANIMA;
  address public immutable AOV;
  address public immutable REALM_ADDRESS;
  address public immutable LAB_ADDRESS;
  IRandomPicker public immutable RANDOM_PICKER;
  ICraftingDynamicConfigProvider public CRAFTING_CONFIG_PROVIDER;

  //=======================================
  // Lab config
  //=======================================
  uint128 cacheEpochConfig;
  mapping(uint256 => LabCraftingConfig) public labConfig;
  uint256[] supportedLabIds;
  DynamicCraftingConfigCache _dynamicConfigCache;

  //=======================================
  // Uint256
  //=======================================
  uint256 minimumGasPerCraft;

  //=======================================
  // Recipes
  //=======================================
  uint256[] public availableRecipes;
  mapping(uint256 => Recipe) public recipes;

  // material address -> material id -> rarity
  mapping(address => mapping(uint256 => uint256)) public materialGroupConfig;

  //=======================================
  // Event
  //=======================================

  event CraftingStarted(
    uint actionId,
    uint craftId,
    address adventurerAddress,
    uint adventurerId,
    uint recipeId
  );

  event CraftedItem(
    uint actionId,
    uint craftId,
    address adventurerAddress,
    uint adventurerId,
    uint resultType,
    address resultAddress,
    uint resultTokenId,
    uint resultAmount
  );

  event CraftingCosts(
    uint actionId,
    uint labId,
    uint animaMultiplier,
    uint animaAmount,
    uint craftedTotal,
    uint craftingLevelsTotal
  );

  //=======================================
  // Struct
  //=======================================

  struct DynamicCraftingConfigCache {
    uint epoch;
    uint32[] realmCraftingCostPercentage;
    uint32[] voidCraftingCostPercentage;
    uint32[] durabilityLossPercentage;
    uint32[] productivityPerCraft;
  }

  struct CraftingCostCurveConfig {
    uint64 labSoftCap;
    uint64 min;
    uint64 max;
    uint64 range;
  }

  struct TempMemoryStorage {
    address adventurerAddress;
    uint256 adventurerId;
    uint256 adventurerLevel;
    uint256[] recipeIds;
    uint256[] realmIds;
    address[] materialAddresses;
    uint256[][][] usedMaterials;
    uint256[][][] usedMaterialAmounts;
    // temp storage
    uint256 randomBase;
    uint256 currentRecipeId;
    uint256 currentRecipeAmount;
    uint256 currentRecipeLabsToBurn;
    uint256 currentRealmId;
    uint256 currentLabStakedCount;
    uint256 currentSuccessfulCrafts;
    uint256 craftingCost;
  }

  struct VerificationMemory {
    Recipe recipe;
    RecipeMaterialMapping craftingAttempt;
    MaterialRequirementMapping materialMapping;
    uint256[][][] totalTokenAmounts;
    uint[] craftAmounts;
    uint[] craftCostAdjustments;
    uint[] levels;
  }

  //=======================================
  // Constructor
  //=======================================
  constructor(CraftingContractCreationRequest memory _request) ManagerModifier(_request.MANAGER) {
    ACTION_ID_STORAGE = IGlobalActionIdStorage(_request.ACTION_ID_STORAGE);
    ACTION_PERMIT = IActionPermit(_request.ACTION_PERMIT);
    FOCUS = IFocus(_request.FOCUS);
    GATEWAY = IBatchAdventurerGateway(_request.GATEWAY);
    ACTION_DEMAND_STORAGE = IActionDemandAverageStorage(_request.ACTION_DEMAND_STORAGE);
    LAB_ADDRESS = _request.LAB_ADDRESS;
    REALM_ADDRESS = _request.REALM_ADDRESS;
    REALM_ARMORY = IDurabilityEnabledArmory(_request.REALM_ARMORY);
    ADVENTURER_DATA = IBatchAdventurerData(_request.ADVENTURER_DATA);
    ADVENTURER_ARMORY = IArmory(_request.ADVENTURER_ARMORY);
    ANIMA = Anima(_request.ANIMA);
    RESOURCE = IResource(_request.RESOURCE);
    CRAFTING_CONFIG_PROVIDER = ICraftingDynamicConfigProvider(_request.CRAFTING_CONFIG_PROVIDER);
    PRODUCTIVITY_STORAGE = IProductivity(_request.PRODUCTIVITY_STORAGE);
    RANDOM_PICKER = IRandomPicker(_request.RANDOM_PICKER);
    AOV = _request.AOV;
    cacheEpochConfig = Epoch.toConfig(1 days, 0 hours);
    minimumGasPerCraft = 300000;
  }

  //=======================================
  // External
  //=======================================
  function craft(
    CraftingRequests calldata _realmRequests,
    CraftingRequests calldata _voidRequests,
    StakeRequest calldata _stakeRequest
  ) external nonReentrant whenNotPaused {
    require(msg.sender == tx.origin, "Crafting is not allowed through another contract");
    if (gasleft() < (_realmRequests.totalCrafts + _voidRequests.totalCrafts) * minimumGasPerCraft) {
      revert GasTooLow(
        gasleft(),
        (_realmRequests.totalCrafts + _voidRequests.totalCrafts) * minimumGasPerCraft
      );
    }

    if (_stakeRequest.adventurerAddresses.length > 0) {
      ADVENTURER_ARMORY.stakeBatchMulti(
        MultiStakeRequest(
          msg.sender,
          _stakeRequest.adventurerAddresses,
          _stakeRequest.adventurerIds,
          _stakeRequest.proofs,
          _stakeRequest.matsToStakeAddresses,
          _stakeRequest.matsToStakeIds,
          _stakeRequest.matsToStakeAmounts
        )
      );
    }

    DynamicCraftingConfigCache storage config = _getDynamicConfig();
    uint totalAnima;
    if (_realmRequests.totalCrafts > 0) {
      totalAnima += _handleRealmCrafting(_realmRequests, config);
    }
    if (_voidRequests.totalCrafts > 0) {
      totalAnima += _handleVoidCrafting(_voidRequests, config);
    }

    ANIMA.burnFrom(msg.sender, totalAnima);
  }

  function dynamicConfigCache() public returns (DynamicCraftingConfigCache memory) {
    return _getDynamicConfig();
  }

  function getSupportedLabIds() public view returns (uint[] memory) {
    return supportedLabIds;
  }

  function maximumRealmCraftsAvailable() public returns (uint[] memory) {
    return _maximumCraftAmounts(_getDynamicConfig());
  }

  function maximumRealmCraftsAvailableView() public view returns (uint[] memory) {
    return _maximumCraftAmounts(_dynamicConfigCache);
  }

  function craftingCostsView() external view returns (CraftingCost[] memory result) {
    result = new CraftingCost[](supportedLabIds.length);

    for (uint i = 0; i < result.length; i++) {
      result[i].realm = labConfig[supportedLabIds[i]].baseAnimaCost;
      result[i].void =
        (result[i].realm * uint(_dynamicConfigCache.voidCraftingCostPercentage[i])) /
        ONE_HUNDRED;
    }
  }

  function craftingCosts() external returns (CraftingCost[] memory result) {
    result = new CraftingCost[](supportedLabIds.length);

    for (uint i = 0; i < result.length; i++) {
      result[i].realm = labConfig[supportedLabIds[i]].baseAnimaCost;
      result[i].void =
        (result[i].realm * uint(_getDynamicConfig().voidCraftingCostPercentage[i])) /
        ONE_HUNDRED;
    }
  }

  //=======================================
  // Internals
  //=======================================

  function _handleRealmCrafting(
    CraftingRequests calldata _requests,
    DynamicCraftingConfigCache storage _config
  ) internal returns (uint) {
    (uint anima, uint[] memory realmCrafts, uint randomBase) = _handleCrafting(
      _requests,
      _config.realmCraftingCostPercentage,
      ACTION_ADVENTURER_REALM_CRAFTING
    );

    _affectRealms(realmCrafts, randomBase);

    return anima;
  }

  function _affectRealms(uint[] memory realmCrafts, uint randomBase) internal {
    verifyCraftsAvailable(realmCrafts);

    uint[] memory memLabIds = supportedLabIds;
    (uint[][] memory realmIds, ) = RANDOM_PICKER.useRandomizerBatch(
      uint256(uint160(LAB_ADDRESS)),
      memLabIds,
      realmCrafts,
      randomBase
    );

    address[] memory realmAddresses;
    uint[][] memory labIds;
    for (uint i = 0; i < memLabIds.length; i++) {
      if (realmCrafts[i] == 0) {
        continue;
      }
      realmAddresses = ArrayUtils.toMemoryArray(REALM_ADDRESS, realmCrafts[i]);
      labIds = new uint[][](realmIds[i].length);
      for (uint j = 0; j < realmIds[i].length; j++) {
        labIds[j] = ArrayUtils.toMemoryArray(memLabIds[i], 1);
      }

      REALM_ARMORY.reduceDurabilityBatch(
        realmAddresses,
        realmIds[i],
        LAB_ADDRESS,
        labIds,
        _dynamicConfigCache.durabilityLossPercentage[i],
        true,
        true
      );

      PRODUCTIVITY_STORAGE.changeBatch(
        realmIds[i],
        int(uint(_dynamicConfigCache.productivityPerCraft[i])),
        true
      );

      uint animaCapacity = labConfig[memLabIds[i]].animaCapacity;
      for (uint j = 0; j < realmIds[i].length; j++) {
        RESOURCE.add(realmIds[i][j], resources.ANIMA_CAPACITY, animaCapacity);
      }
    }
  }

  function _handleVoidCrafting(
    CraftingRequests calldata _requests,
    DynamicCraftingConfigCache storage _config
  ) internal returns (uint totalAnima) {
    (totalAnima, , ) = _handleCrafting(
      _requests,
      _config.voidCraftingCostPercentage,
      ACTION_ADVENTURER_VOID_CRAFTING
    );
  }

  function _handleCrafting(
    CraftingRequests calldata _requests,
    uint32[] storage animaMultipliers,
    uint _action
  ) internal returns (uint256 totalAnima, uint[] memory totalCrafts, uint randomBase) {
    GATEWAY.checkAddressBatch(_requests.adventurerAddresses, _requests.proofs);
    ACTION_PERMIT.checkPermissionsMany(
      msg.sender,
      _requests.adventurerAddresses,
      _requests.adventurerIds,
      _requests.proofs,
      _action
    );
    ADVENTURER_ARMORY.burnBatchMulti(
      _requests.adventurerAddresses,
      _requests.adventurerIds,
      _requests.materialAddresses,
      _requests.materialIds,
      _requests.materialAmounts
    );

    uint[] memory levels = ADVENTURER_DATA.getBatch(
      _requests.adventurerAddresses,
      _requests.adventurerIds,
      traits.ADV_TRAIT_GROUP_BASE,
      traits.ADV_TRAIT_BASE_LEVEL
    );

    uint[] memory craftingCostAdjustments;
    (totalCrafts, craftingCostAdjustments) = _verifyMaterials(_requests, levels);
    uint craftsCount;
    (totalAnima, craftsCount) = _totals(
      _action,
      totalCrafts,
      craftingCostAdjustments,
      animaMultipliers
    );
    if (craftsCount != _requests.totalCrafts) {
      revert InvalidTotalRequestsCount();
    }

    randomBase = _dispense(_action, _requests);

    ACTION_DEMAND_STORAGE.increaseDemandBatch(_action, supportedLabIds, totalCrafts);
  }

  function _dispense(uint _action, CraftingRequests calldata _requests) internal returns (uint) {
    uint craftId = ACTION_ID_STORAGE.getAndIncrementNextId(_action, _requests.totalCrafts);
    uint randomBase = Random.startRandomBase(_action, craftId);
    for (uint i = 0; i < _requests.recipes.length; i++) {
      for (uint j = 0; j < _requests.recipes[i].length; j++) {
        emit CraftingStarted(
          _action,
          craftId,
          _requests.adventurerAddresses[i],
          _requests.adventurerIds[i],
          _requests.recipes[i][j].recipeId
        );

        randomBase = _dispenseRewards(
          _action,
          randomBase,
          craftId,
          _requests.adventurerAddresses[i],
          _requests.adventurerIds[i],
          _requests.recipes[i][j].recipeId,
          _requests.recipes[i][j].recipeAmount
        );

        craftId++;
      }
    }
    return randomBase;
  }

  function _totals(
    uint _action,
    uint[] memory totalCrafts,
    uint[] memory craftingCostAdjustments,
    uint32[] memory animaMultipliers
  ) internal returns (uint256 totalAnima, uint256 craftsCount) {
    uint animaCosts = 0;
    for (uint i = 0; i < supportedLabIds.length; i++) {
      LabCraftingConfig storage config = labConfig[supportedLabIds[i]];
      if (!config.enabled) {
        revert InvalidLabId(supportedLabIds[i]);
      }
      animaCosts =
        (config.baseAnimaCost * (craftingCostAdjustments[i]) * uint(animaMultipliers[i])) /
        ONE_HUNDRED;

      emit CraftingCosts(
        _action,
        supportedLabIds[i],
        animaMultipliers[i],
        animaCosts,
        totalCrafts[i],
        craftingCostAdjustments[i]
      );

      totalAnima += animaCosts;
      craftsCount += totalCrafts[i];
    }
  }

  function _verifyMaterials(
    CraftingRequests calldata _requests,
    uint[] memory _levels
  ) internal view returns (uint[] memory, uint[] memory) {
    VerificationMemory memory mem;
    mem.craftAmounts = new uint[](supportedLabIds.length);
    mem.craftCostAdjustments = new uint[](supportedLabIds.length);
    mem.totalTokenAmounts = _createEmptyMaterialAmountsTotalsArray(_requests);
    mem.levels = _levels;
    // adventurer index
    for (uint ai = 0; ai < _requests.adventurerIds.length; ai++) {
      // recipe index
      for (uint ri = 0; ri < _requests.recipes[ai].length; ri++) {
        mem.craftingAttempt = _requests.recipes[ai][ri];
        mem.recipe = recipes[mem.craftingAttempt.recipeId];

        // Increment total crafted amounts
        _verifyLabRequirementsAndIncrementCounts(
          mem.recipe.labId,
          mem.craftingAttempt.recipeAmount,
          _requests.adventurerAddresses[ai],
          mem.levels[ai],
          mem.craftAmounts,
          mem.craftCostAdjustments
        );

        // recipe requirement id
        for (uint rri = 0; rri < mem.recipe.requirements.length; rri++) {
          if (!mem.recipe.requirements[rri].enabled) {
            break;
          }
          mem.materialMapping = mem.craftingAttempt.materialMappings[rri];
          _verifyMaterialsAreCorrectTypeAndAmount(
            mem.craftingAttempt.recipeId,
            ai,
            mem.recipe.requirements[rri],
            _requests.materialAddresses,
            _requests.materialIds,
            mem.materialMapping.materialAddressIndexes,
            mem.materialMapping.materialIndexes,
            mem.materialMapping.materialAmounts,
            mem.craftingAttempt.recipeAmount,
            mem.totalTokenAmounts
          );
        }
      }
    }

    _verifyTotals(_requests.materialAmounts, mem.totalTokenAmounts);
    return (mem.craftAmounts, mem.craftCostAdjustments);
  }

  function _verifyLabRequirementsAndIncrementCounts(
    uint labId,
    uint amount,
    address adventurerAddress,
    uint adventurerLevel,
    uint[] memory craftCounts,
    uint[] memory craftCostAdjustments
  ) internal view {
    if (!labConfig[labId].enabled) {
      revert InvalidLabId(labId);
    }

    if (labConfig[labId].minimumLevel > adventurerLevel) {
      revert AdventurerLevelTooLow(labConfig[labId].minimumLevel, adventurerLevel);
    }

    craftCounts[labConfig[labId].labIndex] += amount;
    // Crafting costs are baseCost * (1 + adventurerLevel). Aov costs are 5x higher (relative to anima gains).
    craftCostAdjustments[labConfig[labId].labIndex] +=
      amount *
      (adventurerLevel) *
      (adventurerAddress == AOV ? 5 : 1);
  }

  struct RequirementVerificationMemory {
    uint submittedMaterialsAmount;
    address materialAddress;
    uint materialId;
  }

  function _verifyMaterialsAreCorrectTypeAndAmount(
    uint _recipeId,
    uint _adventurerIndex,
    RecipeRequirement memory _requirement,
    address[] calldata _materialAddresses,
    uint256[][][] calldata _materialIds,
    uint[] memory _materialAddressIndexes,
    uint[] memory _materialIdIndexes,
    uint[] memory _materialAmounts,
    uint _recipeAmount,
    uint[][][] memory _totalAmounts
  ) internal view {
    RequirementVerificationMemory memory mem;
    for (uint i = 0; i < _materialIdIndexes.length; i++) {
      mem.materialAddress = _materialAddresses[_materialAddressIndexes[i]];
      mem.materialId = _materialIds[_materialAddressIndexes[i]][_adventurerIndex][
        _materialIdIndexes[i]
      ];
      if (_requirement.requirementType == RecipeRequirementType.EXACT_TOKEN) {
        if (
          _requirement.requirementAddress != mem.materialAddress ||
          _requirement.requirementArgument != mem.materialId
        ) {
          revert InvalidMaterial(_recipeId, mem.materialAddress, mem.materialId);
        }
      } else if (_requirement.requirementType == RecipeRequirementType.MATERIAL_GROUP) {
        if (
          _requirement.requirementArgument !=
          materialGroupConfig[mem.materialAddress][mem.materialId]
        ) {
          revert InvalidMaterial(_recipeId, mem.materialAddress, mem.materialId);
        }
      } else {
        revert InvalidRequirementConfig(_recipeId);
      }
      mem.submittedMaterialsAmount += _materialAmounts[i];
      _totalAmounts[_materialAddressIndexes[i]][_adventurerIndex][
        _materialIdIndexes[i]
      ] += _materialAmounts[i];
    }

    if (_requirement.tokenAmount * _recipeAmount != mem.submittedMaterialsAmount) {
      revert InsufficientMaterials(_recipeId);
    }
  }

  function _dispenseRewards(
    uint _action,
    uint _randomBase,
    uint _craftId,
    address _adventurerAddress,
    uint _adventurerId,
    uint recipeId,
    uint recipeAmount
  ) internal returns (uint) {
    if (!recipes[recipeId].enabled) {
      revert InvalidRecipe(recipeId);
    }

    Recipe storage recipe = recipes[recipeId];
    DispensedRewards memory dispensed = recipe.rewardsPool.dispenseRewards(
      recipe.subPoolId,
      _randomBase,
      msg.sender,
      _adventurerAddress,
      _adventurerId,
      recipeAmount
    );

    DispensedReward memory reward;
    for (uint r = 0; r < dispensed.rewards.length; r++) {
      reward = dispensed.rewards[r];
      emit CraftedItem(
        _action,
        _craftId,
        _adventurerAddress,
        _adventurerId,
        reward.armoryTokenType,
        reward.rewardAddress,
        reward.rewardTokenId,
        reward.rewardAmount
      );
    }

    return dispensed.nextRandomBase;
  }

  function _createEmptyMaterialAmountsTotalsArray(
    CraftingRequests calldata _requests
  ) internal pure returns (uint[][][] memory result) {
    result = new uint[][][](_requests.materialAddresses.length);
    for (uint i = 0; i < _requests.materialAddresses.length; i++) {
      result[i] = new uint[][](_requests.adventurerIds.length);
      for (uint j = 0; j < _requests.adventurerIds.length; j++) {
        result[i][j] = new uint[](_requests.materialAmounts[i][j].length);
      }
    }
  }

  function _verifyTotals(
    uint256[][][] calldata requestedAmounts,
    uint256[][][] memory usedInCrafting
  ) internal pure {
    for (uint i = 0; i < usedInCrafting.length; i++) {
      for (uint j = 0; j < usedInCrafting[i].length; j++) {
        for (uint k = 0; k < usedInCrafting[i][j].length; k++) {
          if (requestedAmounts[i][j][k] != usedInCrafting[i][j][k]) {
            revert InvalidMaterialTotal(
              i,
              j,
              k,
              requestedAmounts[i][j][k],
              usedInCrafting[i][j][k]
            );
          }
        }
      }
    }
  }

  function verifyCraftsAvailable(uint[] memory requiredAmounts) internal {
    uint[] memory craftsAvailable = _maximumCraftAmounts(_getDynamicConfig());
    for (uint i = 0; i < supportedLabIds.length; i++) {
      if (craftsAvailable[i] < requiredAmounts[i]) {
        revert InsufficientLabs(supportedLabIds[i]);
      }
    }
  }

  function _maximumCraftAmounts(
    DynamicCraftingConfigCache storage config
  ) internal view returns (uint[] memory result) {
    uint[] memory availableLabs = RANDOM_PICKER.getQueueSizes(
      uint256(uint160(LAB_ADDRESS)),
      supportedLabIds
    );
    result = new uint[](availableLabs.length);
    for (uint i = 0; i < supportedLabIds.length; i++) {
      uint durabilityLoss = config.durabilityLossPercentage[i];
      if (durabilityLoss < 1) {
        durabilityLoss = 1;
      }
      if (durabilityLoss > ONE_HUNDRED) {
        durabilityLoss = ONE_HUNDRED;
      }
      result[i] = (ONE_HUNDRED * availableLabs[i]) / durabilityLoss;
    }
  }

  function _getDynamicConfig() internal returns (DynamicCraftingConfigCache storage) {
    uint256 currentEpoch = Epoch.packTimestampToEpoch(block.timestamp, cacheEpochConfig);
    DynamicCraftingConfigCache storage cache = _dynamicConfigCache;

    // Only load the config once for the day, then return the cached one
    if (currentEpoch == cache.epoch) {
      return cache;
    }

    DynamicLabCraftingConfig[] memory newConfigs = CRAFTING_CONFIG_PROVIDER.getConfigBatch(
      supportedLabIds
    );

    // In case new labs appeared, should be usually skipped
    if (cache.durabilityLossPercentage.length != newConfigs.length) {
      cache.durabilityLossPercentage = new uint32[](newConfigs.length);
      cache.productivityPerCraft = new uint32[](newConfigs.length);
      cache.voidCraftingCostPercentage = new uint32[](newConfigs.length);
      cache.realmCraftingCostPercentage = new uint32[](newConfigs.length);
    }

    // Repack configs for preferred usage format
    for (uint i = 0; i < newConfigs.length; i++) {
      cache.durabilityLossPercentage[i] = uint32(newConfigs[i].durabilityLossPercentage);
      cache.productivityPerCraft[i] = uint32(newConfigs[i].productivityPerCraft);
      cache.voidCraftingCostPercentage[i] = uint32(newConfigs[i].voidCraftingCostPercentage);
      cache.realmCraftingCostPercentage[i] = uint32(newConfigs[i].realmCraftingCostPercentage);
    }

    // Save the epoch
    cache.epoch = currentEpoch;
    return cache;
  }

  function _calculateCraftingCost(
    uint baseCost,
    uint labCount,
    CraftingCostCurveConfig storage curveCostConfig
  ) internal view returns (uint result) {
    return
      ((((baseCost * curveCostConfig.labSoftCap) / (curveCostConfig.labSoftCap + labCount - 1)) *
        curveCostConfig.range) + curveCostConfig.min) / ONE_HUNDRED;
  }

  //=======================================
  // Admin
  //=======================================

  function pause() external onlyAdmin {
    _pause();
  }

  function unpause() external onlyAdmin {
    _unpause();
  }

  // Set minimum gas required
  function updateMinimumGas(uint256 _minimumGas) external onlyAdmin {
    minimumGasPerCraft = _minimumGas;
  }

  // Set minimum gas required
  function updateConfigProvider(address _configProvider) external onlyAdmin {
    CRAFTING_CONFIG_PROVIDER = ICraftingDynamicConfigProvider(_configProvider);
  }

  function configureStructures(
    uint256[] calldata _tokenIds,
    uint64[] calldata _minimumLevels,
    uint256[] calldata _animaCosts,
    uint256[] calldata _animaCapacity
  ) external onlyAdmin {
    require(_tokenIds.length == _minimumLevels.length);

    for (uint i = 0; i < supportedLabIds.length; i++) {
      labConfig[supportedLabIds[i]].enabled = false;
    }

    supportedLabIds = _tokenIds;
    for (uint256 i = 0; i < _tokenIds.length; i++) {
      labConfig[_tokenIds[i]] = LabCraftingConfig(
        true,
        _minimumLevels[i],
        _animaCosts[i],
        _animaCapacity[i],
        i
      );
    }
  }

  function clearCache(bool _forceLoad) external onlyAdmin {
    _dynamicConfigCache.epoch = 0;
    if (_forceLoad) {
      _getDynamicConfig();
    }
  }

  function configureMaterialGroup(
    address _materialAddress,
    uint[] calldata _materialTokenIds,
    uint[] calldata _materialGroup
  ) external onlyAdmin {
    for (uint i = 0; i < _materialTokenIds.length; i++) {
      materialGroupConfig[_materialAddress][_materialTokenIds[i]] = _materialGroup[i];
    }
  }

  function updateRecipes(
    uint[] calldata _recipeIndexes,
    Recipe[] calldata _recipes,
    bool replaceAll
  ) external onlyAdmin {
    if (replaceAll) {
      for (uint i = 0; i < availableRecipes.length; i++) {
        recipes[availableRecipes[i]].enabled = false;
      }
      availableRecipes = _recipeIndexes;
    } else {
      for (uint i = 0; i < _recipeIndexes.length; i++) {
        if (!recipes[_recipeIndexes[i]].enabled) {
          availableRecipes.push();
          availableRecipes[availableRecipes.length - 1] = _recipeIndexes[i];
        }
      }
    }
    for (uint i = 0; i < _recipeIndexes.length; i++) {
      recipes[_recipeIndexes[i]] = _recipes[i];
    }
  }

  function updatePermit(address _permit) external onlyAdmin {
    ACTION_PERMIT = IActionPermit(_permit);
  }

  function updateGateway(address _gateway) external onlyAdmin {
    GATEWAY = IBatchAdventurerGateway(_gateway);
  }
}

File 41 of 63 : ICrafting.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

struct MaterialRequirementMapping {
  uint256[] materialAddressIndexes;
  uint256[] materialIndexes;
  uint256[] materialAmounts;
}

struct RecipeMaterialMapping {
  uint256 recipeId;
  uint256 recipeAmount;
  // (recipe requirement => material mapping)
  MaterialRequirementMapping[] materialMappings;
}

struct CraftingRequests {
  // Adventurers
  address[] adventurerAddresses;
  uint256[] adventurerIds;
  // Material totals
  address[] materialAddresses;
  // material address -> adventurer index -> material ids
  uint256[][][] materialIds;
  // material address -> adventurer index -> material amounts
  uint256[][][] materialAmounts;
  bytes32[][] proofs;
  // Crafting requests
  // List per adventurer
  RecipeMaterialMapping[][] recipes;
  // Gas efficiency and kinda checksum
  uint totalCrafts;
}

struct StakeRequest {
  // Adventurers
  address[] adventurerAddresses;
  uint256[] adventurerIds;
  bytes32[][] proofs;
  // Materials to stake into Armory
  address[] matsToStakeAddresses;
  // material address -> adventurer index -> material ids
  uint256[][][] matsToStakeIds;
  // material address -> adventurer index -> material amounts
  uint256[][][] matsToStakeAmounts;
}

interface ICrafting {
  function craft(
    CraftingRequests calldata _realmRequests,
    CraftingRequests calldata _voidRequests,
    StakeRequest calldata _stakeRequest
  ) external;
}

File 42 of 63 : ICraftingDynamicConfigProvider.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.17;

import "../Manager/ManagerModifier.sol";
import "../Lab/LabSupplyAverageStorage.sol";
import "../Action/Actions.sol";
import "../Utils/Epoch.sol";

struct DynamicLabCraftingConfig {
  uint256 realmCraftingCostPercentage;
  uint256 voidCraftingCostPercentage;
  uint256 durabilityLossPercentage;
  uint256 productivityPerCraft;
}

interface ICraftingDynamicConfigProvider {
  function getConfigBatch(
    uint256[] calldata labIds
  ) external returns (DynamicLabCraftingConfig[] memory result);
}

File 43 of 63 : IOwnerSpecificRewardsPool.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.17;

//=======================================
// Structs
//=======================================
struct DispensedRewards {
  uint256 nextRandomBase;
  DispensedReward[] rewards;
}

struct DispensedReward {
  uint armoryTokenType;
  address rewardAddress;
  uint256 rewardTokenId;
  uint256 rewardAmount;
}

//=======================================================================================================================================================
// Dispenser contract for rewards. Each RewardPool is divided into subpools (in case of lootboxes: for different rarities, or realm specific pools, etc).
//=======================================================================================================================================================
interface IOwnerSpecificRewardsPool {
  //==============================================================================================================================
  // Dispenses random rewards from the pool
  //==============================================================================================================================
  function dispenseRewards(
    uint64 subPoolId,
    uint256 randomNumberBase,
    address receiver,
    address ownerAddress,
    uint ownerId,
    uint amount
  ) external returns (DispensedRewards memory);
}

File 44 of 63 : ILab.sol
// SPDX-License-Identifier: Unlicensed

pragma solidity ^0.8.17;

import "../BatchStaker/IBatchBurnableStructure.sol";

interface ILab is IBatchBurnableStructure {
  function totalSupply(uint _tokenId) external view returns (uint256);

  function mintFor(address _for, uint256 _id, uint256 _amount) external;

  function mintBatchFor(
    address _for,
    uint256[] calldata _ids,
    uint256[] calldata _amounts
  ) external;

  function mintBatchFor(
    address[] calldata _for,
    uint256[][] memory _ids,
    uint256[][] memory _amounts
  ) external;

  function burn(uint256 _id, uint256 _amount) external;

  function burnBatch(uint256[] calldata ids, uint256[] calldata amounts) external;

  function burnBatch(uint256[][] memory ids, uint256[][] memory amounts) external;

  function burnBatchFor(
    address _for,
    uint256[] calldata _ids,
    uint256[] calldata _amounts
  ) external;

  function burnFor(address _for, uint256 _id, uint256 _amount) external;

  function safeBatchTransferFrom(
    address from,
    address to,
    uint256[][] memory ids,
    uint256[][] memory amounts,
    bytes memory data
  ) external;
}

File 45 of 63 : LabSupplyAverageStorage.sol
// SPDX-License-Identifier: Unlicensed

pragma solidity ^0.8.17;

import "../Manager/ManagerModifier.sol";
import "../SupplyDemand/AbstractEpochAverageStorage.sol";
import "../Utils/Epoch.sol";
import "./ILab.sol";

contract LabSupplyAverageStorage is ManagerModifier, AbstractEpochAverageStorage {
  using Epoch for uint256;

  uint constant LAB_GROUP = 0;

  uint128 public EPOCH_CONFIG;
  EpochAverageStorageConfig public AVERAGE_STORAGE_CONFIG;
  ILab public immutable LAB;

  constructor(address _manager, address _lab) ManagerModifier(_manager) {
    LAB = ILab(_lab);
    EPOCH_CONFIG = Epoch.toConfig(1 days, 0 hours);

    AVERAGE_STORAGE_CONFIG = EpochAverageStorageConfig(4, 1, 5); // EMA5
  }

  function getSupplyBatch(uint256[] calldata _labIds) external returns (uint256[] memory) {
    return _getValueBatch(LAB_GROUP, _labIds);
  }

  function _getConfig(
    uint256 _group,
    uint256 _subGroup
  ) internal view override returns (EpochAverageStorageConfig memory) {
    return AVERAGE_STORAGE_CONFIG;
  }

  function _getCurrentValue(
    uint256 _group,
    uint256 _subGroup
  ) internal view override returns (uint256) {
    return LAB.totalSupply(_subGroup);
  }

  function _getPredictedNextValue(
    uint256 _group,
    uint256 _subGroup
  ) internal view override returns (uint256) {
    return LAB.totalSupply(_subGroup);
  }

  function _getCurrentEpoch(
    uint256 _group,
    uint256 _subGroup
  ) internal view override returns (uint256) {
    return Epoch.toEpochNumber(block.timestamp, EPOCH_CONFIG);
  }

  function forceUpdateBaseValue(uint _tokenId, uint newValue) external onlyAdmin {
    _forceUpdateBaseValue(LAB_GROUP, _tokenId, newValue);
  }

  function updateConfig(uint _baseWeight, uint _epochWeight) external onlyAdmin {
    AVERAGE_STORAGE_CONFIG.baseWeight = _baseWeight;
    AVERAGE_STORAGE_CONFIG.epochWeight = _epochWeight;
    AVERAGE_STORAGE_CONFIG.totalWeight = _baseWeight + _epochWeight;
  }
}

File 46 of 63 : FloatingPointConstants.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

uint256 constant DECIMAL_POINT = 10 ** 3;
int256 constant SIGNED_DECIMAL_POINT = int256(DECIMAL_POINT);

uint256 constant ONE_HUNDRED = 100 * DECIMAL_POINT;
uint256 constant ONE_HUNDRED_SQUARE = ONE_HUNDRED * ONE_HUNDRED;
int256 constant SIGNED_ONE_HUNDRED = 100 * SIGNED_DECIMAL_POINT;
int256 constant SIGNED_ONE_HUNDRED_SQUARE = SIGNED_ONE_HUNDRED * SIGNED_ONE_HUNDRED;

int256 constant SIGNED_ZERO = 0;

File 47 of 63 : IManager.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

interface IManager {
  function isAdmin(address _addr) external view returns (bool);

  function isManager(address _addr, uint256 _type) external view returns (bool);

  function addManager(address _addr, uint256 _type) external;

  function removeManager(address _addr, uint256 _type) external;

  function addAdmin(address _addr) external;

  function removeAdmin(address _addr) external;
}

File 48 of 63 : ManagerModifier.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import "../Manager/IManager.sol";

abstract contract ManagerModifier {
  //=======================================
  // Immutables
  //=======================================
  IManager public immutable MANAGER;

  //=======================================
  // Constructor
  //=======================================
  constructor(address _manager) {
    MANAGER = IManager(_manager);
  }

  //=======================================
  // Modifiers
  //=======================================
  modifier onlyAdmin() {
    require(MANAGER.isAdmin(msg.sender), "Manager: Not an Admin");
    _;
  }

  modifier onlyManager() {
    require(MANAGER.isManager(msg.sender, 0), "Manager: Not manager");
    _;
  }

  modifier onlyMinter() {
    require(MANAGER.isManager(msg.sender, 1), "Manager: Not minter");
    _;
  }

  modifier onlyTokenMinter() {
    require(MANAGER.isManager(msg.sender, 2), "Manager: Not token minter");
    _;
  }

  modifier onlyBinder() {
    require(MANAGER.isManager(msg.sender, 3), "Manager: Not binder");
    _;
  }
}

File 49 of 63 : IParticle.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

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

interface IParticle is IERC20 {
  function mintFor(address _for, uint256 _amount) external;
}

File 50 of 63 : Particle.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

import "../Bound/IERC20Bound.sol";
import "./IParticle.sol";

import "../Manager/ManagerModifier.sol";

contract Particle is
  IParticle,
  ERC20,
  ERC20Burnable,
  ManagerModifier,
  ReentrancyGuard,
  Pausable
{
  //=======================================
  // Immutables
  //=======================================
  IERC20Bound public immutable BOUND;
  uint256 public immutable CAP;

  //=======================================
  // Constructor
  //=======================================
  constructor(
    address _manager,
    address _bound,
    uint256 _cap
  ) ERC20("Particle", "PARTICLE") ManagerModifier(_manager) {
    BOUND = IERC20Bound(_bound);
    CAP = _cap;
  }

  //=======================================
  // External
  //=======================================
  function mintFor(
    address _for,
    uint256 _amount
  ) external override onlyTokenMinter {
    // Check amount doesn't exceed cap
    require(ERC20.totalSupply() + _amount <= CAP, "Particle: Cap exceeded");

    // Mint
    _mint(_for, _amount);
  }

  //=======================================
  // Admin
  //=======================================
  function pause() external onlyAdmin {
    _pause();
  }

  function unpause() external onlyAdmin {
    _unpause();
  }

  //=======================================
  // Internal
  //=======================================
  function _beforeTokenTransfer(
    address from,
    address to,
    uint256 amount
  ) internal override {
    // Call super
    super._beforeTokenTransfer(from, to, amount);

    // Check if sender is manager
    if (!MANAGER.isManager(msg.sender, 0)) {
      // Check if minting or burning
      if (from != address(0) && to != address(0)) {
        // Check if token is unbound
        require(BOUND.isUnbound(address(this)), "Particle: Token not unbound");
      }
    }

    // Check if contract is paused
    require(!paused(), "Particle: Paused");
  }
}

File 51 of 63 : IProductivity.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.17;

interface IProductivity {
  // All time Productivity
  function currentProductivity(uint256 _realmId) external view returns (uint);

  function currentProductivityBatch(
    uint[] calldata _realmIds
  ) external view returns (uint[] memory result);

  function previousEpochsProductivityTotals(
    uint _realmId,
    uint _numberOfEpochs,
    bool _includeCurrentEpoch
  ) external view returns (uint gains, uint losses);

  function epochsProductivityTotals(
    uint _realmId,
    uint _startEpoch,
    uint _endEpoch
  ) external view returns (uint gains, uint losses);

  function previousEpochsProductivityTotalsBatch(
    uint[] calldata _realmIds,
    uint _numberOfEpochs,
    bool _includeCurrentEpoch
  ) external view returns (uint[] memory gains, uint[] memory spending);

  function epochsProductivityTotalsBatch(
    uint[] calldata _realmIds,
    uint _startEpoch,
    uint _endEpoch
  ) external view returns (uint[] memory gains, uint[] memory spending);

  function change(uint256 _realmId, int _delta, bool _includeInTotals) external;

  function changeBatch(
    uint256[] calldata _tokenIds,
    int[] calldata _deltas,
    bool _includeInTotals
  ) external;

  function changeBatch(uint256[] calldata _tokenIds, int _delta, bool _includeInTotals) external;

  function increase(uint256 _realmId, uint _delta, bool _includeInTotals) external;

  function increaseBatch(
    uint256[] calldata _tokenIds,
    uint[] calldata _delta,
    bool _includeInTotals
  ) external;

  function increaseBatch(uint256[] calldata _tokenIds, uint _delta, bool _includeInTotals) external;

  function decrease(uint256 _realmId, uint _delta, bool _includeInTotals) external;

  function decreaseBatch(
    uint256[] calldata _tokenIds,
    uint[] calldata _delta,
    bool _includeInTotals
  ) external;

  function decreaseBatch(uint256[] calldata _tokenIds, uint _delta, bool _includeInTotals) external;
}

File 52 of 63 : IRandomPicker.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.17;

interface IRandomPicker {
  function addToQueue(uint256 queueType, uint256 subQueue, uint256 owner, uint256 number) external;

  function addToQueueBatch(
    uint256 queueType,
    uint256 subQueue,
    uint256[] calldata owner,
    uint256[] calldata number
  ) external;

  function addToQueueBatch(
    uint256 queueType,
    uint256[] calldata subQueue,
    uint256 owner,
    uint256[] calldata number
  ) external;

  function addToQueueBatch(
    uint256 queueType,
    uint256[] calldata subQueue,
    uint256[][] calldata owner,
    uint256[][] calldata number
  ) external;

  function addToQueueBatch(
    uint256 queueType,
    uint256[][] calldata subQueue,
    uint256[] calldata owner,
    uint256[][] calldata number
  ) external;

  function removeFromQueue(
    uint256 queueType,
    uint256 subQueue,
    uint256 owner,
    uint256 number
  ) external;

  function removeFromQueueBatch(
    uint256 queueType,
    uint256 subQueue,
    uint256[] calldata owner,
    uint256[] calldata number
  ) external;

  function removeFromQueueBatch(
    uint256 queueType,
    uint256[] calldata subQueue,
    uint256 owner,
    uint256[] calldata number
  ) external;

  function removeFromQueueBatch(
    uint256 queueType,
    uint256[] calldata subQueue,
    uint256[][] calldata owner,
    uint256[][] calldata number
  ) external;

  function removeFromQueueBatch(
    uint256 queueType,
    uint256[][] calldata subQueue,
    uint256[] calldata owner,
    uint256[][] calldata number
  ) external;

  function useRandomizer(
    uint256 queueType,
    uint256 subQueue,
    uint256 number,
    uint256 randomBase
  ) external view returns (uint[] memory result, uint newRandomBase);

  function useRandomizerBatch(
    uint256 queueType,
    uint256[] calldata subQueue,
    uint256[] calldata number,
    uint256 randomBase
  ) external view returns (uint[][] memory result, uint newRandomBase);

  function getQueueSizes(
    uint256 queueType,
    uint256[] calldata subQueues
  ) external view returns (uint256[] memory result);
}

File 53 of 63 : RandomPicker.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.17;

import "../Manager/ManagerModifier.sol";
import "../Utils/Random.sol";
import "./IRandomPicker.sol";

contract RandomPicker is ManagerModifier, IRandomPicker {
  constructor(address _manager) ManagerModifier(_manager) {}

  mapping(uint256 => mapping(uint256 => uint32)) public queueLengths;
  mapping(uint256 => mapping(uint256 => uint16[])) public queues;

  mapping(uint256 => mapping(uint256 => mapping(uint16 => uint32[]))) public queuePositionsByOwner;
  mapping(uint256 => mapping(uint256 => mapping(uint16 => uint32))) public ownerTicketsLengths;

  function addToQueue(
    uint256 queueType,
    uint256 subQueue,
    uint256 owner,
    uint256 number
  ) external onlyManager {
    _addToQueue(queueType, subQueue, owner, number);
  }

  function addToQueueBatch(
    uint256 queueType,
    uint256 subQueue,
    uint256[] calldata owners,
    uint256[] calldata numbers
  ) external onlyManager {
    for (uint i = 0; i < owners.length; i++) {
      _addToQueue(queueType, subQueue, owners[i], numbers[i]);
    }
  }

  function addToQueueBatch(
    uint256 queueType,
    uint256[] calldata subQueues,
    uint256 owner,
    uint256[] calldata numbers
  ) external onlyManager {
    for (uint i = 0; i < subQueues.length; i++) {
      _addToQueue(queueType, subQueues[i], owner, numbers[i]);
    }
  }

  function addToQueueBatch(
    uint256 queueType,
    uint256[][] calldata subQueues,
    uint256[] calldata owners,
    uint256[][] calldata numbers
  ) external onlyManager {
    for (uint i = 0; i < owners.length; i++) {
      for (uint j = 0; j < subQueues[i].length; j++) {
        _addToQueue(queueType, subQueues[i][j], owners[i], numbers[i][j]);
      }
    }
  }

  function addToQueueBatch(
    uint256 queueType,
    uint256[] calldata subQueues,
    uint256[][] calldata owners,
    uint256[][] calldata numbers
  ) external onlyManager {
    for (uint i = 0; i < subQueues.length; i++) {
      for (uint j = 0; j < owners[i].length; j++) {
        _addToQueue(queueType, subQueues[i], owners[i][j], numbers[i][j]);
      }
    }
  }

  function removeFromQueue(
    uint256 queueType,
    uint256 subQueue,
    uint256 owner,
    uint256 number
  ) external onlyManager {
    uint32 queueLength = queueLengths[queueType][subQueue];
    require(queueLength >= number);
    uint16[] storage queue = queues[queueType][subQueue];
    uint32[] storage oTickets = queuePositionsByOwner[queueType][subQueue][uint16(owner)];
    mapping(uint16 => uint32) storage ownerTicketsLength = ownerTicketsLengths[queueType][subQueue];
    uint32 oTicketsLength = ownerTicketsLength[uint16(owner)];

    require(oTicketsLength >= number);

    uint32 indexToRemove;
    for (uint i = 0; i < number; i++) {
      indexToRemove = oTickets[oTicketsLength - i - 1];
      queue[indexToRemove] = queue[queueLength - i - 1];
    }

    ownerTicketsLength[uint16(owner)] -= uint32(number);
    queueLengths[queueType][subQueue] -= uint32(number);
  }

  function removeFromQueueBatch(
    uint256 queueType,
    uint256 subQueue,
    uint256[] calldata owner,
    uint256[] calldata number
  ) external onlyManager {
    for (uint i = 0; i < owner.length; i++) {
      _removeFromQueue(queueType, subQueue, owner[i], number[i]);
    }
  }

  function removeFromQueueBatch(
    uint256 queueType,
    uint256[] calldata subQueues,
    uint256 owner,
    uint256[] calldata numbers
  ) external onlyManager {
    for (uint i = 0; i < subQueues.length; i++) {
      _removeFromQueue(queueType, subQueues[i], owner, numbers[i]);
    }
  }

  function removeFromQueueBatch(
    uint256 queueType,
    uint256[][] calldata subQueues,
    uint256[] calldata owners,
    uint256[][] calldata numbers
  ) external onlyManager {
    for (uint i = 0; i < owners.length; i++) {
      for (uint j = 0; j < subQueues[i].length; j++) {
        _removeFromQueue(queueType, subQueues[i][j], owners[i], numbers[i][j]);
      }
    }
  }

  function removeFromQueueBatch(
    uint256 queueType,
    uint256[] calldata subQueues,
    uint256[][] calldata owners,
    uint256[][] calldata numbers
  ) external onlyManager {
    for (uint i = 0; i < subQueues.length; i++) {
      for (uint j = 0; j < owners[i].length; j++) {
        _removeFromQueue(queueType, subQueues[i], owners[i][j], numbers[i][j]);
      }
    }
  }

  function useRandomizer(
    uint256 queueType,
    uint256 subQueue,
    uint256 number,
    uint256 randomBase
  ) external view returns (uint[] memory result, uint newRandomBase) {
    (result, newRandomBase) = _findRandom(queueType, subQueue, number, randomBase);
  }

  function useRandomizerBatch(
    uint256 queueType,
    uint256[] calldata subQueue,
    uint256[] calldata number,
    uint256 randomBase
  ) external view returns (uint[][] memory result, uint newRandomBase) {
    require(subQueue.length == number.length);

    result = new uint[][](subQueue.length);
    newRandomBase = randomBase;
    for (uint i = 0; i < subQueue.length; i++) {
      (result[i], newRandomBase) = _findRandom(queueType, subQueue[i], number[i], newRandomBase);
    }
  }

  function getQueueSizes(
    uint256 queueType,
    uint256[] calldata subQueues
  ) external view returns (uint256[] memory result) {
    result = new uint256[](subQueues.length);
    for (uint i = 0; i < subQueues.length; i++) {
      result[i] = uint256(queueLengths[queueType][subQueues[i]]);
    }
  }

  function _addToQueue(
    uint256 queueType,
    uint256 subQueue,
    uint256 owner,
    uint256 number
  ) internal {
    uint32 queueLength = queueLengths[queueType][subQueue];
    uint16[] storage queue = queues[queueType][subQueue];
    uint32[] storage oTickets = queuePositionsByOwner[queueType][subQueue][uint16(owner)];
    mapping(uint16 => uint32) storage ownerTicketsLength = ownerTicketsLengths[queueType][subQueue];
    uint32 oTicketsLength = ownerTicketsLength[uint16(owner)];

    if (oTickets.length < oTicketsLength + number) {
      // Expand tickets owned by the user array, this should be rare after the initial stake
      uint newLength = oTicketsLength + number;
      assembly {
        let arrayPointer := sload(oTickets.slot)
        sstore(oTickets.slot, newLength)
      }
    }

    if (queue.length < queueLength + number) {
      uint newLength = queueLength + number;
      // Expand the queue array if needed
      assembly {
        sstore(queue.slot, newLength)
      }
    }

    for (uint i = 0; i < number; i++) {
      queue[queueLength + i] = uint16(owner);
      oTickets[oTicketsLength + i] = uint32(queueLength + i);
    }

    queueLengths[queueType][subQueue] += uint16(number);
    ownerTicketsLength[uint16(owner)] += uint16(number);
  }

  function _removeFromQueue(
    uint256 queueType,
    uint256 subQueue,
    uint256 owner,
    uint256 number
  ) internal {
    uint32 queueLength = queueLengths[queueType][subQueue];
    require(queueLength >= number);
    uint16[] storage queue = queues[queueType][subQueue];
    uint32[] storage oTickets = queuePositionsByOwner[queueType][subQueue][uint16(owner)];
    mapping(uint16 => uint32) storage ownerTicketsLength = ownerTicketsLengths[queueType][subQueue];
    uint32 oTicketsLength = ownerTicketsLength[uint16(owner)];

    require(oTicketsLength >= number);

    uint32 indexToRemove;
    for (uint i = 0; i < number; i++) {
      indexToRemove = oTickets[oTicketsLength - i - 1];
      queue[indexToRemove] = queue[queueLength - i - 1];
    }

    ownerTicketsLength[uint16(owner)] -= uint32(number);
    queueLengths[queueType][subQueue] -= uint32(number);
  }

  function _findRandom(
    uint256 queueType,
    uint256 subQueue,
    uint256 number,
    uint256 randomBase
  ) internal view returns (uint[] memory result, uint256 nextRandomBase) {
    uint32 queueLength = queueLengths[queueType][subQueue];
    uint16[] storage queue = queues[queueType][subQueue];

    require(queueLength > 0 || number == 0);

    uint randomNumber;
    result = new uint[](number);
    for (uint i = 0; i < number; i++) {
      (randomNumber, randomBase) = Random.getNextRandom(randomBase, queueLength);
      result[i] = queue[randomNumber % queueLength];
    }
    nextRandomBase = randomBase;
  }
}

File 54 of 63 : Realm.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

interface IConnector {
  function ownerOf(uint256 tokenId) external view returns (address owner);
}

contract Realm is ERC721Enumerable, ReentrancyGuard, Ownable {
  bytes internal constant TABLE =
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

  uint256 private constant REALM_SIZE = 10 ** 6 * 3;
  uint256 private constant DEFAULT_WEALTH = 1000;
  uint256 private constant ACTION_HOURS = 12 hours;

  uint256 public price = 10000000000000000;
  uint256 public partnerPrice = 5000000000000000;
  uint256 public supply = 10000;

  uint256[35] private PROBABILITY = [
    2,
    3,
    5,
    7,
    11,
    13,
    17,
    19,
    23,
    25,
    29,
    31,
    37,
    39,
    41,
    43,
    47,
    51,
    53,
    57,
    59,
    61,
    65,
    67,
    71,
    75,
    77,
    79,
    83,
    85,
    89,
    92,
    94,
    96,
    100
  ];

  string[35] public features = [
    "Pond", // 0
    "Valley", // 1
    "Gulf", // 2
    "Basin", // 3
    "Butte", // 4
    "Canal", // 5
    "Cape", // 6
    "Prairie", // 7
    "Plateau", // 8
    "Mesa", // 9
    "Peninsula", // 10
    "River", // 11
    "Sea", // 12
    "Cove", // 13
    "Lake", // 14
    "Swamp", // 15
    "Tundra", // 16
    "Bay", // 17
    "Ice shelf", // 18
    "Dune", // 19
    "Fjord", // 20
    "Geyser", // 21
    "Glacier", // 22
    "Ocean", // 23
    "Desert", // 24
    "Biosphere", // 25
    "Lagoon", // 26
    "Mountain", // 27
    "Island", // 28
    "Canyon", // 29
    "Cave", // 30
    "Oasis", // 31
    "Waterfall", // 32
    "Reef", // 33
    "Volcano" // 34
  ];

  struct realm {
    string name;
    uint256 size;
    uint256 createdAt;
    bool partner;
  }

  struct Connector {
    address _contract;
    uint256 start;
    uint256 end;
    bool exists;
  }

  mapping(uint256 => realm) public realms;
  mapping(uint256 => uint256) public wealth;
  mapping(uint256 => uint256) public explorer;
  mapping(uint256 => uint256) public explorerTime;
  mapping(uint256 => uint256) public terraformTime;
  mapping(address => Connector) public connectors;
  mapping(uint256 => mapping(uint256 => uint256)) public realmFeatures;

  event RealmCreated(
    string name,
    uint256 size,
    bool partner,
    string feature1,
    string feature2,
    string feature3
  );
  event Explored(
    uint256 realmId,
    uint256 explored,
    uint256 wealthGained,
    uint256 totalExplored,
    uint256 totalWealth
  );
  event Terraform(
    uint256 realmId,
    string feature1,
    string feature2,
    string feature3
  );
  event ConnectorCreated(address _contract, uint256 start, uint256 end);
  event ConnectorRemoved(address _contract);
  event WealthSpent(uint256 realmId, uint256 WealthSpent, uint256 totalWealth);

  constructor() ERC721("Realm", "REALM") Ownable() {}

  function explore(uint256 _realmId) external {
    require(_isApprovedOrOwner(msg.sender, _realmId));
    require(
      block.timestamp > explorerTime[_realmId],
      "You are currently exploring"
    );
    require(
      explorer[_realmId] < realms[_realmId].size,
      "You've explored the whole map"
    );

    uint256 _wealthGained = _random(wealth[_realmId], DEFAULT_WEALTH) +
      DEFAULT_WEALTH;

    explorer[_realmId] += _wealthGained;
    wealth[_realmId] += _wealthGained;

    // You can explore every 12 hours
    explorerTime[_realmId] = block.timestamp + ACTION_HOURS;

    emit Explored(
      _realmId,
      _wealthGained,
      _wealthGained,
      explorer[_realmId],
      wealth[_realmId]
    );
  }

  function spendWealth(uint256 _realmId, uint256 _wealth) external {
    require(_wealth <= wealth[_realmId], "Not enough wealth");
    require(_isApprovedOrOwner(msg.sender, _realmId));

    wealth[_realmId] -= _wealth;

    emit WealthSpent(_realmId, _wealth, wealth[_realmId]);
  }

  function terraform(uint256 _realmId, uint256 _feature) external {
    require(_isApprovedOrOwner(msg.sender, _realmId));
    require(_feature <= 2, "Feature must be 0 to 2");
    require(block.timestamp > terraformTime[_realmId], "Allowed once a year");

    uint256 _newFeatureId = _random(realms[_realmId].size, features.length);

    // Update feature
    realmFeatures[_realmId][_feature] = _newFeatureId;

    // Allowed once a year
    terraformTime[_realmId] = block.timestamp + 365 days;

    emit Terraform(
      _realmId,
      features[realmFeatures[_realmId][0]],
      features[realmFeatures[_realmId][1]],
      features[realmFeatures[_realmId][2]]
    );
  }

  function claim(
    uint256 _realmId,
    string memory _name
  ) external payable nonReentrant {
    require(msg.value >= price, "Eth sent is not enough");
    require(_realmId > 5 && _realmId <= supply, "_realmId invalid");
    require(!_exists(_realmId), "_realmId invalid");

    _createRealm(_realmId, _name, false);
    _safeMint(_msgSender(), _realmId);
  }

  function claimAsPartner(
    address _contract,
    uint256 _partnerId,
    uint256 _realmId,
    string memory _name
  ) external payable nonReentrant {
    require(connectors[_contract].exists, "Contract not allowed");
    require(msg.value >= partnerPrice, "Eth sent is not enough");
    require(
      _realmId > connectors[_contract].start &&
        _realmId < connectors[_contract].end,
      "_realmId not in range"
    );
    require(!_exists(_realmId), "_realmId doesn't exist");

    IConnector connector = IConnector(_contract);

    require(
      connector.ownerOf(_partnerId) == msg.sender,
      "You do not own the _partnerId"
    );

    _createRealm(_realmId, _name, true);
    _safeMint(_msgSender(), _realmId);
  }

  function ownerClaim(
    uint256 _realmId,
    string memory _name
  ) external nonReentrant onlyOwner {
    require(_realmId <= 5, "_realmId invalid");
    require(!_exists(_realmId), "_realmId invalid");

    _createRealm(_realmId, _name, false);
    _safeMint(owner(), _realmId);
  }

  function setPrice(uint256 _newPrice, uint256 _type) external onlyOwner {
    if (_type == 0) {
      price = _newPrice;
    } else {
      partnerPrice = _newPrice;
    }
  }

  function setSupply(uint256 _supply) external onlyOwner {
    supply = _supply;
  }

  function setConnector(
    address _contract,
    uint256 _start,
    uint256 _end
  ) external onlyOwner {
    connectors[_contract]._contract = _contract;
    connectors[_contract].start = _start;
    connectors[_contract].end = _end;
    connectors[_contract].exists = true;

    emit ConnectorCreated(_contract, _start, _end);
  }

  function removeConnector(address _contract) external onlyOwner {
    delete connectors[_contract];

    emit ConnectorRemoved(_contract);
  }

  function getRealm(
    uint256 _realmId
  ) external view returns (string memory, uint256, uint256, bool) {
    return (
      realms[_realmId].name,
      realms[_realmId].size,
      realms[_realmId].createdAt,
      realms[_realmId].partner
    );
  }

  function hasConnector(address _contract) external view returns (bool) {
    return connectors[_contract].exists;
  }

  function ownerWithdraw() external onlyOwner {
    payable(owner()).transfer(address(this).balance);
  }

  function tokenURI(
    uint256 _realmId
  ) public view override returns (string memory) {
    string[5] memory _parts;

    _parts[
      0
    ] = '<?xml version="1.0" encoding="UTF-8"?><svg width="350px" height="350px" viewBox="0 0 350 350" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><rect fill="#ffb300" x="0" y="0" width="350" height="350"></rect><text x="50%" y="40%" dominant-baseline="middle" text-anchor="middle" fill-opacity="50%" font-size="65px" fill="#fff" font-family="Georgia">Realm</text><text x="50%" y="62%" fill-opacity="100%" fill="#fff" dominant-baseline="middle" text-anchor="middle" font-size="24px" font-family="Georgia">';
    _parts[1] = realms[_realmId].name;
    _parts[
      2
    ] = '</text><text x="50%" y="69%" fill-opacity="100%" fill="#fff" dominant-baseline="middle" text-anchor="middle" font-size="12px" font-family="Georgia">';
    _parts[3] = _featureNames(_realmId);
    _parts[
      4
    ] = '</text><line class="line" stroke-width="5" x1="125" x2="137" y1="185" y2="185"></line> <line class="line" stroke-width="5" x1="147" x2="148" y1="185" y2="185"></line> <line class="line" stroke-width="5" x1="158" x2="170" y1="185" y2="185"></line> <line class="line" stroke-width="5" x1="180" x2="181" y1="185" y2="185"></line> <line class="line" stroke-width="5" x1="191" x2="192" y1="185" y2="185"></line> <line class="line" stroke-width="5" x1="202" x2="214" y1="185" y2="185"></line> <line class="line" stroke-width="5" x1="224" x2="225" y1="185" y2="185"></line><style type="text/css">.line{stroke:white;stroke-linecap:round;opacity:50%}</style></svg>';

    string memory _output = string(
      abi.encodePacked(_parts[0], _parts[1], _parts[2], _parts[3], _parts[4])
    );

    string memory _atrrOutput = _makeAttributeParts(_realmId);
    string memory _json = _encode(
      bytes(
        string(
          abi.encodePacked(
            '{"name": "Realm #',
            _toString(_realmId),
            '", "description": "Discover your Realm. Explore. Mine. Research. Build.", "image": "data:image/svg+xml;base64,',
            _encode(bytes(_output)),
            '"',
            ',"attributes":',
            _atrrOutput,
            "}"
          )
        )
      )
    );
    _output = string(abi.encodePacked("data:application/json;base64,", _json));

    return _output;
  }

  function _createRealm(
    uint256 _realmId,
    string memory _name,
    bool _partner
  ) internal {
    realms[_realmId].name = _name;
    realms[_realmId].size = _randomFromString(_name, REALM_SIZE) + REALM_SIZE;
    realms[_realmId].createdAt = block.timestamp;
    realms[_realmId].partner = _partner;

    realmFeatures[_realmId][0] = _randomFromString(
      realms[_realmId].name,
      features.length
    );
    realmFeatures[_realmId][1] = _random(
      realms[_realmId].size,
      features.length
    );
    realmFeatures[_realmId][2] = _random(
      realms[_realmId].createdAt,
      features.length
    );

    emit RealmCreated(
      realms[_realmId].name,
      realms[_realmId].size,
      _partner,
      features[realmFeatures[_realmId][0]],
      features[realmFeatures[_realmId][1]],
      features[realmFeatures[_realmId][2]]
    );
  }

  function _random(
    uint256 _salt,
    uint256 _limit
  ) internal view returns (uint256) {
    return
      uint256(
        keccak256(abi.encodePacked(block.number, block.timestamp, _salt))
      ) % _limit;
  }

  function _randomFromString(
    string memory _salt,
    uint256 _limit
  ) internal view returns (uint256) {
    return
      uint256(
        keccak256(abi.encodePacked(block.number, block.timestamp, _salt))
      ) % _limit;
  }

  function _rarity(
    uint256 _salt,
    uint256 _limit
  ) internal view returns (uint256) {
    uint256 _rand = _randomFromString(string(abi.encodePacked(_salt)), _limit);

    uint256 j = 0;
    for (; j < PROBABILITY.length; j++) {
      if (_rand <= PROBABILITY[j]) {
        break;
      }
    }
    return j;
  }

  function _makeAttributeParts(
    uint256 _realmId
  ) internal view returns (string memory) {
    string[9] memory _parts;

    _parts[0] = '[{ "trait_type": "Realm", "value": "';
    _parts[1] = realms[_realmId].name;
    _parts[2] = '" }, { "trait_type": "Geographical Feature 1", "value": "';
    _parts[3] = features[realmFeatures[_realmId][0]];
    _parts[4] = '" }, { "trait_type": "Geographical Feature 2", "value": "';
    _parts[5] = features[realmFeatures[_realmId][1]];
    _parts[6] = '" }, { "trait_type": "Geographical Feature 3", "value": "';
    _parts[7] = features[realmFeatures[_realmId][2]];
    _parts[8] = '" }]';

    string memory _output = string(
      abi.encodePacked(_parts[0], _parts[1], _parts[2], _parts[3], _parts[4])
    );
    _output = string(
      abi.encodePacked(_output, _parts[5], _parts[6], _parts[7], _parts[8])
    );

    return _output;
  }

  function _featureNames(
    uint256 _realmId
  ) internal view returns (string memory) {
    return
      string(
        abi.encodePacked(
          features[realmFeatures[_realmId][0]],
          " | ",
          features[realmFeatures[_realmId][1]],
          " | ",
          features[realmFeatures[_realmId][2]]
        )
      );
  }

  function _toString(uint256 value) internal pure returns (string memory) {
    // Inspired by OraclizeAPI's implementation - MIT license
    // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

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

  function _encode(bytes memory data) internal pure returns (string memory) {
    uint256 len = data.length;
    if (len == 0) return "";

    // multiply by 4/3 rounded up
    uint256 encodedLen = 4 * ((len + 2) / 3);

    // Add some extra buffer at the end
    bytes memory result = new bytes(encodedLen + 32);

    bytes memory table = TABLE;

    assembly {
      let tablePtr := add(table, 1)
      let resultPtr := add(result, 32)

      for {
        let i := 0
      } lt(i, len) {

      } {
        i := add(i, 3)
        let input := and(mload(add(data, i)), 0xffffff)

        let out := mload(add(tablePtr, and(shr(18, input), 0x3F)))
        out := shl(8, out)
        out := add(
          out,
          and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)
        )
        out := shl(8, out)
        out := add(
          out,
          and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)
        )
        out := shl(8, out)
        out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF))
        out := shl(224, out)

        mstore(resultPtr, out)

        resultPtr := add(resultPtr, 4)
      }

      switch mod(len, 3)
      case 1 {
        mstore(sub(resultPtr, 2), shl(240, 0x3d3d))
      }
      case 2 {
        mstore(sub(resultPtr, 1), shl(248, 0x3d))
      }

      mstore(result, encodedLen)
    }

    return string(result);
  }

  // TEST CODE
  function setFeatures(
    uint256 _realmId,
    uint256[] calldata _features
  ) external {
    realmFeatures[_realmId][0] = _features[0];
    realmFeatures[_realmId][1] = _features[1];
    realmFeatures[_realmId][2] = _features[2];
  }
}

File 55 of 63 : IFocus.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.17;

import "../Utils/IEpochConfigurable.sol";

interface IFocus is IEpochConfigurable {
  error InsufficientFocus(
    address adventurerAddress,
    uint adventurerId,
    int64 spentFocus,
    int64 currentFocus
  );

  function currentFocus(address _adventurerAddress, uint _adventurerId) external view returns (int);

  function currentFocusBatch(
    address[] calldata _adventurerAddresses,
    uint[] calldata _adventurerIds
  ) external view returns (int[] memory result);

  function currentCounterBatch(
    address[] calldata _adventurerAddresses,
    uint[] calldata _adventurerIds
  ) external view returns (int[] memory result);

  function isFocusedThisEpoch(
    address[] calldata _adventurerAddresses,
    uint[] calldata _adventurerIds
  ) external view returns (bool[] memory result);

  function setCounterBatch(
    address[] calldata _adventurerAddresses,
    uint[] calldata _adventurerIds,
    int[] calldata _newValues
  ) external;

  function setCounterBatchSingleValue(
    address[] calldata _adventurerAddresses,
    uint[] calldata _adventurerIds,
    int64 _newValue
  ) external;

  function addToCounterBatch(
    address[] calldata _adventurerAddresses,
    uint[] calldata _adventurerIds,
    int[] calldata _addValues
  ) external;

  function addToCounterBatchSingleValue(
    address[] calldata _adventurerAddresses,
    uint[] calldata _adventurerIds,
    int64 _addValue
  ) external;

  function markFocusedBatch(
    address[] calldata _adventurerAddresses,
    uint[] calldata _adventurerIds
  ) external;

  function spendFocusBatch(
    address[] calldata _adventurerAddresses,
    uint[] calldata _adventurerIds,
    int[] calldata _spendings
  ) external;
}

File 56 of 63 : IResource.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

interface IResource {
  function data(
    uint256 _realmId,
    uint256 _resourceId
  ) external view returns (uint256);

  function add(uint256 _realmId, uint256 _resourceId, uint256 _amount) external;

  function remove(
    uint256 _realmId,
    uint256 _resourceId,
    uint256 _amount
  ) external;
}

File 57 of 63 : ResourceConstants.sol
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.17;

library resources {
  // Season 1 resources
  uint256 public constant MINERAL_DEPOSIT = 0;
  uint256 public constant LAND_ABUNDANCE = 1;
  uint256 public constant AQUATIC_RESOURCES = 2;
  uint256 public constant ANCIENT_ARTIFACTS = 3;

  // Staking capacities
  uint256 public constant ANIMA_CAPACITY = 100;

  uint256 public constant PARTICLE_CAPACITY = 110;
}

File 58 of 63 : AbstractEpochAverageStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

import "../Manager/ManagerModifier.sol";
import "../lib/FloatingPointConstants.sol";

struct EpochAverageStorageConfig {
  uint256 baseWeight;
  uint256 epochWeight;
  uint256 totalWeight;
}

abstract contract AbstractEpochAverageStorage {
  mapping(uint256 => EpochAverageStorageConfig) public config;
  mapping(uint256 => mapping(uint256 => uint256)) public baseValueEpoch;
  mapping(uint256 => mapping(uint256 => uint256)) public baseValue;

  function _getConfig(
    uint256 _group,
    uint256 _subGroup
  ) internal view virtual returns (EpochAverageStorageConfig memory);

  function _getCurrentValue(
    uint256 _group,
    uint256 _subGroup
  ) internal view virtual returns (uint256);

  function _getPredictedNextValue(
    uint256 _group,
    uint256 _subGroup
  ) internal view virtual returns (uint256);

  function _getCurrentEpoch(
    uint256 _group,
    uint256 _subGroup
  ) internal view virtual returns (uint256);

  function _predictNextValue(
    uint256 _group,
    uint256 _subGroup
  ) internal view returns (uint256 result) {
    EpochAverageStorageConfig memory cfg = _getConfig(_group, _subGroup);

    result = _getValueView(_group, _subGroup);
    uint256 predictedValue = _getPredictedNextValue(_group, _subGroup);
    result = (result * cfg.baseWeight + predictedValue * cfg.epochWeight) / cfg.totalWeight;
  }

  function _getValue(uint256 _group, uint256 _subGroup) internal returns (uint256 result) {
    uint currentEpoch = _getCurrentEpoch(_group, _subGroup);
    if (currentEpoch == baseValueEpoch[_group][_subGroup]) {
      return baseValue[_group][_subGroup];
    }

    result = _getValueView(_group, _subGroup);
    baseValue[_group][_subGroup] = result;
    baseValueEpoch[_group][_subGroup] = currentEpoch;
  }

  function _getValueView(uint256 _group, uint256 _subGroup) internal view returns (uint256 result) {
    result = baseValue[_group][_subGroup];
    uint256 currentEpoch = _getCurrentEpoch(_group, _subGroup);
    if (currentEpoch == baseValueEpoch[_group][_subGroup]) {
      return baseValue[_group][_subGroup];
    }

    EpochAverageStorageConfig memory cfg = _getConfig(_group, _subGroup);
    result =
      (result * cfg.baseWeight + _getCurrentValue(_group, _subGroup) * cfg.epochWeight) /
      cfg.totalWeight;
  }

  function _getValueBatch(
    uint256 _group,
    uint256[] calldata _subGroups
  ) internal returns (uint256[] memory results) {
    results = new uint256[](_subGroups.length);
    for (uint i = 0; i < _subGroups.length; i++) {
      results[i] = _getValue(_group, _subGroups[i]);
    }
  }

  function _getValueViewBatch(
    uint256 _group,
    uint256[] calldata _subGroups
  ) internal view returns (uint256[] memory results) {
    results = new uint256[](_subGroups.length);
    for (uint i = 0; i < _subGroups.length; i++) {
      results[i] = _getValueView(_group, _subGroups[i]);
    }
  }

  function _getPredictionBatch(
    uint256 _group,
    uint256[] calldata _subGroups
  ) internal view returns (uint256[] memory results) {
    results = new uint256[](_subGroups.length);
    for (uint i = 0; i < _subGroups.length; i++) {
      results[i] = _getPredictedNextValue(_group, _subGroups[i]);
    }
  }

  function _forceUpdateBaseValue(uint _group, uint _subgroup, uint _newValue) internal {
    baseValue[_group][_subgroup] = _newValue;
    baseValueEpoch[_group][_subgroup] = _getCurrentEpoch(_group, _subgroup);
  }
}

File 59 of 63 : ArrayUtils.sol
// SPDX-License-Identifier: Unlicensed

pragma solidity ^0.8.17;

library ArrayUtils {
  error ArrayLengthMismatch(uint _length1, uint _length2);
  error InvalidArrayOrder(uint index);

  function ensureSameLength(uint _l1, uint _l2) internal pure {
    if (_l1 != _l2) {
      revert ArrayLengthMismatch(_l1, _l2);
    }
  }

  function ensureSameLength(uint _l1, uint _l2, uint _l3) internal pure {
    ensureSameLength(_l1, _l2);
    ensureSameLength(_l1, _l3);
  }

  function ensureSameLength(uint _l1, uint _l2, uint _l3, uint _l4) internal pure {
    ensureSameLength(_l1, _l2);
    ensureSameLength(_l1, _l3);
    ensureSameLength(_l1, _l4);
  }

  function ensureSameLength(uint _l1, uint _l2, uint _l3, uint _l4, uint _l5) internal pure {
    ensureSameLength(_l1, _l2);
    ensureSameLength(_l1, _l3);
    ensureSameLength(_l1, _l4);
    ensureSameLength(_l1, _l5);
  }

  function checkAddressesForDuplicates(address[] memory _tokenAddrs) internal pure {
    address lastAddress;
    for (uint i = 0; i < _tokenAddrs.length; i++) {
      if (lastAddress > _tokenAddrs[i]) {
        revert InvalidArrayOrder(i);
      }
      lastAddress = _tokenAddrs[i];
    }
  }

  function checkForDuplicates(uint[] memory _ids) internal pure {
    uint lastId;
    for (uint i = 0; i < _ids.length; i++) {
      if (lastId > _ids[i]) {
        revert InvalidArrayOrder(i);
      }
      lastId = _ids[i];
    }
  }

  function checkForDuplicates(address[] memory _tokenAddrs, uint[] memory _tokenIds) internal pure {
    address lastAddress;
    int256 lastTokenId = -1;
    for (uint i = 0; i < _tokenAddrs.length; i++) {
      if (_tokenAddrs[i] > lastAddress) {
        lastTokenId = -1;
      }

      if (_tokenAddrs[i] < lastAddress || int(_tokenIds[i]) <= lastTokenId) {
        revert InvalidArrayOrder(i);
      }
      lastAddress = _tokenAddrs[i];
      lastTokenId = int(_tokenIds[i]);
    }
  }

  function toMemoryArray(uint _value, uint _length) internal pure returns (uint[] memory result) {
    result = new uint[](_length);
    for (uint i = 0; i < _length; i++) {
      result[i] = _value;
    }
  }

  function toMemoryArray(uint[] calldata _value) internal pure returns (uint[] memory result) {
    result = new uint[](_value.length);
    for (uint i = 0; i < _value.length; i++) {
      result[i] = _value[i];
    }
  }

  function toMemoryArray(
    address _address,
    uint _length
  ) internal pure returns (address[] memory result) {
    result = new address[](_length);
    for (uint i = 0; i < _length; i++) {
      result[i] = _address;
    }
  }

  function toMemoryArray(
    address[] calldata _addresses
  ) internal pure returns (address[] memory result) {
    result = new address[](_addresses.length);
    for (uint i = 0; i < _addresses.length; i++) {
      result[i] = _addresses[i];
    }
  }
}

File 60 of 63 : Epoch.sol
pragma solidity ^0.8.17;

// SPDX-License-Identifier: Unlicensed

import "../lib/FloatingPointConstants.sol";

uint256 constant MASK_128 = ((1 << 128) - 1);
uint128 constant MASK_64 = ((1 << 64) - 1);

library Epoch {
  // Converts a given timestamp to an epoch using the specified duration and offset.
  // Example for battle timers resetting at noon UTC is: _duration = 1 days; _offset = 12 hours;
  function toEpochNumber(
    uint256 _timestamp,
    uint256 _duration,
    uint256 _offset
  ) internal pure returns (uint256) {
    return (_timestamp + _offset) / _duration;
  }

  // Here we assume that _config is a packed _duration (left 64 bits) and _offset (right 64 bits)
  function toEpochNumber(uint256 _timestamp, uint128 _config) internal pure returns (uint256) {
    return (_timestamp + (_config & MASK_64)) / ((_config >> 64) & MASK_64);
  }

  // Returns a value between 0 and ONE_HUNDRED which is the percentage of "completeness" of the epoch
  // result variable is reused for memory efficiency
  function toEpochCompleteness(
    uint256 _timestamp,
    uint128 _config
  ) internal pure returns (uint256 result) {
    result = (_config >> 64) & MASK_64;
    result = (ONE_HUNDRED * ((_timestamp + (_config & MASK_64)) % result)) / result;
  }

  // Converts a given epoch to a timestamp at the start of the epoch
  function epochToTimestamp(
    uint256 _epoch,
    uint128 _config
  ) internal pure returns (uint256 result) {
    result = _epoch * ((_config >> 64) & MASK_64);
    if (result > 0) {
      result -= (_config & MASK_64);
    }
  }

  // Create a config for the function above
  function toConfig(uint64 _duration, uint64 _offset) internal pure returns (uint128) {
    return (uint128(_duration) << 64) | uint128(_offset);
  }

  // Pack the epoch number with the config into a single uint256 for mappings
  function packEpoch(uint256 _epochNumber, uint128 _config) internal pure returns (uint256) {
    return (uint256(_config) << 128) | uint128(_epochNumber);
  }

  // Convert timestamp to Epoch and pack it with the config into a single uint256 for mappings
  function packTimestampToEpoch(
    uint256 _timestamp,
    uint128 _config
  ) internal pure returns (uint256) {
    return packEpoch(toEpochNumber(_timestamp, _config), _config);
  }

  // Unpack packedEpoch to epochNumber and config
  function unpack(
    uint256 _packedEpoch
  ) internal pure returns (uint256 epochNumber, uint128 config) {
    config = uint128(_packedEpoch >> 128);
    epochNumber = _packedEpoch & MASK_128;
  }
}

File 61 of 63 : IArbSys.sol
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity >=0.4.21 <0.9.0;

/**
 * @title System level functionality
 * @notice For use by contracts to interact with core L2-specific functionality.
 * Precompiled contract that exists in every Arbitrum chain at address(100), 0x0000000000000000000000000000000000000064.
 */
interface ArbSys {
  /**
   * @notice Get Arbitrum block number (distinct from L1 block number; Arbitrum genesis block has block number 0)
   * @return block number as int
   */
  function arbBlockNumber() external view returns (uint256);

  /**
   * @notice Get Arbitrum block hash (reverts unless currentBlockNum-256 <= arbBlockNum < currentBlockNum)
   * @return block hash
   */
  function arbBlockHash(uint256 arbBlockNum) external view returns (bytes32);

  /**
   * @notice Gets the rollup's unique chain identifier
   * @return Chain identifier as int
   */
  function arbChainID() external view returns (uint256);

  /**
   * @notice Get internal version number identifying an ArbOS build
   * @return version number as int
   */
  function arbOSVersion() external view returns (uint256);

  /**
   * @notice Returns 0 since Nitro has no concept of storage gas
   * @return uint 0
   */
  function getStorageGasAvailable() external view returns (uint256);

  /**
   * @notice (deprecated) check if current call is top level (meaning it was triggered by an EoA or a L1 contract)
   * @dev this call has been deprecated and may be removed in a future release
   * @return true if current execution frame is not a call by another L2 contract
   */
  function isTopLevelCall() external view returns (bool);

  /**
   * @notice map L1 sender contract address to its L2 alias
   * @param sender sender address
   * @param unused argument no longer used
   * @return aliased sender address
   */
  function mapL1SenderContractAddressToL2Alias(
    address sender,
    address unused
  ) external pure returns (address);

  /**
   * @notice check if the caller (of this caller of this) is an aliased L1 contract address
   * @return true iff the caller's address is an alias for an L1 contract address
   */
  function wasMyCallersAddressAliased() external view returns (bool);

  /**
   * @notice return the address of the caller (of this caller of this), without applying L1 contract address aliasing
   * @return address of the caller's caller, without applying L1 contract address aliasing
   */
  function myCallersAddressWithoutAliasing() external view returns (address);

  /**
   * @notice Send given amount of Eth to dest from sender.
   * This is a convenience function, which is equivalent to calling sendTxToL1 with empty data.
   * @param destination recipient address on L1
   * @return unique identifier for this L2-to-L1 transaction.
   */
  function withdrawEth(address destination) external payable returns (uint256);

  /**
   * @notice Send a transaction to L1
   * @dev it is not possible to execute on the L1 any L2-to-L1 transaction which contains data
   * to a contract address without any code (as enforced by the Bridge contract).
   * @param destination recipient address on L1
   * @param data (optional) calldata for L1 contract call
   * @return a unique identifier for this L2-to-L1 transaction.
   */
  function sendTxToL1(address destination, bytes calldata data) external payable returns (uint256);

  /**
   * @notice Get send Merkle tree .state
   * @return size number of sends in the history
   * @return root root hash of the send history
   * @return partials hashes of partial subtrees in the send history tree
   */
  function sendMerkleTreeState()
    external
    view
    returns (uint256 size, bytes32 root, bytes32[] memory partials);

  /**
   * @notice creates a send txn from L2 to L1
   * @param position = (level << 192) + leaf = (0 << 192) + leaf = leaf
   */
  event L2ToL1Tx(
    address caller,
    address indexed destination,
    uint256 indexed hash,
    uint256 indexed position,
    uint256 arbBlockNum,
    uint256 ethBlockNum,
    uint256 timestamp,
    uint256 callvalue,
    bytes data
  );

  /// @dev DEPRECATED in favour of the new L2ToL1Tx event above after the nitro upgrade
  event L2ToL1Transaction(
    address caller,
    address indexed destination,
    uint256 indexed uniqueId,
    uint256 indexed batchNumber,
    uint256 indexInBatch,
    uint256 arbBlockNum,
    uint256 ethBlockNum,
    uint256 timestamp,
    uint256 callvalue,
    bytes data
  );

  /**
   * @notice logs a merkle branch for proof synthesis
   * @param reserved an index meant only to align the 4th index with L2ToL1Transaction's 4th event
   * @param hash the merkle hash
   * @param position = (level << 192) + leaf
   */
  event SendMerkleUpdate(uint256 indexed reserved, bytes32 indexed hash, uint256 indexed position);

  error InvalidBlockNumber(uint256 requested, uint256 current);
}

File 62 of 63 : IEpochConfigurable.sol
pragma solidity ^0.8.17;

// SPDX-License-Identifier: MIT

interface IEpochConfigurable {
  function currentEpoch() external view returns (uint);

  function epochAtTimestamp(uint _timestamp) external view returns (uint);
}

File 63 of 63 : Random.sol
// SPDX-License-Identifier: Unlicensed

pragma solidity ^0.8.17;

import "./IArbSys.sol";

//=========================================================================================================================================
// We're trying to normalize all chances close to 100%, which is 100 000 with decimal point 10^3. Assuming this, we can get more "random"
// numbers by dividing the "random" number by this prime. To be honest most primes larger than 100% should work, but to be safe we'll
// use an order of magnitude higher (10^3) relative to the decimal point
// We're using uint256 (2^256 ~= 10^77), which means we're safe to derive 8 consecutive random numbers from each hash.
// If we, by any chance, run out of random numbers (hash being lower than the range) we can in turn
// use the remainder of the hash to regenerate a new random number.
// Example: assuming our hash function result would be 1132134687911000 (shorter number picked for explanation) and we're using
// % 100000 range for our drop chance. The first "random" number is 11000. We then divide 1000000011000 by the 100000037 prime,
// leaving us at 11321342. The second derived random number would be 11321342 % 100000 = 21342. 11321342/100000037 is in turn less than
// 100000037, so we'll instead regenerate a new hash using 11321342.
// Primes are used for additional safety, but we could just deal with the "range".
//=========================================================================================================================================
uint256 constant MIN_SAFE_NEXT_NUMBER_PRIME = 200033;
uint256 constant HIGH_RANGE_PRIME_OFFSET = 13;

library Random {
  function startRandomBase(uint256 _highSalt, uint256 _lowSalt) internal view returns (uint256) {
    return
      uint256(
        keccak256(
          abi.encodePacked(
            _getPreviousBlockhash(),
            block.timestamp,
            msg.sender,
            _lowSalt,
            _highSalt
          )
        )
      );
  }

  function getNextRandom(
    uint256 _randomBase,
    uint256 _range
  ) internal view returns (uint256, uint256) {
    uint256 nextNumberSeparator = MIN_SAFE_NEXT_NUMBER_PRIME > _range
      ? MIN_SAFE_NEXT_NUMBER_PRIME
      : (_range + HIGH_RANGE_PRIME_OFFSET);
    uint256 nextBaseNumber = _randomBase / nextNumberSeparator;
    if (nextBaseNumber > nextNumberSeparator) {
      return (_randomBase % _range, nextBaseNumber);
    }
    nextBaseNumber = uint256(
      keccak256(abi.encodePacked(_getPreviousBlockhash(), msg.sender, _randomBase, _range))
    );
    return (nextBaseNumber % _range, nextBaseNumber / nextNumberSeparator);
  }

  function _getPreviousBlockhash() internal view returns (bytes32) {
    // Arbitrum One, Nova, Goerli, Sepolia, Stylus or Rinkeby
    if (
      block.chainid == 42161 ||
      block.chainid == 42170 ||
      block.chainid == 421613 ||
      block.chainid == 421614 ||
      block.chainid == 23011913 ||
      block.chainid == 421611
    ) {
      return ArbSys(address(0x64)).arbBlockHash(ArbSys(address(0x64)).arbBlockNumber() - 1);
    } else {
      // WARNING: THIS IS HIGHLY INSECURE ON ETH MAINNET, it is currently used mostly for testing
      return blockhash(block.number - 1);
    }
  }
}

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

Contract ABI

[{"inputs":[{"components":[{"internalType":"address","name":"MANAGER","type":"address"},{"internalType":"address","name":"FOCUS","type":"address"},{"internalType":"address","name":"GATEWAY","type":"address"},{"internalType":"address","name":"ACTION_PERMIT","type":"address"},{"internalType":"address","name":"ACTION_ID_STORAGE","type":"address"},{"internalType":"address","name":"ACTION_DEMAND_STORAGE","type":"address"},{"internalType":"address","name":"ADVENTURER_DATA","type":"address"},{"internalType":"address","name":"RESOURCE","type":"address"},{"internalType":"address","name":"ADVENTURER_ARMORY","type":"address"},{"internalType":"address","name":"REALM_ARMORY","type":"address"},{"internalType":"address","name":"ANIMA","type":"address"},{"internalType":"address","name":"REALM_ADDRESS","type":"address"},{"internalType":"address","name":"LAB_ADDRESS","type":"address"},{"internalType":"address","name":"CRAFTING_CONFIG_PROVIDER","type":"address"},{"internalType":"address","name":"PRODUCTIVITY_STORAGE","type":"address"},{"internalType":"address","name":"RANDOM_PICKER","type":"address"},{"internalType":"address","name":"AOV","type":"address"}],"internalType":"struct CraftingContractCreationRequest","name":"_request","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint64","name":"minimumLevel","type":"uint64"},{"internalType":"uint256","name":"currentLevel","type":"uint256"}],"name":"AdventurerLevelTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"gasAmount","type":"uint256"},{"internalType":"uint256","name":"gasRequired","type":"uint256"}],"name":"GasTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"labId","type":"uint256"}],"name":"InsufficientLabs","type":"error"},{"inputs":[{"internalType":"uint256","name":"recipeId","type":"uint256"}],"name":"InsufficientMaterials","type":"error"},{"inputs":[{"internalType":"uint256","name":"labId","type":"uint256"}],"name":"InvalidLabId","type":"error"},{"inputs":[{"internalType":"uint256","name":"recipeId","type":"uint256"},{"internalType":"address","name":"materialAddress","type":"address"},{"internalType":"uint256","name":"materialId","type":"uint256"}],"name":"InvalidMaterial","type":"error"},{"inputs":[{"internalType":"uint256","name":"materialAddressIndex","type":"uint256"},{"internalType":"uint256","name":"adventurerIndex","type":"uint256"},{"internalType":"uint256","name":"materialIdIndex","type":"uint256"},{"internalType":"uint256","name":"expectedAmount","type":"uint256"},{"internalType":"uint256","name":"actualAmount","type":"uint256"}],"name":"InvalidMaterialTotal","type":"error"},{"inputs":[{"internalType":"uint256","name":"recipeId","type":"uint256"}],"name":"InvalidRecipe","type":"error"},{"inputs":[{"internalType":"uint256","name":"recipeId","type":"uint256"}],"name":"InvalidRecipeAmount","type":"error"},{"inputs":[{"internalType":"uint256","name":"recipeId","type":"uint256"}],"name":"InvalidRequirementConfig","type":"error"},{"inputs":[],"name":"InvalidTotalRequestsCount","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"actionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"craftId","type":"uint256"},{"indexed":false,"internalType":"address","name":"adventurerAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"adventurerId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"resultType","type":"uint256"},{"indexed":false,"internalType":"address","name":"resultAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"resultTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"resultAmount","type":"uint256"}],"name":"CraftedItem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"actionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"labId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"animaMultiplier","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"animaAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"craftedTotal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"craftingLevelsTotal","type":"uint256"}],"name":"CraftingCosts","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"actionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"craftId","type":"uint256"},{"indexed":false,"internalType":"address","name":"adventurerAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"adventurerId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"recipeId","type":"uint256"}],"name":"CraftingStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"ACTION_DEMAND_STORAGE","outputs":[{"internalType":"contract IActionDemandAverageStorage","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ACTION_ID_STORAGE","outputs":[{"internalType":"contract IGlobalActionIdStorage","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ACTION_PERMIT","outputs":[{"internalType":"contract IActionPermit","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ADVENTURER_ARMORY","outputs":[{"internalType":"contract IArmory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ADVENTURER_DATA","outputs":[{"internalType":"contract IBatchAdventurerData","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ANIMA","outputs":[{"internalType":"contract Anima","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"AOV","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CRAFTING_CONFIG_PROVIDER","outputs":[{"internalType":"contract ICraftingDynamicConfigProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FOCUS","outputs":[{"internalType":"contract IFocus","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GATEWAY","outputs":[{"internalType":"contract IBatchAdventurerGateway","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LAB_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER","outputs":[{"internalType":"contract IManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRODUCTIVITY_STORAGE","outputs":[{"internalType":"contract IProductivity","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RANDOM_PICKER","outputs":[{"internalType":"contract IRandomPicker","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REALM_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REALM_ARMORY","outputs":[{"internalType":"contract IDurabilityEnabledArmory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RESOURCE","outputs":[{"internalType":"contract IResource","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"availableRecipes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_forceLoad","type":"bool"}],"name":"clearCache","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_materialAddress","type":"address"},{"internalType":"uint256[]","name":"_materialTokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_materialGroup","type":"uint256[]"}],"name":"configureMaterialGroup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint64[]","name":"_minimumLevels","type":"uint64[]"},{"internalType":"uint256[]","name":"_animaCosts","type":"uint256[]"},{"internalType":"uint256[]","name":"_animaCapacity","type":"uint256[]"}],"name":"configureStructures","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address[]","name":"adventurerAddresses","type":"address[]"},{"internalType":"uint256[]","name":"adventurerIds","type":"uint256[]"},{"internalType":"address[]","name":"materialAddresses","type":"address[]"},{"internalType":"uint256[][][]","name":"materialIds","type":"uint256[][][]"},{"internalType":"uint256[][][]","name":"materialAmounts","type":"uint256[][][]"},{"internalType":"bytes32[][]","name":"proofs","type":"bytes32[][]"},{"components":[{"internalType":"uint256","name":"recipeId","type":"uint256"},{"internalType":"uint256","name":"recipeAmount","type":"uint256"},{"components":[{"internalType":"uint256[]","name":"materialAddressIndexes","type":"uint256[]"},{"internalType":"uint256[]","name":"materialIndexes","type":"uint256[]"},{"internalType":"uint256[]","name":"materialAmounts","type":"uint256[]"}],"internalType":"struct MaterialRequirementMapping[]","name":"materialMappings","type":"tuple[]"}],"internalType":"struct RecipeMaterialMapping[][]","name":"recipes","type":"tuple[][]"},{"internalType":"uint256","name":"totalCrafts","type":"uint256"}],"internalType":"struct CraftingRequests","name":"_realmRequests","type":"tuple"},{"components":[{"internalType":"address[]","name":"adventurerAddresses","type":"address[]"},{"internalType":"uint256[]","name":"adventurerIds","type":"uint256[]"},{"internalType":"address[]","name":"materialAddresses","type":"address[]"},{"internalType":"uint256[][][]","name":"materialIds","type":"uint256[][][]"},{"internalType":"uint256[][][]","name":"materialAmounts","type":"uint256[][][]"},{"internalType":"bytes32[][]","name":"proofs","type":"bytes32[][]"},{"components":[{"internalType":"uint256","name":"recipeId","type":"uint256"},{"internalType":"uint256","name":"recipeAmount","type":"uint256"},{"components":[{"internalType":"uint256[]","name":"materialAddressIndexes","type":"uint256[]"},{"internalType":"uint256[]","name":"materialIndexes","type":"uint256[]"},{"internalType":"uint256[]","name":"materialAmounts","type":"uint256[]"}],"internalType":"struct MaterialRequirementMapping[]","name":"materialMappings","type":"tuple[]"}],"internalType":"struct RecipeMaterialMapping[][]","name":"recipes","type":"tuple[][]"},{"internalType":"uint256","name":"totalCrafts","type":"uint256"}],"internalType":"struct CraftingRequests","name":"_voidRequests","type":"tuple"},{"components":[{"internalType":"address[]","name":"adventurerAddresses","type":"address[]"},{"internalType":"uint256[]","name":"adventurerIds","type":"uint256[]"},{"internalType":"bytes32[][]","name":"proofs","type":"bytes32[][]"},{"internalType":"address[]","name":"matsToStakeAddresses","type":"address[]"},{"internalType":"uint256[][][]","name":"matsToStakeIds","type":"uint256[][][]"},{"internalType":"uint256[][][]","name":"matsToStakeAmounts","type":"uint256[][][]"}],"internalType":"struct StakeRequest","name":"_stakeRequest","type":"tuple"}],"name":"craft","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"craftingCosts","outputs":[{"components":[{"internalType":"uint256","name":"realm","type":"uint256"},{"internalType":"uint256","name":"void","type":"uint256"}],"internalType":"struct CraftingCost[]","name":"result","type":"tuple[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"craftingCostsView","outputs":[{"components":[{"internalType":"uint256","name":"realm","type":"uint256"},{"internalType":"uint256","name":"void","type":"uint256"}],"internalType":"struct CraftingCost[]","name":"result","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dynamicConfigCache","outputs":[{"components":[{"internalType":"uint256","name":"epoch","type":"uint256"},{"internalType":"uint32[]","name":"realmCraftingCostPercentage","type":"uint32[]"},{"internalType":"uint32[]","name":"voidCraftingCostPercentage","type":"uint32[]"},{"internalType":"uint32[]","name":"durabilityLossPercentage","type":"uint32[]"},{"internalType":"uint32[]","name":"productivityPerCraft","type":"uint32[]"}],"internalType":"struct Crafting.DynamicCraftingConfigCache","name":"","type":"tuple"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getSupportedLabIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"labConfig","outputs":[{"internalType":"bool","name":"enabled","type":"bool"},{"internalType":"uint64","name":"minimumLevel","type":"uint64"},{"internalType":"uint256","name":"baseAnimaCost","type":"uint256"},{"internalType":"uint256","name":"animaCapacity","type":"uint256"},{"internalType":"uint256","name":"labIndex","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"materialGroupConfig","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumRealmCraftsAvailable","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maximumRealmCraftsAvailableView","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"recipes","outputs":[{"internalType":"bool","name":"enabled","type":"bool"},{"internalType":"contract IOwnerSpecificRewardsPool","name":"rewardsPool","type":"address"},{"internalType":"uint64","name":"subPoolId","type":"uint64"},{"internalType":"uint256","name":"labId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_configProvider","type":"address"}],"name":"updateConfigProvider","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gateway","type":"address"}],"name":"updateGateway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minimumGas","type":"uint256"}],"name":"updateMinimumGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_permit","type":"address"}],"name":"updatePermit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_recipeIndexes","type":"uint256[]"},{"components":[{"internalType":"bool","name":"enabled","type":"bool"},{"components":[{"internalType":"address","name":"requirementAddress","type":"address"},{"internalType":"enum RecipeRequirementType","name":"requirementType","type":"uint8"},{"internalType":"bool","name":"enabled","type":"bool"},{"internalType":"uint32","name":"tokenAmount","type":"uint32"},{"internalType":"uint256","name":"requirementArgument","type":"uint256"}],"internalType":"struct RecipeRequirement[4]","name":"requirements","type":"tuple[4]"},{"internalType":"contract IOwnerSpecificRewardsPool","name":"rewardsPool","type":"address"},{"internalType":"uint64","name":"subPoolId","type":"uint64"},{"internalType":"uint256","name":"labId","type":"uint256"}],"internalType":"struct Recipe[]","name":"_recipes","type":"tuple[]"},{"internalType":"bool","name":"replaceAll","type":"bool"}],"name":"updateRecipes","outputs":[],"stateMutability":"nonpayable","type":"function"}]

6102406040523480156200001257600080fd5b50604051620062b2380380620062b28339810160408190526200003591620001ac565b80516001600160a01b03908116608090815260016000819055805491840151831660c09081526060850151600280549186166001600160a01b03199283161790556020860151851660a0908152604087015186166101009081026001600160a81b03199096169590951790935591850151841660e09081526101808087015186166102009081526101608089015188166101e0908152610120808b01518a16909252948901518816875295880151871661014090815288015187166101a0908152928801518716909552908601516003805491871691909416179092556101c0808601518516909252840151831661022052920151169052600480546001600160801b0319166a0151800000000000000000179055620493e0600c5562000317565b60405161022081016001600160401b03811182821017156200018957634e487b7160e01b600052604160045260246000fd5b60405290565b80516001600160a01b0381168114620001a757600080fd5b919050565b60006102208284031215620001c057600080fd5b620001ca62000157565b620001d5836200018f565b8152620001e5602084016200018f565b6020820152620001f8604084016200018f565b60408201526200020b606084016200018f565b60608201526200021e608084016200018f565b60808201526200023160a084016200018f565b60a08201526200024460c084016200018f565b60c08201526200025760e084016200018f565b60e08201526101006200026c8185016200018f565b90820152610120620002808482016200018f565b90820152610140620002948482016200018f565b90820152610160620002a88482016200018f565b90820152610180620002bc8482016200018f565b908201526101a0620002d08482016200018f565b908201526101c0620002e48482016200018f565b908201526101e0620002f88482016200018f565b908201526102006200030c8482016200018f565b908201529392505050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e0516102005161022051615e3d620004756000396000818161052f01528181611f8301526127c701526000818161041401528181611fb2015281816127f60152612a2c01526000818161046601526128be0152600081816106c50152613b4b0152600081816104a0015261152c0152600081816105560152612ae10152600081816104f501526129e20152600081816106ec0152818161132c015261248b0152600081816102c80152612c17015260008181610713015261255801526000818161034b01526126ed01526000818161057d01526133ac015260006102ef01526000818161025c0152818161074a0152818161099901528181610ace01528181610de001528181610e89015281816110cd01528181611179015281816115b6015281816119ab0152611a770152615e3d6000f3fe608060405234801561001057600080fd5b506004361061023d5760003560e01c8063835d61021161013b578063bab675bc116100b8578063e7c17fcb1161007c578063e7c17fcb1461063f578063ed53122e14610647578063efb8f8d7146106c0578063f2f039ec146106e7578063fcac08921461070e57600080fd5b8063bab675bc146105eb578063bb9dd493146105f3578063c0346b2014610606578063da5b91c314610619578063def47d701461062c57600080fd5b80639eb2b106116100ff5780639eb2b1061461052a578063aed0f90014610551578063af00a2ef14610578578063b0e8ab7a1461059f578063b93e9fa3146105d857600080fd5b8063835d6102146104c25780638456cb59146104d557806394df7486146104dd57806398589568146104f05780639c11e98a1461051757600080fd5b80633cc00a39116101c95780635c975abb1161018d5780635c975abb146104365780636308cf941461044c578063677d43de1461046157806376d2dfc514610488578063816738531461049b57600080fd5b80633cc00a39146103465780633f4ba83a1461036d578063443c227c1461037557806344975d81146103fc578063525ae1cb1461040f57600080fd5b80632b3ed84e116102105780632b3ed84e146102c35780632d2ea544146102ea5780632e51cf3814610311578063338c537114610326578063347b40931461033e57600080fd5b806308ee3ea0146102425780631b2df85014610257578063236b379c1461029b57806326721dba146102b0575b600080fd5b610255610250366004614787565b610735565b005b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6102a3610804565b60405161029291906147a4565b6102556102be366004614787565b610984565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b610319610a4a565b604051610292919061482e565b60015461027e9061010090046001600160a01b031681565b610319610aa2565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b610255610ab9565b6103c4610383366004614841565b600e60205260009081526040902080546009820154600a9092015460ff909116916001600160a01b03811691600160a01b9091046001600160401b03169084565b6040805194151585526001600160a01b0390931660208501526001600160401b03909116918301919091526060820152608001610292565b60025461027e906001600160a01b031681565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b60015460ff166040519015158152602001610292565b610454610b67565b6040516102929190614890565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b610255610496366004614841565b610dcb565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b6102556104d036600461497a565b610e74565b6102556110b8565b6102556104eb366004614a2b565b611164565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b610255610525366004614a5b565b611220565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b6105ca6105ad366004614ae9565b600f60209081526000928352604080842090915290825290205481565b604051908152602001610292565b6102556105e6366004614b15565b6115a1565b6102a3611801565b6105ca610601366004614841565b611975565b610255610614366004614787565b611996565b610255610627366004614bd8565b611a62565b60035461027e906001600160a01b031681565b610319611b8f565b61068e610655366004614841565b600560205260009081526040902080546001820154600283015460039093015460ff8316936101009093046001600160401b0316929085565b6040805195151586526001600160401b039094166020860152928401919091526060830152608082015260a001610292565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b61027e7f000000000000000000000000000000000000000000000000000000000000000081565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa158015610799573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107bd9190614c5a565b6107e25760405162461bcd60e51b81526004016107d990614c77565b60405180910390fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6006546060906001600160401b0381111561082157610821614ca6565b60405190808252806020026020018201604052801561086657816020015b604080518082019091526000808252602082015281526020019060019003908161083f5790505b50905060005b815181101561098057600560006006838154811061088c5761088c614cbc565b90600052602060002001548152602001908152602001600020600101548282815181106108bb576108bb614cbc565b6020908102919091010151526108d46103e86064614ce8565b6108dc611b9b565b60020182815481106108f0576108f0614cbc565b90600052602060002090600891828204019190066004029054906101000a900463ffffffff1663ffffffff1683838151811061092e5761092e614cbc565b6020026020010151600001516109449190614ce8565b61094e9190614cff565b82828151811061096057610960614cbc565b60209081029190910181015101528061097881614d21565b91505061086c565b5090565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa1580156109e8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0c9190614c5a565b610a285760405162461bcd60e51b81526004016107d990614c77565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b60606006805480602002602001604051908101604052809291908181526020018280548015610a9857602002820191906000526020600020905b815481526020019060010190808311610a84575b5050505050905090565b6060610ab4610aaf611b9b565b611f7d565b905090565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa158015610b1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b419190614c5a565b610b5d5760405162461bcd60e51b81526004016107d990614c77565b610b65612175565b565b610b996040518060a0016040528060008152602001606081526020016060815260200160608152602001606081525090565b610ba1611b9b565b6040518060a00160405290816000820154815260200160018201805480602002602001604051908101604052809291908181526020018280548015610c3157602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff1681526020019060040190602082600301049283019260010382029150808411610bf45790505b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015610cb557602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff1681526020019060040190602082600301049283019260010382029150808411610c785790505b5050505050815260200160038201805480602002602001604051908101604052809291908181526020018280548015610d3957602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff1681526020019060040190602082600301049283019260010382029150808411610cfc5790505b5050505050815260200160048201805480602002602001604051908101604052809291908181526020018280548015610dbd57602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff1681526020019060040190602082600301049283019260010382029150808411610d805790505b505050505081525050905090565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa158015610e2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e539190614c5a565b610e6f5760405162461bcd60e51b81526004016107d990614c77565b600c55565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa158015610ed8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efc9190614c5a565b610f185760405162461bcd60e51b81526004016107d990614c77565b8015610f945760005b600d54811015610f81576000600e6000600d8481548110610f4457610f44614cbc565b60009182526020808320919091015483528201929092526040019020805460ff191691151591909117905580610f7981614d21565b915050610f21565b50610f8e600d8686614561565b50611040565b60005b8481101561103e57600e6000878784818110610fb557610fb5614cbc565b602090810292909201358352508101919091526040016000205460ff1661102c57600d80546001018155600052858582818110610ff457610ff4614cbc565b90506020020135600d6001600d8054905061100f9190614d3a565b8154811061101f5761101f614cbc565b6000918252602090912001555b8061103681614d21565b915050610f97565b505b60005b848110156110b05783838281811061105d5761105d614cbc565b90506103000201600e600088888581811061107a5761107a614cbc565b905060200201358152602001908152602001600020818161109b9190614e77565b508190506110a881614d21565b915050611043565b505050505050565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa15801561111c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111409190614c5a565b61115c5760405162461bcd60e51b81526004016107d990614c77565b610b656121c7565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa1580156111c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ec9190614c5a565b6112085760405162461bcd60e51b81526004016107d990614c77565b6000600755801561121d5761121b611b9b565b505b50565b611228612202565b61123061225b565b3332146112985760405162461bcd60e51b815260206004820152603060248201527f4372616674696e67206973206e6f7420616c6c6f776564207468726f7567682060448201526f185b9bdd1a195c8818dbdb9d1c9858dd60821b60648201526084016107d9565b600c546112ad60e08085013590860135614f32565b6112b79190614ce8565b5a1015611300575a600c546112d460e08086013590870135614f32565b6112de9190614ce8565b60405163fe336aa760e01b8152600481019290925260248201526044016107d9565b600061130c8280614f45565b905011156114c0576040805160e081019091523381526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063b963347890602081016113618580614f45565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020908101906113a790860186614f45565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020016113eb6040860186614f45565b6113f49161504d565b81526020016114066060860186614f45565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050509082525060200161144a6080860186614f45565b6114539161517d565b815260200161146560a0860186614f45565b61146e9161517d565b8152506040518263ffffffff1660e01b815260040161148d91906153a4565b600060405180830381600087803b1580156114a757600080fd5b505af11580156114bb573d6000803e3d6000fd5b505050505b60006114ca611b9b565b9050600060e0850135156114ef576114e285836122a1565b6114ec9082614f32565b90505b60e0840135156115105761150384836122d3565b61150d9082614f32565b90505b60405163079cc67960e41b8152336004820152602481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906379cc679090604401600060405180830381600087803b15801561157857600080fd5b505af115801561158c573d6000803e3d6000fd5b50505050505061159c6001600055565b505050565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa158015611605573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116299190614c5a565b6116455760405162461bcd60e51b81526004016107d990614c77565b86851461165157600080fd5b60005b6006548110156116b4576000600560006006848154811061167757611677614cbc565b60009182526020808320919091015483528201929092526040019020805460ff1916911515919091179055806116ac81614d21565b915050611654565b506116c160068989614561565b5060005b878110156117f6576040518060a001604052806001151581526020018888848181106116f3576116f3614cbc565b9050602002016020810190611708919061546d565b6001600160401b0316815260200186868481811061172857611728614cbc565b90506020020135815260200184848481811061174657611746614cbc565b90506020020135815260200182815250600560008b8b8581811061176c5761176c614cbc565b60209081029290920135835250818101929092526040908101600020835181549385015168ffffffffffffffffff1990941690151568ffffffffffffffff001916176101006001600160401b0390941693909302929092178255820151600182015560608201516002820155608090910151600390910155806117ee81614d21565b9150506116c5565b505050505050505050565b6006546060906001600160401b0381111561181e5761181e614ca6565b60405190808252806020026020018201604052801561186357816020015b604080518082019091526000808252602082015281526020019060019003908161183c5790505b50905060005b815181101561098057600560006006838154811061188957611889614cbc565b90600052602060002001548152602001908152602001600020600101548282815181106118b8576118b8614cbc565b6020908102919091010151526118d16103e86064614ce8565b60098054839081106118e5576118e5614cbc565b90600052602060002090600891828204019190066004029054906101000a900463ffffffff1663ffffffff1683838151811061192357611923614cbc565b6020026020010151600001516119399190614ce8565b6119439190614cff565b82828151811061195557611955614cbc565b60209081029190910181015101528061196d81614d21565b915050611869565b600d818154811061198557600080fd5b600091825260209091200154905081565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa1580156119fa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1e9190614c5a565b611a3a5760405162461bcd60e51b81526004016107d990614c77565b600180546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b604051630935e01b60e21b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906324d7806c90602401602060405180830381865afa158015611ac6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aea9190614c5a565b611b065760405162461bcd60e51b81526004016107d990614c77565b60005b838110156110b057828282818110611b2357611b23614cbc565b90506020020135600f6000886001600160a01b03166001600160a01b031681526020019081526020016000206000878785818110611b6357611b63614cbc565b905060200201358152602001908152602001600020819055508080611b8790614d21565b915050611b09565b6060610ab46007611f7d565b6004546000908190611bb79042906001600160801b03166122ef565b60078054919250908203611bcb5792915050565b6003546040516331a9d24560e01b81526000916001600160a01b0316906331a9d24590611bfd906006906004016154bf565b6000604051808303816000875af1158015611c1c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c4491908101906154d2565b8051600384015491925014611dbc5780516001600160401b03811115611c6c57611c6c614ca6565b604051908082528060200260200182016040528015611c95578160200160208202803683370190505b508051611cac9160038501916020909101906145a8565b5080516001600160401b03811115611cc657611cc6614ca6565b604051908082528060200260200182016040528015611cef578160200160208202803683370190505b508051611d069160048501916020909101906145a8565b5080516001600160401b03811115611d2057611d20614ca6565b604051908082528060200260200182016040528015611d49578160200160208202803683370190505b508051611d609160028501916020909101906145a8565b5080516001600160401b03811115611d7a57611d7a614ca6565b604051908082528060200260200182016040528015611da3578160200160208202803683370190505b508051611dba9160018501916020909101906145a8565b505b60005b8151811015611f7357818181518110611dda57611dda614cbc565b602002602001015160400151836003018281548110611dfb57611dfb614cbc565b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908363ffffffff160217905550818181518110611e4057611e40614cbc565b602002602001015160600151836004018281548110611e6157611e61614cbc565b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908363ffffffff160217905550818181518110611ea657611ea6614cbc565b602002602001015160200151836002018281548110611ec757611ec7614cbc565b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908363ffffffff160217905550818181518110611f0c57611f0c614cbc565b602002602001015160000151836001018281548110611f2d57611f2d614cbc565b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908363ffffffff1602179055508080611f6b90614d21565b915050611dbf565b5050908155919050565b606060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663c45deef87f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031660066040518363ffffffff1660e01b8152600401611ff992919061559b565b600060405180830381865afa158015612016573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261203e9190810190615617565b905080516001600160401b0381111561205957612059614ca6565b604051908082528060200260200182016040528015612082578160200160208202803683370190505b50915060005b60065481101561216e5760008460030182815481106120a9576120a9614cbc565b6000918252602090912060088204015460079091166004026101000a900463ffffffff16905060018110156120dc575060015b6120e96103e86064614ce8565b811115612100576120fd6103e86064614ce8565b90505b8083838151811061211357612113614cbc565b60200260200101516103e8606461212a9190614ce8565b6121349190614ce8565b61213e9190614cff565b84838151811061215057612150614cbc565b6020908102919091010152508061216681614d21565b915050612088565b5050919050565b61217d61232a565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6121cf61225b565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258336121aa565b6002600054036122545760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107d9565b6002600055565b60015460ff1615610b655760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016107d9565b6000806000806122b786866001016103ed612373565b9250925092506122c78282612765565b50909150505b92915050565b60006122e583836002016103ec612373565b5090949350505050565b60006123236122fe8484612d0c565b6001600160801b0316608084901b6fffffffffffffffffffffffffffffffff19161790565b9392505050565b60015460ff16610b655760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016107d9565b600154600090606090829061010090046001600160a01b031663e3b161f961239b8880614f45565b6123a860a08b018b614f45565b6040518563ffffffff1660e01b81526004016123c79493929190615753565b60006040518083038186803b1580156123df57600080fd5b505afa1580156123f3573d6000803e3d6000fd5b50506002546001600160a01b031691506348f3db699050336124158980614f45565b61242260208c018c614f45565b61242f60a08e018e614f45565b8c6040518963ffffffff1660e01b815260040161245398979695949392919061577a565b60006040518083038186803b15801561246b57600080fd5b505afa15801561247f573d6000803e3d6000fd5b50506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691506368bffafe90506124be8880614f45565b6124cb60208b018b614f45565b6124d860408d018d614f45565b6124e560608f018f614f45565b8f80608001906124f59190614f45565b6040518b63ffffffff1660e01b815260040161251a9a9998979695949392919061586e565b600060405180830381600087803b15801561253457600080fd5b505af1158015612548573d6000803e3d6000fd5b5060009250506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169050639c0ab7c06125898980614f45565b61259660208c018c614f45565b6000806040518763ffffffff1660e01b81526004016125ba969594939291906158e5565b6000604051808303816000875af11580156125d9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526126019190810190615617565b9050606061260f8883612d34565b809250819550505060006126a08786848b80548060200260200160405190810160405280929190818152602001828054801561269657602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff16815260200190600401906020826003010492830192600103820291508084116126595790505b5050505050613165565b909650905060e089013581146126c957604051631530045560e31b815260040160405180910390fd5b6126d3878a613380565b604051631c163f0160e31b81529094506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e0b1f80890612727908a906006908a90600401615922565b600060405180830381600087803b15801561274157600080fd5b505af1158015612755573d6000803e3d6000fd5b5050505050505093509350939050565b61276e826136c1565b600060068054806020026020016040519081016040528092919081815260200182805480156127bc57602002820191906000526020600020905b8154815260200190600101908083116127a8575b5050505050905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637eef1cfd7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168487876040518563ffffffff1660e01b81526004016128409493929190615957565b600060405180830381865afa15801561285d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526128859190810190615994565b50905060608060005b8451811015612d03578681815181106128a9576128a9614cbc565b602002602001015160000315612cf1576128fc7f00000000000000000000000000000000000000000000000000000000000000008883815181106128ef576128ef614cbc565b6020026020010151613763565b925083818151811061291057612910614cbc565b6020026020010151516001600160401b0381111561293057612930614ca6565b60405190808252806020026020018201604052801561296357816020015b606081526020019060019003908161294e5790505b50915060005b84828151811061297b5761297b614cbc565b6020026020010151518110156129df576129af8683815181106129a0576129a0614cbc565b602002602001015160016137f8565b8382815181106129c1576129c1614cbc565b602002602001018190525080806129d790614d21565b915050612969565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663cebb767284868481518110612a2257612a22614cbc565b60200260200101517f00000000000000000000000000000000000000000000000000000000000000008660076003018781548110612a6257612a62614cbc565b90600052602060002090600891828204019190066004029054906101000a900463ffffffff166001806040518863ffffffff1660e01b8152600401612aad9796959493929190615a94565b600060405180830381600087803b158015612ac757600080fd5b505af1158015612adb573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663197aa6aa858381518110612b2057612b20614cbc565b602002602001015160076004018481548110612b3e57612b3e614cbc565b90600052602060002090600891828204019190066004029054906101000a900463ffffffff1663ffffffff1660016040518463ffffffff1660e01b8152600401612b8a93929190615b44565b600060405180830381600087803b158015612ba457600080fd5b505af1158015612bb8573d6000803e3d6000fd5b50505050600060056000878481518110612bd457612bd4614cbc565b6020026020010151815260200190815260200160002060020154905060005b858381518110612c0557612c05614cbc565b602002602001015151811015612cee577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663505fb46c878581518110612c5657612c56614cbc565b60200260200101518381518110612c6f57612c6f614cbc565b60200260200101516064856040518463ffffffff1660e01b8152600401612ca9939291909283526020830191909152604082015260600190565b600060405180830381600087803b158015612cc357600080fd5b505af1158015612cd7573d6000803e3d6000fd5b505050508080612ce690614d21565b915050612bf3565b50505b80612cfb81614d21565b91505061288e565b50505050505050565b60006001600160401b03604083901c811690612d2a90841685614f32565b6123239190614cff565b606080612d3f614652565b6006546001600160401b03811115612d5957612d59614ca6565b604051908082528060200260200182016040528015612d82578160200160208202803683370190505b5060808201526006546001600160401b03811115612da257612da2614ca6565b604051908082528060200260200182016040528015612dcb578160200160208202803683370190505b5060a0820152612dda85613879565b606082015260c0810184905260005b612df66020870187614f45565b90508110156131335760005b612e0f60c0880188614f45565b83818110612e1f57612e1f614cbc565b9050602002810190612e319190614f45565b905081101561312057612e4760c0880188614f45565b83818110612e5757612e57614cbc565b9050602002810190612e699190614f45565b82818110612e7957612e79614cbc565b9050602002810190612e8b9190615b6e565b612e9490615b8e565b602080850182905290516000908152600e82526040808220815160a081018352815460ff161515815282516080810190935293909290840191906001840190600490835b82821015612f79576040805160a0810190915260028302850180546001600160a01b03811683526020830190600160a01b900460ff166001811115612f1f57612f1f614d6d565b6001811115612f3057612f30614d6d565b81528154600160a81b810460ff161515602080840191909152600160b01b90910463ffffffff166040830152600192830154606090920191909152918352929092019101612ed8565b5050509082525060098201546001600160a01b038116602080840191909152600160a01b9091046001600160401b03166040830152600a90920154606090910152818552608090910151848201519091015161302c9190612fda8a80614f45565b86818110612fea57612fea614cbc565b9050602002016020810190612fff9190614787565b8660c00151868151811061301557613015614cbc565b602002602001015187608001518860a00151613a76565b60005b600481101561310d57835160200151816004811061304f5761304f614cbc565b6020020151604001511561310d57836020015160400151818151811061307757613077614cbc565b602002602001015184604001819052506130fb8460200151600001518486600001516020015184600481106130ae576130ae614cbc565b60200201516130c060408d018d614f45565b6130cd60608f018f614f45565b8b60400151600001518c60400151602001518d60400151604001518e60200151602001518f60600151613be2565b8061310581614d21565b91505061302f565b508061311881614d21565b915050612e02565b508061312b81614d21565b915050612de9565b5061314e6131446080870187614f45565b8360600151613f7a565b80608001518160a0015192509250505b9250929050565b6000806000805b600654811015613375576000600560006006848154811061318f5761318f614cbc565b600091825260208083209091015483528201929092526040019020805490915060ff166131f057600682815481106131c9576131c9614cbc565b906000526020600020015460405163ba997a0160e01b81526004016107d991815260200190565b6131fd6103e86064614ce8565b86838151811061320f5761320f614cbc565b602002602001015163ffffffff1688848151811061322f5761322f614cbc565b602002602001015183600101546132469190614ce8565b6132509190614ce8565b61325a9190614cff565b92507ffe8d48ec0ae86903b5c94d43d79e424e406c2ff08552e9e0769c780879319439896006848154811061329157613291614cbc565b90600052602060002001548885815181106132ae576132ae614cbc565b6020026020010151868c87815181106132c9576132c9614cbc565b60200260200101518c88815181106132e3576132e3614cbc565b602002602001015160405161332696959493929190958652602086019490945263ffffffff9290921660408501526060840152608083015260a082015260c00190565b60405180910390a16133388386614f32565b945087828151811061334c5761334c614cbc565b60200260200101518461335f9190614f32565b935050808061336d90614d21565b91505061316c565b505094509492505050565b6040516259f78360e41b81526004810183905260e0820135602482015260009081906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063059f7830906044016020604051808303816000875af11580156133f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134199190615cdd565b9050600061342785836141bb565b905060005b61343960c0860186614f45565b90508110156136b85760005b61345260c0870187614f45565b8381811061346257613462614cbc565b90506020028101906134749190614f45565b90508110156136a5577f9e57972e90779687234156a318f02ebc8bbb0bb64cf527e34ca86a9a7412757087856134aa8980614f45565b868181106134ba576134ba614cbc565b90506020020160208101906134cf9190614787565b6134dc60208b018b614f45565b878181106134ec576134ec614cbc565b905060200201358a8060c001906135039190614f45565b8881811061351357613513614cbc565b90506020028101906135259190614f45565b8781811061353557613535614cbc565b90506020028101906135479190615b6e565b6040805195865260208601949094526001600160a01b0392909216848401526060840152356080830152519081900360a00190a161368387848661358b8a80614f45565b8781811061359b5761359b614cbc565b90506020020160208101906135b09190614787565b6135bd60208c018c614f45565b888181106135cd576135cd614cbc565b905060200201358b8060c001906135e49190614f45565b898181106135f4576135f4614cbc565b90506020028101906136069190614f45565b8881811061361657613616614cbc565b90506020028101906136289190615b6e565b3561363660c08e018e614f45565b8a81811061364657613646614cbc565b90506020028101906136589190614f45565b8981811061366857613668614cbc565b905060200281019061367a9190615b6e565b6020013561421f565b92508361368f81614d21565b945050808061369d90614d21565b915050613445565b50806136b081614d21565b91505061342c565b50949350505050565b60006136ce610aaf611b9b565b905060005b60065481101561159c578281815181106136ef576136ef614cbc565b602002602001015182828151811061370957613709614cbc565b60200260200101511015613751576006818154811061372a5761372a614cbc565b906000526020600020015460405163400ff3a760e11b81526004016107d991815260200190565b8061375b81614d21565b9150506136d3565b6060816001600160401b0381111561377d5761377d614ca6565b6040519080825280602002602001820160405280156137a6578160200160208202803683370190505b50905060005b828110156137f157838282815181106137c7576137c7614cbc565b6001600160a01b0390921660209283029190910190910152806137e981614d21565b9150506137ac565b5092915050565b6060816001600160401b0381111561381257613812614ca6565b60405190808252806020026020018201604052801561383b578160200160208202803683370190505b50905060005b828110156137f1578382828151811061385c5761385c614cbc565b60209081029190910101528061387181614d21565b915050613841565b60606138886040830183614f45565b90506001600160401b038111156138a1576138a1614ca6565b6040519080825280602002602001820160405280156138d457816020015b60608152602001906001900390816138bf5790505b50905060005b6138e76040840184614f45565b9050811015613a70576138fd6020840184614f45565b90506001600160401b0381111561391657613916614ca6565b60405190808252806020026020018201604052801561394957816020015b60608152602001906001900390816139345790505b5082828151811061395c5761395c614cbc565b602002602001018190525060005b6139776020850185614f45565b9050811015613a5d5761398d6080850185614f45565b8381811061399d5761399d614cbc565b90506020028101906139af9190614f45565b828181106139bf576139bf614cbc565b90506020028101906139d19190614f45565b90506001600160401b038111156139ea576139ea614ca6565b604051908082528060200260200182016040528015613a13578160200160208202803683370190505b50838381518110613a2657613a26614cbc565b60200260200101518281518110613a3f57613a3f614cbc565b60200260200101819052508080613a5590614d21565b91505061396a565b5080613a6881614d21565b9150506138da565b50919050565b60008681526005602052604090205460ff16613aa85760405163ba997a0160e01b8152600481018790526024016107d9565b60008681526005602052604090205461010090046001600160401b0316831015613b0c576000868152600560205260409081902054905163150e52b160e31b81526101009091046001600160401b03166004820152602481018490526044016107d9565b6000868152600560205260409020600301548251869184918110613b3257613b32614cbc565b60200260200101818151613b469190614f32565b9052507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811690851614613b84576001613b87565b60055b60ff16613b948487614ce8565b613b9e9190614ce8565b60008781526005602052604090206003015482518391908110613bc357613bc3614cbc565b60200260200101818151613bd79190614f32565b905250505050505050565b613c0f60405180606001604052806000815260200160006001600160a01b03168152602001600081525090565b60005b8551811015613f31578a8a888381518110613c2f57613c2f614cbc565b6020026020010151818110613c4657613c46614cbc565b9050602002016020810190613c5b9190614787565b6001600160a01b03166020830152865189908990899084908110613c8157613c81614cbc565b6020026020010151818110613c9857613c98614cbc565b9050602002810190613caa9190614f45565b8e818110613cba57613cba614cbc565b9050602002810190613ccc9190614f45565b878381518110613cde57613cde614cbc565b6020026020010151818110613cf557613cf5614cbc565b602002919091013560408401525060018c602001516001811115613d1b57613d1b614d6d565b03613d9c5781602001516001600160a01b03168c600001516001600160a01b0316141580613d51575081604001518c6080015114155b15613d97578d8260200151836040015160405163ec51523b60e01b81526004016107d9939291909283526001600160a01b03919091166020830152604082015260600190565b613e48565b60008c602001516001811115613db457613db4614d6d565b03613e2c576020808301516001600160a01b03166000908152600f82526040808220818601518352909252205460808d015114613d97578d8260200151836040015160405163ec51523b60e01b81526004016107d9939291909283526001600160a01b03919091166020830152604082015260600190565b604051636f289def60e11b8152600481018f90526024016107d9565b848181518110613e5a57613e5a614cbc565b602002602001015182600001818151613e739190614f32565b9052508451859082908110613e8a57613e8a614cbc565b602002602001015183888381518110613ea557613ea5614cbc565b602002602001015181518110613ebd57613ebd614cbc565b60200260200101518e81518110613ed657613ed6614cbc565b6020026020010151878381518110613ef057613ef0614cbc565b602002602001015181518110613f0857613f08614cbc565b60200260200101818151613f1c9190614f32565b90525080613f2981614d21565b915050613c12565b50805160608c0151613f4a90859063ffffffff16614ce8565b14613f6b57604051634e02ec9760e01b8152600481018e90526024016107d9565b50505050505050505050505050565b60005b81518110156141b55760005b828281518110613f9b57613f9b614cbc565b6020026020010151518110156141a25760005b838381518110613fc057613fc0614cbc565b60200260200101518281518110613fd957613fd9614cbc565b60200260200101515181101561418f57838381518110613ffb57613ffb614cbc565b6020026020010151828151811061401457614014614cbc565b6020026020010151818151811061402d5761402d614cbc565b602002602001015186868581811061404757614047614cbc565b90506020028101906140599190614f45565b8481811061406957614069614cbc565b905060200281019061407b9190614f45565b8381811061408b5761408b614cbc565b905060200201351461417d578282828888878181106140ac576140ac614cbc565b90506020028101906140be9190614f45565b868181106140ce576140ce614cbc565b90506020028101906140e09190614f45565b858181106140f0576140f0614cbc565b9050602002013587878151811061410957614109614cbc565b6020026020010151868151811061412257614122614cbc565b6020026020010151858151811061413b5761413b614cbc565b6020908102919091010151604051632eae91db60e21b81526004810195909552602485019390935260448401919091526064830152608482015260a4016107d9565b8061418781614d21565b915050613fae565b508061419a81614d21565b915050613f89565b50806141ad81614d21565b915050613f7d565b50505050565b60006141c5614425565b604080516020810192909252429082015233606090811b6bffffffffffffffffffffffff191690820152607481018390526094810184905260b40160408051601f1981840301815291905280516020909101209392505050565b6000828152600e602052604081205460ff166142515760405163da77a83f60e01b8152600481018490526024016107d9565b6000838152600e6020526040808220600981015491516343590b8f60e01b8152600160a01b83046001600160401b03166004820152602481018b90523360448201526001600160a01b0389811660648301526084820189905260a4820187905291939291909116906343590b8f9060c4016000604051808303816000875af11580156142e1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526143099190810190615cf6565b905061433f60405180608001604052806000815260200160006001600160a01b0316815260200160008152602001600081525090565b60005b826020015151811015614415578260200151818151811061436557614365614cbc565b602002602001015191507f94bc3a60588238311bdc7da466fa841ceecd4c4812bda794e3b773caa1a44e538c8b8b8b86600001518760200151886040015189606001516040516143fb98979695949392919097885260208801969096526001600160a01b0394851660408801526060870193909352608086019190915290911660a084015260c083015260e08201526101000190565b60405180910390a18061440d81614d21565b915050614342565b5050519998505050505050505050565b60004661a4b1148061443857504661a4ba145b8061444557504662066eed145b8061445257504662066eee145b8061446057504663015f2249145b8061446d57504662066eeb145b156145505760646001600160a01b0316632b407a82600160646001600160a01b031663a3b1b31d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156144c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144e79190615cdd565b6144f19190614d3a565b6040518263ffffffff1660e01b815260040161450f91815260200190565b602060405180830381865afa15801561452c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab49190615cdd565b61455b600143614d3a565b40905090565b82805482825590600052602060002090810192821561459c579160200282015b8281111561459c578235825591602001919060010190614581565b506109809291506146d9565b8280548282559060005260206000209060070160089004810192821561459c5791602002820160005b8382111561461557835183826101000a81548163ffffffff021916908363ffffffff16021790555092602001926004016020816003010492830192600103026145d1565b80156146455782816101000a81549063ffffffff0219169055600401602081600301049283019260010302614615565b50506109809291506146d9565b6040518060e001604052806146656146ee565b815260200161468e60405180606001604052806000815260200160008152602001606081525090565b81526020016146b760405180606001604052806060815260200160608152602001606081525090565b8152602001606081526020016060815260200160608152602001606081525090565b5b8082111561098057600081556001016146da565b6040518060a0016040528060001515815260200161470a614725565b81526000602082018190526040820181905260609091015290565b60405180608001604052806004905b6040805160a0810182526000808252602080830182905292820181905260608201819052608082015282526000199092019101816147345790505090565b6001600160a01b038116811461121d57600080fd5b60006020828403121561479957600080fd5b813561232381614772565b602080825282518282018190526000919060409081850190868401855b828110156147e6578151805185528601518685015292840192908501906001016147c1565b5091979650505050505050565b600081518084526020808501945080840160005b8381101561482357815187529582019590820190600101614807565b509495945050505050565b60208152600061232360208301846147f3565b60006020828403121561485357600080fd5b5035919050565b600081518084526020808501945080840160005b8381101561482357815163ffffffff168752958201959082019060010161486e565b60208152815160208201526000602083015160a060408401526148b660c084018261485a565b90506040840151601f19808584030160608601526148d4838361485a565b925060608601519150808584030160808601526148f1838361485a565b925060808601519150808584030160a08601525061490f828261485a565b95945050505050565b60008083601f84011261492a57600080fd5b5081356001600160401b0381111561494157600080fd5b6020830191508360208260051b850101111561315e57600080fd5b801515811461121d57600080fd5b80356149758161495c565b919050565b60008060008060006060868803121561499257600080fd5b85356001600160401b03808211156149a957600080fd5b6149b589838a01614918565b909750955060208801359150808211156149ce57600080fd5b818801915088601f8301126149e257600080fd5b8135818111156149f157600080fd5b89602061030083028501011115614a0757600080fd5b602083019550809450505050614a1f6040870161496a565b90509295509295909350565b600060208284031215614a3d57600080fd5b81356123238161495c565b60006101008284031215613a7057600080fd5b600080600060608486031215614a7057600080fd5b83356001600160401b0380821115614a8757600080fd5b614a9387838801614a48565b94506020860135915080821115614aa957600080fd5b614ab587838801614a48565b93506040860135915080821115614acb57600080fd5b50840160c08187031215614ade57600080fd5b809150509250925092565b60008060408385031215614afc57600080fd5b8235614b0781614772565b946020939093013593505050565b6000806000806000806000806080898b031215614b3157600080fd5b88356001600160401b0380821115614b4857600080fd5b614b548c838d01614918565b909a50985060208b0135915080821115614b6d57600080fd5b614b798c838d01614918565b909850965060408b0135915080821115614b9257600080fd5b614b9e8c838d01614918565b909650945060608b0135915080821115614bb757600080fd5b50614bc48b828c01614918565b999c989b5096995094979396929594505050565b600080600080600060608688031215614bf057600080fd5b8535614bfb81614772565b945060208601356001600160401b0380821115614c1757600080fd5b614c2389838a01614918565b90965094506040880135915080821115614c3c57600080fd5b50614c4988828901614918565b969995985093965092949392505050565b600060208284031215614c6c57600080fd5b81516123238161495c565b60208082526015908201527426b0b730b3b2b91d102737ba1030b71020b236b4b760591b604082015260600190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176122cd576122cd614cd2565b600082614d1c57634e487b7160e01b600052601260045260246000fd5b500490565b600060018201614d3357614d33614cd2565b5060010190565b818103818111156122cd576122cd614cd2565b80546001600160a01b0319166001600160a01b0392909216919091179055565b634e487b7160e01b600052602160045260246000fd5b6000813563ffffffff811681146122cd57600080fd5b8135614da481614772565b614dae8183614d4d565b50602082013560028110614dc157600080fd5b815460ff60a01b19811660a09290921b60ff60a01b1691821783556040840135614dea8161495c565b61ffff60a01b199190911690911790151560a81b60ff60a81b16178155614e3a614e1660608401614d83565b82805463ffffffff60b01b191660b09290921b63ffffffff60b01b16919091179055565b608082013560018201555050565b600081356122cd81614772565b6001600160401b038116811461121d57600080fd5b600081356122cd81614e55565b8135614e828161495c565b815490151560ff1660ff199190911617815560016020830181830160005b6004811015614ec857614eb38383614d99565b60a09290920191600291909101908301614ea0565b5050505060098101614ee6614ee06102a08501614e48565b82614d4d565b614f22614ef66102c08501614e6a565b82805467ffffffffffffffff60a01b191660a09290921b67ffffffffffffffff60a01b16919091179055565b506102e0820135600a8201555050565b808201808211156122cd576122cd614cd2565b6000808335601e19843603018112614f5c57600080fd5b8301803591506001600160401b03821115614f7657600080fd5b6020019150600581901b360382131561315e57600080fd5b604051608081016001600160401b0381118282101715614fb057614fb0614ca6565b60405290565b604051606081016001600160401b0381118282101715614fb057614fb0614ca6565b604080519081016001600160401b0381118282101715614fb057614fb0614ca6565b604051601f8201601f191681016001600160401b038111828210171561502257615022614ca6565b604052919050565b60006001600160401b0382111561504357615043614ca6565b5060051b60200190565b600061506061505b8461502a565b614ffa565b83815260208082019190600586811b86013681111561507e57600080fd5b865b8181101561510a5780356001600160401b0381111561509f5760008081fd5b880136601f8201126150b15760008081fd5b80356150bf61505b8261502a565b81815290851b820186019086810190368311156150dc5760008081fd5b928701925b828410156150fa578335825292870192908701906150e1565b8952505050948301948301615080565b5092979650505050505050565b600082601f83011261512857600080fd5b8135602061513861505b8361502a565b82815260059290921b8401810191818101908684111561515757600080fd5b8286015b84811015615172578035835291830191830161515b565b509695505050505050565b600061518b61505b8461502a565b83815260208082019190600586811b8601368111156151a957600080fd5b865b8181101561510a5780356001600160401b03808211156151cb5760008081fd5b9089019036601f8301126151df5760008081fd5b81356151ed61505b8261502a565b81815290861b8301870190878101903683111561520a5760008081fd5b8885015b83811015615242578035858111156152265760008081fd5b615234368c838a0101615117565b84525091890191890161520e565b508a52505050958401955083016151ab565b600081518084526020808501945080840160005b838110156148235781516001600160a01b031687529582019590820190600101615268565b600081518084526020808501808196508360051b810191508286016000805b868110156152fb578385038a52825180518087529087019087870190845b818110156152e6578351835292890192918901916001016152ca565b50509a87019a955050918501916001016152ac565b509298975050505050505050565b60008282518085526020808601955060058183821b8501018287016000805b8681101561539557601f1988850381018c5283518051808752908801908887019080891b88018a01865b8281101561537e57858a830301845261536c8286516147f3565b948c0194938c01939150600101615352565b509e8a019e97505050938701935050600101615328565b50919998505050505050505050565b602081526153be6020820183516001600160a01b03169052565b6000602083015160e060408401526153da610100840182615254565b90506040840151601f19808584030160608601526153f883836147f3565b92506060860151915080858403016080860152615415838361528d565b925060808601519150808584030160a08601526154328383615254565b925060a08601519150808584030160c086015261544f8383615309565b925060c08601519150808584030160e08601525061490f8282615309565b60006020828403121561547f57600080fd5b813561232381614e55565b6000815480845260208085019450836000528060002060005b83811015614823578154875295820195600191820191016154a3565b602081526000612323602083018461548a565b600060208083850312156154e557600080fd5b82516001600160401b038111156154fb57600080fd5b8301601f8101851361550c57600080fd5b805161551a61505b8261502a565b81815260079190911b8201830190838101908783111561553957600080fd5b928401925b8284101561559057608084890312156155575760008081fd5b61555f614f8e565b845181528585015186820152604080860151908201526060808601519082015282526080909301929084019061553e565b979650505050505050565b8281526040602082015260006155b4604083018461548a565b949350505050565b600082601f8301126155cd57600080fd5b815160206155dd61505b8361502a565b82815260059290921b840181019181810190868411156155fc57600080fd5b8286015b848110156151725780518352918301918301615600565b60006020828403121561562957600080fd5b81516001600160401b0381111561563f57600080fd5b6155b4848285016155bc565b8183526000602080850194508260005b8581101561482357813561566e81614772565b6001600160a01b03168752958201959082019060010161565b565b81835260006001600160fb1b038311156156a257600080fd5b8260051b80836020870137939093016020019392505050565b6000808335601e198436030181126156d257600080fd5b83016020810192503590506001600160401b038111156156f157600080fd5b8060051b360382131561315e57600080fd5b81835260006020808501808196508560051b810191508460005b878110156147e657828403895261573482886156bb565b61573f868284615689565b9a87019a955050509084019060010161571d565b60408152600061576760408301868861564b565b8281036020840152615590818587615703565b6001600160a01b038916815260a06020820181905260009061579f908301898b61564b565b82810360408401526157b281888a615689565b905082810360608401526157c7818688615703565b9150508260808301529998505050505050505050565b81835260006020808501945084600585811b8701856000805b89811015615395578584038b5261580d838a6156bb565b80865288860181881b87018a0183865b8481101561585757898303601f1901845261583882876156bb565b615843858284615689565b958f019594505050908c019060010161581d565b50509d8a019d9650505092870192506001016157f6565b60a08152600061588260a083018c8e61564b565b8281036020840152615895818b8d615689565b905082810360408401526158aa81898b61564b565b905082810360608401526158bf8187896157dd565b905082810360808401526158d48185876157dd565b9d9c50505050505050505050505050565b6080815260006158f960808301888a61564b565b828103602084015261590c818789615689565b6040840195909552505060600152949350505050565b83815260606020820152600061593b606083018561548a565b828103604084015261594d81856147f3565b9695505050505050565b84815260806020820152600061597060808301866147f3565b828103604084015261598281866147f3565b91505082606083015295945050505050565b600080604083850312156159a757600080fd5b82516001600160401b03808211156159be57600080fd5b818501915085601f8301126159d257600080fd5b815160206159e261505b8361502a565b82815260059290921b84018101918181019089841115615a0157600080fd5b8286015b84811015615a3957805186811115615a1d5760008081fd5b615a2b8c86838b01016155bc565b845250918301918301615a05565b5097909101519698969750505050505050565b600081518084526020808501808196508360051b8101915082860160005b858110156147e6578284038952615a828483516147f3565b98850198935090840190600101615a6a565b60e08082528851908201819052600090602090610100840190828c01845b82811015615ad75781516001600160a01b031684529284019290840190600101615ab2565b50505083810382850152615aeb818b6147f3565b915050615b0360408401896001600160a01b03169052565b8281036060840152615b158188615a4c565b915050615b2a608083018663ffffffff169052565b92151560a082015290151560c09091015295945050505050565b606081526000615b5760608301866147f3565b602083019490945250901515604090910152919050565b60008235605e19833603018112615b8457600080fd5b9190910192915050565b60006060808336031215615ba157600080fd5b615ba9614fb6565b83358152602080850135818301526040808601356001600160401b0380821115615bd257600080fd5b9087019036601f830112615be557600080fd5b8135615bf361505b8261502a565b81815260059190911b83018501908581019036831115615c1257600080fd5b8685015b83811015615cc857803585811115615c2e5760008081fd5b860136819003601f19018b1315615c455760008081fd5b615c4d614fb6565b8982013587811115615c5f5760008081fd5b615c6d368c83860101615117565b8252508882013587811115615c825760008081fd5b615c90368c83860101615117565b8b830152508b82013587811115615ca75760008081fd5b615cb5368c83860101615117565b828b015250845250918701918701615c16565b50948701949094525093979650505050505050565b600060208284031215615cef57600080fd5b5051919050565b60006020808385031215615d0957600080fd5b82516001600160401b0380821115615d2057600080fd5b81850191506040808388031215615d3657600080fd5b615d3e614fd8565b835181528484015183811115615d5357600080fd5b80850194505087601f850112615d6857600080fd5b83519250615d7861505b8461502a565b83815260079390931b84018501928581019089851115615d9757600080fd5b948601945b84861015615df5576080868b031215615db55760008081fd5b615dbd614f8e565b8651815287870151615dce81614772565b81890152868501518582015260608088015190820152825260809095019490860190615d9c565b9582019590955297965050505050505056fea264697066735822122028dbba021bd888975cf9b3d6df5228a2e8a495bc8b7883ea079120b1f59a5c3e64736f6c634300081400330000000000000000000000004e572433a3bfa336b6396d13afc9f69b58252861000000000000000000000000b1d6eccd0b2ed5ce9b2599cae1386daae2c623c8000000000000000000000000c1b4861697f3cba41c6a8744dee86daf62d3c123000000000000000000000000839f0ffee7d4edc9f3b38b2c2b316ff28da67e4a000000000000000000000000bd025cca38afaa180d0d1b204e80763db361d6f800000000000000000000000037d5b5527866214d103fcc4013e5c0e963de81cc000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d000000000000000000000000b0171b76b413303ad35e5d7cf9e9586480a87f570000000000000000000000006f96e4f04600343c92cb4afe0bc70e8154a2512500000000000000000000000011073afb248b2f2d9f34928c39fe2f37aae5b71a000000000000000000000000ccd05a0fcfc1380e9da27862adb2198e58e0d66f0000000000000000000000004de95c1e202102e22e801590c51d7b979f167fbb00000000000000000000000012b38bb36d4510cd69055b33c2df74c63fadb2f70000000000000000000000006f762a3202793f928aefbd6401a00145e2db94e40000000000000000000000007b769444ebf1b63306d5a7518bde14db0891c1dc000000000000000000000000f689cc15eaa634c7b80114cfb0d11dc8617f52ba000000000000000000000000747910b74d2651a06563c3182838eae4120f4277

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061023d5760003560e01c8063835d61021161013b578063bab675bc116100b8578063e7c17fcb1161007c578063e7c17fcb1461063f578063ed53122e14610647578063efb8f8d7146106c0578063f2f039ec146106e7578063fcac08921461070e57600080fd5b8063bab675bc146105eb578063bb9dd493146105f3578063c0346b2014610606578063da5b91c314610619578063def47d701461062c57600080fd5b80639eb2b106116100ff5780639eb2b1061461052a578063aed0f90014610551578063af00a2ef14610578578063b0e8ab7a1461059f578063b93e9fa3146105d857600080fd5b8063835d6102146104c25780638456cb59146104d557806394df7486146104dd57806398589568146104f05780639c11e98a1461051757600080fd5b80633cc00a39116101c95780635c975abb1161018d5780635c975abb146104365780636308cf941461044c578063677d43de1461046157806376d2dfc514610488578063816738531461049b57600080fd5b80633cc00a39146103465780633f4ba83a1461036d578063443c227c1461037557806344975d81146103fc578063525ae1cb1461040f57600080fd5b80632b3ed84e116102105780632b3ed84e146102c35780632d2ea544146102ea5780632e51cf3814610311578063338c537114610326578063347b40931461033e57600080fd5b806308ee3ea0146102425780631b2df85014610257578063236b379c1461029b57806326721dba146102b0575b600080fd5b610255610250366004614787565b610735565b005b61027e7f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b5825286181565b6040516001600160a01b0390911681526020015b60405180910390f35b6102a3610804565b60405161029291906147a4565b6102556102be366004614787565b610984565b61027e7f000000000000000000000000b0171b76b413303ad35e5d7cf9e9586480a87f5781565b61027e7f000000000000000000000000b1d6eccd0b2ed5ce9b2599cae1386daae2c623c881565b610319610a4a565b604051610292919061482e565b60015461027e9061010090046001600160a01b031681565b610319610aa2565b61027e7f00000000000000000000000037d5b5527866214d103fcc4013e5c0e963de81cc81565b610255610ab9565b6103c4610383366004614841565b600e60205260009081526040902080546009820154600a9092015460ff909116916001600160a01b03811691600160a01b9091046001600160401b03169084565b6040805194151585526001600160a01b0390931660208501526001600160401b03909116918301919091526060820152608001610292565b60025461027e906001600160a01b031681565b61027e7f00000000000000000000000012b38bb36d4510cd69055b33c2df74c63fadb2f781565b60015460ff166040519015158152602001610292565b610454610b67565b6040516102929190614890565b61027e7f0000000000000000000000004de95c1e202102e22e801590c51d7b979f167fbb81565b610255610496366004614841565b610dcb565b61027e7f000000000000000000000000ccd05a0fcfc1380e9da27862adb2198e58e0d66f81565b6102556104d036600461497a565b610e74565b6102556110b8565b6102556104eb366004614a2b565b611164565b61027e7f00000000000000000000000011073afb248b2f2d9f34928c39fe2f37aae5b71a81565b610255610525366004614a5b565b611220565b61027e7f000000000000000000000000f689cc15eaa634c7b80114cfb0d11dc8617f52ba81565b61027e7f0000000000000000000000007b769444ebf1b63306d5a7518bde14db0891c1dc81565b61027e7f000000000000000000000000bd025cca38afaa180d0d1b204e80763db361d6f881565b6105ca6105ad366004614ae9565b600f60209081526000928352604080842090915290825290205481565b604051908152602001610292565b6102556105e6366004614b15565b6115a1565b6102a3611801565b6105ca610601366004614841565b611975565b610255610614366004614787565b611996565b610255610627366004614bd8565b611a62565b60035461027e906001600160a01b031681565b610319611b8f565b61068e610655366004614841565b600560205260009081526040902080546001820154600283015460039093015460ff8316936101009093046001600160401b0316929085565b6040805195151586526001600160401b039094166020860152928401919091526060830152608082015260a001610292565b61027e7f000000000000000000000000747910b74d2651a06563c3182838eae4120f427781565b61027e7f0000000000000000000000006f96e4f04600343c92cb4afe0bc70e8154a2512581565b61027e7f000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d81565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa158015610799573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107bd9190614c5a565b6107e25760405162461bcd60e51b81526004016107d990614c77565b60405180910390fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6006546060906001600160401b0381111561082157610821614ca6565b60405190808252806020026020018201604052801561086657816020015b604080518082019091526000808252602082015281526020019060019003908161083f5790505b50905060005b815181101561098057600560006006838154811061088c5761088c614cbc565b90600052602060002001548152602001908152602001600020600101548282815181106108bb576108bb614cbc565b6020908102919091010151526108d46103e86064614ce8565b6108dc611b9b565b60020182815481106108f0576108f0614cbc565b90600052602060002090600891828204019190066004029054906101000a900463ffffffff1663ffffffff1683838151811061092e5761092e614cbc565b6020026020010151600001516109449190614ce8565b61094e9190614cff565b82828151811061096057610960614cbc565b60209081029190910181015101528061097881614d21565b91505061086c565b5090565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa1580156109e8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0c9190614c5a565b610a285760405162461bcd60e51b81526004016107d990614c77565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b60606006805480602002602001604051908101604052809291908181526020018280548015610a9857602002820191906000526020600020905b815481526020019060010190808311610a84575b5050505050905090565b6060610ab4610aaf611b9b565b611f7d565b905090565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa158015610b1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b419190614c5a565b610b5d5760405162461bcd60e51b81526004016107d990614c77565b610b65612175565b565b610b996040518060a0016040528060008152602001606081526020016060815260200160608152602001606081525090565b610ba1611b9b565b6040518060a00160405290816000820154815260200160018201805480602002602001604051908101604052809291908181526020018280548015610c3157602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff1681526020019060040190602082600301049283019260010382029150808411610bf45790505b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015610cb557602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff1681526020019060040190602082600301049283019260010382029150808411610c785790505b5050505050815260200160038201805480602002602001604051908101604052809291908181526020018280548015610d3957602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff1681526020019060040190602082600301049283019260010382029150808411610cfc5790505b5050505050815260200160048201805480602002602001604051908101604052809291908181526020018280548015610dbd57602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff1681526020019060040190602082600301049283019260010382029150808411610d805790505b505050505081525050905090565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa158015610e2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e539190614c5a565b610e6f5760405162461bcd60e51b81526004016107d990614c77565b600c55565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa158015610ed8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efc9190614c5a565b610f185760405162461bcd60e51b81526004016107d990614c77565b8015610f945760005b600d54811015610f81576000600e6000600d8481548110610f4457610f44614cbc565b60009182526020808320919091015483528201929092526040019020805460ff191691151591909117905580610f7981614d21565b915050610f21565b50610f8e600d8686614561565b50611040565b60005b8481101561103e57600e6000878784818110610fb557610fb5614cbc565b602090810292909201358352508101919091526040016000205460ff1661102c57600d80546001018155600052858582818110610ff457610ff4614cbc565b90506020020135600d6001600d8054905061100f9190614d3a565b8154811061101f5761101f614cbc565b6000918252602090912001555b8061103681614d21565b915050610f97565b505b60005b848110156110b05783838281811061105d5761105d614cbc565b90506103000201600e600088888581811061107a5761107a614cbc565b905060200201358152602001908152602001600020818161109b9190614e77565b508190506110a881614d21565b915050611043565b505050505050565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa15801561111c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111409190614c5a565b61115c5760405162461bcd60e51b81526004016107d990614c77565b610b656121c7565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa1580156111c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ec9190614c5a565b6112085760405162461bcd60e51b81526004016107d990614c77565b6000600755801561121d5761121b611b9b565b505b50565b611228612202565b61123061225b565b3332146112985760405162461bcd60e51b815260206004820152603060248201527f4372616674696e67206973206e6f7420616c6c6f776564207468726f7567682060448201526f185b9bdd1a195c8818dbdb9d1c9858dd60821b60648201526084016107d9565b600c546112ad60e08085013590860135614f32565b6112b79190614ce8565b5a1015611300575a600c546112d460e08086013590870135614f32565b6112de9190614ce8565b60405163fe336aa760e01b8152600481019290925260248201526044016107d9565b600061130c8280614f45565b905011156114c0576040805160e081019091523381526001600160a01b037f0000000000000000000000006f96e4f04600343c92cb4afe0bc70e8154a25125169063b963347890602081016113618580614f45565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020908101906113a790860186614f45565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020016113eb6040860186614f45565b6113f49161504d565b81526020016114066060860186614f45565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050509082525060200161144a6080860186614f45565b6114539161517d565b815260200161146560a0860186614f45565b61146e9161517d565b8152506040518263ffffffff1660e01b815260040161148d91906153a4565b600060405180830381600087803b1580156114a757600080fd5b505af11580156114bb573d6000803e3d6000fd5b505050505b60006114ca611b9b565b9050600060e0850135156114ef576114e285836122a1565b6114ec9082614f32565b90505b60e0840135156115105761150384836122d3565b61150d9082614f32565b90505b60405163079cc67960e41b8152336004820152602481018290527f000000000000000000000000ccd05a0fcfc1380e9da27862adb2198e58e0d66f6001600160a01b0316906379cc679090604401600060405180830381600087803b15801561157857600080fd5b505af115801561158c573d6000803e3d6000fd5b50505050505061159c6001600055565b505050565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa158015611605573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116299190614c5a565b6116455760405162461bcd60e51b81526004016107d990614c77565b86851461165157600080fd5b60005b6006548110156116b4576000600560006006848154811061167757611677614cbc565b60009182526020808320919091015483528201929092526040019020805460ff1916911515919091179055806116ac81614d21565b915050611654565b506116c160068989614561565b5060005b878110156117f6576040518060a001604052806001151581526020018888848181106116f3576116f3614cbc565b9050602002016020810190611708919061546d565b6001600160401b0316815260200186868481811061172857611728614cbc565b90506020020135815260200184848481811061174657611746614cbc565b90506020020135815260200182815250600560008b8b8581811061176c5761176c614cbc565b60209081029290920135835250818101929092526040908101600020835181549385015168ffffffffffffffffff1990941690151568ffffffffffffffff001916176101006001600160401b0390941693909302929092178255820151600182015560608201516002820155608090910151600390910155806117ee81614d21565b9150506116c5565b505050505050505050565b6006546060906001600160401b0381111561181e5761181e614ca6565b60405190808252806020026020018201604052801561186357816020015b604080518082019091526000808252602082015281526020019060019003908161183c5790505b50905060005b815181101561098057600560006006838154811061188957611889614cbc565b90600052602060002001548152602001908152602001600020600101548282815181106118b8576118b8614cbc565b6020908102919091010151526118d16103e86064614ce8565b60098054839081106118e5576118e5614cbc565b90600052602060002090600891828204019190066004029054906101000a900463ffffffff1663ffffffff1683838151811061192357611923614cbc565b6020026020010151600001516119399190614ce8565b6119439190614cff565b82828151811061195557611955614cbc565b60209081029190910181015101528061196d81614d21565b915050611869565b600d818154811061198557600080fd5b600091825260209091200154905081565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa1580156119fa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1e9190614c5a565b611a3a5760405162461bcd60e51b81526004016107d990614c77565b600180546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b604051630935e01b60e21b81523360048201527f0000000000000000000000004e572433a3bfa336b6396d13afc9f69b582528616001600160a01b0316906324d7806c90602401602060405180830381865afa158015611ac6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aea9190614c5a565b611b065760405162461bcd60e51b81526004016107d990614c77565b60005b838110156110b057828282818110611b2357611b23614cbc565b90506020020135600f6000886001600160a01b03166001600160a01b031681526020019081526020016000206000878785818110611b6357611b63614cbc565b905060200201358152602001908152602001600020819055508080611b8790614d21565b915050611b09565b6060610ab46007611f7d565b6004546000908190611bb79042906001600160801b03166122ef565b60078054919250908203611bcb5792915050565b6003546040516331a9d24560e01b81526000916001600160a01b0316906331a9d24590611bfd906006906004016154bf565b6000604051808303816000875af1158015611c1c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c4491908101906154d2565b8051600384015491925014611dbc5780516001600160401b03811115611c6c57611c6c614ca6565b604051908082528060200260200182016040528015611c95578160200160208202803683370190505b508051611cac9160038501916020909101906145a8565b5080516001600160401b03811115611cc657611cc6614ca6565b604051908082528060200260200182016040528015611cef578160200160208202803683370190505b508051611d069160048501916020909101906145a8565b5080516001600160401b03811115611d2057611d20614ca6565b604051908082528060200260200182016040528015611d49578160200160208202803683370190505b508051611d609160028501916020909101906145a8565b5080516001600160401b03811115611d7a57611d7a614ca6565b604051908082528060200260200182016040528015611da3578160200160208202803683370190505b508051611dba9160018501916020909101906145a8565b505b60005b8151811015611f7357818181518110611dda57611dda614cbc565b602002602001015160400151836003018281548110611dfb57611dfb614cbc565b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908363ffffffff160217905550818181518110611e4057611e40614cbc565b602002602001015160600151836004018281548110611e6157611e61614cbc565b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908363ffffffff160217905550818181518110611ea657611ea6614cbc565b602002602001015160200151836002018281548110611ec757611ec7614cbc565b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908363ffffffff160217905550818181518110611f0c57611f0c614cbc565b602002602001015160000151836001018281548110611f2d57611f2d614cbc565b90600052602060002090600891828204019190066004026101000a81548163ffffffff021916908363ffffffff1602179055508080611f6b90614d21565b915050611dbf565b5050908155919050565b606060007f000000000000000000000000f689cc15eaa634c7b80114cfb0d11dc8617f52ba6001600160a01b031663c45deef87f00000000000000000000000012b38bb36d4510cd69055b33c2df74c63fadb2f76001600160a01b031660066040518363ffffffff1660e01b8152600401611ff992919061559b565b600060405180830381865afa158015612016573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261203e9190810190615617565b905080516001600160401b0381111561205957612059614ca6565b604051908082528060200260200182016040528015612082578160200160208202803683370190505b50915060005b60065481101561216e5760008460030182815481106120a9576120a9614cbc565b6000918252602090912060088204015460079091166004026101000a900463ffffffff16905060018110156120dc575060015b6120e96103e86064614ce8565b811115612100576120fd6103e86064614ce8565b90505b8083838151811061211357612113614cbc565b60200260200101516103e8606461212a9190614ce8565b6121349190614ce8565b61213e9190614cff565b84838151811061215057612150614cbc565b6020908102919091010152508061216681614d21565b915050612088565b5050919050565b61217d61232a565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6121cf61225b565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258336121aa565b6002600054036122545760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107d9565b6002600055565b60015460ff1615610b655760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016107d9565b6000806000806122b786866001016103ed612373565b9250925092506122c78282612765565b50909150505b92915050565b60006122e583836002016103ec612373565b5090949350505050565b60006123236122fe8484612d0c565b6001600160801b0316608084901b6fffffffffffffffffffffffffffffffff19161790565b9392505050565b60015460ff16610b655760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016107d9565b600154600090606090829061010090046001600160a01b031663e3b161f961239b8880614f45565b6123a860a08b018b614f45565b6040518563ffffffff1660e01b81526004016123c79493929190615753565b60006040518083038186803b1580156123df57600080fd5b505afa1580156123f3573d6000803e3d6000fd5b50506002546001600160a01b031691506348f3db699050336124158980614f45565b61242260208c018c614f45565b61242f60a08e018e614f45565b8c6040518963ffffffff1660e01b815260040161245398979695949392919061577a565b60006040518083038186803b15801561246b57600080fd5b505afa15801561247f573d6000803e3d6000fd5b50506001600160a01b037f0000000000000000000000006f96e4f04600343c92cb4afe0bc70e8154a251251691506368bffafe90506124be8880614f45565b6124cb60208b018b614f45565b6124d860408d018d614f45565b6124e560608f018f614f45565b8f80608001906124f59190614f45565b6040518b63ffffffff1660e01b815260040161251a9a9998979695949392919061586e565b600060405180830381600087803b15801561253457600080fd5b505af1158015612548573d6000803e3d6000fd5b5060009250506001600160a01b037f000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d169050639c0ab7c06125898980614f45565b61259660208c018c614f45565b6000806040518763ffffffff1660e01b81526004016125ba969594939291906158e5565b6000604051808303816000875af11580156125d9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526126019190810190615617565b9050606061260f8883612d34565b809250819550505060006126a08786848b80548060200260200160405190810160405280929190818152602001828054801561269657602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff16815260200190600401906020826003010492830192600103820291508084116126595790505b5050505050613165565b909650905060e089013581146126c957604051631530045560e31b815260040160405180910390fd5b6126d3878a613380565b604051631c163f0160e31b81529094506001600160a01b037f00000000000000000000000037d5b5527866214d103fcc4013e5c0e963de81cc169063e0b1f80890612727908a906006908a90600401615922565b600060405180830381600087803b15801561274157600080fd5b505af1158015612755573d6000803e3d6000fd5b5050505050505093509350939050565b61276e826136c1565b600060068054806020026020016040519081016040528092919081815260200182805480156127bc57602002820191906000526020600020905b8154815260200190600101908083116127a8575b5050505050905060007f000000000000000000000000f689cc15eaa634c7b80114cfb0d11dc8617f52ba6001600160a01b0316637eef1cfd7f00000000000000000000000012b38bb36d4510cd69055b33c2df74c63fadb2f76001600160a01b03168487876040518563ffffffff1660e01b81526004016128409493929190615957565b600060405180830381865afa15801561285d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526128859190810190615994565b50905060608060005b8451811015612d03578681815181106128a9576128a9614cbc565b602002602001015160000315612cf1576128fc7f0000000000000000000000004de95c1e202102e22e801590c51d7b979f167fbb8883815181106128ef576128ef614cbc565b6020026020010151613763565b925083818151811061291057612910614cbc565b6020026020010151516001600160401b0381111561293057612930614ca6565b60405190808252806020026020018201604052801561296357816020015b606081526020019060019003908161294e5790505b50915060005b84828151811061297b5761297b614cbc565b6020026020010151518110156129df576129af8683815181106129a0576129a0614cbc565b602002602001015160016137f8565b8382815181106129c1576129c1614cbc565b602002602001018190525080806129d790614d21565b915050612969565b507f00000000000000000000000011073afb248b2f2d9f34928c39fe2f37aae5b71a6001600160a01b031663cebb767284868481518110612a2257612a22614cbc565b60200260200101517f00000000000000000000000012b38bb36d4510cd69055b33c2df74c63fadb2f78660076003018781548110612a6257612a62614cbc565b90600052602060002090600891828204019190066004029054906101000a900463ffffffff166001806040518863ffffffff1660e01b8152600401612aad9796959493929190615a94565b600060405180830381600087803b158015612ac757600080fd5b505af1158015612adb573d6000803e3d6000fd5b505050507f0000000000000000000000007b769444ebf1b63306d5a7518bde14db0891c1dc6001600160a01b031663197aa6aa858381518110612b2057612b20614cbc565b602002602001015160076004018481548110612b3e57612b3e614cbc565b90600052602060002090600891828204019190066004029054906101000a900463ffffffff1663ffffffff1660016040518463ffffffff1660e01b8152600401612b8a93929190615b44565b600060405180830381600087803b158015612ba457600080fd5b505af1158015612bb8573d6000803e3d6000fd5b50505050600060056000878481518110612bd457612bd4614cbc565b6020026020010151815260200190815260200160002060020154905060005b858381518110612c0557612c05614cbc565b602002602001015151811015612cee577f000000000000000000000000b0171b76b413303ad35e5d7cf9e9586480a87f576001600160a01b031663505fb46c878581518110612c5657612c56614cbc565b60200260200101518381518110612c6f57612c6f614cbc565b60200260200101516064856040518463ffffffff1660e01b8152600401612ca9939291909283526020830191909152604082015260600190565b600060405180830381600087803b158015612cc357600080fd5b505af1158015612cd7573d6000803e3d6000fd5b505050508080612ce690614d21565b915050612bf3565b50505b80612cfb81614d21565b91505061288e565b50505050505050565b60006001600160401b03604083901c811690612d2a90841685614f32565b6123239190614cff565b606080612d3f614652565b6006546001600160401b03811115612d5957612d59614ca6565b604051908082528060200260200182016040528015612d82578160200160208202803683370190505b5060808201526006546001600160401b03811115612da257612da2614ca6565b604051908082528060200260200182016040528015612dcb578160200160208202803683370190505b5060a0820152612dda85613879565b606082015260c0810184905260005b612df66020870187614f45565b90508110156131335760005b612e0f60c0880188614f45565b83818110612e1f57612e1f614cbc565b9050602002810190612e319190614f45565b905081101561312057612e4760c0880188614f45565b83818110612e5757612e57614cbc565b9050602002810190612e699190614f45565b82818110612e7957612e79614cbc565b9050602002810190612e8b9190615b6e565b612e9490615b8e565b602080850182905290516000908152600e82526040808220815160a081018352815460ff161515815282516080810190935293909290840191906001840190600490835b82821015612f79576040805160a0810190915260028302850180546001600160a01b03811683526020830190600160a01b900460ff166001811115612f1f57612f1f614d6d565b6001811115612f3057612f30614d6d565b81528154600160a81b810460ff161515602080840191909152600160b01b90910463ffffffff166040830152600192830154606090920191909152918352929092019101612ed8565b5050509082525060098201546001600160a01b038116602080840191909152600160a01b9091046001600160401b03166040830152600a90920154606090910152818552608090910151848201519091015161302c9190612fda8a80614f45565b86818110612fea57612fea614cbc565b9050602002016020810190612fff9190614787565b8660c00151868151811061301557613015614cbc565b602002602001015187608001518860a00151613a76565b60005b600481101561310d57835160200151816004811061304f5761304f614cbc565b6020020151604001511561310d57836020015160400151818151811061307757613077614cbc565b602002602001015184604001819052506130fb8460200151600001518486600001516020015184600481106130ae576130ae614cbc565b60200201516130c060408d018d614f45565b6130cd60608f018f614f45565b8b60400151600001518c60400151602001518d60400151604001518e60200151602001518f60600151613be2565b8061310581614d21565b91505061302f565b508061311881614d21565b915050612e02565b508061312b81614d21565b915050612de9565b5061314e6131446080870187614f45565b8360600151613f7a565b80608001518160a0015192509250505b9250929050565b6000806000805b600654811015613375576000600560006006848154811061318f5761318f614cbc565b600091825260208083209091015483528201929092526040019020805490915060ff166131f057600682815481106131c9576131c9614cbc565b906000526020600020015460405163ba997a0160e01b81526004016107d991815260200190565b6131fd6103e86064614ce8565b86838151811061320f5761320f614cbc565b602002602001015163ffffffff1688848151811061322f5761322f614cbc565b602002602001015183600101546132469190614ce8565b6132509190614ce8565b61325a9190614cff565b92507ffe8d48ec0ae86903b5c94d43d79e424e406c2ff08552e9e0769c780879319439896006848154811061329157613291614cbc565b90600052602060002001548885815181106132ae576132ae614cbc565b6020026020010151868c87815181106132c9576132c9614cbc565b60200260200101518c88815181106132e3576132e3614cbc565b602002602001015160405161332696959493929190958652602086019490945263ffffffff9290921660408501526060840152608083015260a082015260c00190565b60405180910390a16133388386614f32565b945087828151811061334c5761334c614cbc565b60200260200101518461335f9190614f32565b935050808061336d90614d21565b91505061316c565b505094509492505050565b6040516259f78360e41b81526004810183905260e0820135602482015260009081906001600160a01b037f000000000000000000000000bd025cca38afaa180d0d1b204e80763db361d6f8169063059f7830906044016020604051808303816000875af11580156133f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134199190615cdd565b9050600061342785836141bb565b905060005b61343960c0860186614f45565b90508110156136b85760005b61345260c0870187614f45565b8381811061346257613462614cbc565b90506020028101906134749190614f45565b90508110156136a5577f9e57972e90779687234156a318f02ebc8bbb0bb64cf527e34ca86a9a7412757087856134aa8980614f45565b868181106134ba576134ba614cbc565b90506020020160208101906134cf9190614787565b6134dc60208b018b614f45565b878181106134ec576134ec614cbc565b905060200201358a8060c001906135039190614f45565b8881811061351357613513614cbc565b90506020028101906135259190614f45565b8781811061353557613535614cbc565b90506020028101906135479190615b6e565b6040805195865260208601949094526001600160a01b0392909216848401526060840152356080830152519081900360a00190a161368387848661358b8a80614f45565b8781811061359b5761359b614cbc565b90506020020160208101906135b09190614787565b6135bd60208c018c614f45565b888181106135cd576135cd614cbc565b905060200201358b8060c001906135e49190614f45565b898181106135f4576135f4614cbc565b90506020028101906136069190614f45565b8881811061361657613616614cbc565b90506020028101906136289190615b6e565b3561363660c08e018e614f45565b8a81811061364657613646614cbc565b90506020028101906136589190614f45565b8981811061366857613668614cbc565b905060200281019061367a9190615b6e565b6020013561421f565b92508361368f81614d21565b945050808061369d90614d21565b915050613445565b50806136b081614d21565b91505061342c565b50949350505050565b60006136ce610aaf611b9b565b905060005b60065481101561159c578281815181106136ef576136ef614cbc565b602002602001015182828151811061370957613709614cbc565b60200260200101511015613751576006818154811061372a5761372a614cbc565b906000526020600020015460405163400ff3a760e11b81526004016107d991815260200190565b8061375b81614d21565b9150506136d3565b6060816001600160401b0381111561377d5761377d614ca6565b6040519080825280602002602001820160405280156137a6578160200160208202803683370190505b50905060005b828110156137f157838282815181106137c7576137c7614cbc565b6001600160a01b0390921660209283029190910190910152806137e981614d21565b9150506137ac565b5092915050565b6060816001600160401b0381111561381257613812614ca6565b60405190808252806020026020018201604052801561383b578160200160208202803683370190505b50905060005b828110156137f1578382828151811061385c5761385c614cbc565b60209081029190910101528061387181614d21565b915050613841565b60606138886040830183614f45565b90506001600160401b038111156138a1576138a1614ca6565b6040519080825280602002602001820160405280156138d457816020015b60608152602001906001900390816138bf5790505b50905060005b6138e76040840184614f45565b9050811015613a70576138fd6020840184614f45565b90506001600160401b0381111561391657613916614ca6565b60405190808252806020026020018201604052801561394957816020015b60608152602001906001900390816139345790505b5082828151811061395c5761395c614cbc565b602002602001018190525060005b6139776020850185614f45565b9050811015613a5d5761398d6080850185614f45565b8381811061399d5761399d614cbc565b90506020028101906139af9190614f45565b828181106139bf576139bf614cbc565b90506020028101906139d19190614f45565b90506001600160401b038111156139ea576139ea614ca6565b604051908082528060200260200182016040528015613a13578160200160208202803683370190505b50838381518110613a2657613a26614cbc565b60200260200101518281518110613a3f57613a3f614cbc565b60200260200101819052508080613a5590614d21565b91505061396a565b5080613a6881614d21565b9150506138da565b50919050565b60008681526005602052604090205460ff16613aa85760405163ba997a0160e01b8152600481018790526024016107d9565b60008681526005602052604090205461010090046001600160401b0316831015613b0c576000868152600560205260409081902054905163150e52b160e31b81526101009091046001600160401b03166004820152602481018490526044016107d9565b6000868152600560205260409020600301548251869184918110613b3257613b32614cbc565b60200260200101818151613b469190614f32565b9052507f000000000000000000000000747910b74d2651a06563c3182838eae4120f42776001600160a01b0390811690851614613b84576001613b87565b60055b60ff16613b948487614ce8565b613b9e9190614ce8565b60008781526005602052604090206003015482518391908110613bc357613bc3614cbc565b60200260200101818151613bd79190614f32565b905250505050505050565b613c0f60405180606001604052806000815260200160006001600160a01b03168152602001600081525090565b60005b8551811015613f31578a8a888381518110613c2f57613c2f614cbc565b6020026020010151818110613c4657613c46614cbc565b9050602002016020810190613c5b9190614787565b6001600160a01b03166020830152865189908990899084908110613c8157613c81614cbc565b6020026020010151818110613c9857613c98614cbc565b9050602002810190613caa9190614f45565b8e818110613cba57613cba614cbc565b9050602002810190613ccc9190614f45565b878381518110613cde57613cde614cbc565b6020026020010151818110613cf557613cf5614cbc565b602002919091013560408401525060018c602001516001811115613d1b57613d1b614d6d565b03613d9c5781602001516001600160a01b03168c600001516001600160a01b0316141580613d51575081604001518c6080015114155b15613d97578d8260200151836040015160405163ec51523b60e01b81526004016107d9939291909283526001600160a01b03919091166020830152604082015260600190565b613e48565b60008c602001516001811115613db457613db4614d6d565b03613e2c576020808301516001600160a01b03166000908152600f82526040808220818601518352909252205460808d015114613d97578d8260200151836040015160405163ec51523b60e01b81526004016107d9939291909283526001600160a01b03919091166020830152604082015260600190565b604051636f289def60e11b8152600481018f90526024016107d9565b848181518110613e5a57613e5a614cbc565b602002602001015182600001818151613e739190614f32565b9052508451859082908110613e8a57613e8a614cbc565b602002602001015183888381518110613ea557613ea5614cbc565b602002602001015181518110613ebd57613ebd614cbc565b60200260200101518e81518110613ed657613ed6614cbc565b6020026020010151878381518110613ef057613ef0614cbc565b602002602001015181518110613f0857613f08614cbc565b60200260200101818151613f1c9190614f32565b90525080613f2981614d21565b915050613c12565b50805160608c0151613f4a90859063ffffffff16614ce8565b14613f6b57604051634e02ec9760e01b8152600481018e90526024016107d9565b50505050505050505050505050565b60005b81518110156141b55760005b828281518110613f9b57613f9b614cbc565b6020026020010151518110156141a25760005b838381518110613fc057613fc0614cbc565b60200260200101518281518110613fd957613fd9614cbc565b60200260200101515181101561418f57838381518110613ffb57613ffb614cbc565b6020026020010151828151811061401457614014614cbc565b6020026020010151818151811061402d5761402d614cbc565b602002602001015186868581811061404757614047614cbc565b90506020028101906140599190614f45565b8481811061406957614069614cbc565b905060200281019061407b9190614f45565b8381811061408b5761408b614cbc565b905060200201351461417d578282828888878181106140ac576140ac614cbc565b90506020028101906140be9190614f45565b868181106140ce576140ce614cbc565b90506020028101906140e09190614f45565b858181106140f0576140f0614cbc565b9050602002013587878151811061410957614109614cbc565b6020026020010151868151811061412257614122614cbc565b6020026020010151858151811061413b5761413b614cbc565b6020908102919091010151604051632eae91db60e21b81526004810195909552602485019390935260448401919091526064830152608482015260a4016107d9565b8061418781614d21565b915050613fae565b508061419a81614d21565b915050613f89565b50806141ad81614d21565b915050613f7d565b50505050565b60006141c5614425565b604080516020810192909252429082015233606090811b6bffffffffffffffffffffffff191690820152607481018390526094810184905260b40160408051601f1981840301815291905280516020909101209392505050565b6000828152600e602052604081205460ff166142515760405163da77a83f60e01b8152600481018490526024016107d9565b6000838152600e6020526040808220600981015491516343590b8f60e01b8152600160a01b83046001600160401b03166004820152602481018b90523360448201526001600160a01b0389811660648301526084820189905260a4820187905291939291909116906343590b8f9060c4016000604051808303816000875af11580156142e1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526143099190810190615cf6565b905061433f60405180608001604052806000815260200160006001600160a01b0316815260200160008152602001600081525090565b60005b826020015151811015614415578260200151818151811061436557614365614cbc565b602002602001015191507f94bc3a60588238311bdc7da466fa841ceecd4c4812bda794e3b773caa1a44e538c8b8b8b86600001518760200151886040015189606001516040516143fb98979695949392919097885260208801969096526001600160a01b0394851660408801526060870193909352608086019190915290911660a084015260c083015260e08201526101000190565b60405180910390a18061440d81614d21565b915050614342565b5050519998505050505050505050565b60004661a4b1148061443857504661a4ba145b8061444557504662066eed145b8061445257504662066eee145b8061446057504663015f2249145b8061446d57504662066eeb145b156145505760646001600160a01b0316632b407a82600160646001600160a01b031663a3b1b31d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156144c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144e79190615cdd565b6144f19190614d3a565b6040518263ffffffff1660e01b815260040161450f91815260200190565b602060405180830381865afa15801561452c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab49190615cdd565b61455b600143614d3a565b40905090565b82805482825590600052602060002090810192821561459c579160200282015b8281111561459c578235825591602001919060010190614581565b506109809291506146d9565b8280548282559060005260206000209060070160089004810192821561459c5791602002820160005b8382111561461557835183826101000a81548163ffffffff021916908363ffffffff16021790555092602001926004016020816003010492830192600103026145d1565b80156146455782816101000a81549063ffffffff0219169055600401602081600301049283019260010302614615565b50506109809291506146d9565b6040518060e001604052806146656146ee565b815260200161468e60405180606001604052806000815260200160008152602001606081525090565b81526020016146b760405180606001604052806060815260200160608152602001606081525090565b8152602001606081526020016060815260200160608152602001606081525090565b5b8082111561098057600081556001016146da565b6040518060a0016040528060001515815260200161470a614725565b81526000602082018190526040820181905260609091015290565b60405180608001604052806004905b6040805160a0810182526000808252602080830182905292820181905260608201819052608082015282526000199092019101816147345790505090565b6001600160a01b038116811461121d57600080fd5b60006020828403121561479957600080fd5b813561232381614772565b602080825282518282018190526000919060409081850190868401855b828110156147e6578151805185528601518685015292840192908501906001016147c1565b5091979650505050505050565b600081518084526020808501945080840160005b8381101561482357815187529582019590820190600101614807565b509495945050505050565b60208152600061232360208301846147f3565b60006020828403121561485357600080fd5b5035919050565b600081518084526020808501945080840160005b8381101561482357815163ffffffff168752958201959082019060010161486e565b60208152815160208201526000602083015160a060408401526148b660c084018261485a565b90506040840151601f19808584030160608601526148d4838361485a565b925060608601519150808584030160808601526148f1838361485a565b925060808601519150808584030160a08601525061490f828261485a565b95945050505050565b60008083601f84011261492a57600080fd5b5081356001600160401b0381111561494157600080fd5b6020830191508360208260051b850101111561315e57600080fd5b801515811461121d57600080fd5b80356149758161495c565b919050565b60008060008060006060868803121561499257600080fd5b85356001600160401b03808211156149a957600080fd5b6149b589838a01614918565b909750955060208801359150808211156149ce57600080fd5b818801915088601f8301126149e257600080fd5b8135818111156149f157600080fd5b89602061030083028501011115614a0757600080fd5b602083019550809450505050614a1f6040870161496a565b90509295509295909350565b600060208284031215614a3d57600080fd5b81356123238161495c565b60006101008284031215613a7057600080fd5b600080600060608486031215614a7057600080fd5b83356001600160401b0380821115614a8757600080fd5b614a9387838801614a48565b94506020860135915080821115614aa957600080fd5b614ab587838801614a48565b93506040860135915080821115614acb57600080fd5b50840160c08187031215614ade57600080fd5b809150509250925092565b60008060408385031215614afc57600080fd5b8235614b0781614772565b946020939093013593505050565b6000806000806000806000806080898b031215614b3157600080fd5b88356001600160401b0380821115614b4857600080fd5b614b548c838d01614918565b909a50985060208b0135915080821115614b6d57600080fd5b614b798c838d01614918565b909850965060408b0135915080821115614b9257600080fd5b614b9e8c838d01614918565b909650945060608b0135915080821115614bb757600080fd5b50614bc48b828c01614918565b999c989b5096995094979396929594505050565b600080600080600060608688031215614bf057600080fd5b8535614bfb81614772565b945060208601356001600160401b0380821115614c1757600080fd5b614c2389838a01614918565b90965094506040880135915080821115614c3c57600080fd5b50614c4988828901614918565b969995985093965092949392505050565b600060208284031215614c6c57600080fd5b81516123238161495c565b60208082526015908201527426b0b730b3b2b91d102737ba1030b71020b236b4b760591b604082015260600190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176122cd576122cd614cd2565b600082614d1c57634e487b7160e01b600052601260045260246000fd5b500490565b600060018201614d3357614d33614cd2565b5060010190565b818103818111156122cd576122cd614cd2565b80546001600160a01b0319166001600160a01b0392909216919091179055565b634e487b7160e01b600052602160045260246000fd5b6000813563ffffffff811681146122cd57600080fd5b8135614da481614772565b614dae8183614d4d565b50602082013560028110614dc157600080fd5b815460ff60a01b19811660a09290921b60ff60a01b1691821783556040840135614dea8161495c565b61ffff60a01b199190911690911790151560a81b60ff60a81b16178155614e3a614e1660608401614d83565b82805463ffffffff60b01b191660b09290921b63ffffffff60b01b16919091179055565b608082013560018201555050565b600081356122cd81614772565b6001600160401b038116811461121d57600080fd5b600081356122cd81614e55565b8135614e828161495c565b815490151560ff1660ff199190911617815560016020830181830160005b6004811015614ec857614eb38383614d99565b60a09290920191600291909101908301614ea0565b5050505060098101614ee6614ee06102a08501614e48565b82614d4d565b614f22614ef66102c08501614e6a565b82805467ffffffffffffffff60a01b191660a09290921b67ffffffffffffffff60a01b16919091179055565b506102e0820135600a8201555050565b808201808211156122cd576122cd614cd2565b6000808335601e19843603018112614f5c57600080fd5b8301803591506001600160401b03821115614f7657600080fd5b6020019150600581901b360382131561315e57600080fd5b604051608081016001600160401b0381118282101715614fb057614fb0614ca6565b60405290565b604051606081016001600160401b0381118282101715614fb057614fb0614ca6565b604080519081016001600160401b0381118282101715614fb057614fb0614ca6565b604051601f8201601f191681016001600160401b038111828210171561502257615022614ca6565b604052919050565b60006001600160401b0382111561504357615043614ca6565b5060051b60200190565b600061506061505b8461502a565b614ffa565b83815260208082019190600586811b86013681111561507e57600080fd5b865b8181101561510a5780356001600160401b0381111561509f5760008081fd5b880136601f8201126150b15760008081fd5b80356150bf61505b8261502a565b81815290851b820186019086810190368311156150dc5760008081fd5b928701925b828410156150fa578335825292870192908701906150e1565b8952505050948301948301615080565b5092979650505050505050565b600082601f83011261512857600080fd5b8135602061513861505b8361502a565b82815260059290921b8401810191818101908684111561515757600080fd5b8286015b84811015615172578035835291830191830161515b565b509695505050505050565b600061518b61505b8461502a565b83815260208082019190600586811b8601368111156151a957600080fd5b865b8181101561510a5780356001600160401b03808211156151cb5760008081fd5b9089019036601f8301126151df5760008081fd5b81356151ed61505b8261502a565b81815290861b8301870190878101903683111561520a5760008081fd5b8885015b83811015615242578035858111156152265760008081fd5b615234368c838a0101615117565b84525091890191890161520e565b508a52505050958401955083016151ab565b600081518084526020808501945080840160005b838110156148235781516001600160a01b031687529582019590820190600101615268565b600081518084526020808501808196508360051b810191508286016000805b868110156152fb578385038a52825180518087529087019087870190845b818110156152e6578351835292890192918901916001016152ca565b50509a87019a955050918501916001016152ac565b509298975050505050505050565b60008282518085526020808601955060058183821b8501018287016000805b8681101561539557601f1988850381018c5283518051808752908801908887019080891b88018a01865b8281101561537e57858a830301845261536c8286516147f3565b948c0194938c01939150600101615352565b509e8a019e97505050938701935050600101615328565b50919998505050505050505050565b602081526153be6020820183516001600160a01b03169052565b6000602083015160e060408401526153da610100840182615254565b90506040840151601f19808584030160608601526153f883836147f3565b92506060860151915080858403016080860152615415838361528d565b925060808601519150808584030160a08601526154328383615254565b925060a08601519150808584030160c086015261544f8383615309565b925060c08601519150808584030160e08601525061490f8282615309565b60006020828403121561547f57600080fd5b813561232381614e55565b6000815480845260208085019450836000528060002060005b83811015614823578154875295820195600191820191016154a3565b602081526000612323602083018461548a565b600060208083850312156154e557600080fd5b82516001600160401b038111156154fb57600080fd5b8301601f8101851361550c57600080fd5b805161551a61505b8261502a565b81815260079190911b8201830190838101908783111561553957600080fd5b928401925b8284101561559057608084890312156155575760008081fd5b61555f614f8e565b845181528585015186820152604080860151908201526060808601519082015282526080909301929084019061553e565b979650505050505050565b8281526040602082015260006155b4604083018461548a565b949350505050565b600082601f8301126155cd57600080fd5b815160206155dd61505b8361502a565b82815260059290921b840181019181810190868411156155fc57600080fd5b8286015b848110156151725780518352918301918301615600565b60006020828403121561562957600080fd5b81516001600160401b0381111561563f57600080fd5b6155b4848285016155bc565b8183526000602080850194508260005b8581101561482357813561566e81614772565b6001600160a01b03168752958201959082019060010161565b565b81835260006001600160fb1b038311156156a257600080fd5b8260051b80836020870137939093016020019392505050565b6000808335601e198436030181126156d257600080fd5b83016020810192503590506001600160401b038111156156f157600080fd5b8060051b360382131561315e57600080fd5b81835260006020808501808196508560051b810191508460005b878110156147e657828403895261573482886156bb565b61573f868284615689565b9a87019a955050509084019060010161571d565b60408152600061576760408301868861564b565b8281036020840152615590818587615703565b6001600160a01b038916815260a06020820181905260009061579f908301898b61564b565b82810360408401526157b281888a615689565b905082810360608401526157c7818688615703565b9150508260808301529998505050505050505050565b81835260006020808501945084600585811b8701856000805b89811015615395578584038b5261580d838a6156bb565b80865288860181881b87018a0183865b8481101561585757898303601f1901845261583882876156bb565b615843858284615689565b958f019594505050908c019060010161581d565b50509d8a019d9650505092870192506001016157f6565b60a08152600061588260a083018c8e61564b565b8281036020840152615895818b8d615689565b905082810360408401526158aa81898b61564b565b905082810360608401526158bf8187896157dd565b905082810360808401526158d48185876157dd565b9d9c50505050505050505050505050565b6080815260006158f960808301888a61564b565b828103602084015261590c818789615689565b6040840195909552505060600152949350505050565b83815260606020820152600061593b606083018561548a565b828103604084015261594d81856147f3565b9695505050505050565b84815260806020820152600061597060808301866147f3565b828103604084015261598281866147f3565b91505082606083015295945050505050565b600080604083850312156159a757600080fd5b82516001600160401b03808211156159be57600080fd5b818501915085601f8301126159d257600080fd5b815160206159e261505b8361502a565b82815260059290921b84018101918181019089841115615a0157600080fd5b8286015b84811015615a3957805186811115615a1d5760008081fd5b615a2b8c86838b01016155bc565b845250918301918301615a05565b5097909101519698969750505050505050565b600081518084526020808501808196508360051b8101915082860160005b858110156147e6578284038952615a828483516147f3565b98850198935090840190600101615a6a565b60e08082528851908201819052600090602090610100840190828c01845b82811015615ad75781516001600160a01b031684529284019290840190600101615ab2565b50505083810382850152615aeb818b6147f3565b915050615b0360408401896001600160a01b03169052565b8281036060840152615b158188615a4c565b915050615b2a608083018663ffffffff169052565b92151560a082015290151560c09091015295945050505050565b606081526000615b5760608301866147f3565b602083019490945250901515604090910152919050565b60008235605e19833603018112615b8457600080fd5b9190910192915050565b60006060808336031215615ba157600080fd5b615ba9614fb6565b83358152602080850135818301526040808601356001600160401b0380821115615bd257600080fd5b9087019036601f830112615be557600080fd5b8135615bf361505b8261502a565b81815260059190911b83018501908581019036831115615c1257600080fd5b8685015b83811015615cc857803585811115615c2e5760008081fd5b860136819003601f19018b1315615c455760008081fd5b615c4d614fb6565b8982013587811115615c5f5760008081fd5b615c6d368c83860101615117565b8252508882013587811115615c825760008081fd5b615c90368c83860101615117565b8b830152508b82013587811115615ca75760008081fd5b615cb5368c83860101615117565b828b015250845250918701918701615c16565b50948701949094525093979650505050505050565b600060208284031215615cef57600080fd5b5051919050565b60006020808385031215615d0957600080fd5b82516001600160401b0380821115615d2057600080fd5b81850191506040808388031215615d3657600080fd5b615d3e614fd8565b835181528484015183811115615d5357600080fd5b80850194505087601f850112615d6857600080fd5b83519250615d7861505b8461502a565b83815260079390931b84018501928581019089851115615d9757600080fd5b948601945b84861015615df5576080868b031215615db55760008081fd5b615dbd614f8e565b8651815287870151615dce81614772565b81890152868501518582015260608088015190820152825260809095019490860190615d9c565b9582019590955297965050505050505056fea264697066735822122028dbba021bd888975cf9b3d6df5228a2e8a495bc8b7883ea079120b1f59a5c3e64736f6c63430008140033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000004e572433a3bfa336b6396d13afc9f69b58252861000000000000000000000000b1d6eccd0b2ed5ce9b2599cae1386daae2c623c8000000000000000000000000c1b4861697f3cba41c6a8744dee86daf62d3c123000000000000000000000000839f0ffee7d4edc9f3b38b2c2b316ff28da67e4a000000000000000000000000bd025cca38afaa180d0d1b204e80763db361d6f800000000000000000000000037d5b5527866214d103fcc4013e5c0e963de81cc000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d000000000000000000000000b0171b76b413303ad35e5d7cf9e9586480a87f570000000000000000000000006f96e4f04600343c92cb4afe0bc70e8154a2512500000000000000000000000011073afb248b2f2d9f34928c39fe2f37aae5b71a000000000000000000000000ccd05a0fcfc1380e9da27862adb2198e58e0d66f0000000000000000000000004de95c1e202102e22e801590c51d7b979f167fbb00000000000000000000000012b38bb36d4510cd69055b33c2df74c63fadb2f70000000000000000000000006f762a3202793f928aefbd6401a00145e2db94e40000000000000000000000007b769444ebf1b63306d5a7518bde14db0891c1dc000000000000000000000000f689cc15eaa634c7b80114cfb0d11dc8617f52ba000000000000000000000000747910b74d2651a06563c3182838eae4120f4277

-----Decoded View---------------
Arg [0] : _request (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]

-----Encoded View---------------
17 Constructor Arguments found :
Arg [0] : 0000000000000000000000004e572433a3bfa336b6396d13afc9f69b58252861
Arg [1] : 000000000000000000000000b1d6eccd0b2ed5ce9b2599cae1386daae2c623c8
Arg [2] : 000000000000000000000000c1b4861697f3cba41c6a8744dee86daf62d3c123
Arg [3] : 000000000000000000000000839f0ffee7d4edc9f3b38b2c2b316ff28da67e4a
Arg [4] : 000000000000000000000000bd025cca38afaa180d0d1b204e80763db361d6f8
Arg [5] : 00000000000000000000000037d5b5527866214d103fcc4013e5c0e963de81cc
Arg [6] : 000000000000000000000000aec1d99ea44b01071befc08c4ecc9b4f1780678d
Arg [7] : 000000000000000000000000b0171b76b413303ad35e5d7cf9e9586480a87f57
Arg [8] : 0000000000000000000000006f96e4f04600343c92cb4afe0bc70e8154a25125
Arg [9] : 00000000000000000000000011073afb248b2f2d9f34928c39fe2f37aae5b71a
Arg [10] : 000000000000000000000000ccd05a0fcfc1380e9da27862adb2198e58e0d66f
Arg [11] : 0000000000000000000000004de95c1e202102e22e801590c51d7b979f167fbb
Arg [12] : 00000000000000000000000012b38bb36d4510cd69055b33c2df74c63fadb2f7
Arg [13] : 0000000000000000000000006f762a3202793f928aefbd6401a00145e2db94e4
Arg [14] : 0000000000000000000000007b769444ebf1b63306d5a7518bde14db0891c1dc
Arg [15] : 000000000000000000000000f689cc15eaa634c7b80114cfb0d11dc8617f52ba
Arg [16] : 000000000000000000000000747910b74d2651a06563c3182838eae4120f4277


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.