ETH Price: $2,410.85 (-2.87%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60806040170815402023-04-19 15:30:11565 days ago1681918211IN
 Create: CyanVaultV2
0 ETH0.2310794378.63798043

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CyanVaultV2

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 500 runs

Other Settings:
default evmVersion
File 1 of 32 : CyanVaultV2.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

import "./CyanVaultTokenV1.sol";
import "./openzeppelin/ERC1155HolderUpgradeable.sol";

/// @title Cyan Vault - Cyan's staking solution
/// @author Bulgantamir Gankhuyag - <[email protected]>
/// @author Naranbayar Uuganbayar - <[email protected]>
contract CyanVaultV2 is
    AccessControlUpgradeable,
    ReentrancyGuardUpgradeable,
    ERC721HolderUpgradeable,
    ERC1155HolderUpgradeable,
    PausableUpgradeable
{
    using SafeERC20Upgradeable for IERC20Upgradeable;

    bytes32 public constant CYAN_ROLE = keccak256("CYAN_ROLE");
    bytes32 public constant CYAN_PAYMENT_PLAN_ROLE = keccak256("CYAN_PAYMENT_PLAN_ROLE");

    event Deposit(address indexed from, uint256 amount, uint256 tokenAmount);
    event Lend(address indexed to, uint256 amount);
    event Earn(uint256 paymentAmount, uint256 profitAmount);
    event NftDefaulted(uint256 unpaidAmount, uint256 estimatedPriceOfNFT);
    event NftLiquidated(uint256 defaultedAssetsAmount, uint256 soldAmount);
    event Withdraw(address indexed from, uint256 amount, uint256 tokenAmount);
    event GetDefaultedNFT(address indexed to, address indexed contractAddress, uint256 indexed tokenId);
    event GetDefaultedERC1155(
        address indexed to,
        address indexed contractAddress,
        uint256 indexed tokenId,
        uint256 amount
    );
    event UpdatedDefaultedNFTAssetAmount(uint256 amount);
    event UpdatedServiceFeePercent(uint256 from, uint256 to);
    event UpdatedSafetyFundPercent(uint256 from, uint256 to);
    event InitializedServiceFeePercent(uint256 to);
    event InitializedSafetyFundPercent(uint256 to);
    event ReceivedETH(uint256 amount, address indexed from);
    event WithdrewERC20(address indexed token, address to, uint256 amount);
    event CollectedServiceFee(uint256 collectedAmount, uint256 remainingAmount);

    address public _cyanVaultTokenAddress;
    CyanVaultTokenV1 private _cyanVaultTokenContract;

    address private _stEthTokenContract; // unused
    address private _stableSwapSTETHContract; // unused

    // Safety fund percent. (x100)
    uint256 public _safetyFundPercent;

    // Cyan service fee percent. (x100)
    uint256 public _serviceFeePercent;

    // Remaining amount of the currency
    uint256 private REMAINING_AMOUNT;

    // Total loaned amount
    uint256 private LOANED_AMOUNT;

    // Total defaulted NFT amount
    uint256 private DEFAULTED_NFT_ASSET_AMOUNT;

    // Cyan collected service fee
    uint256 private COLLECTED_SERVICE_FEE_AMOUNT;

    address public _currencyTokenAddress;
    IERC20Upgradeable private _currencyToken;
    bool public nonNativeCurrency;

    function initialize(
        address cyanVaultTokenAddress,
        address currencyTokenAddress,
        address cyanPaymentPlanAddress,
        address cyanSuperAdmin,
        uint256 safetyFundPercent,
        uint256 serviceFeePercent
    ) external initializer {
        require(cyanVaultTokenAddress != address(0), "Cyan Vault Token address cannot be zero");
        require(cyanPaymentPlanAddress != address(0), "Cyan Payment Plan address cannot be zero");
        require(cyanSuperAdmin != address(0), "Cyan Super Admin address cannot be zero");
        require(safetyFundPercent <= 10000, "Safety fund percent must be equal or less than 100 percent");
        require(serviceFeePercent <= 200, "Service fee percent must not be greater than 2 percent");

        __AccessControl_init();
        __ReentrancyGuard_init();
        __ERC721Holder_init();
        __Pausable_init();

        _cyanVaultTokenAddress = cyanVaultTokenAddress;
        _cyanVaultTokenContract = CyanVaultTokenV1(_cyanVaultTokenAddress);
        _currencyTokenAddress = currencyTokenAddress;
        if (currencyTokenAddress != address(0)) {
            _currencyToken = IERC20Upgradeable(currencyTokenAddress);
            nonNativeCurrency = true;
        } else {
            nonNativeCurrency = false;
        }
        _safetyFundPercent = safetyFundPercent;
        _serviceFeePercent = serviceFeePercent;

        LOANED_AMOUNT = 0;
        DEFAULTED_NFT_ASSET_AMOUNT = 0;
        REMAINING_AMOUNT = 0;

        _setupRole(DEFAULT_ADMIN_ROLE, cyanSuperAdmin);
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(CYAN_PAYMENT_PLAN_ROLE, cyanPaymentPlanAddress);

        emit InitializedServiceFeePercent(serviceFeePercent);
        emit InitializedSafetyFundPercent(safetyFundPercent);
    }

    // User stakes
    function deposit(uint256 amount) external payable nonReentrant whenNotPaused {
        require(amount > 0, "Must deposit more than zero");
        if (nonNativeCurrency) {
            require(msg.value == 0, "Invalid deposit amount");
        } else {
            require(msg.value == amount, "Invalid deposit amount");
        }
        // Cyan collecting service fee from deposits
        uint256 cyanServiceFee = (amount * _serviceFeePercent) / 10000;

        uint256 depositedAmount = amount - cyanServiceFee;
        uint256 mintAmount = calculateTokenByCurrency(depositedAmount);

        if (nonNativeCurrency) {
            _currencyToken.safeTransferFrom(msg.sender, address(this), amount);
        }
        REMAINING_AMOUNT += depositedAmount;
        COLLECTED_SERVICE_FEE_AMOUNT += cyanServiceFee;
        _cyanVaultTokenContract.mint(msg.sender, mintAmount);

        emit Deposit(msg.sender, depositedAmount, mintAmount);
    }

    // Cyan lends money from Vault to do BNPL or PAWN
    function lend(address to, uint256 amount) external nonReentrant whenNotPaused onlyRole(CYAN_PAYMENT_PLAN_ROLE) {
        require(to != address(0), "to address cannot be zero");

        uint256 maxWithdrableAmount = getMaxWithdrawableAmount();
        require(amount <= maxWithdrableAmount, "Not enough balance in the Vault");

        LOANED_AMOUNT += amount;
        REMAINING_AMOUNT -= amount;

        safeCurrencyTransfer(to, amount);

        emit Lend(to, amount);
    }

    // Cyan Payment Plan contract transfers paid amount back to Vault
    function earn(uint256 amount, uint256 profit) external payable nonReentrant onlyRole(CYAN_PAYMENT_PLAN_ROLE) {
        if (nonNativeCurrency) {
            require(msg.value == 0, "Wrong tranfer amount");
        } else {
            require(msg.value == amount + profit, "Wrong tranfer amount");
        }

        if (nonNativeCurrency) {
            _currencyToken.safeTransferFrom(msg.sender, address(this), amount + profit);
        }
        REMAINING_AMOUNT += amount + profit;
        if (LOANED_AMOUNT >= amount) {
            LOANED_AMOUNT -= amount;
        } else {
            LOANED_AMOUNT = 0;
        }

        emit Earn(amount, profit);
    }

    // When BNPL or PAWN plan defaults
    function nftDefaulted(uint256 unpaidAmount, uint256 estimatedPriceOfNFT)
        external
        nonReentrant
        onlyRole(CYAN_PAYMENT_PLAN_ROLE)
    {
        DEFAULTED_NFT_ASSET_AMOUNT += estimatedPriceOfNFT;

        if (LOANED_AMOUNT >= unpaidAmount) {
            LOANED_AMOUNT -= unpaidAmount;
        } else {
            LOANED_AMOUNT = 0;
        }

        emit NftDefaulted(unpaidAmount, estimatedPriceOfNFT);
    }

    // Liquidating defaulted BNPL or PAWN token and tranferred sold amount to Vault
    function liquidateNFT(uint256 liquidatedAmount, uint256 totalDefaultedNFTAmount)
        external
        payable
        whenNotPaused
        onlyRole(CYAN_ROLE)
    {
        if (nonNativeCurrency) {
            require(msg.value == 0, "Invalid deposit amount");
        } else {
            require(msg.value == liquidatedAmount, "Invalid deposit amount");
        }
        if (nonNativeCurrency) {
            _currencyToken.safeTransferFrom(msg.sender, address(this), liquidatedAmount);
        }

        REMAINING_AMOUNT += liquidatedAmount;
        DEFAULTED_NFT_ASSET_AMOUNT = totalDefaultedNFTAmount;

        emit NftLiquidated(liquidatedAmount, totalDefaultedNFTAmount);
    }

    // User unstakes tokenAmount of tokens and receives withdrawAmount of currency
    function withdraw(uint256 tokenAmount) external nonReentrant whenNotPaused {
        require(tokenAmount > 0, "Non-positive token amount");

        uint256 withdrawableTokenBalance = getWithdrawableBalance(msg.sender);
        require(tokenAmount <= withdrawableTokenBalance, "Not enough active balance in Cyan Vault");

        uint256 withdrawAmount = calculateCurrencyByToken(tokenAmount);

        REMAINING_AMOUNT -= withdrawAmount;
        _cyanVaultTokenContract.burn(msg.sender, tokenAmount);
        safeCurrencyTransfer(msg.sender, withdrawAmount);

        emit Withdraw(msg.sender, withdrawAmount, tokenAmount);
    }

    // Cyan updating total amount of defaulted NFT assets
    function updateDefaultedNFTAssetAmount(uint256 amount) external whenNotPaused onlyRole(CYAN_ROLE) {
        DEFAULTED_NFT_ASSET_AMOUNT = amount;
        emit UpdatedDefaultedNFTAssetAmount(amount);
    }

    // Get defaulted NFT from Vault to Cyan Admin account
    function getDefaultedNFT(address contractAddress, uint256 tokenId)
        external
        nonReentrant
        whenNotPaused
        onlyRole(CYAN_ROLE)
    {
        require(contractAddress != address(0), "Zero contract address");

        IERC721 originalContract = IERC721(contractAddress);

        require(originalContract.ownerOf(tokenId) == address(this), "Vault is not the owner of the token");

        originalContract.safeTransferFrom(address(this), msg.sender, tokenId);

        emit GetDefaultedNFT(msg.sender, contractAddress, tokenId);
    }

    // Get defaulted ERC1155 from Vault to Cyan Admin account
    function getDefaultedERC1155(
        address contractAddress,
        uint256 tokenId,
        uint256 amount
    ) external nonReentrant whenNotPaused onlyRole(CYAN_ROLE) {
        require(contractAddress != address(0), "Zero contract address");
        IERC1155 originalContract = IERC1155(contractAddress);
        require(originalContract.balanceOf(address(this), tokenId) >= amount, "Vault does not have enough token");

        originalContract.safeTransferFrom(address(this), msg.sender, tokenId, amount, bytes(""));

        emit GetDefaultedERC1155(msg.sender, contractAddress, tokenId, amount);
    }

    function getWithdrawableBalance(address user) public view returns (uint256) {
        uint256 tokenBalance = _cyanVaultTokenContract.balanceOf(user);
        uint256 currencyAmountForToken = calculateCurrencyByToken(tokenBalance);
        uint256 maxWithdrawableAmount = getMaxWithdrawableAmount();

        if (currencyAmountForToken <= maxWithdrawableAmount) {
            return tokenBalance;
        }
        return calculateTokenByCurrency(maxWithdrawableAmount);
    }

    function getMaxWithdrawableAmount() public view returns (uint256) {
        uint256 util = ((LOANED_AMOUNT + DEFAULTED_NFT_ASSET_AMOUNT) * _safetyFundPercent) / 10000;
        if (REMAINING_AMOUNT > util) {
            return REMAINING_AMOUNT - util;
        }
        return 0;
    }

    function getCurrentAssetAmounts()
        external
        view
        returns (
            uint256,
            uint256,
            uint256,
            uint256
        )
    {
        return (REMAINING_AMOUNT, LOANED_AMOUNT, DEFAULTED_NFT_ASSET_AMOUNT, COLLECTED_SERVICE_FEE_AMOUNT);
    }

    function getCurrencyAddress() external view returns (address) {
        return _currencyTokenAddress;
    }

    function calculateTokenByCurrency(uint256 amount) public view returns (uint256) {
        (uint256 totalCurrency, uint256 totalToken) = getTotalCurrencyAndToken();
        if (totalCurrency == 0) return amount;
        return (amount * totalToken) / totalCurrency;
    }

    function calculateCurrencyByToken(uint256 amount) public view returns (uint256) {
        (uint256 totalCurrency, uint256 totalToken) = getTotalCurrencyAndToken();
        if (totalToken == 0) return amount;
        return (amount * totalCurrency) / totalToken;
    }

    function getTotalCurrencyAndToken() private view returns (uint256, uint256) {
        uint256 totalCurrency = REMAINING_AMOUNT + LOANED_AMOUNT + DEFAULTED_NFT_ASSET_AMOUNT;
        uint256 totalToken = _cyanVaultTokenContract.totalSupply();

        return (totalCurrency, totalToken);
    }

    function updateSafetyFundPercent(uint256 safetyFundPercent) external nonReentrant onlyRole(DEFAULT_ADMIN_ROLE) {
        require(safetyFundPercent <= 10000, "Safety fund percent must be equal or less than 100 percent");
        emit UpdatedSafetyFundPercent(_safetyFundPercent, safetyFundPercent);
        _safetyFundPercent = safetyFundPercent;
    }

    function updateServiceFeePercent(uint256 serviceFeePercent) external nonReentrant onlyRole(DEFAULT_ADMIN_ROLE) {
        require(serviceFeePercent <= 200, "Service fee percent must not be greater than 2 percent");
        emit UpdatedServiceFeePercent(_serviceFeePercent, serviceFeePercent);
        _serviceFeePercent = serviceFeePercent;
    }

    function collectServiceFee(uint256 amount) external nonReentrant onlyRole(DEFAULT_ADMIN_ROLE) {
        require(amount <= COLLECTED_SERVICE_FEE_AMOUNT, "Not enough collected service fee");
        COLLECTED_SERVICE_FEE_AMOUNT -= amount;

        safeCurrencyTransfer(msg.sender, amount);

        emit CollectedServiceFee(amount, COLLECTED_SERVICE_FEE_AMOUNT);
    }

    function safeCurrencyTransfer(address to, uint256 amount) private {
        if (nonNativeCurrency) {
            _currencyToken.safeTransfer(to, amount);
        } else {
            (bool success, ) = payable(to).call{value: amount}("");
            require(success, "Payment failed: Native token transfer");
        }
    }

    function withdrawAirDroppedERC20(address contractAddress, uint256 amount)
        external
        nonReentrant
        onlyRole(CYAN_ROLE)
    {
        require(contractAddress != _currencyTokenAddress, "Cannot withdraw currency token");
        IERC20Upgradeable erc20Contract = IERC20Upgradeable(contractAddress);
        require(erc20Contract.balanceOf(address(this)) >= amount, "ERC20 balance not enough");
        erc20Contract.safeTransfer(msg.sender, amount);

        emit WithdrewERC20(contractAddress, msg.sender, amount);
    }

    function withdrawApprovedERC20(
        address contractAddress,
        address from,
        uint256 amount
    ) external nonReentrant onlyRole(CYAN_ROLE) {
        require(contractAddress != _currencyTokenAddress, "Cannot withdraw currency token");
        IERC20Upgradeable erc20Contract = IERC20Upgradeable(contractAddress);
        require(erc20Contract.allowance(from, address(this)) >= amount, "ERC20 allowance not enough");
        erc20Contract.safeTransferFrom(from, msg.sender, amount);

        emit WithdrewERC20(contractAddress, msg.sender, amount);
    }

    function pause() external nonReentrant onlyRole(DEFAULT_ADMIN_ROLE) {
        _pause();
    }

    function unpause() external nonReentrant onlyRole(DEFAULT_ADMIN_ROLE) {
        _unpause();
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(AccessControlUpgradeable, ERC1155ReceiverUpgradeable)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }
}

File 2 of 32 : CyanVaultTokenV1.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract CyanVaultTokenV1 is AccessControl, ERC20 {
    bytes32 public constant CYAN_VAULT_ROLE = keccak256("CYAN_VAULT_ROLE");
    event BurnedAdminToken(uint256 amount);

    constructor(
        string memory _name,
        string memory _symbol,
        address cyanSuperAdmin
    ) ERC20(_name, _symbol) {
        _setupRole(DEFAULT_ADMIN_ROLE, cyanSuperAdmin);
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    function mint(address to, uint256 amount) external onlyRole(CYAN_VAULT_ROLE) {
        require(to != address(0), "Mint to the zero address");
        _mint(to, amount);
    }

    function burn(address from, uint256 amount) external onlyRole(CYAN_VAULT_ROLE) {
        require(balanceOf(from) >= amount, "Balance not enough");
        _burn(from, amount);
    }

    function burnAdminToken(uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
        require(balanceOf(msg.sender) >= amount, "Balance not enough");
        _burn(msg.sender, amount);

        emit BurnedAdminToken(amount);
    }
}

File 3 of 32 : ERC1155HolderUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)

pragma solidity ^0.8.0;

import "./ERC1155ReceiverUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

/**
 * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
 *
 * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
 * stuck.
 *
 * @dev _Available since v3.1._
 */
contract ERC1155HolderUpgradeable is Initializable, ERC1155ReceiverUpgradeable {
    function __ERC1155Holder_init() internal onlyInitializing {}

    function __ERC1155Holder_init_unchained() internal onlyInitializing {}

    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}

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

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

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

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

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

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

/**
 * @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 ReentrancyGuardUpgradeable is Initializable {
    // 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;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _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;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

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

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @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.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _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());
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 7 of 32 : 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 8 of 32 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

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

    /**
     * @dev 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 9 of 32 : IERC20Upgradeable.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 IERC20Upgradeable {
    /**
     * @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 10 of 32 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

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

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

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

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

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

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

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

    /**
     * @dev Internal function that returns the initialized version. Returns `_initialized`
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Internal function that returns the initialized version. Returns `_initializing`
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

File 11 of 32 : ERC721HolderUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
 */
contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable {
    function __ERC721Holder_init() internal onlyInitializing {
    }

    function __ERC721Holder_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 12 of 32 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../extensions/draft-IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";

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

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

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

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

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

    function safeDecreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20PermitUpgradeable token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

File 13 of 32 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

File 14 of 32 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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.zeppelin.solutions/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;
        }
        _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;
        _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;
        }
        _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 15 of 32 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_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) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

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

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @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] = _HEX_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 16 of 32 : 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 17 of 32 : 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 18 of 32 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 19 of 32 : 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 20 of 32 : 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 21 of 32 : 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 22 of 32 : ERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155ReceiverUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155ReceiverUpgradeable is Initializable, ERC165Upgradeable, IERC1155ReceiverUpgradeable {
    function __ERC1155Receiver_init() internal onlyInitializing {}

    function __ERC1155Receiver_init_unchained() internal onlyInitializing {}

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

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 25 of 32 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

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

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 31 of 32 : IERC721ReceiverUpgradeable.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 IERC721ReceiverUpgradeable {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 32 of 32 : draft-IERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20PermitUpgradeable {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

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

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"collectedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"remainingAmount","type":"uint256"}],"name":"CollectedServiceFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"profitAmount","type":"uint256"}],"name":"Earn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"contractAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"GetDefaultedERC1155","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"contractAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"GetDefaultedNFT","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"to","type":"uint256"}],"name":"InitializedSafetyFundPercent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"to","type":"uint256"}],"name":"InitializedServiceFeePercent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Lend","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"unpaidAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"estimatedPriceOfNFT","type":"uint256"}],"name":"NftDefaulted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"defaultedAssetsAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"soldAmount","type":"uint256"}],"name":"NftLiquidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"}],"name":"ReceivedETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UpdatedDefaultedNFTAssetAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"from","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"to","type":"uint256"}],"name":"UpdatedSafetyFundPercent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"from","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"to","type":"uint256"}],"name":"UpdatedServiceFeePercent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrewERC20","type":"event"},{"inputs":[],"name":"CYAN_PAYMENT_PLAN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CYAN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_currencyTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_cyanVaultTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_safetyFundPercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_serviceFeePercent","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calculateCurrencyByToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calculateTokenByCurrency","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"collectServiceFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"profit","type":"uint256"}],"name":"earn","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getCurrencyAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentAssetAmounts","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getDefaultedERC1155","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getDefaultedNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getMaxWithdrawableAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getWithdrawableBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"cyanVaultTokenAddress","type":"address"},{"internalType":"address","name":"currencyTokenAddress","type":"address"},{"internalType":"address","name":"cyanPaymentPlanAddress","type":"address"},{"internalType":"address","name":"cyanSuperAdmin","type":"address"},{"internalType":"uint256","name":"safetyFundPercent","type":"uint256"},{"internalType":"uint256","name":"serviceFeePercent","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"lend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"liquidatedAmount","type":"uint256"},{"internalType":"uint256","name":"totalDefaultedNFTAmount","type":"uint256"}],"name":"liquidateNFT","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"unpaidAmount","type":"uint256"},{"internalType":"uint256","name":"estimatedPriceOfNFT","type":"uint256"}],"name":"nftDefaulted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nonNativeCurrency","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","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":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"updateDefaultedNFTAssetAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"safetyFundPercent","type":"uint256"}],"name":"updateSafetyFundPercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"serviceFeePercent","type":"uint256"}],"name":"updateServiceFeePercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawAirDroppedERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawApprovedERC20","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50613434806100206000396000f3fe6080604052600436106102565760003560e01c80638d676a9211610149578063c7e01ad6116100c6578063e895e1171161008a578063f23a6e6111610064578063f23a6e611461077c578063f61e0268146107a8578063f7f57ad8146107c857600080fd5b8063e895e1171461071c578063e8c5c6d31461073c578063ec8e83c01461075c57600080fd5b8063c7e01ad61461065d578063c9d375f41461067d578063d23f9a9a146106ba578063d547741f146106dc578063d7c41c79146106fc57600080fd5b8063a930daf41161010d578063a930daf4146105aa578063b5a68b81146105de578063b6b55f25146105ff578063bc197c8114610612578063bfe0c27e1461063e57600080fd5b80638d676a92146104fc57806391d148541461051c578063a217fddf14610562578063a2fb342d14610577578063a6617e781461059757600080fd5b806345e1aa3c116101d75780637bc565581161019b5780637bc565581461044e578063823cbb091461046e578063843592d3146104a75780638456cb59146104c757806387acb02c146104dc57600080fd5b806345e1aa3c146103ca57806346fe120e146103ea5780635c975abb1461040c578063643840f2146104245780636d54294b1461043757600080fd5b80632e1a7d4d1161021e5780632e1a7d4d146103335780632f2ff15d1461035557806336568abe146103755780633f4ba83a14610395578063404da783146103aa57600080fd5b806301ffc9a71461025b578063037d69f5146102905780630bdb92c0146102b5578063150b7a02146102ca578063248a9ca314610303575b600080fd5b34801561026757600080fd5b5061027b610276366004612cdb565b6107e8565b60405190151581526020015b60405180910390f35b34801561029c57600080fd5b506102a76101325481565b604051908152602001610287565b3480156102c157600080fd5b506102a76107f9565b3480156102d657600080fd5b506102ea6102e5366004612dd1565b610853565b6040516001600160e01b03199091168152602001610287565b34801561030f57600080fd5b506102a761031e366004612e3d565b60009081526065602052604090206001015490565b34801561033f57600080fd5b5061035361034e366004612e3d565b610864565b005b34801561036157600080fd5b50610353610370366004612e56565b610a14565b34801561038157600080fd5b50610353610390366004612e56565b610a3e565b3480156103a157600080fd5b50610353610aca565b3480156103b657600080fd5b506103536103c5366004612e3d565b610af2565b3480156103d657600080fd5b506103536103e5366004612e86565b610bcb565b3480156103f657600080fd5b506102a76000805160206133df83398151915281565b34801561041857600080fd5b5060fb5460ff1661027b565b610353610432366004612ec7565b610d71565b34801561044357600080fd5b506102a76101315481565b34801561045a57600080fd5b50610353610469366004612ec7565b610f1b565b34801561047a57600080fd5b5061012d5461048f906001600160a01b031681565b6040516001600160a01b039091168152602001610287565b3480156104b357600080fd5b506102a76104c2366004612ee9565b610fca565b3480156104d357600080fd5b5061035361107a565b3480156104e857600080fd5b506103536104f7366004612f06565b611095565b34801561050857600080fd5b50610353610517366004612f32565b611233565b34801561052857600080fd5b5061027b610537366004612e56565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561056e57600080fd5b506102a7600081565b34801561058357600080fd5b50610353610592366004612f06565b611434565b6103536105a5366004612ec7565b611598565b3480156105b657600080fd5b506102a77f507793b6688804c17fc033a24c049858152fd713503d8768de9c67313c5a3afd81565b3480156105ea57600080fd5b506101375461048f906001600160a01b031681565b61035361060d366004612e3d565b6116e7565b34801561061e57600080fd5b506102ea61062d366004612fdc565b63bc197c8160e01b95945050505050565b34801561064a57600080fd5b50610137546001600160a01b031661048f565b34801561066957600080fd5b50610353610678366004612e3d565b611935565b34801561068957600080fd5b5061013354610134546101355461013654604080519485526020850193909352918301526060820152608001610287565b3480156106c657600080fd5b506101385461027b90600160a01b900460ff1681565b3480156106e857600080fd5b506103536106f7366004612e56565b611a0d565b34801561070857600080fd5b5061035361071736600461308a565b611a32565b34801561072857600080fd5b50610353610737366004612e3d565b611eeb565b34801561074857600080fd5b506102a7610757366004612e3d565b611f48565b34801561076857600080fd5b50610353610777366004612f06565b611f7e565b34801561078857600080fd5b506102ea6107973660046130f8565b63f23a6e6160e01b95945050505050565b3480156107b457600080fd5b506102a76107c3366004612e3d565b61216d565b3480156107d457600080fd5b506103536107e3366004612e3d565b612199565b60006107f38261226b565b92915050565b6000806127106101315461013554610134546108159190613177565b61081f919061318a565b61082991906131a1565b90508061013354111561084b57806101335461084591906131c3565b91505090565b600091505090565b630a85bd0160e11b5b949350505050565b61086c612290565b6108746122e9565b600081116108c95760405162461bcd60e51b815260206004820152601960248201527f4e6f6e2d706f73697469766520746f6b656e20616d6f756e740000000000000060448201526064015b60405180910390fd5b60006108d433610fca565b9050808211156109365760405162461bcd60e51b815260206004820152602760248201527f4e6f7420656e6f756768206163746976652062616c616e636520696e204379616044820152661b8815985d5b1d60ca1b60648201526084016108c0565b60006109418361216d565b905080610133600082825461095691906131c3565b909155505061012e54604051632770a7eb60e21b8152336004820152602481018590526001600160a01b0390911690639dc29fac90604401600060405180830381600087803b1580156109a857600080fd5b505af11580156109bc573d6000803e3d6000fd5b505050506109ca338261233c565b604080518281526020810185905233917ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568910160405180910390a25050610a116001609755565b50565b600082815260656020526040902060010154610a2f8161241f565b610a398383612429565b505050565b6001600160a01b0381163314610abc5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016108c0565b610ac682826124cb565b5050565b610ad2612290565b6000610add8161241f565b610ae561254e565b50610af06001609755565b565b610afa612290565b6000610b058161241f565b612710821115610b7d5760405162461bcd60e51b815260206004820152603a60248201527f5361666574792066756e642070657263656e74206d757374206265206571756160448201527f6c206f72206c657373207468616e203130302070657263656e7400000000000060648201526084016108c0565b6101315460408051918252602082018490527feeeb5af1c3ceeab4fb8414a031926b58ba0e9b17d71c2ade80057757e6cb0260910160405180910390a150610131819055610a116001609755565b610bd3612290565b6000805160206133df833981519152610beb8161241f565b610137546001600160a01b0390811690851603610c4a5760405162461bcd60e51b815260206004820152601e60248201527f43616e6e6f742077697468647261772063757272656e637920746f6b656e000060448201526064016108c0565b604051636eb1769f60e11b81526001600160a01b0384811660048301523060248301528591849183169063dd62ed3e90604401602060405180830381865afa158015610c9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cbe91906131d6565b1015610d0c5760405162461bcd60e51b815260206004820152601a60248201527f455243323020616c6c6f77616e6365206e6f7420656e6f75676800000000000060448201526064016108c0565b610d216001600160a01b0382168533866125a0565b60408051338152602081018590526001600160a01b038716917fa14466d832b5a1ff01be72c58e51196498a8e10751ab9c227fe73c4730dedc41910160405180910390a25050610a396001609755565b610d79612290565b7f507793b6688804c17fc033a24c049858152fd713503d8768de9c67313c5a3afd610da38161241f565b61013854600160a01b900460ff1615610e00573415610dfb5760405162461bcd60e51b815260206004820152601460248201527315dc9bdb99c81d1c985b99995c88185b5bdd5b9d60621b60448201526064016108c0565b610e4f565b610e0a8284613177565b3414610e4f5760405162461bcd60e51b815260206004820152601460248201527315dc9bdb99c81d1c985b99995c88185b5bdd5b9d60621b60448201526064016108c0565b61013854600160a01b900460ff1615610e8657610e863330610e718587613177565b610138546001600160a01b03169291906125a0565b610e908284613177565b6101336000828254610ea29190613177565b9091555050610134548311610ecf57826101346000828254610ec491906131c3565b90915550610ed69050565b6000610134555b60408051848152602081018490527f5850d758e6151f474c145f4f59e8cb315c3f1a9fe82d96dff5bd2d48b5a76f9b91015b60405180910390a150610ac66001609755565b610f23612290565b7f507793b6688804c17fc033a24c049858152fd713503d8768de9c67313c5a3afd610f4d8161241f565b816101356000828254610f609190613177565b9091555050610134548311610f8d57826101346000828254610f8291906131c3565b90915550610f949050565b6000610134555b60408051848152602081018490527f9b8376ea2c5e9863179edf3c51616d423d51e32eea3ca2e7a02ce8a3d3aa01429101610f08565b61012e546040516370a0823160e01b81526001600160a01b03838116600483015260009283929116906370a0823190602401602060405180830381865afa158015611019573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103d91906131d6565b9050600061104a8261216d565b905060006110566107f9565b90508082116110685750909392505050565b61107181611f48565b95945050505050565b611082612290565b600061108d8161241f565b610ae5612626565b61109d612290565b6000805160206133df8339815191526110b58161241f565b610137546001600160a01b03908116908416036111145760405162461bcd60e51b815260206004820152601e60248201527f43616e6e6f742077697468647261772063757272656e637920746f6b656e000060448201526064016108c0565b6040516370a0823160e01b8152306004820152839083906001600160a01b038316906370a0823190602401602060405180830381865afa15801561115c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118091906131d6565b10156111ce5760405162461bcd60e51b815260206004820152601860248201527f45524332302062616c616e6365206e6f7420656e6f756768000000000000000060448201526064016108c0565b6111e26001600160a01b0382163385612663565b60408051338152602081018590526001600160a01b038616917fa14466d832b5a1ff01be72c58e51196498a8e10751ab9c227fe73c4730dedc4191015b60405180910390a25050610ac66001609755565b61123b612290565b6112436122e9565b6000805160206133df83398151915261125b8161241f565b6001600160a01b0384166112a95760405162461bcd60e51b81526020600482015260156024820152745a65726f20636f6e7472616374206164647265737360581b60448201526064016108c0565b604051627eeac760e11b815230600482015260248101849052849083906001600160a01b0383169062fdd58e90604401602060405180830381865afa1580156112f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131a91906131d6565b10156113685760405162461bcd60e51b815260206004820181905260248201527f5661756c7420646f6573206e6f74206861766520656e6f75676820746f6b656e60448201526064016108c0565b60408051602081018252600081529051637921219560e11b81526001600160a01b0383169163f242432a916113a891309133918a918a919060040161323f565b600060405180830381600087803b1580156113c257600080fd5b505af11580156113d6573d6000803e3d6000fd5b5050505083856001600160a01b0316336001600160a01b03167f07394b3fad6920c344c25134bb6cf65ee1313a0296830f2043653661beb4136d8660405161142091815260200190565b60405180910390a45050610a396001609755565b61143c612290565b6114446122e9565b7f507793b6688804c17fc033a24c049858152fd713503d8768de9c67313c5a3afd61146e8161241f565b6001600160a01b0383166114c45760405162461bcd60e51b815260206004820152601960248201527f746f20616464726573732063616e6e6f74206265207a65726f0000000000000060448201526064016108c0565b60006114ce6107f9565b9050808311156115205760405162461bcd60e51b815260206004820152601f60248201527f4e6f7420656e6f7567682062616c616e636520696e20746865205661756c740060448201526064016108c0565b8261013460008282546115339190613177565b9250508190555082610133600082825461154d91906131c3565b9091555061155d9050848461233c565b836001600160a01b03167f41b123d2493c7b2067b8b7f49cf71532523d83ead11494d793531ece1fd4d0468460405161121f91815260200190565b6115a06122e9565b6000805160206133df8339815191526115b88161241f565b61013854600160a01b900460ff16156116175734156116125760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a590819195c1bdcda5d08185b5bdd5b9d60521b60448201526064016108c0565b61165f565b82341461165f5760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a590819195c1bdcda5d08185b5bdd5b9d60521b60448201526064016108c0565b61013854600160a01b900460ff161561168b576101385461168b906001600160a01b03163330866125a0565b82610133600082825461169e9190613177565b909155505061013582905560408051848152602081018490527f3310b86842fde17f760398e1219d8d61221bdffe0c33e5635830eaaf2f213ddb910160405180910390a1505050565b6116ef612290565b6116f76122e9565b600081116117475760405162461bcd60e51b815260206004820152601b60248201527f4d757374206465706f736974206d6f7265207468616e207a65726f000000000060448201526064016108c0565b61013854600160a01b900460ff16156117a65734156117a15760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a590819195c1bdcda5d08185b5bdd5b9d60521b60448201526064016108c0565b6117ee565b8034146117ee5760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a590819195c1bdcda5d08185b5bdd5b9d60521b60448201526064016108c0565b60006127106101325483611802919061318a565b61180c91906131a1565b9050600061181a82846131c3565b9050600061182782611f48565b61013854909150600160a01b900460ff16156118565761013854611856906001600160a01b03163330876125a0565b8161013360008282546118699190613177565b925050819055508261013660008282546118839190613177565b909155505061012e546040516340c10f1960e01b8152336004820152602481018390526001600160a01b03909116906340c10f1990604401600060405180830381600087803b1580156118d557600080fd5b505af11580156118e9573d6000803e3d6000fd5b505060408051858152602081018590523393507f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1592500160405180910390a2505050610a116001609755565b61193d612290565b60006119488161241f565b60c88211156119bf5760405162461bcd60e51b815260206004820152603660248201527f53657276696365206665652070657263656e74206d757374206e6f742062652060448201527f67726561746572207468616e20322070657263656e740000000000000000000060648201526084016108c0565b6101325460408051918252602082018490527f67ea558a1975802c885d7e38bc96ea4f925e1d5d86c8f53ad1a8387906297a90910160405180910390a150610132819055610a116001609755565b600082815260656020526040902060010154611a288161241f565b610a3983836124cb565b600054610100900460ff1615808015611a525750600054600160ff909116105b80611a6c5750303b158015611a6c575060005460ff166001145b611ade5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016108c0565b6000805460ff191660011790558015611b01576000805461ff0019166101001790555b6001600160a01b038716611b675760405162461bcd60e51b815260206004820152602760248201527f4379616e205661756c7420546f6b656e20616464726573732063616e6e6f74206044820152666265207a65726f60c81b60648201526084016108c0565b6001600160a01b038516611bce5760405162461bcd60e51b815260206004820152602860248201527f4379616e205061796d656e7420506c616e20616464726573732063616e6e6f74604482015267206265207a65726f60c01b60648201526084016108c0565b6001600160a01b038416611c345760405162461bcd60e51b815260206004820152602760248201527f4379616e2053757065722041646d696e20616464726573732063616e6e6f74206044820152666265207a65726f60c81b60648201526084016108c0565b612710831115611cac5760405162461bcd60e51b815260206004820152603a60248201527f5361666574792066756e642070657263656e74206d757374206265206571756160448201527f6c206f72206c657373207468616e203130302070657263656e7400000000000060648201526084016108c0565b60c8821115611d235760405162461bcd60e51b815260206004820152603660248201527f53657276696365206665652070657263656e74206d757374206e6f742062652060448201527f67726561746572207468616e20322070657263656e740000000000000000000060648201526084016108c0565b611d2b612693565b611d336126ba565b611d3b612693565b611d436126e9565b61012d80546001600160a01b03808a1673ffffffffffffffffffffffffffffffffffffffff19928316811790935561012e805483169093179092556101378054928916929091168217905515611dc857610138805474ffffffffffffffffffffffffffffffffffffffffff19166001600160a01b03881617600160a01b179055611dd7565b610138805460ff60a01b191690555b6101318390556101328290556000610134819055610135819055610133819055611e019085612718565b611e0c600033612718565b611e367f507793b6688804c17fc033a24c049858152fd713503d8768de9c67313c5a3afd86612718565b6040518281527f9946eeb5f4ca76305e83426173176fffd327e46ff4ac0e853f1806a8a6accb879060200160405180910390a16040518381527f183d0700d6a3fbe1d9843804c26a1fad21802c73c8976b4945f947600230b2679060200160405180910390a18015611ee2576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b611ef36122e9565b6000805160206133df833981519152611f0b8161241f565b6101358290556040518281527f897bbee971dc0a064ca7156866801787a25be91f42b7aab8e91a953974d274a19060200160405180910390a15050565b6000806000611f55612722565b9150915081600003611f6957509192915050565b81611f74828661318a565b61085c91906131a1565b611f86612290565b611f8e6122e9565b6000805160206133df833981519152611fa68161241f565b6001600160a01b038316611ff45760405162461bcd60e51b81526020600482015260156024820152745a65726f20636f6e7472616374206164647265737360581b60448201526064016108c0565b6040516331a9108f60e11b815260048101839052839030906001600160a01b03831690636352211e90602401602060405180830381865afa15801561203d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120619190613277565b6001600160a01b0316146120c35760405162461bcd60e51b815260206004820152602360248201527f5661756c74206973206e6f7420746865206f776e6572206f662074686520746f60448201526235b2b760e91b60648201526084016108c0565b604051632142170760e11b8152306004820152336024820152604481018490526001600160a01b038216906342842e0e90606401600060405180830381600087803b15801561211157600080fd5b505af1158015612125573d6000803e3d6000fd5b50506040518592506001600160a01b038716915033907f8c6ca3d9b6a0c7bebfa8490b1b23bd368f29583611fadb449ff9ff56a33d94dd90600090a45050610ac66001609755565b600080600061217a612722565b915091508060000361218e57509192915050565b80611f74838661318a565b6121a1612290565b60006121ac8161241f565b610136548211156121ff5760405162461bcd60e51b815260206004820181905260248201527f4e6f7420656e6f75676820636f6c6c656374656420736572766963652066656560448201526064016108c0565b81610136600082825461221291906131c3565b909155506122229050338361233c565b610136546040805184815260208101929092527fe5b03f691ac58372304b24b638e1a4e106a14e996edc607b7a21ad492e2ca7c9910160405180910390a150610a116001609755565b60006001600160e01b03198216630271189760e51b14806107f357506107f3826127ce565b6002609754036122e25760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108c0565b6002609755565b60fb5460ff1615610af05760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064016108c0565b61013854600160a01b900460ff16156123675761013854610ac6906001600160a01b03168383612663565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146123b4576040519150601f19603f3d011682016040523d82523d6000602084013e6123b9565b606091505b5050905080610a395760405162461bcd60e51b815260206004820152602560248201527f5061796d656e74206661696c65643a204e617469766520746f6b656e207472616044820152643739b332b960d91b60648201526084016108c0565b6001609755565b610a118133612803565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16610ac65760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556124873390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff1615610ac65760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b612556612878565b60fb805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040516001600160a01b03808516602483015283166044820152606481018290526126209085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b0319909316929092179091526128ca565b50505050565b61262e6122e9565b60fb805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586125833390565b6040516001600160a01b038316602482015260448101829052610a3990849063a9059cbb60e01b906064016125d4565b600054610100900460ff16610af05760405162461bcd60e51b81526004016108c090613294565b600054610100900460ff166126e15760405162461bcd60e51b81526004016108c090613294565b610af061299c565b600054610100900460ff166127105760405162461bcd60e51b81526004016108c090613294565b610af06129c3565b610ac68282612429565b600080600061013554610134546101335461273d9190613177565b6127479190613177565b9050600061012e60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561279f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c391906131d6565b919491935090915050565b60006001600160e01b03198216637965db0b60e01b14806107f357506301ffc9a760e01b6001600160e01b03198316146107f3565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16610ac657612836816129f6565b612841836020612a08565b6040516020016128529291906132df565b60408051601f198184030181529082905262461bcd60e51b82526108c091600401613360565b60fb5460ff16610af05760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f742070617573656400000000000000000000000060448201526064016108c0565b600061291f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612bb89092919063ffffffff16565b805190915015610a39578080602001905181019061293d9190613373565b610a395760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016108c0565b600054610100900460ff166124185760405162461bcd60e51b81526004016108c090613294565b600054610100900460ff166129ea5760405162461bcd60e51b81526004016108c090613294565b60fb805460ff19169055565b60606107f36001600160a01b03831660145b60606000612a1783600261318a565b612a22906002613177565b67ffffffffffffffff811115612a3a57612a3a612d1a565b6040519080825280601f01601f191660200182016040528015612a64576020820181803683370190505b509050600360fc1b81600081518110612a7f57612a7f613395565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612aae57612aae613395565b60200101906001600160f81b031916908160001a9053506000612ad284600261318a565b612add906001613177565b90505b6001811115612b62577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110612b1e57612b1e613395565b1a60f81b828281518110612b3457612b34613395565b60200101906001600160f81b031916908160001a90535060049490941c93612b5b816133ab565b9050612ae0565b508315612bb15760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016108c0565b9392505050565b606061085c848460008585600080866001600160a01b03168587604051612bdf91906133c2565b60006040518083038185875af1925050503d8060008114612c1c576040519150601f19603f3d011682016040523d82523d6000602084013e612c21565b606091505b5091509150612c3287838387612c3d565b979650505050505050565b60608315612cac578251600003612ca5576001600160a01b0385163b612ca55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108c0565b508161085c565b61085c8383815115612cc15781518083602001fd5b8060405162461bcd60e51b81526004016108c09190613360565b600060208284031215612ced57600080fd5b81356001600160e01b031981168114612bb157600080fd5b6001600160a01b0381168114610a1157600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612d5957612d59612d1a565b604052919050565b600082601f830112612d7257600080fd5b813567ffffffffffffffff811115612d8c57612d8c612d1a565b612d9f601f8201601f1916602001612d30565b818152846020838601011115612db457600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215612de757600080fd5b8435612df281612d05565b93506020850135612e0281612d05565b925060408501359150606085013567ffffffffffffffff811115612e2557600080fd5b612e3187828801612d61565b91505092959194509250565b600060208284031215612e4f57600080fd5b5035919050565b60008060408385031215612e6957600080fd5b823591506020830135612e7b81612d05565b809150509250929050565b600080600060608486031215612e9b57600080fd5b8335612ea681612d05565b92506020840135612eb681612d05565b929592945050506040919091013590565b60008060408385031215612eda57600080fd5b50508035926020909101359150565b600060208284031215612efb57600080fd5b8135612bb181612d05565b60008060408385031215612f1957600080fd5b8235612f2481612d05565b946020939093013593505050565b600080600060608486031215612f4757600080fd5b8335612f5281612d05565b95602085013595506040909401359392505050565b600082601f830112612f7857600080fd5b8135602067ffffffffffffffff821115612f9457612f94612d1a565b8160051b612fa3828201612d30565b9283528481018201928281019087851115612fbd57600080fd5b83870192505b84831015612c3257823582529183019190830190612fc3565b600080600080600060a08688031215612ff457600080fd5b8535612fff81612d05565b9450602086013561300f81612d05565b9350604086013567ffffffffffffffff8082111561302c57600080fd5b61303889838a01612f67565b9450606088013591508082111561304e57600080fd5b61305a89838a01612f67565b9350608088013591508082111561307057600080fd5b5061307d88828901612d61565b9150509295509295909350565b60008060008060008060c087890312156130a357600080fd5b86356130ae81612d05565b955060208701356130be81612d05565b945060408701356130ce81612d05565b935060608701356130de81612d05565b9598949750929560808101359460a0909101359350915050565b600080600080600060a0868803121561311057600080fd5b853561311b81612d05565b9450602086013561312b81612d05565b93506040860135925060608601359150608086013567ffffffffffffffff81111561315557600080fd5b61307d88828901612d61565b634e487b7160e01b600052601160045260246000fd5b808201808211156107f3576107f3613161565b80820281158282048414176107f3576107f3613161565b6000826131be57634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156107f3576107f3613161565b6000602082840312156131e857600080fd5b5051919050565b60005b8381101561320a5781810151838201526020016131f2565b50506000910152565b6000815180845261322b8160208601602086016131ef565b601f01601f19169290920160200192915050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a06080830152612c3260a0830184613213565b60006020828403121561328957600080fd5b8151612bb181612d05565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516133178160178501602088016131ef565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516133548160288401602088016131ef565b01602801949350505050565b602081526000612bb16020830184613213565b60006020828403121561338557600080fd5b81518015158114612bb157600080fd5b634e487b7160e01b600052603260045260246000fd5b6000816133ba576133ba613161565b506000190190565b600082516133d48184602087016131ef565b919091019291505056fe321163fcbab3bac890d4fb1f03b22c5c6bd95bc472ee55584937974a1db03356a2646970667358221220e87059ff6f7d5767a1ee44120bf890efa5d5a580bca71f116e2f8bb58ab0d40964736f6c63430008130033

Deployed Bytecode

0x6080604052600436106102565760003560e01c80638d676a9211610149578063c7e01ad6116100c6578063e895e1171161008a578063f23a6e6111610064578063f23a6e611461077c578063f61e0268146107a8578063f7f57ad8146107c857600080fd5b8063e895e1171461071c578063e8c5c6d31461073c578063ec8e83c01461075c57600080fd5b8063c7e01ad61461065d578063c9d375f41461067d578063d23f9a9a146106ba578063d547741f146106dc578063d7c41c79146106fc57600080fd5b8063a930daf41161010d578063a930daf4146105aa578063b5a68b81146105de578063b6b55f25146105ff578063bc197c8114610612578063bfe0c27e1461063e57600080fd5b80638d676a92146104fc57806391d148541461051c578063a217fddf14610562578063a2fb342d14610577578063a6617e781461059757600080fd5b806345e1aa3c116101d75780637bc565581161019b5780637bc565581461044e578063823cbb091461046e578063843592d3146104a75780638456cb59146104c757806387acb02c146104dc57600080fd5b806345e1aa3c146103ca57806346fe120e146103ea5780635c975abb1461040c578063643840f2146104245780636d54294b1461043757600080fd5b80632e1a7d4d1161021e5780632e1a7d4d146103335780632f2ff15d1461035557806336568abe146103755780633f4ba83a14610395578063404da783146103aa57600080fd5b806301ffc9a71461025b578063037d69f5146102905780630bdb92c0146102b5578063150b7a02146102ca578063248a9ca314610303575b600080fd5b34801561026757600080fd5b5061027b610276366004612cdb565b6107e8565b60405190151581526020015b60405180910390f35b34801561029c57600080fd5b506102a76101325481565b604051908152602001610287565b3480156102c157600080fd5b506102a76107f9565b3480156102d657600080fd5b506102ea6102e5366004612dd1565b610853565b6040516001600160e01b03199091168152602001610287565b34801561030f57600080fd5b506102a761031e366004612e3d565b60009081526065602052604090206001015490565b34801561033f57600080fd5b5061035361034e366004612e3d565b610864565b005b34801561036157600080fd5b50610353610370366004612e56565b610a14565b34801561038157600080fd5b50610353610390366004612e56565b610a3e565b3480156103a157600080fd5b50610353610aca565b3480156103b657600080fd5b506103536103c5366004612e3d565b610af2565b3480156103d657600080fd5b506103536103e5366004612e86565b610bcb565b3480156103f657600080fd5b506102a76000805160206133df83398151915281565b34801561041857600080fd5b5060fb5460ff1661027b565b610353610432366004612ec7565b610d71565b34801561044357600080fd5b506102a76101315481565b34801561045a57600080fd5b50610353610469366004612ec7565b610f1b565b34801561047a57600080fd5b5061012d5461048f906001600160a01b031681565b6040516001600160a01b039091168152602001610287565b3480156104b357600080fd5b506102a76104c2366004612ee9565b610fca565b3480156104d357600080fd5b5061035361107a565b3480156104e857600080fd5b506103536104f7366004612f06565b611095565b34801561050857600080fd5b50610353610517366004612f32565b611233565b34801561052857600080fd5b5061027b610537366004612e56565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561056e57600080fd5b506102a7600081565b34801561058357600080fd5b50610353610592366004612f06565b611434565b6103536105a5366004612ec7565b611598565b3480156105b657600080fd5b506102a77f507793b6688804c17fc033a24c049858152fd713503d8768de9c67313c5a3afd81565b3480156105ea57600080fd5b506101375461048f906001600160a01b031681565b61035361060d366004612e3d565b6116e7565b34801561061e57600080fd5b506102ea61062d366004612fdc565b63bc197c8160e01b95945050505050565b34801561064a57600080fd5b50610137546001600160a01b031661048f565b34801561066957600080fd5b50610353610678366004612e3d565b611935565b34801561068957600080fd5b5061013354610134546101355461013654604080519485526020850193909352918301526060820152608001610287565b3480156106c657600080fd5b506101385461027b90600160a01b900460ff1681565b3480156106e857600080fd5b506103536106f7366004612e56565b611a0d565b34801561070857600080fd5b5061035361071736600461308a565b611a32565b34801561072857600080fd5b50610353610737366004612e3d565b611eeb565b34801561074857600080fd5b506102a7610757366004612e3d565b611f48565b34801561076857600080fd5b50610353610777366004612f06565b611f7e565b34801561078857600080fd5b506102ea6107973660046130f8565b63f23a6e6160e01b95945050505050565b3480156107b457600080fd5b506102a76107c3366004612e3d565b61216d565b3480156107d457600080fd5b506103536107e3366004612e3d565b612199565b60006107f38261226b565b92915050565b6000806127106101315461013554610134546108159190613177565b61081f919061318a565b61082991906131a1565b90508061013354111561084b57806101335461084591906131c3565b91505090565b600091505090565b630a85bd0160e11b5b949350505050565b61086c612290565b6108746122e9565b600081116108c95760405162461bcd60e51b815260206004820152601960248201527f4e6f6e2d706f73697469766520746f6b656e20616d6f756e740000000000000060448201526064015b60405180910390fd5b60006108d433610fca565b9050808211156109365760405162461bcd60e51b815260206004820152602760248201527f4e6f7420656e6f756768206163746976652062616c616e636520696e204379616044820152661b8815985d5b1d60ca1b60648201526084016108c0565b60006109418361216d565b905080610133600082825461095691906131c3565b909155505061012e54604051632770a7eb60e21b8152336004820152602481018590526001600160a01b0390911690639dc29fac90604401600060405180830381600087803b1580156109a857600080fd5b505af11580156109bc573d6000803e3d6000fd5b505050506109ca338261233c565b604080518281526020810185905233917ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568910160405180910390a25050610a116001609755565b50565b600082815260656020526040902060010154610a2f8161241f565b610a398383612429565b505050565b6001600160a01b0381163314610abc5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016108c0565b610ac682826124cb565b5050565b610ad2612290565b6000610add8161241f565b610ae561254e565b50610af06001609755565b565b610afa612290565b6000610b058161241f565b612710821115610b7d5760405162461bcd60e51b815260206004820152603a60248201527f5361666574792066756e642070657263656e74206d757374206265206571756160448201527f6c206f72206c657373207468616e203130302070657263656e7400000000000060648201526084016108c0565b6101315460408051918252602082018490527feeeb5af1c3ceeab4fb8414a031926b58ba0e9b17d71c2ade80057757e6cb0260910160405180910390a150610131819055610a116001609755565b610bd3612290565b6000805160206133df833981519152610beb8161241f565b610137546001600160a01b0390811690851603610c4a5760405162461bcd60e51b815260206004820152601e60248201527f43616e6e6f742077697468647261772063757272656e637920746f6b656e000060448201526064016108c0565b604051636eb1769f60e11b81526001600160a01b0384811660048301523060248301528591849183169063dd62ed3e90604401602060405180830381865afa158015610c9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cbe91906131d6565b1015610d0c5760405162461bcd60e51b815260206004820152601a60248201527f455243323020616c6c6f77616e6365206e6f7420656e6f75676800000000000060448201526064016108c0565b610d216001600160a01b0382168533866125a0565b60408051338152602081018590526001600160a01b038716917fa14466d832b5a1ff01be72c58e51196498a8e10751ab9c227fe73c4730dedc41910160405180910390a25050610a396001609755565b610d79612290565b7f507793b6688804c17fc033a24c049858152fd713503d8768de9c67313c5a3afd610da38161241f565b61013854600160a01b900460ff1615610e00573415610dfb5760405162461bcd60e51b815260206004820152601460248201527315dc9bdb99c81d1c985b99995c88185b5bdd5b9d60621b60448201526064016108c0565b610e4f565b610e0a8284613177565b3414610e4f5760405162461bcd60e51b815260206004820152601460248201527315dc9bdb99c81d1c985b99995c88185b5bdd5b9d60621b60448201526064016108c0565b61013854600160a01b900460ff1615610e8657610e863330610e718587613177565b610138546001600160a01b03169291906125a0565b610e908284613177565b6101336000828254610ea29190613177565b9091555050610134548311610ecf57826101346000828254610ec491906131c3565b90915550610ed69050565b6000610134555b60408051848152602081018490527f5850d758e6151f474c145f4f59e8cb315c3f1a9fe82d96dff5bd2d48b5a76f9b91015b60405180910390a150610ac66001609755565b610f23612290565b7f507793b6688804c17fc033a24c049858152fd713503d8768de9c67313c5a3afd610f4d8161241f565b816101356000828254610f609190613177565b9091555050610134548311610f8d57826101346000828254610f8291906131c3565b90915550610f949050565b6000610134555b60408051848152602081018490527f9b8376ea2c5e9863179edf3c51616d423d51e32eea3ca2e7a02ce8a3d3aa01429101610f08565b61012e546040516370a0823160e01b81526001600160a01b03838116600483015260009283929116906370a0823190602401602060405180830381865afa158015611019573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103d91906131d6565b9050600061104a8261216d565b905060006110566107f9565b90508082116110685750909392505050565b61107181611f48565b95945050505050565b611082612290565b600061108d8161241f565b610ae5612626565b61109d612290565b6000805160206133df8339815191526110b58161241f565b610137546001600160a01b03908116908416036111145760405162461bcd60e51b815260206004820152601e60248201527f43616e6e6f742077697468647261772063757272656e637920746f6b656e000060448201526064016108c0565b6040516370a0823160e01b8152306004820152839083906001600160a01b038316906370a0823190602401602060405180830381865afa15801561115c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118091906131d6565b10156111ce5760405162461bcd60e51b815260206004820152601860248201527f45524332302062616c616e6365206e6f7420656e6f756768000000000000000060448201526064016108c0565b6111e26001600160a01b0382163385612663565b60408051338152602081018590526001600160a01b038616917fa14466d832b5a1ff01be72c58e51196498a8e10751ab9c227fe73c4730dedc4191015b60405180910390a25050610ac66001609755565b61123b612290565b6112436122e9565b6000805160206133df83398151915261125b8161241f565b6001600160a01b0384166112a95760405162461bcd60e51b81526020600482015260156024820152745a65726f20636f6e7472616374206164647265737360581b60448201526064016108c0565b604051627eeac760e11b815230600482015260248101849052849083906001600160a01b0383169062fdd58e90604401602060405180830381865afa1580156112f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131a91906131d6565b10156113685760405162461bcd60e51b815260206004820181905260248201527f5661756c7420646f6573206e6f74206861766520656e6f75676820746f6b656e60448201526064016108c0565b60408051602081018252600081529051637921219560e11b81526001600160a01b0383169163f242432a916113a891309133918a918a919060040161323f565b600060405180830381600087803b1580156113c257600080fd5b505af11580156113d6573d6000803e3d6000fd5b5050505083856001600160a01b0316336001600160a01b03167f07394b3fad6920c344c25134bb6cf65ee1313a0296830f2043653661beb4136d8660405161142091815260200190565b60405180910390a45050610a396001609755565b61143c612290565b6114446122e9565b7f507793b6688804c17fc033a24c049858152fd713503d8768de9c67313c5a3afd61146e8161241f565b6001600160a01b0383166114c45760405162461bcd60e51b815260206004820152601960248201527f746f20616464726573732063616e6e6f74206265207a65726f0000000000000060448201526064016108c0565b60006114ce6107f9565b9050808311156115205760405162461bcd60e51b815260206004820152601f60248201527f4e6f7420656e6f7567682062616c616e636520696e20746865205661756c740060448201526064016108c0565b8261013460008282546115339190613177565b9250508190555082610133600082825461154d91906131c3565b9091555061155d9050848461233c565b836001600160a01b03167f41b123d2493c7b2067b8b7f49cf71532523d83ead11494d793531ece1fd4d0468460405161121f91815260200190565b6115a06122e9565b6000805160206133df8339815191526115b88161241f565b61013854600160a01b900460ff16156116175734156116125760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a590819195c1bdcda5d08185b5bdd5b9d60521b60448201526064016108c0565b61165f565b82341461165f5760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a590819195c1bdcda5d08185b5bdd5b9d60521b60448201526064016108c0565b61013854600160a01b900460ff161561168b576101385461168b906001600160a01b03163330866125a0565b82610133600082825461169e9190613177565b909155505061013582905560408051848152602081018490527f3310b86842fde17f760398e1219d8d61221bdffe0c33e5635830eaaf2f213ddb910160405180910390a1505050565b6116ef612290565b6116f76122e9565b600081116117475760405162461bcd60e51b815260206004820152601b60248201527f4d757374206465706f736974206d6f7265207468616e207a65726f000000000060448201526064016108c0565b61013854600160a01b900460ff16156117a65734156117a15760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a590819195c1bdcda5d08185b5bdd5b9d60521b60448201526064016108c0565b6117ee565b8034146117ee5760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a590819195c1bdcda5d08185b5bdd5b9d60521b60448201526064016108c0565b60006127106101325483611802919061318a565b61180c91906131a1565b9050600061181a82846131c3565b9050600061182782611f48565b61013854909150600160a01b900460ff16156118565761013854611856906001600160a01b03163330876125a0565b8161013360008282546118699190613177565b925050819055508261013660008282546118839190613177565b909155505061012e546040516340c10f1960e01b8152336004820152602481018390526001600160a01b03909116906340c10f1990604401600060405180830381600087803b1580156118d557600080fd5b505af11580156118e9573d6000803e3d6000fd5b505060408051858152602081018590523393507f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1592500160405180910390a2505050610a116001609755565b61193d612290565b60006119488161241f565b60c88211156119bf5760405162461bcd60e51b815260206004820152603660248201527f53657276696365206665652070657263656e74206d757374206e6f742062652060448201527f67726561746572207468616e20322070657263656e740000000000000000000060648201526084016108c0565b6101325460408051918252602082018490527f67ea558a1975802c885d7e38bc96ea4f925e1d5d86c8f53ad1a8387906297a90910160405180910390a150610132819055610a116001609755565b600082815260656020526040902060010154611a288161241f565b610a3983836124cb565b600054610100900460ff1615808015611a525750600054600160ff909116105b80611a6c5750303b158015611a6c575060005460ff166001145b611ade5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016108c0565b6000805460ff191660011790558015611b01576000805461ff0019166101001790555b6001600160a01b038716611b675760405162461bcd60e51b815260206004820152602760248201527f4379616e205661756c7420546f6b656e20616464726573732063616e6e6f74206044820152666265207a65726f60c81b60648201526084016108c0565b6001600160a01b038516611bce5760405162461bcd60e51b815260206004820152602860248201527f4379616e205061796d656e7420506c616e20616464726573732063616e6e6f74604482015267206265207a65726f60c01b60648201526084016108c0565b6001600160a01b038416611c345760405162461bcd60e51b815260206004820152602760248201527f4379616e2053757065722041646d696e20616464726573732063616e6e6f74206044820152666265207a65726f60c81b60648201526084016108c0565b612710831115611cac5760405162461bcd60e51b815260206004820152603a60248201527f5361666574792066756e642070657263656e74206d757374206265206571756160448201527f6c206f72206c657373207468616e203130302070657263656e7400000000000060648201526084016108c0565b60c8821115611d235760405162461bcd60e51b815260206004820152603660248201527f53657276696365206665652070657263656e74206d757374206e6f742062652060448201527f67726561746572207468616e20322070657263656e740000000000000000000060648201526084016108c0565b611d2b612693565b611d336126ba565b611d3b612693565b611d436126e9565b61012d80546001600160a01b03808a1673ffffffffffffffffffffffffffffffffffffffff19928316811790935561012e805483169093179092556101378054928916929091168217905515611dc857610138805474ffffffffffffffffffffffffffffffffffffffffff19166001600160a01b03881617600160a01b179055611dd7565b610138805460ff60a01b191690555b6101318390556101328290556000610134819055610135819055610133819055611e019085612718565b611e0c600033612718565b611e367f507793b6688804c17fc033a24c049858152fd713503d8768de9c67313c5a3afd86612718565b6040518281527f9946eeb5f4ca76305e83426173176fffd327e46ff4ac0e853f1806a8a6accb879060200160405180910390a16040518381527f183d0700d6a3fbe1d9843804c26a1fad21802c73c8976b4945f947600230b2679060200160405180910390a18015611ee2576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b611ef36122e9565b6000805160206133df833981519152611f0b8161241f565b6101358290556040518281527f897bbee971dc0a064ca7156866801787a25be91f42b7aab8e91a953974d274a19060200160405180910390a15050565b6000806000611f55612722565b9150915081600003611f6957509192915050565b81611f74828661318a565b61085c91906131a1565b611f86612290565b611f8e6122e9565b6000805160206133df833981519152611fa68161241f565b6001600160a01b038316611ff45760405162461bcd60e51b81526020600482015260156024820152745a65726f20636f6e7472616374206164647265737360581b60448201526064016108c0565b6040516331a9108f60e11b815260048101839052839030906001600160a01b03831690636352211e90602401602060405180830381865afa15801561203d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120619190613277565b6001600160a01b0316146120c35760405162461bcd60e51b815260206004820152602360248201527f5661756c74206973206e6f7420746865206f776e6572206f662074686520746f60448201526235b2b760e91b60648201526084016108c0565b604051632142170760e11b8152306004820152336024820152604481018490526001600160a01b038216906342842e0e90606401600060405180830381600087803b15801561211157600080fd5b505af1158015612125573d6000803e3d6000fd5b50506040518592506001600160a01b038716915033907f8c6ca3d9b6a0c7bebfa8490b1b23bd368f29583611fadb449ff9ff56a33d94dd90600090a45050610ac66001609755565b600080600061217a612722565b915091508060000361218e57509192915050565b80611f74838661318a565b6121a1612290565b60006121ac8161241f565b610136548211156121ff5760405162461bcd60e51b815260206004820181905260248201527f4e6f7420656e6f75676820636f6c6c656374656420736572766963652066656560448201526064016108c0565b81610136600082825461221291906131c3565b909155506122229050338361233c565b610136546040805184815260208101929092527fe5b03f691ac58372304b24b638e1a4e106a14e996edc607b7a21ad492e2ca7c9910160405180910390a150610a116001609755565b60006001600160e01b03198216630271189760e51b14806107f357506107f3826127ce565b6002609754036122e25760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016108c0565b6002609755565b60fb5460ff1615610af05760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064016108c0565b61013854600160a01b900460ff16156123675761013854610ac6906001600160a01b03168383612663565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146123b4576040519150601f19603f3d011682016040523d82523d6000602084013e6123b9565b606091505b5050905080610a395760405162461bcd60e51b815260206004820152602560248201527f5061796d656e74206661696c65643a204e617469766520746f6b656e207472616044820152643739b332b960d91b60648201526084016108c0565b6001609755565b610a118133612803565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16610ac65760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556124873390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff1615610ac65760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b612556612878565b60fb805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040516001600160a01b03808516602483015283166044820152606481018290526126209085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b0319909316929092179091526128ca565b50505050565b61262e6122e9565b60fb805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586125833390565b6040516001600160a01b038316602482015260448101829052610a3990849063a9059cbb60e01b906064016125d4565b600054610100900460ff16610af05760405162461bcd60e51b81526004016108c090613294565b600054610100900460ff166126e15760405162461bcd60e51b81526004016108c090613294565b610af061299c565b600054610100900460ff166127105760405162461bcd60e51b81526004016108c090613294565b610af06129c3565b610ac68282612429565b600080600061013554610134546101335461273d9190613177565b6127479190613177565b9050600061012e60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561279f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c391906131d6565b919491935090915050565b60006001600160e01b03198216637965db0b60e01b14806107f357506301ffc9a760e01b6001600160e01b03198316146107f3565b60008281526065602090815260408083206001600160a01b038516845290915290205460ff16610ac657612836816129f6565b612841836020612a08565b6040516020016128529291906132df565b60408051601f198184030181529082905262461bcd60e51b82526108c091600401613360565b60fb5460ff16610af05760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f742070617573656400000000000000000000000060448201526064016108c0565b600061291f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612bb89092919063ffffffff16565b805190915015610a39578080602001905181019061293d9190613373565b610a395760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016108c0565b600054610100900460ff166124185760405162461bcd60e51b81526004016108c090613294565b600054610100900460ff166129ea5760405162461bcd60e51b81526004016108c090613294565b60fb805460ff19169055565b60606107f36001600160a01b03831660145b60606000612a1783600261318a565b612a22906002613177565b67ffffffffffffffff811115612a3a57612a3a612d1a565b6040519080825280601f01601f191660200182016040528015612a64576020820181803683370190505b509050600360fc1b81600081518110612a7f57612a7f613395565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110612aae57612aae613395565b60200101906001600160f81b031916908160001a9053506000612ad284600261318a565b612add906001613177565b90505b6001811115612b62577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110612b1e57612b1e613395565b1a60f81b828281518110612b3457612b34613395565b60200101906001600160f81b031916908160001a90535060049490941c93612b5b816133ab565b9050612ae0565b508315612bb15760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016108c0565b9392505050565b606061085c848460008585600080866001600160a01b03168587604051612bdf91906133c2565b60006040518083038185875af1925050503d8060008114612c1c576040519150601f19603f3d011682016040523d82523d6000602084013e612c21565b606091505b5091509150612c3287838387612c3d565b979650505050505050565b60608315612cac578251600003612ca5576001600160a01b0385163b612ca55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108c0565b508161085c565b61085c8383815115612cc15781518083602001fd5b8060405162461bcd60e51b81526004016108c09190613360565b600060208284031215612ced57600080fd5b81356001600160e01b031981168114612bb157600080fd5b6001600160a01b0381168114610a1157600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612d5957612d59612d1a565b604052919050565b600082601f830112612d7257600080fd5b813567ffffffffffffffff811115612d8c57612d8c612d1a565b612d9f601f8201601f1916602001612d30565b818152846020838601011115612db457600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215612de757600080fd5b8435612df281612d05565b93506020850135612e0281612d05565b925060408501359150606085013567ffffffffffffffff811115612e2557600080fd5b612e3187828801612d61565b91505092959194509250565b600060208284031215612e4f57600080fd5b5035919050565b60008060408385031215612e6957600080fd5b823591506020830135612e7b81612d05565b809150509250929050565b600080600060608486031215612e9b57600080fd5b8335612ea681612d05565b92506020840135612eb681612d05565b929592945050506040919091013590565b60008060408385031215612eda57600080fd5b50508035926020909101359150565b600060208284031215612efb57600080fd5b8135612bb181612d05565b60008060408385031215612f1957600080fd5b8235612f2481612d05565b946020939093013593505050565b600080600060608486031215612f4757600080fd5b8335612f5281612d05565b95602085013595506040909401359392505050565b600082601f830112612f7857600080fd5b8135602067ffffffffffffffff821115612f9457612f94612d1a565b8160051b612fa3828201612d30565b9283528481018201928281019087851115612fbd57600080fd5b83870192505b84831015612c3257823582529183019190830190612fc3565b600080600080600060a08688031215612ff457600080fd5b8535612fff81612d05565b9450602086013561300f81612d05565b9350604086013567ffffffffffffffff8082111561302c57600080fd5b61303889838a01612f67565b9450606088013591508082111561304e57600080fd5b61305a89838a01612f67565b9350608088013591508082111561307057600080fd5b5061307d88828901612d61565b9150509295509295909350565b60008060008060008060c087890312156130a357600080fd5b86356130ae81612d05565b955060208701356130be81612d05565b945060408701356130ce81612d05565b935060608701356130de81612d05565b9598949750929560808101359460a0909101359350915050565b600080600080600060a0868803121561311057600080fd5b853561311b81612d05565b9450602086013561312b81612d05565b93506040860135925060608601359150608086013567ffffffffffffffff81111561315557600080fd5b61307d88828901612d61565b634e487b7160e01b600052601160045260246000fd5b808201808211156107f3576107f3613161565b80820281158282048414176107f3576107f3613161565b6000826131be57634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156107f3576107f3613161565b6000602082840312156131e857600080fd5b5051919050565b60005b8381101561320a5781810151838201526020016131f2565b50506000910152565b6000815180845261322b8160208601602086016131ef565b601f01601f19169290920160200192915050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a06080830152612c3260a0830184613213565b60006020828403121561328957600080fd5b8151612bb181612d05565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516133178160178501602088016131ef565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516133548160288401602088016131ef565b01602801949350505050565b602081526000612bb16020830184613213565b60006020828403121561338557600080fd5b81518015158114612bb157600080fd5b634e487b7160e01b600052603260045260246000fd5b6000816133ba576133ba613161565b506000190190565b600082516133d48184602087016131ef565b919091019291505056fe321163fcbab3bac890d4fb1f03b22c5c6bd95bc472ee55584937974a1db03356a2646970667358221220e87059ff6f7d5767a1ee44120bf890efa5d5a580bca71f116e2f8bb58ab0d40964736f6c63430008130033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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